@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,57 @@
|
|
|
1
|
+
//#region src/cli/router.ts
|
|
2
|
+
/**
|
|
3
|
+
* Top-level argv routing for the `po` binary.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately tiny and dependency-free. It answers two questions before any
|
|
6
|
+
* command module loads: which subcommand was named, and whether this run only
|
|
7
|
+
* wants help or a version. Everything else, including the harness options and
|
|
8
|
+
* the Pi passthrough, stays with `parseHarnessArgs`, which already knows the
|
|
9
|
+
* harness vocabulary and forwards what it does not own.
|
|
10
|
+
*/
|
|
11
|
+
/** Subcommands that parse their own arguments instead of passing them to Pi. */
|
|
12
|
+
const KNOWN_COMMANDS = [
|
|
13
|
+
"init",
|
|
14
|
+
"sync",
|
|
15
|
+
"api-export",
|
|
16
|
+
"compat",
|
|
17
|
+
"doctor"
|
|
18
|
+
];
|
|
19
|
+
const HELP_FLAGS = ["--help", "-h"];
|
|
20
|
+
const VERSION_FLAGS = ["--version", "-v"];
|
|
21
|
+
/** Everything after this belongs to a provider or to Pi, never to po. */
|
|
22
|
+
const PASSTHROUGH_SEPARATOR = "--";
|
|
23
|
+
/**
|
|
24
|
+
* The named subcommand, or undefined when this run is a Pi invocation.
|
|
25
|
+
*
|
|
26
|
+
* Reads argv[0] only. A token later in the line is a flag value or prompt text,
|
|
27
|
+
* never a command, so scanning further would let `po --profile sync` look
|
|
28
|
+
* like a sync.
|
|
29
|
+
*/
|
|
30
|
+
function routeCommand(args) {
|
|
31
|
+
const first = args[0];
|
|
32
|
+
return first !== void 0 && KNOWN_COMMANDS.includes(first) ? first : void 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether this run asks for help or a version, before the passthrough boundary.
|
|
36
|
+
*
|
|
37
|
+
* The scan stops at the first bare `--` so a provider's own `--help` reaches
|
|
38
|
+
* the provider rather than printing po's help and exiting.
|
|
39
|
+
*/
|
|
40
|
+
function informationalRequest(args) {
|
|
41
|
+
for (const argument of args) {
|
|
42
|
+
if (argument === PASSTHROUGH_SEPARATOR) return void 0;
|
|
43
|
+
if (HELP_FLAGS.includes(argument)) return "help";
|
|
44
|
+
if (VERSION_FLAGS.includes(argument)) return "version";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Convenience for a subcommand that only needs to know whether to print help. */
|
|
48
|
+
function wantsHelp(args) {
|
|
49
|
+
return informationalRequest(args) === "help";
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.KNOWN_COMMANDS = KNOWN_COMMANDS;
|
|
53
|
+
exports.informationalRequest = informationalRequest;
|
|
54
|
+
exports.routeCommand = routeCommand;
|
|
55
|
+
exports.wantsHelp = wantsHelp;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=router.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.cjs","names":[],"sources":["../../../src/cli/router.ts"],"sourcesContent":["/**\n * Top-level argv routing for the `po` binary.\n *\n * Deliberately tiny and dependency-free. It answers two questions before any\n * command module loads: which subcommand was named, and whether this run only\n * wants help or a version. Everything else, including the harness options and\n * the Pi passthrough, stays with `parseHarnessArgs`, which already knows the\n * harness vocabulary and forwards what it does not own.\n */\n\n/** Subcommands that parse their own arguments instead of passing them to Pi. */\nexport const KNOWN_COMMANDS = ['init', 'sync', 'api-export', 'compat', 'doctor'] as const;\n\nexport type KnownCommand = (typeof KNOWN_COMMANDS)[number];\n\nconst HELP_FLAGS = ['--help', '-h'];\nconst VERSION_FLAGS = ['--version', '-v'];\n/** Everything after this belongs to a provider or to Pi, never to po. */\nconst PASSTHROUGH_SEPARATOR = '--';\n\n/**\n * The named subcommand, or undefined when this run is a Pi invocation.\n *\n * Reads argv[0] only. A token later in the line is a flag value or prompt text,\n * never a command, so scanning further would let `po --profile sync` look\n * like a sync.\n */\nexport function routeCommand(args: readonly string[]): KnownCommand | undefined {\n const first = args[0];\n return first !== undefined && (KNOWN_COMMANDS as readonly string[]).includes(first)\n ? (first as KnownCommand)\n : undefined;\n}\n\n/**\n * Whether this run asks for help or a version, before the passthrough boundary.\n *\n * The scan stops at the first bare `--` so a provider's own `--help` reaches\n * the provider rather than printing po's help and exiting.\n */\nexport function informationalRequest(args: readonly string[]): 'help' | 'version' | undefined {\n for (const argument of args) {\n if (argument === PASSTHROUGH_SEPARATOR) return undefined;\n if (HELP_FLAGS.includes(argument)) return 'help';\n if (VERSION_FLAGS.includes(argument)) return 'version';\n }\n return undefined;\n}\n\n/** Convenience for a subcommand that only needs to know whether to print help. */\nexport function wantsHelp(args: readonly string[]): boolean {\n return informationalRequest(args) === 'help';\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,iBAAiB;CAAC;CAAQ;CAAQ;CAAc;CAAU;AAAQ;AAI/E,MAAM,aAAa,CAAC,UAAU,IAAI;AAClC,MAAM,gBAAgB,CAAC,aAAa,IAAI;;AAExC,MAAM,wBAAwB;;;;;;;;AAS9B,SAAgB,aAAa,MAAmD;CAC9E,MAAM,QAAQ,KAAK;CACnB,OAAO,UAAU,KAAA,KAAc,eAAqC,SAAS,KAAK,IAC7E,QACD,KAAA;AACN;;;;;;;AAQA,SAAgB,qBAAqB,MAAyD;CAC5F,KAAK,MAAM,YAAY,MAAM;EAC3B,IAAI,aAAa,uBAAuB,OAAO,KAAA;EAC/C,IAAI,WAAW,SAAS,QAAQ,GAAG,OAAO;EAC1C,IAAI,cAAc,SAAS,QAAQ,GAAG,OAAO;CAC/C;AAEF;;AAGA,SAAgB,UAAU,MAAkC;CAC1D,OAAO,qBAAqB,IAAI,MAAM;AACxC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/cli/router.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Top-level argv routing for the `po` binary.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately tiny and dependency-free. It answers two questions before any
|
|
6
|
+
* command module loads: which subcommand was named, and whether this run only
|
|
7
|
+
* wants help or a version. Everything else, including the harness options and
|
|
8
|
+
* the Pi passthrough, stays with `parseHarnessArgs`, which already knows the
|
|
9
|
+
* harness vocabulary and forwards what it does not own.
|
|
10
|
+
*/
|
|
11
|
+
/** Subcommands that parse their own arguments instead of passing them to Pi. */
|
|
12
|
+
export declare const KNOWN_COMMANDS: readonly ['init', 'sync', 'api-export', 'compat', 'doctor'];
|
|
13
|
+
export type KnownCommand = (typeof KNOWN_COMMANDS)[number];
|
|
14
|
+
/**
|
|
15
|
+
* The named subcommand, or undefined when this run is a Pi invocation.
|
|
16
|
+
*
|
|
17
|
+
* Reads argv[0] only. A token later in the line is a flag value or prompt text,
|
|
18
|
+
* never a command, so scanning further would let `po --profile sync` look
|
|
19
|
+
* like a sync.
|
|
20
|
+
*/
|
|
21
|
+
export declare function routeCommand(args: readonly string[]): KnownCommand | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Whether this run asks for help or a version, before the passthrough boundary.
|
|
24
|
+
*
|
|
25
|
+
* The scan stops at the first bare `--` so a provider's own `--help` reaches
|
|
26
|
+
* the provider rather than printing po's help and exiting.
|
|
27
|
+
*/
|
|
28
|
+
export declare function informationalRequest(args: readonly string[]): 'help' | 'version' | undefined;
|
|
29
|
+
/** Convenience for a subcommand that only needs to know whether to print help. */
|
|
30
|
+
export declare function wantsHelp(args: readonly string[]): boolean;
|
|
31
|
+
//#endregion
|
|
32
|
+
//# sourceMappingURL=router.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.mts","names":[],"sources":["../../../src/cli/router.ts"],"mappings":";;;;;;;;;;;qBAWa;YAED,uBAAuB;;;;;;;;wBAcnB,aAAa,0BAA0B;;;;;;;wBAavC,qBAAqB;;wBAUrB,UAAU"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/cli/router.ts
|
|
2
|
+
/**
|
|
3
|
+
* Top-level argv routing for the `po` binary.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately tiny and dependency-free. It answers two questions before any
|
|
6
|
+
* command module loads: which subcommand was named, and whether this run only
|
|
7
|
+
* wants help or a version. Everything else, including the harness options and
|
|
8
|
+
* the Pi passthrough, stays with `parseHarnessArgs`, which already knows the
|
|
9
|
+
* harness vocabulary and forwards what it does not own.
|
|
10
|
+
*/
|
|
11
|
+
/** Subcommands that parse their own arguments instead of passing them to Pi. */
|
|
12
|
+
const KNOWN_COMMANDS = [
|
|
13
|
+
"init",
|
|
14
|
+
"sync",
|
|
15
|
+
"api-export",
|
|
16
|
+
"compat",
|
|
17
|
+
"doctor"
|
|
18
|
+
];
|
|
19
|
+
const HELP_FLAGS = ["--help", "-h"];
|
|
20
|
+
const VERSION_FLAGS = ["--version", "-v"];
|
|
21
|
+
/** Everything after this belongs to a provider or to Pi, never to po. */
|
|
22
|
+
const PASSTHROUGH_SEPARATOR = "--";
|
|
23
|
+
/**
|
|
24
|
+
* The named subcommand, or undefined when this run is a Pi invocation.
|
|
25
|
+
*
|
|
26
|
+
* Reads argv[0] only. A token later in the line is a flag value or prompt text,
|
|
27
|
+
* never a command, so scanning further would let `po --profile sync` look
|
|
28
|
+
* like a sync.
|
|
29
|
+
*/
|
|
30
|
+
function routeCommand(args) {
|
|
31
|
+
const first = args[0];
|
|
32
|
+
return first !== void 0 && KNOWN_COMMANDS.includes(first) ? first : void 0;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether this run asks for help or a version, before the passthrough boundary.
|
|
36
|
+
*
|
|
37
|
+
* The scan stops at the first bare `--` so a provider's own `--help` reaches
|
|
38
|
+
* the provider rather than printing po's help and exiting.
|
|
39
|
+
*/
|
|
40
|
+
function informationalRequest(args) {
|
|
41
|
+
for (const argument of args) {
|
|
42
|
+
if (argument === PASSTHROUGH_SEPARATOR) return void 0;
|
|
43
|
+
if (HELP_FLAGS.includes(argument)) return "help";
|
|
44
|
+
if (VERSION_FLAGS.includes(argument)) return "version";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Convenience for a subcommand that only needs to know whether to print help. */
|
|
48
|
+
function wantsHelp(args) {
|
|
49
|
+
return informationalRequest(args) === "help";
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { KNOWN_COMMANDS, informationalRequest, routeCommand, wantsHelp };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=router.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.mjs","names":[],"sources":["../../../src/cli/router.ts"],"sourcesContent":["/**\n * Top-level argv routing for the `po` binary.\n *\n * Deliberately tiny and dependency-free. It answers two questions before any\n * command module loads: which subcommand was named, and whether this run only\n * wants help or a version. Everything else, including the harness options and\n * the Pi passthrough, stays with `parseHarnessArgs`, which already knows the\n * harness vocabulary and forwards what it does not own.\n */\n\n/** Subcommands that parse their own arguments instead of passing them to Pi. */\nexport const KNOWN_COMMANDS = ['init', 'sync', 'api-export', 'compat', 'doctor'] as const;\n\nexport type KnownCommand = (typeof KNOWN_COMMANDS)[number];\n\nconst HELP_FLAGS = ['--help', '-h'];\nconst VERSION_FLAGS = ['--version', '-v'];\n/** Everything after this belongs to a provider or to Pi, never to po. */\nconst PASSTHROUGH_SEPARATOR = '--';\n\n/**\n * The named subcommand, or undefined when this run is a Pi invocation.\n *\n * Reads argv[0] only. A token later in the line is a flag value or prompt text,\n * never a command, so scanning further would let `po --profile sync` look\n * like a sync.\n */\nexport function routeCommand(args: readonly string[]): KnownCommand | undefined {\n const first = args[0];\n return first !== undefined && (KNOWN_COMMANDS as readonly string[]).includes(first)\n ? (first as KnownCommand)\n : undefined;\n}\n\n/**\n * Whether this run asks for help or a version, before the passthrough boundary.\n *\n * The scan stops at the first bare `--` so a provider's own `--help` reaches\n * the provider rather than printing po's help and exiting.\n */\nexport function informationalRequest(args: readonly string[]): 'help' | 'version' | undefined {\n for (const argument of args) {\n if (argument === PASSTHROUGH_SEPARATOR) return undefined;\n if (HELP_FLAGS.includes(argument)) return 'help';\n if (VERSION_FLAGS.includes(argument)) return 'version';\n }\n return undefined;\n}\n\n/** Convenience for a subcommand that only needs to know whether to print help. */\nexport function wantsHelp(args: readonly string[]): boolean {\n return informationalRequest(args) === 'help';\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,iBAAiB;CAAC;CAAQ;CAAQ;CAAc;CAAU;AAAQ;AAI/E,MAAM,aAAa,CAAC,UAAU,IAAI;AAClC,MAAM,gBAAgB,CAAC,aAAa,IAAI;;AAExC,MAAM,wBAAwB;;;;;;;;AAS9B,SAAgB,aAAa,MAAmD;CAC9E,MAAM,QAAQ,KAAK;CACnB,OAAO,UAAU,KAAA,KAAc,eAAqC,SAAS,KAAK,IAC7E,QACD,KAAA;AACN;;;;;;;AAQA,SAAgB,qBAAqB,MAAyD;CAC5F,KAAK,MAAM,YAAY,MAAM;EAC3B,IAAI,aAAa,uBAAuB,OAAO,KAAA;EAC/C,IAAI,WAAW,SAAS,QAAQ,GAAG,OAAO;EAC1C,IAAI,cAAc,SAAS,QAAQ,GAAG,OAAO;CAC/C;AAEF;;AAGA,SAAgB,UAAU,MAAkC;CAC1D,OAAO,qBAAqB,IAAI,MAAM;AACxC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require("../../builders/server/sessionArguments.cjs");
|
|
2
|
+
//#region src/cli/server/options.ts
|
|
3
|
+
const TOKEN_FILE_OPTION = "--auth-token-file";
|
|
4
|
+
const WEB_OPTION = "--web";
|
|
5
|
+
const NAME_OPTION = "--name";
|
|
6
|
+
const SESSION_ID_OPTION = "--session-id";
|
|
7
|
+
const AGENT_SEPARATOR = "--";
|
|
8
|
+
const DEFAULT_WEB_PORT = 7533;
|
|
9
|
+
const DEFAULT_SESSION_NAME = "untitled";
|
|
10
|
+
const SERVE_USAGE = `po-server ${TOKEN_FILE_OPTION} <file> [--no-session] [${NAME_OPTION} <name>] [${SESSION_ID_OPTION} <id>] [${WEB_OPTION} [port]] [${AGENT_SEPARATOR} <agent arguments>]`;
|
|
11
|
+
/**
|
|
12
|
+
* Parses the server's own arguments, leaving the agent's untouched.
|
|
13
|
+
*
|
|
14
|
+
* The token is read from a file rather than a flag because command arguments are visible to other local processes.
|
|
15
|
+
*/
|
|
16
|
+
function parseServeOptions(argv) {
|
|
17
|
+
let noSession = false;
|
|
18
|
+
let tokenFile;
|
|
19
|
+
let webPort = DEFAULT_WEB_PORT;
|
|
20
|
+
let sessionName;
|
|
21
|
+
let sessionId;
|
|
22
|
+
const agentArgs = [];
|
|
23
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
24
|
+
const argument = argv[index];
|
|
25
|
+
if (argument === "--no-session") {
|
|
26
|
+
noSession = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (argument === AGENT_SEPARATOR) {
|
|
30
|
+
agentArgs.push(...argv.slice(index + 1));
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
if (argument === WEB_OPTION) {
|
|
34
|
+
const value = argv[index + 1];
|
|
35
|
+
if (value !== void 0 && /^\d+$/u.test(value)) {
|
|
36
|
+
const parsed = Number.parseInt(value, 10);
|
|
37
|
+
if (parsed < 1 || parsed > 65535) throw new Error(`${WEB_OPTION} expects a port number, received "${value}".`);
|
|
38
|
+
webPort = parsed;
|
|
39
|
+
index += 1;
|
|
40
|
+
} else webPort = DEFAULT_WEB_PORT;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (argument === TOKEN_FILE_OPTION || argument === NAME_OPTION || argument === SESSION_ID_OPTION) {
|
|
44
|
+
const value = argv[index + 1];
|
|
45
|
+
if (value === void 0 || value.startsWith("-")) throw new Error(`${argument} requires a value.`);
|
|
46
|
+
if (argument === TOKEN_FILE_OPTION) tokenFile = value;
|
|
47
|
+
else if (argument === NAME_OPTION) sessionName = value;
|
|
48
|
+
else {
|
|
49
|
+
if (value.includes("/")) throw new Error(`${SESSION_ID_OPTION} must not contain "/".`);
|
|
50
|
+
sessionId = value;
|
|
51
|
+
}
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Unknown option ${argument}. Usage: ${SERVE_USAGE}`);
|
|
56
|
+
}
|
|
57
|
+
if (!tokenFile) throw new Error(`${TOKEN_FILE_OPTION} is required. Usage: ${SERVE_USAGE}`);
|
|
58
|
+
return {
|
|
59
|
+
...noSession ? { noSession: true } : {},
|
|
60
|
+
tokenFile,
|
|
61
|
+
agentArgs,
|
|
62
|
+
webPort,
|
|
63
|
+
sessionName: sessionName ?? DEFAULT_SESSION_NAME,
|
|
64
|
+
sessionId
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
exports.SERVE_USAGE = SERVE_USAGE;
|
|
69
|
+
exports.parseServeOptions = parseServeOptions;
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=options.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.cjs","names":[],"sources":["../../../../src/cli/server/options.ts"],"sourcesContent":["import type { ServeOptions } from '../../builders/server/types';\nexport type { ServeOptions } from '../../builders/server/types';\nexport {\n resolveSessionIdentity,\n relaunchAgentArgs,\n type SessionIdentity,\n} from '../../builders/server/sessionArguments';\nconst TOKEN_FILE_OPTION = '--auth-token-file';\nconst WEB_OPTION = '--web';\nconst NAME_OPTION = '--name';\nconst SESSION_ID_OPTION = '--session-id';\nconst AGENT_SEPARATOR = '--';\nconst DEFAULT_WEB_PORT = 7533;\nconst DEFAULT_SESSION_NAME = 'untitled';\n\nexport const SERVE_USAGE = `po-server ${TOKEN_FILE_OPTION} <file> [--no-session] [${NAME_OPTION} <name>] [${SESSION_ID_OPTION} <id>] [${WEB_OPTION} [port]] [${AGENT_SEPARATOR} <agent arguments>]`;\n\n/**\n * Parses the server's own arguments, leaving the agent's untouched.\n *\n * The token is read from a file rather than a flag because command arguments are visible to other local processes.\n */\nexport function parseServeOptions(argv: readonly string[]): ServeOptions {\n let noSession = false;\n let tokenFile: string | undefined;\n let webPort = DEFAULT_WEB_PORT;\n let sessionName: string | undefined;\n let sessionId: string | undefined;\n const agentArgs: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const argument = argv[index];\n if (argument === '--no-session') {\n noSession = true;\n continue;\n }\n if (argument === AGENT_SEPARATOR) {\n agentArgs.push(...argv.slice(index + 1));\n break;\n }\n if (argument === WEB_OPTION) {\n // The port is optional, so only consume the next token when it reads as\n // one; otherwise it belongs to whatever flag follows.\n const value = argv[index + 1];\n if (value !== undefined && /^\\d+$/u.test(value)) {\n const parsed = Number.parseInt(value, 10);\n if (parsed < 1 || parsed > 65535) throw new Error(`${WEB_OPTION} expects a port number, received \"${value}\".`);\n webPort = parsed;\n index += 1;\n } else {\n webPort = DEFAULT_WEB_PORT;\n }\n continue;\n }\n if (argument === TOKEN_FILE_OPTION || argument === NAME_OPTION || argument === SESSION_ID_OPTION) {\n const value = argv[index + 1];\n if (value === undefined || value.startsWith('-')) throw new Error(`${argument} requires a value.`);\n if (argument === TOKEN_FILE_OPTION) tokenFile = value;\n else if (argument === NAME_OPTION) sessionName = value;\n else {\n if (value.includes('/')) throw new Error(`${SESSION_ID_OPTION} must not contain \"/\".`);\n sessionId = value;\n }\n index += 1;\n continue;\n }\n throw new Error(`Unknown option ${argument}. Usage: ${SERVE_USAGE}`);\n }\n\n if (!tokenFile) throw new Error(`${TOKEN_FILE_OPTION} is required. Usage: ${SERVE_USAGE}`);\n return {\n ...(noSession ? { noSession: true } : {}),\n tokenFile,\n agentArgs,\n webPort,\n sessionName: sessionName ?? DEFAULT_SESSION_NAME,\n sessionId,\n };\n}\n"],"mappings":";;AAOA,MAAM,oBAAoB;AAC1B,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAE7B,MAAa,cAAc,aAAa,kBAAkB,0BAA0B,YAAY,YAAY,kBAAkB,UAAU,WAAW,YAAY,gBAAgB;;;;;;AAO/K,SAAgB,kBAAkB,MAAuC;CACvE,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,MAAM,YAAsB,CAAC;CAE7B,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,WAAW,KAAK;EACtB,IAAI,aAAa,gBAAgB;GAC/B,YAAY;GACZ;EACF;EACA,IAAI,aAAa,iBAAiB;GAChC,UAAU,KAAK,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC;GACvC;EACF;EACA,IAAI,aAAa,YAAY;GAG3B,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,SAAS,KAAK,KAAK,GAAG;IAC/C,MAAM,SAAS,OAAO,SAAS,OAAO,EAAE;IACxC,IAAI,SAAS,KAAK,SAAS,OAAO,MAAM,IAAI,MAAM,GAAG,WAAW,oCAAoC,MAAM,GAAG;IAC7G,UAAU;IACV,SAAS;GACX,OACE,UAAU;GAEZ;EACF;EACA,IAAI,aAAa,qBAAqB,aAAa,eAAe,aAAa,mBAAmB;GAChG,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,SAAS,mBAAmB;GACjG,IAAI,aAAa,mBAAmB,YAAY;QAC3C,IAAI,aAAa,aAAa,cAAc;QAC5C;IACH,IAAI,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,kBAAkB,uBAAuB;IACrF,YAAY;GACd;GACA,SAAS;GACT;EACF;EACA,MAAM,IAAI,MAAM,kBAAkB,SAAS,WAAW,aAAa;CACrE;CAEA,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,GAAG,kBAAkB,uBAAuB,aAAa;CACzF,OAAO;EACL,GAAI,YAAY,EAAE,WAAW,KAAK,IAAI,CAAC;EACvC;EACA;EACA;EACA,aAAa,eAAe;EAC5B;CACF;AACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import "../../builders/server/sessionArguments.mjs";
|
|
2
|
+
//#region src/cli/server/options.ts
|
|
3
|
+
const TOKEN_FILE_OPTION = "--auth-token-file";
|
|
4
|
+
const WEB_OPTION = "--web";
|
|
5
|
+
const NAME_OPTION = "--name";
|
|
6
|
+
const SESSION_ID_OPTION = "--session-id";
|
|
7
|
+
const AGENT_SEPARATOR = "--";
|
|
8
|
+
const DEFAULT_WEB_PORT = 7533;
|
|
9
|
+
const DEFAULT_SESSION_NAME = "untitled";
|
|
10
|
+
const SERVE_USAGE = `po-server ${TOKEN_FILE_OPTION} <file> [--no-session] [${NAME_OPTION} <name>] [${SESSION_ID_OPTION} <id>] [${WEB_OPTION} [port]] [${AGENT_SEPARATOR} <agent arguments>]`;
|
|
11
|
+
/**
|
|
12
|
+
* Parses the server's own arguments, leaving the agent's untouched.
|
|
13
|
+
*
|
|
14
|
+
* The token is read from a file rather than a flag because command arguments are visible to other local processes.
|
|
15
|
+
*/
|
|
16
|
+
function parseServeOptions(argv) {
|
|
17
|
+
let noSession = false;
|
|
18
|
+
let tokenFile;
|
|
19
|
+
let webPort = DEFAULT_WEB_PORT;
|
|
20
|
+
let sessionName;
|
|
21
|
+
let sessionId;
|
|
22
|
+
const agentArgs = [];
|
|
23
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
24
|
+
const argument = argv[index];
|
|
25
|
+
if (argument === "--no-session") {
|
|
26
|
+
noSession = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (argument === AGENT_SEPARATOR) {
|
|
30
|
+
agentArgs.push(...argv.slice(index + 1));
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
if (argument === WEB_OPTION) {
|
|
34
|
+
const value = argv[index + 1];
|
|
35
|
+
if (value !== void 0 && /^\d+$/u.test(value)) {
|
|
36
|
+
const parsed = Number.parseInt(value, 10);
|
|
37
|
+
if (parsed < 1 || parsed > 65535) throw new Error(`${WEB_OPTION} expects a port number, received "${value}".`);
|
|
38
|
+
webPort = parsed;
|
|
39
|
+
index += 1;
|
|
40
|
+
} else webPort = DEFAULT_WEB_PORT;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (argument === TOKEN_FILE_OPTION || argument === NAME_OPTION || argument === SESSION_ID_OPTION) {
|
|
44
|
+
const value = argv[index + 1];
|
|
45
|
+
if (value === void 0 || value.startsWith("-")) throw new Error(`${argument} requires a value.`);
|
|
46
|
+
if (argument === TOKEN_FILE_OPTION) tokenFile = value;
|
|
47
|
+
else if (argument === NAME_OPTION) sessionName = value;
|
|
48
|
+
else {
|
|
49
|
+
if (value.includes("/")) throw new Error(`${SESSION_ID_OPTION} must not contain "/".`);
|
|
50
|
+
sessionId = value;
|
|
51
|
+
}
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Unknown option ${argument}. Usage: ${SERVE_USAGE}`);
|
|
56
|
+
}
|
|
57
|
+
if (!tokenFile) throw new Error(`${TOKEN_FILE_OPTION} is required. Usage: ${SERVE_USAGE}`);
|
|
58
|
+
return {
|
|
59
|
+
...noSession ? { noSession: true } : {},
|
|
60
|
+
tokenFile,
|
|
61
|
+
agentArgs,
|
|
62
|
+
webPort,
|
|
63
|
+
sessionName: sessionName ?? DEFAULT_SESSION_NAME,
|
|
64
|
+
sessionId
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { SERVE_USAGE, parseServeOptions };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.mjs","names":[],"sources":["../../../../src/cli/server/options.ts"],"sourcesContent":["import type { ServeOptions } from '../../builders/server/types';\nexport type { ServeOptions } from '../../builders/server/types';\nexport {\n resolveSessionIdentity,\n relaunchAgentArgs,\n type SessionIdentity,\n} from '../../builders/server/sessionArguments';\nconst TOKEN_FILE_OPTION = '--auth-token-file';\nconst WEB_OPTION = '--web';\nconst NAME_OPTION = '--name';\nconst SESSION_ID_OPTION = '--session-id';\nconst AGENT_SEPARATOR = '--';\nconst DEFAULT_WEB_PORT = 7533;\nconst DEFAULT_SESSION_NAME = 'untitled';\n\nexport const SERVE_USAGE = `po-server ${TOKEN_FILE_OPTION} <file> [--no-session] [${NAME_OPTION} <name>] [${SESSION_ID_OPTION} <id>] [${WEB_OPTION} [port]] [${AGENT_SEPARATOR} <agent arguments>]`;\n\n/**\n * Parses the server's own arguments, leaving the agent's untouched.\n *\n * The token is read from a file rather than a flag because command arguments are visible to other local processes.\n */\nexport function parseServeOptions(argv: readonly string[]): ServeOptions {\n let noSession = false;\n let tokenFile: string | undefined;\n let webPort = DEFAULT_WEB_PORT;\n let sessionName: string | undefined;\n let sessionId: string | undefined;\n const agentArgs: string[] = [];\n\n for (let index = 0; index < argv.length; index += 1) {\n const argument = argv[index];\n if (argument === '--no-session') {\n noSession = true;\n continue;\n }\n if (argument === AGENT_SEPARATOR) {\n agentArgs.push(...argv.slice(index + 1));\n break;\n }\n if (argument === WEB_OPTION) {\n // The port is optional, so only consume the next token when it reads as\n // one; otherwise it belongs to whatever flag follows.\n const value = argv[index + 1];\n if (value !== undefined && /^\\d+$/u.test(value)) {\n const parsed = Number.parseInt(value, 10);\n if (parsed < 1 || parsed > 65535) throw new Error(`${WEB_OPTION} expects a port number, received \"${value}\".`);\n webPort = parsed;\n index += 1;\n } else {\n webPort = DEFAULT_WEB_PORT;\n }\n continue;\n }\n if (argument === TOKEN_FILE_OPTION || argument === NAME_OPTION || argument === SESSION_ID_OPTION) {\n const value = argv[index + 1];\n if (value === undefined || value.startsWith('-')) throw new Error(`${argument} requires a value.`);\n if (argument === TOKEN_FILE_OPTION) tokenFile = value;\n else if (argument === NAME_OPTION) sessionName = value;\n else {\n if (value.includes('/')) throw new Error(`${SESSION_ID_OPTION} must not contain \"/\".`);\n sessionId = value;\n }\n index += 1;\n continue;\n }\n throw new Error(`Unknown option ${argument}. Usage: ${SERVE_USAGE}`);\n }\n\n if (!tokenFile) throw new Error(`${TOKEN_FILE_OPTION} is required. Usage: ${SERVE_USAGE}`);\n return {\n ...(noSession ? { noSession: true } : {}),\n tokenFile,\n agentArgs,\n webPort,\n sessionName: sessionName ?? DEFAULT_SESSION_NAME,\n sessionId,\n };\n}\n"],"mappings":";;AAOA,MAAM,oBAAoB;AAC1B,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAE7B,MAAa,cAAc,aAAa,kBAAkB,0BAA0B,YAAY,YAAY,kBAAkB,UAAU,WAAW,YAAY,gBAAgB;;;;;;AAO/K,SAAgB,kBAAkB,MAAuC;CACvE,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,MAAM,YAAsB,CAAC;CAE7B,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,MAAM,WAAW,KAAK;EACtB,IAAI,aAAa,gBAAgB;GAC/B,YAAY;GACZ;EACF;EACA,IAAI,aAAa,iBAAiB;GAChC,UAAU,KAAK,GAAG,KAAK,MAAM,QAAQ,CAAC,CAAC;GACvC;EACF;EACA,IAAI,aAAa,YAAY;GAG3B,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,SAAS,KAAK,KAAK,GAAG;IAC/C,MAAM,SAAS,OAAO,SAAS,OAAO,EAAE;IACxC,IAAI,SAAS,KAAK,SAAS,OAAO,MAAM,IAAI,MAAM,GAAG,WAAW,oCAAoC,MAAM,GAAG;IAC7G,UAAU;IACV,SAAS;GACX,OACE,UAAU;GAEZ;EACF;EACA,IAAI,aAAa,qBAAqB,aAAa,eAAe,aAAa,mBAAmB;GAChG,MAAM,QAAQ,KAAK,QAAQ;GAC3B,IAAI,UAAU,KAAA,KAAa,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,SAAS,mBAAmB;GACjG,IAAI,aAAa,mBAAmB,YAAY;QAC3C,IAAI,aAAa,aAAa,cAAc;QAC5C;IACH,IAAI,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,kBAAkB,uBAAuB;IACrF,YAAY;GACd;GACA,SAAS;GACT;EACF;EACA,MAAM,IAAI,MAAM,kBAAkB,SAAS,WAAW,aAAa;CACrE;CAEA,IAAI,CAAC,WAAW,MAAM,IAAI,MAAM,GAAG,kBAAkB,uBAAuB,aAAa;CACzF,OAAO;EACL,GAAI,YAAY,EAAE,WAAW,KAAK,IAAI,CAAC;EACvC;EACA;EACA;EACA,aAAa,eAAe;EAC5B;CACF;AACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
let node_url = require("node:url");
|
|
7
|
+
/** Longest graceful stop (telemetry flush included) before an uncaught exception exits anyway. */
|
|
8
|
+
const FATAL_STOP_DEADLINE_MS = 5e3;
|
|
9
|
+
const SNAPSHOT_ROOT = /(\S*?)[\\/]node_modules[\\/]\.po-snapshots[\\/]([^\\/\s:)]+)[\\/]/;
|
|
10
|
+
const UPM_STORE = /[\\/]node_modules[\\/]\.upm[\\/]/;
|
|
11
|
+
const PACKAGE_PATH = /[\\/]node_modules[\\/]((?:@[^\\/\s]+[\\/])?[^\\/\s:)]+)[\\/]/g;
|
|
12
|
+
function packageNameAt(directory) {
|
|
13
|
+
try {
|
|
14
|
+
const manifest = JSON.parse(node_fs.default.readFileSync(node_path.default.join(directory, "package.json"), "utf8"));
|
|
15
|
+
return typeof manifest.name === "string" ? manifest.name : void 0;
|
|
16
|
+
} catch {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Best-effort owner of an error: the Po package whose snapshot or upm store path appears
|
|
22
|
+
* first in its stack. Snapshots carry their `package.json`, so their name is exact; a upm
|
|
23
|
+
* path uses its innermost `node_modules/<name>` segment. Ordinary dependency frames are
|
|
24
|
+
* ignored, so a library on the stack is never blamed for its caller.
|
|
25
|
+
*/
|
|
26
|
+
function attributePackage(error) {
|
|
27
|
+
const stack = error instanceof Error ? error.stack : void 0;
|
|
28
|
+
if (!stack) return void 0;
|
|
29
|
+
for (const line of stack.split("\n")) {
|
|
30
|
+
const snapshot = SNAPSHOT_ROOT.exec(line);
|
|
31
|
+
if (snapshot) {
|
|
32
|
+
const location = snapshot[1].replace(/^\(/, "");
|
|
33
|
+
const root = location.startsWith("file:") ? (0, node_url.fileURLToPath)(`${location}/`) : location;
|
|
34
|
+
const name = packageNameAt(node_path.default.join(root, "node_modules", ".po-snapshots", snapshot[2]));
|
|
35
|
+
if (name) return name;
|
|
36
|
+
}
|
|
37
|
+
if (!UPM_STORE.test(line)) continue;
|
|
38
|
+
const name = [...line.matchAll(PACKAGE_PATH)].map((match) => match[1]).at(-1);
|
|
39
|
+
if (name && !name.startsWith(".")) return name.replace(/\\/g, "/");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function describe(error) {
|
|
43
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Keeps one bad extension from taking the server down.
|
|
47
|
+
*
|
|
48
|
+
* An unhandled rejection is logged with its package and the server keeps running: a
|
|
49
|
+
* rejected promise has already unwound and leaves no broken state behind. An uncaught
|
|
50
|
+
* exception may have interrupted any synchronous invariant, so the server stops
|
|
51
|
+
* gracefully (bounded) and exits with `UNCAUGHT_EXIT_CODE`.
|
|
52
|
+
*/
|
|
53
|
+
function installProcessGuards(options, target = process) {
|
|
54
|
+
let fatal = false;
|
|
55
|
+
const onRejection = (reason) => {
|
|
56
|
+
const owner = attributePackage(reason);
|
|
57
|
+
options.write(`[po-server] unhandled rejection${owner ? ` from ${owner}` : ""}: ${describe(reason)}\n`);
|
|
58
|
+
};
|
|
59
|
+
const onException = (error) => {
|
|
60
|
+
const owner = attributePackage(error);
|
|
61
|
+
options.write(`[po-server] uncaught exception${owner ? ` from ${owner}` : ""}: ${describe(error)}\n`);
|
|
62
|
+
if (fatal) return;
|
|
63
|
+
fatal = true;
|
|
64
|
+
const deadline = setTimeout(() => options.exit(75), options.stopDeadlineMs ?? FATAL_STOP_DEADLINE_MS);
|
|
65
|
+
options.stop().catch((stopError) => {
|
|
66
|
+
options.write(`[po-server] stop after uncaught exception failed: ${describe(stopError)}\n`);
|
|
67
|
+
}).finally(() => {
|
|
68
|
+
clearTimeout(deadline);
|
|
69
|
+
options.exit(75);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
target.on("unhandledRejection", onRejection);
|
|
73
|
+
target.on("uncaughtException", onException);
|
|
74
|
+
return () => {
|
|
75
|
+
target.off("unhandledRejection", onRejection);
|
|
76
|
+
target.off("uncaughtException", onException);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
exports.attributePackage = attributePackage;
|
|
81
|
+
exports.installProcessGuards = installProcessGuards;
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=processGuards.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processGuards.cjs","names":["fs","path","fileURLToPath"],"sources":["../../../../src/cli/server/processGuards.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/** Exit code for an uncaught exception: temporary failure, so a supervisor restarts the server. */\nexport const UNCAUGHT_EXIT_CODE = 75;\n/** Longest graceful stop (telemetry flush included) before an uncaught exception exits anyway. */\nconst FATAL_STOP_DEADLINE_MS = 5_000;\n\nconst SNAPSHOT_ROOT = /(\\S*?)[\\\\/]node_modules[\\\\/]\\.po-snapshots[\\\\/]([^\\\\/\\s:)]+)[\\\\/]/;\nconst UPM_STORE = /[\\\\/]node_modules[\\\\/]\\.upm[\\\\/]/;\nconst PACKAGE_PATH = /[\\\\/]node_modules[\\\\/]((?:@[^\\\\/\\s]+[\\\\/])?[^\\\\/\\s:)]+)[\\\\/]/g;\n\nfunction packageNameAt(directory: string): string | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf8')) as { name?: unknown };\n return typeof manifest.name === 'string' ? manifest.name : undefined;\n } catch {\n // Best effort: an unreadable manifest only loses the attribution.\n return undefined;\n }\n}\n\n/**\n * Best-effort owner of an error: the Po package whose snapshot or upm store path appears\n * first in its stack. Snapshots carry their `package.json`, so their name is exact; a upm\n * path uses its innermost `node_modules/<name>` segment. Ordinary dependency frames are\n * ignored, so a library on the stack is never blamed for its caller.\n */\nexport function attributePackage(error: unknown): string | undefined {\n const stack = error instanceof Error ? error.stack : undefined;\n if (!stack) return undefined;\n for (const line of stack.split('\\n')) {\n const snapshot = SNAPSHOT_ROOT.exec(line);\n if (snapshot) {\n const location = snapshot[1]!.replace(/^\\(/, '');\n const root = location.startsWith('file:') ? fileURLToPath(`${location}/`) : location;\n const name = packageNameAt(path.join(root, 'node_modules', '.po-snapshots', snapshot[2]!));\n if (name) return name;\n }\n if (!UPM_STORE.test(line)) continue;\n const names = [...line.matchAll(PACKAGE_PATH)].map((match) => match[1]!);\n const name = names.at(-1);\n if (name && !name.startsWith('.')) return name.replace(/\\\\/g, '/');\n }\n return undefined;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? (error.stack ?? error.message) : String(error);\n}\n\nexport interface ProcessGuardOptions {\n readonly write: (message: string) => void;\n /** Starts the server's graceful stop, which flushes telemetry and logs. */\n readonly stop: () => Promise<unknown>;\n readonly exit: (code: number) => void;\n readonly stopDeadlineMs?: number;\n}\n\n/**\n * Keeps one bad extension from taking the server down.\n *\n * An unhandled rejection is logged with its package and the server keeps running: a\n * rejected promise has already unwound and leaves no broken state behind. An uncaught\n * exception may have interrupted any synchronous invariant, so the server stops\n * gracefully (bounded) and exits with `UNCAUGHT_EXIT_CODE`.\n */\nexport function installProcessGuards(options: ProcessGuardOptions, target: NodeJS.Process = process): () => void {\n let fatal = false;\n const onRejection = (reason: unknown): void => {\n const owner = attributePackage(reason);\n options.write(`[po-server] unhandled rejection${owner ? ` from ${owner}` : ''}: ${describe(reason)}\\n`);\n };\n const onException = (error: unknown): void => {\n const owner = attributePackage(error);\n options.write(`[po-server] uncaught exception${owner ? ` from ${owner}` : ''}: ${describe(error)}\\n`);\n if (fatal) return;\n fatal = true;\n const deadline = setTimeout(\n () => options.exit(UNCAUGHT_EXIT_CODE),\n options.stopDeadlineMs ?? FATAL_STOP_DEADLINE_MS,\n );\n // Not unref'd: if the stop hangs with no other handle alive, the process must still exit 75,\n // not drain to 0, so the supervisor restarts it.\n void options\n .stop()\n .catch((stopError: unknown) => {\n options.write(`[po-server] stop after uncaught exception failed: ${describe(stopError)}\\n`);\n })\n .finally(() => {\n clearTimeout(deadline);\n options.exit(UNCAUGHT_EXIT_CODE);\n });\n };\n target.on('unhandledRejection', onRejection);\n target.on('uncaughtException', onException);\n return () => {\n target.off('unhandledRejection', onRejection);\n target.off('uncaughtException', onException);\n };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,yBAAyB;AAE/B,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAClB,MAAM,eAAe;AAErB,SAAS,cAAc,WAAuC;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,MAAMA,QAAAA,QAAG,aAAaC,UAAAA,QAAK,KAAK,WAAW,cAAc,GAAG,MAAM,CAAC;EACzF,OAAO,OAAO,SAAS,SAAS,WAAW,SAAS,OAAO,KAAA;CAC7D,QAAQ;EAEN;CACF;AACF;;;;;;;AAQA,SAAgB,iBAAiB,OAAoC;CACnE,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;CACrD,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,KAAK,MAAM,QAAQ,MAAM,MAAM,IAAI,GAAG;EACpC,MAAM,WAAW,cAAc,KAAK,IAAI;EACxC,IAAI,UAAU;GACZ,MAAM,WAAW,SAAS,EAAE,CAAE,QAAQ,OAAO,EAAE;GAC/C,MAAM,OAAO,SAAS,WAAW,OAAO,KAAA,GAAIC,SAAAA,cAAAA,CAAc,GAAG,SAAS,EAAE,IAAI;GAC5E,MAAM,OAAO,cAAcD,UAAAA,QAAK,KAAK,MAAM,gBAAgB,iBAAiB,SAAS,EAAG,CAAC;GACzF,IAAI,MAAM,OAAO;EACnB;EACA,IAAI,CAAC,UAAU,KAAK,IAAI,GAAG;EAE3B,MAAM,OADQ,CAAC,GAAG,KAAK,SAAS,YAAY,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,EACnD,CAAC,CAAC,GAAG,EAAE;EACxB,IAAI,QAAQ,CAAC,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,QAAQ,OAAO,GAAG;CACnE;AAEF;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK;AAC/E;;;;;;;;;AAkBA,SAAgB,qBAAqB,SAA8B,SAAyB,SAAqB;CAC/G,IAAI,QAAQ;CACZ,MAAM,eAAe,WAA0B;EAC7C,MAAM,QAAQ,iBAAiB,MAAM;EACrC,QAAQ,MAAM,kCAAkC,QAAQ,SAAS,UAAU,GAAG,IAAI,SAAS,MAAM,EAAE,GAAG;CACxG;CACA,MAAM,eAAe,UAAyB;EAC5C,MAAM,QAAQ,iBAAiB,KAAK;EACpC,QAAQ,MAAM,iCAAiC,QAAQ,SAAS,UAAU,GAAG,IAAI,SAAS,KAAK,EAAE,GAAG;EACpG,IAAI,OAAO;EACX,QAAQ;EACR,MAAM,WAAW,iBACT,QAAQ,KAAA,EAAuB,GACrC,QAAQ,kBAAkB,sBAC5B;EAGA,QACG,KAAK,CAAC,CACN,OAAO,cAAuB;GAC7B,QAAQ,MAAM,qDAAqD,SAAS,SAAS,EAAE,GAAG;EAC5F,CAAC,CAAC,CACD,cAAc;GACb,aAAa,QAAQ;GACrB,QAAQ,KAAA,EAAuB;EACjC,CAAC;CACL;CACA,OAAO,GAAG,sBAAsB,WAAW;CAC3C,OAAO,GAAG,qBAAqB,WAAW;CAC1C,aAAa;EACX,OAAO,IAAI,sBAAsB,WAAW;EAC5C,OAAO,IAAI,qBAAqB,WAAW;CAC7C;AACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/** Longest graceful stop (telemetry flush included) before an uncaught exception exits anyway. */
|
|
5
|
+
const FATAL_STOP_DEADLINE_MS = 5e3;
|
|
6
|
+
const SNAPSHOT_ROOT = /(\S*?)[\\/]node_modules[\\/]\.po-snapshots[\\/]([^\\/\s:)]+)[\\/]/;
|
|
7
|
+
const UPM_STORE = /[\\/]node_modules[\\/]\.upm[\\/]/;
|
|
8
|
+
const PACKAGE_PATH = /[\\/]node_modules[\\/]((?:@[^\\/\s]+[\\/])?[^\\/\s:)]+)[\\/]/g;
|
|
9
|
+
function packageNameAt(directory) {
|
|
10
|
+
try {
|
|
11
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"));
|
|
12
|
+
return typeof manifest.name === "string" ? manifest.name : void 0;
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Best-effort owner of an error: the Po package whose snapshot or upm store path appears
|
|
19
|
+
* first in its stack. Snapshots carry their `package.json`, so their name is exact; a upm
|
|
20
|
+
* path uses its innermost `node_modules/<name>` segment. Ordinary dependency frames are
|
|
21
|
+
* ignored, so a library on the stack is never blamed for its caller.
|
|
22
|
+
*/
|
|
23
|
+
function attributePackage(error) {
|
|
24
|
+
const stack = error instanceof Error ? error.stack : void 0;
|
|
25
|
+
if (!stack) return void 0;
|
|
26
|
+
for (const line of stack.split("\n")) {
|
|
27
|
+
const snapshot = SNAPSHOT_ROOT.exec(line);
|
|
28
|
+
if (snapshot) {
|
|
29
|
+
const location = snapshot[1].replace(/^\(/, "");
|
|
30
|
+
const root = location.startsWith("file:") ? fileURLToPath(`${location}/`) : location;
|
|
31
|
+
const name = packageNameAt(path.join(root, "node_modules", ".po-snapshots", snapshot[2]));
|
|
32
|
+
if (name) return name;
|
|
33
|
+
}
|
|
34
|
+
if (!UPM_STORE.test(line)) continue;
|
|
35
|
+
const name = [...line.matchAll(PACKAGE_PATH)].map((match) => match[1]).at(-1);
|
|
36
|
+
if (name && !name.startsWith(".")) return name.replace(/\\/g, "/");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function describe(error) {
|
|
40
|
+
return error instanceof Error ? error.stack ?? error.message : String(error);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Keeps one bad extension from taking the server down.
|
|
44
|
+
*
|
|
45
|
+
* An unhandled rejection is logged with its package and the server keeps running: a
|
|
46
|
+
* rejected promise has already unwound and leaves no broken state behind. An uncaught
|
|
47
|
+
* exception may have interrupted any synchronous invariant, so the server stops
|
|
48
|
+
* gracefully (bounded) and exits with `UNCAUGHT_EXIT_CODE`.
|
|
49
|
+
*/
|
|
50
|
+
function installProcessGuards(options, target = process) {
|
|
51
|
+
let fatal = false;
|
|
52
|
+
const onRejection = (reason) => {
|
|
53
|
+
const owner = attributePackage(reason);
|
|
54
|
+
options.write(`[po-server] unhandled rejection${owner ? ` from ${owner}` : ""}: ${describe(reason)}\n`);
|
|
55
|
+
};
|
|
56
|
+
const onException = (error) => {
|
|
57
|
+
const owner = attributePackage(error);
|
|
58
|
+
options.write(`[po-server] uncaught exception${owner ? ` from ${owner}` : ""}: ${describe(error)}\n`);
|
|
59
|
+
if (fatal) return;
|
|
60
|
+
fatal = true;
|
|
61
|
+
const deadline = setTimeout(() => options.exit(75), options.stopDeadlineMs ?? FATAL_STOP_DEADLINE_MS);
|
|
62
|
+
options.stop().catch((stopError) => {
|
|
63
|
+
options.write(`[po-server] stop after uncaught exception failed: ${describe(stopError)}\n`);
|
|
64
|
+
}).finally(() => {
|
|
65
|
+
clearTimeout(deadline);
|
|
66
|
+
options.exit(75);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
target.on("unhandledRejection", onRejection);
|
|
70
|
+
target.on("uncaughtException", onException);
|
|
71
|
+
return () => {
|
|
72
|
+
target.off("unhandledRejection", onRejection);
|
|
73
|
+
target.off("uncaughtException", onException);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { attributePackage, installProcessGuards };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=processGuards.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processGuards.mjs","names":[],"sources":["../../../../src/cli/server/processGuards.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/** Exit code for an uncaught exception: temporary failure, so a supervisor restarts the server. */\nexport const UNCAUGHT_EXIT_CODE = 75;\n/** Longest graceful stop (telemetry flush included) before an uncaught exception exits anyway. */\nconst FATAL_STOP_DEADLINE_MS = 5_000;\n\nconst SNAPSHOT_ROOT = /(\\S*?)[\\\\/]node_modules[\\\\/]\\.po-snapshots[\\\\/]([^\\\\/\\s:)]+)[\\\\/]/;\nconst UPM_STORE = /[\\\\/]node_modules[\\\\/]\\.upm[\\\\/]/;\nconst PACKAGE_PATH = /[\\\\/]node_modules[\\\\/]((?:@[^\\\\/\\s]+[\\\\/])?[^\\\\/\\s:)]+)[\\\\/]/g;\n\nfunction packageNameAt(directory: string): string | undefined {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(directory, 'package.json'), 'utf8')) as { name?: unknown };\n return typeof manifest.name === 'string' ? manifest.name : undefined;\n } catch {\n // Best effort: an unreadable manifest only loses the attribution.\n return undefined;\n }\n}\n\n/**\n * Best-effort owner of an error: the Po package whose snapshot or upm store path appears\n * first in its stack. Snapshots carry their `package.json`, so their name is exact; a upm\n * path uses its innermost `node_modules/<name>` segment. Ordinary dependency frames are\n * ignored, so a library on the stack is never blamed for its caller.\n */\nexport function attributePackage(error: unknown): string | undefined {\n const stack = error instanceof Error ? error.stack : undefined;\n if (!stack) return undefined;\n for (const line of stack.split('\\n')) {\n const snapshot = SNAPSHOT_ROOT.exec(line);\n if (snapshot) {\n const location = snapshot[1]!.replace(/^\\(/, '');\n const root = location.startsWith('file:') ? fileURLToPath(`${location}/`) : location;\n const name = packageNameAt(path.join(root, 'node_modules', '.po-snapshots', snapshot[2]!));\n if (name) return name;\n }\n if (!UPM_STORE.test(line)) continue;\n const names = [...line.matchAll(PACKAGE_PATH)].map((match) => match[1]!);\n const name = names.at(-1);\n if (name && !name.startsWith('.')) return name.replace(/\\\\/g, '/');\n }\n return undefined;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? (error.stack ?? error.message) : String(error);\n}\n\nexport interface ProcessGuardOptions {\n readonly write: (message: string) => void;\n /** Starts the server's graceful stop, which flushes telemetry and logs. */\n readonly stop: () => Promise<unknown>;\n readonly exit: (code: number) => void;\n readonly stopDeadlineMs?: number;\n}\n\n/**\n * Keeps one bad extension from taking the server down.\n *\n * An unhandled rejection is logged with its package and the server keeps running: a\n * rejected promise has already unwound and leaves no broken state behind. An uncaught\n * exception may have interrupted any synchronous invariant, so the server stops\n * gracefully (bounded) and exits with `UNCAUGHT_EXIT_CODE`.\n */\nexport function installProcessGuards(options: ProcessGuardOptions, target: NodeJS.Process = process): () => void {\n let fatal = false;\n const onRejection = (reason: unknown): void => {\n const owner = attributePackage(reason);\n options.write(`[po-server] unhandled rejection${owner ? ` from ${owner}` : ''}: ${describe(reason)}\\n`);\n };\n const onException = (error: unknown): void => {\n const owner = attributePackage(error);\n options.write(`[po-server] uncaught exception${owner ? ` from ${owner}` : ''}: ${describe(error)}\\n`);\n if (fatal) return;\n fatal = true;\n const deadline = setTimeout(\n () => options.exit(UNCAUGHT_EXIT_CODE),\n options.stopDeadlineMs ?? FATAL_STOP_DEADLINE_MS,\n );\n // Not unref'd: if the stop hangs with no other handle alive, the process must still exit 75,\n // not drain to 0, so the supervisor restarts it.\n void options\n .stop()\n .catch((stopError: unknown) => {\n options.write(`[po-server] stop after uncaught exception failed: ${describe(stopError)}\\n`);\n })\n .finally(() => {\n clearTimeout(deadline);\n options.exit(UNCAUGHT_EXIT_CODE);\n });\n };\n target.on('unhandledRejection', onRejection);\n target.on('uncaughtException', onException);\n return () => {\n target.off('unhandledRejection', onRejection);\n target.off('uncaughtException', onException);\n };\n}\n"],"mappings":";;;;AAOA,MAAM,yBAAyB;AAE/B,MAAM,gBAAgB;AACtB,MAAM,YAAY;AAClB,MAAM,eAAe;AAErB,SAAS,cAAc,WAAuC;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,WAAW,cAAc,GAAG,MAAM,CAAC;EACzF,OAAO,OAAO,SAAS,SAAS,WAAW,SAAS,OAAO,KAAA;CAC7D,QAAQ;EAEN;CACF;AACF;;;;;;;AAQA,SAAgB,iBAAiB,OAAoC;CACnE,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;CACrD,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,KAAK,MAAM,QAAQ,MAAM,MAAM,IAAI,GAAG;EACpC,MAAM,WAAW,cAAc,KAAK,IAAI;EACxC,IAAI,UAAU;GACZ,MAAM,WAAW,SAAS,EAAE,CAAE,QAAQ,OAAO,EAAE;GAC/C,MAAM,OAAO,SAAS,WAAW,OAAO,IAAI,cAAc,GAAG,SAAS,EAAE,IAAI;GAC5E,MAAM,OAAO,cAAc,KAAK,KAAK,MAAM,gBAAgB,iBAAiB,SAAS,EAAG,CAAC;GACzF,IAAI,MAAM,OAAO;EACnB;EACA,IAAI,CAAC,UAAU,KAAK,IAAI,GAAG;EAE3B,MAAM,OADQ,CAAC,GAAG,KAAK,SAAS,YAAY,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,EACnD,CAAC,CAAC,GAAG,EAAE;EACxB,IAAI,QAAQ,CAAC,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,QAAQ,OAAO,GAAG;CACnE;AAEF;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK;AAC/E;;;;;;;;;AAkBA,SAAgB,qBAAqB,SAA8B,SAAyB,SAAqB;CAC/G,IAAI,QAAQ;CACZ,MAAM,eAAe,WAA0B;EAC7C,MAAM,QAAQ,iBAAiB,MAAM;EACrC,QAAQ,MAAM,kCAAkC,QAAQ,SAAS,UAAU,GAAG,IAAI,SAAS,MAAM,EAAE,GAAG;CACxG;CACA,MAAM,eAAe,UAAyB;EAC5C,MAAM,QAAQ,iBAAiB,KAAK;EACpC,QAAQ,MAAM,iCAAiC,QAAQ,SAAS,UAAU,GAAG,IAAI,SAAS,KAAK,EAAE,GAAG;EACpG,IAAI,OAAO;EACX,QAAQ;EACR,MAAM,WAAW,iBACT,QAAQ,KAAA,EAAuB,GACrC,QAAQ,kBAAkB,sBAC5B;EAGA,QACG,KAAK,CAAC,CACN,OAAO,cAAuB;GAC7B,QAAQ,MAAM,qDAAqD,SAAS,SAAS,EAAE,GAAG;EAC5F,CAAC,CAAC,CACD,cAAc;GACb,aAAa,QAAQ;GACrB,QAAQ,KAAA,EAAuB;EACjC,CAAC;CACL;CACA,OAAO,GAAG,sBAAsB,WAAW;CAC3C,OAAO,GAAG,qBAAqB,WAAW;CAC1C,aAAa;EACX,OAAO,IAAI,sBAAsB,WAAW;EAC5C,OAAO,IAAI,qBAAqB,WAAW;CAC7C;AACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_harnessOptions = require("../harnessOptions.cjs");
|
|
3
|
+
const require_index = require("../../composition/poHomeMigration/index.cjs");
|
|
4
|
+
const require_runtime$1 = require("../../builders/server/runtime.cjs");
|
|
5
|
+
const require_options = require("./options.cjs");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
8
|
+
let node_os = require("node:os");
|
|
9
|
+
node_os = require_runtime.__toESM(node_os, 1);
|
|
10
|
+
let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
|
|
11
|
+
//#region src/cli/server/run.ts
|
|
12
|
+
/** Removes Po's leftover entries from Pi's default user agent directory, once per server start. */
|
|
13
|
+
function removeLegacyPiIntegration(homeDirectory) {
|
|
14
|
+
try {
|
|
15
|
+
for (const removed of (0, _agimon_ai_po_core_piSettings.removePoPiSettings)(node_path.default.join(homeDirectory, ".pi", "agent"))) process.stderr.write(`[po-server] Removed Po's Pi entry: ${removed}\n`);
|
|
16
|
+
} catch (error) {
|
|
17
|
+
process.stderr.write(`[po-server] Could not remove Po's Pi entries: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Registers this host, then deletes `~/.pi/.po` once no older host can be using it.
|
|
22
|
+
* Never fatal: a failure here leaves the old directory for the next start.
|
|
23
|
+
*/
|
|
24
|
+
function registerAndRetireLegacyHome(homeDirectory, environment) {
|
|
25
|
+
const poHome = (0, _agimon_ai_po_core_piSettings.poHomeDirectory)(homeDirectory, environment);
|
|
26
|
+
let release = () => void 0;
|
|
27
|
+
try {
|
|
28
|
+
release = require_index.registerPoHost(poHome);
|
|
29
|
+
const retired = require_index.retireLegacyPoHome(homeDirectory, poHome);
|
|
30
|
+
if (retired.status === "removed") process.stderr.write("[po-server] Removed the old ~/.pi/.po directory.\n");
|
|
31
|
+
if (retired.status === "deferred") process.stderr.write(`[po-server] Kept ~/.pi/.po for now: ${retired.reason}\n`);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
process.stderr.write(`[po-server] Could not retire ~/.pi/.po: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
34
|
+
}
|
|
35
|
+
return release;
|
|
36
|
+
}
|
|
37
|
+
async function runServer(args, stopSignal) {
|
|
38
|
+
const options = require_options.parseServeOptions(args);
|
|
39
|
+
const environment = Object.freeze({ ...process.env });
|
|
40
|
+
const homeDirectory = environment.HOME ?? node_os.default.homedir();
|
|
41
|
+
removeLegacyPiIntegration(homeDirectory);
|
|
42
|
+
const releaseHost = registerAndRetireLegacyHome(homeDirectory, environment);
|
|
43
|
+
const controller = new AbortController();
|
|
44
|
+
const stop = () => controller.abort();
|
|
45
|
+
process.on("SIGINT", stop);
|
|
46
|
+
process.on("SIGTERM", stop);
|
|
47
|
+
process.on("disconnect", stop);
|
|
48
|
+
stopSignal?.addEventListener("abort", stop, { once: true });
|
|
49
|
+
if (stopSignal?.aborted) stop();
|
|
50
|
+
try {
|
|
51
|
+
return await require_runtime$1.runServerRuntime(options, {
|
|
52
|
+
cwd: process.cwd(),
|
|
53
|
+
environment,
|
|
54
|
+
signal: controller.signal,
|
|
55
|
+
resolveHarnessOptions: require_harnessOptions.resolveHarnessOptions,
|
|
56
|
+
notice: (message) => void process.stderr.write(`[po-server] ${message}\n`)
|
|
57
|
+
});
|
|
58
|
+
} finally {
|
|
59
|
+
process.off("SIGINT", stop);
|
|
60
|
+
process.off("SIGTERM", stop);
|
|
61
|
+
process.off("disconnect", stop);
|
|
62
|
+
stopSignal?.removeEventListener("abort", stop);
|
|
63
|
+
releaseHost();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
exports.runServer = runServer;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=run.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.cjs","names":["removePoPiSettings","path","poHomeDirectory","registerPoHost","retireLegacyPoHome","parseServeOptions","os","runServerRuntime"],"sources":["../../../../src/cli/server/run.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\n\nimport { poHomeDirectory, removePoPiSettings } from '@agimon-ai/po-core/piSettings';\n\nimport { runServerRuntime } from '../../builders/server/runtime';\nimport { registerPoHost, retireLegacyPoHome } from '../../composition/poHomeMigration';\nimport { resolveHarnessOptions } from '../harnessOptions';\nimport { parseServeOptions } from './options';\n\n/** Removes Po's leftover entries from Pi's default user agent directory, once per server start. */\nfunction removeLegacyPiIntegration(homeDirectory: string): void {\n try {\n for (const removed of removePoPiSettings(path.join(homeDirectory, '.pi', 'agent'))) {\n process.stderr.write(`[po-server] Removed Po's Pi entry: ${removed}\\n`);\n }\n } catch (error) {\n process.stderr.write(\n `[po-server] Could not remove Po's Pi entries: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n }\n}\n\n/**\n * Registers this host, then deletes `~/.pi/.po` once no older host can be using it.\n * Never fatal: a failure here leaves the old directory for the next start.\n */\nfunction registerAndRetireLegacyHome(homeDirectory: string, environment: NodeJS.ProcessEnv): () => void {\n const poHome = poHomeDirectory(homeDirectory, environment);\n let release = (): void => undefined;\n try {\n release = registerPoHost(poHome);\n const retired = retireLegacyPoHome(homeDirectory, poHome);\n if (retired.status === 'removed') process.stderr.write('[po-server] Removed the old ~/.pi/.po directory.\\n');\n if (retired.status === 'deferred') process.stderr.write(`[po-server] Kept ~/.pi/.po for now: ${retired.reason}\\n`);\n } catch (error) {\n process.stderr.write(\n `[po-server] Could not retire ~/.pi/.po: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n }\n return release;\n}\n\nexport async function runServer(\n args: readonly string[],\n /** Aborting stops the server gracefully, as a termination signal does. */\n stopSignal?: AbortSignal,\n): Promise<number> {\n const options = parseServeOptions(args);\n const environment = Object.freeze({ ...process.env });\n const homeDirectory = environment.HOME ?? os.homedir();\n removeLegacyPiIntegration(homeDirectory);\n const releaseHost = registerAndRetireLegacyHome(homeDirectory, environment);\n const controller = new AbortController();\n const stop = () => controller.abort();\n process.on('SIGINT', stop);\n process.on('SIGTERM', stop);\n // An IPC parent owns this server's lifetime. Its channel closes even when the\n // parent is killed before it can forward a termination signal.\n process.on('disconnect', stop);\n stopSignal?.addEventListener('abort', stop, { once: true });\n if (stopSignal?.aborted) stop();\n try {\n return await runServerRuntime(options, {\n cwd: process.cwd(),\n environment,\n signal: controller.signal,\n resolveHarnessOptions,\n notice: (message) => void process.stderr.write(`[po-server] ${message}\\n`),\n });\n } finally {\n process.off('SIGINT', stop);\n process.off('SIGTERM', stop);\n process.off('disconnect', stop);\n stopSignal?.removeEventListener('abort', stop);\n releaseHost();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAS,0BAA0B,eAA6B;CAC9D,IAAI;EACF,KAAK,MAAM,YAAA,GAAWA,8BAAAA,mBAAAA,CAAmBC,UAAAA,QAAK,KAAK,eAAe,OAAO,OAAO,CAAC,GAC/E,QAAQ,OAAO,MAAM,sCAAsC,QAAQ,GAAG;CAE1E,SAAS,OAAO;EACd,QAAQ,OAAO,MACb,iDAAiD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC1G;CACF;AACF;;;;;AAMA,SAAS,4BAA4B,eAAuB,aAA4C;CACtG,MAAM,UAAA,GAASC,8BAAAA,gBAAAA,CAAgB,eAAe,WAAW;CACzD,IAAI,gBAAsB,KAAA;CAC1B,IAAI;EACF,UAAUC,cAAAA,eAAe,MAAM;EAC/B,MAAM,UAAUC,cAAAA,mBAAmB,eAAe,MAAM;EACxD,IAAI,QAAQ,WAAW,WAAW,QAAQ,OAAO,MAAM,oDAAoD;EAC3G,IAAI,QAAQ,WAAW,YAAY,QAAQ,OAAO,MAAM,uCAAuC,QAAQ,OAAO,GAAG;CACnH,SAAS,OAAO;EACd,QAAQ,OAAO,MACb,2CAA2C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GACpG;CACF;CACA,OAAO;AACT;AAEA,eAAsB,UACpB,MAEA,YACiB;CACjB,MAAM,UAAUC,gBAAAA,kBAAkB,IAAI;CACtC,MAAM,cAAc,OAAO,OAAO,EAAE,GAAG,QAAQ,IAAI,CAAC;CACpD,MAAM,gBAAgB,YAAY,QAAQC,QAAAA,QAAG,QAAQ;CACrD,0BAA0B,aAAa;CACvC,MAAM,cAAc,4BAA4B,eAAe,WAAW;CAC1E,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,aAAa,WAAW,MAAM;CACpC,QAAQ,GAAG,UAAU,IAAI;CACzB,QAAQ,GAAG,WAAW,IAAI;CAG1B,QAAQ,GAAG,cAAc,IAAI;CAC7B,YAAY,iBAAiB,SAAS,MAAM,EAAE,MAAM,KAAK,CAAC;CAC1D,IAAI,YAAY,SAAS,KAAK;CAC9B,IAAI;EACF,OAAO,MAAMC,kBAAAA,iBAAiB,SAAS;GACrC,KAAK,QAAQ,IAAI;GACjB;GACA,QAAQ,WAAW;GACnB,uBAAA,uBAAA;GACA,SAAS,YAAY,KAAK,QAAQ,OAAO,MAAM,eAAe,QAAQ,GAAG;EAC3E,CAAC;CACH,UAAU;EACR,QAAQ,IAAI,UAAU,IAAI;EAC1B,QAAQ,IAAI,WAAW,IAAI;EAC3B,QAAQ,IAAI,cAAc,IAAI;EAC9B,YAAY,oBAAoB,SAAS,IAAI;EAC7C,YAAY;CACd;AACF"}
|