@xenosystem/agent-interface-host 0.1.3
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 +67 -0
- package/dist/acp/AcpAgentRegistryService.d.ts +77 -0
- package/dist/acp/AcpAgentRegistryService.d.ts.map +1 -0
- package/dist/acp/AcpAgentRegistryService.js +754 -0
- package/dist/acp/AcpAgentRegistryService.js.map +1 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts +56 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts.map +1 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.js +323 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.js.map +1 -0
- package/dist/acp/AcpApprovalPortAdapter.d.ts +41 -0
- package/dist/acp/AcpApprovalPortAdapter.d.ts.map +1 -0
- package/dist/acp/AcpApprovalPortAdapter.js +82 -0
- package/dist/acp/AcpApprovalPortAdapter.js.map +1 -0
- package/dist/acp/AcpCoordinationBridge.d.ts +13 -0
- package/dist/acp/AcpCoordinationBridge.d.ts.map +1 -0
- package/dist/acp/AcpCoordinationBridge.js +13 -0
- package/dist/acp/AcpCoordinationBridge.js.map +1 -0
- package/dist/acp/AcpDiagnosticsService.d.ts +61 -0
- package/dist/acp/AcpDiagnosticsService.d.ts.map +1 -0
- package/dist/acp/AcpDiagnosticsService.js +203 -0
- package/dist/acp/AcpDiagnosticsService.js.map +1 -0
- package/dist/acp/AcpExternalCertificationHarness.d.ts +47 -0
- package/dist/acp/AcpExternalCertificationHarness.d.ts.map +1 -0
- package/dist/acp/AcpExternalCertificationHarness.js +176 -0
- package/dist/acp/AcpExternalCertificationHarness.js.map +1 -0
- package/dist/acp/AcpHostBridge.d.ts +81 -0
- package/dist/acp/AcpHostBridge.d.ts.map +1 -0
- package/dist/acp/AcpHostBridge.js +101 -0
- package/dist/acp/AcpHostBridge.js.map +1 -0
- package/dist/acp/AcpInteractivePermissionBridge.d.ts +77 -0
- package/dist/acp/AcpInteractivePermissionBridge.d.ts.map +1 -0
- package/dist/acp/AcpInteractivePermissionBridge.js +127 -0
- package/dist/acp/AcpInteractivePermissionBridge.js.map +1 -0
- package/dist/acp/AcpPermissionBridge.d.ts +19 -0
- package/dist/acp/AcpPermissionBridge.d.ts.map +1 -0
- package/dist/acp/AcpPermissionBridge.js +110 -0
- package/dist/acp/AcpPermissionBridge.js.map +1 -0
- package/dist/acp/AcpPermissionPolicy.d.ts +111 -0
- package/dist/acp/AcpPermissionPolicy.d.ts.map +1 -0
- package/dist/acp/AcpPermissionPolicy.js +167 -0
- package/dist/acp/AcpPermissionPolicy.js.map +1 -0
- package/dist/acp/AcpProcessSupervisor.d.ts +134 -0
- package/dist/acp/AcpProcessSupervisor.d.ts.map +1 -0
- package/dist/acp/AcpProcessSupervisor.js +674 -0
- package/dist/acp/AcpProcessSupervisor.js.map +1 -0
- package/dist/acp/AcpProviderApprovalService.d.ts +27 -0
- package/dist/acp/AcpProviderApprovalService.d.ts.map +1 -0
- package/dist/acp/AcpProviderApprovalService.js +128 -0
- package/dist/acp/AcpProviderApprovalService.js.map +1 -0
- package/dist/acp/AcpProviderCatalogService.d.ts +69 -0
- package/dist/acp/AcpProviderCatalogService.d.ts.map +1 -0
- package/dist/acp/AcpProviderCatalogService.js +707 -0
- package/dist/acp/AcpProviderCatalogService.js.map +1 -0
- package/dist/acp/AcpProviderModelService.d.ts +6 -0
- package/dist/acp/AcpProviderModelService.d.ts.map +1 -0
- package/dist/acp/AcpProviderModelService.js +274 -0
- package/dist/acp/AcpProviderModelService.js.map +1 -0
- package/dist/acp/AcpProviderVersionReadiness.d.ts +6 -0
- package/dist/acp/AcpProviderVersionReadiness.d.ts.map +1 -0
- package/dist/acp/AcpProviderVersionReadiness.js +100 -0
- package/dist/acp/AcpProviderVersionReadiness.js.map +1 -0
- package/dist/acp/AcpRuntimeEventMapper.d.ts +16 -0
- package/dist/acp/AcpRuntimeEventMapper.d.ts.map +1 -0
- package/dist/acp/AcpRuntimeEventMapper.js +326 -0
- package/dist/acp/AcpRuntimeEventMapper.js.map +1 -0
- package/dist/acp/AcpSessionService.d.ts +65 -0
- package/dist/acp/AcpSessionService.d.ts.map +1 -0
- package/dist/acp/AcpSessionService.js +931 -0
- package/dist/acp/AcpSessionService.js.map +1 -0
- package/dist/acp/DurableAcpPermissionPolicyStore.d.ts +25 -0
- package/dist/acp/DurableAcpPermissionPolicyStore.d.ts.map +1 -0
- package/dist/acp/DurableAcpPermissionPolicyStore.js +100 -0
- package/dist/acp/DurableAcpPermissionPolicyStore.js.map +1 -0
- package/dist/acp/acpCommandSafety.d.ts +63 -0
- package/dist/acp/acpCommandSafety.d.ts.map +1 -0
- package/dist/acp/acpCommandSafety.js +90 -0
- package/dist/acp/acpCommandSafety.js.map +1 -0
- package/dist/acp/acpErrors.d.ts +47 -0
- package/dist/acp/acpErrors.d.ts.map +1 -0
- package/dist/acp/acpErrors.js +93 -0
- package/dist/acp/acpErrors.js.map +1 -0
- package/dist/acp/acpRedaction.d.ts +9 -0
- package/dist/acp/acpRedaction.d.ts.map +1 -0
- package/dist/acp/acpRedaction.js +69 -0
- package/dist/acp/acpRedaction.js.map +1 -0
- package/dist/acp/acpSessionResume.d.ts +8 -0
- package/dist/acp/acpSessionResume.d.ts.map +1 -0
- package/dist/acp/acpSessionResume.js +31 -0
- package/dist/acp/acpSessionResume.js.map +1 -0
- package/dist/acp/acpTypes.d.ts +467 -0
- package/dist/acp/acpTypes.d.ts.map +1 -0
- package/dist/acp/acpTypes.js +2 -0
- package/dist/acp/acpTypes.js.map +1 -0
- package/dist/agent/chooseDirectoryBridge.d.ts +29 -0
- package/dist/agent/chooseDirectoryBridge.d.ts.map +1 -0
- package/dist/agent/chooseDirectoryBridge.js +116 -0
- package/dist/agent/chooseDirectoryBridge.js.map +1 -0
- package/dist/agent/permissionProfiles.d.ts +29 -0
- package/dist/agent/permissionProfiles.d.ts.map +1 -0
- package/dist/agent/permissionProfiles.js +107 -0
- package/dist/agent/permissionProfiles.js.map +1 -0
- package/dist/agent/runtimeAuthorityPrompt.d.ts +13 -0
- package/dist/agent/runtimeAuthorityPrompt.d.ts.map +1 -0
- package/dist/agent/runtimeAuthorityPrompt.js +45 -0
- package/dist/agent/runtimeAuthorityPrompt.js.map +1 -0
- package/dist/agent/runtimeModeOutputGuard.d.ts +6 -0
- package/dist/agent/runtimeModeOutputGuard.d.ts.map +1 -0
- package/dist/agent/runtimeModeOutputGuard.js +40 -0
- package/dist/agent/runtimeModeOutputGuard.js.map +1 -0
- package/dist/agent/workspacePlacementBridge.d.ts +29 -0
- package/dist/agent/workspacePlacementBridge.d.ts.map +1 -0
- package/dist/agent/workspacePlacementBridge.js +143 -0
- package/dist/agent/workspacePlacementBridge.js.map +1 -0
- package/dist/agentSearch/AgentSearchService.d.ts +81 -0
- package/dist/agentSearch/AgentSearchService.d.ts.map +1 -0
- package/dist/agentSearch/AgentSearchService.js +1038 -0
- package/dist/agentSearch/AgentSearchService.js.map +1 -0
- package/dist/agentSearch/JsonInvertedIndexAdapter.d.ts +44 -0
- package/dist/agentSearch/JsonInvertedIndexAdapter.d.ts.map +1 -0
- package/dist/agentSearch/JsonInvertedIndexAdapter.js +307 -0
- package/dist/agentSearch/JsonInvertedIndexAdapter.js.map +1 -0
- package/dist/agentSearch/SearchIndexAdapter.d.ts +33 -0
- package/dist/agentSearch/SearchIndexAdapter.d.ts.map +1 -0
- package/dist/agentSearch/SearchIndexAdapter.js +2 -0
- package/dist/agentSearch/SearchIndexAdapter.js.map +1 -0
- package/dist/agentSearch/SearchSourceWatcher.d.ts +29 -0
- package/dist/agentSearch/SearchSourceWatcher.d.ts.map +1 -0
- package/dist/agentSearch/SearchSourceWatcher.js +150 -0
- package/dist/agentSearch/SearchSourceWatcher.js.map +1 -0
- package/dist/agentSearch/SqliteFtsIndexAdapter.d.ts +58 -0
- package/dist/agentSearch/SqliteFtsIndexAdapter.d.ts.map +1 -0
- package/dist/agentSearch/SqliteFtsIndexAdapter.js +420 -0
- package/dist/agentSearch/SqliteFtsIndexAdapter.js.map +1 -0
- package/dist/agentSearch/conversationIndexer.d.ts +69 -0
- package/dist/agentSearch/conversationIndexer.d.ts.map +1 -0
- package/dist/agentSearch/conversationIndexer.js +313 -0
- package/dist/agentSearch/conversationIndexer.js.map +1 -0
- package/dist/agentSearch/searchTypes.d.ts +264 -0
- package/dist/agentSearch/searchTypes.d.ts.map +1 -0
- package/dist/agentSearch/searchTypes.js +2 -0
- package/dist/agentSearch/searchTypes.js.map +1 -0
- package/dist/agentSearch/searchUtils.d.ts +12 -0
- package/dist/agentSearch/searchUtils.d.ts.map +1 -0
- package/dist/agentSearch/searchUtils.js +125 -0
- package/dist/agentSearch/searchUtils.js.map +1 -0
- package/dist/agentSearch/workspaceMetadataIndexer.d.ts +3 -0
- package/dist/agentSearch/workspaceMetadataIndexer.d.ts.map +1 -0
- package/dist/agentSearch/workspaceMetadataIndexer.js +125 -0
- package/dist/agentSearch/workspaceMetadataIndexer.js.map +1 -0
- package/dist/cli/CliControlPlaneService.d.ts +269 -0
- package/dist/cli/CliControlPlaneService.d.ts.map +1 -0
- package/dist/cli/CliControlPlaneService.js +1874 -0
- package/dist/cli/CliControlPlaneService.js.map +1 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts +91 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts.map +1 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js +379 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js.map +1 -0
- package/dist/codebase/CodebaseIntelligenceService.d.ts +68 -0
- package/dist/codebase/CodebaseIntelligenceService.d.ts.map +1 -0
- package/dist/codebase/CodebaseIntelligenceService.js +1717 -0
- package/dist/codebase/CodebaseIntelligenceService.js.map +1 -0
- package/dist/codebase/LanguageServerProcessManager.d.ts +85 -0
- package/dist/codebase/LanguageServerProcessManager.d.ts.map +1 -0
- package/dist/codebase/LanguageServerProcessManager.js +607 -0
- package/dist/codebase/LanguageServerProcessManager.js.map +1 -0
- package/dist/codebase/codeTypes.d.ts +485 -0
- package/dist/codebase/codeTypes.d.ts.map +1 -0
- package/dist/codebase/codeTypes.js +2 -0
- package/dist/codebase/codeTypes.js.map +1 -0
- package/dist/codebase/codeUtils.d.ts +24 -0
- package/dist/codebase/codeUtils.d.ts.map +1 -0
- package/dist/codebase/codeUtils.js +177 -0
- package/dist/codebase/codeUtils.js.map +1 -0
- package/dist/codebase/contextPacks.d.ts +18 -0
- package/dist/codebase/contextPacks.d.ts.map +1 -0
- package/dist/codebase/contextPacks.js +180 -0
- package/dist/codebase/contextPacks.js.map +1 -0
- package/dist/codebase/dependencyGraph.d.ts +3 -0
- package/dist/codebase/dependencyGraph.d.ts.map +1 -0
- package/dist/codebase/dependencyGraph.js +209 -0
- package/dist/codebase/dependencyGraph.js.map +1 -0
- package/dist/codebase/fileIndexer.d.ts +27 -0
- package/dist/codebase/fileIndexer.d.ts.map +1 -0
- package/dist/codebase/fileIndexer.js +167 -0
- package/dist/codebase/fileIndexer.js.map +1 -0
- package/dist/codebase/symbolIndexer.d.ts +3 -0
- package/dist/codebase/symbolIndexer.d.ts.map +1 -0
- package/dist/codebase/symbolIndexer.js +184 -0
- package/dist/codebase/symbolIndexer.js.map +1 -0
- package/dist/codebase/whatChanged.d.ts +4 -0
- package/dist/codebase/whatChanged.d.ts.map +1 -0
- package/dist/codebase/whatChanged.js +138 -0
- package/dist/codebase/whatChanged.js.map +1 -0
- package/dist/coordination/CoordinationService.d.ts +166 -0
- package/dist/coordination/CoordinationService.d.ts.map +1 -0
- package/dist/coordination/CoordinationService.js +247 -0
- package/dist/coordination/CoordinationService.js.map +1 -0
- package/dist/coordination/claims.d.ts +122 -0
- package/dist/coordination/claims.d.ts.map +1 -0
- package/dist/coordination/claims.js +196 -0
- package/dist/coordination/claims.js.map +1 -0
- package/dist/coordination/coordinationTools.d.ts +40 -0
- package/dist/coordination/coordinationTools.d.ts.map +1 -0
- package/dist/coordination/coordinationTools.js +92 -0
- package/dist/coordination/coordinationTools.js.map +1 -0
- package/dist/coordination/laneBridge.d.ts +84 -0
- package/dist/coordination/laneBridge.d.ts.map +1 -0
- package/dist/coordination/laneBridge.js +86 -0
- package/dist/coordination/laneBridge.js.map +1 -0
- package/dist/coordination/messages.d.ts +225 -0
- package/dist/coordination/messages.d.ts.map +1 -0
- package/dist/coordination/messages.js +335 -0
- package/dist/coordination/messages.js.map +1 -0
- package/dist/coordination/permissionWaitRegistry.d.ts +32 -0
- package/dist/coordination/permissionWaitRegistry.d.ts.map +1 -0
- package/dist/coordination/permissionWaitRegistry.js +59 -0
- package/dist/coordination/permissionWaitRegistry.js.map +1 -0
- package/dist/coordination/query.d.ts +187 -0
- package/dist/coordination/query.d.ts.map +1 -0
- package/dist/coordination/query.js +138 -0
- package/dist/coordination/query.js.map +1 -0
- package/dist/coordination/renderInbox.d.ts +15 -0
- package/dist/coordination/renderInbox.d.ts.map +1 -0
- package/dist/coordination/renderInbox.js +19 -0
- package/dist/coordination/renderInbox.js.map +1 -0
- package/dist/coordination/runtimeEvents.d.ts +53 -0
- package/dist/coordination/runtimeEvents.d.ts.map +1 -0
- package/dist/coordination/runtimeEvents.js +112 -0
- package/dist/coordination/runtimeEvents.js.map +1 -0
- package/dist/detachedHostService.d.ts +77 -0
- package/dist/detachedHostService.d.ts.map +1 -0
- package/dist/detachedHostService.js +66 -0
- package/dist/detachedHostService.js.map +1 -0
- package/dist/detachedHostSupervisor.d.ts +102 -0
- package/dist/detachedHostSupervisor.d.ts.map +1 -0
- package/dist/detachedHostSupervisor.js +168 -0
- package/dist/detachedHostSupervisor.js.map +1 -0
- package/dist/durableRuntimeEventStore.d.ts +49 -0
- package/dist/durableRuntimeEventStore.d.ts.map +1 -0
- package/dist/durableRuntimeEventStore.js +364 -0
- package/dist/durableRuntimeEventStore.js.map +1 -0
- package/dist/engineering/EngineeringWorkbenchService.d.ts +142 -0
- package/dist/engineering/EngineeringWorkbenchService.d.ts.map +1 -0
- package/dist/engineering/EngineeringWorkbenchService.js +2301 -0
- package/dist/engineering/EngineeringWorkbenchService.js.map +1 -0
- package/dist/engineering/LandingService.d.ts +112 -0
- package/dist/engineering/LandingService.d.ts.map +1 -0
- package/dist/engineering/LandingService.js +239 -0
- package/dist/engineering/LandingService.js.map +1 -0
- package/dist/engineering/engineeringTypes.d.ts +2 -0
- package/dist/engineering/engineeringTypes.d.ts.map +1 -0
- package/dist/engineering/engineeringTypes.js +2 -0
- package/dist/engineering/engineeringTypes.js.map +1 -0
- package/dist/engineering/patchReview.d.ts +11 -0
- package/dist/engineering/patchReview.d.ts.map +1 -0
- package/dist/engineering/patchReview.js +174 -0
- package/dist/engineering/patchReview.js.map +1 -0
- package/dist/index.d.ts +834 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3242 -0
- package/dist/index.js.map +1 -0
- package/dist/intake/IntakeService.d.ts +84 -0
- package/dist/intake/IntakeService.d.ts.map +1 -0
- package/dist/intake/IntakeService.js +117 -0
- package/dist/intake/IntakeService.js.map +1 -0
- package/dist/intake/RepositoryTodoIntakeSource.d.ts +72 -0
- package/dist/intake/RepositoryTodoIntakeSource.d.ts.map +1 -0
- package/dist/intake/RepositoryTodoIntakeSource.js +168 -0
- package/dist/intake/RepositoryTodoIntakeSource.js.map +1 -0
- package/dist/intake/WorkspaceTodoIntakeSource.d.ts +53 -0
- package/dist/intake/WorkspaceTodoIntakeSource.d.ts.map +1 -0
- package/dist/intake/WorkspaceTodoIntakeSource.js +81 -0
- package/dist/intake/WorkspaceTodoIntakeSource.js.map +1 -0
- package/dist/isolation/CommandExecution.d.ts +132 -0
- package/dist/isolation/CommandExecution.d.ts.map +1 -0
- package/dist/isolation/CommandExecution.js +48 -0
- package/dist/isolation/CommandExecution.js.map +1 -0
- package/dist/isolation/LocalCommandExecutor.d.ts +27 -0
- package/dist/isolation/LocalCommandExecutor.d.ts.map +1 -0
- package/dist/isolation/LocalCommandExecutor.js +97 -0
- package/dist/isolation/LocalCommandExecutor.js.map +1 -0
- package/dist/isolation/RunExecutionEnvironment.d.ts +135 -0
- package/dist/isolation/RunExecutionEnvironment.d.ts.map +1 -0
- package/dist/isolation/RunExecutionEnvironment.js +206 -0
- package/dist/isolation/RunExecutionEnvironment.js.map +1 -0
- package/dist/isolation/RunIsolationService.d.ts +90 -0
- package/dist/isolation/RunIsolationService.d.ts.map +1 -0
- package/dist/isolation/RunIsolationService.js +86 -0
- package/dist/isolation/RunIsolationService.js.map +1 -0
- package/dist/isolation/SandboxCommandExecutor.d.ts +93 -0
- package/dist/isolation/SandboxCommandExecutor.d.ts.map +1 -0
- package/dist/isolation/SandboxCommandExecutor.js +189 -0
- package/dist/isolation/SandboxCommandExecutor.js.map +1 -0
- package/dist/knowledge/WorkspaceKnowledgeService.d.ts +71 -0
- package/dist/knowledge/WorkspaceKnowledgeService.d.ts.map +1 -0
- package/dist/knowledge/WorkspaceKnowledgeService.js +103 -0
- package/dist/knowledge/WorkspaceKnowledgeService.js.map +1 -0
- package/dist/localHostAuthority.d.ts +24 -0
- package/dist/localHostAuthority.d.ts.map +1 -0
- package/dist/localHostAuthority.js +87 -0
- package/dist/localHostAuthority.js.map +1 -0
- package/dist/localHostLease.d.ts +51 -0
- package/dist/localHostLease.d.ts.map +1 -0
- package/dist/localHostLease.js +167 -0
- package/dist/localHostLease.js.map +1 -0
- package/dist/localHostPaths.d.ts +30 -0
- package/dist/localHostPaths.d.ts.map +1 -0
- package/dist/localHostPaths.js +60 -0
- package/dist/localHostPaths.js.map +1 -0
- package/dist/localRpcTransport.d.ts +21 -0
- package/dist/localRpcTransport.d.ts.map +1 -0
- package/dist/localRpcTransport.js +423 -0
- package/dist/localRpcTransport.js.map +1 -0
- package/dist/node.d.ts +104 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +103 -0
- package/dist/node.js.map +1 -0
- package/dist/observation/DirectoryBaselineScanner.d.ts +44 -0
- package/dist/observation/DirectoryBaselineScanner.d.ts.map +1 -0
- package/dist/observation/DirectoryBaselineScanner.js +112 -0
- package/dist/observation/DirectoryBaselineScanner.js.map +1 -0
- package/dist/observation/MountContentReader.d.ts +63 -0
- package/dist/observation/MountContentReader.d.ts.map +1 -0
- package/dist/observation/MountContentReader.js +158 -0
- package/dist/observation/MountContentReader.js.map +1 -0
- package/dist/observation/RunObservationService.d.ts +229 -0
- package/dist/observation/RunObservationService.d.ts.map +1 -0
- package/dist/observation/RunObservationService.js +248 -0
- package/dist/observation/RunObservationService.js.map +1 -0
- package/dist/observation/XenoUseObservationSource.d.ts +42 -0
- package/dist/observation/XenoUseObservationSource.d.ts.map +1 -0
- package/dist/observation/XenoUseObservationSource.js +104 -0
- package/dist/observation/XenoUseObservationSource.js.map +1 -0
- package/dist/observation/XenoUseRunObserver.d.ts +140 -0
- package/dist/observation/XenoUseRunObserver.d.ts.map +1 -0
- package/dist/observation/XenoUseRunObserver.js +256 -0
- package/dist/observation/XenoUseRunObserver.js.map +1 -0
- package/dist/pluginMcp/PluginMcpManagerService.d.ts +141 -0
- package/dist/pluginMcp/PluginMcpManagerService.d.ts.map +1 -0
- package/dist/pluginMcp/PluginMcpManagerService.js +1821 -0
- package/dist/pluginMcp/PluginMcpManagerService.js.map +1 -0
- package/dist/pluginMcp/pluginMcpTypes.d.ts +349 -0
- package/dist/pluginMcp/pluginMcpTypes.d.ts.map +1 -0
- package/dist/pluginMcp/pluginMcpTypes.js +2 -0
- package/dist/pluginMcp/pluginMcpTypes.js.map +1 -0
- package/dist/policy/WorkspacePolicyService.d.ts +83 -0
- package/dist/policy/WorkspacePolicyService.d.ts.map +1 -0
- package/dist/policy/WorkspacePolicyService.js +809 -0
- package/dist/policy/WorkspacePolicyService.js.map +1 -0
- package/dist/policy/policyGuard.d.ts +27 -0
- package/dist/policy/policyGuard.d.ts.map +1 -0
- package/dist/policy/policyGuard.js +143 -0
- package/dist/policy/policyGuard.js.map +1 -0
- package/dist/policy/policyTypes.d.ts +190 -0
- package/dist/policy/policyTypes.d.ts.map +1 -0
- package/dist/policy/policyTypes.js +2 -0
- package/dist/policy/policyTypes.js.map +1 -0
- package/dist/runtime/RuntimeEventStore.d.ts +42 -0
- package/dist/runtime/RuntimeEventStore.d.ts.map +1 -0
- package/dist/runtime/RuntimeEventStore.js +412 -0
- package/dist/runtime/RuntimeEventStore.js.map +1 -0
- package/dist/runtime/RuntimeEventStoreRepositoryAdapter.d.ts +21 -0
- package/dist/runtime/RuntimeEventStoreRepositoryAdapter.d.ts.map +1 -0
- package/dist/runtime/RuntimeEventStoreRepositoryAdapter.js +41 -0
- package/dist/runtime/RuntimeEventStoreRepositoryAdapter.js.map +1 -0
- package/dist/runtime/RuntimeTimelineProjection.d.ts +5 -0
- package/dist/runtime/RuntimeTimelineProjection.d.ts.map +1 -0
- package/dist/runtime/RuntimeTimelineProjection.js +705 -0
- package/dist/runtime/RuntimeTimelineProjection.js.map +1 -0
- package/dist/runtime/runtimeEventTypes.d.ts +73 -0
- package/dist/runtime/runtimeEventTypes.d.ts.map +1 -0
- package/dist/runtime/runtimeEventTypes.js +2 -0
- package/dist/runtime/runtimeEventTypes.js.map +1 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts +117 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts.map +1 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js +214 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js.map +1 -0
- package/dist/session/AgentSessionService.d.ts +285 -0
- package/dist/session/AgentSessionService.d.ts.map +1 -0
- package/dist/session/AgentSessionService.js +444 -0
- package/dist/session/AgentSessionService.js.map +1 -0
- package/dist/session/bufferedSessionPty.d.ts +27 -0
- package/dist/session/bufferedSessionPty.d.ts.map +1 -0
- package/dist/session/bufferedSessionPty.js +49 -0
- package/dist/session/bufferedSessionPty.js.map +1 -0
- package/dist/session/renderSupport.d.ts +53 -0
- package/dist/session/renderSupport.d.ts.map +1 -0
- package/dist/session/renderSupport.js +41 -0
- package/dist/session/renderSupport.js.map +1 -0
- package/dist/session/runtimeEventChannel.d.ts +56 -0
- package/dist/session/runtimeEventChannel.d.ts.map +1 -0
- package/dist/session/runtimeEventChannel.js +53 -0
- package/dist/session/runtimeEventChannel.js.map +1 -0
- package/dist/state/JsonAgentStateRepository.d.ts +29 -0
- package/dist/state/JsonAgentStateRepository.d.ts.map +1 -0
- package/dist/state/JsonAgentStateRepository.js +165 -0
- package/dist/state/JsonAgentStateRepository.js.map +1 -0
- package/dist/state/SqliteAgentStateRepository.d.ts +58 -0
- package/dist/state/SqliteAgentStateRepository.d.ts.map +1 -0
- package/dist/state/SqliteAgentStateRepository.js +777 -0
- package/dist/state/SqliteAgentStateRepository.js.map +1 -0
- package/dist/state/createAgentStateRepository.d.ts +4 -0
- package/dist/state/createAgentStateRepository.d.ts.map +1 -0
- package/dist/state/createAgentStateRepository.js +12 -0
- package/dist/state/createAgentStateRepository.js.map +1 -0
- package/dist/state/stateSanitizers.d.ts +7 -0
- package/dist/state/stateSanitizers.d.ts.map +1 -0
- package/dist/state/stateSanitizers.js +87 -0
- package/dist/state/stateSanitizers.js.map +1 -0
- package/dist/subagents/AcpSubagentExecutionAdapter.d.ts +12 -0
- package/dist/subagents/AcpSubagentExecutionAdapter.d.ts.map +1 -0
- package/dist/subagents/AcpSubagentExecutionAdapter.js +119 -0
- package/dist/subagents/AcpSubagentExecutionAdapter.js.map +1 -0
- package/dist/subagents/CliSubagentExecutionAdapter.d.ts +13 -0
- package/dist/subagents/CliSubagentExecutionAdapter.d.ts.map +1 -0
- package/dist/subagents/CliSubagentExecutionAdapter.js +217 -0
- package/dist/subagents/CliSubagentExecutionAdapter.js.map +1 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts +78 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts.map +1 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.js +160 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.js.map +1 -0
- package/dist/subagents/SubagentRunService.d.ts +103 -0
- package/dist/subagents/SubagentRunService.d.ts.map +1 -0
- package/dist/subagents/SubagentRunService.js +1183 -0
- package/dist/subagents/SubagentRunService.js.map +1 -0
- package/dist/subagents/SubagentScheduler.d.ts +167 -0
- package/dist/subagents/SubagentScheduler.d.ts.map +1 -0
- package/dist/subagents/SubagentScheduler.js +530 -0
- package/dist/subagents/SubagentScheduler.js.map +1 -0
- package/dist/subagents/TeamAgentRouter.d.ts +104 -0
- package/dist/subagents/TeamAgentRouter.d.ts.map +1 -0
- package/dist/subagents/TeamAgentRouter.js +435 -0
- package/dist/subagents/TeamAgentRouter.js.map +1 -0
- package/dist/subagents/capabilityMatcher.d.ts +3 -0
- package/dist/subagents/capabilityMatcher.d.ts.map +1 -0
- package/dist/subagents/capabilityMatcher.js +127 -0
- package/dist/subagents/capabilityMatcher.js.map +1 -0
- package/dist/subagents/subagentRunPort.d.ts +43 -0
- package/dist/subagents/subagentRunPort.d.ts.map +1 -0
- package/dist/subagents/subagentRunPort.js +24 -0
- package/dist/subagents/subagentRunPort.js.map +1 -0
- package/dist/subagents/subagentTypes.d.ts +330 -0
- package/dist/subagents/subagentTypes.d.ts.map +1 -0
- package/dist/subagents/subagentTypes.js +2 -0
- package/dist/subagents/subagentTypes.js.map +1 -0
- package/dist/subagents/subagentWorkspaceAuthority.d.ts +29 -0
- package/dist/subagents/subagentWorkspaceAuthority.d.ts.map +1 -0
- package/dist/subagents/subagentWorkspaceAuthority.js +173 -0
- package/dist/subagents/subagentWorkspaceAuthority.js.map +1 -0
- package/dist/support/SupportDiagnosticsService.d.ts +87 -0
- package/dist/support/SupportDiagnosticsService.d.ts.map +1 -0
- package/dist/support/SupportDiagnosticsService.js +1199 -0
- package/dist/support/SupportDiagnosticsService.js.map +1 -0
- package/dist/turns/DurableInterruptedTurnStore.d.ts +14 -0
- package/dist/turns/DurableInterruptedTurnStore.d.ts.map +1 -0
- package/dist/turns/DurableInterruptedTurnStore.js +63 -0
- package/dist/turns/DurableInterruptedTurnStore.js.map +1 -0
- package/dist/turns/interruptedTurns.d.ts +50 -0
- package/dist/turns/interruptedTurns.d.ts.map +1 -0
- package/dist/turns/interruptedTurns.js +54 -0
- package/dist/turns/interruptedTurns.js.map +1 -0
- package/dist/turns/turnAdmission.d.ts +113 -0
- package/dist/turns/turnAdmission.d.ts.map +1 -0
- package/dist/turns/turnAdmission.js +136 -0
- package/dist/turns/turnAdmission.js.map +1 -0
- package/dist/workspace/WorkspaceHostService.d.ts +126 -0
- package/dist/workspace/WorkspaceHostService.d.ts.map +1 -0
- package/dist/workspace/WorkspaceHostService.js +841 -0
- package/dist/workspace/WorkspaceHostService.js.map +1 -0
- package/dist/workspace/WorkspaceShellService.d.ts +71 -0
- package/dist/workspace/WorkspaceShellService.d.ts.map +1 -0
- package/dist/workspace/WorkspaceShellService.js +273 -0
- package/dist/workspace/WorkspaceShellService.js.map +1 -0
- package/dist/workspace/fileAssociations.d.ts +12 -0
- package/dist/workspace/fileAssociations.d.ts.map +1 -0
- package/dist/workspace/fileAssociations.js +202 -0
- package/dist/workspace/fileAssociations.js.map +1 -0
- package/dist/workspace/scrollbackBuffer.d.ts +48 -0
- package/dist/workspace/scrollbackBuffer.d.ts.map +1 -0
- package/dist/workspace/scrollbackBuffer.js +94 -0
- package/dist/workspace/scrollbackBuffer.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,931 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'crypto';
|
|
2
|
+
import { mkdirSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { RuntimeEventStore } from '../runtime/RuntimeEventStore.js';
|
|
5
|
+
import { defaultRunIdOf } from '@xenosystem/agent-interface-contract';
|
|
6
|
+
import { HostCoordinationLaneBridge } from '../coordination/laneBridge.js';
|
|
7
|
+
import { AcpProcessSupervisor, XENO_ACP_CONTEXT_META_KEY } from './AcpProcessSupervisor.js';
|
|
8
|
+
import { FailClosedAcpPermissionBridge } from './AcpPermissionBridge.js';
|
|
9
|
+
import { FailClosedAcpHostBridge, } from './AcpHostBridge.js';
|
|
10
|
+
import { acpErrorCode, acpSafeErrorMessage } from './acpErrors.js';
|
|
11
|
+
import { redactAcpText } from './acpRedaction.js';
|
|
12
|
+
import { XENO_ACP_SESSION_RESUME_META_KEY } from './acpSessionResume.js';
|
|
13
|
+
import { mapAcpAgentExitedToRuntimeEvent, mapAcpAgentFailedToRuntimeEvent, mapAcpAgentReadyToRuntimeEvent, mapAcpAgentStartedToRuntimeEvent, mapAcpAgentStderrToRuntimeEvent, mapAcpChooseDirectoryResultToRuntimeEvent, mapAcpChooseWorkspacePlacementResultToRuntimeEvent, mapAcpPermissionDecidedToRuntimeEvent, mapAcpPermissionRequestedToRuntimeEvent, mapAcpPromptResultToRuntimeEvent, mapAcpSessionFailedToRuntimeEvent, mapAcpSessionStartedToRuntimeEvent, mapAcpSessionUpdateToRuntimeEvent, } from './AcpRuntimeEventMapper.js';
|
|
14
|
+
/**
|
|
15
|
+
* How long a cancelled prompt waits for its transport to finish dying before concluding it did
|
|
16
|
+
* not die.
|
|
17
|
+
*
|
|
18
|
+
* Generous enough that a process which exits on cancel — the normal case, and the one the
|
|
19
|
+
* lifecycle event exists to report — is reliably observed. Short enough to be invisible on a path
|
|
20
|
+
* a human just triggered, and it is only ever paid when the agent survives the cancel, since the
|
|
21
|
+
* wait returns the moment the exit lands.
|
|
22
|
+
*/
|
|
23
|
+
const CANCELLED_TRANSPORT_SETTLE_MS = 500;
|
|
24
|
+
export class AcpSessionService {
|
|
25
|
+
rootDir;
|
|
26
|
+
runtimeStore;
|
|
27
|
+
onRuntimeEvent;
|
|
28
|
+
permissionBridge;
|
|
29
|
+
hostBridge;
|
|
30
|
+
coordinationPort;
|
|
31
|
+
onRunActivity;
|
|
32
|
+
requestTimeoutMs;
|
|
33
|
+
conversationSessions = new Map();
|
|
34
|
+
conversationPromptTails = new Map();
|
|
35
|
+
constructor(options = {}) {
|
|
36
|
+
this.rootDir = options.rootDir;
|
|
37
|
+
this.runtimeStore = options.runtimeStore || new RuntimeEventStore(options.rootDir ? join(options.rootDir, 'runtime-events') : undefined);
|
|
38
|
+
this.onRuntimeEvent = options.onRuntimeEvent;
|
|
39
|
+
this.permissionBridge = options.permissionBridge || new FailClosedAcpPermissionBridge();
|
|
40
|
+
this.hostBridge = options.hostBridge || new FailClosedAcpHostBridge();
|
|
41
|
+
this.coordinationPort = options.coordinationPort;
|
|
42
|
+
this.onRunActivity = options.onRunActivity;
|
|
43
|
+
this.requestTimeoutMs = options.requestTimeoutMs || 30_000;
|
|
44
|
+
}
|
|
45
|
+
async runPrompt(request) {
|
|
46
|
+
const [result] = await this.runPromptBatch({
|
|
47
|
+
config: request.config,
|
|
48
|
+
prompts: [{
|
|
49
|
+
conversationId: request.conversationId,
|
|
50
|
+
requestId: request.requestId,
|
|
51
|
+
subagentRunId: request.subagentRunId,
|
|
52
|
+
prompt: request.prompt,
|
|
53
|
+
history: request.history,
|
|
54
|
+
systemPrompt: request.systemPrompt,
|
|
55
|
+
cwd: request.cwd,
|
|
56
|
+
additionalDirectories: request.additionalDirectories,
|
|
57
|
+
execution: request.execution,
|
|
58
|
+
providerModel: request.providerModel,
|
|
59
|
+
resumeSessionId: request.resumeSessionId,
|
|
60
|
+
resumeState: request.resumeState,
|
|
61
|
+
resumeAgentConfigId: request.resumeAgentConfigId,
|
|
62
|
+
resumeAgentConfigFingerprint: request.resumeAgentConfigFingerprint,
|
|
63
|
+
resumeWorkspaceFingerprint: request.resumeWorkspaceFingerprint,
|
|
64
|
+
timeoutMs: request.timeoutMs,
|
|
65
|
+
cancelAfterMs: request.cancelAfterMs,
|
|
66
|
+
abortSignal: request.abortSignal,
|
|
67
|
+
}],
|
|
68
|
+
});
|
|
69
|
+
if (!result)
|
|
70
|
+
throw new Error('ACP prompt batch returned no result for its requested prompt.');
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
async runConversationPrompt(request) {
|
|
74
|
+
const key = `${request.config.id}:${request.conversationId}`;
|
|
75
|
+
const previous = this.conversationPromptTails.get(key) || Promise.resolve();
|
|
76
|
+
let releaseCurrent;
|
|
77
|
+
const current = new Promise((resolve) => {
|
|
78
|
+
releaseCurrent = resolve;
|
|
79
|
+
});
|
|
80
|
+
const tail = previous.catch(() => undefined).then(() => current);
|
|
81
|
+
this.conversationPromptTails.set(key, tail);
|
|
82
|
+
await previous.catch(() => undefined);
|
|
83
|
+
try {
|
|
84
|
+
return await this.runConversationPromptExclusive(request, key);
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
releaseCurrent();
|
|
88
|
+
if (this.conversationPromptTails.get(key) === tail) {
|
|
89
|
+
this.conversationPromptTails.delete(key);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async runConversationPromptExclusive(request, key) {
|
|
94
|
+
if (!request.config.enabled) {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
status: 'failed',
|
|
98
|
+
conversationId: request.conversationId,
|
|
99
|
+
requestId: request.requestId,
|
|
100
|
+
acpProcessId: `acp-process-${Date.now()}-${randomUUID().slice(0, 8)}`,
|
|
101
|
+
acpAgentConfigId: request.config.id,
|
|
102
|
+
eventCount: 0,
|
|
103
|
+
error: 'ACP agent config must be enabled before launch.',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const cwd = this.resolveConversationCwd(request);
|
|
107
|
+
const additionalDirectories = request.additionalDirectories || [];
|
|
108
|
+
const workspaceKey = this.workspaceKeyFor(cwd, additionalDirectories, request.execution);
|
|
109
|
+
const workspaceFingerprint = this.workspaceFingerprintFor(workspaceKey);
|
|
110
|
+
const configFingerprint = this.agentConfigFingerprintFor(request.config);
|
|
111
|
+
let replayHistoryOnFreshSession = false;
|
|
112
|
+
let active = this.conversationSessions.get(key);
|
|
113
|
+
if (active && (active.supervisor.getStatus() !== 'ready' || active.workspaceKey !== workspaceKey)) {
|
|
114
|
+
await this.closeConversationSession(active).catch(() => undefined);
|
|
115
|
+
active = undefined;
|
|
116
|
+
}
|
|
117
|
+
if (!active) {
|
|
118
|
+
const acpProcessId = `acp-process-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
119
|
+
const recorder = new RuntimeRecordingAcpPermissionBridge(this.permissionBridge, (mapping, context) => {
|
|
120
|
+
this.appendRuntimeEvent(context, mapping);
|
|
121
|
+
}, this.onRunActivity);
|
|
122
|
+
const hostRecorder = new RuntimeRecordingAcpHostBridge(this.hostBridge, (mapping, context) => {
|
|
123
|
+
this.appendRuntimeEvent(context, mapping);
|
|
124
|
+
});
|
|
125
|
+
const supervisor = new AcpProcessSupervisor(request.config, {
|
|
126
|
+
permissionBridge: recorder,
|
|
127
|
+
hostBridge: hostRecorder,
|
|
128
|
+
/**
|
|
129
|
+
* \u{1F534} The caller's run id is bound HERE, from the host's own request —
|
|
130
|
+
* never read from a parameter the agent supplies. An agent that could
|
|
131
|
+
* name its own `fromRunId` could message as another run, read a peer's
|
|
132
|
+
* summary through someone else's visibility, and claim a file in a
|
|
133
|
+
* third run's name. Coordination is host-mediated exactly so a
|
|
134
|
+
* participant cannot assert who it is.
|
|
135
|
+
*
|
|
136
|
+
* `defaultRunIdOf` rather than `conversationId`, because a subagent run
|
|
137
|
+
* is its own run and coordinates under its own identity.
|
|
138
|
+
*/
|
|
139
|
+
...(this.coordinationPort
|
|
140
|
+
? {
|
|
141
|
+
coordinationBridge: new HostCoordinationLaneBridge({
|
|
142
|
+
callerRunId: defaultRunIdOf({
|
|
143
|
+
conversationId: request.conversationId,
|
|
144
|
+
...(request.subagentRunId === undefined ? {} : { subagentRunId: request.subagentRunId }),
|
|
145
|
+
}),
|
|
146
|
+
port: this.coordinationPort,
|
|
147
|
+
}),
|
|
148
|
+
}
|
|
149
|
+
: {}),
|
|
150
|
+
requestTimeoutMs: this.requestTimeoutMs,
|
|
151
|
+
});
|
|
152
|
+
const context = {
|
|
153
|
+
conversationId: request.conversationId,
|
|
154
|
+
requestId: request.requestId,
|
|
155
|
+
subagentRunId: request.subagentRunId,
|
|
156
|
+
acpProcessId,
|
|
157
|
+
acpAgentConfigId: request.config.id,
|
|
158
|
+
providerKind: 'acp-provider',
|
|
159
|
+
providerId: request.config.id,
|
|
160
|
+
providerModel: request.providerModel,
|
|
161
|
+
schemaVersion: 1,
|
|
162
|
+
redactionState: 'redacted',
|
|
163
|
+
};
|
|
164
|
+
this.appendRuntimeEvent(context, mapAcpAgentStartedToRuntimeEvent(context, supervisor.diagnostics()));
|
|
165
|
+
try {
|
|
166
|
+
await supervisor.initialize();
|
|
167
|
+
this.appendRuntimeEvent(context, mapAcpAgentReadyToRuntimeEvent(context, supervisor.diagnostics()));
|
|
168
|
+
let session;
|
|
169
|
+
let resumeSkipReason;
|
|
170
|
+
if (request.resumeSessionId) {
|
|
171
|
+
if (request.resumeAgentConfigId !== request.config.id) {
|
|
172
|
+
resumeSkipReason = 'provider_mismatch';
|
|
173
|
+
}
|
|
174
|
+
else if (!request.resumeAgentConfigFingerprint
|
|
175
|
+
|| request.resumeAgentConfigFingerprint !== configFingerprint) {
|
|
176
|
+
resumeSkipReason = 'provider_config_changed';
|
|
177
|
+
}
|
|
178
|
+
else if (!request.resumeWorkspaceFingerprint
|
|
179
|
+
|| request.resumeWorkspaceFingerprint !== workspaceFingerprint) {
|
|
180
|
+
resumeSkipReason = 'workspace_mismatch';
|
|
181
|
+
}
|
|
182
|
+
else if (!request.resumeState) {
|
|
183
|
+
resumeSkipReason = 'missing_resume_state';
|
|
184
|
+
}
|
|
185
|
+
else if (!supervisor.supportsResumeSession()
|
|
186
|
+
&& !supervisor.supportsSessionNewResumeState()) {
|
|
187
|
+
resumeSkipReason = 'unsupported';
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
try {
|
|
191
|
+
const transport = supervisor.supportsResumeSession()
|
|
192
|
+
? 'session_resume'
|
|
193
|
+
: 'session_new_meta';
|
|
194
|
+
session = transport === 'session_resume'
|
|
195
|
+
? await supervisor.resumeSession(request.resumeSessionId, {
|
|
196
|
+
cwd,
|
|
197
|
+
additionalDirectories,
|
|
198
|
+
mcpServers: [],
|
|
199
|
+
...this.sessionExecutionMeta(request, true),
|
|
200
|
+
})
|
|
201
|
+
: await supervisor.createSession({
|
|
202
|
+
cwd,
|
|
203
|
+
additionalDirectories,
|
|
204
|
+
mcpServers: [],
|
|
205
|
+
...this.sessionExecutionMeta(request, true),
|
|
206
|
+
});
|
|
207
|
+
context.acpSessionId = session.sessionId;
|
|
208
|
+
this.appendLifecycleEvent(context, 'acp.session.resumed', {
|
|
209
|
+
status: 'ready',
|
|
210
|
+
transport,
|
|
211
|
+
configFingerprint,
|
|
212
|
+
workspaceFingerprint,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
resumeSkipReason = 'resume_failed';
|
|
217
|
+
this.appendLifecycleEvent(context, 'acp.session.resume_failed', {
|
|
218
|
+
status: 'failed',
|
|
219
|
+
configFingerprint,
|
|
220
|
+
workspaceFingerprint,
|
|
221
|
+
error: redactAcpText(acpSafeErrorMessage(error)),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (resumeSkipReason && resumeSkipReason !== 'resume_failed') {
|
|
226
|
+
this.appendLifecycleEvent(context, 'acp.session.resume_skipped', {
|
|
227
|
+
status: 'skipped',
|
|
228
|
+
reason: resumeSkipReason,
|
|
229
|
+
configFingerprint,
|
|
230
|
+
workspaceFingerprint,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!session) {
|
|
235
|
+
session = await supervisor.createSession({
|
|
236
|
+
cwd,
|
|
237
|
+
additionalDirectories,
|
|
238
|
+
mcpServers: [],
|
|
239
|
+
...this.sessionExecutionMeta(request),
|
|
240
|
+
});
|
|
241
|
+
replayHistoryOnFreshSession = (request.history?.length || 0) > 0;
|
|
242
|
+
}
|
|
243
|
+
context.acpSessionId = session.sessionId;
|
|
244
|
+
const started = mapAcpSessionStartedToRuntimeEvent(context, session.sessionId);
|
|
245
|
+
started.event.configFingerprint = configFingerprint;
|
|
246
|
+
started.event.workspaceFingerprint = workspaceFingerprint;
|
|
247
|
+
this.appendRuntimeEvent(context, started);
|
|
248
|
+
active = {
|
|
249
|
+
key,
|
|
250
|
+
conversationId: request.conversationId,
|
|
251
|
+
configId: request.config.id,
|
|
252
|
+
configFingerprint,
|
|
253
|
+
workspaceKey,
|
|
254
|
+
workspaceFingerprint,
|
|
255
|
+
acpProcessId,
|
|
256
|
+
acpSessionId: session.sessionId,
|
|
257
|
+
supervisor,
|
|
258
|
+
recorder,
|
|
259
|
+
hostRecorder,
|
|
260
|
+
};
|
|
261
|
+
this.conversationSessions.set(key, active);
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
const diagnostics = supervisor.diagnostics();
|
|
265
|
+
this.appendRuntimeEvent(context, mapAcpAgentFailedToRuntimeEvent(context, redactAcpText(acpSafeErrorMessage(error)), diagnostics));
|
|
266
|
+
this.emitStderrIfPresent(context, diagnostics);
|
|
267
|
+
this.appendRuntimeEvent(context, mapAcpAgentExitedToRuntimeEvent(context, diagnostics));
|
|
268
|
+
await supervisor.stop().catch(() => undefined);
|
|
269
|
+
return {
|
|
270
|
+
success: false,
|
|
271
|
+
status: statusForError(error),
|
|
272
|
+
conversationId: request.conversationId,
|
|
273
|
+
requestId: request.requestId,
|
|
274
|
+
acpProcessId,
|
|
275
|
+
acpAgentConfigId: request.config.id,
|
|
276
|
+
eventCount: 0,
|
|
277
|
+
error: redactAcpText(acpSafeErrorMessage(error)),
|
|
278
|
+
diagnostics,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const promptRequest = replayHistoryOnFreshSession
|
|
283
|
+
? {
|
|
284
|
+
...request,
|
|
285
|
+
prompt: buildAcpConversationReplayPrompt(request.history || [], request.prompt),
|
|
286
|
+
}
|
|
287
|
+
: request;
|
|
288
|
+
if (replayHistoryOnFreshSession) {
|
|
289
|
+
this.appendLifecycleEvent({
|
|
290
|
+
conversationId: request.conversationId,
|
|
291
|
+
requestId: request.requestId,
|
|
292
|
+
subagentRunId: request.subagentRunId,
|
|
293
|
+
acpProcessId: active.acpProcessId,
|
|
294
|
+
acpAgentConfigId: request.config.id,
|
|
295
|
+
acpSessionId: active.acpSessionId,
|
|
296
|
+
providerKind: 'acp-provider',
|
|
297
|
+
providerId: request.config.id,
|
|
298
|
+
providerModel: request.providerModel,
|
|
299
|
+
schemaVersion: 1,
|
|
300
|
+
redactionState: 'redacted',
|
|
301
|
+
}, 'acp.session.context_replayed', {
|
|
302
|
+
status: 'ready',
|
|
303
|
+
messageCount: request.history?.length || 0,
|
|
304
|
+
characterCount: (request.history || []).reduce((sum, message) => sum + message.content.length, 0),
|
|
305
|
+
configFingerprint: active.configFingerprint,
|
|
306
|
+
workspaceFingerprint: active.workspaceFingerprint,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const result = await this.runExistingSessionPrompt(active.supervisor, {
|
|
310
|
+
...promptRequest,
|
|
311
|
+
timeoutMs: request.timeoutMs || this.requestTimeoutMs,
|
|
312
|
+
}, active.acpProcessId, active.acpSessionId, active.recorder, active.hostRecorder);
|
|
313
|
+
if (!result.success) {
|
|
314
|
+
if (result.status === 'timed_out') {
|
|
315
|
+
await this.closeConversationSession(active).catch(() => undefined);
|
|
316
|
+
}
|
|
317
|
+
else if (result.status === 'process_exited') {
|
|
318
|
+
this.conversationSessions.delete(active.key);
|
|
319
|
+
await active.supervisor.stop().catch(() => undefined);
|
|
320
|
+
}
|
|
321
|
+
else if (result.status === 'cancelled' && active.supervisor.getStatus() !== 'ready') {
|
|
322
|
+
// Deliberately still a plain read, and it is now sufficient: the exit was already
|
|
323
|
+
// established above (with a bounded wait) before this result was returned, so by the time
|
|
324
|
+
// control reaches here a transport that died has had its chance to say so. A second
|
|
325
|
+
// independent wait would double the cancel latency to re-answer a settled question.
|
|
326
|
+
this.conversationSessions.delete(active.key);
|
|
327
|
+
await active.supervisor.stop().catch(() => undefined);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return result;
|
|
331
|
+
}
|
|
332
|
+
async closeConversationSessions() {
|
|
333
|
+
const sessions = [...this.conversationSessions.values()];
|
|
334
|
+
await Promise.all(sessions.map((session) => this.closeConversationSession(session).catch(() => undefined)));
|
|
335
|
+
}
|
|
336
|
+
async closeConversation(conversationId, configId) {
|
|
337
|
+
const sessions = [...this.conversationSessions.values()]
|
|
338
|
+
.filter((session) => (session.conversationId === conversationId
|
|
339
|
+
&& (!configId || session.configId === configId)));
|
|
340
|
+
await Promise.all(sessions.map((session) => this.closeConversationSession(session).catch(() => undefined)));
|
|
341
|
+
return sessions.length;
|
|
342
|
+
}
|
|
343
|
+
async runPromptBatch(request) {
|
|
344
|
+
const acpProcessId = `acp-process-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
345
|
+
if (!request.config.enabled) {
|
|
346
|
+
return request.prompts.map((prompt) => ({
|
|
347
|
+
success: false,
|
|
348
|
+
status: 'failed',
|
|
349
|
+
conversationId: prompt.conversationId,
|
|
350
|
+
requestId: prompt.requestId,
|
|
351
|
+
acpProcessId,
|
|
352
|
+
acpAgentConfigId: request.config.id,
|
|
353
|
+
eventCount: 0,
|
|
354
|
+
error: 'ACP agent config must be enabled before launch.',
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
const recorder = new RuntimeRecordingAcpPermissionBridge(this.permissionBridge, (mapping, context) => {
|
|
358
|
+
this.appendRuntimeEvent(context, mapping);
|
|
359
|
+
}, this.onRunActivity);
|
|
360
|
+
const hostRecorder = new RuntimeRecordingAcpHostBridge(this.hostBridge, (mapping, context) => {
|
|
361
|
+
this.appendRuntimeEvent(context, mapping);
|
|
362
|
+
});
|
|
363
|
+
const supervisor = new AcpProcessSupervisor(request.config, {
|
|
364
|
+
permissionBridge: recorder,
|
|
365
|
+
hostBridge: hostRecorder,
|
|
366
|
+
requestTimeoutMs: this.requestTimeoutMs,
|
|
367
|
+
});
|
|
368
|
+
const results = [];
|
|
369
|
+
const firstPrompt = request.prompts[0];
|
|
370
|
+
const baseContext = {
|
|
371
|
+
conversationId: firstPrompt?.conversationId || 'acp-conversation-unknown',
|
|
372
|
+
requestId: firstPrompt?.requestId || 'acp-request-unknown',
|
|
373
|
+
subagentRunId: firstPrompt?.subagentRunId,
|
|
374
|
+
acpProcessId,
|
|
375
|
+
acpAgentConfigId: request.config.id,
|
|
376
|
+
providerKind: 'acp-provider',
|
|
377
|
+
providerId: request.config.id,
|
|
378
|
+
providerModel: firstPrompt?.providerModel,
|
|
379
|
+
schemaVersion: 1,
|
|
380
|
+
redactionState: 'redacted',
|
|
381
|
+
};
|
|
382
|
+
this.appendRuntimeEvent(baseContext, mapAcpAgentStartedToRuntimeEvent(baseContext, supervisor.diagnostics()));
|
|
383
|
+
try {
|
|
384
|
+
await supervisor.initialize();
|
|
385
|
+
this.appendRuntimeEvent(baseContext, mapAcpAgentReadyToRuntimeEvent(baseContext, supervisor.diagnostics()));
|
|
386
|
+
for (const prompt of request.prompts) {
|
|
387
|
+
results.push(await this.runSinglePrompt(supervisor, {
|
|
388
|
+
...prompt,
|
|
389
|
+
config: request.config,
|
|
390
|
+
timeoutMs: prompt.timeoutMs || request.timeoutMs || this.requestTimeoutMs,
|
|
391
|
+
}, acpProcessId, recorder, hostRecorder));
|
|
392
|
+
}
|
|
393
|
+
return results;
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
const diagnostics = supervisor.diagnostics();
|
|
397
|
+
this.appendRuntimeEvent(baseContext, mapAcpAgentFailedToRuntimeEvent(baseContext, redactAcpText(acpSafeErrorMessage(error)), diagnostics));
|
|
398
|
+
const fallback = {
|
|
399
|
+
success: false,
|
|
400
|
+
status: statusForError(error),
|
|
401
|
+
conversationId: baseContext.conversationId,
|
|
402
|
+
requestId: baseContext.requestId,
|
|
403
|
+
acpProcessId,
|
|
404
|
+
acpAgentConfigId: request.config.id,
|
|
405
|
+
eventCount: 0,
|
|
406
|
+
error: redactAcpText(acpSafeErrorMessage(error)),
|
|
407
|
+
diagnostics,
|
|
408
|
+
};
|
|
409
|
+
return results.length ? results : [fallback];
|
|
410
|
+
}
|
|
411
|
+
finally {
|
|
412
|
+
const diagnosticsBeforeStop = supervisor.diagnostics();
|
|
413
|
+
this.emitStderrIfPresent(baseContext, diagnosticsBeforeStop);
|
|
414
|
+
this.appendRuntimeEvent(baseContext, mapAcpAgentExitedToRuntimeEvent(baseContext, diagnosticsBeforeStop));
|
|
415
|
+
await supervisor.stop().catch(() => undefined);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async runSinglePrompt(supervisor, request, acpProcessId, recorder, hostRecorder) {
|
|
419
|
+
let acpSessionId;
|
|
420
|
+
const context = {
|
|
421
|
+
conversationId: request.conversationId,
|
|
422
|
+
requestId: request.requestId,
|
|
423
|
+
subagentRunId: request.subagentRunId,
|
|
424
|
+
acpProcessId,
|
|
425
|
+
acpAgentConfigId: request.config.id,
|
|
426
|
+
providerKind: 'acp-provider',
|
|
427
|
+
providerId: request.config.id,
|
|
428
|
+
providerModel: request.providerModel,
|
|
429
|
+
schemaVersion: 1,
|
|
430
|
+
redactionState: 'redacted',
|
|
431
|
+
};
|
|
432
|
+
let status = 'starting';
|
|
433
|
+
const eventCountBefore = this.listEventCount(request.conversationId);
|
|
434
|
+
try {
|
|
435
|
+
const session = await supervisor.createSession({
|
|
436
|
+
cwd: request.cwd || request.config.cwd,
|
|
437
|
+
additionalDirectories: request.additionalDirectories,
|
|
438
|
+
mcpServers: [],
|
|
439
|
+
...this.sessionExecutionMeta(request),
|
|
440
|
+
});
|
|
441
|
+
acpSessionId = session.sessionId;
|
|
442
|
+
context.acpSessionId = acpSessionId;
|
|
443
|
+
this.appendRuntimeEvent(context, mapAcpSessionStartedToRuntimeEvent(context, acpSessionId));
|
|
444
|
+
return await this.runExistingSessionPrompt(supervisor, request, acpProcessId, acpSessionId, recorder, hostRecorder, eventCountBefore);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
status = statusForError(error);
|
|
448
|
+
const diagnostics = supervisor.diagnostics();
|
|
449
|
+
diagnostics.runtimeEventCount = this.listEventCount(request.conversationId) - eventCountBefore;
|
|
450
|
+
this.appendRuntimeEvent(context, mapAcpSessionFailedToRuntimeEvent(context, status, redactAcpText(acpSafeErrorMessage(error)), diagnostics));
|
|
451
|
+
if (status === 'process_exited') {
|
|
452
|
+
this.appendRuntimeEvent(context, mapAcpAgentExitedToRuntimeEvent(context, diagnostics));
|
|
453
|
+
}
|
|
454
|
+
return {
|
|
455
|
+
success: false,
|
|
456
|
+
status,
|
|
457
|
+
conversationId: request.conversationId,
|
|
458
|
+
requestId: request.requestId,
|
|
459
|
+
acpProcessId,
|
|
460
|
+
acpAgentConfigId: request.config.id,
|
|
461
|
+
acpSessionId,
|
|
462
|
+
eventCount: diagnostics.runtimeEventCount || 0,
|
|
463
|
+
error: redactAcpText(acpSafeErrorMessage(error)),
|
|
464
|
+
diagnostics,
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
finally {
|
|
468
|
+
recorder.setActiveContext(undefined);
|
|
469
|
+
hostRecorder.setActiveContext(undefined);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
async runExistingSessionPrompt(supervisor, request, acpProcessId, acpSessionId, recorder, hostRecorder, eventCountBefore = this.listEventCount(request.conversationId)) {
|
|
473
|
+
const context = {
|
|
474
|
+
conversationId: request.conversationId,
|
|
475
|
+
requestId: request.requestId,
|
|
476
|
+
subagentRunId: request.subagentRunId,
|
|
477
|
+
acpProcessId,
|
|
478
|
+
acpAgentConfigId: request.config.id,
|
|
479
|
+
acpSessionId,
|
|
480
|
+
providerKind: 'acp-provider',
|
|
481
|
+
providerId: request.config.id,
|
|
482
|
+
providerModel: request.providerModel,
|
|
483
|
+
schemaVersion: 1,
|
|
484
|
+
redactionState: 'redacted',
|
|
485
|
+
};
|
|
486
|
+
recorder.setActiveContext(context);
|
|
487
|
+
hostRecorder.setActiveContext(context);
|
|
488
|
+
let cancelTimer;
|
|
489
|
+
let cancellationRequested = request.abortSignal?.aborted === true;
|
|
490
|
+
const cancelActiveSession = () => {
|
|
491
|
+
cancellationRequested = true;
|
|
492
|
+
void supervisor.cancelSession(acpSessionId).catch(() => undefined);
|
|
493
|
+
};
|
|
494
|
+
if (request.cancelAfterMs !== undefined) {
|
|
495
|
+
cancelTimer = setTimeout(cancelActiveSession, Math.max(0, request.cancelAfterMs));
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
const promptResult = await supervisor.prompt(acpSessionId, request.prompt, {
|
|
499
|
+
timeoutMs: request.timeoutMs,
|
|
500
|
+
signal: request.abortSignal,
|
|
501
|
+
model: request.providerModel,
|
|
502
|
+
systemPrompt: request.systemPrompt,
|
|
503
|
+
execution: request.execution,
|
|
504
|
+
onUpdate: (update) => {
|
|
505
|
+
this.appendRuntimeEvent(context, mapAcpSessionUpdateToRuntimeEvent(update, context));
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
this.appendRuntimeEvent(context, mapAcpPromptResultToRuntimeEvent(acpSessionId, context, promptResult.result));
|
|
509
|
+
const status = promptResult.result.stopReason === 'cancelled' ? 'cancelled' : 'completed';
|
|
510
|
+
const diagnostics = supervisor.diagnostics();
|
|
511
|
+
diagnostics.lastStopReason = promptResult.result.stopReason;
|
|
512
|
+
diagnostics.runtimeEventCount = this.listEventCount(request.conversationId) - eventCountBefore;
|
|
513
|
+
return {
|
|
514
|
+
success: status === 'completed',
|
|
515
|
+
status,
|
|
516
|
+
conversationId: request.conversationId,
|
|
517
|
+
requestId: request.requestId,
|
|
518
|
+
acpProcessId,
|
|
519
|
+
acpAgentConfigId: request.config.id,
|
|
520
|
+
acpSessionId,
|
|
521
|
+
eventCount: diagnostics.runtimeEventCount,
|
|
522
|
+
stopReason: promptResult.result.stopReason,
|
|
523
|
+
diagnostics,
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
catch (error) {
|
|
527
|
+
const status = cancellationRequested || request.abortSignal?.aborted === true
|
|
528
|
+
? 'cancelled'
|
|
529
|
+
: statusForError(error);
|
|
530
|
+
const diagnostics = supervisor.diagnostics();
|
|
531
|
+
if (status === 'cancelled')
|
|
532
|
+
diagnostics.lastStopReason = 'cancelled';
|
|
533
|
+
diagnostics.runtimeEventCount = this.listEventCount(request.conversationId) - eventCountBefore;
|
|
534
|
+
if (status === 'cancelled') {
|
|
535
|
+
this.appendRuntimeEvent(context, mapAcpPromptResultToRuntimeEvent(acpSessionId, context, { stopReason: 'cancelled' }));
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
this.appendRuntimeEvent(context, mapAcpSessionFailedToRuntimeEvent(context, status, redactAcpText(acpSafeErrorMessage(error)), diagnostics));
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* ESTABLISH the exit; do not sample it.
|
|
542
|
+
*
|
|
543
|
+
* This read `supervisor.getStatus() === 'exited'` at the instant the prompt rejected —
|
|
544
|
+
* which, for a cancellation, is the one moment the connection state is guaranteed to still
|
|
545
|
+
* be settling, because cancelling is what aborted it.
|
|
546
|
+
*
|
|
547
|
+
* ⚠️ Stated carefully, because a stronger version of this comment was written first and the
|
|
548
|
+
* evidence did not support it. Losing that race does NOT lose the event:
|
|
549
|
+
* `closeConversationSession` emits `acp.agent.exited` later under the synthetic request id
|
|
550
|
+
* `acp-session-close`. What raced was ATTRIBUTION — whether the exit is reported against
|
|
551
|
+
* the request that caused it, or deferred and attributed to a close — plus the matching
|
|
552
|
+
* decision about discarding the session.
|
|
553
|
+
*
|
|
554
|
+
* ⚠️ And it is a race removed BY CONSTRUCTION, not a diagnosed cause. An intermittent
|
|
555
|
+
* failure was observed in the cancel-recovery test under full parallel load; reading the
|
|
556
|
+
* code showed three separate decisions sampling this one settling value. But no
|
|
557
|
+
* deterministic reproduction of the sampled answer being WRONG was achieved — with the
|
|
558
|
+
* fixtures available the exit is always already visible by the time the prompt settles. So
|
|
559
|
+
* this is "a class of race made unrepresentable", which is worth having, and it is not
|
|
560
|
+
* evidence that it was the cause of that failure.
|
|
561
|
+
*
|
|
562
|
+
* `process_exited` needs no wait — that status IS the observation, and `prompt()` has
|
|
563
|
+
* already transitioned the supervisor to `exited` on `AcpProcessExitedError`.
|
|
564
|
+
*/
|
|
565
|
+
const transportGone = status === 'process_exited'
|
|
566
|
+
|| (status === 'cancelled' && await supervisor.waitForExit(CANCELLED_TRANSPORT_SETTLE_MS));
|
|
567
|
+
if (transportGone) {
|
|
568
|
+
this.appendRuntimeEvent(context, mapAcpAgentExitedToRuntimeEvent(context, diagnostics));
|
|
569
|
+
}
|
|
570
|
+
return {
|
|
571
|
+
success: false,
|
|
572
|
+
status,
|
|
573
|
+
conversationId: request.conversationId,
|
|
574
|
+
requestId: request.requestId,
|
|
575
|
+
acpProcessId,
|
|
576
|
+
acpAgentConfigId: request.config.id,
|
|
577
|
+
acpSessionId,
|
|
578
|
+
eventCount: diagnostics.runtimeEventCount || 0,
|
|
579
|
+
...(status === 'cancelled'
|
|
580
|
+
? { stopReason: 'cancelled' }
|
|
581
|
+
: { error: redactAcpText(acpSafeErrorMessage(error)) }),
|
|
582
|
+
diagnostics,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
finally {
|
|
586
|
+
if (cancelTimer)
|
|
587
|
+
clearTimeout(cancelTimer);
|
|
588
|
+
recorder.setActiveContext(undefined);
|
|
589
|
+
hostRecorder.setActiveContext(undefined);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
async closeConversationSession(active) {
|
|
593
|
+
this.conversationSessions.delete(active.key);
|
|
594
|
+
const context = {
|
|
595
|
+
conversationId: active.conversationId,
|
|
596
|
+
requestId: 'acp-session-close',
|
|
597
|
+
acpProcessId: active.acpProcessId,
|
|
598
|
+
acpAgentConfigId: active.configId,
|
|
599
|
+
acpSessionId: active.acpSessionId,
|
|
600
|
+
providerKind: 'acp-provider',
|
|
601
|
+
providerId: active.configId,
|
|
602
|
+
schemaVersion: 1,
|
|
603
|
+
redactionState: 'redacted',
|
|
604
|
+
};
|
|
605
|
+
const diagnostics = active.supervisor.diagnostics();
|
|
606
|
+
this.emitStderrIfPresent(context, diagnostics);
|
|
607
|
+
this.appendRuntimeEvent(context, mapAcpAgentExitedToRuntimeEvent(context, diagnostics));
|
|
608
|
+
await active.supervisor.stop().catch(() => undefined);
|
|
609
|
+
}
|
|
610
|
+
appendRuntimeEvent(context, mapping) {
|
|
611
|
+
const result = this.runtimeStore.append({
|
|
612
|
+
conversationId: context.conversationId,
|
|
613
|
+
requestId: context.requestId,
|
|
614
|
+
subagentRunId: context.subagentRunId,
|
|
615
|
+
source: 'acp',
|
|
616
|
+
event: {
|
|
617
|
+
...mapping.event,
|
|
618
|
+
conversationId: context.conversationId,
|
|
619
|
+
requestId: context.requestId,
|
|
620
|
+
source: 'acp',
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
if (result.event && !result.duplicate)
|
|
624
|
+
this.onRuntimeEvent?.(result.event);
|
|
625
|
+
}
|
|
626
|
+
appendLifecycleEvent(context, type, payload) {
|
|
627
|
+
this.appendRuntimeEvent(context, {
|
|
628
|
+
type,
|
|
629
|
+
event: {
|
|
630
|
+
type,
|
|
631
|
+
timestamp: new Date().toISOString(),
|
|
632
|
+
...context,
|
|
633
|
+
...payload,
|
|
634
|
+
},
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
emitStderrIfPresent(context, diagnostics) {
|
|
638
|
+
if (diagnostics.stderrTail.length === 0)
|
|
639
|
+
return;
|
|
640
|
+
this.appendRuntimeEvent(context, mapAcpAgentStderrToRuntimeEvent(context, diagnostics.stderrTail));
|
|
641
|
+
}
|
|
642
|
+
listEventCount(conversationId) {
|
|
643
|
+
return this.runtimeStore.list({ conversationId, limit: 5000 }).events.length;
|
|
644
|
+
}
|
|
645
|
+
workspaceKeyFor(cwd, additionalDirectories, execution) {
|
|
646
|
+
return JSON.stringify({
|
|
647
|
+
cwd: normalizeWorkspacePath(cwd || ''),
|
|
648
|
+
additionalDirectories: additionalDirectories.map(normalizeWorkspacePath).sort(),
|
|
649
|
+
execution: execution || {
|
|
650
|
+
schemaVersion: 1,
|
|
651
|
+
permissionProfile: 'unspecified',
|
|
652
|
+
filesystem: 'read-only',
|
|
653
|
+
},
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
sessionExecutionMeta(request, includeResumeState = false) {
|
|
657
|
+
const meta = {};
|
|
658
|
+
if (request.execution) {
|
|
659
|
+
meta[XENO_ACP_CONTEXT_META_KEY] = {
|
|
660
|
+
execution: request.execution,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
if (includeResumeState && request.resumeState) {
|
|
664
|
+
meta[XENO_ACP_SESSION_RESUME_META_KEY] = request.resumeState;
|
|
665
|
+
}
|
|
666
|
+
return Object.keys(meta).length > 0 ? { _meta: meta } : {};
|
|
667
|
+
}
|
|
668
|
+
workspaceFingerprintFor(workspaceKey) {
|
|
669
|
+
return createHash('sha256').update(workspaceKey).digest('hex');
|
|
670
|
+
}
|
|
671
|
+
agentConfigFingerprintFor(config) {
|
|
672
|
+
return createHash('sha256').update(JSON.stringify({
|
|
673
|
+
id: config.id,
|
|
674
|
+
command: config.command,
|
|
675
|
+
args: config.args,
|
|
676
|
+
cwd: config.cwd || '',
|
|
677
|
+
envKeys: Object.keys(config.env || {}).sort(),
|
|
678
|
+
trustLevel: config.trustLevel,
|
|
679
|
+
updatedAt: config.updatedAt,
|
|
680
|
+
})).digest('hex');
|
|
681
|
+
}
|
|
682
|
+
resolveConversationCwd(request) {
|
|
683
|
+
if (request.cwd)
|
|
684
|
+
return request.cwd;
|
|
685
|
+
if (!this.rootDir)
|
|
686
|
+
return undefined;
|
|
687
|
+
const safeConversationId = request.conversationId
|
|
688
|
+
.replace(/[^A-Za-z0-9._-]/g, '_')
|
|
689
|
+
.slice(0, 120) || 'conversation';
|
|
690
|
+
const cwd = join(this.rootDir, 'acp-chat-workspaces', safeConversationId);
|
|
691
|
+
mkdirSync(cwd, { recursive: true });
|
|
692
|
+
return cwd;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
function normalizeWorkspacePath(path) {
|
|
696
|
+
const normalized = path.trim().replace(/\//g, '\\').replace(/\\+$/, '');
|
|
697
|
+
return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
698
|
+
}
|
|
699
|
+
class RuntimeRecordingAcpPermissionBridge {
|
|
700
|
+
delegate;
|
|
701
|
+
append;
|
|
702
|
+
onRunActivity;
|
|
703
|
+
activeContext;
|
|
704
|
+
constructor(delegate, append,
|
|
705
|
+
/**
|
|
706
|
+
* 🔴 This layer is the ONLY one that knows both facts at once: that a
|
|
707
|
+
* human is being waited on, and which run is waiting. The delegate knows
|
|
708
|
+
* the prompt and not the run; the host knows the run and not that the
|
|
709
|
+
* prompt is outstanding.
|
|
710
|
+
*/
|
|
711
|
+
onRunActivity) {
|
|
712
|
+
this.delegate = delegate;
|
|
713
|
+
this.append = append;
|
|
714
|
+
this.onRunActivity = onRunActivity;
|
|
715
|
+
}
|
|
716
|
+
setActiveContext(context) {
|
|
717
|
+
this.activeContext = context;
|
|
718
|
+
}
|
|
719
|
+
async requestPermission(request) {
|
|
720
|
+
const context = {
|
|
721
|
+
...this.activeContext,
|
|
722
|
+
conversationId: this.activeContext?.conversationId || 'acp-conversation-unknown',
|
|
723
|
+
requestId: this.activeContext?.requestId || 'acp-request-unknown',
|
|
724
|
+
acpProcessId: this.activeContext?.acpProcessId || 'acp-process-unknown',
|
|
725
|
+
acpAgentConfigId: this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
726
|
+
providerKind: this.activeContext?.providerKind || 'acp-provider',
|
|
727
|
+
providerId: this.activeContext?.providerId || this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
728
|
+
subagentRunId: this.activeContext?.subagentRunId,
|
|
729
|
+
acpSessionId: request.sessionId || this.activeContext?.acpSessionId,
|
|
730
|
+
schemaVersion: 1,
|
|
731
|
+
redactionState: 'redacted',
|
|
732
|
+
};
|
|
733
|
+
const permissionId = `acp-permission-${Date.now()}-${randomUUID().slice(0, 8)}`;
|
|
734
|
+
this.append(mapAcpPermissionRequestedToRuntimeEvent(context, permissionId, request), context);
|
|
735
|
+
// The delegate may need to raise this to a surface, and a surface routes a
|
|
736
|
+
// prompt onto a conversation by the HOST request id. Only this layer knows
|
|
737
|
+
// it, so it is attached here rather than plumbed through every bridge.
|
|
738
|
+
const runId = defaultRunIdOf({
|
|
739
|
+
conversationId: context.conversationId,
|
|
740
|
+
...(context.subagentRunId === undefined ? {} : { subagentRunId: context.subagentRunId }),
|
|
741
|
+
});
|
|
742
|
+
this.onRunActivity?.({ runId, state: 'awaiting-approval' });
|
|
743
|
+
try {
|
|
744
|
+
const outcome = await this.delegate.requestPermission({
|
|
745
|
+
...request,
|
|
746
|
+
hostRequestId: context.requestId,
|
|
747
|
+
hostConversationId: context.conversationId,
|
|
748
|
+
// The SAME id the journal event above carries, so a prompt rendered from
|
|
749
|
+
// either source is answerable by the same key.
|
|
750
|
+
hostPermissionId: permissionId,
|
|
751
|
+
});
|
|
752
|
+
this.append(mapAcpPermissionDecidedToRuntimeEvent(context, permissionId, outcome, request.sessionId), context);
|
|
753
|
+
this.onRunActivity?.({
|
|
754
|
+
runId,
|
|
755
|
+
state: 'running',
|
|
756
|
+
// §7's "last decision", in the run's own terms. The OUTCOME, not the
|
|
757
|
+
// prompt: a peer needs to know what this run was allowed to do, and the
|
|
758
|
+
// prompt text is the request rather than the answer.
|
|
759
|
+
lastDecision: describePermissionOutcome(outcome),
|
|
760
|
+
});
|
|
761
|
+
return outcome;
|
|
762
|
+
}
|
|
763
|
+
catch (error) {
|
|
764
|
+
// A failed prompt still ENDS the wait. Left in `awaiting-approval` the run
|
|
765
|
+
// would look blocked on a human forever, and a peer would keep deferring
|
|
766
|
+
// to something that is not going to answer.
|
|
767
|
+
this.onRunActivity?.({ runId, state: 'running' });
|
|
768
|
+
throw error;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
cancelOutstanding(reason) {
|
|
772
|
+
this.delegate.cancelOutstanding?.(reason);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* One line a peer can act on, from a permission outcome.
|
|
777
|
+
*
|
|
778
|
+
* Deliberately terse and structural rather than the prompt text: §9 is explicit
|
|
779
|
+
* that a summary is never a transcript, and a permission prompt can quote a
|
|
780
|
+
* command, a path or a diff. What another run needs is what this one was
|
|
781
|
+
* allowed to do, not what it was asked.
|
|
782
|
+
*/
|
|
783
|
+
function describePermissionOutcome(outcome) {
|
|
784
|
+
return outcome.outcome === 'selected'
|
|
785
|
+
? `permission selected (${outcome.selectedOptionId})`
|
|
786
|
+
: 'permission cancelled';
|
|
787
|
+
}
|
|
788
|
+
class RuntimeRecordingAcpHostBridge {
|
|
789
|
+
delegate;
|
|
790
|
+
append;
|
|
791
|
+
activeContext;
|
|
792
|
+
constructor(delegate, append) {
|
|
793
|
+
this.delegate = delegate;
|
|
794
|
+
this.append = append;
|
|
795
|
+
}
|
|
796
|
+
setActiveContext(context) {
|
|
797
|
+
this.activeContext = context;
|
|
798
|
+
}
|
|
799
|
+
async chooseDirectory(request) {
|
|
800
|
+
const context = {
|
|
801
|
+
...this.activeContext,
|
|
802
|
+
conversationId: this.activeContext?.conversationId || 'acp-conversation-unknown',
|
|
803
|
+
requestId: this.activeContext?.requestId || request.requestId || 'acp-request-unknown',
|
|
804
|
+
acpProcessId: this.activeContext?.acpProcessId || 'acp-process-unknown',
|
|
805
|
+
acpAgentConfigId: this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
806
|
+
providerKind: this.activeContext?.providerKind || 'acp-provider',
|
|
807
|
+
providerId: this.activeContext?.providerId || this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
808
|
+
subagentRunId: this.activeContext?.subagentRunId,
|
|
809
|
+
acpSessionId: request.sessionId || this.activeContext?.acpSessionId,
|
|
810
|
+
schemaVersion: 1,
|
|
811
|
+
redactionState: 'redacted',
|
|
812
|
+
};
|
|
813
|
+
let chooseDirectoryId;
|
|
814
|
+
const delegatedRequest = {
|
|
815
|
+
...request,
|
|
816
|
+
requestId: context.requestId,
|
|
817
|
+
sessionId: context.acpSessionId,
|
|
818
|
+
emitRuntimeEvent: (event) => {
|
|
819
|
+
const type = typeof event.type === 'string' && event.type.trim()
|
|
820
|
+
? event.type.trim()
|
|
821
|
+
: 'choose_directory.requested';
|
|
822
|
+
if (typeof event.chooseDirectoryId === 'string' && event.chooseDirectoryId.trim()) {
|
|
823
|
+
chooseDirectoryId = event.chooseDirectoryId.trim();
|
|
824
|
+
}
|
|
825
|
+
this.append({
|
|
826
|
+
type,
|
|
827
|
+
event: {
|
|
828
|
+
...event,
|
|
829
|
+
type,
|
|
830
|
+
source: 'acp',
|
|
831
|
+
...context,
|
|
832
|
+
toolCallId: request.toolCallId,
|
|
833
|
+
toolName: 'ChooseDirectory',
|
|
834
|
+
},
|
|
835
|
+
}, context);
|
|
836
|
+
},
|
|
837
|
+
};
|
|
838
|
+
let result;
|
|
839
|
+
try {
|
|
840
|
+
result = await this.delegate.chooseDirectory(delegatedRequest);
|
|
841
|
+
}
|
|
842
|
+
catch (error) {
|
|
843
|
+
result = { error: acpSafeErrorMessage(error) };
|
|
844
|
+
}
|
|
845
|
+
this.append(mapAcpChooseDirectoryResultToRuntimeEvent(context, delegatedRequest, result, chooseDirectoryId), context);
|
|
846
|
+
return result;
|
|
847
|
+
}
|
|
848
|
+
async chooseWorkspacePlacement(request) {
|
|
849
|
+
const context = {
|
|
850
|
+
...this.activeContext,
|
|
851
|
+
conversationId: this.activeContext?.conversationId || 'acp-conversation-unknown',
|
|
852
|
+
requestId: this.activeContext?.requestId || request.requestId || 'acp-request-unknown',
|
|
853
|
+
acpProcessId: this.activeContext?.acpProcessId || 'acp-process-unknown',
|
|
854
|
+
acpAgentConfigId: this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
855
|
+
providerKind: this.activeContext?.providerKind || 'acp-provider',
|
|
856
|
+
providerId: this.activeContext?.providerId || this.activeContext?.acpAgentConfigId || 'acp-agent-unknown',
|
|
857
|
+
subagentRunId: this.activeContext?.subagentRunId,
|
|
858
|
+
acpSessionId: request.sessionId || this.activeContext?.acpSessionId,
|
|
859
|
+
schemaVersion: 1,
|
|
860
|
+
redactionState: 'redacted',
|
|
861
|
+
};
|
|
862
|
+
let workspacePlacementId;
|
|
863
|
+
const delegatedRequest = {
|
|
864
|
+
...request,
|
|
865
|
+
requestId: context.requestId,
|
|
866
|
+
sessionId: context.acpSessionId,
|
|
867
|
+
emitRuntimeEvent: (event) => {
|
|
868
|
+
const type = typeof event.type === 'string' && event.type.trim()
|
|
869
|
+
? event.type.trim()
|
|
870
|
+
: 'workspace_placement.requested';
|
|
871
|
+
if (typeof event.workspacePlacementId === 'string' && event.workspacePlacementId.trim()) {
|
|
872
|
+
workspacePlacementId = event.workspacePlacementId.trim();
|
|
873
|
+
}
|
|
874
|
+
this.append({
|
|
875
|
+
type,
|
|
876
|
+
event: {
|
|
877
|
+
...event,
|
|
878
|
+
type,
|
|
879
|
+
source: 'acp',
|
|
880
|
+
...context,
|
|
881
|
+
toolCallId: request.toolCallId,
|
|
882
|
+
toolName: 'ChooseWorkspacePlacement',
|
|
883
|
+
},
|
|
884
|
+
}, context);
|
|
885
|
+
},
|
|
886
|
+
};
|
|
887
|
+
let result;
|
|
888
|
+
try {
|
|
889
|
+
result = await this.delegate.chooseWorkspacePlacement(delegatedRequest);
|
|
890
|
+
}
|
|
891
|
+
catch (error) {
|
|
892
|
+
result = { error: acpSafeErrorMessage(error) };
|
|
893
|
+
}
|
|
894
|
+
this.append(mapAcpChooseWorkspacePlacementResultToRuntimeEvent(context, delegatedRequest, result, workspacePlacementId), context);
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
897
|
+
cancelOutstanding(reason) {
|
|
898
|
+
this.delegate.cancelOutstanding?.(reason);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
export function buildAcpConversationReplayPrompt(history, currentPrompt) {
|
|
902
|
+
const priorMessages = history.map((message) => ({ ...message }));
|
|
903
|
+
const last = priorMessages.at(-1);
|
|
904
|
+
if (last?.role === 'user' && last.content.trim() === currentPrompt.trim()) {
|
|
905
|
+
priorMessages.pop();
|
|
906
|
+
}
|
|
907
|
+
if (priorMessages.length === 0)
|
|
908
|
+
return currentPrompt;
|
|
909
|
+
return [
|
|
910
|
+
'XENO Agent restored this conversation into a fresh ACP session.',
|
|
911
|
+
'Use the JSON transcript as prior conversational context. Do not repeat or answer prior turns again.',
|
|
912
|
+
'Answer only the current user message that follows the transcript.',
|
|
913
|
+
JSON.stringify({
|
|
914
|
+
schema: 'xeno.agent.acp-conversation-replay.v1',
|
|
915
|
+
messages: priorMessages,
|
|
916
|
+
}),
|
|
917
|
+
'Current user message:',
|
|
918
|
+
currentPrompt,
|
|
919
|
+
].join('\n\n');
|
|
920
|
+
}
|
|
921
|
+
function statusForError(error) {
|
|
922
|
+
const code = acpErrorCode(error);
|
|
923
|
+
if (code === 'ACP_TIMEOUT')
|
|
924
|
+
return 'timed_out';
|
|
925
|
+
if (code === 'ACP_CANCELLED')
|
|
926
|
+
return 'cancelled';
|
|
927
|
+
if (code === 'ACP_PROCESS_EXITED')
|
|
928
|
+
return 'process_exited';
|
|
929
|
+
return 'failed';
|
|
930
|
+
}
|
|
931
|
+
//# sourceMappingURL=AcpSessionService.js.map
|