@office-ai/aioncli-core 0.2.3 → 0.18.4
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 +16 -3
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +132 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -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 +114 -0
- package/dist/src/agents/executor.js +779 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.js +1362 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +40 -0
- package/dist/src/agents/registry.js +105 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +160 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +110 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +146 -0
- package/dist/src/agents/types.js +19 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +13 -1
- package/dist/src/code_assist/codeAssist.js.map +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 +5 -1
- package/dist/src/code_assist/converter.js +39 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +112 -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.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +110 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +198 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +3 -3
- package/dist/src/code_assist/oauth2.js +252 -125
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +788 -350
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +8 -6
- package/dist/src/code_assist/server.js +41 -10
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +151 -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 +5 -3
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +18 -3
- 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 +282 -60
- package/dist/src/config/config.js +677 -129
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +1020 -146
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- 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 +37 -0
- package/dist/src/config/models.js +72 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +116 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +36 -0
- package/dist/src/config/storage.js +115 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +48 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +18 -0
- package/dist/src/confirmation-bus/message-bus.js +87 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +170 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +49 -0
- package/dist/src/confirmation-bus/types.js +16 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- 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 +50 -0
- package/dist/src/core/baseLlmClient.js +185 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +311 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +30 -42
- package/dist/src/core/client.js +178 -477
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +739 -617
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +7 -6
- package/dist/src/core/contentGenerator.js +59 -45
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +50 -4
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +28 -11
- package/dist/src/core/coreToolScheduler.js +493 -161
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +995 -163
- 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 +61 -55
- package/dist/src/core/geminiChat.js +388 -366
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1600 -355
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +11 -4
- package/dist/src/core/logger.js +39 -30
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +62 -45
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +4 -3
- package/dist/src/core/loggingContentGenerator.js +116 -37
- 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 +4 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -120
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +168 -84
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +4 -3
- package/dist/src/core/openaiContentGenerator.js +49 -19
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +1 -0
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +7 -1
- package/dist/src/core/prompts.js +198 -195
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +172 -104
- 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/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +125 -90
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +59 -44
- package/dist/src/core/subagent.test.js.map +1 -1
- 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 +57 -13
- package/dist/src/core/turn.js +79 -35
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +373 -120
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +181 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +245 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- 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/constants.d.ts +3 -0
- package/dist/src/ide/constants.js +3 -0
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +52 -12
- package/dist/src/ide/detect-ide.js +51 -65
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +95 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +72 -24
- package/dist/src/ide/ide-client.js +380 -84
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +539 -35
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +93 -35
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +157 -26
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +35 -365
- package/dist/src/ide/ideContext.js +60 -106
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +152 -24
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +7 -5
- package/dist/src/ide/process-utils.js +108 -67
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +151 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +41 -2
- package/dist/src/index.js +44 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +5 -3
- 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 +25 -18
- package/dist/src/mcp/oauth-provider.js +194 -97
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +581 -39
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +14 -32
- package/dist/src/mcp/oauth-token-storage.js +58 -28
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +262 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +16 -1
- package/dist/src/mcp/oauth-utils.js +68 -33
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +86 -3
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
- package/dist/src/mcp/sa-impersonation-provider.js +113 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +151 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +145 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +238 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +305 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +44 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- 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 +82 -0
- package/dist/src/output/types.js +22 -0
- package/dist/src/output/types.js.map +1 -0
- 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 +9 -0
- package/dist/src/policy/index.js +10 -0
- package/dist/src/policy/index.js.map +1 -0
- 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 +39 -0
- package/dist/src/policy/policy-engine.js +158 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +899 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- 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 +130 -0
- package/dist/src/policy/types.js +22 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- 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.d.ts +1 -1
- 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.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +85 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +160 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +166 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +196 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +68 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +59 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +45 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- 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 +10 -15
- package/dist/src/services/chatRecordingService.js +43 -29
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +69 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +8 -10
- package/dist/src/services/fileDiscoveryService.js +31 -53
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +94 -14
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +12 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +30 -24
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +30 -37
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +12 -3
- package/dist/src/services/loopDetectionService.js +148 -55
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +280 -21
- 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 +37 -2
- package/dist/src/services/shellExecutionService.js +361 -67
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +333 -71
- 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-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -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/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +53 -5
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +581 -56
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +2 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +467 -31
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +75 -4
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +182 -6
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +76 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +0 -18
- package/dist/src/telemetry/constants.js +0 -18
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +116 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +16 -2
- package/dist/src/telemetry/index.js +25 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +25 -3
- package/dist/src/telemetry/loggers.js +333 -154
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -4
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +868 -63
- 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 +498 -11
- package/dist/src/telemetry/metrics.js +729 -84
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +964 -101
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +23 -4
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +108 -0
- package/dist/src/telemetry/sdk.test.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.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +41 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- 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 +351 -25
- package/dist/src/telemetry/types.js +1071 -63
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +4 -4
- package/dist/src/telemetry/uiTelemetry.js +14 -15
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +122 -96
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +3 -2
- package/dist/src/test-utils/config.js +1 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +66 -0
- package/dist/src/test-utils/{tools.js → mock-tool.js} +45 -29
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +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/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +10 -8
- package/dist/src/tools/edit.js +100 -79
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +429 -163
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +11 -5
- package/dist/src/tools/glob.js +58 -42
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +249 -166
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +7 -5
- package/dist/src/tools/grep.js +66 -40
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +41 -15
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +7 -5
- package/dist/src/tools/ls.js +54 -68
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +150 -293
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +52 -12
- package/dist/src/tools/mcp-client-manager.js +196 -27
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +139 -13
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +28 -24
- package/dist/src/tools/mcp-client.js +338 -351
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +380 -193
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +11 -5
- package/dist/src/tools/mcp-tool.js +66 -17
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +278 -211
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +10 -7
- package/dist/src/tools/memoryTool.js +28 -49
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +26 -13
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +196 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +7 -3
- package/dist/src/tools/modifiable-tool.js +41 -19
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +70 -35
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +9 -7
- package/dist/src/tools/read-file.js +39 -60
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +103 -36
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +9 -14
- package/dist/src/tools/read-many-files.js +71 -155
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +98 -44
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +73 -0
- package/dist/src/tools/ripGrep.js +395 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +1305 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +19 -6
- package/dist/src/tools/shell.js +92 -56
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +176 -103
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +78 -0
- package/dist/src/tools/smart-edit.js +717 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +592 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +39 -1
- package/dist/src/tools/tool-error.js +54 -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 +38 -20
- package/dist/src/tools/tool-registry.js +134 -77
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +218 -58
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +49 -17
- package/dist/src/tools/tools.js +150 -8
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +14 -5
- package/dist/src/tools/web-fetch.js +90 -44
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +388 -20
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +8 -6
- package/dist/src/tools/web-search.js +40 -15
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +75 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +7 -5
- package/dist/src/tools/write-file.js +54 -54
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +237 -146
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +50 -0
- package/dist/src/tools/write-todos.js +193 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +16 -9
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.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.d.ts +9 -8
- package/dist/src/utils/editCorrector.js +62 -34
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +52 -87
- 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 +56 -55
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +47 -88
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +3 -2
- 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/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +28 -0
- package/dist/src/utils/errors.js +48 -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 +5 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +28 -12
- package/dist/src/utils/fileUtils.js +204 -81
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +426 -82
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +103 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- 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/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +12 -20
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +11 -10
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +7 -8
- package/dist/src/utils/gitIgnoreParser.js +145 -36
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +127 -38
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.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.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +246 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +51 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +85 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +155 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +223 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +26 -6
- package/dist/src/utils/memoryDiscovery.js +239 -40
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +365 -44
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +19 -25
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +24 -155
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +3 -3
- package/dist/src/utils/nextSpeakerChecker.js +10 -4
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +85 -66
- 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/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- 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.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +406 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +133 -57
- 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/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -3
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +5 -10
- package/dist/src/utils/retry.js +114 -197
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +196 -130
- 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/schemaValidator.js +15 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +21 -3
- package/dist/src/utils/shell-utils.js +427 -159
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +250 -59
- 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 +6 -4
- 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 +7 -6
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +4 -3
- 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/terminalSerializer.d.ts +25 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +5 -0
- package/dist/src/utils/textUtils.js +14 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +67 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +69 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +115 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +41 -36
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +23 -17
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +45 -19
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -10
- package/dist/src/core/modelCheck.d.ts +0 -14
- package/dist/src/core/modelCheck.js +0 -62
- package/dist/src/core/modelCheck.js.map +0 -1
- package/dist/src/test-utils/tools.d.ts +0 -44
- package/dist/src/test-utils/tools.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.js +0 -118
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/flashFallback.integration.test.d.ts → agents/codebase-investigator.test.d.ts} +0 -0
- /package/dist/src/{utils/user_account.test.d.ts → agents/executor.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → agents/invocation.test.d.ts} +0 -0
|
@@ -0,0 +1,899 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
7
|
+
import { PolicyEngine } from './policy-engine.js';
|
|
8
|
+
import { PolicyDecision, InProcessCheckerType, } from './types.js';
|
|
9
|
+
import { SafetyCheckDecision } from '../safety/protocol.js';
|
|
10
|
+
describe('PolicyEngine', () => {
|
|
11
|
+
let engine;
|
|
12
|
+
let mockCheckerRunner;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockCheckerRunner = {
|
|
15
|
+
runChecker: vi.fn(),
|
|
16
|
+
};
|
|
17
|
+
engine = new PolicyEngine({}, mockCheckerRunner);
|
|
18
|
+
});
|
|
19
|
+
describe('constructor', () => {
|
|
20
|
+
it('should use default config when none provided', async () => {
|
|
21
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
22
|
+
expect(decision).toBe(PolicyDecision.ASK_USER);
|
|
23
|
+
});
|
|
24
|
+
it('should respect custom default decision', async () => {
|
|
25
|
+
engine = new PolicyEngine({ defaultDecision: PolicyDecision.DENY });
|
|
26
|
+
const { decision } = await engine.check({ name: 'test' }, undefined);
|
|
27
|
+
expect(decision).toBe(PolicyDecision.DENY);
|
|
28
|
+
});
|
|
29
|
+
it('should sort rules by priority', () => {
|
|
30
|
+
const rules = [
|
|
31
|
+
{ toolName: 'tool1', decision: PolicyDecision.DENY, priority: 1 },
|
|
32
|
+
{ toolName: 'tool2', decision: PolicyDecision.ALLOW, priority: 10 },
|
|
33
|
+
{ toolName: 'tool3', decision: PolicyDecision.ASK_USER, priority: 5 },
|
|
34
|
+
];
|
|
35
|
+
engine = new PolicyEngine({ rules });
|
|
36
|
+
const sortedRules = engine.getRules();
|
|
37
|
+
expect(sortedRules[0].priority).toBe(10);
|
|
38
|
+
expect(sortedRules[1].priority).toBe(5);
|
|
39
|
+
expect(sortedRules[2].priority).toBe(1);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('check', () => {
|
|
43
|
+
it('should match tool by name', async () => {
|
|
44
|
+
const rules = [
|
|
45
|
+
{ toolName: 'shell', decision: PolicyDecision.ALLOW },
|
|
46
|
+
{ toolName: 'edit', decision: PolicyDecision.DENY },
|
|
47
|
+
];
|
|
48
|
+
engine = new PolicyEngine({ rules });
|
|
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);
|
|
52
|
+
});
|
|
53
|
+
it('should match by args pattern', async () => {
|
|
54
|
+
const rules = [
|
|
55
|
+
{
|
|
56
|
+
toolName: 'shell',
|
|
57
|
+
argsPattern: /rm -rf/,
|
|
58
|
+
decision: PolicyDecision.DENY,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
toolName: 'shell',
|
|
62
|
+
decision: PolicyDecision.ALLOW,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
engine = new PolicyEngine({ rules });
|
|
66
|
+
const dangerousCall = {
|
|
67
|
+
name: 'shell',
|
|
68
|
+
args: { command: 'rm -rf /' },
|
|
69
|
+
};
|
|
70
|
+
const safeCall = {
|
|
71
|
+
name: 'shell',
|
|
72
|
+
args: { command: 'ls -la' },
|
|
73
|
+
};
|
|
74
|
+
expect((await engine.check(dangerousCall, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
75
|
+
expect((await engine.check(safeCall, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
76
|
+
});
|
|
77
|
+
it('should apply rules by priority', async () => {
|
|
78
|
+
const rules = [
|
|
79
|
+
{ toolName: 'shell', decision: PolicyDecision.DENY, priority: 1 },
|
|
80
|
+
{ toolName: 'shell', decision: PolicyDecision.ALLOW, priority: 10 },
|
|
81
|
+
];
|
|
82
|
+
engine = new PolicyEngine({ rules });
|
|
83
|
+
// Higher priority rule (ALLOW) should win
|
|
84
|
+
expect((await engine.check({ name: 'shell' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
85
|
+
});
|
|
86
|
+
it('should apply wildcard rules (no toolName)', async () => {
|
|
87
|
+
const rules = [
|
|
88
|
+
{ decision: PolicyDecision.DENY }, // Applies to all tools
|
|
89
|
+
{ toolName: 'safe-tool', decision: PolicyDecision.ALLOW, priority: 10 },
|
|
90
|
+
];
|
|
91
|
+
engine = new PolicyEngine({ rules });
|
|
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);
|
|
94
|
+
});
|
|
95
|
+
it('should handle non-interactive mode', async () => {
|
|
96
|
+
const config = {
|
|
97
|
+
nonInteractive: true,
|
|
98
|
+
rules: [
|
|
99
|
+
{ toolName: 'interactive-tool', decision: PolicyDecision.ASK_USER },
|
|
100
|
+
{ toolName: 'allowed-tool', decision: PolicyDecision.ALLOW },
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
engine = new PolicyEngine(config);
|
|
104
|
+
// ASK_USER should become DENY in non-interactive mode
|
|
105
|
+
expect((await engine.check({ name: 'interactive-tool' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
106
|
+
// ALLOW should remain ALLOW
|
|
107
|
+
expect((await engine.check({ name: 'allowed-tool' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
108
|
+
// Default ASK_USER should also become DENY
|
|
109
|
+
expect((await engine.check({ name: 'unknown-tool' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe('addRule', () => {
|
|
113
|
+
it('should add a new rule and maintain priority order', () => {
|
|
114
|
+
engine.addRule({
|
|
115
|
+
toolName: 'tool1',
|
|
116
|
+
decision: PolicyDecision.ALLOW,
|
|
117
|
+
priority: 5,
|
|
118
|
+
});
|
|
119
|
+
engine.addRule({
|
|
120
|
+
toolName: 'tool2',
|
|
121
|
+
decision: PolicyDecision.DENY,
|
|
122
|
+
priority: 10,
|
|
123
|
+
});
|
|
124
|
+
engine.addRule({
|
|
125
|
+
toolName: 'tool3',
|
|
126
|
+
decision: PolicyDecision.ASK_USER,
|
|
127
|
+
priority: 1,
|
|
128
|
+
});
|
|
129
|
+
const rules = engine.getRules();
|
|
130
|
+
expect(rules).toHaveLength(3);
|
|
131
|
+
expect(rules[0].priority).toBe(10);
|
|
132
|
+
expect(rules[1].priority).toBe(5);
|
|
133
|
+
expect(rules[2].priority).toBe(1);
|
|
134
|
+
});
|
|
135
|
+
it('should apply newly added rules', async () => {
|
|
136
|
+
expect((await engine.check({ name: 'new-tool' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
137
|
+
engine.addRule({ toolName: 'new-tool', decision: PolicyDecision.ALLOW });
|
|
138
|
+
expect((await engine.check({ name: 'new-tool' }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
describe('removeRulesForTool', () => {
|
|
142
|
+
it('should remove rules for specific tool', () => {
|
|
143
|
+
engine.addRule({ toolName: 'tool1', decision: PolicyDecision.ALLOW });
|
|
144
|
+
engine.addRule({ toolName: 'tool2', decision: PolicyDecision.DENY });
|
|
145
|
+
engine.addRule({
|
|
146
|
+
toolName: 'tool1',
|
|
147
|
+
decision: PolicyDecision.ASK_USER,
|
|
148
|
+
priority: 10,
|
|
149
|
+
});
|
|
150
|
+
expect(engine.getRules()).toHaveLength(3);
|
|
151
|
+
engine.removeRulesForTool('tool1');
|
|
152
|
+
const remainingRules = engine.getRules();
|
|
153
|
+
expect(remainingRules).toHaveLength(1);
|
|
154
|
+
expect(remainingRules.some((r) => r.toolName === 'tool1')).toBe(false);
|
|
155
|
+
expect(remainingRules.some((r) => r.toolName === 'tool2')).toBe(true);
|
|
156
|
+
});
|
|
157
|
+
it('should handle removing non-existent tool', () => {
|
|
158
|
+
engine.addRule({ toolName: 'existing', decision: PolicyDecision.ALLOW });
|
|
159
|
+
expect(() => engine.removeRulesForTool('non-existent')).not.toThrow();
|
|
160
|
+
expect(engine.getRules()).toHaveLength(1);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
describe('getRules', () => {
|
|
164
|
+
it('should return readonly array of rules', () => {
|
|
165
|
+
const rules = [
|
|
166
|
+
{ toolName: 'tool1', decision: PolicyDecision.ALLOW },
|
|
167
|
+
{ toolName: 'tool2', decision: PolicyDecision.DENY },
|
|
168
|
+
];
|
|
169
|
+
engine = new PolicyEngine({ rules });
|
|
170
|
+
const retrievedRules = engine.getRules();
|
|
171
|
+
expect(retrievedRules).toHaveLength(2);
|
|
172
|
+
expect(retrievedRules[0].toolName).toBe('tool1');
|
|
173
|
+
expect(retrievedRules[1].toolName).toBe('tool2');
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe('MCP server wildcard patterns', () => {
|
|
177
|
+
it('should match MCP server wildcard patterns', async () => {
|
|
178
|
+
const rules = [
|
|
179
|
+
{
|
|
180
|
+
toolName: 'my-server__*',
|
|
181
|
+
decision: PolicyDecision.ALLOW,
|
|
182
|
+
priority: 10,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
toolName: 'blocked-server__*',
|
|
186
|
+
decision: PolicyDecision.DENY,
|
|
187
|
+
priority: 20,
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
engine = new PolicyEngine({ rules });
|
|
191
|
+
// Should match my-server tools
|
|
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);
|
|
195
|
+
// Should match blocked-server tools
|
|
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);
|
|
200
|
+
// Should not match other patterns
|
|
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
|
|
205
|
+
});
|
|
206
|
+
it('should prioritize specific tool rules over server wildcards', async () => {
|
|
207
|
+
const rules = [
|
|
208
|
+
{
|
|
209
|
+
toolName: 'my-server__*',
|
|
210
|
+
decision: PolicyDecision.ALLOW,
|
|
211
|
+
priority: 10,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
toolName: 'my-server__dangerous-tool',
|
|
215
|
+
decision: PolicyDecision.DENY,
|
|
216
|
+
priority: 20,
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
engine = new PolicyEngine({ rules });
|
|
220
|
+
// Specific tool deny should override server allow
|
|
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);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
describe('complex scenarios', () => {
|
|
268
|
+
it('should handle multiple matching rules with different priorities', async () => {
|
|
269
|
+
const rules = [
|
|
270
|
+
{ decision: PolicyDecision.DENY, priority: 0 }, // Default deny all
|
|
271
|
+
{ toolName: 'shell', decision: PolicyDecision.ASK_USER, priority: 5 },
|
|
272
|
+
{
|
|
273
|
+
toolName: 'shell',
|
|
274
|
+
argsPattern: /"command":"ls/,
|
|
275
|
+
decision: PolicyDecision.ALLOW,
|
|
276
|
+
priority: 10,
|
|
277
|
+
},
|
|
278
|
+
];
|
|
279
|
+
engine = new PolicyEngine({ rules });
|
|
280
|
+
// Matches highest priority rule (ls command)
|
|
281
|
+
expect((await engine.check({ name: 'shell', args: { command: 'ls -la' } }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
282
|
+
// Matches middle priority rule (shell without ls)
|
|
283
|
+
expect((await engine.check({ name: 'shell', args: { command: 'pwd' } }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
284
|
+
// Matches lowest priority rule (not shell)
|
|
285
|
+
expect((await engine.check({ name: 'edit' }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
286
|
+
});
|
|
287
|
+
it('should handle tools with no args', async () => {
|
|
288
|
+
const rules = [
|
|
289
|
+
{
|
|
290
|
+
toolName: 'read',
|
|
291
|
+
argsPattern: /secret/,
|
|
292
|
+
decision: PolicyDecision.DENY,
|
|
293
|
+
},
|
|
294
|
+
];
|
|
295
|
+
engine = new PolicyEngine({ rules });
|
|
296
|
+
// Tool call without args should not match pattern
|
|
297
|
+
expect((await engine.check({ name: 'read' }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
298
|
+
// Tool call with args not matching pattern
|
|
299
|
+
expect((await engine.check({ name: 'read', args: { file: 'public.txt' } }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
300
|
+
// Tool call with args matching pattern
|
|
301
|
+
expect((await engine.check({ name: 'read', args: { file: 'secret.txt' } }, undefined)).decision).toBe(PolicyDecision.DENY);
|
|
302
|
+
});
|
|
303
|
+
it('should match args pattern regardless of property order', async () => {
|
|
304
|
+
const rules = [
|
|
305
|
+
{
|
|
306
|
+
toolName: 'shell',
|
|
307
|
+
// Pattern matches the stable stringified format
|
|
308
|
+
argsPattern: /"command":"rm[^"]*-rf/,
|
|
309
|
+
decision: PolicyDecision.DENY,
|
|
310
|
+
},
|
|
311
|
+
];
|
|
312
|
+
engine = new PolicyEngine({ rules });
|
|
313
|
+
// Same args with different property order should both match
|
|
314
|
+
const args1 = { command: 'rm -rf /', path: '/home' };
|
|
315
|
+
const args2 = { path: '/home', command: 'rm -rf /' };
|
|
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);
|
|
320
|
+
// Verify safe command doesn't match
|
|
321
|
+
const safeArgs = { command: 'ls -la', path: '/home' };
|
|
322
|
+
expect((await engine.check({ name: 'shell', args: safeArgs }, undefined))
|
|
323
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
324
|
+
});
|
|
325
|
+
it('should handle nested objects in args with stable stringification', async () => {
|
|
326
|
+
const rules = [
|
|
327
|
+
{
|
|
328
|
+
toolName: 'api',
|
|
329
|
+
argsPattern: /"sensitive":true/,
|
|
330
|
+
decision: PolicyDecision.DENY,
|
|
331
|
+
},
|
|
332
|
+
];
|
|
333
|
+
engine = new PolicyEngine({ rules });
|
|
334
|
+
// Nested objects with different key orders should match consistently
|
|
335
|
+
const args1 = {
|
|
336
|
+
data: { sensitive: true, value: 'secret' },
|
|
337
|
+
method: 'POST',
|
|
338
|
+
};
|
|
339
|
+
const args2 = {
|
|
340
|
+
method: 'POST',
|
|
341
|
+
data: { value: 'secret', sensitive: true },
|
|
342
|
+
};
|
|
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);
|
|
345
|
+
});
|
|
346
|
+
it('should handle circular references without stack overflow', async () => {
|
|
347
|
+
const rules = [
|
|
348
|
+
{
|
|
349
|
+
toolName: 'test',
|
|
350
|
+
argsPattern: /\[Circular\]/,
|
|
351
|
+
decision: PolicyDecision.DENY,
|
|
352
|
+
},
|
|
353
|
+
];
|
|
354
|
+
engine = new PolicyEngine({ rules });
|
|
355
|
+
const circularArgs = {
|
|
356
|
+
name: 'test',
|
|
357
|
+
data: {},
|
|
358
|
+
};
|
|
359
|
+
// Create circular reference - TypeScript allows this since data is Record<string, unknown>
|
|
360
|
+
circularArgs.data['self'] =
|
|
361
|
+
circularArgs.data;
|
|
362
|
+
// Should not throw stack overflow error
|
|
363
|
+
await expect(engine.check({ name: 'test', args: circularArgs }, undefined)).resolves.not.toThrow();
|
|
364
|
+
// Should detect the circular reference pattern
|
|
365
|
+
expect((await engine.check({ name: 'test', args: circularArgs }, undefined))
|
|
366
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
367
|
+
// Non-circular object should not match
|
|
368
|
+
const normalArgs = { name: 'test', data: { value: 'normal' } };
|
|
369
|
+
expect((await engine.check({ name: 'test', args: normalArgs }, undefined))
|
|
370
|
+
.decision).toBe(PolicyDecision.ASK_USER);
|
|
371
|
+
});
|
|
372
|
+
it('should handle deep circular references', async () => {
|
|
373
|
+
const rules = [
|
|
374
|
+
{
|
|
375
|
+
toolName: 'deep',
|
|
376
|
+
argsPattern: /\[Circular\]/,
|
|
377
|
+
decision: PolicyDecision.DENY,
|
|
378
|
+
},
|
|
379
|
+
];
|
|
380
|
+
engine = new PolicyEngine({ rules });
|
|
381
|
+
const deepCircular = {
|
|
382
|
+
level1: {
|
|
383
|
+
level2: {
|
|
384
|
+
level3: {},
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
// Create circular reference with proper type assertions
|
|
389
|
+
const level3 = deepCircular.level1.level2.level3;
|
|
390
|
+
level3['back'] = deepCircular.level1;
|
|
391
|
+
// Should handle without stack overflow
|
|
392
|
+
await expect(engine.check({ name: 'deep', args: deepCircular }, undefined)).resolves.not.toThrow();
|
|
393
|
+
// Should detect the circular reference
|
|
394
|
+
expect((await engine.check({ name: 'deep', args: deepCircular }, undefined))
|
|
395
|
+
.decision).toBe(PolicyDecision.DENY);
|
|
396
|
+
});
|
|
397
|
+
it('should handle repeated non-circular objects correctly', async () => {
|
|
398
|
+
const rules = [
|
|
399
|
+
{
|
|
400
|
+
toolName: 'test',
|
|
401
|
+
argsPattern: /\[Circular\]/,
|
|
402
|
+
decision: PolicyDecision.DENY,
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
toolName: 'test',
|
|
406
|
+
argsPattern: /"value":"shared"/,
|
|
407
|
+
decision: PolicyDecision.ALLOW,
|
|
408
|
+
priority: 10,
|
|
409
|
+
},
|
|
410
|
+
];
|
|
411
|
+
engine = new PolicyEngine({ rules });
|
|
412
|
+
// Create an object with repeated references but no cycles
|
|
413
|
+
const sharedObj = { value: 'shared' };
|
|
414
|
+
const args = {
|
|
415
|
+
first: sharedObj,
|
|
416
|
+
second: sharedObj,
|
|
417
|
+
third: { nested: sharedObj },
|
|
418
|
+
};
|
|
419
|
+
// Should NOT mark repeated objects as circular, and should match the shared value pattern
|
|
420
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
421
|
+
});
|
|
422
|
+
it('should omit undefined and function values from objects', async () => {
|
|
423
|
+
const rules = [
|
|
424
|
+
{
|
|
425
|
+
toolName: 'test',
|
|
426
|
+
argsPattern: /"definedValue":"test"/,
|
|
427
|
+
decision: PolicyDecision.ALLOW,
|
|
428
|
+
},
|
|
429
|
+
];
|
|
430
|
+
engine = new PolicyEngine({ rules });
|
|
431
|
+
const args = {
|
|
432
|
+
definedValue: 'test',
|
|
433
|
+
undefinedValue: undefined,
|
|
434
|
+
functionValue: () => 'hello',
|
|
435
|
+
nullValue: null,
|
|
436
|
+
};
|
|
437
|
+
// Should match pattern with defined value, undefined and functions omitted
|
|
438
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
439
|
+
// Check that the pattern would NOT match if undefined was included
|
|
440
|
+
const rulesWithUndefined = [
|
|
441
|
+
{
|
|
442
|
+
toolName: 'test',
|
|
443
|
+
argsPattern: /undefinedValue/,
|
|
444
|
+
decision: PolicyDecision.DENY,
|
|
445
|
+
},
|
|
446
|
+
];
|
|
447
|
+
engine = new PolicyEngine({ rules: rulesWithUndefined });
|
|
448
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
449
|
+
// Check that the pattern would NOT match if function was included
|
|
450
|
+
const rulesWithFunction = [
|
|
451
|
+
{
|
|
452
|
+
toolName: 'test',
|
|
453
|
+
argsPattern: /functionValue/,
|
|
454
|
+
decision: PolicyDecision.DENY,
|
|
455
|
+
},
|
|
456
|
+
];
|
|
457
|
+
engine = new PolicyEngine({ rules: rulesWithFunction });
|
|
458
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ASK_USER);
|
|
459
|
+
});
|
|
460
|
+
it('should convert undefined and functions to null in arrays', async () => {
|
|
461
|
+
const rules = [
|
|
462
|
+
{
|
|
463
|
+
toolName: 'test',
|
|
464
|
+
argsPattern: /\["value",null,null,null\]/,
|
|
465
|
+
decision: PolicyDecision.ALLOW,
|
|
466
|
+
},
|
|
467
|
+
];
|
|
468
|
+
engine = new PolicyEngine({ rules });
|
|
469
|
+
const args = {
|
|
470
|
+
array: ['value', undefined, () => 'hello', null],
|
|
471
|
+
};
|
|
472
|
+
// Should match pattern with undefined and functions converted to null
|
|
473
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
474
|
+
});
|
|
475
|
+
it('should produce valid JSON for all inputs', async () => {
|
|
476
|
+
const testCases = [
|
|
477
|
+
{ input: { simple: 'string' }, desc: 'simple object' },
|
|
478
|
+
{
|
|
479
|
+
input: { nested: { deep: { value: 123 } } },
|
|
480
|
+
desc: 'nested object',
|
|
481
|
+
},
|
|
482
|
+
{ input: { data: [1, 2, 3] }, desc: 'simple array' },
|
|
483
|
+
{ input: { mixed: [1, { a: 'b' }, null] }, desc: 'mixed array' },
|
|
484
|
+
{
|
|
485
|
+
input: { undef: undefined, func: () => { }, normal: 'value' },
|
|
486
|
+
desc: 'object with undefined and function',
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
input: { data: ['a', undefined, () => { }, null] },
|
|
490
|
+
desc: 'array with undefined and function',
|
|
491
|
+
},
|
|
492
|
+
];
|
|
493
|
+
for (const { input } of testCases) {
|
|
494
|
+
const rules = [
|
|
495
|
+
{
|
|
496
|
+
toolName: 'test',
|
|
497
|
+
argsPattern: /.*/,
|
|
498
|
+
decision: PolicyDecision.ALLOW,
|
|
499
|
+
},
|
|
500
|
+
];
|
|
501
|
+
engine = new PolicyEngine({ rules });
|
|
502
|
+
// Should not throw when checking (which internally uses stableStringify)
|
|
503
|
+
await expect(engine.check({ name: 'test', args: input }, undefined)).resolves.not.toThrow();
|
|
504
|
+
// The check should succeed
|
|
505
|
+
expect((await engine.check({ name: 'test', args: input }, undefined))
|
|
506
|
+
.decision).toBe(PolicyDecision.ALLOW);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
it('should respect toJSON methods on objects', async () => {
|
|
510
|
+
const rules = [
|
|
511
|
+
{
|
|
512
|
+
toolName: 'test',
|
|
513
|
+
argsPattern: /"sanitized":"safe"/,
|
|
514
|
+
decision: PolicyDecision.ALLOW,
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
toolName: 'test',
|
|
518
|
+
argsPattern: /"dangerous":"data"/,
|
|
519
|
+
decision: PolicyDecision.DENY,
|
|
520
|
+
},
|
|
521
|
+
];
|
|
522
|
+
engine = new PolicyEngine({ rules });
|
|
523
|
+
// Object with toJSON that sanitizes output
|
|
524
|
+
const args = {
|
|
525
|
+
data: {
|
|
526
|
+
dangerous: 'data',
|
|
527
|
+
toJSON: () => ({ sanitized: 'safe' }),
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
// Should match the sanitized pattern, not the dangerous one
|
|
531
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
532
|
+
});
|
|
533
|
+
it('should handle toJSON that returns primitives', async () => {
|
|
534
|
+
const rules = [
|
|
535
|
+
{
|
|
536
|
+
toolName: 'test',
|
|
537
|
+
argsPattern: /"value":"string-value"/,
|
|
538
|
+
decision: PolicyDecision.ALLOW,
|
|
539
|
+
},
|
|
540
|
+
];
|
|
541
|
+
engine = new PolicyEngine({ rules });
|
|
542
|
+
const args = {
|
|
543
|
+
value: {
|
|
544
|
+
complex: 'object',
|
|
545
|
+
toJSON: () => 'string-value',
|
|
546
|
+
},
|
|
547
|
+
};
|
|
548
|
+
// toJSON returns a string, which should be properly stringified
|
|
549
|
+
expect((await engine.check({ name: 'test', args }, undefined)).decision).toBe(PolicyDecision.ALLOW);
|
|
550
|
+
});
|
|
551
|
+
it('should handle toJSON that throws an error', async () => {
|
|
552
|
+
const rules = [
|
|
553
|
+
{
|
|
554
|
+
toolName: 'test',
|
|
555
|
+
argsPattern: /"fallback":"value"/,
|
|
556
|
+
decision: PolicyDecision.ALLOW,
|
|
557
|
+
},
|
|
558
|
+
];
|
|
559
|
+
engine = new PolicyEngine({ rules });
|
|
560
|
+
const args = {
|
|
561
|
+
data: {
|
|
562
|
+
fallback: 'value',
|
|
563
|
+
toJSON: () => {
|
|
564
|
+
throw new Error('toJSON error');
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
};
|
|
568
|
+
// Should fall back to regular object serialization when toJSON throws
|
|
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);
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
//# sourceMappingURL=policy-engine.test.js.map
|