@xenosystem/agent-interface-host 0.1.25 → 0.1.26
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/dist/account/AccountIntegrationOperations.d.ts +11 -0
- package/dist/account/AccountIntegrationOperations.d.ts.map +1 -0
- package/dist/account/AccountIntegrationOperations.js +78 -0
- package/dist/account/AccountIntegrationOperations.js.map +1 -0
- package/dist/account/AccountOperations.d.ts +15 -0
- package/dist/account/AccountOperations.d.ts.map +1 -0
- package/dist/account/AccountOperations.js +129 -0
- package/dist/account/AccountOperations.js.map +1 -0
- package/dist/account/AccountWorkforceService.d.ts +44 -0
- package/dist/account/AccountWorkforceService.d.ts.map +1 -0
- package/dist/account/AccountWorkforceService.js +175 -0
- package/dist/account/AccountWorkforceService.js.map +1 -0
- package/dist/account/AccountWorkspaceService.d.ts +56 -0
- package/dist/account/AccountWorkspaceService.d.ts.map +1 -0
- package/dist/account/AccountWorkspaceService.js +424 -0
- package/dist/account/AccountWorkspaceService.js.map +1 -0
- package/dist/account/ConversationCollaborationClient.d.ts +71 -0
- package/dist/account/ConversationCollaborationClient.d.ts.map +1 -0
- package/dist/account/ConversationCollaborationClient.js +271 -0
- package/dist/account/ConversationCollaborationClient.js.map +1 -0
- package/dist/account/WorkforceResourceOperations.d.ts +42 -0
- package/dist/account/WorkforceResourceOperations.d.ts.map +1 -0
- package/dist/account/WorkforceResourceOperations.js +225 -0
- package/dist/account/WorkforceResourceOperations.js.map +1 -0
- package/dist/account/WorkspaceKeyOperations.d.ts +54 -0
- package/dist/account/WorkspaceKeyOperations.d.ts.map +1 -0
- package/dist/account/WorkspaceKeyOperations.js +284 -0
- package/dist/account/WorkspaceKeyOperations.js.map +1 -0
- package/dist/account/WorkspaceMembershipOperations.d.ts +28 -0
- package/dist/account/WorkspaceMembershipOperations.d.ts.map +1 -0
- package/dist/account/WorkspaceMembershipOperations.js +188 -0
- package/dist/account/WorkspaceMembershipOperations.js.map +1 -0
- package/dist/account/accountIntegrationState.d.ts +22 -0
- package/dist/account/accountIntegrationState.d.ts.map +1 -0
- package/dist/account/accountIntegrationState.js +26 -0
- package/dist/account/accountIntegrationState.js.map +1 -0
- package/dist/account/accountKeyOperationState.d.ts +31 -0
- package/dist/account/accountKeyOperationState.d.ts.map +1 -0
- package/dist/account/accountKeyOperationState.js +33 -0
- package/dist/account/accountKeyOperationState.js.map +1 -0
- package/dist/account/accountMembershipOperationState.d.ts +32 -0
- package/dist/account/accountMembershipOperationState.d.ts.map +1 -0
- package/dist/account/accountMembershipOperationState.js +67 -0
- package/dist/account/accountMembershipOperationState.js.map +1 -0
- package/dist/account/accountOperationState.d.ts +22 -0
- package/dist/account/accountOperationState.d.ts.map +1 -0
- package/dist/account/accountOperationState.js +25 -0
- package/dist/account/accountOperationState.js.map +1 -0
- package/dist/account/accountWorkerClient.d.ts +15 -0
- package/dist/account/accountWorkerClient.d.ts.map +1 -0
- package/dist/account/accountWorkerClient.js +251 -0
- package/dist/account/accountWorkerClient.js.map +1 -0
- package/dist/account/accountWorkerEntry.d.ts +2 -0
- package/dist/account/accountWorkerEntry.d.ts.map +1 -0
- package/dist/account/accountWorkerEntry.js +50 -0
- package/dist/account/accountWorkerEntry.js.map +1 -0
- package/dist/account/accountWorkerProtocol.d.ts +76 -0
- package/dist/account/accountWorkerProtocol.d.ts.map +1 -0
- package/dist/account/accountWorkerProtocol.js +44 -0
- package/dist/account/accountWorkerProtocol.js.map +1 -0
- package/dist/account/accountWorkerRuntime.d.ts +81 -0
- package/dist/account/accountWorkerRuntime.d.ts.map +1 -0
- package/dist/account/accountWorkerRuntime.js +172 -0
- package/dist/account/accountWorkerRuntime.js.map +1 -0
- package/dist/account/accountWorkforceOperationState.d.ts +141 -0
- package/dist/account/accountWorkforceOperationState.d.ts.map +1 -0
- package/dist/account/accountWorkforceOperationState.js +149 -0
- package/dist/account/accountWorkforceOperationState.js.map +1 -0
- package/dist/account/canonicalAccountPort.d.ts +473 -0
- package/dist/account/canonicalAccountPort.d.ts.map +1 -0
- package/dist/account/canonicalAccountPort.js +44 -0
- package/dist/account/canonicalAccountPort.js.map +1 -0
- package/dist/acp/AcpAgentRegistryService.d.ts.map +1 -1
- package/dist/acp/AcpAgentRegistryService.js +11 -1
- package/dist/acp/AcpAgentRegistryService.js.map +1 -1
- package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts +27 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.d.ts.map +1 -1
- package/dist/acp/AcpAgentTurnExecutionAdapter.js +18 -0
- package/dist/acp/AcpAgentTurnExecutionAdapter.js.map +1 -1
- package/dist/acp/AcpProcessSupervisor.d.ts +10 -0
- package/dist/acp/AcpProcessSupervisor.d.ts.map +1 -1
- package/dist/acp/AcpProcessSupervisor.js +156 -1
- package/dist/acp/AcpProcessSupervisor.js.map +1 -1
- package/dist/acp/AcpProviderModelService.d.ts.map +1 -1
- package/dist/acp/AcpProviderModelService.js +2 -0
- package/dist/acp/AcpProviderModelService.js.map +1 -1
- package/dist/acp/AcpRuntimeEventMapper.d.ts +1 -1
- package/dist/acp/AcpRuntimeEventMapper.d.ts.map +1 -1
- package/dist/acp/AcpRuntimeEventMapper.js +64 -2
- package/dist/acp/AcpRuntimeEventMapper.js.map +1 -1
- package/dist/acp/AcpSessionService.d.ts +24 -0
- package/dist/acp/AcpSessionService.d.ts.map +1 -1
- package/dist/acp/AcpSessionService.js +150 -14
- package/dist/acp/AcpSessionService.js.map +1 -1
- package/dist/acp/acpMeasuredUsage.d.ts +15 -0
- package/dist/acp/acpMeasuredUsage.d.ts.map +1 -0
- package/dist/acp/acpMeasuredUsage.js +41 -0
- package/dist/acp/acpMeasuredUsage.js.map +1 -0
- package/dist/acp/acpTypes.d.ts +28 -2
- package/dist/acp/acpTypes.d.ts.map +1 -1
- package/dist/acp/acpTypes.js.map +1 -1
- package/dist/agent/permissionProfiles.d.ts +3 -0
- package/dist/agent/permissionProfiles.d.ts.map +1 -1
- package/dist/agent/permissionProfiles.js.map +1 -1
- package/dist/browser/BrowserAdmissionLedger.d.ts +37 -0
- package/dist/browser/BrowserAdmissionLedger.d.ts.map +1 -0
- package/dist/browser/BrowserAdmissionLedger.js +51 -0
- package/dist/browser/BrowserAdmissionLedger.js.map +1 -0
- package/dist/browser/BrowserAutomationHttpTransport.d.ts +81 -0
- package/dist/browser/BrowserAutomationHttpTransport.d.ts.map +1 -0
- package/dist/browser/BrowserAutomationHttpTransport.js +160 -0
- package/dist/browser/BrowserAutomationHttpTransport.js.map +1 -0
- package/dist/browser/BrowserScopeResolver.d.ts +31 -0
- package/dist/browser/BrowserScopeResolver.d.ts.map +1 -0
- package/dist/browser/BrowserScopeResolver.js +31 -0
- package/dist/browser/BrowserScopeResolver.js.map +1 -0
- package/dist/browser/OwnedBrowserCommandService.d.ts +43 -0
- package/dist/browser/OwnedBrowserCommandService.d.ts.map +1 -0
- package/dist/browser/OwnedBrowserCommandService.js +99 -0
- package/dist/browser/OwnedBrowserCommandService.js.map +1 -0
- package/dist/browser/OwnedBrowserSessionRegistry.d.ts +83 -0
- package/dist/browser/OwnedBrowserSessionRegistry.d.ts.map +1 -0
- package/dist/browser/OwnedBrowserSessionRegistry.js +268 -0
- package/dist/browser/OwnedBrowserSessionRegistry.js.map +1 -0
- package/dist/browser/OwnedBrowserSessionService.d.ts +10 -0
- package/dist/browser/OwnedBrowserSessionService.d.ts.map +1 -0
- package/dist/browser/OwnedBrowserSessionService.js +37 -0
- package/dist/browser/OwnedBrowserSessionService.js.map +1 -0
- package/dist/browser/browserFrame.d.ts +12 -0
- package/dist/browser/browserFrame.d.ts.map +1 -0
- package/dist/browser/browserFrame.js +21 -0
- package/dist/browser/browserFrame.js.map +1 -0
- package/dist/cli/CliControlPlaneService.d.ts +12 -1
- package/dist/cli/CliControlPlaneService.d.ts.map +1 -1
- package/dist/cli/CliControlPlaneService.js +164 -15
- package/dist/cli/CliControlPlaneService.js.map +1 -1
- package/dist/cli/CliRemoteAdmissionStore.d.ts +43 -0
- package/dist/cli/CliRemoteAdmissionStore.d.ts.map +1 -0
- package/dist/cli/CliRemoteAdmissionStore.js +56 -0
- package/dist/cli/CliRemoteAdmissionStore.js.map +1 -0
- package/dist/cli/CliSchedulingService.d.ts +19 -0
- package/dist/cli/CliSchedulingService.d.ts.map +1 -0
- package/dist/cli/CliSchedulingService.js +182 -0
- package/dist/cli/CliSchedulingService.js.map +1 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts +3 -0
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.d.ts.map +1 -1
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js +9 -3
- package/dist/cloud/XenoCloudAgentTurnExecutionAdapter.js.map +1 -1
- package/dist/codebase/CodebaseIntelligenceService.d.ts.map +1 -1
- package/dist/codebase/CodebaseIntelligenceService.js +9 -173
- package/dist/codebase/CodebaseIntelligenceService.js.map +1 -1
- package/dist/codebase/LanguageServerProcessManager.d.ts +2 -0
- package/dist/codebase/LanguageServerProcessManager.d.ts.map +1 -1
- package/dist/codebase/LanguageServerProcessManager.js +4 -0
- package/dist/codebase/LanguageServerProcessManager.js.map +1 -1
- package/dist/codebase/workspaceEdits.d.ts +7 -0
- package/dist/codebase/workspaceEdits.d.ts.map +1 -0
- package/dist/codebase/workspaceEdits.js +205 -0
- package/dist/codebase/workspaceEdits.js.map +1 -0
- package/dist/coordination/messages.d.ts +1 -1
- package/dist/coordination/messages.d.ts.map +1 -1
- package/dist/coordination/messages.js +3 -0
- package/dist/coordination/messages.js.map +1 -1
- package/dist/engineering/EngineeringWorkbenchService.d.ts +2 -2
- package/dist/engineering/EngineeringWorkbenchService.d.ts.map +1 -1
- package/dist/engineering/EngineeringWorkbenchService.js +40 -14
- package/dist/engineering/EngineeringWorkbenchService.js.map +1 -1
- package/dist/engineering/GitLandingArtifactSource.d.ts +55 -0
- package/dist/engineering/GitLandingArtifactSource.d.ts.map +1 -0
- package/dist/engineering/GitLandingArtifactSource.js +261 -0
- package/dist/engineering/GitLandingArtifactSource.js.map +1 -0
- package/dist/engineering/GitLandingAuthority.d.ts +148 -0
- package/dist/engineering/GitLandingAuthority.d.ts.map +1 -0
- package/dist/engineering/GitLandingAuthority.js +516 -0
- package/dist/engineering/GitLandingAuthority.js.map +1 -0
- package/dist/engineering/LandingService.d.ts +27 -75
- package/dist/engineering/LandingService.d.ts.map +1 -1
- package/dist/engineering/LandingService.js +169 -225
- package/dist/engineering/LandingService.js.map +1 -1
- package/dist/engineering/LandingServicePersistence.d.ts +20 -0
- package/dist/engineering/LandingServicePersistence.d.ts.map +1 -0
- package/dist/engineering/LandingServicePersistence.js +148 -0
- package/dist/engineering/LandingServicePersistence.js.map +1 -0
- package/dist/index.d.ts +198 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +677 -35
- package/dist/index.js.map +1 -1
- package/dist/inference/AuxiliaryInferenceService.d.ts +23 -0
- package/dist/inference/AuxiliaryInferenceService.d.ts.map +1 -0
- package/dist/inference/AuxiliaryInferenceService.js +103 -0
- package/dist/inference/AuxiliaryInferenceService.js.map +1 -0
- package/dist/isolation/CommandExecution.d.ts +26 -3
- package/dist/isolation/CommandExecution.d.ts.map +1 -1
- package/dist/isolation/CommandExecution.js.map +1 -1
- package/dist/isolation/LocalCommandExecutor.d.ts +8 -1
- package/dist/isolation/LocalCommandExecutor.d.ts.map +1 -1
- package/dist/isolation/LocalCommandExecutor.js +92 -6
- package/dist/isolation/LocalCommandExecutor.js.map +1 -1
- package/dist/isolation/SandboxCommandExecutor.d.ts.map +1 -1
- package/dist/isolation/SandboxCommandExecutor.js +2 -0
- package/dist/isolation/SandboxCommandExecutor.js.map +1 -1
- package/dist/knowledge/WorkspaceKnowledgeService.d.ts +7 -2
- package/dist/knowledge/WorkspaceKnowledgeService.d.ts.map +1 -1
- package/dist/knowledge/WorkspaceKnowledgeService.js +91 -40
- package/dist/knowledge/WorkspaceKnowledgeService.js.map +1 -1
- package/dist/lease/ProcessLivenessProber.d.ts +10 -8
- package/dist/lease/ProcessLivenessProber.d.ts.map +1 -1
- package/dist/lease/ProcessLivenessProber.js +36 -51
- package/dist/lease/ProcessLivenessProber.js.map +1 -1
- package/dist/lease/ProviderWriterLeaseService.d.ts +1 -1
- package/dist/lease/ProviderWriterLeaseService.d.ts.map +1 -1
- package/dist/lease/ProviderWriterLeaseService.js +2 -2
- package/dist/lease/ProviderWriterLeaseService.js.map +1 -1
- package/dist/lease/localLeaseMutex.d.ts +5 -0
- package/dist/lease/localLeaseMutex.d.ts.map +1 -0
- package/dist/lease/localLeaseMutex.js +64 -0
- package/dist/lease/localLeaseMutex.js.map +1 -0
- package/dist/localHostLease.d.ts +5 -19
- package/dist/localHostLease.d.ts.map +1 -1
- package/dist/localHostLease.js +126 -125
- package/dist/localHostLease.js.map +1 -1
- package/dist/localRpcTransport.d.ts +1 -0
- package/dist/localRpcTransport.d.ts.map +1 -1
- package/dist/localRpcTransport.js +52 -11
- package/dist/localRpcTransport.js.map +1 -1
- package/dist/node.d.ts +28 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +26 -0
- package/dist/node.js.map +1 -1
- package/dist/notifications/WorkspaceNotificationService.d.ts +74 -0
- package/dist/notifications/WorkspaceNotificationService.d.ts.map +1 -0
- package/dist/notifications/WorkspaceNotificationService.js +480 -0
- package/dist/notifications/WorkspaceNotificationService.js.map +1 -0
- package/dist/notifications/notificationDestinationOperationState.d.ts +19 -0
- package/dist/notifications/notificationDestinationOperationState.d.ts.map +1 -0
- package/dist/notifications/notificationDestinationOperationState.js +58 -0
- package/dist/notifications/notificationDestinationOperationState.js.map +1 -0
- package/dist/provider/ProviderLaneService.d.ts +2 -0
- package/dist/provider/ProviderLaneService.d.ts.map +1 -1
- package/dist/provider/ProviderLaneService.js +19 -4
- package/dist/provider/ProviderLaneService.js.map +1 -1
- package/dist/sdk/SdkExecutionSettlementRegistry.d.ts +43 -0
- package/dist/sdk/SdkExecutionSettlementRegistry.d.ts.map +1 -0
- package/dist/sdk/SdkExecutionSettlementRegistry.js +88 -0
- package/dist/sdk/SdkExecutionSettlementRegistry.js.map +1 -0
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts +21 -1
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.d.ts.map +1 -1
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js +18 -4
- package/dist/sdk/SdkNativeAgentTurnExecutionAdapter.js.map +1 -1
- package/dist/state/JsonAgentStateRepository.d.ts.map +1 -1
- package/dist/state/JsonAgentStateRepository.js +24 -1
- package/dist/state/JsonAgentStateRepository.js.map +1 -1
- package/dist/state/ScopedAuditService.d.ts +9 -0
- package/dist/state/ScopedAuditService.d.ts.map +1 -0
- package/dist/state/ScopedAuditService.js +137 -0
- package/dist/state/ScopedAuditService.js.map +1 -0
- package/dist/state/ScopedBackupService.d.ts +26 -0
- package/dist/state/ScopedBackupService.d.ts.map +1 -0
- package/dist/state/ScopedBackupService.js +203 -0
- package/dist/state/ScopedBackupService.js.map +1 -0
- package/dist/state/ScopedUsageService.d.ts +9 -0
- package/dist/state/ScopedUsageService.d.ts.map +1 -0
- package/dist/state/ScopedUsageService.js +171 -0
- package/dist/state/ScopedUsageService.js.map +1 -0
- package/dist/state/SqliteAgentStateRepository.d.ts +132 -0
- package/dist/state/SqliteAgentStateRepository.d.ts.map +1 -1
- package/dist/state/SqliteAgentStateRepository.js +976 -19
- package/dist/state/SqliteAgentStateRepository.js.map +1 -1
- package/dist/state/SqliteWorkspaceKnowledgeStore.d.ts +19 -0
- package/dist/state/SqliteWorkspaceKnowledgeStore.d.ts.map +1 -0
- package/dist/state/SqliteWorkspaceKnowledgeStore.js +29 -0
- package/dist/state/SqliteWorkspaceKnowledgeStore.js.map +1 -0
- package/dist/state/WorkspaceEnvironmentService.d.ts +24 -0
- package/dist/state/WorkspaceEnvironmentService.d.ts.map +1 -0
- package/dist/state/WorkspaceEnvironmentService.js +150 -0
- package/dist/state/WorkspaceEnvironmentService.js.map +1 -0
- package/dist/state/WorkspaceLifecycleService.d.ts +10 -0
- package/dist/state/WorkspaceLifecycleService.d.ts.map +1 -0
- package/dist/state/WorkspaceLifecycleService.js +28 -0
- package/dist/state/WorkspaceLifecycleService.js.map +1 -0
- package/dist/state/WorkspaceRulesService.d.ts +36 -0
- package/dist/state/WorkspaceRulesService.d.ts.map +1 -0
- package/dist/state/WorkspaceRulesService.js +135 -0
- package/dist/state/WorkspaceRulesService.js.map +1 -0
- package/dist/state/scopedBackupProjection.d.ts +21 -0
- package/dist/state/scopedBackupProjection.d.ts.map +1 -0
- package/dist/state/scopedBackupProjection.js +102 -0
- package/dist/state/scopedBackupProjection.js.map +1 -0
- package/dist/state/sdkProtectedStateCipher.d.ts +1 -0
- package/dist/state/sdkProtectedStateCipher.d.ts.map +1 -1
- package/dist/state/sdkProtectedStateCipher.js +9 -3
- package/dist/state/sdkProtectedStateCipher.js.map +1 -1
- package/dist/state/sqliteContention.d.ts +5 -0
- package/dist/state/sqliteContention.d.ts.map +1 -0
- package/dist/state/sqliteContention.js +21 -0
- package/dist/state/sqliteContention.js.map +1 -0
- package/dist/state/stateSanitizers.d.ts.map +1 -1
- package/dist/state/stateSanitizers.js +22 -20
- package/dist/state/stateSanitizers.js.map +1 -1
- package/dist/state/workspaceAdmission.d.ts +31 -0
- package/dist/state/workspaceAdmission.d.ts.map +1 -0
- package/dist/state/workspaceAdmission.js +27 -0
- package/dist/state/workspaceAdmission.js.map +1 -0
- package/dist/state/workspaceCoordinationFence.d.ts +26 -0
- package/dist/state/workspaceCoordinationFence.d.ts.map +1 -0
- package/dist/state/workspaceCoordinationFence.js +56 -0
- package/dist/state/workspaceCoordinationFence.js.map +1 -0
- package/dist/state/workspaceEnvironmentProjection.d.ts +3 -0
- package/dist/state/workspaceEnvironmentProjection.d.ts.map +1 -0
- package/dist/state/workspaceEnvironmentProjection.js +27 -0
- package/dist/state/workspaceEnvironmentProjection.js.map +1 -0
- package/dist/state/workspaceLifecycle.d.ts +29 -0
- package/dist/state/workspaceLifecycle.d.ts.map +1 -0
- package/dist/state/workspaceLifecycle.js +129 -0
- package/dist/state/workspaceLifecycle.js.map +1 -0
- package/dist/subagents/CliSubagentExecutionAdapter.d.ts +1 -0
- package/dist/subagents/CliSubagentExecutionAdapter.d.ts.map +1 -1
- package/dist/subagents/CliSubagentExecutionAdapter.js +74 -19
- package/dist/subagents/CliSubagentExecutionAdapter.js.map +1 -1
- package/dist/subagents/CliSubagentRecoveryAdapter.d.ts +9 -0
- package/dist/subagents/CliSubagentRecoveryAdapter.d.ts.map +1 -0
- package/dist/subagents/CliSubagentRecoveryAdapter.js +31 -0
- package/dist/subagents/CliSubagentRecoveryAdapter.js.map +1 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts +8 -0
- package/dist/subagents/HostTurnSubagentExecutionAdapter.d.ts.map +1 -1
- package/dist/subagents/HostTurnSubagentExecutionAdapter.js +67 -1
- package/dist/subagents/HostTurnSubagentExecutionAdapter.js.map +1 -1
- package/dist/subagents/SubagentRunService.d.ts +23 -0
- package/dist/subagents/SubagentRunService.d.ts.map +1 -1
- package/dist/subagents/SubagentRunService.js +102 -8
- package/dist/subagents/SubagentRunService.js.map +1 -1
- package/dist/subagents/SubagentScheduler.d.ts +28 -0
- package/dist/subagents/SubagentScheduler.d.ts.map +1 -1
- package/dist/subagents/SubagentScheduler.js +106 -2
- package/dist/subagents/SubagentScheduler.js.map +1 -1
- package/dist/subagents/subagentExecutionOwnership.d.ts +21 -0
- package/dist/subagents/subagentExecutionOwnership.d.ts.map +1 -0
- package/dist/subagents/subagentExecutionOwnership.js +26 -0
- package/dist/subagents/subagentExecutionOwnership.js.map +1 -0
- package/dist/subagents/subagentRunPort.d.ts +17 -0
- package/dist/subagents/subagentRunPort.d.ts.map +1 -1
- package/dist/subagents/subagentRunPort.js +4 -2
- package/dist/subagents/subagentRunPort.js.map +1 -1
- package/dist/subagents/subagentTypes.d.ts +7 -0
- package/dist/subagents/subagentTypes.d.ts.map +1 -1
- package/dist/turns/DurableInterruptedTurnStore.d.ts.map +1 -1
- package/dist/turns/DurableInterruptedTurnStore.js +48 -35
- package/dist/turns/DurableInterruptedTurnStore.js.map +1 -1
- package/dist/turns/persistedToolPolicy.d.ts +7 -0
- package/dist/turns/persistedToolPolicy.d.ts.map +1 -0
- package/dist/turns/persistedToolPolicy.js +25 -0
- package/dist/turns/persistedToolPolicy.js.map +1 -0
- package/dist/turns/reasoningSelection.d.ts +4 -0
- package/dist/turns/reasoningSelection.d.ts.map +1 -0
- package/dist/turns/reasoningSelection.js +20 -0
- package/dist/turns/reasoningSelection.js.map +1 -0
- package/dist/turns/toolCategoryAdmission.d.ts +5 -0
- package/dist/turns/toolCategoryAdmission.d.ts.map +1 -0
- package/dist/turns/toolCategoryAdmission.js +24 -0
- package/dist/turns/toolCategoryAdmission.js.map +1 -0
- package/dist/turns/workspaceExecutionScope.d.ts +10 -0
- package/dist/turns/workspaceExecutionScope.d.ts.map +1 -0
- package/dist/turns/workspaceExecutionScope.js +47 -0
- package/dist/turns/workspaceExecutionScope.js.map +1 -0
- package/dist/workspace/WorkspaceHostService.d.ts +12 -2
- package/dist/workspace/WorkspaceHostService.d.ts.map +1 -1
- package/dist/workspace/WorkspaceHostService.js +81 -19
- package/dist/workspace/WorkspaceHostService.js.map +1 -1
- package/dist/workspace/readWorkspaceText.d.ts +8 -0
- package/dist/workspace/readWorkspaceText.d.ts.map +1 -0
- package/dist/workspace/readWorkspaceText.js +46 -0
- package/dist/workspace/readWorkspaceText.js.map +1 -0
- package/dist/workspace/windowsWorkspaceText.d.ts +18 -0
- package/dist/workspace/windowsWorkspaceText.d.ts.map +1 -0
- package/dist/workspace/windowsWorkspaceText.js +188 -0
- package/dist/workspace/windowsWorkspaceText.js.map +1 -0
- package/dist/workspace/writeWorkspaceText.d.ts +20 -0
- package/dist/workspace/writeWorkspaceText.d.ts.map +1 -0
- package/dist/workspace/writeWorkspaceText.js +185 -0
- package/dist/workspace/writeWorkspaceText.js.map +1 -0
- package/package.json +16 -7
package/dist/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import { resolveWorkspaceExecutionScope } from './turns/workspaceExecutionScope.js';
|
|
2
|
+
import { admissionInScope } from './state/workspaceAdmission.js';
|
|
3
|
+
import { fenceWorkspaceCoordination, restoreWorkspaceCoordination, settleWorkspaceCoordinationOwner } from './state/workspaceCoordinationFence.js';
|
|
4
|
+
import { publicWorkspaceEnvironment, preservePrivateLegacyEnvironment } from './state/workspaceEnvironmentProjection.js';
|
|
5
|
+
import { applyWorkspaceLifecycle } from './state/WorkspaceLifecycleService.js';
|
|
6
|
+
import { assertNoDirectLifecycleMutation } from './state/workspaceLifecycle.js';
|
|
7
|
+
import { assertNativeToolCategoryAdmission, assertToolCategoryAdmission } from './turns/toolCategoryAdmission.js';
|
|
8
|
+
import { resolvePersistedToolCapabilities } from './turns/persistedToolPolicy.js';
|
|
1
9
|
import { AgentHostProtocolError, XENO_AGENT_HOST_MIN_PROTOCOL_VERSION, XENO_AGENT_HOST_PROTOCOL_VERSION, isAgentHostClientIdentity, isAgentProviderListResult, defaultRunIdOf, isAgentRuntimeEventEnvelope, } from '@xenosystem/agent-interface-contract';
|
|
2
10
|
/**
|
|
3
11
|
* Bounds on the instruction queue. Unbounded queues are how a stuck loop turns
|
|
@@ -59,6 +67,11 @@ export class AgentHostCoordinator {
|
|
|
59
67
|
runtimeEvents = new Map();
|
|
60
68
|
runtimeEventRepository;
|
|
61
69
|
stateRepository;
|
|
70
|
+
backupService;
|
|
71
|
+
environmentService;
|
|
72
|
+
schedulingService;
|
|
73
|
+
usageService;
|
|
74
|
+
auditService;
|
|
62
75
|
workspaceService;
|
|
63
76
|
interactionService;
|
|
64
77
|
permissionPolicyService;
|
|
@@ -68,6 +81,7 @@ export class AgentHostCoordinator {
|
|
|
68
81
|
coordinationService;
|
|
69
82
|
developmentCoordinationStore;
|
|
70
83
|
developmentCoordinationLeases = new Map();
|
|
84
|
+
executionSettlements = new Map();
|
|
71
85
|
/**
|
|
72
86
|
* Run id -> the conversation that run belongs to.
|
|
73
87
|
*
|
|
@@ -140,6 +154,10 @@ export class AgentHostCoordinator {
|
|
|
140
154
|
catalogRevision = 0;
|
|
141
155
|
providerCatalogFingerprint = '';
|
|
142
156
|
providerCatalogRefresh = null;
|
|
157
|
+
closing = false;
|
|
158
|
+
closeFlight;
|
|
159
|
+
pendingTurnStarts = new Set();
|
|
160
|
+
turnCompletions = new Set();
|
|
143
161
|
constructor(options) {
|
|
144
162
|
const { providers, providerCatalogLoader, runtimeEvents, runtimeEventRepository, stateRepository, workspaceService, interactionService, permissionPolicyService, interruptedTurnStore, turnAdmissionPolicy, turnAbandonGraceMs, sdkControlService, engineeringControlService, providerLaneService, turnExecutionAdapters, coordinationService, developmentCoordinationStore, runObservationService, runIsolationService, runObservationBinder, sessionService, nativeTuiLane, acpAgentRegistry, intakeService, knowledgeService, acpApprovalService, subagentRuns, resolveRunId, ...hostOptions } = options;
|
|
145
163
|
if (runtimeEventRepository && runtimeEvents && runtimeEvents.length > 0) {
|
|
@@ -149,6 +167,12 @@ export class AgentHostCoordinator {
|
|
|
149
167
|
this.runtimeEventRepository = runtimeEventRepository;
|
|
150
168
|
this.providerCatalogLoader = providerCatalogLoader;
|
|
151
169
|
this.stateRepository = stateRepository;
|
|
170
|
+
this.backupService = options.backupService;
|
|
171
|
+
this.environmentService = options.environmentService;
|
|
172
|
+
this.schedulingService = options.schedulingService;
|
|
173
|
+
this.usageService = options.usageService;
|
|
174
|
+
this.auditService = options.auditService;
|
|
175
|
+
this.backupService?.start();
|
|
152
176
|
this.workspaceService = workspaceService;
|
|
153
177
|
this.interactionService = interactionService;
|
|
154
178
|
this.permissionPolicyService = permissionPolicyService;
|
|
@@ -813,6 +837,28 @@ export class AgentHostCoordinator {
|
|
|
813
837
|
return { ok: false, removed: false, reason: 'This host has no ACP agent registry mounted.' };
|
|
814
838
|
return registry.remove(request.agentId);
|
|
815
839
|
}
|
|
840
|
+
getAcpAdapter() {
|
|
841
|
+
for (const adapter of this.turnExecutionAdapters.values()) {
|
|
842
|
+
if (adapter.id === 'acp' || (typeof adapter.supports === 'function' && adapter.supports({ kind: 'acp' }))) {
|
|
843
|
+
return adapter;
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return undefined;
|
|
847
|
+
}
|
|
848
|
+
async getAcpCapabilitySnapshot(request) {
|
|
849
|
+
const adapter = this.getAcpAdapter();
|
|
850
|
+
if (!adapter || typeof adapter.getCapabilitySnapshot !== 'function') {
|
|
851
|
+
return { success: false, error: 'This host has no ACP execution adapter mounted.' };
|
|
852
|
+
}
|
|
853
|
+
return await adapter.getCapabilitySnapshot(request);
|
|
854
|
+
}
|
|
855
|
+
async invokeAcpCommand(request) {
|
|
856
|
+
const adapter = this.getAcpAdapter();
|
|
857
|
+
if (!adapter || typeof adapter.invokeCommand !== 'function') {
|
|
858
|
+
return { success: false, error: 'This host has no ACP execution adapter mounted.' };
|
|
859
|
+
}
|
|
860
|
+
return await adapter.invokeCommand(request);
|
|
861
|
+
}
|
|
816
862
|
setSessionMode(request) {
|
|
817
863
|
const service = this.sessionService;
|
|
818
864
|
if (!service)
|
|
@@ -1445,6 +1491,98 @@ export class AgentHostCoordinator {
|
|
|
1445
1491
|
return this.sessionService;
|
|
1446
1492
|
}
|
|
1447
1493
|
async request(method, input) {
|
|
1494
|
+
if (this.closing)
|
|
1495
|
+
throw new Error('The Agent host is shutting down and cannot admit new requests.');
|
|
1496
|
+
if (method === 'workspace.environment') {
|
|
1497
|
+
if (!this.environmentService)
|
|
1498
|
+
return { success: false, error: 'Protected environment service unavailable on this host.' };
|
|
1499
|
+
const result = await this.environmentService.request(input);
|
|
1500
|
+
if (result.success && input.action !== 'list')
|
|
1501
|
+
this.publish('state.workspaces.changed', { revision: result.revision });
|
|
1502
|
+
return result;
|
|
1503
|
+
}
|
|
1504
|
+
if (method === 'account.request') {
|
|
1505
|
+
if (!this.options.accountService)
|
|
1506
|
+
return { success: false, code: 'UNCONFIGURED', status: { state: 'unconfigured', persistence: 'unavailable', reason: 'Account authority is not configured on this host.' } };
|
|
1507
|
+
return await this.options.accountService.request(input);
|
|
1508
|
+
}
|
|
1509
|
+
if (method === 'workforce.request') {
|
|
1510
|
+
if (!this.options.workforceService)
|
|
1511
|
+
return { schemaVersion: 1, success: false, code: 'UNCONFIGURED', error: 'Workforce authority is not configured on this host.' };
|
|
1512
|
+
return await this.options.workforceService.request(input);
|
|
1513
|
+
}
|
|
1514
|
+
if (method === 'workspace.notifications') {
|
|
1515
|
+
if (!this.options.notificationService)
|
|
1516
|
+
return { success: false, error: 'Durable notification delivery is unavailable in this host.' };
|
|
1517
|
+
return await this.options.notificationService.request(input);
|
|
1518
|
+
}
|
|
1519
|
+
if (method === 'workspace.rules') {
|
|
1520
|
+
if (!this.options.rulesService)
|
|
1521
|
+
return { success: false, error: 'Workspace rules are unavailable on this host.' };
|
|
1522
|
+
return await this.options.rulesService.request(input);
|
|
1523
|
+
}
|
|
1524
|
+
if (method === 'workspace.browser') {
|
|
1525
|
+
this.assertConnectedClient(input.client, 'using the owned Browser');
|
|
1526
|
+
if (!this.options.browserService)
|
|
1527
|
+
return { success: false, code: 'unavailable', error: 'Owned Browser authority is unavailable on this host.' };
|
|
1528
|
+
return await this.options.browserService.request(input);
|
|
1529
|
+
}
|
|
1530
|
+
if (method === 'workspace.browser.session') {
|
|
1531
|
+
this.assertConnectedClient(input.client, 'managing owned Browser sessions');
|
|
1532
|
+
if (!this.options.browserSessionService)
|
|
1533
|
+
return { success: false, code: 'unavailable', error: 'Owned XENO Browser sessions are unavailable on this host.' };
|
|
1534
|
+
return await this.options.browserSessionService.request(input);
|
|
1535
|
+
}
|
|
1536
|
+
if (method === 'workspace.backup') {
|
|
1537
|
+
if (!this.backupService)
|
|
1538
|
+
return { success: false, error: 'Scoped backup service is unavailable on this host version.' };
|
|
1539
|
+
const result = await this.backupService.request(input);
|
|
1540
|
+
if (result.success && result.restoredConversations)
|
|
1541
|
+
this.publish('state.workspaces.changed', { revision: result.revision });
|
|
1542
|
+
return result;
|
|
1543
|
+
}
|
|
1544
|
+
if (method === 'workspace.lifecycle.apply') {
|
|
1545
|
+
const request = input;
|
|
1546
|
+
this.assertConnectedClient(request.command.client, 'changing workspace lifecycle');
|
|
1547
|
+
const repository = this.requireStateRepository();
|
|
1548
|
+
if (!repository.beginWorkspaceLifecycle || !repository.finishWorkspaceLifecycle)
|
|
1549
|
+
return { success: false, status: 'rejected', operationId: request.operationId, error: 'Durable lifecycle service is unavailable on this host.' };
|
|
1550
|
+
const result = await applyWorkspaceLifecycle(repository, request, async (operation) => {
|
|
1551
|
+
const state = await repository.loadWorkspaces();
|
|
1552
|
+
if (!state.success)
|
|
1553
|
+
throw new Error(state.error || 'Workspace authority is unavailable');
|
|
1554
|
+
this.publish('state.workspaces.changed', { revision: state.revision });
|
|
1555
|
+
if (!this.schedulingService?.cancelScope)
|
|
1556
|
+
throw new Error('Scheduling cancellation authority is unavailable; lifecycle remains pending');
|
|
1557
|
+
const scheduled = await this.schedulingService.cancelScope(operation.scope, state);
|
|
1558
|
+
if (!scheduled.success)
|
|
1559
|
+
throw new Error(scheduled.error || 'Scoped schedules did not confirm cancellation');
|
|
1560
|
+
await this.quiesceWorkspaceLifecycle(operation, request);
|
|
1561
|
+
});
|
|
1562
|
+
if (result.success)
|
|
1563
|
+
this.publish('state.workspaces.changed', { revision: result.revision });
|
|
1564
|
+
return result;
|
|
1565
|
+
}
|
|
1566
|
+
if (method === 'workspace.schedule') {
|
|
1567
|
+
if (!this.schedulingService)
|
|
1568
|
+
return { success: false, error: 'Scheduling service is unavailable on this host version.' };
|
|
1569
|
+
return await this.schedulingService.request(input, await this.requireStateRepository().loadWorkspaces());
|
|
1570
|
+
}
|
|
1571
|
+
if (method === 'workspace.audit') {
|
|
1572
|
+
if (!this.auditService)
|
|
1573
|
+
return { success: false, error: 'Scoped audit service is unavailable on this host.' };
|
|
1574
|
+
return await this.auditService.request(input, await this.requireStateRepository().loadWorkspaces());
|
|
1575
|
+
}
|
|
1576
|
+
if (method === 'inference.request') {
|
|
1577
|
+
if (!this.options.inferenceService)
|
|
1578
|
+
return { success: false, error: 'Auxiliary inference is unavailable on this host.' };
|
|
1579
|
+
return await this.options.inferenceService.request(input);
|
|
1580
|
+
}
|
|
1581
|
+
if (method === 'workspace.usage') {
|
|
1582
|
+
if (!this.usageService)
|
|
1583
|
+
return { success: false, error: 'Scoped usage service is unavailable on this host.' };
|
|
1584
|
+
return await this.usageService.request(input, await this.requireStateRepository().loadWorkspaces());
|
|
1585
|
+
}
|
|
1448
1586
|
if (method === 'host.handshake') {
|
|
1449
1587
|
return this.handshake(input);
|
|
1450
1588
|
}
|
|
@@ -1459,10 +1597,44 @@ export class AgentHostCoordinator {
|
|
|
1459
1597
|
return await this.listRuntimeEvents(input);
|
|
1460
1598
|
}
|
|
1461
1599
|
if (method === 'state.workspaces.load') {
|
|
1462
|
-
|
|
1600
|
+
const state = await this.requireStateRepository().loadWorkspaces();
|
|
1601
|
+
return { ...state, workspaces: publicWorkspaceEnvironment(state.workspaces) };
|
|
1463
1602
|
}
|
|
1464
1603
|
if (method === 'state.workspaces.save') {
|
|
1465
|
-
|
|
1604
|
+
const request = input;
|
|
1605
|
+
const repository = this.requireStateRepository();
|
|
1606
|
+
const before = await repository.loadWorkspaces();
|
|
1607
|
+
if (!before.success)
|
|
1608
|
+
return { success: false, error: before.error || 'Workspace authority is unavailable' };
|
|
1609
|
+
try {
|
|
1610
|
+
if (request.expectedRevision === undefined || request.expectedRevision === before.revision)
|
|
1611
|
+
assertNoDirectLifecycleMutation(before.workspaces, request.workspaces);
|
|
1612
|
+
}
|
|
1613
|
+
catch (error) {
|
|
1614
|
+
return { success: false, error: error instanceof Error ? error.message : 'Use the host lifecycle operation' };
|
|
1615
|
+
}
|
|
1616
|
+
// Legacy repositories have no revision contract. A revision-aware authority
|
|
1617
|
+
// must never accept an unconditional renderer snapshot.
|
|
1618
|
+
if (request.expectedRevision === undefined) {
|
|
1619
|
+
const current = await repository.loadWorkspaces();
|
|
1620
|
+
if (!current.success || current.revision !== undefined) {
|
|
1621
|
+
return { success: false, code: 'WORKSPACE_REVISION_REQUIRED', error: 'Load workspace state before saving. This host requires its revision to prevent overwriting another window.' };
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
const privateState = await repository.loadWorkspaces();
|
|
1625
|
+
if (!privateState.success)
|
|
1626
|
+
return { success: false, error: 'Workspace authority is unavailable.' };
|
|
1627
|
+
let workspaces;
|
|
1628
|
+
try {
|
|
1629
|
+
workspaces = preservePrivateLegacyEnvironment(request.workspaces, privateState.workspaces);
|
|
1630
|
+
}
|
|
1631
|
+
catch {
|
|
1632
|
+
return { success: false, error: 'Use protected environment settings to change secrets; workspace metadata was not saved.' };
|
|
1633
|
+
}
|
|
1634
|
+
const result = await repository.saveWorkspaces({ ...request, workspaces });
|
|
1635
|
+
if (result.success)
|
|
1636
|
+
this.publish('state.workspaces.changed', { revision: result.revision });
|
|
1637
|
+
return result;
|
|
1466
1638
|
}
|
|
1467
1639
|
if (method === 'state.conversations.load') {
|
|
1468
1640
|
return await this.requireStateRepository().loadConversations();
|
|
@@ -1504,6 +1676,11 @@ export class AgentHostCoordinator {
|
|
|
1504
1676
|
if (method === 'coordination.action') {
|
|
1505
1677
|
const request = input;
|
|
1506
1678
|
this.assertConnectedClient(request.command.client, 'changing development coordination state');
|
|
1679
|
+
const stopping = request.action === 'ownership.release' || request.action === 'goal.cancel'
|
|
1680
|
+
|| (request.action === 'loop.set_status' && ['paused', 'stopped'].includes(String(request.payload?.status)));
|
|
1681
|
+
if (!stopping)
|
|
1682
|
+
await this.executionScope(request.sessionId, {});
|
|
1683
|
+
const admissionReceipt = stopping ? null : await this.beginScopeAdmission({ id: this.commandKey('coordination.action', request.command), hostInstanceId: this.options.hostInstanceId, conversationId: request.sessionId, requestId: request.command.commandId, kind: 'coordination', scope: {} });
|
|
1507
1684
|
const clientId = request.command.client.instanceId;
|
|
1508
1685
|
const leaseKey = `${clientId}\u0000${request.sessionId}`;
|
|
1509
1686
|
const ownerId = `interface:${clientId}`;
|
|
@@ -1583,6 +1760,8 @@ export class AgentHostCoordinator {
|
|
|
1583
1760
|
const event = state.events.at(-1);
|
|
1584
1761
|
if (event)
|
|
1585
1762
|
this.publish('coordination.event', safeDevelopmentCoordinationEvent(event));
|
|
1763
|
+
if (admissionReceipt)
|
|
1764
|
+
await this.stateRepository.settleWorkspaceAdmission(admissionReceipt.id, admissionReceipt.hostInstanceId);
|
|
1586
1765
|
return {
|
|
1587
1766
|
schemaVersion: 1,
|
|
1588
1767
|
sessionId: request.sessionId,
|
|
@@ -1607,14 +1786,17 @@ export class AgentHostCoordinator {
|
|
|
1607
1786
|
}
|
|
1608
1787
|
if (method === 'workspace.file.write') {
|
|
1609
1788
|
this.assertWorkspaceClient(input);
|
|
1789
|
+
await this.executionScope(input.conversationId || '', input);
|
|
1610
1790
|
return await this.requireWorkspaceService().writeFile(input);
|
|
1611
1791
|
}
|
|
1612
1792
|
if (method === 'workspace.command.run') {
|
|
1613
1793
|
this.assertWorkspaceClient(input);
|
|
1794
|
+
await this.executionScope(input.conversationId || '', input);
|
|
1614
1795
|
return await this.requireWorkspaceService().runCommand(input);
|
|
1615
1796
|
}
|
|
1616
1797
|
if (method === 'workspace.terminal.start') {
|
|
1617
1798
|
this.assertWorkspaceClient(input);
|
|
1799
|
+
await this.executionScope(input.conversationId || '', input);
|
|
1618
1800
|
return await this.requireWorkspaceService().startTerminal(input);
|
|
1619
1801
|
}
|
|
1620
1802
|
if (method === 'workspace.terminal.stop') {
|
|
@@ -1623,6 +1805,7 @@ export class AgentHostCoordinator {
|
|
|
1623
1805
|
}
|
|
1624
1806
|
if (method === 'workspace.pty.start') {
|
|
1625
1807
|
this.assertWorkspaceClient(input);
|
|
1808
|
+
await this.executionScope(input.conversationId || '', input);
|
|
1626
1809
|
return await this.requireWorkspaceService().startPty(input);
|
|
1627
1810
|
}
|
|
1628
1811
|
if (method === 'workspace.pty.snapshot') {
|
|
@@ -1658,6 +1841,12 @@ export class AgentHostCoordinator {
|
|
|
1658
1841
|
if (method === 'xeno.tui.attach') {
|
|
1659
1842
|
const request = input;
|
|
1660
1843
|
this.assertConnectedClient(request.command.client, 'attaching the XENO Agent TUI');
|
|
1844
|
+
try {
|
|
1845
|
+
await this.executionScope(request.conversationId, {});
|
|
1846
|
+
}
|
|
1847
|
+
catch (error) {
|
|
1848
|
+
return { success: false, code: 'WORKSPACE_EPOCH_CONFLICT', error: error instanceof Error ? error.message : 'Workspace execution is unavailable.' };
|
|
1849
|
+
}
|
|
1661
1850
|
if ([...this.activeTurns.values()].some((active) => active.request.conversationId === request.conversationId)) {
|
|
1662
1851
|
return {
|
|
1663
1852
|
success: false,
|
|
@@ -1770,8 +1959,20 @@ export class AgentHostCoordinator {
|
|
|
1770
1959
|
return await this.requireProviderLaneService().selectLane(request);
|
|
1771
1960
|
}
|
|
1772
1961
|
if (method === 'provider.native.attach') {
|
|
1773
|
-
|
|
1962
|
+
let request = input;
|
|
1774
1963
|
this.assertConnectedClient(request.command.client, 'attaching a native provider TUI');
|
|
1964
|
+
try {
|
|
1965
|
+
const scope = await this.executionScope(request.conversationId, {});
|
|
1966
|
+
const execution = await this.executionCapabilities(scope);
|
|
1967
|
+
if (await this.options.rulesService?.resolveForScope(scope))
|
|
1968
|
+
throw new Error('This native provider has no supported XENO rules override channel. Reset the override or use an SDK-owned runtime; provider-native instruction files remain separate.');
|
|
1969
|
+
if (execution?.capabilities?.fileWrite === false)
|
|
1970
|
+
request = { ...request, executionPolicy: 'read-only' };
|
|
1971
|
+
assertNativeToolCategoryAdmission(execution, request.executionPolicy === 'read-only');
|
|
1972
|
+
}
|
|
1973
|
+
catch (error) {
|
|
1974
|
+
return { success: false, code: 'WORKSPACE_EPOCH_CONFLICT', error: error instanceof Error ? error.message : 'Workspace execution is unavailable.' };
|
|
1975
|
+
}
|
|
1775
1976
|
if ([...this.activeTurns.values()].some((active) => active.request.conversationId === request.conversationId)) {
|
|
1776
1977
|
return {
|
|
1777
1978
|
success: false,
|
|
@@ -1835,13 +2036,13 @@ export class AgentHostCoordinator {
|
|
|
1835
2036
|
return this.readRunObservationOverlaps(input);
|
|
1836
2037
|
}
|
|
1837
2038
|
if (method === 'subagent.run.create') {
|
|
1838
|
-
return this.createSubagentRun(input);
|
|
2039
|
+
return await this.createSubagentRun(input);
|
|
1839
2040
|
}
|
|
1840
2041
|
if (method === 'subagent.run.list') {
|
|
1841
2042
|
return this.listSubagentRuns(input);
|
|
1842
2043
|
}
|
|
1843
2044
|
if (method === 'subagent.run.cancel') {
|
|
1844
|
-
return this.cancelSubagentRun(input);
|
|
2045
|
+
return await this.cancelSubagentRun(input);
|
|
1845
2046
|
}
|
|
1846
2047
|
if (method === 'subagent.scheduler.status') {
|
|
1847
2048
|
return this.readSubagentSchedulerStatus();
|
|
@@ -1888,6 +2089,12 @@ export class AgentHostCoordinator {
|
|
|
1888
2089
|
if (method === 'acp.agents.remove') {
|
|
1889
2090
|
return this.removeAcpAgent(input);
|
|
1890
2091
|
}
|
|
2092
|
+
if (method === 'acp.capabilitySnapshot.get') {
|
|
2093
|
+
return await this.getAcpCapabilitySnapshot(input);
|
|
2094
|
+
}
|
|
2095
|
+
if (method === 'acp.command.invoke') {
|
|
2096
|
+
return await this.invokeAcpCommand(input);
|
|
2097
|
+
}
|
|
1891
2098
|
if (method === 'session.setMode') {
|
|
1892
2099
|
return this.setSessionMode(input);
|
|
1893
2100
|
}
|
|
@@ -2007,6 +2214,10 @@ export class AgentHostCoordinator {
|
|
|
2007
2214
|
releaseClient(instanceId) {
|
|
2008
2215
|
this.connectedClients.delete(instanceId);
|
|
2009
2216
|
this.clientCapabilities.delete(instanceId);
|
|
2217
|
+
// Connection revocation must not wait for a slow OS child. The Browser
|
|
2218
|
+
// owner retains failed cleanup and its durable lifecycle admission; close()
|
|
2219
|
+
// retries it and cannot declare shutdown while it is unresolved.
|
|
2220
|
+
void this.options.browserSessionOwner?.quiesceClient?.(instanceId).catch(() => { });
|
|
2010
2221
|
for (const [key, lease] of this.developmentCoordinationLeases) {
|
|
2011
2222
|
if (!key.startsWith(`${instanceId}\u0000`))
|
|
2012
2223
|
continue;
|
|
@@ -2014,6 +2225,11 @@ export class AgentHostCoordinator {
|
|
|
2014
2225
|
void lease.stop();
|
|
2015
2226
|
}
|
|
2016
2227
|
}
|
|
2228
|
+
/** Trusted composition services share the live handshake registry; they must
|
|
2229
|
+
* not maintain a second, stale list of authorized Browser documents. */
|
|
2230
|
+
assertClientIdentity(identity) {
|
|
2231
|
+
this.assertConnectedClient(identity, 'using host-owned services');
|
|
2232
|
+
}
|
|
2017
2233
|
/**
|
|
2018
2234
|
* Is there a connected client that can put a question to a person and answer it?
|
|
2019
2235
|
*
|
|
@@ -2043,16 +2259,40 @@ export class AgentHostCoordinator {
|
|
|
2043
2259
|
}
|
|
2044
2260
|
this.turnExecutionAdapters.set(adapter.id, adapter);
|
|
2045
2261
|
}
|
|
2046
|
-
|
|
2262
|
+
close() {
|
|
2263
|
+
if (this.closeFlight)
|
|
2264
|
+
return this.closeFlight;
|
|
2265
|
+
this.closing = true;
|
|
2266
|
+
this.subagentRuns?.stop?.();
|
|
2267
|
+
for (const active of this.activeTurns.values())
|
|
2268
|
+
active.controller.abort('The XENO Agent host is shutting down.');
|
|
2269
|
+
this.closeFlight = this.closeOwnedResources().catch(error => { this.closeFlight = undefined; throw error; });
|
|
2270
|
+
return this.closeFlight;
|
|
2271
|
+
}
|
|
2272
|
+
async closeOwnedResources() {
|
|
2273
|
+
// In-flight admission can own durable intent before an active turn exists.
|
|
2274
|
+
// Do not close its repository while it is still committing/refusing that intent.
|
|
2275
|
+
await Promise.allSettled([...this.pendingTurnStarts]);
|
|
2276
|
+
for (const active of this.activeTurns.values())
|
|
2277
|
+
active.controller.abort('The XENO Agent host is shutting down.');
|
|
2278
|
+
await this.options.inferenceService?.close();
|
|
2279
|
+
await this.options.notificationService?.close();
|
|
2280
|
+
await this.options.workforceService?.close();
|
|
2281
|
+
await this.options.accountService?.close();
|
|
2282
|
+
await this.options.browserSessionOwner?.close();
|
|
2283
|
+
await this.backupService?.close();
|
|
2047
2284
|
for (const active of this.activeTurns.values()) {
|
|
2048
2285
|
active.controller.abort('The XENO Agent host is shutting down.');
|
|
2049
2286
|
}
|
|
2050
|
-
this.activeTurns.clear();
|
|
2051
2287
|
await Promise.all([...this.developmentCoordinationLeases.values()].map((lease) => lease.stop()));
|
|
2052
2288
|
this.developmentCoordinationLeases.clear();
|
|
2053
2289
|
await Promise.all([...this.turnExecutionAdapters.values()].map(async (adapter) => {
|
|
2054
2290
|
await adapter.close?.();
|
|
2055
2291
|
}));
|
|
2292
|
+
// Adapter close alone does not finish the host's final journal/lane writes.
|
|
2293
|
+
// A rejected cleanup remains retained, so shutdown cannot claim a clean exit.
|
|
2294
|
+
await Promise.all([...this.turnCompletions]);
|
|
2295
|
+
this.activeTurns.clear();
|
|
2056
2296
|
await this.sdkControlService?.close?.();
|
|
2057
2297
|
await this.engineeringControlService?.close?.();
|
|
2058
2298
|
await this.providerLaneService?.close?.();
|
|
@@ -2138,7 +2378,7 @@ export class AgentHostCoordinator {
|
|
|
2138
2378
|
* with no scheduler is a normal composition (the standalone app had none until this landed),
|
|
2139
2379
|
* and a create that silently succeeded against nothing would queue work no one will ever run.
|
|
2140
2380
|
*/
|
|
2141
|
-
createSubagentRun(input) {
|
|
2381
|
+
async createSubagentRun(input) {
|
|
2142
2382
|
if (!this.isConnectedClient(input.command.client)) {
|
|
2143
2383
|
return { success: false, safeError: 'The requesting surface must complete the host handshake first.' };
|
|
2144
2384
|
}
|
|
@@ -2225,7 +2465,16 @@ export class AgentHostCoordinator {
|
|
|
2225
2465
|
allowFurtherDelegation: input.policy?.allowFurtherDelegation !== false,
|
|
2226
2466
|
cancellationPropagation: input.policy?.cancellationPropagation !== false,
|
|
2227
2467
|
};
|
|
2468
|
+
let admissionReceipt;
|
|
2469
|
+
try {
|
|
2470
|
+
await this.executionScope(input.parentConversationId, { workspaceId: input.workspaceId, teamId: input.teamId, agentId: input.parentAgentId });
|
|
2471
|
+
admissionReceipt = await this.beginScopeAdmission({ id: commandKey, hostInstanceId: this.options.hostInstanceId, conversationId: input.childConversationId, requestId: input.command.commandId, kind: 'subagent', scope: { workspaceId: input.workspaceId, teamId: input.teamId, agentId: input.childAgentId } });
|
|
2472
|
+
}
|
|
2473
|
+
catch (error) {
|
|
2474
|
+
return { success: false, safeError: error instanceof Error ? error.message : 'Subagent scope admission failed.' };
|
|
2475
|
+
}
|
|
2228
2476
|
const created = this.subagentRuns.createRun({
|
|
2477
|
+
...(admissionReceipt ? { admissionReceiptId: admissionReceipt.id } : {}),
|
|
2229
2478
|
...(bound.workspace === undefined ? {} : { workspace: bound.workspace }),
|
|
2230
2479
|
parentConversationId: input.parentConversationId,
|
|
2231
2480
|
...(input.parentRequestId === undefined ? {} : { parentRequestId: input.parentRequestId }),
|
|
@@ -2267,6 +2516,8 @@ export class AgentHostCoordinator {
|
|
|
2267
2516
|
depth,
|
|
2268
2517
|
},
|
|
2269
2518
|
});
|
|
2519
|
+
if (admissionReceipt)
|
|
2520
|
+
await this.stateRepository.settleWorkspaceAdmission(admissionReceipt.id, admissionReceipt.hostInstanceId);
|
|
2270
2521
|
const result = created.success && created.run
|
|
2271
2522
|
? {
|
|
2272
2523
|
success: true,
|
|
@@ -2329,20 +2580,32 @@ export class AgentHostCoordinator {
|
|
|
2329
2580
|
? { success: true, runs: listed.runs.map(summariseSubagentRun) }
|
|
2330
2581
|
: { success: false, runs: [], safeError: listed.error ?? 'Subagent runs could not be listed.' };
|
|
2331
2582
|
}
|
|
2332
|
-
cancelSubagentRun(input) {
|
|
2583
|
+
async cancelSubagentRun(input) {
|
|
2333
2584
|
if (!this.isConnectedClient(input.command.client)) {
|
|
2334
2585
|
return { success: false, safeError: 'The requesting surface must complete the host handshake first.' };
|
|
2335
2586
|
}
|
|
2336
2587
|
if (!this.subagentRuns) {
|
|
2337
2588
|
return { success: false, safeError: 'This Agent host has no subagent scheduler mounted.' };
|
|
2338
2589
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2590
|
+
if (!this.subagentRuns.cancelRunAndWait) {
|
|
2591
|
+
return { success: false, safeError: 'Child execution settlement confirmation is unavailable; cancellation was not confirmed.' };
|
|
2592
|
+
}
|
|
2593
|
+
try {
|
|
2594
|
+
const cancelled = await this.subagentRuns.cancelRunAndWait({
|
|
2595
|
+
id: input.runId,
|
|
2596
|
+
...(input.reason === undefined ? {} : { reason: input.reason }),
|
|
2597
|
+
requestedFrom: 'user',
|
|
2598
|
+
propagateToChild: true,
|
|
2599
|
+
});
|
|
2600
|
+
return {
|
|
2601
|
+
success: cancelled.success,
|
|
2602
|
+
...(cancelled.run ? { run: summariseSubagentRun(cancelled.run) } : {}),
|
|
2603
|
+
...(!cancelled.success ? { safeError: cancelled.error ?? 'Cancellation requested; child execution is not confirmed stopped.' } : {}),
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
catch {
|
|
2607
|
+
return { success: false, safeError: 'Cancellation settlement failed; child execution is not confirmed stopped. Refresh and retry.' };
|
|
2608
|
+
}
|
|
2346
2609
|
}
|
|
2347
2610
|
readSubagentSchedulerStatus() {
|
|
2348
2611
|
if (!this.subagentRuns) {
|
|
@@ -2464,7 +2727,85 @@ export class AgentHostCoordinator {
|
|
|
2464
2727
|
timer.unref?.();
|
|
2465
2728
|
this.trackTurnTimer(activeKey, timer);
|
|
2466
2729
|
}
|
|
2467
|
-
async
|
|
2730
|
+
async executionScope(conversationId, requested) {
|
|
2731
|
+
// Minimal embedders may omit entity storage entirely. The composed desktop/Hub
|
|
2732
|
+
// authority always supplies it; a failed read there must never become "global".
|
|
2733
|
+
if (!this.stateRepository)
|
|
2734
|
+
return requested;
|
|
2735
|
+
const state = await this.stateRepository.loadWorkspaces();
|
|
2736
|
+
if (!state.success)
|
|
2737
|
+
throw new Error('Workspace state could not be verified before execution.');
|
|
2738
|
+
if (!conversationId.trim()) {
|
|
2739
|
+
// Settings actions have an entity scope, not a fabricated conversation.
|
|
2740
|
+
// Require explicit ancestry and validate it against the same persisted
|
|
2741
|
+
// lifecycle authority; a directory grant cannot invent workspace identity.
|
|
2742
|
+
if (!requested.workspaceId?.trim() || (requested.agentId && !requested.teamId?.trim())) {
|
|
2743
|
+
throw new Error('Execution without a conversation requires an explicit workspace and complete entity scope.');
|
|
2744
|
+
}
|
|
2745
|
+
return resolveWorkspaceExecutionScope(state.workspaces, requested);
|
|
2746
|
+
}
|
|
2747
|
+
let conversation;
|
|
2748
|
+
if (this.stateRepository.loadConversationForHost) {
|
|
2749
|
+
conversation = this.stateRepository.loadConversationForHost(conversationId);
|
|
2750
|
+
}
|
|
2751
|
+
else {
|
|
2752
|
+
const loaded = await this.stateRepository.loadConversations();
|
|
2753
|
+
if (!loaded.success)
|
|
2754
|
+
throw new Error('Conversation scope could not be verified before execution.');
|
|
2755
|
+
conversation = loaded.conversations.find((value) => isRecord(value) && value.id === conversationId);
|
|
2756
|
+
}
|
|
2757
|
+
return resolveWorkspaceExecutionScope(state.workspaces, requested, conversation);
|
|
2758
|
+
}
|
|
2759
|
+
async beginScopeAdmission(input) {
|
|
2760
|
+
if (!this.stateRepository)
|
|
2761
|
+
return null;
|
|
2762
|
+
if (this.stateRepository.beginWorkspaceAdmission && this.stateRepository.readyWorkspaceAdmission && this.stateRepository.settleWorkspaceAdmission) {
|
|
2763
|
+
const receipt = await this.stateRepository.beginWorkspaceAdmission(input);
|
|
2764
|
+
if (!receipt)
|
|
2765
|
+
return null;
|
|
2766
|
+
try {
|
|
2767
|
+
if (input.kind === 'turn' && input.adapterId && !this.stateRepository.markWorkspaceTurnExecution)
|
|
2768
|
+
throw new Error('Durable workspace execution outcome support is required');
|
|
2769
|
+
const coordination = await loadDevelopmentCoordinationModule();
|
|
2770
|
+
const store = this.developmentCoordinationStore ??= new coordination.DurableXenoCoordinationStore();
|
|
2771
|
+
await restoreWorkspaceCoordination(store, input.conversationId, `workspace:${receipt.scope.workspaceId}`);
|
|
2772
|
+
// An archive may have raced with the cross-store restoration above. No
|
|
2773
|
+
// provider/run admission has happened yet, so rejection can settle this intent.
|
|
2774
|
+
await this.executionScope(input.conversationId, receipt.scope);
|
|
2775
|
+
await this.stateRepository.readyWorkspaceAdmission(receipt.id, receipt.hostInstanceId);
|
|
2776
|
+
receipt.phase = 'ready';
|
|
2777
|
+
return receipt;
|
|
2778
|
+
}
|
|
2779
|
+
catch (error) {
|
|
2780
|
+
if (receipt.execution && this.stateRepository.markWorkspaceTurnExecution)
|
|
2781
|
+
await this.stateRepository.markWorkspaceTurnExecution(receipt.id, receipt.hostInstanceId, 'settled');
|
|
2782
|
+
await this.stateRepository.settleWorkspaceAdmission(receipt.id, receipt.hostInstanceId);
|
|
2783
|
+
throw error;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
const scope = await this.executionScope(input.conversationId, input.scope);
|
|
2787
|
+
if (scope.workspaceId)
|
|
2788
|
+
throw new Error('This host cannot safely admit workspace execution; durable admission support is required.');
|
|
2789
|
+
return null;
|
|
2790
|
+
}
|
|
2791
|
+
async executionCapabilities(scope, requested) {
|
|
2792
|
+
if (!this.stateRepository)
|
|
2793
|
+
return requested;
|
|
2794
|
+
const state = await this.stateRepository.loadWorkspaces();
|
|
2795
|
+
if (!state.success)
|
|
2796
|
+
throw new Error('Persisted agent tool restrictions could not be verified.');
|
|
2797
|
+
const capabilities = resolvePersistedToolCapabilities(state.workspaces, scope, requested?.capabilities);
|
|
2798
|
+
return capabilities ? { ...requested, capabilities } : requested;
|
|
2799
|
+
}
|
|
2800
|
+
startTurn(input) {
|
|
2801
|
+
if (this.closing)
|
|
2802
|
+
return Promise.resolve(turnStartFailure('invalid_request', 'The Agent host is shutting down; no turn was started.', input));
|
|
2803
|
+
const pending = this.admitTurn(input);
|
|
2804
|
+
this.pendingTurnStarts.add(pending);
|
|
2805
|
+
void pending.then(() => this.pendingTurnStarts.delete(pending), () => this.pendingTurnStarts.delete(pending));
|
|
2806
|
+
return pending;
|
|
2807
|
+
}
|
|
2808
|
+
async admitTurn(input) {
|
|
2468
2809
|
let invalidReason = validateTurnStartRequest(input);
|
|
2469
2810
|
if (invalidReason) {
|
|
2470
2811
|
return turnStartFailure('invalid_request', invalidReason, input);
|
|
@@ -2485,6 +2826,8 @@ export class AgentHostCoordinator {
|
|
|
2485
2826
|
if (invalidReason)
|
|
2486
2827
|
return turnStartFailure('invalid_request', invalidReason, input);
|
|
2487
2828
|
}
|
|
2829
|
+
if (this.closing)
|
|
2830
|
+
return turnStartFailure('invalid_request', 'The Agent host stopped during turn preparation; no adapter was started.', input);
|
|
2488
2831
|
const commandKey = this.commandKey('turn.start', input.command);
|
|
2489
2832
|
const fingerprint = commandFingerprint(input);
|
|
2490
2833
|
const prior = this.commandResults.get(commandKey);
|
|
@@ -2560,6 +2903,26 @@ export class AgentHostCoordinator {
|
|
|
2560
2903
|
// It READS `activeTurns` rather than keeping its own count. That map's cleanup runs in a
|
|
2561
2904
|
// `finally` and is guarded against evicting a newer turn, so deriving the decision from it
|
|
2562
2905
|
// makes a leaked slot unrepresentable — there is no second ledger to drift out of sync.
|
|
2906
|
+
try {
|
|
2907
|
+
const scope = await this.executionScope(input.conversationId, input);
|
|
2908
|
+
const execution = await this.executionCapabilities(scope, input.execution);
|
|
2909
|
+
input = { ...input, ...scope, ...(execution ? { execution } : {}) };
|
|
2910
|
+
if (execution?.capabilities?.fileWrite === false && input.workspace)
|
|
2911
|
+
input.workspace = { ...input.workspace, filesystem: 'read-only' };
|
|
2912
|
+
assertToolCategoryAdmission(input, provider);
|
|
2913
|
+
}
|
|
2914
|
+
catch (error) {
|
|
2915
|
+
// Not cached: unarchiving or repairing scope must allow an explicit retry.
|
|
2916
|
+
return turnStartFailure('invalid_request', error instanceof Error ? error.message : 'Workspace execution is unavailable.', input);
|
|
2917
|
+
}
|
|
2918
|
+
try {
|
|
2919
|
+
const rules = await this.options.rulesService?.resolveForScope(input);
|
|
2920
|
+
if (rules && !adapter.supportsWorkspaceRules)
|
|
2921
|
+
return turnStartFailure('adapter_unavailable', 'This runtime has no supported workspace rules override channel. Reset the override or choose a supported runtime; rules are never sent as chat text.', input);
|
|
2922
|
+
}
|
|
2923
|
+
catch {
|
|
2924
|
+
return turnStartFailure('invalid_request', 'The configured workspace rules file is unavailable or no longer authorized. Repair it or reset the override.', input);
|
|
2925
|
+
}
|
|
2563
2926
|
const admission = evaluateTurnAdmission({
|
|
2564
2927
|
surface: input.command.client.surface,
|
|
2565
2928
|
providerId: input.selection.providerId,
|
|
@@ -2580,17 +2943,44 @@ export class AgentHostCoordinator {
|
|
|
2580
2943
|
// is nothing to deduplicate — re-evaluating on retry is the correct behaviour.
|
|
2581
2944
|
return turnStartFailure('concurrency_limit_reached', admission.safeError, input);
|
|
2582
2945
|
}
|
|
2946
|
+
let admissionReceipt;
|
|
2947
|
+
try {
|
|
2948
|
+
admissionReceipt = await this.beginScopeAdmission({ id: commandKey, hostInstanceId: this.options.hostInstanceId, conversationId: input.conversationId, requestId: input.requestId, kind: 'turn', scope: input, adapterId: adapter.id });
|
|
2949
|
+
}
|
|
2950
|
+
catch (error) {
|
|
2951
|
+
return turnStartFailure('invalid_request', error instanceof Error ? error.message : 'Workspace execution admission failed.', input);
|
|
2952
|
+
}
|
|
2583
2953
|
const request = structuredClone(input);
|
|
2584
2954
|
if (this.providerLaneService?.beginStructuredTurn) {
|
|
2585
2955
|
try {
|
|
2586
2956
|
await this.providerLaneService.beginStructuredTurn(request);
|
|
2587
2957
|
}
|
|
2588
2958
|
catch (error) {
|
|
2959
|
+
// This host observed the lane rejection before invoking any execution
|
|
2960
|
+
// adapter. A partial lane record is still enumerated by lifecycle; there
|
|
2961
|
+
// is no unknown turn launch to keep this admission intent pending.
|
|
2962
|
+
if (admissionReceipt) {
|
|
2963
|
+
await this.stateRepository.markWorkspaceTurnExecution(admissionReceipt.id, admissionReceipt.hostInstanceId, 'settled');
|
|
2964
|
+
await this.stateRepository.settleWorkspaceAdmission(admissionReceipt.id, admissionReceipt.hostInstanceId);
|
|
2965
|
+
}
|
|
2589
2966
|
return this.rememberTurnStartFailure(commandKey, fingerprint, turnStartFailure('request_already_active', error instanceof Error && error.message.trim()
|
|
2590
2967
|
? error.message.slice(0, 1_000)
|
|
2591
2968
|
: 'The provider lane writer could not be acquired.', request));
|
|
2592
2969
|
}
|
|
2593
2970
|
}
|
|
2971
|
+
// A failed journal write must refuse before active registration or adapter
|
|
2972
|
+
// invocation, not leave an in-memory running turn with no durable evidence.
|
|
2973
|
+
try {
|
|
2974
|
+
this.interruptedTurnStore.record({ conversationId: request.conversationId, requestId: request.requestId, adapterId: adapter.id, startedAt: Date.now(), request });
|
|
2975
|
+
}
|
|
2976
|
+
catch {
|
|
2977
|
+
if (admissionReceipt) {
|
|
2978
|
+
await this.stateRepository.markWorkspaceTurnExecution(admissionReceipt.id, admissionReceipt.hostInstanceId, 'settled');
|
|
2979
|
+
await this.stateRepository.settleWorkspaceAdmission(admissionReceipt.id, admissionReceipt.hostInstanceId);
|
|
2980
|
+
}
|
|
2981
|
+
await this.providerLaneService?.finishStructuredTurn?.(request.conversationId, request.requestId);
|
|
2982
|
+
return turnStartFailure('invalid_request', 'The interrupted-turn journal could not persist this execution intent; no adapter was started.', input);
|
|
2983
|
+
}
|
|
2594
2984
|
// Recorded BEFORE execution, so a coordination event arriving in the first
|
|
2595
2985
|
// moments of a turn still finds its conversation.
|
|
2596
2986
|
const contextRunId = this.resolveRunId(request);
|
|
@@ -2614,12 +3004,12 @@ export class AgentHostCoordinator {
|
|
|
2614
3004
|
// whatever the child asks for.
|
|
2615
3005
|
...(request.workspace === undefined ? {} : { workspace: structuredClone(request.workspace) }),
|
|
2616
3006
|
});
|
|
2617
|
-
//
|
|
2618
|
-
//
|
|
2619
|
-
//
|
|
2620
|
-
//
|
|
3007
|
+
// Awaited before adapter dispatch so the immutable Git baseline cannot
|
|
3008
|
+
// race the agent's first write. Implementations must perform expensive
|
|
3009
|
+
// process/filesystem work asynchronously; a binder refusal only disables
|
|
3010
|
+
// review/landing and must never disable the user's actual turn.
|
|
2621
3011
|
try {
|
|
2622
|
-
this.runObservationBinder?.begin({
|
|
3012
|
+
await this.runObservationBinder?.begin({
|
|
2623
3013
|
runId: contextRunId,
|
|
2624
3014
|
conversationId: request.conversationId,
|
|
2625
3015
|
...(request.workspace?.primaryDirectory === undefined
|
|
@@ -2637,7 +3027,19 @@ export class AgentHostCoordinator {
|
|
|
2637
3027
|
this.registerCoordinationRun(contextRunId, 'running');
|
|
2638
3028
|
}
|
|
2639
3029
|
const controller = new AbortController();
|
|
2640
|
-
|
|
3030
|
+
const activeExecution = { adapter, controller, request, settled: false, durableAcknowledged: false, promiseFinished: false };
|
|
3031
|
+
let adapterInvoked = false;
|
|
3032
|
+
let adapterResolved = false;
|
|
3033
|
+
this.executionSettlements.set(turnKey(request.conversationId, request.requestId), activeExecution);
|
|
3034
|
+
if (this.executionSettlements.size > 2048) {
|
|
3035
|
+
for (const [key, value] of this.executionSettlements) {
|
|
3036
|
+
if (this.executionSettlements.size <= 2048)
|
|
3037
|
+
break;
|
|
3038
|
+
if (value.settled && value.durableAcknowledged)
|
|
3039
|
+
this.executionSettlements.delete(key);
|
|
3040
|
+
}
|
|
3041
|
+
}
|
|
3042
|
+
this.activeTurns.set(activeKey, activeExecution);
|
|
2641
3043
|
this.conversationAdapters.set(request.conversationId, adapter);
|
|
2642
3044
|
// 🔴 The host ENFORCES the deadline it already validates. `timeoutMs` was checked on the way
|
|
2643
3045
|
// in (1..3_600_000) and forwarded to the adapter, but nothing here ever acted on it: the
|
|
@@ -2651,15 +3053,6 @@ export class AgentHostCoordinator {
|
|
|
2651
3053
|
deadline.unref?.();
|
|
2652
3054
|
this.trackTurnTimer(activeKey, deadline);
|
|
2653
3055
|
}
|
|
2654
|
-
// Written BEFORE execution begins: a record created afterwards would miss
|
|
2655
|
-
// exactly the turns that die early, which are the ones worth reporting.
|
|
2656
|
-
this.interruptedTurnStore.record({
|
|
2657
|
-
conversationId: request.conversationId,
|
|
2658
|
-
requestId: request.requestId,
|
|
2659
|
-
adapterId: adapter.id,
|
|
2660
|
-
startedAt: Date.now(),
|
|
2661
|
-
request,
|
|
2662
|
-
});
|
|
2663
3056
|
const accepted = {
|
|
2664
3057
|
success: true,
|
|
2665
3058
|
status: 'accepted',
|
|
@@ -2673,8 +3066,12 @@ export class AgentHostCoordinator {
|
|
|
2673
3066
|
fingerprint,
|
|
2674
3067
|
result: structuredClone(accepted),
|
|
2675
3068
|
});
|
|
2676
|
-
|
|
2677
|
-
.then(() =>
|
|
3069
|
+
const completion = Promise.resolve()
|
|
3070
|
+
.then(() => {
|
|
3071
|
+
if (this.closing || controller.signal.aborted)
|
|
3072
|
+
throw new Error('Host stopped before turn execution.');
|
|
3073
|
+
return this.recordContextCompaction(request, provider, resolved.selection);
|
|
3074
|
+
})
|
|
2678
3075
|
// §5.8's gate lives here. Everything else in that pillar — the store, the
|
|
2679
3076
|
// selection, the cross-provider guarantee — is inert until a fact actually
|
|
2680
3077
|
// reaches a prompt.
|
|
@@ -2683,9 +3080,24 @@ export class AgentHostCoordinator {
|
|
|
2683
3080
|
// it a run could send and no run could ever receive.
|
|
2684
3081
|
.then(() => this.deliverCoordinationMessages(request))
|
|
2685
3082
|
.then(async () => {
|
|
3083
|
+
if (this.closing || controller.signal.aborted)
|
|
3084
|
+
throw new Error('Host stopped before turn execution.');
|
|
2686
3085
|
const hostBinding = await this.providerLaneService?.getHostBinding?.(request.conversationId);
|
|
3086
|
+
const workspaceEnvironment = await this.environmentService?.resolveForTurn(request);
|
|
3087
|
+
const workspaceRules = await this.options.rulesService?.resolveForScope(request);
|
|
3088
|
+
if (workspaceRules && !adapter.supportsWorkspaceRules)
|
|
3089
|
+
throw new Error('This runtime has no supported workspace rules override channel. Reset the override or choose a runtime that supports it; rules were not sent as chat text.');
|
|
3090
|
+
if (workspaceEnvironment && Object.keys(workspaceEnvironment.values).length > 0 && !adapter.supportsWorkspaceEnvironment)
|
|
3091
|
+
throw new Error('This provider cannot safely receive scoped environment values. Use the SDK-native lane until its environment contract is supported.');
|
|
3092
|
+
if (admissionReceipt)
|
|
3093
|
+
await this.stateRepository.markWorkspaceTurnExecution(admissionReceipt.id, admissionReceipt.hostInstanceId, 'launching');
|
|
3094
|
+
if (this.closing || controller.signal.aborted)
|
|
3095
|
+
throw new Error('Host stopped before adapter dispatch.');
|
|
3096
|
+
adapterInvoked = true;
|
|
2687
3097
|
return adapter.execute(request, provider, resolved.selection, {
|
|
2688
3098
|
signal: controller.signal,
|
|
3099
|
+
...(workspaceEnvironment ? { workspaceEnvironment } : {}),
|
|
3100
|
+
...(workspaceRules ? { workspaceRules } : {}),
|
|
2689
3101
|
...(hostBinding ? { hostBinding: structuredClone(hostBinding) } : {}),
|
|
2690
3102
|
publishPersistedRuntimeEvent: (event) => this.publishPersistedRuntimeEvent(event),
|
|
2691
3103
|
commitProviderContinuation: async (continuation) => {
|
|
@@ -2702,6 +3114,7 @@ export class AgentHostCoordinator {
|
|
|
2702
3114
|
});
|
|
2703
3115
|
})
|
|
2704
3116
|
.then(() => {
|
|
3117
|
+
adapterResolved = true;
|
|
2705
3118
|
// The turn ended WELL. Published here rather than inferred by each surface from
|
|
2706
3119
|
// provider-specific runtime event strings — see the note on the event type itself.
|
|
2707
3120
|
//
|
|
@@ -2742,6 +3155,21 @@ export class AgentHostCoordinator {
|
|
|
2742
3155
|
});
|
|
2743
3156
|
})
|
|
2744
3157
|
.finally(async () => {
|
|
3158
|
+
activeExecution.promiseFinished = true;
|
|
3159
|
+
// Rejection can mean cleanup failed while an owned process still runs.
|
|
3160
|
+
// Never turn that failure into a durable stopped receipt by default.
|
|
3161
|
+
const confirmed = !adapterInvoked || (adapter.confirmExecutionSettlement
|
|
3162
|
+
? await this.confirmAdapterSettlement(adapter, request) : adapterResolved);
|
|
3163
|
+
let durableOutcomeRecorded = confirmed;
|
|
3164
|
+
if (admissionReceipt && confirmed) {
|
|
3165
|
+
try {
|
|
3166
|
+
await this.stateRepository.markWorkspaceTurnExecution(admissionReceipt.id, admissionReceipt.hostInstanceId, 'settled');
|
|
3167
|
+
}
|
|
3168
|
+
catch {
|
|
3169
|
+
durableOutcomeRecorded = false;
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
activeExecution.settled = confirmed;
|
|
2745
3173
|
await this.providerLaneService?.finishStructuredTurn?.(request.conversationId, request.requestId);
|
|
2746
3174
|
const active = this.activeTurns.get(activeKey);
|
|
2747
3175
|
if (active?.controller === controller)
|
|
@@ -2752,7 +3180,16 @@ export class AgentHostCoordinator {
|
|
|
2752
3180
|
// Reaching here at all means the turn ended — well or badly. Either way
|
|
2753
3181
|
// it was not interrupted by process death, which is the only thing this
|
|
2754
3182
|
// record exists to describe.
|
|
2755
|
-
|
|
3183
|
+
if (durableOutcomeRecorded) {
|
|
3184
|
+
this.interruptedTurnStore.clear(request.conversationId, request.requestId);
|
|
3185
|
+
// A release failure retains the private owner; a later lifecycle retry may
|
|
3186
|
+
// acknowledge it. Never let a failed durable write discard authority.
|
|
3187
|
+
try {
|
|
3188
|
+
activeExecution.durableAcknowledged = adapter.releaseExecutionAuthority
|
|
3189
|
+
? await adapter.releaseExecutionAuthority({ conversationId: request.conversationId, requestId: request.requestId }) : true;
|
|
3190
|
+
}
|
|
3191
|
+
catch { /* Retain for retry. */ }
|
|
3192
|
+
}
|
|
2756
3193
|
// Gate 8: a delivered message is the receiving run's cause "until its
|
|
2757
3194
|
// turn ends", so this is where that ends. In `finally`, because a turn
|
|
2758
3195
|
// that FAILED still ended — leaving the cause set would attribute the
|
|
@@ -2770,6 +3207,12 @@ export class AgentHostCoordinator {
|
|
|
2770
3207
|
this.registerCoordinationRun(runId, 'idle');
|
|
2771
3208
|
}
|
|
2772
3209
|
});
|
|
3210
|
+
this.turnCompletions.add(completion);
|
|
3211
|
+
// Retain rejected cleanup for explicit reconciliation; never leave a floating
|
|
3212
|
+
// rejection or silently drop the last handle to an uncertain final write.
|
|
3213
|
+
void completion.then(() => this.turnCompletions.delete(completion), () => { });
|
|
3214
|
+
if (admissionReceipt)
|
|
3215
|
+
await this.stateRepository.settleWorkspaceAdmission(admissionReceipt.id, admissionReceipt.hostInstanceId);
|
|
2773
3216
|
return structuredClone(accepted);
|
|
2774
3217
|
}
|
|
2775
3218
|
async recordContextCompaction(request, provider, selection) {
|
|
@@ -2891,6 +3334,204 @@ export class AgentHostCoordinator {
|
|
|
2891
3334
|
this.commandResults.set(commandKey, { method: 'turn.cancel', fingerprint, result: structuredClone(result) });
|
|
2892
3335
|
return result;
|
|
2893
3336
|
}
|
|
3337
|
+
async waitForTurnExecutionSettlement(input) {
|
|
3338
|
+
const execution = this.executionSettlements.get(turnKey(input.conversationId, input.requestId));
|
|
3339
|
+
if (!execution)
|
|
3340
|
+
return { success: false, error: 'Execution settlement is unknown on this host.' };
|
|
3341
|
+
const deadline = Date.now() + Math.min(30000, Math.max(0, input.timeoutMs ?? 5000));
|
|
3342
|
+
while (!execution.settled && Date.now() < deadline) {
|
|
3343
|
+
if (execution.promiseFinished && execution.adapter.confirmExecutionSettlement) {
|
|
3344
|
+
execution.settled = await this.confirmAdapterSettlement(execution.adapter, execution.request, Math.min(1000, Math.max(1, deadline - Date.now())));
|
|
3345
|
+
}
|
|
3346
|
+
if (!execution.settled)
|
|
3347
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
3348
|
+
}
|
|
3349
|
+
return execution.settled ? { success: true } : { success: false, error: 'Execution is still settling after cancellation.' };
|
|
3350
|
+
}
|
|
3351
|
+
async confirmAdapterSettlement(adapter, request, timeoutMs = 1000) {
|
|
3352
|
+
if (!adapter.confirmExecutionSettlement)
|
|
3353
|
+
return false;
|
|
3354
|
+
let timer;
|
|
3355
|
+
try {
|
|
3356
|
+
return await Promise.race([adapter.confirmExecutionSettlement({ conversationId: request.conversationId, requestId: request.requestId }), new Promise(resolve => { timer = setTimeout(() => resolve(false), timeoutMs); })]);
|
|
3357
|
+
}
|
|
3358
|
+
catch {
|
|
3359
|
+
return false;
|
|
3360
|
+
}
|
|
3361
|
+
finally {
|
|
3362
|
+
if (timer)
|
|
3363
|
+
clearTimeout(timer);
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
async quiesceWorkspaceLifecycle(operation, request) {
|
|
3367
|
+
// SQLite has already fenced new admission. Stop owned Browser processes before
|
|
3368
|
+
// waiting on their durable admission ACK; an absent owner never implies exit.
|
|
3369
|
+
await this.options.browserSessionOwner?.quiesceScope(operation.scope);
|
|
3370
|
+
const coordination = await loadDevelopmentCoordinationModule();
|
|
3371
|
+
const coordinationStore = this.developmentCoordinationStore ??= new coordination.DurableXenoCoordinationStore();
|
|
3372
|
+
const ids = new Set(operation.conversationIds);
|
|
3373
|
+
for (const receipt of this.stateRepository?.workspaceAdmissions?.() ?? [])
|
|
3374
|
+
if (admissionInScope(receipt, operation.scope))
|
|
3375
|
+
ids.add(receipt.conversationId);
|
|
3376
|
+
for (const sessionId of ids)
|
|
3377
|
+
await fenceWorkspaceCoordination(coordinationStore, sessionId, { authorityId: `workspace:${operation.scope.workspaceId}`, operationId: operation.id, action: operation.action });
|
|
3378
|
+
// A successful SDK fence held the same lock as every coordination admission:
|
|
3379
|
+
// previous writes completed and future writes are refused. This settles only
|
|
3380
|
+
// admission ordering, not the execution owner, which is checked separately below.
|
|
3381
|
+
for (const receipt of this.stateRepository?.workspaceAdmissions?.() ?? []) {
|
|
3382
|
+
if (!admissionInScope(receipt, operation.scope))
|
|
3383
|
+
continue;
|
|
3384
|
+
// Browser settlement belongs to its process owner, not turn/coordination recovery.
|
|
3385
|
+
if (receipt.kind === 'browser')
|
|
3386
|
+
continue;
|
|
3387
|
+
if (receipt.execution?.phase === 'prepared' && receipt.phase === 'ready') {
|
|
3388
|
+
// The SQLite fence now prevents the same transaction from transitioning
|
|
3389
|
+
// this exact receipt to launching. No adapter invocation was admitted.
|
|
3390
|
+
await this.stateRepository.markWorkspaceTurnExecution(receipt.id, receipt.hostInstanceId, 'settled');
|
|
3391
|
+
if (receipt.state === 'pending')
|
|
3392
|
+
await this.stateRepository.settleWorkspaceAdmission(receipt.id, receipt.hostInstanceId);
|
|
3393
|
+
continue;
|
|
3394
|
+
}
|
|
3395
|
+
if (receipt.state !== 'pending')
|
|
3396
|
+
continue;
|
|
3397
|
+
const knownTurn = receipt.kind === 'turn' && this.executionSettlements.has(turnKey(receipt.conversationId, receipt.requestId));
|
|
3398
|
+
let knownChild = false;
|
|
3399
|
+
if (receipt.kind === 'subagent' && this.subagentRuns?.findAdmissionForLifecycle) {
|
|
3400
|
+
const found = this.subagentRuns.findAdmissionForLifecycle(receipt.id);
|
|
3401
|
+
if (!found.success)
|
|
3402
|
+
throw new Error(found.error || 'Child admission authority could not be read');
|
|
3403
|
+
const run = found.run;
|
|
3404
|
+
if (run) {
|
|
3405
|
+
if (run.childConversationId !== receipt.conversationId || run.workspaceId !== receipt.scope.workspaceId || run.teamId !== receipt.scope.teamId || run.childAgentId !== receipt.scope.agentId)
|
|
3406
|
+
throw new Error('Child admission scope does not match its durable receipt');
|
|
3407
|
+
// Never enumerate the parent here: deleting one child agent must not
|
|
3408
|
+
// cancel its siblings. Its own conversation is already in `ids`.
|
|
3409
|
+
if (!this.subagentRuns.cancelRunAndWait)
|
|
3410
|
+
throw new Error('Child execution settlement confirmation is unavailable');
|
|
3411
|
+
const stopped = await this.subagentRuns.cancelRunAndWait({ id: run.id, reason: 'Workspace admission recovery', requestedFrom: 'user', propagateToChild: true });
|
|
3412
|
+
if (!stopped.success)
|
|
3413
|
+
throw new Error(stopped.error || 'Recovered child execution has not settled');
|
|
3414
|
+
knownChild = true;
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
if ((receipt.kind === 'coordination' && receipt.phase === 'ready') || knownTurn || knownChild)
|
|
3418
|
+
await this.stateRepository?.settleWorkspaceAdmission?.(receipt.id, receipt.hostInstanceId);
|
|
3419
|
+
}
|
|
3420
|
+
// Existing admissions may have crossed into another durable store just before
|
|
3421
|
+
// SQLite fenced this scope. Enumerate execution only after they acknowledge.
|
|
3422
|
+
const admissionDeadline = Date.now() + 5000;
|
|
3423
|
+
while (this.stateRepository?.workspaceAdmissions?.().some(receipt => receipt.state === 'pending' && admissionInScope(receipt, operation.scope))) {
|
|
3424
|
+
if (Date.now() >= admissionDeadline)
|
|
3425
|
+
throw new Error('Workspace admission outcome is not confirmed; lifecycle remains pending');
|
|
3426
|
+
await new Promise(resolve => setTimeout(resolve, 25));
|
|
3427
|
+
}
|
|
3428
|
+
// A previously admitted explicit restore may have cleared the first fence
|
|
3429
|
+
// before acknowledging. Re-fence after all admissions settle, before enumeration.
|
|
3430
|
+
for (const sessionId of ids)
|
|
3431
|
+
await fenceWorkspaceCoordination(coordinationStore, sessionId, { authorityId: `workspace:${operation.scope.workspaceId}`, operationId: operation.id, action: operation.action });
|
|
3432
|
+
const selectedExecutions = [...this.executionSettlements.values()].filter(turn => ids.has(turn.request.conversationId) || (turn.request.workspaceId === operation.scope.workspaceId && (!operation.scope.teamId || turn.request.teamId === operation.scope.teamId) && (!operation.scope.agentId || turn.request.agentId === operation.scope.agentId)));
|
|
3433
|
+
const active = selectedExecutions.filter(turn => !turn.settled);
|
|
3434
|
+
for (const turn of active)
|
|
3435
|
+
ids.add(turn.request.conversationId);
|
|
3436
|
+
for (const turn of active) {
|
|
3437
|
+
this.abortAndAbandon(turnKey(turn.request.conversationId, turn.request.requestId), 'Workspace lifecycle cancellation');
|
|
3438
|
+
if (turn.adapter.cancel)
|
|
3439
|
+
void Promise.resolve(turn.adapter.cancel({ command: request.command, conversationId: turn.request.conversationId, requestId: turn.request.requestId, reason: 'Workspace lifecycle cancellation' })).catch(() => { });
|
|
3440
|
+
}
|
|
3441
|
+
if (this.subagentRuns) {
|
|
3442
|
+
for (const conversationId of ids) {
|
|
3443
|
+
if (!this.subagentRuns.listRunsForLifecycle)
|
|
3444
|
+
throw new Error('Complete child execution enumeration is unavailable; lifecycle remains pending');
|
|
3445
|
+
const children = this.subagentRuns.listRunsForLifecycle(conversationId);
|
|
3446
|
+
if (!children.success)
|
|
3447
|
+
throw new Error(children.error || 'Child execution cancellation could not be enumerated');
|
|
3448
|
+
for (const child of children.runs) {
|
|
3449
|
+
ids.add(child.childConversationId);
|
|
3450
|
+
if (!this.subagentRuns.cancelRunAndWait)
|
|
3451
|
+
throw new Error('Child execution settlement confirmation is unavailable; lifecycle remains pending');
|
|
3452
|
+
const cancelled = await this.subagentRuns.cancelRunAndWait({ id: child.id, reason: 'Workspace lifecycle cancellation', requestedFrom: 'user', propagateToChild: true });
|
|
3453
|
+
if (!cancelled.success)
|
|
3454
|
+
throw new Error(cancelled.error || 'Child execution did not acknowledge cancellation');
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
for (const conversationId of ids) {
|
|
3459
|
+
const lanes = await this.providerLaneService?.listLanes({ client: request.command.client, conversationId, includeHistorical: true });
|
|
3460
|
+
if (lanes && !lanes.success)
|
|
3461
|
+
throw new Error(lanes.error || 'Provider execution could not be enumerated');
|
|
3462
|
+
for (const lane of lanes?.lanes ?? [])
|
|
3463
|
+
if (lane.status === 'active_native') {
|
|
3464
|
+
const stopped = await this.providerLaneService.stopNative({ command: request.command, conversationId, laneId: lane.laneId });
|
|
3465
|
+
if (!stopped.success)
|
|
3466
|
+
throw new Error(stopped.error || 'Native writer is owned elsewhere; lifecycle remains pending');
|
|
3467
|
+
}
|
|
3468
|
+
const terminal = this.workspaceService?.findXenoPty?.(conversationId);
|
|
3469
|
+
if (terminal) {
|
|
3470
|
+
this.workspaceService?.transferPtyOwnership?.(terminal.terminalId, request.command.client.instanceId);
|
|
3471
|
+
const stopped = await this.workspaceService.stopPty({ client: request.command.client, terminalId: terminal.terminalId, allowedDirectories: [] });
|
|
3472
|
+
if (!stopped.success)
|
|
3473
|
+
throw new Error(stopped.error || 'XENO terminal did not stop');
|
|
3474
|
+
}
|
|
3475
|
+
if (this.workspaceService?.stopConversationPtys) {
|
|
3476
|
+
const settled = await this.workspaceService.stopConversationPtys(conversationId);
|
|
3477
|
+
if (!settled.success)
|
|
3478
|
+
throw new Error(settled.error || 'Terminal exit is not confirmed');
|
|
3479
|
+
}
|
|
3480
|
+
else if (terminal || lanes?.lanes?.some(lane => lane.status === 'active_native')) {
|
|
3481
|
+
throw new Error('Terminal exit confirmation is unavailable; lifecycle remains pending');
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
const deadline = Date.now() + 5000;
|
|
3485
|
+
for (const turn of active) {
|
|
3486
|
+
await this.waitForTurnExecutionSettlement({ conversationId: turn.request.conversationId, requestId: turn.request.requestId, timeoutMs: Math.max(0, deadline - Date.now()) });
|
|
3487
|
+
}
|
|
3488
|
+
if (active.some(turn => !turn.settled))
|
|
3489
|
+
throw new Error('Execution has not settled after cancellation; lifecycle remains pending');
|
|
3490
|
+
for (const receipt of this.stateRepository?.workspaceAdmissions?.() ?? []) {
|
|
3491
|
+
if (!admissionInScope(receipt, operation.scope) || !receipt.execution || receipt.execution.phase === 'settled')
|
|
3492
|
+
continue;
|
|
3493
|
+
const retained = this.executionSettlements.get(turnKey(receipt.conversationId, receipt.requestId));
|
|
3494
|
+
if (!retained?.settled || retained.adapter.id !== receipt.execution.adapterId)
|
|
3495
|
+
throw new Error('Provider execution outcome is unknown after restart; lifecycle requires exact adapter settlement');
|
|
3496
|
+
await this.stateRepository.markWorkspaceTurnExecution(receipt.id, receipt.hostInstanceId, 'settled');
|
|
3497
|
+
}
|
|
3498
|
+
for (const interrupted of this.interruptedTurnStore.list()) {
|
|
3499
|
+
const selected = ids.has(interrupted.conversationId) || (interrupted.request.workspaceId === operation.scope.workspaceId && (!operation.scope.teamId || interrupted.request.teamId === operation.scope.teamId) && (!operation.scope.agentId || interrupted.request.agentId === operation.scope.agentId));
|
|
3500
|
+
if (!selected)
|
|
3501
|
+
continue;
|
|
3502
|
+
const retained = this.executionSettlements.get(turnKey(interrupted.conversationId, interrupted.requestId));
|
|
3503
|
+
if (!retained?.settled || retained.adapter.id !== interrupted.adapterId)
|
|
3504
|
+
throw new Error('Interrupted provider execution has no confirmed settlement; lifecycle remains pending');
|
|
3505
|
+
this.interruptedTurnStore.clear(interrupted.conversationId, interrupted.requestId);
|
|
3506
|
+
}
|
|
3507
|
+
for (const turn of selectedExecutions)
|
|
3508
|
+
if (turn.settled && !turn.durableAcknowledged) {
|
|
3509
|
+
turn.durableAcknowledged = turn.adapter.releaseExecutionAuthority
|
|
3510
|
+
? await turn.adapter.releaseExecutionAuthority({ conversationId: turn.request.conversationId, requestId: turn.request.requestId }) : true;
|
|
3511
|
+
}
|
|
3512
|
+
for (const [key, lease] of this.developmentCoordinationLeases) {
|
|
3513
|
+
if ([...ids].some(id => key.endsWith('\u0000' + id))) {
|
|
3514
|
+
await lease.stop();
|
|
3515
|
+
this.developmentCoordinationLeases.delete(key);
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
for (const sessionId of ids) {
|
|
3519
|
+
await fenceWorkspaceCoordination(coordinationStore, sessionId, { authorityId: `workspace:${operation.scope.workspaceId}`, operationId: operation.id, action: operation.action });
|
|
3520
|
+
await settleWorkspaceCoordinationOwner(coordinationStore, sessionId, `workspace:${operation.scope.workspaceId}`);
|
|
3521
|
+
const state = await coordinationStore.getSessionState(sessionId);
|
|
3522
|
+
for (const loop of state.loops)
|
|
3523
|
+
if (['running', 'waiting', 'paused'].includes(loop.status)) {
|
|
3524
|
+
await coordinationStore.setLoopStatus(sessionId, loop.id, loop.version, operation.action === 'delete' ? 'stopped' : 'paused', 'Workspace lifecycle');
|
|
3525
|
+
}
|
|
3526
|
+
for (const goal of state.goals)
|
|
3527
|
+
if (['active', 'waiting', 'blocked', 'paused'].includes(goal.status)) {
|
|
3528
|
+
if (operation.action === 'delete')
|
|
3529
|
+
await coordinationStore.cancelGoal(sessionId, goal.id, goal.version, 'Workspace lifecycle deletion');
|
|
3530
|
+
else
|
|
3531
|
+
await coordinationStore.updateGoal(sessionId, goal.id, goal.version, { status: 'paused' });
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
2894
3535
|
async steerTurn(input) {
|
|
2895
3536
|
if (!this.isConnectedClient(input.command.client)) {
|
|
2896
3537
|
return {
|
|
@@ -3954,6 +4595,7 @@ export * from './session/renderSupport.js';
|
|
|
3954
4595
|
function summariseKnowledge(entry) {
|
|
3955
4596
|
return {
|
|
3956
4597
|
id: entry.id,
|
|
4598
|
+
...(entry.sequence !== undefined ? { sequence: entry.sequence } : {}),
|
|
3957
4599
|
subject: entry.subject,
|
|
3958
4600
|
fact: entry.fact,
|
|
3959
4601
|
...(entry.pinned ? { pinned: true } : {}),
|