@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,809 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { basename, dirname, join, resolve } from 'path';
|
|
5
|
+
import { createScopeAcl, estimateTokens, stableDocumentId } from '../agentSearch/searchUtils.js';
|
|
6
|
+
const DEFAULT_XENO_DIR = join(homedir(), '.xeno');
|
|
7
|
+
const MAX_MEMORY_BYTES = 128_000;
|
|
8
|
+
const MAX_ARTIFACT_CONTENT_BYTES = 10 * 1024 * 1024;
|
|
9
|
+
const DEFAULT_COLUMNS = ['todo', 'in_progress', 'blocked', 'review', 'done'];
|
|
10
|
+
const POLICY_AUDIT_ENV = 'XENO_POLICY_AUDIT_PATH';
|
|
11
|
+
function ensureDir(path) {
|
|
12
|
+
if (!existsSync(path))
|
|
13
|
+
mkdirSync(path, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
function safeReadJson(path, fallback) {
|
|
16
|
+
try {
|
|
17
|
+
if (!existsSync(path))
|
|
18
|
+
return fallback;
|
|
19
|
+
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return fallback;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function safeWriteJson(path, value) {
|
|
26
|
+
ensureDir(dirname(path));
|
|
27
|
+
const tmpPath = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
28
|
+
writeFileSync(tmpPath, JSON.stringify(value, null, 2), 'utf-8');
|
|
29
|
+
renameSync(tmpPath, path);
|
|
30
|
+
}
|
|
31
|
+
function policyAuditPath() {
|
|
32
|
+
return process.env[POLICY_AUDIT_ENV] || join(DEFAULT_XENO_DIR, 'audit', 'policy-decisions.jsonl');
|
|
33
|
+
}
|
|
34
|
+
function shortHash(value) {
|
|
35
|
+
return createHash('sha256').update(value).digest('hex').slice(0, 20);
|
|
36
|
+
}
|
|
37
|
+
function compactScope(scope) {
|
|
38
|
+
if (!scope)
|
|
39
|
+
return undefined;
|
|
40
|
+
const compact = {
|
|
41
|
+
workspaceId: scope.workspaceId,
|
|
42
|
+
teamId: scope.teamId,
|
|
43
|
+
agentId: scope.agentId,
|
|
44
|
+
conversationId: scope.conversationId,
|
|
45
|
+
sdkSessionId: scope.sdkSessionId,
|
|
46
|
+
rootDirectory: scope.rootDirectory ? `[path:${shortHash(resolve(scope.rootDirectory))}]` : undefined,
|
|
47
|
+
};
|
|
48
|
+
return Object.values(compact).some(Boolean) ? compact : undefined;
|
|
49
|
+
}
|
|
50
|
+
function writePolicyAudit(request, decision) {
|
|
51
|
+
try {
|
|
52
|
+
const resource = request.resource || { kind: 'conversation' };
|
|
53
|
+
const path = typeof resource.path === 'string' && resource.path.trim() ? resolve(resource.path) : '';
|
|
54
|
+
const allowedDirectories = request.caller?.allowedDirectories || [];
|
|
55
|
+
const entry = {
|
|
56
|
+
id: `policy_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,
|
|
57
|
+
timestamp: new Date().toISOString(),
|
|
58
|
+
action: request.action,
|
|
59
|
+
resource: {
|
|
60
|
+
kind: resource.kind,
|
|
61
|
+
id: resource.id,
|
|
62
|
+
pathHash: path ? shortHash(path) : undefined,
|
|
63
|
+
pathBasename: path ? basename(path).slice(0, 200) : undefined,
|
|
64
|
+
scope: compactScope(resource.scope),
|
|
65
|
+
aclVisibility: resource.acl?.visibility,
|
|
66
|
+
},
|
|
67
|
+
caller: request.caller
|
|
68
|
+
? {
|
|
69
|
+
userId: request.caller.userId,
|
|
70
|
+
workspaceId: request.caller.workspaceId,
|
|
71
|
+
teamId: request.caller.teamId,
|
|
72
|
+
agentId: request.caller.agentId,
|
|
73
|
+
allowedDirectoryCount: allowedDirectories.length,
|
|
74
|
+
allowedDirectoryHashes: allowedDirectories.map((dir) => shortHash(resolve(dir))).slice(0, 50),
|
|
75
|
+
}
|
|
76
|
+
: undefined,
|
|
77
|
+
decision: {
|
|
78
|
+
allowed: decision.allowed,
|
|
79
|
+
reason: decision.reason,
|
|
80
|
+
matchedVisibility: decision.matchedVisibility,
|
|
81
|
+
matchedScope: compactScope(decision.matchedScope),
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
const targetPath = policyAuditPath();
|
|
85
|
+
ensureDir(dirname(targetPath));
|
|
86
|
+
appendFileSync(targetPath, `${JSON.stringify(entry)}\n`, 'utf-8');
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Policy evaluation must never fail because audit storage is unavailable.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function safeSegment(value) {
|
|
93
|
+
return String(value || 'unknown').replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 160) || 'unknown';
|
|
94
|
+
}
|
|
95
|
+
function cleanString(value, max = 10_000) {
|
|
96
|
+
return typeof value === 'string' ? value.trim().slice(0, max) : '';
|
|
97
|
+
}
|
|
98
|
+
function uniqueStrings(values, maxItems = 50, maxLength = 80) {
|
|
99
|
+
if (!Array.isArray(values))
|
|
100
|
+
return [];
|
|
101
|
+
const out = [];
|
|
102
|
+
const seen = new Set();
|
|
103
|
+
for (const value of values) {
|
|
104
|
+
const item = cleanString(value, maxLength);
|
|
105
|
+
if (!item || seen.has(item))
|
|
106
|
+
continue;
|
|
107
|
+
seen.add(item);
|
|
108
|
+
out.push(item);
|
|
109
|
+
if (out.length >= maxItems)
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
function clampImportance(value) {
|
|
115
|
+
const num = typeof value === 'number' && Number.isFinite(value) ? value : 0.5;
|
|
116
|
+
return Math.max(0, Math.min(1, num));
|
|
117
|
+
}
|
|
118
|
+
function normalizePathForCompare(path) {
|
|
119
|
+
const resolved = resolve(path);
|
|
120
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
121
|
+
}
|
|
122
|
+
function isPathInside(path, parent) {
|
|
123
|
+
const child = normalizePathForCompare(path);
|
|
124
|
+
const root = normalizePathForCompare(parent);
|
|
125
|
+
return child === root || child.startsWith(root.endsWith('\\') || root.endsWith('/') ? root : `${root}${process.platform === 'win32' ? '\\' : '/'}`);
|
|
126
|
+
}
|
|
127
|
+
function scopeFromRequest(input) {
|
|
128
|
+
return {
|
|
129
|
+
workspaceId: cleanString(input.workspaceId, 200) || undefined,
|
|
130
|
+
teamId: cleanString(input.teamId, 200) || undefined,
|
|
131
|
+
agentId: cleanString(input.agentId, 200) || undefined,
|
|
132
|
+
conversationId: cleanString(input.conversationId, 200) || undefined,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function defaultVisibility(scope, fallback = 'private') {
|
|
136
|
+
if (scope.agentId)
|
|
137
|
+
return 'agent';
|
|
138
|
+
if (scope.teamId)
|
|
139
|
+
return 'team';
|
|
140
|
+
if (scope.workspaceId)
|
|
141
|
+
return 'workspace';
|
|
142
|
+
return fallback;
|
|
143
|
+
}
|
|
144
|
+
function defaultAcl(scope, fallback = 'private') {
|
|
145
|
+
return createScopeAcl(scope, defaultVisibility(scope, fallback));
|
|
146
|
+
}
|
|
147
|
+
function aclAllows(caller, scope, acl, action) {
|
|
148
|
+
const effectiveAcl = acl || defaultAcl(scope || {}, 'global');
|
|
149
|
+
const writeLike = action !== 'read';
|
|
150
|
+
const callerAgentId = caller?.agentId;
|
|
151
|
+
const callerTeamId = caller?.teamId;
|
|
152
|
+
const callerWorkspaceId = caller?.workspaceId;
|
|
153
|
+
if (effectiveAcl.visibility !== 'global') {
|
|
154
|
+
if (scope?.workspaceId && callerWorkspaceId !== scope.workspaceId) {
|
|
155
|
+
return {
|
|
156
|
+
allowed: false,
|
|
157
|
+
reason: 'Caller workspace does not match the resource workspace. Switch to the matching workspace/team/agent or request access from the owner before retrying.',
|
|
158
|
+
matchedVisibility: effectiveAcl.visibility,
|
|
159
|
+
matchedScope: scope,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if ((effectiveAcl.visibility === 'team' || effectiveAcl.visibility === 'agent' || effectiveAcl.visibility === 'private') && scope?.teamId && callerTeamId !== scope.teamId) {
|
|
163
|
+
return {
|
|
164
|
+
allowed: false,
|
|
165
|
+
reason: 'Caller team does not match the resource team. Switch to the matching workspace/team/agent or request access from the owner before retrying.',
|
|
166
|
+
matchedVisibility: effectiveAcl.visibility,
|
|
167
|
+
matchedScope: scope,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if ((effectiveAcl.visibility === 'agent' || effectiveAcl.visibility === 'private') && scope?.agentId && callerAgentId !== scope.agentId) {
|
|
171
|
+
return {
|
|
172
|
+
allowed: false,
|
|
173
|
+
reason: 'Caller agent does not match the resource agent. Switch to the matching workspace/team/agent or request access from the owner before retrying.',
|
|
174
|
+
matchedVisibility: effectiveAcl.visibility,
|
|
175
|
+
matchedScope: scope,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const agentAllowed = !!callerAgentId && (effectiveAcl.ownerAgentId === callerAgentId
|
|
180
|
+
|| effectiveAcl.allowedAgentIds?.includes(callerAgentId)
|
|
181
|
+
|| scope?.agentId === callerAgentId);
|
|
182
|
+
const teamAllowed = !!callerTeamId && (effectiveAcl.allowedTeamIds?.includes(callerTeamId)
|
|
183
|
+
|| scope?.teamId === callerTeamId);
|
|
184
|
+
const workspaceAllowed = !!callerWorkspaceId && (effectiveAcl.allowedWorkspaceIds?.includes(callerWorkspaceId)
|
|
185
|
+
|| scope?.workspaceId === callerWorkspaceId);
|
|
186
|
+
if (effectiveAcl.visibility === 'global') {
|
|
187
|
+
if (writeLike && !agentAllowed && !teamAllowed && !workspaceAllowed) {
|
|
188
|
+
return {
|
|
189
|
+
allowed: false,
|
|
190
|
+
reason: 'Global resources require matching workspace, team, or agent scope for mutation. Select the correct workspace/team/agent context before retrying.',
|
|
191
|
+
matchedVisibility: effectiveAcl.visibility,
|
|
192
|
+
matchedScope: scope,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return { allowed: true, reason: 'Global visibility allows access.', matchedVisibility: effectiveAcl.visibility, matchedScope: scope };
|
|
196
|
+
}
|
|
197
|
+
if (effectiveAcl.visibility === 'workspace' && (workspaceAllowed || teamAllowed || agentAllowed)) {
|
|
198
|
+
return { allowed: true, reason: 'Caller is in the resource workspace scope.', matchedVisibility: effectiveAcl.visibility, matchedScope: scope };
|
|
199
|
+
}
|
|
200
|
+
if (effectiveAcl.visibility === 'team' && (teamAllowed || agentAllowed)) {
|
|
201
|
+
return { allowed: true, reason: 'Caller is in the resource team scope.', matchedVisibility: effectiveAcl.visibility, matchedScope: scope };
|
|
202
|
+
}
|
|
203
|
+
if (effectiveAcl.visibility === 'agent' && agentAllowed) {
|
|
204
|
+
return { allowed: true, reason: 'Caller is in the resource agent scope.', matchedVisibility: effectiveAcl.visibility, matchedScope: scope };
|
|
205
|
+
}
|
|
206
|
+
if (effectiveAcl.visibility === 'private' && agentAllowed) {
|
|
207
|
+
return { allowed: true, reason: 'Caller owns the private resource.', matchedVisibility: effectiveAcl.visibility, matchedScope: scope };
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
allowed: false,
|
|
211
|
+
reason: `Caller is outside ${effectiveAcl.visibility} visibility scope. Switch to the matching workspace/team/agent or request access from the owner before retrying.`,
|
|
212
|
+
matchedVisibility: effectiveAcl.visibility,
|
|
213
|
+
matchedScope: scope,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function getScopeTypeDirectory(scopeType) {
|
|
217
|
+
if (scopeType === 'workspace')
|
|
218
|
+
return 'workspace';
|
|
219
|
+
if (scopeType === 'team')
|
|
220
|
+
return 'team';
|
|
221
|
+
return 'agent';
|
|
222
|
+
}
|
|
223
|
+
function readJsonl(path) {
|
|
224
|
+
try {
|
|
225
|
+
if (!existsSync(path))
|
|
226
|
+
return [];
|
|
227
|
+
return readFileSync(path, 'utf-8')
|
|
228
|
+
.split(/\r?\n/)
|
|
229
|
+
.map((line) => line.trim())
|
|
230
|
+
.filter(Boolean)
|
|
231
|
+
.map((line) => JSON.parse(line));
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function artifactBody(record) {
|
|
238
|
+
return [
|
|
239
|
+
record.title,
|
|
240
|
+
record.type,
|
|
241
|
+
record.path,
|
|
242
|
+
record.uri,
|
|
243
|
+
record.conversationId,
|
|
244
|
+
record.subagentRunId,
|
|
245
|
+
Object.entries(record.metadata || {}).map(([key, value]) => `${key}: ${String(value)}`).join('\n'),
|
|
246
|
+
].filter(Boolean).join('\n');
|
|
247
|
+
}
|
|
248
|
+
function memoryBody(entry) {
|
|
249
|
+
return [entry.content, entry.tags.join(' '), entry.sourceConversationId].filter(Boolean).join('\n');
|
|
250
|
+
}
|
|
251
|
+
function taskBody(task, board) {
|
|
252
|
+
return [
|
|
253
|
+
task.title,
|
|
254
|
+
task.description,
|
|
255
|
+
task.status,
|
|
256
|
+
task.priority,
|
|
257
|
+
task.labels.join(' '),
|
|
258
|
+
task.assigneeAgentId,
|
|
259
|
+
task.artifactIds.join(' '),
|
|
260
|
+
task.conversationIds.join(' '),
|
|
261
|
+
board.title,
|
|
262
|
+
].filter(Boolean).join('\n');
|
|
263
|
+
}
|
|
264
|
+
export class WorkspacePolicyService {
|
|
265
|
+
baseDir;
|
|
266
|
+
memoryDir;
|
|
267
|
+
artifactsDir;
|
|
268
|
+
artifactRegistryPath;
|
|
269
|
+
artifactBlobDir;
|
|
270
|
+
taskBoardsDir;
|
|
271
|
+
constructor(baseDir = DEFAULT_XENO_DIR) {
|
|
272
|
+
this.baseDir = baseDir;
|
|
273
|
+
this.memoryDir = join(baseDir, 'memory');
|
|
274
|
+
this.artifactsDir = join(baseDir, 'artifacts');
|
|
275
|
+
this.artifactRegistryPath = join(this.artifactsDir, 'registry.json');
|
|
276
|
+
this.artifactBlobDir = join(this.artifactsDir, 'blobs');
|
|
277
|
+
this.taskBoardsDir = join(baseDir, 'task-boards');
|
|
278
|
+
}
|
|
279
|
+
evaluate(request) {
|
|
280
|
+
const resource = request.resource || { kind: 'conversation' };
|
|
281
|
+
const pathDecision = this.evaluatePath(request.caller, resource);
|
|
282
|
+
const decision = pathDecision.allowed
|
|
283
|
+
? aclAllows(request.caller, resource.scope, resource.acl, request.action)
|
|
284
|
+
: pathDecision;
|
|
285
|
+
writePolicyAudit(request, decision);
|
|
286
|
+
return decision;
|
|
287
|
+
}
|
|
288
|
+
writeMemory(request) {
|
|
289
|
+
try {
|
|
290
|
+
const scopeId = cleanString(request.scopeId, 200);
|
|
291
|
+
const content = cleanString(request.content, MAX_MEMORY_BYTES);
|
|
292
|
+
if (!scopeId)
|
|
293
|
+
return { success: false, error: 'scopeId is required.' };
|
|
294
|
+
if (!content)
|
|
295
|
+
return { success: false, error: 'Memory content is required.' };
|
|
296
|
+
const scope = this.scopeForMemory(request.scopeType, scopeId, request);
|
|
297
|
+
const acl = request.acl || defaultAcl(scope);
|
|
298
|
+
const decision = this.evaluate({
|
|
299
|
+
action: 'write',
|
|
300
|
+
caller: request.caller || { workspaceId: scope.workspaceId, teamId: scope.teamId, agentId: request.authorAgentId || scope.agentId },
|
|
301
|
+
resource: { kind: 'memory', id: scopeId, scope, acl },
|
|
302
|
+
});
|
|
303
|
+
if (!decision.allowed)
|
|
304
|
+
return { success: false, error: decision.reason };
|
|
305
|
+
const now = Date.now();
|
|
306
|
+
const entry = {
|
|
307
|
+
id: stableDocumentId('memory', request.scopeType, scopeId, now, content.slice(0, 80)),
|
|
308
|
+
scopeType: request.scopeType,
|
|
309
|
+
scopeId,
|
|
310
|
+
workspaceId: scope.workspaceId,
|
|
311
|
+
teamId: scope.teamId,
|
|
312
|
+
agentId: scope.agentId,
|
|
313
|
+
content,
|
|
314
|
+
tags: uniqueStrings(request.tags),
|
|
315
|
+
createdAt: now,
|
|
316
|
+
updatedAt: now,
|
|
317
|
+
authorAgentId: cleanString(request.authorAgentId, 200) || undefined,
|
|
318
|
+
sourceConversationId: cleanString(request.sourceConversationId, 200) || undefined,
|
|
319
|
+
importance: clampImportance(request.importance),
|
|
320
|
+
acl,
|
|
321
|
+
};
|
|
322
|
+
const path = this.memoryFilePath(entry.scopeType, entry.scopeId);
|
|
323
|
+
ensureDir(dirname(path));
|
|
324
|
+
appendFileSync(path, `${JSON.stringify(entry)}\n`, 'utf-8');
|
|
325
|
+
return { success: true, entry };
|
|
326
|
+
}
|
|
327
|
+
catch (err) {
|
|
328
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
listMemory(request = {}) {
|
|
332
|
+
try {
|
|
333
|
+
const entries = this.readAllMemory()
|
|
334
|
+
.filter((entry) => this.matchesMemoryFilter(entry, request))
|
|
335
|
+
.filter((entry) => !request.caller || this.evaluate({
|
|
336
|
+
action: 'read',
|
|
337
|
+
caller: request.caller,
|
|
338
|
+
resource: { kind: 'memory', id: entry.id, scope: this.scopeForEntry(entry), acl: entry.acl },
|
|
339
|
+
}).allowed)
|
|
340
|
+
.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
341
|
+
.slice(0, Math.max(1, Math.min(1000, request.limit || 100)));
|
|
342
|
+
return { success: true, entries };
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
return { success: false, entries: [], error: err instanceof Error ? err.message : String(err) };
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
registerArtifact(request) {
|
|
349
|
+
try {
|
|
350
|
+
const title = cleanString(request.title, 300);
|
|
351
|
+
if (!title)
|
|
352
|
+
return { success: false, error: 'Artifact title is required.' };
|
|
353
|
+
const scope = scopeFromRequest(request);
|
|
354
|
+
const acl = request.acl || defaultAcl(scope, 'workspace');
|
|
355
|
+
const decision = this.evaluate({
|
|
356
|
+
action: 'write',
|
|
357
|
+
caller: request.caller || { workspaceId: scope.workspaceId, teamId: scope.teamId, agentId: request.createdByAgentId || scope.agentId },
|
|
358
|
+
resource: { kind: 'artifact', scope, acl, path: request.path },
|
|
359
|
+
});
|
|
360
|
+
if (!decision.allowed)
|
|
361
|
+
return { success: false, error: decision.reason };
|
|
362
|
+
const now = Date.now();
|
|
363
|
+
const artifacts = this.readArtifacts();
|
|
364
|
+
let blobSha256;
|
|
365
|
+
let sizeBytes;
|
|
366
|
+
if (typeof request.content === 'string') {
|
|
367
|
+
const encoding = request.contentEncoding === 'base64' ? 'base64' : 'utf8';
|
|
368
|
+
const buffer = Buffer.from(request.content, encoding);
|
|
369
|
+
if (buffer.length > MAX_ARTIFACT_CONTENT_BYTES) {
|
|
370
|
+
return { success: false, error: `Artifact content exceeds ${MAX_ARTIFACT_CONTENT_BYTES} bytes.` };
|
|
371
|
+
}
|
|
372
|
+
blobSha256 = createHash('sha256').update(buffer).digest('hex');
|
|
373
|
+
sizeBytes = buffer.length;
|
|
374
|
+
this.writeBlob(blobSha256, buffer);
|
|
375
|
+
}
|
|
376
|
+
const artifact = {
|
|
377
|
+
id: stableDocumentId('artifact', title, now, request.path || request.uri || blobSha256 || ''),
|
|
378
|
+
type: request.type || 'other',
|
|
379
|
+
title,
|
|
380
|
+
path: cleanString(request.path, 2000) || undefined,
|
|
381
|
+
uri: cleanString(request.uri, 2000) || undefined,
|
|
382
|
+
blobSha256,
|
|
383
|
+
contentType: cleanString(request.contentType, 200) || undefined,
|
|
384
|
+
sizeBytes,
|
|
385
|
+
workspaceId: scope.workspaceId,
|
|
386
|
+
teamId: scope.teamId,
|
|
387
|
+
agentId: scope.agentId,
|
|
388
|
+
conversationId: scope.conversationId,
|
|
389
|
+
subagentRunId: cleanString(request.subagentRunId, 200) || undefined,
|
|
390
|
+
createdAt: now,
|
|
391
|
+
updatedAt: now,
|
|
392
|
+
createdByAgentId: cleanString(request.createdByAgentId, 200) || undefined,
|
|
393
|
+
metadata: request.metadata && typeof request.metadata === 'object' ? request.metadata : {},
|
|
394
|
+
acl,
|
|
395
|
+
};
|
|
396
|
+
artifacts.push(artifact);
|
|
397
|
+
this.saveArtifacts(artifacts);
|
|
398
|
+
return { success: true, artifact };
|
|
399
|
+
}
|
|
400
|
+
catch (err) {
|
|
401
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
listArtifacts(request = {}) {
|
|
405
|
+
try {
|
|
406
|
+
const query = cleanString(request.query, 500).toLowerCase();
|
|
407
|
+
const artifacts = this.readArtifacts()
|
|
408
|
+
.filter((artifact) => !request.workspaceId || artifact.workspaceId === request.workspaceId)
|
|
409
|
+
.filter((artifact) => !request.teamId || artifact.teamId === request.teamId)
|
|
410
|
+
.filter((artifact) => !request.agentId || artifact.agentId === request.agentId)
|
|
411
|
+
.filter((artifact) => !request.conversationId || artifact.conversationId === request.conversationId)
|
|
412
|
+
.filter((artifact) => !request.subagentRunId || artifact.subagentRunId === request.subagentRunId)
|
|
413
|
+
.filter((artifact) => !request.types?.length || request.types.includes(artifact.type))
|
|
414
|
+
.filter((artifact) => !query || artifactBody(artifact).toLowerCase().includes(query))
|
|
415
|
+
.filter((artifact) => !request.caller || this.evaluate({
|
|
416
|
+
action: 'read',
|
|
417
|
+
caller: request.caller,
|
|
418
|
+
resource: { kind: 'artifact', id: artifact.id, path: artifact.path, scope: this.scopeForArtifact(artifact), acl: artifact.acl },
|
|
419
|
+
}).allowed)
|
|
420
|
+
.sort((a, b) => b.updatedAt - a.updatedAt)
|
|
421
|
+
.slice(0, Math.max(1, Math.min(1000, request.limit || 100)));
|
|
422
|
+
return { success: true, artifacts };
|
|
423
|
+
}
|
|
424
|
+
catch (err) {
|
|
425
|
+
return { success: false, artifacts: [], error: err instanceof Error ? err.message : String(err) };
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
getArtifact(request) {
|
|
429
|
+
try {
|
|
430
|
+
const id = cleanString(request.id, 240);
|
|
431
|
+
const artifact = this.readArtifacts().find((item) => item.id === id);
|
|
432
|
+
if (!artifact)
|
|
433
|
+
return { success: false, error: 'Artifact not found.' };
|
|
434
|
+
const decision = this.evaluate({
|
|
435
|
+
action: 'read',
|
|
436
|
+
caller: request.caller,
|
|
437
|
+
resource: { kind: 'artifact', id: artifact.id, path: artifact.path, scope: this.scopeForArtifact(artifact), acl: artifact.acl },
|
|
438
|
+
});
|
|
439
|
+
if (!decision.allowed)
|
|
440
|
+
return { success: false, error: decision.reason };
|
|
441
|
+
const result = { artifact };
|
|
442
|
+
if (request.includeContent && artifact.blobSha256) {
|
|
443
|
+
const blob = this.readBlob(artifact.blobSha256);
|
|
444
|
+
result.content = blob.toString('base64');
|
|
445
|
+
result.contentEncoding = 'base64';
|
|
446
|
+
}
|
|
447
|
+
return { success: true, result };
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
deleteArtifact(request) {
|
|
454
|
+
try {
|
|
455
|
+
const id = cleanString(request.id, 240);
|
|
456
|
+
const artifacts = this.readArtifacts();
|
|
457
|
+
const artifact = artifacts.find((item) => item.id === id);
|
|
458
|
+
if (!artifact)
|
|
459
|
+
return { success: false, error: 'Artifact not found.' };
|
|
460
|
+
const decision = this.evaluate({
|
|
461
|
+
action: 'delete',
|
|
462
|
+
caller: request.caller,
|
|
463
|
+
resource: { kind: 'artifact', id: artifact.id, path: artifact.path, scope: this.scopeForArtifact(artifact), acl: artifact.acl },
|
|
464
|
+
});
|
|
465
|
+
if (!decision.allowed)
|
|
466
|
+
return { success: false, error: decision.reason };
|
|
467
|
+
this.saveArtifacts(artifacts.filter((item) => item.id !== id));
|
|
468
|
+
return { success: true };
|
|
469
|
+
}
|
|
470
|
+
catch (err) {
|
|
471
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
getTaskBoard(request) {
|
|
475
|
+
try {
|
|
476
|
+
const board = this.loadOrCreateBoard(request);
|
|
477
|
+
if (!board)
|
|
478
|
+
return { success: false, error: 'Task board not found.' };
|
|
479
|
+
const decision = this.evaluate({
|
|
480
|
+
action: 'read',
|
|
481
|
+
caller: request.caller,
|
|
482
|
+
resource: { kind: 'task', id: board.id, scope: this.scopeForBoard(board), acl: board.acl },
|
|
483
|
+
});
|
|
484
|
+
if (!decision.allowed)
|
|
485
|
+
return { success: false, error: decision.reason };
|
|
486
|
+
return { success: true, board };
|
|
487
|
+
}
|
|
488
|
+
catch (err) {
|
|
489
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
upsertTask(request) {
|
|
493
|
+
try {
|
|
494
|
+
const board = this.loadOrCreateBoard({ ...request, createIfMissing: true });
|
|
495
|
+
if (!board)
|
|
496
|
+
return { success: false, error: 'Task board not found.' };
|
|
497
|
+
const decision = this.evaluate({
|
|
498
|
+
action: 'write',
|
|
499
|
+
caller: request.caller || { workspaceId: board.workspaceId, teamId: board.teamId, agentId: request.task?.creatorAgentId },
|
|
500
|
+
resource: { kind: 'task', id: board.id, scope: this.scopeForBoard(board), acl: board.acl },
|
|
501
|
+
});
|
|
502
|
+
if (!decision.allowed)
|
|
503
|
+
return { success: false, error: decision.reason };
|
|
504
|
+
const now = Date.now();
|
|
505
|
+
const input = request.task || {};
|
|
506
|
+
const existingIndex = input.id ? board.tasks.findIndex((task) => task.id === input.id) : -1;
|
|
507
|
+
const current = existingIndex >= 0 ? board.tasks[existingIndex] : undefined;
|
|
508
|
+
const title = cleanString(input.title, 300) || current?.title;
|
|
509
|
+
if (!title)
|
|
510
|
+
return { success: false, error: 'Task title is required.' };
|
|
511
|
+
const task = {
|
|
512
|
+
id: current?.id || stableDocumentId('task', board.id, title, now),
|
|
513
|
+
title,
|
|
514
|
+
description: cleanString(input.description, 5000) || current?.description,
|
|
515
|
+
status: this.normalizeStatus(input.status || current?.status || 'todo'),
|
|
516
|
+
priority: input.priority || current?.priority || 'normal',
|
|
517
|
+
assigneeAgentId: cleanString(input.assigneeAgentId, 200) || current?.assigneeAgentId,
|
|
518
|
+
creatorAgentId: cleanString(input.creatorAgentId, 200) || current?.creatorAgentId,
|
|
519
|
+
artifactIds: uniqueStrings(input.artifactIds || current?.artifactIds || []),
|
|
520
|
+
conversationIds: uniqueStrings(input.conversationIds || current?.conversationIds || []),
|
|
521
|
+
labels: uniqueStrings(input.labels || current?.labels || []),
|
|
522
|
+
dueAt: typeof input.dueAt === 'number' ? input.dueAt : current?.dueAt,
|
|
523
|
+
createdAt: current?.createdAt || now,
|
|
524
|
+
updatedAt: now,
|
|
525
|
+
};
|
|
526
|
+
if (existingIndex >= 0)
|
|
527
|
+
board.tasks[existingIndex] = task;
|
|
528
|
+
else
|
|
529
|
+
board.tasks.push(task);
|
|
530
|
+
board.updatedAt = now;
|
|
531
|
+
this.saveBoard(board);
|
|
532
|
+
return { success: true, board, task };
|
|
533
|
+
}
|
|
534
|
+
catch (err) {
|
|
535
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
deleteTask(request) {
|
|
539
|
+
try {
|
|
540
|
+
const board = this.loadOrCreateBoard(request);
|
|
541
|
+
if (!board)
|
|
542
|
+
return { success: false, error: 'Task board not found.' };
|
|
543
|
+
const decision = this.evaluate({
|
|
544
|
+
action: 'delete',
|
|
545
|
+
caller: request.caller,
|
|
546
|
+
resource: { kind: 'task', id: board.id, scope: this.scopeForBoard(board), acl: board.acl },
|
|
547
|
+
});
|
|
548
|
+
if (!decision.allowed)
|
|
549
|
+
return { success: false, error: decision.reason };
|
|
550
|
+
board.tasks = board.tasks.filter((task) => task.id !== request.taskId);
|
|
551
|
+
board.updatedAt = Date.now();
|
|
552
|
+
this.saveBoard(board);
|
|
553
|
+
return { success: true, board };
|
|
554
|
+
}
|
|
555
|
+
catch (err) {
|
|
556
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
listTaskBoards(request = {}) {
|
|
560
|
+
try {
|
|
561
|
+
const boards = this.readBoards()
|
|
562
|
+
.filter((board) => !request.workspaceId || board.workspaceId === request.workspaceId)
|
|
563
|
+
.filter((board) => !request.teamId || board.teamId === request.teamId)
|
|
564
|
+
.filter((board) => !request.caller || this.evaluate({
|
|
565
|
+
action: 'read',
|
|
566
|
+
caller: request.caller,
|
|
567
|
+
resource: { kind: 'task', id: board.id, scope: this.scopeForBoard(board), acl: board.acl },
|
|
568
|
+
}).allowed)
|
|
569
|
+
.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
570
|
+
return { success: true, boards };
|
|
571
|
+
}
|
|
572
|
+
catch (err) {
|
|
573
|
+
return { success: false, boards: [], error: err instanceof Error ? err.message : String(err) };
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
getSnapshot(caller) {
|
|
577
|
+
const memory = this.listMemory({ caller, limit: 10_000 }).entries;
|
|
578
|
+
const artifacts = this.listArtifacts({ caller, limit: 10_000 }).artifacts;
|
|
579
|
+
const taskBoards = this.listTaskBoards({ caller }).boards;
|
|
580
|
+
return {
|
|
581
|
+
memory,
|
|
582
|
+
artifacts,
|
|
583
|
+
taskBoards,
|
|
584
|
+
searchDocuments: this.toSearchDocuments(caller),
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
toSearchDocuments(caller) {
|
|
588
|
+
const documents = [];
|
|
589
|
+
for (const entry of this.listMemory({ caller, limit: 10_000 }).entries) {
|
|
590
|
+
const scope = this.scopeForEntry(entry);
|
|
591
|
+
documents.push({
|
|
592
|
+
id: stableDocumentId('search-memory', entry.id),
|
|
593
|
+
type: 'memory',
|
|
594
|
+
scope,
|
|
595
|
+
acl: entry.acl,
|
|
596
|
+
title: `Memory: ${entry.tags[0] || entry.scopeType} ${entry.scopeId}`,
|
|
597
|
+
body: memoryBody(entry),
|
|
598
|
+
keywords: ['memory', entry.scopeType, ...entry.tags],
|
|
599
|
+
timestamps: { createdAt: entry.createdAt, updatedAt: entry.updatedAt },
|
|
600
|
+
sourceRef: { artifactId: undefined },
|
|
601
|
+
metrics: { tokenEstimate: estimateTokens(entry.content), bodyBytes: entry.content.length, importance: entry.importance },
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
for (const artifact of this.listArtifacts({ caller, limit: 10_000 }).artifacts) {
|
|
605
|
+
const scope = this.scopeForArtifact(artifact);
|
|
606
|
+
documents.push({
|
|
607
|
+
id: stableDocumentId('search-artifact', artifact.id),
|
|
608
|
+
type: 'artifact',
|
|
609
|
+
scope,
|
|
610
|
+
acl: artifact.acl,
|
|
611
|
+
title: `Artifact: ${artifact.title}`,
|
|
612
|
+
body: artifactBody(artifact),
|
|
613
|
+
keywords: ['artifact', artifact.type, artifact.contentType || '', basename(artifact.path || '')].filter(Boolean),
|
|
614
|
+
sourcePath: artifact.path,
|
|
615
|
+
sourceRef: { artifactId: artifact.id, filePath: artifact.path },
|
|
616
|
+
timestamps: { createdAt: artifact.createdAt, updatedAt: artifact.updatedAt },
|
|
617
|
+
metrics: { tokenEstimate: estimateTokens(artifactBody(artifact)), bodyBytes: artifact.sizeBytes },
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
for (const board of this.listTaskBoards({ caller }).boards) {
|
|
621
|
+
for (const task of board.tasks) {
|
|
622
|
+
const body = taskBody(task, board);
|
|
623
|
+
documents.push({
|
|
624
|
+
id: stableDocumentId('search-task', board.id, task.id),
|
|
625
|
+
type: 'task',
|
|
626
|
+
scope: this.scopeForBoard(board),
|
|
627
|
+
acl: board.acl,
|
|
628
|
+
title: `Task: ${task.title}`,
|
|
629
|
+
body,
|
|
630
|
+
keywords: ['task', task.status, task.priority, ...task.labels],
|
|
631
|
+
sourceRef: { taskId: task.id },
|
|
632
|
+
timestamps: { createdAt: task.createdAt, updatedAt: task.updatedAt },
|
|
633
|
+
metrics: { tokenEstimate: estimateTokens(body), bodyBytes: body.length, importance: task.priority === 'critical' ? 1 : task.priority === 'high' ? 0.8 : 0.5 },
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return documents;
|
|
638
|
+
}
|
|
639
|
+
evaluatePath(caller, resource) {
|
|
640
|
+
if (resource.kind !== 'file' && !resource.path)
|
|
641
|
+
return { allowed: true, reason: 'No path policy required.' };
|
|
642
|
+
if (!resource.path)
|
|
643
|
+
return { allowed: true, reason: 'No path policy required.' };
|
|
644
|
+
const allowedDirectories = Array.isArray(caller?.allowedDirectories) ? caller?.allowedDirectories || [] : [];
|
|
645
|
+
if (allowedDirectories.length === 0) {
|
|
646
|
+
return {
|
|
647
|
+
allowed: false,
|
|
648
|
+
reason: 'No allowed directories were provided for path-scoped access. Select a workspace folder or grant the agent directory access before retrying.',
|
|
649
|
+
matchedScope: resource.scope,
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
const allowed = allowedDirectories.some((dir) => isPathInside(resource.path || '', dir));
|
|
653
|
+
if (!allowed) {
|
|
654
|
+
return {
|
|
655
|
+
allowed: false,
|
|
656
|
+
reason: 'Path is outside the caller allowed directories. Choose a folder inside the workspace, add the folder to directory access, or switch to an agent with the required grant.',
|
|
657
|
+
matchedScope: resource.scope,
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
return { allowed: true, reason: 'Path is inside an allowed directory.', matchedScope: resource.scope };
|
|
661
|
+
}
|
|
662
|
+
memoryFilePath(scopeType, scopeId) {
|
|
663
|
+
return join(this.memoryDir, getScopeTypeDirectory(scopeType), `${safeSegment(scopeId)}.jsonl`);
|
|
664
|
+
}
|
|
665
|
+
scopeForMemory(scopeType, scopeId, input) {
|
|
666
|
+
if (scopeType === 'workspace')
|
|
667
|
+
return { workspaceId: cleanString(input.workspaceId || scopeId, 200) || scopeId };
|
|
668
|
+
if (scopeType === 'team')
|
|
669
|
+
return { workspaceId: cleanString(input.workspaceId, 200) || undefined, teamId: cleanString(input.teamId || scopeId, 200) || scopeId };
|
|
670
|
+
return {
|
|
671
|
+
workspaceId: cleanString(input.workspaceId, 200) || undefined,
|
|
672
|
+
teamId: cleanString(input.teamId, 200) || undefined,
|
|
673
|
+
agentId: cleanString(input.agentId || scopeId, 200) || scopeId,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
scopeForEntry(entry) {
|
|
677
|
+
return {
|
|
678
|
+
workspaceId: entry.workspaceId,
|
|
679
|
+
teamId: entry.teamId,
|
|
680
|
+
agentId: entry.agentId,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
scopeForArtifact(artifact) {
|
|
684
|
+
return {
|
|
685
|
+
workspaceId: artifact.workspaceId,
|
|
686
|
+
teamId: artifact.teamId,
|
|
687
|
+
agentId: artifact.agentId,
|
|
688
|
+
conversationId: artifact.conversationId,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
scopeForBoard(board) {
|
|
692
|
+
return {
|
|
693
|
+
workspaceId: board.workspaceId,
|
|
694
|
+
teamId: board.teamId,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
readAllMemory() {
|
|
698
|
+
const entries = [];
|
|
699
|
+
for (const scopeType of ['workspace', 'team', 'agent']) {
|
|
700
|
+
const dir = join(this.memoryDir, getScopeTypeDirectory(scopeType));
|
|
701
|
+
try {
|
|
702
|
+
if (!existsSync(dir))
|
|
703
|
+
continue;
|
|
704
|
+
for (const file of readdirSync(dir).filter((item) => item.endsWith('.jsonl')).sort()) {
|
|
705
|
+
entries.push(...readJsonl(join(dir, file)));
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
catch {
|
|
709
|
+
// Continue reading other scopes when one file is corrupt or unavailable.
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return entries;
|
|
713
|
+
}
|
|
714
|
+
matchesMemoryFilter(entry, request) {
|
|
715
|
+
if (request.scopeType && entry.scopeType !== request.scopeType)
|
|
716
|
+
return false;
|
|
717
|
+
if (request.scopeId && entry.scopeId !== request.scopeId)
|
|
718
|
+
return false;
|
|
719
|
+
if (request.workspaceId && entry.workspaceId !== request.workspaceId)
|
|
720
|
+
return false;
|
|
721
|
+
if (request.teamId && entry.teamId !== request.teamId)
|
|
722
|
+
return false;
|
|
723
|
+
if (request.agentId && entry.agentId !== request.agentId)
|
|
724
|
+
return false;
|
|
725
|
+
if (request.tags?.length && !request.tags.every((tag) => entry.tags.includes(tag)))
|
|
726
|
+
return false;
|
|
727
|
+
const query = cleanString(request.query, 500).toLowerCase();
|
|
728
|
+
if (query && !memoryBody(entry).toLowerCase().includes(query))
|
|
729
|
+
return false;
|
|
730
|
+
return true;
|
|
731
|
+
}
|
|
732
|
+
readArtifacts() {
|
|
733
|
+
const artifacts = safeReadJson(this.artifactRegistryPath, []);
|
|
734
|
+
return Array.isArray(artifacts) ? artifacts : [];
|
|
735
|
+
}
|
|
736
|
+
saveArtifacts(artifacts) {
|
|
737
|
+
safeWriteJson(this.artifactRegistryPath, artifacts.slice(-20_000));
|
|
738
|
+
}
|
|
739
|
+
writeBlob(sha256, buffer) {
|
|
740
|
+
const dir = join(this.artifactBlobDir, sha256.slice(0, 2));
|
|
741
|
+
ensureDir(dir);
|
|
742
|
+
writeFileSync(join(dir, sha256), buffer);
|
|
743
|
+
}
|
|
744
|
+
readBlob(sha256) {
|
|
745
|
+
return readFileSync(join(this.artifactBlobDir, sha256.slice(0, 2), sha256));
|
|
746
|
+
}
|
|
747
|
+
boardPath(scopeType, scopeId) {
|
|
748
|
+
return join(this.taskBoardsDir, `${scopeType}-${safeSegment(scopeId)}.json`);
|
|
749
|
+
}
|
|
750
|
+
loadOrCreateBoard(request) {
|
|
751
|
+
const scopeId = cleanString(request.scopeId, 200);
|
|
752
|
+
if (!scopeId)
|
|
753
|
+
return null;
|
|
754
|
+
const path = this.boardPath(request.scopeType, scopeId);
|
|
755
|
+
const existing = safeReadJson(path, null);
|
|
756
|
+
if (existing)
|
|
757
|
+
return existing;
|
|
758
|
+
if (!request.createIfMissing)
|
|
759
|
+
return null;
|
|
760
|
+
const now = Date.now();
|
|
761
|
+
const scope = request.scopeType === 'workspace'
|
|
762
|
+
? { workspaceId: request.workspaceId || scopeId }
|
|
763
|
+
: { workspaceId: request.workspaceId, teamId: request.teamId || scopeId };
|
|
764
|
+
const board = {
|
|
765
|
+
id: stableDocumentId('task-board', request.scopeType, scopeId),
|
|
766
|
+
scopeType: request.scopeType,
|
|
767
|
+
scopeId,
|
|
768
|
+
workspaceId: scope.workspaceId,
|
|
769
|
+
teamId: scope.teamId,
|
|
770
|
+
title: request.scopeType === 'workspace' ? `Workspace tasks ${scopeId}` : `Team tasks ${scopeId}`,
|
|
771
|
+
columns: DEFAULT_COLUMNS,
|
|
772
|
+
tasks: [],
|
|
773
|
+
createdAt: now,
|
|
774
|
+
updatedAt: now,
|
|
775
|
+
acl: defaultAcl(scope),
|
|
776
|
+
};
|
|
777
|
+
this.saveBoard(board);
|
|
778
|
+
return board;
|
|
779
|
+
}
|
|
780
|
+
saveBoard(board) {
|
|
781
|
+
safeWriteJson(this.boardPath(board.scopeType, board.scopeId), board);
|
|
782
|
+
}
|
|
783
|
+
readBoards() {
|
|
784
|
+
try {
|
|
785
|
+
if (!existsSync(this.taskBoardsDir))
|
|
786
|
+
return [];
|
|
787
|
+
return readdirSync(this.taskBoardsDir)
|
|
788
|
+
.filter((file) => file.endsWith('.json'))
|
|
789
|
+
.map((file) => safeReadJson(join(this.taskBoardsDir, file), null))
|
|
790
|
+
.filter((board) => !!board);
|
|
791
|
+
}
|
|
792
|
+
catch {
|
|
793
|
+
return [];
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
normalizeStatus(status) {
|
|
797
|
+
if (status === 'todo' || status === 'in_progress' || status === 'blocked' || status === 'review' || status === 'done' || status === 'archived') {
|
|
798
|
+
return status;
|
|
799
|
+
}
|
|
800
|
+
return 'todo';
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
let singleton = null;
|
|
804
|
+
export function getWorkspacePolicyService() {
|
|
805
|
+
if (!singleton)
|
|
806
|
+
singleton = new WorkspacePolicyService();
|
|
807
|
+
return singleton;
|
|
808
|
+
}
|
|
809
|
+
//# sourceMappingURL=WorkspacePolicyService.js.map
|