@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,1428 @@
|
|
|
1
|
+
const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_index = require("../../composition/harnessState/index.cjs");
|
|
3
|
+
const require_index$1 = require("../../composition/repository/index.cjs");
|
|
4
|
+
const require_builders_cli_extensionAssembler_index = require("../../../builders/cli/extensionAssembler/index.cjs");
|
|
5
|
+
const require_packageUrl = require("./packageUrl.cjs");
|
|
6
|
+
const require_index$2 = require("../web/index.cjs");
|
|
7
|
+
const require_index$3 = require("../native/index.cjs");
|
|
8
|
+
const require_index$4 = require("../../composition/layerPackageInstaller/index.cjs");
|
|
9
|
+
const require_sessionComposition = require("../cli/sessionComposition.cjs");
|
|
10
|
+
const require_mcpAppBuild = require("./mcpAppBuild.cjs");
|
|
11
|
+
const require_mcpBundle = require("./mcpBundle.cjs");
|
|
12
|
+
const require_index$5 = require("../../composition/syncService/index.cjs");
|
|
13
|
+
const require_backgroundSync = require("./backgroundSync.cjs");
|
|
14
|
+
const require_harnessContext = require("../cli/harnessContext.cjs");
|
|
15
|
+
const require_index$6 = require("../hooks/index.cjs");
|
|
16
|
+
const require_computerUseBinding = require("./computerUseBinding.cjs");
|
|
17
|
+
const require_defaultWorkspace = require("./defaultWorkspace.cjs");
|
|
18
|
+
const require_idleRestart = require("./idleRestart.cjs");
|
|
19
|
+
const require_index$7 = require("./index.cjs");
|
|
20
|
+
const require_logSink = require("./logSink.cjs");
|
|
21
|
+
const require_packageReloadCheck = require("./packageReloadCheck.cjs");
|
|
22
|
+
const require_runtimeResources = require("./runtimeResources.cjs");
|
|
23
|
+
const require_selectionStatus = require("./selectionStatus.cjs");
|
|
24
|
+
const require_sessionArguments = require("./sessionArguments.cjs");
|
|
25
|
+
const require_shutdown = require("./shutdown.cjs");
|
|
26
|
+
const require_webTemplateDecision = require("./webTemplateDecision.cjs");
|
|
27
|
+
const require_workspaceCheckout = require("./workspaceCheckout.cjs");
|
|
28
|
+
let node_fs = require("node:fs");
|
|
29
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
30
|
+
let node_path = require("node:path");
|
|
31
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
32
|
+
let node_os = require("node:os");
|
|
33
|
+
node_os = require_runtime.__toESM(node_os, 1);
|
|
34
|
+
let _agimon_ai_po_config_config = require("@agimon-ai/po-config/config");
|
|
35
|
+
let _agimon_ai_po_config_majorModes = require("@agimon-ai/po-config/majorModes");
|
|
36
|
+
let _agimon_ai_po_config_profiles = require("@agimon-ai/po-config/profiles");
|
|
37
|
+
let _agimon_ai_po_core_runtimeLogSinkTelemetry = require("@agimon-ai/po-core/runtimeLogSinkTelemetry");
|
|
38
|
+
let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
|
|
39
|
+
let _agimon_ai_po_core_serverFacet = require("@agimon-ai/po-core/serverFacet");
|
|
40
|
+
let node_crypto = require("node:crypto");
|
|
41
|
+
node_crypto = require_runtime.__toESM(node_crypto, 1);
|
|
42
|
+
let _agimon_ai_po_core_history = require("@agimon-ai/po-core/history");
|
|
43
|
+
let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWork");
|
|
44
|
+
let _agimon_ai_po_core_headlessHub = require("@agimon-ai/po-core/headlessHub");
|
|
45
|
+
let _agimon_ai_po_core_headlessServer = require("@agimon-ai/po-core/headlessServer");
|
|
46
|
+
let _agimon_ai_po_core_headlessSessionManager = require("@agimon-ai/po-core/headlessSessionManager");
|
|
47
|
+
let _agimon_ai_po_core_mcpFacet = require("@agimon-ai/po-core/mcpFacet");
|
|
48
|
+
let _agimon_ai_po_core_packageApi = require("@agimon-ai/po-core/packageApi");
|
|
49
|
+
let _agimon_ai_po_core_packageApiServer = require("@agimon-ai/po-core/packageApiServer");
|
|
50
|
+
let _agimon_ai_po_core_remoteRuntime = require("@agimon-ai/po-core/remoteRuntime");
|
|
51
|
+
let _agimon_ai_po_core_serverTelemetry = require("@agimon-ai/po-core/serverTelemetry");
|
|
52
|
+
let _agimon_ai_po_core_webCompositions = require("@agimon-ai/po-core/webCompositions");
|
|
53
|
+
let _agimon_ai_po_minor_mode = require("@agimon-ai/po-minor-mode");
|
|
54
|
+
let ws = require("ws");
|
|
55
|
+
ws = require_runtime.__toESM(ws, 1);
|
|
56
|
+
let _agimon_ai_po_config_harnessStore = require("@agimon-ai/po-config/harnessStore");
|
|
57
|
+
let _agimon_ai_po_config_harnessState = require("@agimon-ai/po-config/harnessState");
|
|
58
|
+
//#region src/builders/server/runtime.ts
|
|
59
|
+
async function bounded(operation, label, notice) {
|
|
60
|
+
try {
|
|
61
|
+
await require_shutdown.withShutdownDeadline(() => operation, label);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
notice(`${label} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function runServerRuntime(options, runtime) {
|
|
67
|
+
const { cwd: baseCwd, environment: incomingEnvironment, notice, resolveHarnessOptions, signal, onExtensionCheck } = runtime;
|
|
68
|
+
const baseEnvironment = {
|
|
69
|
+
...incomingEnvironment,
|
|
70
|
+
LOG_SINK_INSTANCE: "global"
|
|
71
|
+
};
|
|
72
|
+
const executionBudget = (0, _agimon_ai_po_core_packageApi.createServerExecutionBudget)(baseEnvironment);
|
|
73
|
+
await require_logSink.ensureGlobalLogSink({
|
|
74
|
+
cwd: baseCwd,
|
|
75
|
+
env: baseEnvironment,
|
|
76
|
+
notice
|
|
77
|
+
}).catch((error) => notice(`Global log sink unavailable: ${error instanceof Error ? error.message : String(error)}`));
|
|
78
|
+
const telemetry = (0, _agimon_ai_po_core_serverTelemetry.createServerTelemetry)({
|
|
79
|
+
cwd: baseCwd,
|
|
80
|
+
env: baseEnvironment,
|
|
81
|
+
warn: notice
|
|
82
|
+
});
|
|
83
|
+
const homeDirectory = baseEnvironment.HOME ?? node_os.default.homedir();
|
|
84
|
+
/** Content-addressed import URLs for every Po package entry this server loads. */
|
|
85
|
+
const packageUrls = require_packageUrl.createPackageUrls();
|
|
86
|
+
/** URLs whose live import timed out or threw; skipped by every loader until the content changes. */
|
|
87
|
+
const poisonedUrls = /* @__PURE__ */ new Set();
|
|
88
|
+
/** Imports each content-addressed URL once, so a reload imports only what changed. */
|
|
89
|
+
const importLive = require_packageReloadCheck.createLiveModuleCache();
|
|
90
|
+
/** The package identities each mounted global and workspace scope last loaded. */
|
|
91
|
+
const reloadCheck = require_packageReloadCheck.createPackageReloadCheck();
|
|
92
|
+
/** The hook module descriptor from the root's live registry; sources load in place or from snapshots. */
|
|
93
|
+
const liveHookModules = (repoRoot) => require_index$6.writeLiveHookModules({
|
|
94
|
+
repoRoot,
|
|
95
|
+
homeDirectory,
|
|
96
|
+
directory: node_path.default.join((0, _agimon_ai_po_config_config.globalDoomConfigDirectory)(homeDirectory), "server", "hook-modules"),
|
|
97
|
+
artifactFor: (source) => packageUrls.pathFor(source),
|
|
98
|
+
onNotice: notice
|
|
99
|
+
});
|
|
100
|
+
const serverDirectory = node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(baseEnvironment), "server");
|
|
101
|
+
const requestReceipts = (0, _agimon_ai_po_core_history.createRequestReceipts)({ directory: node_path.default.join(serverDirectory, "request-receipts-v1") });
|
|
102
|
+
const activeMedia = /* @__PURE__ */ new Set();
|
|
103
|
+
const mediaArbitration = {
|
|
104
|
+
register(busy) {
|
|
105
|
+
activeMedia.add(busy);
|
|
106
|
+
return () => {
|
|
107
|
+
activeMedia.delete(busy);
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
available(busy) {
|
|
111
|
+
return activeMedia.has(busy) && [...activeMedia].every((other) => other === busy || !other());
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const activePeerAgents = /* @__PURE__ */ new Map();
|
|
115
|
+
const peerAgents = {
|
|
116
|
+
register(sessionId, agent, hubToken) {
|
|
117
|
+
if (activePeerAgents.has(sessionId)) throw new Error(`Voice peer agent '${sessionId}' is already registered.`);
|
|
118
|
+
const entry = {
|
|
119
|
+
fetch: (request) => agent.fetch(request),
|
|
120
|
+
hubToken
|
|
121
|
+
};
|
|
122
|
+
activePeerAgents.set(sessionId, entry);
|
|
123
|
+
return () => {
|
|
124
|
+
if (activePeerAgents.get(sessionId) === entry) activePeerAgents.delete(sessionId);
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
get: (sessionId) => activePeerAgents.get(sessionId)
|
|
128
|
+
};
|
|
129
|
+
const workspaces = (0, _agimon_ai_po_core_history.createWorkspaceRegistry)({
|
|
130
|
+
directory: serverDirectory,
|
|
131
|
+
onNotice: notice
|
|
132
|
+
});
|
|
133
|
+
const openSessions = (0, _agimon_ai_po_core_history.createOpenSessionRegistry)({
|
|
134
|
+
directory: serverDirectory,
|
|
135
|
+
onNotice: notice
|
|
136
|
+
});
|
|
137
|
+
let lastBudgetSnapshot = "";
|
|
138
|
+
let nextEventLoopTick = performance.now() + 1e3;
|
|
139
|
+
const eventLoopMonitor = setInterval(() => {
|
|
140
|
+
const now = performance.now();
|
|
141
|
+
const budget = executionBudget.getSnapshot();
|
|
142
|
+
const snapshot = JSON.stringify(budget);
|
|
143
|
+
if (snapshot !== lastBudgetSnapshot) {
|
|
144
|
+
lastBudgetSnapshot = snapshot;
|
|
145
|
+
telemetry.recordEvent("po_server.execution_budget", {
|
|
146
|
+
host_pid: process.pid,
|
|
147
|
+
running_jobs: budget.running,
|
|
148
|
+
queued_jobs: budget.queued,
|
|
149
|
+
limit: budget.limit
|
|
150
|
+
}).catch((error) => notice(`execution budget telemetry failed: ${String(error)}`));
|
|
151
|
+
}
|
|
152
|
+
const delay = Math.max(0, now - nextEventLoopTick);
|
|
153
|
+
nextEventLoopTick = now + 1e3;
|
|
154
|
+
if (delay >= 100) telemetry.recordEvent("po_server.event_loop_delay", { duration_ms: Math.round(delay) }).catch((error) => notice(`event loop telemetry failed: ${String(error)}`));
|
|
155
|
+
}, 1e3);
|
|
156
|
+
eventLoopMonitor.unref();
|
|
157
|
+
const harnessTelemetry = (0, _agimon_ai_po_core_runtimeLogSinkTelemetry.createHarnessTelemetry)({
|
|
158
|
+
cwd: baseCwd,
|
|
159
|
+
env: baseEnvironment,
|
|
160
|
+
warn: notice,
|
|
161
|
+
deferSpans: true
|
|
162
|
+
});
|
|
163
|
+
const baseSessionManager = (0, _agimon_ai_po_core_headlessSessionManager.createHeadlessSessionManager)({
|
|
164
|
+
publishSelectionStatus: require_selectionStatus.publishHeadlessSelectionStatus,
|
|
165
|
+
contextGroups: (context) => ((0, _agimon_ai_po_minor_mode.readMinorModeCatalog)(context)?.list() ?? []).filter(({ state }) => state.activation === "active").map(({ descriptor }) => ({
|
|
166
|
+
id: descriptor.id,
|
|
167
|
+
label: descriptor.label,
|
|
168
|
+
kind: "minor"
|
|
169
|
+
}))
|
|
170
|
+
});
|
|
171
|
+
/** The server's environment rooted at one configuration root, with no harness state of its own. */
|
|
172
|
+
const rootEnvironment = (root) => {
|
|
173
|
+
const environment = {
|
|
174
|
+
...baseEnvironment,
|
|
175
|
+
PO_ROOT: root
|
|
176
|
+
};
|
|
177
|
+
for (const key of [_agimon_ai_po_config_harnessStore.HARNESS_STATE_POINTER, ...Object.values(_agimon_ai_po_config_harnessState.HARNESS_STATE_KEYS)]) delete environment[key];
|
|
178
|
+
return environment;
|
|
179
|
+
};
|
|
180
|
+
const pendingSessions = /* @__PURE__ */ new Map();
|
|
181
|
+
/** The last harness context built to report each repository's MCP projection, kept while it is current. */
|
|
182
|
+
const repositoryContexts = /* @__PURE__ */ new Map();
|
|
183
|
+
const sessionArtifacts = /* @__PURE__ */ new Map();
|
|
184
|
+
/** Each host's facet root, where its session services (background work included) live. */
|
|
185
|
+
const sessionServiceRoots = /* @__PURE__ */ new WeakMap();
|
|
186
|
+
let mountSessionApis;
|
|
187
|
+
/**
|
|
188
|
+
* Shutdown runs every session through the same close path a user-initiated
|
|
189
|
+
* close uses, so without this the registry would be emptied by the very event
|
|
190
|
+
* it exists to survive.
|
|
191
|
+
*/
|
|
192
|
+
let shuttingDown = false;
|
|
193
|
+
const closeManagedSession = async (sessionId, options) => {
|
|
194
|
+
if (!shuttingDown && options?.keepDormant !== true) openSessions.remove(sessionId);
|
|
195
|
+
const artifacts = sessionArtifacts.get(sessionId);
|
|
196
|
+
sessionArtifacts.delete(sessionId);
|
|
197
|
+
webCompositions?.remove({
|
|
198
|
+
scope: "session",
|
|
199
|
+
sessionId
|
|
200
|
+
});
|
|
201
|
+
webCompositions?.removeNative({
|
|
202
|
+
scope: "session",
|
|
203
|
+
sessionId
|
|
204
|
+
});
|
|
205
|
+
const failures = [];
|
|
206
|
+
try {
|
|
207
|
+
await require_shutdown.withShutdownDeadline(() => baseSessionManager.closeSession(sessionId), `Session '${sessionId}' runtime shutdown`);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
failures.push(error);
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
await require_shutdown.withShutdownDeadline(() => artifacts?.apis.close(), `Session '${sessionId}' API shutdown`);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
failures.push(error);
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
await require_shutdown.withShutdownDeadline(() => artifacts?.cleanup(), `Session '${sessionId}' artifact cleanup`);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
failures.push(error);
|
|
220
|
+
}
|
|
221
|
+
if (failures.length > 0) throw new AggregateError(failures, `Session '${sessionId}' shutdown failed`);
|
|
222
|
+
};
|
|
223
|
+
const sessionManager = {
|
|
224
|
+
async create(sessionOptions) {
|
|
225
|
+
const setup = pendingSessions.get(sessionOptions.sessionId);
|
|
226
|
+
let host;
|
|
227
|
+
try {
|
|
228
|
+
host = await baseSessionManager.create(sessionOptions);
|
|
229
|
+
} catch (error) {
|
|
230
|
+
if (setup !== void 0 && pendingSessions.delete(sessionOptions.sessionId)) await setup.cleanup().catch((cleanupError) => notice(String(cleanupError)));
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
if (setup === void 0 || mountSessionApis === void 0) return host;
|
|
234
|
+
try {
|
|
235
|
+
const apis = await mountSessionApis(sessionOptions, host);
|
|
236
|
+
pendingSessions.delete(sessionOptions.sessionId);
|
|
237
|
+
sessionArtifacts.set(sessionOptions.sessionId, {
|
|
238
|
+
...setup,
|
|
239
|
+
apis
|
|
240
|
+
});
|
|
241
|
+
return host;
|
|
242
|
+
} catch (error) {
|
|
243
|
+
pendingSessions.delete(sessionOptions.sessionId);
|
|
244
|
+
await baseSessionManager.closeSession(sessionOptions.sessionId).catch((closeError) => notice(String(closeError)));
|
|
245
|
+
await setup.cleanup().catch((cleanupError) => notice(String(cleanupError)));
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
get: (sessionId) => baseSessionManager.get(sessionId),
|
|
250
|
+
sessions: () => baseSessionManager.sessions(),
|
|
251
|
+
closeSession: closeManagedSession,
|
|
252
|
+
async close() {
|
|
253
|
+
const ids = baseSessionManager.sessions().map((session) => session.runtime.sessionId);
|
|
254
|
+
const failures = (await Promise.allSettled(ids.map((id) => closeManagedSession(id)))).filter((outcome) => outcome.status === "rejected").map((outcome) => outcome.reason);
|
|
255
|
+
if (failures.length > 0) throw new AggregateError(failures, "Headless session shutdown failed");
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
let requestSessionApi = async () => Response.json({ error: "Session API unavailable." }, { status: 404 });
|
|
259
|
+
let openSession = async () => {
|
|
260
|
+
throw new Error("The cockpit session service is not ready.");
|
|
261
|
+
};
|
|
262
|
+
let admitWorkspace = async () => {
|
|
263
|
+
throw new Error("Workspace admission is not ready.");
|
|
264
|
+
};
|
|
265
|
+
let remoteRuntime;
|
|
266
|
+
const computerUse = await require_computerUseBinding.createComputerUseBinding(process, {
|
|
267
|
+
isDeviceAuthorized: (id) => remoteRuntime?.remote.isDeviceAuthorized(id) === true,
|
|
268
|
+
stepUpRequired: () => remoteRuntime?.remote.stepUpRequired("computer-use.activate") === true
|
|
269
|
+
});
|
|
270
|
+
let hub;
|
|
271
|
+
hub = (0, _agimon_ai_po_core_headlessHub.createHeadlessHub)({
|
|
272
|
+
manager: sessionManager,
|
|
273
|
+
resolveProfileIdentity: (root, profile) => {
|
|
274
|
+
const identity = (0, _agimon_ai_po_config_profiles.resolveProfile)(root, profile, homeDirectory).identity;
|
|
275
|
+
return identity === void 0 ? void 0 : {
|
|
276
|
+
displayName: identity.name,
|
|
277
|
+
icon: identity.icon
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
admitWorkspace: async ({ root, name }) => admitWorkspace(root === void 0 || root.trim() === "" ? await require_defaultWorkspace.createDefaultWorkspaceFolder(name ?? "", homeDirectory) : root, name),
|
|
281
|
+
onWorkspaceRemoved: (workspaceId) => {
|
|
282
|
+
workspaces.remove(workspaceId);
|
|
283
|
+
reloadCheck.forget(`workspace:${workspaceId}`);
|
|
284
|
+
webCompositions?.remove({
|
|
285
|
+
scope: "workspace",
|
|
286
|
+
workspaceId
|
|
287
|
+
});
|
|
288
|
+
webCompositions?.removeNative({
|
|
289
|
+
scope: "workspace",
|
|
290
|
+
workspaceId
|
|
291
|
+
});
|
|
292
|
+
},
|
|
293
|
+
createSession: async (request, placement) => {
|
|
294
|
+
if (placement === void 0) return openSession(request);
|
|
295
|
+
if (require_workspaceCheckout.checkoutWorkspaceId(workspaces.list(), request.cwd) !== placement.workspaceId) throw new Error("The session directory is outside this workspace.");
|
|
296
|
+
return openSession(request, void 0, placement.workspaceId);
|
|
297
|
+
},
|
|
298
|
+
sessionReservations: {
|
|
299
|
+
read(id, parentSessionId) {
|
|
300
|
+
if (!cockpit) throw new Error("Session setup is not ready.");
|
|
301
|
+
return cockpit.sessionReservations.read(id, parentSessionId);
|
|
302
|
+
},
|
|
303
|
+
async prepare(id, parentSessionId, cwd) {
|
|
304
|
+
if (!cockpit) throw new Error("Session setup is not ready.");
|
|
305
|
+
return cockpit.sessionReservations.prepare(id, parentSessionId, cwd);
|
|
306
|
+
},
|
|
307
|
+
async complete(id, parentSessionId) {
|
|
308
|
+
if (!cockpit) throw new Error("Session setup is not ready.");
|
|
309
|
+
return cockpit.sessionReservations.complete(id, parentSessionId);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
onNotice: notice,
|
|
313
|
+
hubToken: () => attachToken,
|
|
314
|
+
requestSessionApi: (scope, request) => requestSessionApi(scope, request),
|
|
315
|
+
...computerUse === void 0 ? {} : { computerUse }
|
|
316
|
+
});
|
|
317
|
+
/** Started by the idle restart once the server is serving; until then a restart waits. */
|
|
318
|
+
let requestRestart;
|
|
319
|
+
const idleRestart = require_idleRestart.createIdleRestart({
|
|
320
|
+
...require_idleRestart.testIdleRestartOverrides(baseEnvironment),
|
|
321
|
+
busy: async () => {
|
|
322
|
+
const hosts = sessionManager.sessions();
|
|
323
|
+
if (hosts.some((host) => {
|
|
324
|
+
const root = sessionServiceRoots.get(host);
|
|
325
|
+
const service = root === void 0 ? void 0 : (0, _agimon_ai_po_core_backgroundWork.readDoomBackgroundWorkService)(root);
|
|
326
|
+
return service !== void 0 && require_idleRestart.holdsRestart(service.snapshot());
|
|
327
|
+
})) return true;
|
|
328
|
+
return (await Promise.all(hosts.map((host) => host.runtime.readState()))).some((state) => state.isStreaming || state.isCompacting);
|
|
329
|
+
},
|
|
330
|
+
restart: () => requestRestart?.(),
|
|
331
|
+
onError: (error) => notice(`Idle restart check failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
332
|
+
});
|
|
333
|
+
const stopIdleRestartPoke = hub.onEvent(() => idleRestart.poke());
|
|
334
|
+
const stopPersistSessionNames = hub.onEvent((event) => {
|
|
335
|
+
if (event.kind !== "upsert") return;
|
|
336
|
+
const record = openSessions.list().find((entry) => entry.sessionId === event.session.id);
|
|
337
|
+
if (record === void 0 || record.name === event.session.name) return;
|
|
338
|
+
openSessions.add({
|
|
339
|
+
...record,
|
|
340
|
+
name: event.session.name
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
let harnessContext;
|
|
344
|
+
let launchWorkspaceId;
|
|
345
|
+
let cockpit;
|
|
346
|
+
let attachToken;
|
|
347
|
+
let webCompositions;
|
|
348
|
+
const stopResourceMonitor = require_runtimeResources.monitorRuntimeResources({
|
|
349
|
+
record: (attributes) => telemetry.recordEvent("po_server.resources", attributes),
|
|
350
|
+
counts: () => {
|
|
351
|
+
const budget = executionBudget.getSnapshot();
|
|
352
|
+
return {
|
|
353
|
+
sessions: sessionManager.sessions().length,
|
|
354
|
+
running_jobs: budget.running,
|
|
355
|
+
queued_jobs: budget.queued,
|
|
356
|
+
job_limit: budget.limit
|
|
357
|
+
};
|
|
358
|
+
},
|
|
359
|
+
warn: notice
|
|
360
|
+
});
|
|
361
|
+
try {
|
|
362
|
+
await telemetry.runInSpan("po_server.startup", {}, async () => {
|
|
363
|
+
const token = node_fs.default.readFileSync(options.tokenFile, "utf8").trim();
|
|
364
|
+
if (!token) throw new Error("The attach token file is empty.");
|
|
365
|
+
attachToken = token;
|
|
366
|
+
const resolved = require_sessionArguments.resolveSessionIdentity(options.agentArgs, {
|
|
367
|
+
sessionId: options.sessionId ?? node_crypto.default.randomUUID(),
|
|
368
|
+
sessionName: options.sessionName
|
|
369
|
+
});
|
|
370
|
+
const globalRoot = (0, _agimon_ai_po_config_config.globalDoomConfigDirectory)(homeDirectory);
|
|
371
|
+
webCompositions = (0, _agimon_ai_po_core_webCompositions.createWebCompositions)(node_path.default.join(globalRoot, "server"), notice);
|
|
372
|
+
/** Assigned once every scope can be checked; a sync that exits sooner is picked up then. */
|
|
373
|
+
let pickUpSync = async () => void 0;
|
|
374
|
+
const backgroundSync = require_backgroundSync.createBackgroundSync({
|
|
375
|
+
environment: baseEnvironment,
|
|
376
|
+
onNotice: notice,
|
|
377
|
+
onExit: () => pickUpSync()
|
|
378
|
+
});
|
|
379
|
+
const syncCheckpoints = require_backgroundSync.createSyncCheckpoints({
|
|
380
|
+
globalRoot,
|
|
381
|
+
homeDirectory,
|
|
382
|
+
environment: baseEnvironment,
|
|
383
|
+
background: backgroundSync,
|
|
384
|
+
onNotice: notice
|
|
385
|
+
});
|
|
386
|
+
/**
|
|
387
|
+
* Every composition the root's config can select, one per major mode, resolved live
|
|
388
|
+
* from the root. A package sync has not prepared yet is left out with a diagnostic, so
|
|
389
|
+
* the root opens without it; the server never installs or builds.
|
|
390
|
+
*/
|
|
391
|
+
const liveCompositions = (root) => require_sessionComposition.rootCompositions({
|
|
392
|
+
root,
|
|
393
|
+
homeDirectory,
|
|
394
|
+
environment: baseEnvironment,
|
|
395
|
+
tolerateUnsynced: true
|
|
396
|
+
});
|
|
397
|
+
/** The root's server facet entries, each with the URL its current package content imports from. */
|
|
398
|
+
const facetEntries = async (root) => {
|
|
399
|
+
const entries = [];
|
|
400
|
+
for (const { declaration, module, owners } of require_index$7.serverFacetCandidates(liveCompositions(root))) entries.push({
|
|
401
|
+
packageName: declaration.packageName,
|
|
402
|
+
entry: declaration.entry,
|
|
403
|
+
module,
|
|
404
|
+
url: await packageUrls.urlFor(module),
|
|
405
|
+
scopes: declaration.scopes,
|
|
406
|
+
owners,
|
|
407
|
+
required: declaration.required === true
|
|
408
|
+
});
|
|
409
|
+
return entries;
|
|
410
|
+
};
|
|
411
|
+
/** Every package root the root's config can select, over all its major modes. */
|
|
412
|
+
const scopePackageRoots = (root) => require_index$2.compositionPackageRoots(liveCompositions(root));
|
|
413
|
+
/** What the root opened without: packages that do not resolve yet and web plugins with no slot. */
|
|
414
|
+
const unsyncedOf = (root) => {
|
|
415
|
+
try {
|
|
416
|
+
const compositions = liveCompositions(root);
|
|
417
|
+
const unslotted = webBuild === void 0 ? [] : require_index$2.unslottedWebPackages(webBuild, require_index$2.compositionPackageRoots(compositions));
|
|
418
|
+
return [.../* @__PURE__ */ new Set([...require_builders_cli_extensionAssembler_index.unsyncedSelectors(compositions), ...unslotted])];
|
|
419
|
+
} catch (error) {
|
|
420
|
+
notice(`'${root}' sync state could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
421
|
+
return [];
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
const workspaceLabel = (root, name) => `Workspace '${name ?? node_path.default.basename(root)}'`;
|
|
425
|
+
/** A checkpoint: request a background sync when the root changed since the last one, and warn. */
|
|
426
|
+
const syncCheckpoint = (root, label, request = true) => syncCheckpoints.check({
|
|
427
|
+
root,
|
|
428
|
+
label,
|
|
429
|
+
unsynced: unsyncedOf(root)
|
|
430
|
+
}, request);
|
|
431
|
+
let webBuild;
|
|
432
|
+
/** Publishes one mount out of the current global build, naming only the plugin slots its root resolves. */
|
|
433
|
+
const publishWebMount = (mount, root) => webBuild === void 0 ? void 0 : webCompositions?.publish(mount, webBuild, hub.channelTypes(), require_index$2.mountWebPluginSlots(webBuild, scopePackageRoots(root)));
|
|
434
|
+
let nativeBuild;
|
|
435
|
+
/** Publishes one mount's native composition out of the current global native build. */
|
|
436
|
+
const publishNativeMount = (mount, root) => nativeBuild === void 0 ? void 0 : webCompositions?.publishNative(mount, nativeBuild, hub.channelTypes(), require_index$3.mountNativePluginIds(nativeBuild, scopePackageRoots(root)));
|
|
437
|
+
const pickUpWebBuild = require_backgroundSync.createKeyedPickup((key) => require_index$2.readGlobalWebBuildRecord(globalRoot, key), (build, key) => {
|
|
438
|
+
notice(`Publishing global web build ${key}.`);
|
|
439
|
+
webBuild = build;
|
|
440
|
+
webCompositions?.publishShell(build);
|
|
441
|
+
});
|
|
442
|
+
const pickUpNativeBuild = require_backgroundSync.createKeyedPickup((key) => require_index$3.readGlobalNativeBuildRecord(globalRoot, key), (build, key) => {
|
|
443
|
+
notice(`Publishing global native build ${key}.`);
|
|
444
|
+
nativeBuild = build;
|
|
445
|
+
});
|
|
446
|
+
/** The keys these roots derive the way sync does, each only when its build exists. */
|
|
447
|
+
const ownBuildKeys = () => {
|
|
448
|
+
const pluginRoots = require_index$5.globalWebPluginRoots(globalRoot, homeDirectory, baseEnvironment, notice);
|
|
449
|
+
const web = require_index$2.readGlobalWebBuildStatus({
|
|
450
|
+
poHome: globalRoot,
|
|
451
|
+
pluginRoots,
|
|
452
|
+
environment: baseEnvironment
|
|
453
|
+
});
|
|
454
|
+
const native = require_index$3.readGlobalNativeBuildStatus({
|
|
455
|
+
poHome: globalRoot,
|
|
456
|
+
pluginRoots
|
|
457
|
+
});
|
|
458
|
+
return {
|
|
459
|
+
...web.status === "current" ? { webKey: web.key } : {},
|
|
460
|
+
...native.status === "current" ? { nativeKey: native.key } : {}
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
const currentBuildKeys = () => {
|
|
464
|
+
const pointer = require_index$5.readSyncPointer(globalRoot);
|
|
465
|
+
return require_backgroundSync.syncedBuildKeys({
|
|
466
|
+
pointer,
|
|
467
|
+
ownsPointer: syncCheckpoints.ownsPointer(pointer),
|
|
468
|
+
published: {
|
|
469
|
+
web: webBuild !== void 0,
|
|
470
|
+
native: nativeBuild !== void 0
|
|
471
|
+
},
|
|
472
|
+
ownKeys: ownBuildKeys,
|
|
473
|
+
newestWebKey: () => require_index$2.newestGlobalWebBuildKey(globalRoot)
|
|
474
|
+
});
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Read-only: picks up the global web and native builds sync's pointer names, publishing
|
|
478
|
+
* the shell only when a key changed, then republishes every shared mount. Never builds;
|
|
479
|
+
* a missing build leaves the previous one serving. Clients pick a new composition up at
|
|
480
|
+
* their next refreshWebPluginCompositions.
|
|
481
|
+
*/
|
|
482
|
+
const refreshWebBuild = () => {
|
|
483
|
+
const keys = currentBuildKeys();
|
|
484
|
+
if (pickUpNativeBuild(keys.nativeKey) === "missing") notice(`The global native build ${String(keys.nativeKey)} is missing; run po sync.`);
|
|
485
|
+
if (pickUpWebBuild(keys.webKey) === "missing") notice(`The global web build ${String(keys.webKey)} is missing; run po sync.`);
|
|
486
|
+
const mounts = hub.workspaces().filter((workspace) => workspace.available !== false).map((workspace) => ({
|
|
487
|
+
root: workspace.root,
|
|
488
|
+
mount: {
|
|
489
|
+
scope: "workspace",
|
|
490
|
+
workspaceId: workspace.id
|
|
491
|
+
}
|
|
492
|
+
}));
|
|
493
|
+
for (const publish of [publishNativeMount, publishWebMount]) {
|
|
494
|
+
publish({ scope: "global" }, globalRoot);
|
|
495
|
+
for (const { root, mount } of mounts) publish(mount, root);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
const defaultSelection = (root) => {
|
|
499
|
+
const config = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfig)(root, homeDirectory, baseEnvironment);
|
|
500
|
+
const majorMode = config.defaultMajorMode;
|
|
501
|
+
return {
|
|
502
|
+
root,
|
|
503
|
+
majorMode,
|
|
504
|
+
activeLayers: (0, _agimon_ai_po_config_majorModes.resolveLayers)(config, majorMode)
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
const loadComposition = async (root, scope, selection) => {
|
|
508
|
+
const selected = selection ?? defaultSelection(root);
|
|
509
|
+
return telemetry.runInSpan("po_server.composition_load", { scope }, async () => (0, _agimon_ai_po_core_serverFacet.loadServerFacets)(scope, {
|
|
510
|
+
entries: await facetEntries(root),
|
|
511
|
+
majorMode: selected.majorMode,
|
|
512
|
+
activeLayers: selected.activeLayers,
|
|
513
|
+
retainCandidates: scope === "session",
|
|
514
|
+
onNotice: notice,
|
|
515
|
+
poisoned: poisonedUrls,
|
|
516
|
+
importer: importLive
|
|
517
|
+
}));
|
|
518
|
+
};
|
|
519
|
+
const scopeKey = (mount) => mount.scope === "global" ? "global" : `workspace:${mount.workspaceId}`;
|
|
520
|
+
/**
|
|
521
|
+
* What a global or workspace scope loads: one identity per facet entry in that scope.
|
|
522
|
+
* The URL changes with package content; `selection` carries ownership and the root's
|
|
523
|
+
* default mode, so a modes.yaml change that moves a facet in or out remounts too.
|
|
524
|
+
*/
|
|
525
|
+
const scopeIdentities = (root, scope, entries) => {
|
|
526
|
+
const { majorMode, activeLayers } = defaultSelection(root);
|
|
527
|
+
return entries.filter((entry) => entry.scopes.includes(scope)).map((entry) => ({
|
|
528
|
+
module: entry.module,
|
|
529
|
+
url: entry.url,
|
|
530
|
+
selection: JSON.stringify([
|
|
531
|
+
entry.owners,
|
|
532
|
+
entry.required === true,
|
|
533
|
+
majorMode,
|
|
534
|
+
activeLayers
|
|
535
|
+
])
|
|
536
|
+
}));
|
|
537
|
+
};
|
|
538
|
+
const scopeChecks = /* @__PURE__ */ new Map();
|
|
539
|
+
/**
|
|
540
|
+
* The reload check for one mounted global or workspace scope: recompute its package
|
|
541
|
+
* URLs and, only when they changed, load the new set and swap it in with
|
|
542
|
+
* `replaceFacets`. Unchanged URLs come from the module cache, so only changed packages
|
|
543
|
+
* import. A scope this server has not mounted yet is left to its admission. Checks of
|
|
544
|
+
* one scope run one at a time; a failure restores the previous facets (the hub reports a
|
|
545
|
+
* failed restore) and retries next time.
|
|
546
|
+
*
|
|
547
|
+
* ponytail: no fs.watch. A rebuilt local package takes effect at the next session or
|
|
548
|
+
* admission. Watch the declared entries (see packageUrl's declaredTargets) and call this
|
|
549
|
+
* when workspace routes must update without opening a session.
|
|
550
|
+
*/
|
|
551
|
+
const checkScope = (root, mount) => {
|
|
552
|
+
const key = scopeKey(mount);
|
|
553
|
+
const settled = (scopeChecks.get(key) ?? Promise.resolve()).then(async () => {
|
|
554
|
+
try {
|
|
555
|
+
refreshWebBuild();
|
|
556
|
+
} catch (error) {
|
|
557
|
+
notice(`Web build check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
558
|
+
}
|
|
559
|
+
const change = reloadCheck.diff(key, scopeIdentities(root, mount.scope, await facetEntries(root)));
|
|
560
|
+
if (change.first || change.changed.length === 0 && change.reselected.length === 0 && change.removed.length === 0) return;
|
|
561
|
+
const bundle = await loadComposition(root, mount.scope);
|
|
562
|
+
await hub.replaceFacets(mount, bundle.facets);
|
|
563
|
+
reloadCheck.commit(key, scopeIdentities(root, mount.scope, bundle.entries));
|
|
564
|
+
idleRestart.supersede(change.superseded);
|
|
565
|
+
publishWebMount(mount, root);
|
|
566
|
+
publishNativeMount(mount, root);
|
|
567
|
+
notice(`Reloaded ${mount.scope === "global" ? "global" : `workspace '${mount.workspaceId}'`} facets (${String(change.changed.length)} changed, ${String(change.removed.length)} removed).`);
|
|
568
|
+
}).catch((error) => notice(`Extension check of ${key} failed and retries at the next check: ${error instanceof Error ? error.message : String(error)}`));
|
|
569
|
+
scopeChecks.set(key, settled);
|
|
570
|
+
settled.then(() => {
|
|
571
|
+
if (scopeChecks.get(key) === settled) scopeChecks.delete(key);
|
|
572
|
+
});
|
|
573
|
+
return settled;
|
|
574
|
+
};
|
|
575
|
+
const loadSessionMcp = async (root, selection) => {
|
|
576
|
+
return telemetry.runInSpan("po_server.mcp_bundle_load", {}, async () => {
|
|
577
|
+
const entries = [];
|
|
578
|
+
const candidates = require_mcpBundle.mcpPluginCandidates(liveCompositions(root));
|
|
579
|
+
for (const { declaration, module, owners } of candidates) entries.push({
|
|
580
|
+
packageName: declaration.packageName,
|
|
581
|
+
...declaration.ui === void 0 ? {} : { widgets: declaration.ui.widgets },
|
|
582
|
+
entry: declaration.entry,
|
|
583
|
+
module,
|
|
584
|
+
url: await packageUrls.urlFor(module),
|
|
585
|
+
owners
|
|
586
|
+
});
|
|
587
|
+
let app;
|
|
588
|
+
try {
|
|
589
|
+
app = require_mcpAppBuild.readMcpAppBuild({
|
|
590
|
+
poHome: globalRoot,
|
|
591
|
+
candidates
|
|
592
|
+
});
|
|
593
|
+
} catch (error) {
|
|
594
|
+
notice(`The MCP app build could not be read: ${error instanceof Error ? error.message : String(error)}`);
|
|
595
|
+
}
|
|
596
|
+
if (app !== void 0 && app.build === void 0) {
|
|
597
|
+
notice(`MCP app build ${app.key} is not synced yet; this session runs without MCP widgets.`);
|
|
598
|
+
syncCheckpoints.requestMissing(`mcp-app:${app.key}`, "the MCP app build is missing");
|
|
599
|
+
}
|
|
600
|
+
const built = app?.build;
|
|
601
|
+
return (0, _agimon_ai_po_core_mcpFacet.loadMcpPlugins)({
|
|
602
|
+
entries,
|
|
603
|
+
...built === void 0 ? {} : { uiResource: (0, _agimon_ai_po_core_mcpFacet.mcpUiResource)(built.html, built.sha256) },
|
|
604
|
+
majorMode: selection.majorMode,
|
|
605
|
+
activeLayers: selection.activeLayers,
|
|
606
|
+
retainCandidates: true,
|
|
607
|
+
onNotice: notice,
|
|
608
|
+
poisoned: poisonedUrls,
|
|
609
|
+
importer: importLive
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
const sharedApiContext = {
|
|
614
|
+
homeDirectory,
|
|
615
|
+
environment: baseEnvironment,
|
|
616
|
+
hubToken: token,
|
|
617
|
+
sessionService: hub.sessionService,
|
|
618
|
+
mediaArbitration,
|
|
619
|
+
executionBudget,
|
|
620
|
+
peerAgents,
|
|
621
|
+
directEvents: hub.directEvents,
|
|
622
|
+
requestApi: (mount, basePath, request) => hub.requestApi(mount, basePath, request),
|
|
623
|
+
repositories: () => hub.workspaces().map((workspace) => ({
|
|
624
|
+
id: workspace.id,
|
|
625
|
+
path: workspace.root,
|
|
626
|
+
name: workspace.root.split("/").at(-1) ?? workspace.id,
|
|
627
|
+
active: hub.snapshot().some((session) => session.workspaceId === workspace.id)
|
|
628
|
+
})),
|
|
629
|
+
resolveRepository: (id) => hub.workspaces().find((workspace) => workspace.id === id)?.root,
|
|
630
|
+
/**
|
|
631
|
+
* Package readiness and the MCP projection, resolved live from the repository. The
|
|
632
|
+
* context stays until the next read replaces it: the projection names its staged files.
|
|
633
|
+
*/
|
|
634
|
+
readRepositorySync: async (id) => {
|
|
635
|
+
const root = hub.workspaces().find((workspace) => workspace.id === id)?.root;
|
|
636
|
+
if (!root) return void 0;
|
|
637
|
+
const environment = rootEnvironment(root);
|
|
638
|
+
const config = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfig)(root, homeDirectory, environment);
|
|
639
|
+
const missing = require_index$4.missingLayerPackageSpecifiers(config, Object.keys(config.layers), require_builders_cli_extensionAssembler_index.createLayerResolvers(root, environment));
|
|
640
|
+
const context = await require_harnessContext.buildHarnessContext(resolveHarnessOptions({
|
|
641
|
+
args: ["--cwd", root],
|
|
642
|
+
cwd: root,
|
|
643
|
+
environment
|
|
644
|
+
}));
|
|
645
|
+
const previous = repositoryContexts.get(root);
|
|
646
|
+
repositoryContexts.set(root, context);
|
|
647
|
+
await previous?.cleanup().catch((error) => notice(String(error)));
|
|
648
|
+
const status = syncCheckpoint(root, workspaceLabel(root, hub.workspaces().find((workspace) => workspace.id === id)?.name), false);
|
|
649
|
+
return {
|
|
650
|
+
fresh: missing.length === 0 && status.reasons.length === 0,
|
|
651
|
+
reasons: [...missing.map((specifier) => `configured package is not installed: ${specifier}`), ...status.reasons],
|
|
652
|
+
syncing: status.syncing,
|
|
653
|
+
mcpProjection: context.resources.mcpProjection
|
|
654
|
+
};
|
|
655
|
+
},
|
|
656
|
+
onNotice: notice
|
|
657
|
+
};
|
|
658
|
+
node_fs.default.mkdirSync(globalRoot, {
|
|
659
|
+
recursive: true,
|
|
660
|
+
mode: 448
|
|
661
|
+
});
|
|
662
|
+
const globalBundle = await loadComposition(globalRoot, "global");
|
|
663
|
+
remoteRuntime = (0, _agimon_ai_po_core_remoteRuntime.createRemoteRuntime)({
|
|
664
|
+
homeDirectory,
|
|
665
|
+
registrationToken: token,
|
|
666
|
+
onDeviceDropped: (id) => computerUse?.revokeDevice?.(id),
|
|
667
|
+
reservedPorts: () => [options.webPort],
|
|
668
|
+
bundleTrust: () => webCompositions?.shellTrust(),
|
|
669
|
+
attestHost: (fields) => webCompositions?.attestHost(fields),
|
|
670
|
+
onNotice: notice,
|
|
671
|
+
forward: async (request) => {
|
|
672
|
+
if (!cockpit || !attachToken) return Response.json({ error: "The headless server is not ready." }, { status: 503 });
|
|
673
|
+
const from = new URL(request.url);
|
|
674
|
+
const headers = new Headers(request.headers);
|
|
675
|
+
headers.set("x-po-token", attachToken);
|
|
676
|
+
return fetch(new URL(`${from.pathname}${from.search}`, cockpit.url), new Request(request, {
|
|
677
|
+
headers,
|
|
678
|
+
redirect: "manual"
|
|
679
|
+
}));
|
|
680
|
+
},
|
|
681
|
+
connectProtocol: (pathname, deviceId) => {
|
|
682
|
+
if (!cockpit || !attachToken) throw new Error("The headless protocol listener is not ready.");
|
|
683
|
+
const url = new URL(pathname, cockpit.url);
|
|
684
|
+
url.protocol = "ws:";
|
|
685
|
+
return new ws.default(url, { headers: {
|
|
686
|
+
"x-po-token": attachToken,
|
|
687
|
+
...deviceId === void 0 ? {} : {
|
|
688
|
+
"x-po-api-caller-locality": "remote",
|
|
689
|
+
"x-po-api-caller-device-id": deviceId,
|
|
690
|
+
"x-po-api-caller-step-up": "not-required"
|
|
691
|
+
}
|
|
692
|
+
} });
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
await hub.mountFacets(globalBundle.facets, {
|
|
696
|
+
...sharedApiContext,
|
|
697
|
+
scope: "global",
|
|
698
|
+
requestReceipts: requestReceipts.receipts,
|
|
699
|
+
remoteControl: { fetch: (request) => remoteRuntime.fetchLocal(request) }
|
|
700
|
+
});
|
|
701
|
+
reloadCheck.commit("global", scopeIdentities(globalRoot, "global", globalBundle.entries));
|
|
702
|
+
refreshWebBuild();
|
|
703
|
+
syncCheckpoint(globalRoot, "The global scope");
|
|
704
|
+
if (!backgroundSync.syncing) backgroundSync.request("server start");
|
|
705
|
+
const admissions = /* @__PURE__ */ new Map();
|
|
706
|
+
const isMemberCheckout = (from, workspace) => node_fs.default.realpathSync(require_index$1.findRepositoryRoot(from)) !== workspace.root;
|
|
707
|
+
admitWorkspace = async (from, requestedName) => {
|
|
708
|
+
const checkoutRoot = node_fs.default.realpathSync(require_index$1.findRepositoryRoot(from));
|
|
709
|
+
const { id, root, moved } = (0, _agimon_ai_po_core_history.identifyWorkspace)({
|
|
710
|
+
records: workspaces.list(),
|
|
711
|
+
checkoutRoot,
|
|
712
|
+
marker: (0, _agimon_ai_po_core_history.readWorkspaceMarker)(checkoutRoot)
|
|
713
|
+
});
|
|
714
|
+
const record = workspaces.list().find((workspace) => workspace.id === id);
|
|
715
|
+
const name = requestedName?.trim() || record?.name;
|
|
716
|
+
const named = name === void 0 ? {} : { name };
|
|
717
|
+
const renamed = record !== void 0 && name !== record.name;
|
|
718
|
+
const existing = hub.workspaces().find((workspace) => workspace.id === id);
|
|
719
|
+
if (existing !== void 0 && existing.available !== false && existing.root === root) {
|
|
720
|
+
await checkScope(root, {
|
|
721
|
+
scope: "workspace",
|
|
722
|
+
workspaceId: id
|
|
723
|
+
});
|
|
724
|
+
syncCheckpoint(root, workspaceLabel(root, name));
|
|
725
|
+
if (renamed) {
|
|
726
|
+
workspaces.add({
|
|
727
|
+
id,
|
|
728
|
+
root,
|
|
729
|
+
...named
|
|
730
|
+
});
|
|
731
|
+
hub.registerWorkspace({
|
|
732
|
+
...existing,
|
|
733
|
+
...named,
|
|
734
|
+
available: true
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return {
|
|
738
|
+
...existing,
|
|
739
|
+
...named,
|
|
740
|
+
available: true
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
const pending = admissions.get(id);
|
|
744
|
+
if (pending) return pending;
|
|
745
|
+
const wasRemembered = record !== void 0;
|
|
746
|
+
if (!wasRemembered || moved || renamed) workspaces.add({
|
|
747
|
+
id,
|
|
748
|
+
root,
|
|
749
|
+
...named
|
|
750
|
+
});
|
|
751
|
+
if (moved) notice(`Workspace '${id}' moved to '${root}'.`);
|
|
752
|
+
hub.registerWorkspace({
|
|
753
|
+
id,
|
|
754
|
+
root,
|
|
755
|
+
...named,
|
|
756
|
+
available: false
|
|
757
|
+
});
|
|
758
|
+
const admission = (async () => {
|
|
759
|
+
const bundle = await loadComposition(root, "workspace");
|
|
760
|
+
await hub.mountFacets(bundle.facets, {
|
|
761
|
+
...sharedApiContext,
|
|
762
|
+
scope: "workspace",
|
|
763
|
+
workspaceId: id,
|
|
764
|
+
workspaceRoot: root,
|
|
765
|
+
cwd: root,
|
|
766
|
+
resolveRepository: (requestedId) => requestedId === id ? root : void 0
|
|
767
|
+
});
|
|
768
|
+
reloadCheck.commit(`workspace:${id}`, scopeIdentities(root, "workspace", bundle.entries));
|
|
769
|
+
try {
|
|
770
|
+
refreshWebBuild();
|
|
771
|
+
publishWebMount({
|
|
772
|
+
scope: "workspace",
|
|
773
|
+
workspaceId: id
|
|
774
|
+
}, root);
|
|
775
|
+
publishNativeMount({
|
|
776
|
+
scope: "workspace",
|
|
777
|
+
workspaceId: id
|
|
778
|
+
}, root);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
notice(`Workspace '${id}' web build check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
781
|
+
}
|
|
782
|
+
syncCheckpoint(root, workspaceLabel(root, name));
|
|
783
|
+
try {
|
|
784
|
+
if ((0, _agimon_ai_po_core_history.readWorkspaceMarker)(root) === void 0) (0, _agimon_ai_po_core_history.writeWorkspaceMarker)(root, id);
|
|
785
|
+
} catch (error) {
|
|
786
|
+
notice(`Workspace '${root}' id could not be recorded in its git data: ${error instanceof Error ? error.message : String(error)}`);
|
|
787
|
+
}
|
|
788
|
+
return {
|
|
789
|
+
id,
|
|
790
|
+
root,
|
|
791
|
+
...named,
|
|
792
|
+
available: true
|
|
793
|
+
};
|
|
794
|
+
})();
|
|
795
|
+
admissions.set(id, admission);
|
|
796
|
+
try {
|
|
797
|
+
return await admission;
|
|
798
|
+
} catch (error) {
|
|
799
|
+
if (!wasRemembered) {
|
|
800
|
+
await hub.removeWorkspace(id);
|
|
801
|
+
workspaces.remove(id);
|
|
802
|
+
}
|
|
803
|
+
throw error;
|
|
804
|
+
} finally {
|
|
805
|
+
admissions.delete(id);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
for (const record of openSessions.list()) {
|
|
809
|
+
if (workspaces.list().some((workspace) => workspace.id === record.workspaceId)) continue;
|
|
810
|
+
try {
|
|
811
|
+
const candidate = record.groupingRoot ?? record.cwd;
|
|
812
|
+
const root = node_fs.default.realpathSync(require_index$1.findRepositoryRoot(candidate));
|
|
813
|
+
if ((record.groupingRoot === void 0 || root === candidate) && !workspaces.list().some((workspace) => workspace.root === root)) workspaces.add({
|
|
814
|
+
id: record.workspaceId,
|
|
815
|
+
root
|
|
816
|
+
});
|
|
817
|
+
else notice(`Session '${record.sessionId}' no longer resolves to its recorded workspace; skipping registration.`);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
notice(`Session '${record.sessionId}' workspace could not be registered: ${error instanceof Error ? error.message : String(error)}`);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
for (const workspace of workspaces.list()) {
|
|
823
|
+
hub.registerWorkspace({
|
|
824
|
+
...workspace,
|
|
825
|
+
available: false
|
|
826
|
+
});
|
|
827
|
+
try {
|
|
828
|
+
if (node_fs.default.realpathSync(require_index$1.findRepositoryRoot(workspace.root)) !== workspace.root) {
|
|
829
|
+
notice(`Workspace '${workspace.root}' no longer resolves to its recorded identity; leaving it unavailable.`);
|
|
830
|
+
continue;
|
|
831
|
+
}
|
|
832
|
+
await admitWorkspace(workspace.root);
|
|
833
|
+
} catch (error) {
|
|
834
|
+
notice(`Workspace '${workspace.root}' could not be restored: ${error instanceof Error ? error.message : String(error)}`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
const sessionDescriptors = /* @__PURE__ */ new WeakMap();
|
|
838
|
+
const sessionHookModules = (context, sourceRoot) => {
|
|
839
|
+
let descriptor = sessionDescriptors.get(context);
|
|
840
|
+
if (descriptor === void 0) {
|
|
841
|
+
descriptor = context.options.hooks ? liveHookModules(sourceRoot).then((admitted) => require_index$6.checkoutHookDescriptor(admitted, sourceRoot, context.options.repoRoot, context.resources.temporaryDirectory)) : Promise.resolve(void 0);
|
|
842
|
+
sessionDescriptors.set(context, descriptor);
|
|
843
|
+
}
|
|
844
|
+
return descriptor;
|
|
845
|
+
};
|
|
846
|
+
const sessionHostOptions = (context, bundle, mcpBundle, identity, workspace, explicit = { pinned: [] }) => {
|
|
847
|
+
const policyOptions = context.options;
|
|
848
|
+
const sessionSelection = {
|
|
849
|
+
root: policyOptions.repoRoot,
|
|
850
|
+
majorMode: policyOptions.majorMode,
|
|
851
|
+
activeLayers: context.selectedLayers,
|
|
852
|
+
domains: policyOptions.domains,
|
|
853
|
+
profile: context.profile,
|
|
854
|
+
state: { "minor-mode": [...explicit.minorModes ?? []] }
|
|
855
|
+
};
|
|
856
|
+
const sessionEnvironment = context.environment;
|
|
857
|
+
require_index.updateHarnessState({ compositionFingerprint: require_builders_cli_extensionAssembler_index.resolveExtensionComposition({
|
|
858
|
+
majorMode: policyOptions.majorMode,
|
|
859
|
+
layers: [...context.selectedLayers],
|
|
860
|
+
majorModesConfig: (0, _agimon_ai_po_config_majorModes.loadMajorModesConfig)(policyOptions.repoRoot, homeDirectory, sessionEnvironment),
|
|
861
|
+
resolvers: require_builders_cli_extensionAssembler_index.createLayerResolvers(policyOptions.repoRoot, sessionEnvironment),
|
|
862
|
+
tolerateUnsynced: true
|
|
863
|
+
}).fingerprint }, sessionEnvironment);
|
|
864
|
+
return {
|
|
865
|
+
cwd: policyOptions.cwd,
|
|
866
|
+
repoRoot: policyOptions.repoRoot,
|
|
867
|
+
sessionId: identity.sessionId,
|
|
868
|
+
workspaceId: workspace.id,
|
|
869
|
+
groupingRoot: workspace.root,
|
|
870
|
+
sessionName: identity.sessionName,
|
|
871
|
+
...explicit.initialFastMode === void 0 ? {} : { initialFastMode: explicit.initialFastMode },
|
|
872
|
+
...explicit.initialAgentLocked === void 0 ? {} : { initialAgentLocked: explicit.initialAgentLocked },
|
|
873
|
+
webComposition: publishWebMount({
|
|
874
|
+
scope: "session",
|
|
875
|
+
sessionId: identity.sessionId
|
|
876
|
+
}, workspace.root),
|
|
877
|
+
nativeComposition: publishNativeMount({
|
|
878
|
+
scope: "session",
|
|
879
|
+
sessionId: identity.sessionId
|
|
880
|
+
}, workspace.root),
|
|
881
|
+
...identity.parentSessionId === void 0 ? {} : { parentSessionId: identity.parentSessionId },
|
|
882
|
+
...identity.sessionProvenance === void 0 ? {} : { sessionProvenance: identity.sessionProvenance },
|
|
883
|
+
agentArgs: policyOptions.piArgs,
|
|
884
|
+
environment: Object.freeze({ ...context.environment }),
|
|
885
|
+
selection: sessionSelection,
|
|
886
|
+
...explicit.allowedTools === void 0 ? {} : { allowedTools: explicit.allowedTools },
|
|
887
|
+
selectionOverrides: [
|
|
888
|
+
"majorMode",
|
|
889
|
+
"domains",
|
|
890
|
+
"profile"
|
|
891
|
+
].filter((axis) => {
|
|
892
|
+
if (explicit.pinned.includes(axis)) return true;
|
|
893
|
+
const flag = axis === "majorMode" ? "--major-mode" : `--${axis}`;
|
|
894
|
+
return identity.sessionId === resolved.identity.sessionId && resolved.agentArgs.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
|
|
895
|
+
}),
|
|
896
|
+
inheritedSelection: () => {
|
|
897
|
+
const environment = { ...baseEnvironment };
|
|
898
|
+
for (const key of [_agimon_ai_po_config_harnessStore.HARNESS_STATE_POINTER, ...Object.values(_agimon_ai_po_config_harnessState.HARNESS_STATE_KEYS)]) delete environment[key];
|
|
899
|
+
const defaults = resolveHarnessOptions({
|
|
900
|
+
args: ["--cwd", policyOptions.cwd],
|
|
901
|
+
cwd: policyOptions.cwd,
|
|
902
|
+
environment,
|
|
903
|
+
...policyOptions.configRoot === void 0 ? {} : { configRoot: policyOptions.configRoot }
|
|
904
|
+
});
|
|
905
|
+
return {
|
|
906
|
+
majorMode: defaults.majorMode,
|
|
907
|
+
domains: defaults.domains,
|
|
908
|
+
profile: defaults.profile
|
|
909
|
+
};
|
|
910
|
+
},
|
|
911
|
+
candidates: bundle.entries,
|
|
912
|
+
providerOverrides: () => (0, _agimon_ai_po_core_serverFacet.selectedServerProviderOverrides)(bundle.facets, sessionEnvironment),
|
|
913
|
+
requiredServerPackages: async () => {
|
|
914
|
+
const harness = (0, _agimon_ai_po_config_harnessStore.loadHarnessState)(sessionEnvironment).state;
|
|
915
|
+
if (!harness.hooks) return [];
|
|
916
|
+
return await require_index$6.validateHookModules({
|
|
917
|
+
repoRoot: policyOptions.repoRoot,
|
|
918
|
+
configRoot: policyOptions.configRoot,
|
|
919
|
+
homeDirectory,
|
|
920
|
+
hookGroups: harness.hookGroups,
|
|
921
|
+
descriptor: harness.hookModules,
|
|
922
|
+
isSubagent: Boolean(sessionEnvironment.PI_SUBAGENT_CHILD)
|
|
923
|
+
}) ? ["@agimon-ai/po-hook"] : [];
|
|
924
|
+
},
|
|
925
|
+
mcpPlugins: mcpBundle.plugins,
|
|
926
|
+
resolveSelection: (requested) => {
|
|
927
|
+
const config = (0, _agimon_ai_po_config_majorModes.loadMajorModesConfig)(policyOptions.configRoot ?? policyOptions.repoRoot, policyOptions.homeDirectory, policyOptions.environment ?? baseEnvironment);
|
|
928
|
+
return {
|
|
929
|
+
...requested,
|
|
930
|
+
activeLayers: (0, _agimon_ai_po_config_majorModes.filterHookDisabledLayers)(config, (0, _agimon_ai_po_config_majorModes.resolveLayers)(config, requested.majorMode), policyOptions.hooks)
|
|
931
|
+
};
|
|
932
|
+
},
|
|
933
|
+
telemetry,
|
|
934
|
+
onNotice: notice
|
|
935
|
+
};
|
|
936
|
+
};
|
|
937
|
+
mountSessionApis = (sessionOptions, host) => (0, _agimon_ai_po_core_packageApiServer.serveSessionApis)({
|
|
938
|
+
sessionId: sessionOptions.sessionId,
|
|
939
|
+
cwd: sessionOptions.cwd,
|
|
940
|
+
environment: sessionOptions.environment,
|
|
941
|
+
directEvents: hub.directEvents,
|
|
942
|
+
requestApi: (mount, basePath, request) => hub.requestApi(mount, basePath, request),
|
|
943
|
+
publishActivity: (activity) => hub.setSessionActivity?.(sessionOptions.sessionId, activity),
|
|
944
|
+
shareFile: (filePath, label) => remoteRuntime === void 0 ? Promise.reject(new Error(_agimon_ai_po_core_packageApi.DOOM_SHARE_FILE_REMOTE_OFF_MESSAGE)) : remoteRuntime.fileShares.mint({
|
|
945
|
+
sessionId: sessionOptions.sessionId,
|
|
946
|
+
cwd: sessionOptions.cwd,
|
|
947
|
+
path: filePath,
|
|
948
|
+
label
|
|
949
|
+
}),
|
|
950
|
+
...computerUse === void 0 ? {} : { computerUse: {
|
|
951
|
+
get available() {
|
|
952
|
+
return computerUse.available;
|
|
953
|
+
},
|
|
954
|
+
get enabled() {
|
|
955
|
+
return computerUse.enabled === true;
|
|
956
|
+
},
|
|
957
|
+
authorize: (headers) => computerUse.authorizeSession?.(sessionOptions.sessionId, headers) === true || computerUse.authorize?.(headers) === true,
|
|
958
|
+
authorizeRecording: (headers) => computerUse.authorizeRecording?.(sessionOptions.sessionId, headers) === true,
|
|
959
|
+
authorizeActivation: (headers) => computerUse.authorizeActivation?.(headers) === true,
|
|
960
|
+
claim: (headers) => computerUse.claimSession?.(sessionOptions.sessionId, headers),
|
|
961
|
+
fetchRecording: (artifactId, range) => computerUse.readRecording?.({
|
|
962
|
+
sessionId: sessionOptions.sessionId,
|
|
963
|
+
cwd: sessionOptions.cwd
|
|
964
|
+
}, artifactId, range) ?? Promise.resolve(Response.json({ error: "Not found." }, { status: 404 })),
|
|
965
|
+
subscribe: (listener) => computerUse.subscribe?.(listener, sessionOptions.sessionId) ?? (() => void 0)
|
|
966
|
+
} },
|
|
967
|
+
hubToken: token,
|
|
968
|
+
sessionService: hub.sessionService,
|
|
969
|
+
mediaArbitration,
|
|
970
|
+
executionBudget,
|
|
971
|
+
peerAgents,
|
|
972
|
+
pluginRegistry: hub.pluginRegistry,
|
|
973
|
+
apis: [],
|
|
974
|
+
facets: pendingSessions.get(sessionOptions.sessionId)?.bundle.facets ?? [],
|
|
975
|
+
workspaceId: sessionOptions.workspaceId,
|
|
976
|
+
workspaceRoot: sessionOptions.repoRoot,
|
|
977
|
+
...host.sessionContext === void 0 ? {} : { sessionContext: host.sessionContext },
|
|
978
|
+
homeDirectory,
|
|
979
|
+
mountChannel: (channel) => {
|
|
980
|
+
return {
|
|
981
|
+
mounted: true,
|
|
982
|
+
dispose: hub.registerChannel(channel, {
|
|
983
|
+
scope: "session",
|
|
984
|
+
sessionId: sessionOptions.sessionId
|
|
985
|
+
})
|
|
986
|
+
};
|
|
987
|
+
},
|
|
988
|
+
prepareFacets: (root) => {
|
|
989
|
+
sessionServiceRoots.set(host, root);
|
|
990
|
+
host.prepareFacets(root);
|
|
991
|
+
},
|
|
992
|
+
activateFacets: host.activateFacets,
|
|
993
|
+
canDispatch: host.canDispatch,
|
|
994
|
+
telemetry,
|
|
995
|
+
onNotice: notice
|
|
996
|
+
});
|
|
997
|
+
requestSessionApi = async (scope, request) => {
|
|
998
|
+
const session = hub.session(scope.sessionId);
|
|
999
|
+
const artifacts = sessionArtifacts.get(scope.sessionId);
|
|
1000
|
+
if (session === void 0 || session.cwd !== scope.cwd || artifacts === void 0) return Response.json({ error: "Session not found." }, { status: 404 });
|
|
1001
|
+
if (!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(request.basePath)) return Response.json({ error: "Invalid session API base path." }, { status: 400 });
|
|
1002
|
+
if (!request.path.startsWith("/") || request.path.startsWith("//") || request.path.includes("#")) return Response.json({ error: "Invalid session API path." }, { status: 400 });
|
|
1003
|
+
const body = request.body === null || request.body === void 0 ? void 0 : request.body;
|
|
1004
|
+
return artifacts.apis.request(new Request(`http://po.local/api/plugins/${request.basePath}${request.path}`, {
|
|
1005
|
+
method: request.method,
|
|
1006
|
+
headers: request.headers,
|
|
1007
|
+
...body === void 0 ? {} : { body },
|
|
1008
|
+
...request.signal === void 0 ? {} : { signal: request.signal }
|
|
1009
|
+
}));
|
|
1010
|
+
};
|
|
1011
|
+
if (!options.noSession) {
|
|
1012
|
+
const initialOptions = resolveHarnessOptions({
|
|
1013
|
+
args: resolved.agentArgs,
|
|
1014
|
+
cwd: baseCwd,
|
|
1015
|
+
environment: baseEnvironment
|
|
1016
|
+
});
|
|
1017
|
+
const initialWorkspace = await admitWorkspace(initialOptions.repoRoot);
|
|
1018
|
+
launchWorkspaceId = initialWorkspace.id;
|
|
1019
|
+
harnessContext = await require_harnessContext.buildHarnessContext(resolveHarnessOptions({
|
|
1020
|
+
args: resolved.agentArgs,
|
|
1021
|
+
cwd: baseCwd,
|
|
1022
|
+
environment: baseEnvironment
|
|
1023
|
+
}), harnessTelemetry);
|
|
1024
|
+
const activeHarnessContext = harnessContext;
|
|
1025
|
+
try {
|
|
1026
|
+
const hookModules = await sessionHookModules(harnessContext, initialWorkspace.root);
|
|
1027
|
+
require_index.updateHarnessState({ hookModules }, harnessContext.environment);
|
|
1028
|
+
if (harnessContext.options.hooks) await require_index$6.validateHookModules({
|
|
1029
|
+
repoRoot: harnessContext.options.repoRoot,
|
|
1030
|
+
configRoot: initialWorkspace.root,
|
|
1031
|
+
homeDirectory,
|
|
1032
|
+
hookGroups: harnessContext.hookGroups,
|
|
1033
|
+
descriptor: hookModules,
|
|
1034
|
+
isSubagent: Boolean(baseEnvironment.PI_SUBAGENT_CHILD)
|
|
1035
|
+
});
|
|
1036
|
+
const initialBundle = await loadComposition(harnessContext.options.repoRoot, "session", {
|
|
1037
|
+
root: harnessContext.options.repoRoot,
|
|
1038
|
+
majorMode: harnessContext.options.majorMode,
|
|
1039
|
+
activeLayers: harnessContext.selectedLayers
|
|
1040
|
+
});
|
|
1041
|
+
const initialMcpBundle = await loadSessionMcp(harnessContext.options.repoRoot, {
|
|
1042
|
+
majorMode: harnessContext.options.majorMode,
|
|
1043
|
+
activeLayers: harnessContext.selectedLayers
|
|
1044
|
+
});
|
|
1045
|
+
pendingSessions.set(resolved.identity.sessionId, {
|
|
1046
|
+
cleanup: () => activeHarnessContext.cleanup(),
|
|
1047
|
+
bundle: initialBundle,
|
|
1048
|
+
mcpBundle: initialMcpBundle
|
|
1049
|
+
});
|
|
1050
|
+
await hub.create(sessionHostOptions(harnessContext, initialBundle, initialMcpBundle, resolved.identity, initialWorkspace));
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
pendingSessions.delete(resolved.identity.sessionId);
|
|
1053
|
+
await activeHarnessContext.cleanup().catch((cleanupError) => notice(String(cleanupError)));
|
|
1054
|
+
throw error;
|
|
1055
|
+
}
|
|
1056
|
+
await bounded(harnessTelemetry.flush(), "initial composition telemetry flush", notice);
|
|
1057
|
+
}
|
|
1058
|
+
const reservedOpens = /* @__PURE__ */ new Map();
|
|
1059
|
+
openSession = async (request, sessionId, groupingWorkspaceId) => {
|
|
1060
|
+
request.signal?.throwIfAborted();
|
|
1061
|
+
if (request.reservationId !== void 0) {
|
|
1062
|
+
if (!request.parentSessionId || !cockpit) throw new Error("A reserved session requires its owning parent.");
|
|
1063
|
+
const prepared = await cockpit.sessionReservations.prepare(request.reservationId, request.parentSessionId, request.cwd);
|
|
1064
|
+
if (sessionId !== void 0 && sessionId !== prepared.sessionId) throw new Error("Reserved session identity cannot change.");
|
|
1065
|
+
sessionId = prepared.sessionId;
|
|
1066
|
+
const existing = hub.session(sessionId);
|
|
1067
|
+
if (existing) {
|
|
1068
|
+
if (existing.cwd !== prepared.cwd || existing.parentSessionId !== request.parentSessionId) throw new Error("Reserved session target does not match.");
|
|
1069
|
+
return {
|
|
1070
|
+
sessionId,
|
|
1071
|
+
cwd: existing.cwd,
|
|
1072
|
+
workspaceId: existing.workspaceId
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
if (openSessions.list().some((record) => record.sessionId === sessionId)) throw new Error("Resume the recorded session instead of recreating it.");
|
|
1076
|
+
const pending = reservedOpens.get(sessionId);
|
|
1077
|
+
if (pending) return pending;
|
|
1078
|
+
request = {
|
|
1079
|
+
...request,
|
|
1080
|
+
cwd: prepared.cwd
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
const identity = {
|
|
1084
|
+
sessionId: sessionId ?? node_crypto.default.randomUUID(),
|
|
1085
|
+
sessionName: request.name,
|
|
1086
|
+
parentSessionId: request.parentSessionId,
|
|
1087
|
+
sessionProvenance: request.sessionProvenance
|
|
1088
|
+
};
|
|
1089
|
+
const inheritedWorkspaceId = groupingWorkspaceId ?? (request.parentSessionId ? hub.session(request.parentSessionId)?.workspaceId ?? openSessions.list().find((record) => record.sessionId === request.parentSessionId)?.workspaceId : void 0);
|
|
1090
|
+
const explicit = require_sessionArguments.sessionSelectionArgs(request);
|
|
1091
|
+
const start = (async () => {
|
|
1092
|
+
const parent = request.parentSessionId !== void 0 && (sessionId === void 0 || request.reservationId !== void 0) ? sessionManager.get(request.parentSessionId) : void 0;
|
|
1093
|
+
let initialFastMode;
|
|
1094
|
+
if (parent !== void 0) {
|
|
1095
|
+
const state = await parent.runtime.readState();
|
|
1096
|
+
if (typeof state.fastMode !== "boolean") throw new Error("Parent Fast mode must be a boolean.");
|
|
1097
|
+
initialFastMode = state.fastMode;
|
|
1098
|
+
}
|
|
1099
|
+
const childIdentity = require_sessionArguments.resolveSessionIdentity([], identity);
|
|
1100
|
+
if (sessionId !== void 0 && request.reservationId === void 0) childIdentity.agentArgs.push("--session", node_path.default.join(serverDirectory, "sessions", "durable-v1", `${childIdentity.identity.sessionId}.sqlite`));
|
|
1101
|
+
const childEnvironment = {
|
|
1102
|
+
...baseEnvironment,
|
|
1103
|
+
...request.environment
|
|
1104
|
+
};
|
|
1105
|
+
for (const key of [_agimon_ai_po_config_harnessStore.HARNESS_STATE_POINTER, ...Object.values(_agimon_ai_po_config_harnessState.HARNESS_STATE_KEYS)]) delete childEnvironment[key];
|
|
1106
|
+
const workspace = inheritedWorkspaceId === void 0 ? await admitWorkspace(request.cwd) : hub.workspaces().find((candidate) => candidate.id === inheritedWorkspaceId && candidate.available !== false);
|
|
1107
|
+
if (workspace === void 0) throw new Error("The session workspace is unavailable.");
|
|
1108
|
+
await checkScope(globalRoot, { scope: "global" });
|
|
1109
|
+
syncCheckpoint(globalRoot, "The global scope");
|
|
1110
|
+
if (inheritedWorkspaceId !== void 0) {
|
|
1111
|
+
await checkScope(workspace.root, {
|
|
1112
|
+
scope: "workspace",
|
|
1113
|
+
workspaceId: workspace.id
|
|
1114
|
+
});
|
|
1115
|
+
syncCheckpoint(workspace.root, workspaceLabel(workspace.root, workspace.name));
|
|
1116
|
+
}
|
|
1117
|
+
const member = isMemberCheckout(request.cwd, workspace);
|
|
1118
|
+
const childContext = await require_harnessContext.buildHarnessContext(resolveHarnessOptions({
|
|
1119
|
+
args: [
|
|
1120
|
+
"--cwd",
|
|
1121
|
+
request.cwd,
|
|
1122
|
+
...childIdentity.agentArgs,
|
|
1123
|
+
...explicit.args
|
|
1124
|
+
],
|
|
1125
|
+
cwd: request.cwd,
|
|
1126
|
+
environment: childEnvironment,
|
|
1127
|
+
...member ? { configRoot: workspace.root } : {}
|
|
1128
|
+
}), harnessTelemetry);
|
|
1129
|
+
try {
|
|
1130
|
+
const hookModules = await sessionHookModules(childContext, workspace.root);
|
|
1131
|
+
require_index.updateHarnessState({ hookModules }, childContext.environment);
|
|
1132
|
+
if (childContext.options.hooks) await require_index$6.validateHookModules({
|
|
1133
|
+
repoRoot: childContext.options.repoRoot,
|
|
1134
|
+
configRoot: workspace.root,
|
|
1135
|
+
homeDirectory,
|
|
1136
|
+
hookGroups: childContext.hookGroups,
|
|
1137
|
+
descriptor: hookModules,
|
|
1138
|
+
isSubagent: Boolean(childEnvironment.PI_SUBAGENT_CHILD)
|
|
1139
|
+
});
|
|
1140
|
+
const bundle = await loadComposition(childContext.options.repoRoot, "session", {
|
|
1141
|
+
root: childContext.options.repoRoot,
|
|
1142
|
+
majorMode: childContext.options.majorMode,
|
|
1143
|
+
activeLayers: childContext.selectedLayers
|
|
1144
|
+
});
|
|
1145
|
+
const mcpBundle = await loadSessionMcp(childContext.options.repoRoot, {
|
|
1146
|
+
majorMode: childContext.options.majorMode,
|
|
1147
|
+
activeLayers: childContext.selectedLayers
|
|
1148
|
+
});
|
|
1149
|
+
request.signal?.throwIfAborted();
|
|
1150
|
+
pendingSessions.set(identity.sessionId, {
|
|
1151
|
+
cleanup: () => childContext.cleanup(),
|
|
1152
|
+
bundle,
|
|
1153
|
+
mcpBundle
|
|
1154
|
+
});
|
|
1155
|
+
const created = await hub.create(sessionHostOptions(childContext, bundle, mcpBundle, identity, workspace, {
|
|
1156
|
+
pinned: explicit.pinned,
|
|
1157
|
+
...initialFastMode === void 0 ? {} : { initialFastMode },
|
|
1158
|
+
...request.reservationId === void 0 ? {} : { initialAgentLocked: true },
|
|
1159
|
+
...request.selection?.minorModes === void 0 ? {} : { minorModes: request.selection.minorModes },
|
|
1160
|
+
...request.tools === void 0 ? {} : { allowedTools: request.tools }
|
|
1161
|
+
}));
|
|
1162
|
+
request.signal?.throwIfAborted();
|
|
1163
|
+
if (created.workspaceId !== void 0) {
|
|
1164
|
+
if (openSessions.add({
|
|
1165
|
+
sessionId: created.id,
|
|
1166
|
+
workspaceId: created.workspaceId,
|
|
1167
|
+
cwd: created.cwd,
|
|
1168
|
+
repoRoot: childContext.options.repoRoot,
|
|
1169
|
+
groupingRoot: workspace.root,
|
|
1170
|
+
name: created.name,
|
|
1171
|
+
createdAt: created.createdAt,
|
|
1172
|
+
...created.parentSessionId === void 0 ? {} : { parentSessionId: created.parentSessionId },
|
|
1173
|
+
...created.sessionProvenance === void 0 ? {} : { sessionProvenance: created.sessionProvenance }
|
|
1174
|
+
}) === false) throw new Error("The new session could not be durably recorded.");
|
|
1175
|
+
}
|
|
1176
|
+
return {
|
|
1177
|
+
sessionId: identity.sessionId,
|
|
1178
|
+
cwd: childContext.options.cwd,
|
|
1179
|
+
workspaceId: created.workspaceId
|
|
1180
|
+
};
|
|
1181
|
+
} catch (error) {
|
|
1182
|
+
if (hub.session(identity.sessionId)) await hub.closeSession(identity.sessionId);
|
|
1183
|
+
else {
|
|
1184
|
+
pendingSessions.delete(identity.sessionId);
|
|
1185
|
+
await childContext.cleanup().catch((cleanupError) => notice(String(cleanupError)));
|
|
1186
|
+
}
|
|
1187
|
+
throw error;
|
|
1188
|
+
}
|
|
1189
|
+
})();
|
|
1190
|
+
if (request.reservationId !== void 0) reservedOpens.set(identity.sessionId, start);
|
|
1191
|
+
try {
|
|
1192
|
+
return await start;
|
|
1193
|
+
} finally {
|
|
1194
|
+
if (reservedOpens.get(identity.sessionId) === start) reservedOpens.delete(identity.sessionId);
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
const checkAllScopes = async () => {
|
|
1198
|
+
await checkScope(globalRoot, { scope: "global" });
|
|
1199
|
+
for (const workspace of hub.workspaces()) if (workspace.available !== false) await checkScope(workspace.root, {
|
|
1200
|
+
scope: "workspace",
|
|
1201
|
+
workspaceId: workspace.id
|
|
1202
|
+
});
|
|
1203
|
+
};
|
|
1204
|
+
onExtensionCheck?.(checkAllScopes);
|
|
1205
|
+
/**
|
|
1206
|
+
* A finished background sync goes through the same live reload: the read-only refresh
|
|
1207
|
+
* republishes a changed build, and each scope re-imports only packages whose URLs moved.
|
|
1208
|
+
* Session facets and the MCP app switch at the next session. The warnings are re-read
|
|
1209
|
+
* without requesting another sync, so a sync that could not fix a root never loops.
|
|
1210
|
+
*/
|
|
1211
|
+
pickUpSync = async () => {
|
|
1212
|
+
await checkAllScopes();
|
|
1213
|
+
syncCheckpoint(globalRoot, "The global scope", false);
|
|
1214
|
+
for (const workspace of hub.workspaces()) if (workspace.available !== false) syncCheckpoint(workspace.root, workspaceLabel(workspace.root, workspace.name), false);
|
|
1215
|
+
};
|
|
1216
|
+
});
|
|
1217
|
+
const workspaceResumes = /* @__PURE__ */ new Map();
|
|
1218
|
+
const savedHistory = async (workspaceId) => {
|
|
1219
|
+
const root = hub.workspaces().find((workspace) => workspace.id === workspaceId && workspace.available !== false)?.root;
|
|
1220
|
+
if (!root) throw new Error("Workspace not found.");
|
|
1221
|
+
return (0, _agimon_ai_po_core_history.listSavedSessionRecords)(node_path.default.join(serverDirectory, "sessions"), root, new Set(hub.snapshot().map((active) => active.id)), workspaceId);
|
|
1222
|
+
};
|
|
1223
|
+
const validateExecution = (target, workspaceId) => {
|
|
1224
|
+
const root = hub.workspaces().find((workspace) => workspace.id === workspaceId && workspace.available !== false)?.root;
|
|
1225
|
+
if (!root || target.groupingRoot !== root || target.workspaceId && target.workspaceId !== workspaceId) throw new Error("Saved session does not belong to this workspace.");
|
|
1226
|
+
if (node_fs.default.realpathSync(require_index$1.findRepositoryRoot(target.cwd)) !== target.repoRoot) throw new Error("Saved session checkout is unavailable.");
|
|
1227
|
+
};
|
|
1228
|
+
const reviveRecord = async (record) => {
|
|
1229
|
+
const groupingRoot = hub.workspaces().find((workspace) => workspace.id === record.workspaceId && workspace.available !== false)?.root;
|
|
1230
|
+
if (!groupingRoot || record.groupingRoot !== void 0 && groupingRoot !== record.groupingRoot) throw new Error("The session workspace is unavailable.");
|
|
1231
|
+
if (record.repoRoot !== void 0 && node_fs.default.realpathSync(require_index$1.findRepositoryRoot(record.cwd)) !== record.repoRoot) throw new Error("The session checkout has changed.");
|
|
1232
|
+
await openSession({
|
|
1233
|
+
cwd: record.cwd,
|
|
1234
|
+
name: record.name,
|
|
1235
|
+
...record.parentSessionId === void 0 ? {} : { parentSessionId: record.parentSessionId },
|
|
1236
|
+
...record.sessionProvenance === void 0 ? {} : { sessionProvenance: record.sessionProvenance }
|
|
1237
|
+
}, record.sessionId, record.workspaceId);
|
|
1238
|
+
};
|
|
1239
|
+
cockpit = await (0, _agimon_ai_po_core_headlessServer.serveHeadlessServer)({
|
|
1240
|
+
port: options.webPort,
|
|
1241
|
+
headlessHub: hub,
|
|
1242
|
+
token: attachToken,
|
|
1243
|
+
sessionMcpPublicOrigin: () => remoteRuntime?.remote.publicOrigin(),
|
|
1244
|
+
sessionMcpStateDir: serverDirectory,
|
|
1245
|
+
sessionMcpPublicOriginRevision: () => remoteRuntime?.remote.publicOriginRevision() ?? 0,
|
|
1246
|
+
isSessionPersisted: (sessionId, cwd) => openSessions.list().some((record) => record.sessionId === sessionId && record.cwd === cwd),
|
|
1247
|
+
workspaceHistory: async (workspaceId) => (await savedHistory(workspaceId)).map((record) => record.summary),
|
|
1248
|
+
resumeWorkspaceSession: async (workspaceId, targetSessionId) => {
|
|
1249
|
+
const key = `${workspaceId}\0${targetSessionId}`;
|
|
1250
|
+
const pending = workspaceResumes.get(key);
|
|
1251
|
+
if (pending) return pending;
|
|
1252
|
+
const resume = (async () => {
|
|
1253
|
+
const target = (await savedHistory(workspaceId)).find((item) => item.summary.id === targetSessionId);
|
|
1254
|
+
if (!target) throw new Error("Saved Pi 1.0 session not found in this workspace. Earlier sessions cannot be resumed.");
|
|
1255
|
+
validateExecution(target.execution, workspaceId);
|
|
1256
|
+
await openSession({
|
|
1257
|
+
cwd: target.execution.cwd,
|
|
1258
|
+
name: target.summary.name ?? "untitled",
|
|
1259
|
+
...target.execution.parentSessionId ? { parentSessionId: target.execution.parentSessionId } : {},
|
|
1260
|
+
...target.execution.sessionProvenance ? { sessionProvenance: target.execution.sessionProvenance } : {}
|
|
1261
|
+
}, target.summary.id, workspaceId);
|
|
1262
|
+
return target.summary.id;
|
|
1263
|
+
})();
|
|
1264
|
+
workspaceResumes.set(key, resume);
|
|
1265
|
+
try {
|
|
1266
|
+
return await resume;
|
|
1267
|
+
} finally {
|
|
1268
|
+
workspaceResumes.delete(key);
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
sessionHistory: (session) => {
|
|
1272
|
+
const workspaceRoot = hub.workspaces().find((workspace) => workspace.id === session.workspaceId)?.root;
|
|
1273
|
+
if (!workspaceRoot) throw new Error("Session workspace not found.");
|
|
1274
|
+
return (0, _agimon_ai_po_core_history.listSavedSessions)(node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(baseEnvironment), "server", "sessions"), workspaceRoot, new Set(hub.snapshot().map((active) => active.id)), session.workspaceId);
|
|
1275
|
+
},
|
|
1276
|
+
readDormantTranscript: (record, request, context) => {
|
|
1277
|
+
const workspaceRoot = hub.workspaces().find((workspace) => workspace.id === record.workspaceId)?.root;
|
|
1278
|
+
if (!workspaceRoot || record.groupingRoot !== void 0 && record.groupingRoot !== workspaceRoot) throw new Error("Saved transcript unavailable.");
|
|
1279
|
+
const owner = node_fs.default.realpathSync(require_index$1.findRepositoryRoot(record.cwd));
|
|
1280
|
+
if (record.repoRoot !== void 0 && record.repoRoot !== owner) throw new Error("Saved transcript checkout has changed.");
|
|
1281
|
+
return (0, _agimon_ai_po_core_history.readSqliteTranscript)(node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(baseEnvironment), "server", "sessions", "durable-v1", `${record.sessionId}.sqlite`), request, context, {
|
|
1282
|
+
sessionId: record.sessionId,
|
|
1283
|
+
workspaceRoot: owner,
|
|
1284
|
+
workspaceId: record.workspaceId,
|
|
1285
|
+
groupingRoot: workspaceRoot
|
|
1286
|
+
});
|
|
1287
|
+
},
|
|
1288
|
+
restartSession: async (session) => {
|
|
1289
|
+
const record = openSessions.list().find((entry) => entry.sessionId === session.id);
|
|
1290
|
+
if (!hub.workspaces().find((workspace) => workspace.id === session.workspaceId && workspace.available !== false)?.root) throw new Error("Session workspace not found.");
|
|
1291
|
+
await hub.closeSession(session.id);
|
|
1292
|
+
try {
|
|
1293
|
+
await openSession({
|
|
1294
|
+
cwd: session.cwd,
|
|
1295
|
+
name: session.name,
|
|
1296
|
+
...session.parentSessionId === void 0 ? {} : { parentSessionId: session.parentSessionId },
|
|
1297
|
+
...session.sessionProvenance === void 0 ? {} : { sessionProvenance: session.sessionProvenance }
|
|
1298
|
+
}, session.id, session.workspaceId);
|
|
1299
|
+
} catch (error) {
|
|
1300
|
+
if (record !== void 0) openSessions.add(record);
|
|
1301
|
+
throw error;
|
|
1302
|
+
}
|
|
1303
|
+
},
|
|
1304
|
+
resumeSession: async (session, targetSessionId) => {
|
|
1305
|
+
const workspaceId = session.workspaceId;
|
|
1306
|
+
if (!workspaceId || !hub.workspaces().some((workspace) => workspace.id === workspaceId)) throw new Error("Session workspace not found.");
|
|
1307
|
+
const target = (await savedHistory(workspaceId)).find((item) => item.summary.id === targetSessionId);
|
|
1308
|
+
if (!target) throw new Error("Saved Pi 1.0 session not found in this workspace. Earlier sessions cannot be resumed.");
|
|
1309
|
+
validateExecution(target.execution, workspaceId);
|
|
1310
|
+
const closedRecord = openSessions.list().find((entry) => entry.sessionId === session.id);
|
|
1311
|
+
await hub.closeSession(session.id);
|
|
1312
|
+
try {
|
|
1313
|
+
await openSession({
|
|
1314
|
+
cwd: target.execution.cwd,
|
|
1315
|
+
name: target.summary.name ?? "untitled",
|
|
1316
|
+
...target.execution.parentSessionId ? { parentSessionId: target.execution.parentSessionId } : {},
|
|
1317
|
+
...target.execution.sessionProvenance ? { sessionProvenance: target.execution.sessionProvenance } : {}
|
|
1318
|
+
}, target.summary.id, workspaceId);
|
|
1319
|
+
} catch (error) {
|
|
1320
|
+
if (closedRecord !== void 0) openSessions.add(closedRecord);
|
|
1321
|
+
throw error;
|
|
1322
|
+
}
|
|
1323
|
+
return target.summary.id;
|
|
1324
|
+
},
|
|
1325
|
+
dormantSessions: () => openSessions.list(),
|
|
1326
|
+
removeDormantSession: (record) => openSessions.remove(record.sessionId),
|
|
1327
|
+
reviveSession: reviveRecord,
|
|
1328
|
+
requestAsset: (request) => webCompositions?.request(request) ?? Promise.resolve(void 0),
|
|
1329
|
+
compositions: () => {
|
|
1330
|
+
const workspaces = hub.workspaces();
|
|
1331
|
+
const decision = {
|
|
1332
|
+
cwd: baseCwd,
|
|
1333
|
+
launchWorkspaceId,
|
|
1334
|
+
workspaces,
|
|
1335
|
+
homeDirectory,
|
|
1336
|
+
environment: baseEnvironment,
|
|
1337
|
+
notice
|
|
1338
|
+
};
|
|
1339
|
+
return {
|
|
1340
|
+
global: webCompositions?.get({ scope: "global" }),
|
|
1341
|
+
nativeGlobal: webCompositions?.getNative({ scope: "global" }),
|
|
1342
|
+
publicKey: webCompositions?.publicKey(),
|
|
1343
|
+
shell: webCompositions?.shellTrust(),
|
|
1344
|
+
template: require_webTemplateDecision.resolveWebTemplateDecision(decision),
|
|
1345
|
+
nativeTemplate: require_webTemplateDecision.resolveWebTemplateDecision({
|
|
1346
|
+
...decision,
|
|
1347
|
+
host: "native"
|
|
1348
|
+
}),
|
|
1349
|
+
workspaces: workspaces.map((workspace) => ({
|
|
1350
|
+
...workspace,
|
|
1351
|
+
webComposition: webCompositions?.get({
|
|
1352
|
+
scope: "workspace",
|
|
1353
|
+
workspaceId: workspace.id
|
|
1354
|
+
}),
|
|
1355
|
+
nativeComposition: webCompositions?.getNative({
|
|
1356
|
+
scope: "workspace",
|
|
1357
|
+
workspaceId: workspace.id
|
|
1358
|
+
})
|
|
1359
|
+
}))
|
|
1360
|
+
};
|
|
1361
|
+
},
|
|
1362
|
+
telemetry,
|
|
1363
|
+
onNotice: notice
|
|
1364
|
+
});
|
|
1365
|
+
notice(`protocol on ${cockpit.url}/api/ws`);
|
|
1366
|
+
let resolveShutdown;
|
|
1367
|
+
const shutdown = new Promise((resolve) => {
|
|
1368
|
+
resolveShutdown = resolve;
|
|
1369
|
+
});
|
|
1370
|
+
requestRestart = () => {
|
|
1371
|
+
const ids = openSessions.list().map((record) => record.sessionId).filter((id) => sessionManager.get(id) !== void 0);
|
|
1372
|
+
try {
|
|
1373
|
+
require_idleRestart.writeRecycleFile(serverDirectory, ids);
|
|
1374
|
+
} catch (error) {
|
|
1375
|
+
notice(`Could not write the recycle file: ${error instanceof Error ? error.message : String(error)}`);
|
|
1376
|
+
}
|
|
1377
|
+
notice(`Restarting at idle to release superseded extension versions (${String(ids.length)} sessions reopen).`);
|
|
1378
|
+
resolveShutdown(75);
|
|
1379
|
+
};
|
|
1380
|
+
await require_idleRestart.reopenRecycledSessions(serverDirectory, async (sessionId) => {
|
|
1381
|
+
const record = openSessions.list().find((entry) => entry.sessionId === sessionId);
|
|
1382
|
+
if (record === void 0) throw new Error("its record is gone.");
|
|
1383
|
+
await reviveRecord(record);
|
|
1384
|
+
}, (sessionId, error) => notice(`Session '${sessionId}' did not reopen after the restart: ${error instanceof Error ? error.message : String(error)}`));
|
|
1385
|
+
idleRestart.poke();
|
|
1386
|
+
const stop = () => resolveShutdown(0);
|
|
1387
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
1388
|
+
if (signal.aborted) stop();
|
|
1389
|
+
try {
|
|
1390
|
+
return await shutdown;
|
|
1391
|
+
} finally {
|
|
1392
|
+
signal.removeEventListener("abort", stop);
|
|
1393
|
+
}
|
|
1394
|
+
} finally {
|
|
1395
|
+
shuttingDown = true;
|
|
1396
|
+
idleRestart.dispose();
|
|
1397
|
+
stopIdleRestartPoke();
|
|
1398
|
+
stopResourceMonitor();
|
|
1399
|
+
executionBudget.close();
|
|
1400
|
+
stopPersistSessionNames();
|
|
1401
|
+
clearInterval(eventLoopMonitor);
|
|
1402
|
+
await bounded(telemetry.recordEvent("po_server.shutdown"), "shutdown telemetry", notice);
|
|
1403
|
+
await bounded(require_shutdown.withShutdownDeadline(() => cockpit?.close(), "listener shutdown"), "listener shutdown", notice);
|
|
1404
|
+
await bounded(remoteRuntime?.close() ?? Promise.resolve(), "remote control shutdown", notice);
|
|
1405
|
+
try {
|
|
1406
|
+
await sessionManager.close();
|
|
1407
|
+
} catch (error) {
|
|
1408
|
+
notice(error instanceof Error ? error.message : String(error));
|
|
1409
|
+
}
|
|
1410
|
+
await bounded(require_shutdown.withShutdownDeadline(() => hub.close(), "hub shutdown"), "hub shutdown", notice);
|
|
1411
|
+
await bounded(require_shutdown.withShutdownDeadline(() => requestReceipts.close(), "receipt shutdown"), "receipt shutdown", notice);
|
|
1412
|
+
await bounded(require_shutdown.withShutdownDeadline(() => computerUse?.close?.(), "computer use shutdown"), "computer use shutdown", notice);
|
|
1413
|
+
await bounded(require_shutdown.withShutdownDeadline(() => webCompositions?.close(), "web composition shutdown"), "web composition shutdown", notice);
|
|
1414
|
+
const pendingCleanups = [...pendingSessions.values()].map((setup) => bounded(require_shutdown.withShutdownDeadline(() => setup.cleanup(), "pending session cleanup"), "pending session cleanup", notice));
|
|
1415
|
+
pendingSessions.clear();
|
|
1416
|
+
await Promise.allSettled(pendingCleanups);
|
|
1417
|
+
await Promise.allSettled([...repositoryContexts.values()].map((context) => bounded(context.cleanup(), "repository context cleanup", notice)));
|
|
1418
|
+
repositoryContexts.clear();
|
|
1419
|
+
await bounded(harnessTelemetry.flush(), "harness telemetry flush", notice);
|
|
1420
|
+
await bounded(harnessTelemetry.shutdown(), "harness telemetry shutdown", notice);
|
|
1421
|
+
await bounded(telemetry.flush(), "server telemetry flush", notice);
|
|
1422
|
+
await bounded(telemetry.shutdown(), "server telemetry shutdown", notice);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
//#endregion
|
|
1426
|
+
exports.runServerRuntime = runServerRuntime;
|
|
1427
|
+
|
|
1428
|
+
//# sourceMappingURL=runtime.cjs.map
|