@office-ai/aioncli-core 0.8.1 → 0.18.5
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/index.d.ts +8 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +36 -1
- package/dist/src/agents/codebase-investigator.js +93 -34
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/codebase-investigator.test.d.ts +6 -0
- package/dist/src/agents/codebase-investigator.test.js +35 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/executor.d.ts +37 -11
- package/dist/src/agents/executor.js +512 -150
- package/dist/src/agents/executor.js.map +1 -1
- package/dist/src/agents/executor.test.js +1188 -245
- package/dist/src/agents/executor.test.js.map +1 -1
- package/dist/src/agents/invocation.d.ts +5 -2
- package/dist/src/agents/invocation.js +4 -2
- package/dist/src/agents/invocation.js.map +1 -1
- package/dist/src/agents/invocation.test.js +9 -0
- package/dist/src/agents/invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +6 -1
- package/dist/src/agents/registry.js +51 -4
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +30 -16
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.d.ts +3 -1
- package/dist/src/agents/subagent-tool-wrapper.js +4 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +9 -4
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +37 -7
- package/dist/src/agents/types.js +2 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/code_assist/codeAssist.js +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
- package/dist/src/code_assist/codeAssist.test.js +99 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +1 -0
- package/dist/src/code_assist/converter.js +1 -0
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +19 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +50 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +36 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments.test.js +92 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
- package/dist/src/code_assist/experiments/flagNames.js +13 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +6 -5
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js +65 -3
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -2
- package/dist/src/code_assist/oauth2.js +161 -93
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +103 -57
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +6 -4
- package/dist/src/code_assist/server.js +16 -8
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +126 -28
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -2
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +1 -1
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +6 -0
- package/dist/src/commands/extensions.test.js +19 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/config/config.d.ts +169 -43
- package/dist/src/config/config.js +418 -79
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +684 -49
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +185 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +23 -2
- package/dist/src/config/models.js +50 -7
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +71 -10
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +3 -1
- package/dist/src/config/storage.js +22 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.d.ts +3 -2
- package/dist/src/confirmation-bus/message-bus.js +9 -3
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.test.js +30 -24
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +13 -2
- package/dist/src/confirmation-bus/types.js +1 -0
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +4 -8
- package/dist/src/core/baseLlmClient.js +6 -11
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +22 -27
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +12 -19
- package/dist/src/core/client.js +104 -206
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +329 -452
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +3 -2
- package/dist/src/core/contentGenerator.js +56 -41
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +49 -1
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +8 -4
- package/dist/src/core/coreToolScheduler.js +348 -179
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +575 -219
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +33 -0
- package/dist/src/core/fakeContentGenerator.js +58 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
- package/dist/src/core/fakeContentGenerator.test.js +127 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +23 -18
- package/dist/src/core/geminiChat.js +186 -108
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +581 -270
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.d.ts +7 -2
- package/dist/src/core/logger.js +35 -27
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +45 -29
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +1 -0
- package/dist/src/core/loggingContentGenerator.js +113 -33
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/loggingContentGenerator.test.js +180 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -2
- package/dist/src/core/nonInteractiveToolExecutor.js +12 -7
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +12 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +15 -1
- package/dist/src/core/openaiContentGenerator.js +139 -22
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +135 -154
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +128 -189
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +18 -0
- package/dist/src/core/recordingContentGenerator.js +77 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/recordingContentGenerator.test.js +101 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +26 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +23 -3
- package/dist/src/core/turn.js +18 -9
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +98 -104
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +60 -8
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +132 -17
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +262 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
- package/dist/src/hooks/hookAggregator.test.js +387 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +46 -0
- package/dist/src/hooks/hookPlanner.js +108 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
- package/dist/src/hooks/hookPlanner.test.js +255 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +87 -0
- package/dist/src/hooks/hookRegistry.js +198 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
- package/dist/src/hooks/hookRegistry.test.js +341 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +42 -0
- package/dist/src/hooks/hookRunner.js +272 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +6 -0
- package/dist/src/hooks/hookRunner.test.js +468 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +232 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
- package/dist/src/hooks/hookTranslator.test.js +192 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +384 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +6 -0
- package/dist/src/hooks/types.test.js +313 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +4 -0
- package/dist/src/ide/detect-ide.js +6 -1
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +16 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +3 -1
- package/dist/src/ide/ide-client.js +12 -10
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +163 -4
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.js +66 -21
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +54 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/process-utils.js +85 -75
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +83 -90
- package/dist/src/ide/process-utils.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +5 -5
- package/dist/src/ide/types.js +1 -1
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +2 -0
- package/dist/src/mcp/google-auth-provider.js +21 -3
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +42 -9
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +8 -5
- package/dist/src/mcp/oauth-provider.js +140 -55
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +369 -2
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.js +5 -4
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +17 -11
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +7 -0
- package/dist/src/mcp/oauth-utils.js +28 -8
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +45 -2
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +0 -6
- package/dist/src/mcp/sa-impersonation-provider.js +6 -23
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.test.js +75 -84
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +3 -2
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +11 -8
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +6 -2
- package/dist/src/mcp/token-storage/keychain-token-storage.js +63 -7
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +54 -3
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/types.d.ts +6 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -1
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +63 -1
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +199 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +6 -0
- package/dist/src/policy/config.test.js +538 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +2 -0
- package/dist/src/policy/index.js +2 -0
- package/dist/src/policy/index.js.map +1 -1
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +56 -0
- package/dist/src/policy/policies/write.toml +73 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +12 -3
- package/dist/src/policy/policy-engine.js +74 -8
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +460 -76
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +47 -0
- package/dist/src/policy/toml-loader.js +411 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +6 -0
- package/dist/src/policy/toml-loader.test.js +376 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +83 -0
- package/dist/src/policy/types.js +10 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
- package/dist/src/prompts/mcp-prompts.test.js +39 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.js +2 -1
- package/dist/src/prompts/prompt-registry.js.map +1 -1
- package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
- package/dist/src/prompts/prompt-registry.test.js +96 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +15 -0
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +62 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js +9 -16
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +17 -13
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +4 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +2 -2
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +3 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +6 -0
- package/dist/src/safety/built-in.test.js +199 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +208 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +6 -0
- package/dist/src/safety/checker-runner.test.js +238 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +6 -0
- package/dist/src/safety/context-builder.test.js +49 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +6 -0
- package/dist/src/safety/registry.test.js +31 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +162 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +6 -0
- package/dist/src/services/chatCompressionService.test.js +210 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +3 -2
- package/dist/src/services/chatRecordingService.js +11 -9
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +2 -14
- package/dist/src/services/fileDiscoveryService.js +19 -55
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +91 -11
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +4 -1
- package/dist/src/services/loopDetectionService.js +95 -42
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +220 -12
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
- package/dist/src/services/modelConfig.golden.test.js +42 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
- package/dist/src/services/modelConfig.integration.test.js +247 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +48 -0
- package/dist/src/services/modelConfigService.js +151 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +6 -0
- package/dist/src/services/modelConfigService.test.js +531 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +1 -0
- package/dist/src/services/shellExecutionService.js +195 -92
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +137 -14
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +251 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +294 -76
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +192 -66
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +25 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +59 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -28
- package/dist/src/telemetry/constants.js +0 -29
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.js +0 -1
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.test.js +1 -1
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +7 -3
- package/dist/src/telemetry/index.js +13 -4
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +14 -7
- package/dist/src/telemetry/loggers.js +197 -320
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +0 -1
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +460 -59
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +180 -4
- package/dist/src/telemetry/metrics.js +270 -6
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +502 -184
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +3 -2
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +269 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +6 -0
- package/dist/src/telemetry/semantic.test.js +387 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.js +29 -28
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +227 -29
- package/dist/src/telemetry/types.js +858 -72
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +7 -7
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +89 -67
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +1 -1
- package/dist/src/test-utils/config.js +1 -1
- package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
- package/dist/src/tools/base-tool-invocation.test.js +85 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +4 -3
- package/dist/src/tools/edit.js +50 -47
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +306 -216
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +4 -3
- package/dist/src/tools/glob.js +24 -27
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +212 -205
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +4 -3
- package/dist/src/tools/grep.js +31 -25
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +15 -12
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +4 -3
- package/dist/src/tools/ls.js +29 -35
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +34 -42
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +49 -11
- package/dist/src/tools/mcp-client-manager.js +191 -31
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +132 -25
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +12 -5
- package/dist/src/tools/mcp-client.js +287 -267
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +352 -45
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +6 -2
- package/dist/src/tools/mcp-tool.js +19 -8
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +186 -273
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +7 -5
- package/dist/src/tools/memoryTool.js +14 -12
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +10 -9
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +14 -1
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.d.ts +5 -1
- package/dist/src/tools/modifiable-tool.js +38 -16
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +66 -31
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +6 -5
- package/dist/src/tools/read-file.js +26 -32
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +68 -33
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +6 -12
- package/dist/src/tools/read-many-files.js +28 -57
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +37 -36
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +28 -10
- package/dist/src/tools/ripGrep.js +195 -193
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +533 -204
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +8 -6
- package/dist/src/tools/shell.js +64 -38
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +134 -43
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +10 -23
- package/dist/src/tools/smart-edit.js +100 -85
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +229 -179
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +21 -0
- package/dist/src/tools/tool-error.js +27 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +21 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +32 -20
- package/dist/src/tools/tool-registry.js +122 -78
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +167 -90
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +23 -8
- package/dist/src/tools/tools.js +69 -37
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +11 -3
- package/dist/src/tools/web-fetch.js +80 -38
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +338 -9
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +4 -3
- package/dist/src/tools/web-search.js +11 -9
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +6 -0
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +3 -2
- package/dist/src/tools/write-file.js +41 -40
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +130 -123
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +34 -9
- package/dist/src/tools/write-todos.js +54 -11
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -2
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.js +3 -2
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +6 -0
- package/dist/src/utils/channel.test.js +170 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +69 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.js +10 -25
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +19 -5
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +4 -2
- package/dist/src/utils/editor.js +53 -39
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +18 -45
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +2 -1
- package/dist/src/utils/environmentContext.js +20 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +6 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +6 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +121 -0
- package/dist/src/utils/events.js +84 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +6 -0
- package/dist/src/utils/events.test.js +212 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +6 -0
- package/dist/src/utils/extensionLoader.test.js +154 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +1 -0
- package/dist/src/utils/fetch.js +4 -0
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +34 -2
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +87 -61
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.js +1 -1
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +28 -47
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.js +9 -17
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +4 -1
- package/dist/src/utils/gitIgnoreParser.js +28 -10
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +58 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +152 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +301 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
- package/dist/src/utils/googleQuotaErrors.js +157 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +311 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.js +26 -30
- package/dist/src/utils/ignorePatterns.test.js.map +1 -1
- package/dist/src/utils/installationManager.js +2 -1
- package/dist/src/utils/installationManager.js.map +1 -1
- package/dist/src/utils/installationManager.test.js +6 -4
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.d.ts +1 -1
- package/dist/src/utils/llm-edit-fixer.js +33 -9
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +38 -1
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +20 -1
- package/dist/src/utils/memoryDiscovery.js +176 -12
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +299 -40
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +4 -3
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +8 -14
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.js +3 -3
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +13 -5
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +15 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.js +4 -4
- package/dist/src/utils/pathReader.js.map +1 -1
- package/dist/src/utils/pathReader.test.js +44 -1
- package/dist/src/utils/pathReader.test.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +131 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +200 -68
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +3 -10
- package/dist/src/utils/retry.js +97 -195
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +179 -145
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +15 -2
- package/dist/src/utils/shell-utils.js +387 -140
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +244 -62
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +6 -0
- package/dist/src/utils/stdio.test.js +47 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +4 -2
- package/dist/src/utils/summarizer.js +8 -9
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +32 -12
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +5 -4
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +2 -1
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +14 -0
- package/dist/src/utils/terminal.js +38 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +2 -2
- package/dist/src/utils/tool-utils.js +15 -6
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +8 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.js +5 -4
- package/dist/src/utils/userAccountManager.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +9 -7
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +13 -13
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +8 -7
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -7
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
6
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
7
7
|
import { PolicyEngine } from './policy-engine.js';
|
|
8
|
-
import { PolicyDecision, } from './types.js';
|
|
8
|
+
import { PolicyDecision, InProcessCheckerType, } from './types.js';
|
|
9
|
+
import { SafetyCheckDecision } from '../safety/protocol.js';
|
|
9
10
|
describe('PolicyEngine', () => {
|
|
10
11
|
let engine;
|
|
12
|
+
let mockCheckerRunner;
|
|
11
13
|
beforeEach(() => {
|
|
12
|
-
|
|
14
|
+
mockCheckerRunner = {
|
|
15
|
+
runChecker: vi.fn(),
|
|
16
|
+
};
|
|
17
|
+
engine = new PolicyEngine({}, mockCheckerRunner);
|
|
13
18
|
});
|
|
14
19
|
describe('constructor', () => {
|
|
15
|
-
it('should use default config when none provided', () => {
|
|
16
|
-
const decision = engine.check({ name: 'test' });
|
|
20
|
+
it('should use default config when none provided', async () => {
|
|
21
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
17
22
|
expect(decision).toBe(PolicyDecision.ASK_USER);
|
|
18
23
|
});
|
|
19
|
-
it('should respect custom default decision', () => {
|
|
24
|
+
it('should respect custom default decision', async () => {
|
|
20
25
|
engine = new PolicyEngine({ defaultDecision: PolicyDecision.DENY });
|
|
21
|
-
const decision = engine.check({ name: 'test' });
|
|
26
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
22
27
|
expect(decision).toBe(PolicyDecision.DENY);
|
|
23
28
|
});
|
|
24
29
|
it('should sort rules by priority', () => {
|
|
@@ -35,17 +40,17 @@ describe('PolicyEngine', () => {
|
|
|
35
40
|
});
|
|
36
41
|
});
|
|
37
42
|
describe('check', () => {
|
|
38
|
-
it('should match tool by name', () => {
|
|
43
|
+
it('should match tool by name', async () => {
|
|
39
44
|
const rules = [
|
|
40
45
|
{ toolName: 'shell', decision: PolicyDecision.ALLOW },
|
|
41
46
|
{ toolName: 'edit', decision: PolicyDecision.DENY },
|
|
42
47
|
];
|
|
43
48
|
engine = new PolicyEngine({ rules });
|
|
44
|
-
expect(engine.check({ name: 'shell' })).toBe(PolicyDecision.ALLOW);
|
|
45
|
-
expect(engine.check({ name: 'edit' })).toBe(PolicyDecision.DENY);
|
|
46
|
-
expect(engine.check({ name: 'other' })).toBe(PolicyDecision.ASK_USER);
|
|
49
|
+
expect((await engine.check({ name: 'shell' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
50
|
+
expect((await engine.check({ name: 'edit' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
51
|
+
expect((await engine.check({ name: 'other' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
47
52
|
});
|
|
48
|
-
it('should match by args pattern', () => {
|
|
53
|
+
it('should match by args pattern', async () => {
|
|
49
54
|
const rules = [
|
|
50
55
|
{
|
|
51
56
|
toolName: 'shell',
|
|
@@ -66,28 +71,28 @@ describe('PolicyEngine', () => {
|
|
|
66
71
|
name: 'shell',
|
|
67
72
|
args: { command: 'ls -la' },
|
|
68
73
|
};
|
|
69
|
-
expect(engine.check(dangerousCall)).toBe(PolicyDecision.DENY);
|
|
70
|
-
expect(engine.check(safeCall)).toBe(PolicyDecision.ALLOW);
|
|
74
|
+
expect((await engine.check(dangerousCall, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
75
|
+
expect((await engine.check(safeCall, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
71
76
|
});
|
|
72
|
-
it('should apply rules by priority', () => {
|
|
77
|
+
it('should apply rules by priority', async () => {
|
|
73
78
|
const rules = [
|
|
74
79
|
{ toolName: 'shell', decision: PolicyDecision.DENY, priority: 1 },
|
|
75
80
|
{ toolName: 'shell', decision: PolicyDecision.ALLOW, priority: 10 },
|
|
76
81
|
];
|
|
77
82
|
engine = new PolicyEngine({ rules });
|
|
78
83
|
// Higher priority rule (ALLOW) should win
|
|
79
|
-
expect(engine.check({ name: 'shell' })).toBe(PolicyDecision.ALLOW);
|
|
84
|
+
expect((await engine.check({ name: 'shell' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
80
85
|
});
|
|
81
|
-
it('should apply wildcard rules (no toolName)', () => {
|
|
86
|
+
it('should apply wildcard rules (no toolName)', async () => {
|
|
82
87
|
const rules = [
|
|
83
88
|
{ decision: PolicyDecision.DENY }, // Applies to all tools
|
|
84
89
|
{ toolName: 'safe-tool', decision: PolicyDecision.ALLOW, priority: 10 },
|
|
85
90
|
];
|
|
86
91
|
engine = new PolicyEngine({ rules });
|
|
87
|
-
expect(engine.check({ name: 'safe-tool' })).toBe(PolicyDecision.ALLOW);
|
|
88
|
-
expect(engine.check({ name: 'any-other-tool' })).toBe(PolicyDecision.DENY);
|
|
92
|
+
expect((await engine.check({ name: 'safe-tool' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
93
|
+
expect((await engine.check({ name: 'any-other-tool' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
89
94
|
});
|
|
90
|
-
it('should handle non-interactive mode', () => {
|
|
95
|
+
it('should handle non-interactive mode', async () => {
|
|
91
96
|
const config = {
|
|
92
97
|
nonInteractive: true,
|
|
93
98
|
rules: [
|
|
@@ -97,11 +102,11 @@ describe('PolicyEngine', () => {
|
|
|
97
102
|
};
|
|
98
103
|
engine = new PolicyEngine(config);
|
|
99
104
|
// ASK_USER should become DENY in non-interactive mode
|
|
100
|
-
expect(engine.check({ name: 'interactive-tool' })).toBe(PolicyDecision.DENY);
|
|
105
|
+
expect((await engine.check({ name: 'interactive-tool' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
101
106
|
// ALLOW should remain ALLOW
|
|
102
|
-
expect(engine.check({ name: 'allowed-tool' })).toBe(PolicyDecision.ALLOW);
|
|
107
|
+
expect((await engine.check({ name: 'allowed-tool' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
103
108
|
// Default ASK_USER should also become DENY
|
|
104
|
-
expect(engine.check({ name: 'unknown-tool' })).toBe(PolicyDecision.DENY);
|
|
109
|
+
expect((await engine.check({ name: 'unknown-tool' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
105
110
|
});
|
|
106
111
|
});
|
|
107
112
|
describe('addRule', () => {
|
|
@@ -127,10 +132,10 @@ describe('PolicyEngine', () => {
|
|
|
127
132
|
expect(rules[1].priority).toBe(5);
|
|
128
133
|
expect(rules[2].priority).toBe(1);
|
|
129
134
|
});
|
|
130
|
-
it('should apply newly added rules', () => {
|
|
131
|
-
expect(engine.check({ name: 'new-tool' })).toBe(PolicyDecision.ASK_USER);
|
|
135
|
+
it('should apply newly added rules', async () => {
|
|
136
|
+
expect((await engine.check({ name: 'new-tool' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
132
137
|
engine.addRule({ toolName: 'new-tool', decision: PolicyDecision.ALLOW });
|
|
133
|
-
expect(engine.check({ name: 'new-tool' })).toBe(PolicyDecision.ALLOW);
|
|
138
|
+
expect((await engine.check({ name: 'new-tool' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
134
139
|
});
|
|
135
140
|
});
|
|
136
141
|
describe('removeRulesForTool', () => {
|
|
@@ -169,7 +174,7 @@ describe('PolicyEngine', () => {
|
|
|
169
174
|
});
|
|
170
175
|
});
|
|
171
176
|
describe('MCP server wildcard patterns', () => {
|
|
172
|
-
it('should match MCP server wildcard patterns', () => {
|
|
177
|
+
it('should match MCP server wildcard patterns', async () => {
|
|
173
178
|
const rules = [
|
|
174
179
|
{
|
|
175
180
|
toolName: 'my-server__*',
|
|
@@ -184,17 +189,21 @@ describe('PolicyEngine', () => {
|
|
|
184
189
|
];
|
|
185
190
|
engine = new PolicyEngine({ rules });
|
|
186
191
|
// Should match my-server tools
|
|
187
|
-
expect(engine.check({ name: 'my-server__tool1' })).toBe(PolicyDecision.ALLOW);
|
|
188
|
-
expect(engine.check({ name: 'my-server__another_tool' }))
|
|
192
|
+
expect((await engine.check({ name: 'my-server__tool1' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
193
|
+
expect((await engine.check({ name: 'my-server__another_tool' }, undefined))
|
|
194
|
+
.decision).toBe(PolicyDecision.ALLOW);
|
|
189
195
|
// Should match blocked-server tools
|
|
190
|
-
expect(engine.check({ name: 'blocked-server__tool1' }))
|
|
191
|
-
|
|
196
|
+
expect((await engine.check({ name: 'blocked-server__tool1' }, undefined))
|
|
197
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
198
|
+
expect((await engine.check({ name: 'blocked-server__dangerous' }, undefined))
|
|
199
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
192
200
|
// Should not match other patterns
|
|
193
|
-
expect(engine.check({ name: 'other-server__tool' }))
|
|
194
|
-
|
|
195
|
-
expect(engine.check({ name: 'my-server' })).toBe(PolicyDecision.ASK_USER); // No
|
|
201
|
+
expect((await engine.check({ name: 'other-server__tool' }, undefined))
|
|
202
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
203
|
+
expect((await engine.check({ name: 'my-server-tool' }, undefined)).decision).toBe(PolicyDecision.ASK_USER); // No __ separator
|
|
204
|
+
expect((await engine.check({ name: 'my-server' }, undefined)).decision).toBe(PolicyDecision.ASK_USER); // No tool name
|
|
196
205
|
});
|
|
197
|
-
it('should prioritize specific tool rules over server wildcards', () => {
|
|
206
|
+
it('should prioritize specific tool rules over server wildcards', async () => {
|
|
198
207
|
const rules = [
|
|
199
208
|
{
|
|
200
209
|
toolName: 'my-server__*',
|
|
@@ -209,12 +218,54 @@ describe('PolicyEngine', () => {
|
|
|
209
218
|
];
|
|
210
219
|
engine = new PolicyEngine({ rules });
|
|
211
220
|
// Specific tool deny should override server allow
|
|
212
|
-
expect(engine.check({ name: 'my-server__dangerous-tool' }))
|
|
213
|
-
|
|
221
|
+
expect((await engine.check({ name: 'my-server__dangerous-tool' }, undefined))
|
|
222
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
223
|
+
expect((await engine.check({ name: 'my-server__safe-tool' }, undefined))
|
|
224
|
+
.decision).toBe(PolicyDecision.ALLOW);
|
|
225
|
+
});
|
|
226
|
+
it('should NOT match spoofed server names when using wildcards', async () => {
|
|
227
|
+
// Vulnerability: A rule for 'prefix__*' matches 'prefix__suffix__tool'
|
|
228
|
+
// effectively allowing a server named 'prefix__suffix' to spoof 'prefix'.
|
|
229
|
+
const rules = [
|
|
230
|
+
{
|
|
231
|
+
toolName: 'safe_server__*',
|
|
232
|
+
decision: PolicyDecision.ALLOW,
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
engine = new PolicyEngine({ rules });
|
|
236
|
+
// A tool from a different server 'safe_server__malicious'
|
|
237
|
+
const spoofedToolCall = { name: 'safe_server__malicious__tool' };
|
|
238
|
+
// CURRENT BEHAVIOR (FIXED): Matches because it starts with 'safe_server__' BUT serverName doesn't match 'safe_server'
|
|
239
|
+
// We expect this to FAIL matching the ALLOW rule, thus falling back to default (ASK_USER)
|
|
240
|
+
expect((await engine.check(spoofedToolCall, 'safe_server__malicious'))
|
|
241
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
242
|
+
});
|
|
243
|
+
it('should verify tool name prefix even if serverName matches', async () => {
|
|
244
|
+
const rules = [
|
|
245
|
+
{
|
|
246
|
+
toolName: 'safe_server__*',
|
|
247
|
+
decision: PolicyDecision.ALLOW,
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
engine = new PolicyEngine({ rules });
|
|
251
|
+
// serverName matches, but tool name does not start with prefix
|
|
252
|
+
const invalidToolCall = { name: 'other_server__tool' };
|
|
253
|
+
expect((await engine.check(invalidToolCall, 'safe_server')).decision).toBe(PolicyDecision.ASK_USER);
|
|
254
|
+
});
|
|
255
|
+
it('should allow when both serverName and tool name prefix match', async () => {
|
|
256
|
+
const rules = [
|
|
257
|
+
{
|
|
258
|
+
toolName: 'safe_server__*',
|
|
259
|
+
decision: PolicyDecision.ALLOW,
|
|
260
|
+
},
|
|
261
|
+
];
|
|
262
|
+
engine = new PolicyEngine({ rules });
|
|
263
|
+
const validToolCall = { name: 'safe_server__tool' };
|
|
264
|
+
expect((await engine.check(validToolCall, 'safe_server')).decision).toBe(PolicyDecision.ALLOW);
|
|
214
265
|
});
|
|
215
266
|
});
|
|
216
267
|
describe('complex scenarios', () => {
|
|
217
|
-
it('should handle multiple matching rules with different priorities', () => {
|
|
268
|
+
it('should handle multiple matching rules with different priorities', async () => {
|
|
218
269
|
const rules = [
|
|
219
270
|
{ decision: PolicyDecision.DENY, priority: 0 }, // Default deny all
|
|
220
271
|
{ toolName: 'shell', decision: PolicyDecision.ASK_USER, priority: 5 },
|
|
@@ -227,13 +278,13 @@ describe('PolicyEngine', () => {
|
|
|
227
278
|
];
|
|
228
279
|
engine = new PolicyEngine({ rules });
|
|
229
280
|
// Matches highest priority rule (ls command)
|
|
230
|
-
expect(engine.check({ name: 'shell', args: { command: 'ls -la' } })).toBe(PolicyDecision.ALLOW);
|
|
281
|
+
expect((await engine.check({ name: 'shell', args: { command: 'ls -la' } }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
231
282
|
// Matches middle priority rule (shell without ls)
|
|
232
|
-
expect(engine.check({ name: 'shell', args: { command: 'pwd' } })).toBe(PolicyDecision.ASK_USER);
|
|
283
|
+
expect((await engine.check({ name: 'shell', args: { command: 'pwd' } }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
233
284
|
// Matches lowest priority rule (not shell)
|
|
234
|
-
expect(engine.check({ name: 'edit' })).toBe(PolicyDecision.DENY);
|
|
285
|
+
expect((await engine.check({ name: 'edit' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
235
286
|
});
|
|
236
|
-
it('should handle tools with no args', () => {
|
|
287
|
+
it('should handle tools with no args', async () => {
|
|
237
288
|
const rules = [
|
|
238
289
|
{
|
|
239
290
|
toolName: 'read',
|
|
@@ -243,13 +294,13 @@ describe('PolicyEngine', () => {
|
|
|
243
294
|
];
|
|
244
295
|
engine = new PolicyEngine({ rules });
|
|
245
296
|
// Tool call without args should not match pattern
|
|
246
|
-
expect(engine.check({ name: 'read' })).toBe(PolicyDecision.ASK_USER);
|
|
297
|
+
expect((await engine.check({ name: 'read' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
247
298
|
// Tool call with args not matching pattern
|
|
248
|
-
expect(engine.check({ name: 'read', args: { file: 'public.txt' } })).toBe(PolicyDecision.ASK_USER);
|
|
299
|
+
expect((await engine.check({ name: 'read', args: { file: 'public.txt' } }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
249
300
|
// Tool call with args matching pattern
|
|
250
|
-
expect(engine.check({ name: 'read', args: { file: 'secret.txt' } })).toBe(PolicyDecision.DENY);
|
|
301
|
+
expect((await engine.check({ name: 'read', args: { file: 'secret.txt' } }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
251
302
|
});
|
|
252
|
-
it('should match args pattern regardless of property order', () => {
|
|
303
|
+
it('should match args pattern regardless of property order', async () => {
|
|
253
304
|
const rules = [
|
|
254
305
|
{
|
|
255
306
|
toolName: 'shell',
|
|
@@ -262,13 +313,16 @@ describe('PolicyEngine', () => {
|
|
|
262
313
|
// Same args with different property order should both match
|
|
263
314
|
const args1 = { command: 'rm -rf /', path: '/home' };
|
|
264
315
|
const args2 = { path: '/home', command: 'rm -rf /' };
|
|
265
|
-
expect(engine.check({ name: 'shell', args: args1 }))
|
|
266
|
-
|
|
316
|
+
expect((await engine.check({ name: 'shell', args: args1 }, undefined))
|
|
317
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
318
|
+
expect((await engine.check({ name: 'shell', args: args2 }, undefined))
|
|
319
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
267
320
|
// Verify safe command doesn't match
|
|
268
321
|
const safeArgs = { command: 'ls -la', path: '/home' };
|
|
269
|
-
expect(engine.check({ name: 'shell', args: safeArgs }))
|
|
322
|
+
expect((await engine.check({ name: 'shell', args: safeArgs }, undefined))
|
|
323
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
270
324
|
});
|
|
271
|
-
it('should handle nested objects in args with stable stringification', () => {
|
|
325
|
+
it('should handle nested objects in args with stable stringification', async () => {
|
|
272
326
|
const rules = [
|
|
273
327
|
{
|
|
274
328
|
toolName: 'api',
|
|
@@ -286,10 +340,10 @@ describe('PolicyEngine', () => {
|
|
|
286
340
|
method: 'POST',
|
|
287
341
|
data: { value: 'secret', sensitive: true },
|
|
288
342
|
};
|
|
289
|
-
expect(engine.check({ name: 'api', args: args1 })).toBe(PolicyDecision.DENY);
|
|
290
|
-
expect(engine.check({ name: 'api', args: args2 })).toBe(PolicyDecision.DENY);
|
|
343
|
+
expect((await engine.check({ name: 'api', args: args1 }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
344
|
+
expect((await engine.check({ name: 'api', args: args2 }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
291
345
|
});
|
|
292
|
-
it('should handle circular references without stack overflow', () => {
|
|
346
|
+
it('should handle circular references without stack overflow', async () => {
|
|
293
347
|
const rules = [
|
|
294
348
|
{
|
|
295
349
|
toolName: 'test',
|
|
@@ -306,14 +360,16 @@ describe('PolicyEngine', () => {
|
|
|
306
360
|
circularArgs.data['self'] =
|
|
307
361
|
circularArgs.data;
|
|
308
362
|
// Should not throw stack overflow error
|
|
309
|
-
expect(
|
|
363
|
+
await expect(engine.check({ name: 'test', args: circularArgs }, undefined)).resolves.not.toThrow();
|
|
310
364
|
// Should detect the circular reference pattern
|
|
311
|
-
expect(engine.check({ name: 'test', args: circularArgs }))
|
|
365
|
+
expect((await engine.check({ name: 'test', args: circularArgs }, undefined))
|
|
366
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
312
367
|
// Non-circular object should not match
|
|
313
368
|
const normalArgs = { name: 'test', data: { value: 'normal' } };
|
|
314
|
-
expect(engine.check({ name: 'test', args: normalArgs }))
|
|
369
|
+
expect((await engine.check({ name: 'test', args: normalArgs }, undefined))
|
|
370
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
315
371
|
});
|
|
316
|
-
it('should handle deep circular references', () => {
|
|
372
|
+
it('should handle deep circular references', async () => {
|
|
317
373
|
const rules = [
|
|
318
374
|
{
|
|
319
375
|
toolName: 'deep',
|
|
@@ -333,11 +389,12 @@ describe('PolicyEngine', () => {
|
|
|
333
389
|
const level3 = deepCircular.level1.level2.level3;
|
|
334
390
|
level3['back'] = deepCircular.level1;
|
|
335
391
|
// Should handle without stack overflow
|
|
336
|
-
expect(
|
|
392
|
+
await expect(engine.check({ name: 'deep', args: deepCircular }, undefined)).resolves.not.toThrow();
|
|
337
393
|
// Should detect the circular reference
|
|
338
|
-
expect(engine.check({ name: 'deep', args: deepCircular }))
|
|
394
|
+
expect((await engine.check({ name: 'deep', args: deepCircular }, undefined))
|
|
395
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
339
396
|
});
|
|
340
|
-
it('should handle repeated non-circular objects correctly', () => {
|
|
397
|
+
it('should handle repeated non-circular objects correctly', async () => {
|
|
341
398
|
const rules = [
|
|
342
399
|
{
|
|
343
400
|
toolName: 'test',
|
|
@@ -360,9 +417,9 @@ describe('PolicyEngine', () => {
|
|
|
360
417
|
third: { nested: sharedObj },
|
|
361
418
|
};
|
|
362
419
|
// Should NOT mark repeated objects as circular, and should match the shared value pattern
|
|
363
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
420
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
364
421
|
});
|
|
365
|
-
it('should omit undefined and function values from objects', () => {
|
|
422
|
+
it('should omit undefined and function values from objects', async () => {
|
|
366
423
|
const rules = [
|
|
367
424
|
{
|
|
368
425
|
toolName: 'test',
|
|
@@ -378,7 +435,7 @@ describe('PolicyEngine', () => {
|
|
|
378
435
|
nullValue: null,
|
|
379
436
|
};
|
|
380
437
|
// Should match pattern with defined value, undefined and functions omitted
|
|
381
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
438
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
382
439
|
// Check that the pattern would NOT match if undefined was included
|
|
383
440
|
const rulesWithUndefined = [
|
|
384
441
|
{
|
|
@@ -388,7 +445,7 @@ describe('PolicyEngine', () => {
|
|
|
388
445
|
},
|
|
389
446
|
];
|
|
390
447
|
engine = new PolicyEngine({ rules: rulesWithUndefined });
|
|
391
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ASK_USER);
|
|
448
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
392
449
|
// Check that the pattern would NOT match if function was included
|
|
393
450
|
const rulesWithFunction = [
|
|
394
451
|
{
|
|
@@ -398,9 +455,9 @@ describe('PolicyEngine', () => {
|
|
|
398
455
|
},
|
|
399
456
|
];
|
|
400
457
|
engine = new PolicyEngine({ rules: rulesWithFunction });
|
|
401
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ASK_USER);
|
|
458
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
402
459
|
});
|
|
403
|
-
it('should convert undefined and functions to null in arrays', () => {
|
|
460
|
+
it('should convert undefined and functions to null in arrays', async () => {
|
|
404
461
|
const rules = [
|
|
405
462
|
{
|
|
406
463
|
toolName: 'test',
|
|
@@ -413,9 +470,9 @@ describe('PolicyEngine', () => {
|
|
|
413
470
|
array: ['value', undefined, () => 'hello', null],
|
|
414
471
|
};
|
|
415
472
|
// Should match pattern with undefined and functions converted to null
|
|
416
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
473
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
417
474
|
});
|
|
418
|
-
it('should produce valid JSON for all inputs', () => {
|
|
475
|
+
it('should produce valid JSON for all inputs', async () => {
|
|
419
476
|
const testCases = [
|
|
420
477
|
{ input: { simple: 'string' }, desc: 'simple object' },
|
|
421
478
|
{
|
|
@@ -443,12 +500,13 @@ describe('PolicyEngine', () => {
|
|
|
443
500
|
];
|
|
444
501
|
engine = new PolicyEngine({ rules });
|
|
445
502
|
// Should not throw when checking (which internally uses stableStringify)
|
|
446
|
-
expect(
|
|
503
|
+
await expect(engine.check({ name: 'test', args: input }, undefined)).resolves.not.toThrow();
|
|
447
504
|
// The check should succeed
|
|
448
|
-
expect(engine.check({ name: 'test', args: input }))
|
|
505
|
+
expect((await engine.check({ name: 'test', args: input }, undefined))
|
|
506
|
+
.decision).toBe(PolicyDecision.ALLOW);
|
|
449
507
|
}
|
|
450
508
|
});
|
|
451
|
-
it('should respect toJSON methods on objects', () => {
|
|
509
|
+
it('should respect toJSON methods on objects', async () => {
|
|
452
510
|
const rules = [
|
|
453
511
|
{
|
|
454
512
|
toolName: 'test',
|
|
@@ -470,9 +528,9 @@ describe('PolicyEngine', () => {
|
|
|
470
528
|
},
|
|
471
529
|
};
|
|
472
530
|
// Should match the sanitized pattern, not the dangerous one
|
|
473
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
531
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
474
532
|
});
|
|
475
|
-
it('should handle toJSON that returns primitives', () => {
|
|
533
|
+
it('should handle toJSON that returns primitives', async () => {
|
|
476
534
|
const rules = [
|
|
477
535
|
{
|
|
478
536
|
toolName: 'test',
|
|
@@ -488,9 +546,9 @@ describe('PolicyEngine', () => {
|
|
|
488
546
|
},
|
|
489
547
|
};
|
|
490
548
|
// toJSON returns a string, which should be properly stringified
|
|
491
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
549
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
492
550
|
});
|
|
493
|
-
it('should handle toJSON that throws an error', () => {
|
|
551
|
+
it('should handle toJSON that throws an error', async () => {
|
|
494
552
|
const rules = [
|
|
495
553
|
{
|
|
496
554
|
toolName: 'test',
|
|
@@ -508,7 +566,333 @@ describe('PolicyEngine', () => {
|
|
|
508
566
|
},
|
|
509
567
|
};
|
|
510
568
|
// Should fall back to regular object serialization when toJSON throws
|
|
511
|
-
expect(engine.check({ name: 'test', args })).toBe(PolicyDecision.ALLOW);
|
|
569
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
describe('safety checker integration', () => {
|
|
573
|
+
it('should call checker when rule allows and has safety_checker', async () => {
|
|
574
|
+
const rules = [
|
|
575
|
+
{
|
|
576
|
+
toolName: 'test-tool',
|
|
577
|
+
decision: PolicyDecision.ALLOW,
|
|
578
|
+
},
|
|
579
|
+
];
|
|
580
|
+
const checkers = [
|
|
581
|
+
{
|
|
582
|
+
toolName: 'test-tool',
|
|
583
|
+
checker: {
|
|
584
|
+
type: 'external',
|
|
585
|
+
name: 'test-checker',
|
|
586
|
+
config: { content: 'test-content' },
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
];
|
|
590
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
591
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
592
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
593
|
+
});
|
|
594
|
+
const result = await engine.check({ name: 'test-tool', args: { foo: 'bar' } }, undefined);
|
|
595
|
+
expect(result.decision).toBe(PolicyDecision.ALLOW);
|
|
596
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledWith({ name: 'test-tool', args: { foo: 'bar' } }, {
|
|
597
|
+
type: 'external',
|
|
598
|
+
name: 'test-checker',
|
|
599
|
+
config: { content: 'test-content' },
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
it('should handle checker errors as DENY', async () => {
|
|
603
|
+
const rules = [
|
|
604
|
+
{
|
|
605
|
+
toolName: 'test',
|
|
606
|
+
decision: PolicyDecision.ALLOW,
|
|
607
|
+
},
|
|
608
|
+
];
|
|
609
|
+
const checkers = [
|
|
610
|
+
{
|
|
611
|
+
toolName: 'test',
|
|
612
|
+
checker: {
|
|
613
|
+
type: 'in-process',
|
|
614
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
];
|
|
618
|
+
mockCheckerRunner.runChecker = vi
|
|
619
|
+
.fn()
|
|
620
|
+
.mockRejectedValue(new Error('Checker failed'));
|
|
621
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
622
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
623
|
+
expect(decision).toBe(PolicyDecision.DENY);
|
|
624
|
+
});
|
|
625
|
+
it('should return DENY when checker denies', async () => {
|
|
626
|
+
const rules = [
|
|
627
|
+
{
|
|
628
|
+
toolName: 'test-tool',
|
|
629
|
+
decision: PolicyDecision.ALLOW,
|
|
630
|
+
},
|
|
631
|
+
];
|
|
632
|
+
const checkers = [
|
|
633
|
+
{
|
|
634
|
+
toolName: 'test-tool',
|
|
635
|
+
checker: {
|
|
636
|
+
type: 'external',
|
|
637
|
+
name: 'test-checker',
|
|
638
|
+
config: { content: 'test-content' },
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
];
|
|
642
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
643
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
644
|
+
decision: SafetyCheckDecision.DENY,
|
|
645
|
+
reason: 'test reason',
|
|
646
|
+
});
|
|
647
|
+
const result = await engine.check({ name: 'test-tool', args: { foo: 'bar' } }, undefined);
|
|
648
|
+
expect(result.decision).toBe(PolicyDecision.DENY);
|
|
649
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalled();
|
|
650
|
+
});
|
|
651
|
+
it('should not call checker if decision is not ALLOW', async () => {
|
|
652
|
+
const rules = [
|
|
653
|
+
{
|
|
654
|
+
toolName: 'test-tool',
|
|
655
|
+
decision: PolicyDecision.ASK_USER,
|
|
656
|
+
},
|
|
657
|
+
];
|
|
658
|
+
const checkers = [
|
|
659
|
+
{
|
|
660
|
+
toolName: 'test-tool',
|
|
661
|
+
checker: {
|
|
662
|
+
type: 'external',
|
|
663
|
+
name: 'test-checker',
|
|
664
|
+
config: { content: 'test-content' },
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
];
|
|
668
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
669
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
670
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
671
|
+
});
|
|
672
|
+
const result = await engine.check({ name: 'test-tool', args: { foo: 'bar' } }, undefined);
|
|
673
|
+
expect(result.decision).toBe(PolicyDecision.ASK_USER);
|
|
674
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalled();
|
|
675
|
+
});
|
|
676
|
+
it('should run checkers when rule allows', async () => {
|
|
677
|
+
const rules = [
|
|
678
|
+
{
|
|
679
|
+
toolName: 'test',
|
|
680
|
+
decision: PolicyDecision.ALLOW,
|
|
681
|
+
},
|
|
682
|
+
];
|
|
683
|
+
const checkers = [
|
|
684
|
+
{
|
|
685
|
+
toolName: 'test',
|
|
686
|
+
checker: {
|
|
687
|
+
type: 'in-process',
|
|
688
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
];
|
|
692
|
+
mockCheckerRunner.runChecker = vi.fn().mockResolvedValue({
|
|
693
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
694
|
+
});
|
|
695
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
696
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
697
|
+
expect(decision).toBe(PolicyDecision.ALLOW);
|
|
698
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledTimes(1);
|
|
699
|
+
});
|
|
700
|
+
it('should not call checker if rule has no safety_checker', async () => {
|
|
701
|
+
const rules = [
|
|
702
|
+
{
|
|
703
|
+
toolName: 'test-tool',
|
|
704
|
+
decision: PolicyDecision.ALLOW,
|
|
705
|
+
},
|
|
706
|
+
];
|
|
707
|
+
engine = new PolicyEngine({ rules }, mockCheckerRunner);
|
|
708
|
+
const result = await engine.check({ name: 'test-tool', args: { foo: 'bar' } }, undefined);
|
|
709
|
+
expect(result.decision).toBe(PolicyDecision.ALLOW);
|
|
710
|
+
expect(mockCheckerRunner.runChecker).not.toHaveBeenCalled();
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
describe('serverName requirement', () => {
|
|
714
|
+
it('should require serverName for checks', async () => {
|
|
715
|
+
// @ts-expect-error - intentionally testing missing serverName
|
|
716
|
+
expect((await engine.check({ name: 'test' })).decision).toBe(PolicyDecision.ASK_USER);
|
|
717
|
+
// When serverName is provided (even undefined), it should work
|
|
718
|
+
expect((await engine.check({ name: 'test' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
719
|
+
expect((await engine.check({ name: 'test' }, 'some-server')).decision).toBe(PolicyDecision.ASK_USER);
|
|
720
|
+
});
|
|
721
|
+
it('should run multiple checkers in priority order and stop at first denial', async () => {
|
|
722
|
+
const rules = [
|
|
723
|
+
{
|
|
724
|
+
toolName: 'test',
|
|
725
|
+
decision: PolicyDecision.ALLOW,
|
|
726
|
+
},
|
|
727
|
+
];
|
|
728
|
+
const checkers = [
|
|
729
|
+
{
|
|
730
|
+
toolName: 'test',
|
|
731
|
+
priority: 10,
|
|
732
|
+
checker: { type: 'external', name: 'checker1' },
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
toolName: 'test',
|
|
736
|
+
priority: 20, // Should run first
|
|
737
|
+
checker: { type: 'external', name: 'checker2' },
|
|
738
|
+
},
|
|
739
|
+
];
|
|
740
|
+
mockCheckerRunner.runChecker = vi
|
|
741
|
+
.fn()
|
|
742
|
+
.mockImplementation(async (_toolCall, config) => {
|
|
743
|
+
if (config.name === 'checker2') {
|
|
744
|
+
return {
|
|
745
|
+
decision: SafetyCheckDecision.DENY,
|
|
746
|
+
reason: 'checker2 denied',
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
return { decision: SafetyCheckDecision.ALLOW };
|
|
750
|
+
});
|
|
751
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
752
|
+
const { decision, rule } = await engine.check({ name: 'test' }, undefined);
|
|
753
|
+
expect(decision).toBe(PolicyDecision.DENY);
|
|
754
|
+
expect(rule).toBeDefined();
|
|
755
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledTimes(1);
|
|
756
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ name: 'checker2' }));
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
describe('addChecker', () => {
|
|
760
|
+
it('should add a new checker and maintain priority order', () => {
|
|
761
|
+
const checker1 = {
|
|
762
|
+
checker: { type: 'external', name: 'checker1' },
|
|
763
|
+
priority: 5,
|
|
764
|
+
};
|
|
765
|
+
const checker2 = {
|
|
766
|
+
checker: { type: 'external', name: 'checker2' },
|
|
767
|
+
priority: 10,
|
|
768
|
+
};
|
|
769
|
+
engine.addChecker(checker1);
|
|
770
|
+
engine.addChecker(checker2);
|
|
771
|
+
const checkers = engine.getCheckers();
|
|
772
|
+
expect(checkers).toHaveLength(2);
|
|
773
|
+
expect(checkers[0].priority).toBe(10);
|
|
774
|
+
expect(checkers[0].checker.name).toBe('checker2');
|
|
775
|
+
expect(checkers[1].priority).toBe(5);
|
|
776
|
+
expect(checkers[1].checker.name).toBe('checker1');
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
describe('checker matching logic', () => {
|
|
780
|
+
it('should match checkers using toolName and argsPattern', async () => {
|
|
781
|
+
const rules = [
|
|
782
|
+
{ toolName: 'tool', decision: PolicyDecision.ALLOW },
|
|
783
|
+
];
|
|
784
|
+
const matchingChecker = {
|
|
785
|
+
checker: { type: 'external', name: 'matching' },
|
|
786
|
+
toolName: 'tool',
|
|
787
|
+
argsPattern: /"safe":true/,
|
|
788
|
+
};
|
|
789
|
+
const nonMatchingChecker = {
|
|
790
|
+
checker: { type: 'external', name: 'non-matching' },
|
|
791
|
+
toolName: 'other',
|
|
792
|
+
};
|
|
793
|
+
engine = new PolicyEngine({ rules, checkers: [matchingChecker, nonMatchingChecker] }, mockCheckerRunner);
|
|
794
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
795
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
796
|
+
});
|
|
797
|
+
await engine.check({ name: 'tool', args: { safe: true } }, undefined);
|
|
798
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ name: 'matching' }));
|
|
799
|
+
expect(mockCheckerRunner.runChecker).not.toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ name: 'non-matching' }));
|
|
800
|
+
});
|
|
801
|
+
it('should support wildcard patterns for checkers', async () => {
|
|
802
|
+
const rules = [
|
|
803
|
+
{ toolName: 'server__tool', decision: PolicyDecision.ALLOW },
|
|
804
|
+
];
|
|
805
|
+
const wildcardChecker = {
|
|
806
|
+
checker: { type: 'external', name: 'wildcard' },
|
|
807
|
+
toolName: 'server__*',
|
|
808
|
+
};
|
|
809
|
+
engine = new PolicyEngine({ rules, checkers: [wildcardChecker] }, mockCheckerRunner);
|
|
810
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
811
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
812
|
+
});
|
|
813
|
+
await engine.check({ name: 'server__tool' }, 'server');
|
|
814
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ name: 'wildcard' }));
|
|
815
|
+
});
|
|
816
|
+
it('should run safety checkers when decision is ASK_USER and downgrade to DENY on failure', async () => {
|
|
817
|
+
const rules = [
|
|
818
|
+
{ toolName: 'tool', decision: PolicyDecision.ASK_USER },
|
|
819
|
+
];
|
|
820
|
+
const checkers = [
|
|
821
|
+
{
|
|
822
|
+
checker: {
|
|
823
|
+
type: 'in-process',
|
|
824
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
825
|
+
},
|
|
826
|
+
},
|
|
827
|
+
];
|
|
828
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
829
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
830
|
+
decision: SafetyCheckDecision.DENY,
|
|
831
|
+
reason: 'Safety check failed',
|
|
832
|
+
});
|
|
833
|
+
const result = await engine.check({ name: 'tool' }, undefined);
|
|
834
|
+
expect(result.decision).toBe(PolicyDecision.DENY);
|
|
835
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalled();
|
|
836
|
+
});
|
|
837
|
+
it('should run safety checkers when decision is ASK_USER and keep ASK_USER on success', async () => {
|
|
838
|
+
const rules = [
|
|
839
|
+
{ toolName: 'tool', decision: PolicyDecision.ASK_USER },
|
|
840
|
+
];
|
|
841
|
+
const checkers = [
|
|
842
|
+
{
|
|
843
|
+
checker: {
|
|
844
|
+
type: 'in-process',
|
|
845
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
846
|
+
},
|
|
847
|
+
},
|
|
848
|
+
];
|
|
849
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
850
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
851
|
+
decision: SafetyCheckDecision.ALLOW,
|
|
852
|
+
});
|
|
853
|
+
const result = await engine.check({ name: 'tool' }, undefined);
|
|
854
|
+
expect(result.decision).toBe(PolicyDecision.ASK_USER);
|
|
855
|
+
expect(mockCheckerRunner.runChecker).toHaveBeenCalled();
|
|
856
|
+
});
|
|
857
|
+
it('should downgrade ALLOW to ASK_USER if checker returns ASK_USER', async () => {
|
|
858
|
+
const rules = [
|
|
859
|
+
{ toolName: 'tool', decision: PolicyDecision.ALLOW },
|
|
860
|
+
];
|
|
861
|
+
const checkers = [
|
|
862
|
+
{
|
|
863
|
+
checker: {
|
|
864
|
+
type: 'in-process',
|
|
865
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
866
|
+
},
|
|
867
|
+
},
|
|
868
|
+
];
|
|
869
|
+
engine = new PolicyEngine({ rules, checkers }, mockCheckerRunner);
|
|
870
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
871
|
+
decision: SafetyCheckDecision.ASK_USER,
|
|
872
|
+
reason: 'Suspicious path',
|
|
873
|
+
});
|
|
874
|
+
const result = await engine.check({ name: 'tool' }, undefined);
|
|
875
|
+
expect(result.decision).toBe(PolicyDecision.ASK_USER);
|
|
876
|
+
});
|
|
877
|
+
it('should DENY if checker returns ASK_USER in non-interactive mode', async () => {
|
|
878
|
+
const rules = [
|
|
879
|
+
{ toolName: 'tool', decision: PolicyDecision.ALLOW },
|
|
880
|
+
];
|
|
881
|
+
const checkers = [
|
|
882
|
+
{
|
|
883
|
+
checker: {
|
|
884
|
+
type: 'in-process',
|
|
885
|
+
name: InProcessCheckerType.ALLOWED_PATH,
|
|
886
|
+
},
|
|
887
|
+
},
|
|
888
|
+
];
|
|
889
|
+
engine = new PolicyEngine({ rules, checkers, nonInteractive: true }, mockCheckerRunner);
|
|
890
|
+
vi.mocked(mockCheckerRunner.runChecker).mockResolvedValue({
|
|
891
|
+
decision: SafetyCheckDecision.ASK_USER,
|
|
892
|
+
reason: 'Suspicious path',
|
|
893
|
+
});
|
|
894
|
+
const result = await engine.check({ name: 'tool' }, undefined);
|
|
895
|
+
expect(result.decision).toBe(PolicyDecision.DENY);
|
|
512
896
|
});
|
|
513
897
|
});
|
|
514
898
|
});
|