@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
|
@@ -3,10 +3,18 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { ToolConfirmationOutcome, ApprovalMode, logToolCall, ToolCallEvent,
|
|
6
|
+
import { ToolConfirmationOutcome, ApprovalMode, logToolCall, ToolErrorType, ToolCallEvent, logToolOutputTruncated, ToolOutputTruncatedEvent, runInDevTraceSpan, } from '../index.js';
|
|
7
|
+
import { READ_FILE_TOOL_NAME, SHELL_TOOL_NAME } from '../tools/tool-names.js';
|
|
7
8
|
import { getResponseTextFromParts } from '../utils/generateContentResponseUtilities.js';
|
|
8
9
|
import { isModifiableDeclarativeTool, modifyWithEditor, } from '../tools/modifiable-tool.js';
|
|
9
10
|
import * as Diff from 'diff';
|
|
11
|
+
import * as fs from 'node:fs/promises';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import { isShellInvocationAllowlisted, SHELL_TOOL_NAMES, } from '../utils/shell-utils.js';
|
|
14
|
+
import { doesToolInvocationMatch } from '../utils/tool-utils.js';
|
|
15
|
+
import levenshtein from 'fast-levenshtein';
|
|
16
|
+
import { ShellToolInvocation } from '../tools/shell.js';
|
|
17
|
+
import { MessageBusType } from '../confirmation-bus/types.js';
|
|
10
18
|
/**
|
|
11
19
|
* Formats tool output for a Gemini FunctionResponse.
|
|
12
20
|
*/
|
|
@@ -24,20 +32,20 @@ export function convertToFunctionResponse(toolName, callId, llmContent) {
|
|
|
24
32
|
? llmContent[0]
|
|
25
33
|
: llmContent;
|
|
26
34
|
if (typeof contentToProcess === 'string') {
|
|
27
|
-
return createFunctionResponsePart(callId, toolName, contentToProcess);
|
|
35
|
+
return [createFunctionResponsePart(callId, toolName, contentToProcess)];
|
|
28
36
|
}
|
|
29
37
|
if (Array.isArray(contentToProcess)) {
|
|
30
38
|
const functionResponse = createFunctionResponsePart(callId, toolName, 'Tool execution succeeded.');
|
|
31
|
-
return [functionResponse, ...contentToProcess];
|
|
39
|
+
return [functionResponse, ...toParts(contentToProcess)];
|
|
32
40
|
}
|
|
33
41
|
// After this point, contentToProcess is a single Part object.
|
|
34
42
|
if (contentToProcess.functionResponse) {
|
|
35
43
|
if (contentToProcess.functionResponse.response?.['content']) {
|
|
36
44
|
const stringifiedOutput = getResponseTextFromParts(contentToProcess.functionResponse.response['content']) || '';
|
|
37
|
-
return createFunctionResponsePart(callId, toolName, stringifiedOutput);
|
|
45
|
+
return [createFunctionResponsePart(callId, toolName, stringifiedOutput)];
|
|
38
46
|
}
|
|
39
47
|
// It's a functionResponse that we should pass through as is.
|
|
40
|
-
return contentToProcess;
|
|
48
|
+
return [contentToProcess];
|
|
41
49
|
}
|
|
42
50
|
if (contentToProcess.inlineData || contentToProcess.fileData) {
|
|
43
51
|
const mimeType = contentToProcess.inlineData?.mimeType ||
|
|
@@ -47,46 +55,143 @@ export function convertToFunctionResponse(toolName, callId, llmContent) {
|
|
|
47
55
|
return [functionResponse, contentToProcess];
|
|
48
56
|
}
|
|
49
57
|
if (contentToProcess.text !== undefined) {
|
|
50
|
-
return
|
|
58
|
+
return [
|
|
59
|
+
createFunctionResponsePart(callId, toolName, contentToProcess.text),
|
|
60
|
+
];
|
|
51
61
|
}
|
|
52
62
|
// Default case for other kinds of parts.
|
|
53
|
-
return
|
|
63
|
+
return [
|
|
64
|
+
createFunctionResponsePart(callId, toolName, 'Tool execution succeeded.'),
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
function toParts(input) {
|
|
68
|
+
const parts = [];
|
|
69
|
+
for (const part of Array.isArray(input) ? input : [input]) {
|
|
70
|
+
if (typeof part === 'string') {
|
|
71
|
+
parts.push({ text: part });
|
|
72
|
+
}
|
|
73
|
+
else if (part) {
|
|
74
|
+
parts.push(part);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return parts;
|
|
54
78
|
}
|
|
55
79
|
const createErrorResponse = (request, error, errorType) => ({
|
|
56
80
|
callId: request.callId,
|
|
57
81
|
error,
|
|
58
|
-
responseParts:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
82
|
+
responseParts: [
|
|
83
|
+
{
|
|
84
|
+
functionResponse: {
|
|
85
|
+
id: request.callId,
|
|
86
|
+
name: request.name,
|
|
87
|
+
response: { error: error.message },
|
|
88
|
+
},
|
|
63
89
|
},
|
|
64
|
-
|
|
90
|
+
],
|
|
65
91
|
resultDisplay: error.message,
|
|
66
92
|
errorType,
|
|
93
|
+
contentLength: error.message.length,
|
|
67
94
|
});
|
|
95
|
+
export async function truncateAndSaveToFile(content, callId, projectTempDir, threshold, truncateLines) {
|
|
96
|
+
if (content.length <= threshold) {
|
|
97
|
+
return { content };
|
|
98
|
+
}
|
|
99
|
+
let lines = content.split('\n');
|
|
100
|
+
let fileContent = content;
|
|
101
|
+
// If the content is long but has few lines, wrap it to enable line-based truncation.
|
|
102
|
+
if (lines.length <= truncateLines) {
|
|
103
|
+
const wrapWidth = 120; // A reasonable width for wrapping.
|
|
104
|
+
const wrappedLines = [];
|
|
105
|
+
for (const line of lines) {
|
|
106
|
+
if (line.length > wrapWidth) {
|
|
107
|
+
for (let i = 0; i < line.length; i += wrapWidth) {
|
|
108
|
+
wrappedLines.push(line.substring(i, i + wrapWidth));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
wrappedLines.push(line);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
lines = wrappedLines;
|
|
116
|
+
fileContent = lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
const head = Math.floor(truncateLines / 5);
|
|
119
|
+
const beginning = lines.slice(0, head);
|
|
120
|
+
const end = lines.slice(-(truncateLines - head));
|
|
121
|
+
const truncatedContent = beginning.join('\n') + '\n... [CONTENT TRUNCATED] ...\n' + end.join('\n');
|
|
122
|
+
// Sanitize callId to prevent path traversal.
|
|
123
|
+
const safeFileName = `${path.basename(callId)}.output`;
|
|
124
|
+
const outputFile = path.join(projectTempDir, safeFileName);
|
|
125
|
+
try {
|
|
126
|
+
await fs.writeFile(outputFile, fileContent);
|
|
127
|
+
return {
|
|
128
|
+
content: `Tool output was too large and has been truncated.
|
|
129
|
+
The full output has been saved to: ${outputFile}
|
|
130
|
+
To read the complete output, use the ${READ_FILE_TOOL_NAME} tool with the absolute file path above. For large files, you can use the offset and limit parameters to read specific sections:
|
|
131
|
+
- ${READ_FILE_TOOL_NAME} tool with offset=0, limit=100 to see the first 100 lines
|
|
132
|
+
- ${READ_FILE_TOOL_NAME} tool with offset=N to skip N lines from the beginning
|
|
133
|
+
- ${READ_FILE_TOOL_NAME} tool with limit=M to read only M lines at a time
|
|
134
|
+
The truncated output below shows the beginning and end of the content. The marker '... [CONTENT TRUNCATED] ...' indicates where content was removed.
|
|
135
|
+
This allows you to efficiently examine different parts of the output without loading the entire file.
|
|
136
|
+
Truncated part of the output:
|
|
137
|
+
${truncatedContent}`,
|
|
138
|
+
outputFile,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (_error) {
|
|
142
|
+
return {
|
|
143
|
+
content: truncatedContent + `\n[Note: Could not save full output to file]`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
68
147
|
export class CoreToolScheduler {
|
|
69
|
-
|
|
148
|
+
// Static WeakMap to track which MessageBus instances already have a handler subscribed
|
|
149
|
+
// This prevents duplicate subscriptions when multiple CoreToolScheduler instances are created
|
|
150
|
+
static subscribedMessageBuses = new WeakMap();
|
|
70
151
|
toolCalls = [];
|
|
71
152
|
outputUpdateHandler;
|
|
72
153
|
onAllToolCallsComplete;
|
|
73
154
|
onToolCallsUpdate;
|
|
74
155
|
getPreferredEditor;
|
|
75
156
|
config;
|
|
76
|
-
onEditorClose;
|
|
77
157
|
isFinalizingToolCalls = false;
|
|
78
158
|
isScheduling = false;
|
|
159
|
+
isCancelling = false;
|
|
79
160
|
requestQueue = [];
|
|
161
|
+
toolCallQueue = [];
|
|
162
|
+
completedToolCallsForBatch = [];
|
|
80
163
|
constructor(options) {
|
|
81
164
|
this.config = options.config;
|
|
82
|
-
this.toolRegistry = options.toolRegistry;
|
|
83
165
|
this.outputUpdateHandler = options.outputUpdateHandler;
|
|
84
166
|
this.onAllToolCallsComplete = options.onAllToolCallsComplete;
|
|
85
167
|
this.onToolCallsUpdate = options.onToolCallsUpdate;
|
|
86
168
|
this.getPreferredEditor = options.getPreferredEditor;
|
|
87
|
-
|
|
169
|
+
// Subscribe to message bus for ASK_USER policy decisions
|
|
170
|
+
// Use a static WeakMap to ensure we only subscribe ONCE per MessageBus instance
|
|
171
|
+
// This prevents memory leaks when multiple CoreToolScheduler instances are created
|
|
172
|
+
// (e.g., on every React render, or for each non-interactive tool call)
|
|
173
|
+
if (this.config.getEnableMessageBusIntegration()) {
|
|
174
|
+
const messageBus = this.config.getMessageBus();
|
|
175
|
+
// Check if we've already subscribed a handler to this message bus
|
|
176
|
+
if (!CoreToolScheduler.subscribedMessageBuses.has(messageBus)) {
|
|
177
|
+
// Create a shared handler that will be used for this message bus
|
|
178
|
+
const sharedHandler = (request) => {
|
|
179
|
+
// When ASK_USER policy decision is made, respond with requiresUserConfirmation=true
|
|
180
|
+
// to tell tools to use their legacy confirmation flow
|
|
181
|
+
messageBus.publish({
|
|
182
|
+
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
|
183
|
+
correlationId: request.correlationId,
|
|
184
|
+
confirmed: false,
|
|
185
|
+
requiresUserConfirmation: true,
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
messageBus.subscribe(MessageBusType.TOOL_CONFIRMATION_REQUEST, sharedHandler);
|
|
189
|
+
// Store the handler in the WeakMap so we don't subscribe again
|
|
190
|
+
CoreToolScheduler.subscribedMessageBuses.set(messageBus, sharedHandler);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
88
193
|
}
|
|
89
|
-
setStatusInternal(targetCallId, newStatus, auxiliaryData) {
|
|
194
|
+
setStatusInternal(targetCallId, newStatus, signal, auxiliaryData) {
|
|
90
195
|
this.toolCalls = this.toolCalls.map((currentCall) => {
|
|
91
196
|
if (currentCall.request.callId !== targetCallId ||
|
|
92
197
|
currentCall.status === 'success' ||
|
|
@@ -163,6 +268,7 @@ export class CoreToolScheduler {
|
|
|
163
268
|
};
|
|
164
269
|
}
|
|
165
270
|
}
|
|
271
|
+
const errorMessage = `[Operation Cancelled] Reason: ${auxiliaryData}`;
|
|
166
272
|
return {
|
|
167
273
|
request: currentCall.request,
|
|
168
274
|
tool: toolInstance,
|
|
@@ -170,18 +276,21 @@ export class CoreToolScheduler {
|
|
|
170
276
|
status: 'cancelled',
|
|
171
277
|
response: {
|
|
172
278
|
callId: currentCall.request.callId,
|
|
173
|
-
responseParts:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
279
|
+
responseParts: [
|
|
280
|
+
{
|
|
281
|
+
functionResponse: {
|
|
282
|
+
id: currentCall.request.callId,
|
|
283
|
+
name: currentCall.request.name,
|
|
284
|
+
response: {
|
|
285
|
+
error: errorMessage,
|
|
286
|
+
},
|
|
179
287
|
},
|
|
180
288
|
},
|
|
181
|
-
|
|
289
|
+
],
|
|
182
290
|
resultDisplay,
|
|
183
291
|
error: undefined,
|
|
184
292
|
errorType: undefined,
|
|
293
|
+
contentLength: errorMessage.length,
|
|
185
294
|
},
|
|
186
295
|
durationMs,
|
|
187
296
|
outcome,
|
|
@@ -212,7 +321,6 @@ export class CoreToolScheduler {
|
|
|
212
321
|
}
|
|
213
322
|
});
|
|
214
323
|
this.notifyToolCallsUpdate();
|
|
215
|
-
this.checkAndNotifyCompletion();
|
|
216
324
|
}
|
|
217
325
|
setArgsInternal(targetCallId, args) {
|
|
218
326
|
this.toolCalls = this.toolCalls.map((call) => {
|
|
@@ -253,48 +361,106 @@ export class CoreToolScheduler {
|
|
|
253
361
|
return new Error(String(e));
|
|
254
362
|
}
|
|
255
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Generates a suggestion string for a tool name that was not found in the registry.
|
|
366
|
+
* It finds the closest matches based on Levenshtein distance.
|
|
367
|
+
* @param unknownToolName The tool name that was not found.
|
|
368
|
+
* @param topN The number of suggestions to return. Defaults to 3.
|
|
369
|
+
* @returns A suggestion string like " Did you mean 'tool'?" or " Did you mean one of: 'tool1', 'tool2'?", or an empty string if no suggestions are found.
|
|
370
|
+
*/
|
|
371
|
+
getToolSuggestion(unknownToolName, topN = 3) {
|
|
372
|
+
const allToolNames = this.config.getToolRegistry().getAllToolNames();
|
|
373
|
+
const matches = allToolNames.map((toolName) => ({
|
|
374
|
+
name: toolName,
|
|
375
|
+
distance: levenshtein.get(unknownToolName, toolName),
|
|
376
|
+
}));
|
|
377
|
+
matches.sort((a, b) => a.distance - b.distance);
|
|
378
|
+
const topNResults = matches.slice(0, topN);
|
|
379
|
+
if (topNResults.length === 0) {
|
|
380
|
+
return '';
|
|
381
|
+
}
|
|
382
|
+
const suggestedNames = topNResults
|
|
383
|
+
.map((match) => `"${match.name}"`)
|
|
384
|
+
.join(', ');
|
|
385
|
+
if (topNResults.length > 1) {
|
|
386
|
+
return ` Did you mean one of: ${suggestedNames}?`;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
return ` Did you mean ${suggestedNames}?`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
256
392
|
schedule(request, signal) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
this.requestQueue.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
signal
|
|
273
|
-
resolve()
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
reject(reason)
|
|
278
|
-
|
|
393
|
+
return runInDevTraceSpan({ name: 'schedule' }, async ({ metadata: spanMetadata }) => {
|
|
394
|
+
spanMetadata.input = request;
|
|
395
|
+
if (this.isRunning() || this.isScheduling) {
|
|
396
|
+
return new Promise((resolve, reject) => {
|
|
397
|
+
const abortHandler = () => {
|
|
398
|
+
// Find and remove the request from the queue
|
|
399
|
+
const index = this.requestQueue.findIndex((item) => item.request === request);
|
|
400
|
+
if (index > -1) {
|
|
401
|
+
this.requestQueue.splice(index, 1);
|
|
402
|
+
reject(new Error('Tool call cancelled while in queue.'));
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
signal.addEventListener('abort', abortHandler, { once: true });
|
|
406
|
+
this.requestQueue.push({
|
|
407
|
+
request,
|
|
408
|
+
signal,
|
|
409
|
+
resolve: () => {
|
|
410
|
+
signal.removeEventListener('abort', abortHandler);
|
|
411
|
+
resolve();
|
|
412
|
+
},
|
|
413
|
+
reject: (reason) => {
|
|
414
|
+
signal.removeEventListener('abort', abortHandler);
|
|
415
|
+
reject(reason);
|
|
416
|
+
},
|
|
417
|
+
});
|
|
279
418
|
});
|
|
280
|
-
}
|
|
419
|
+
}
|
|
420
|
+
return this._schedule(request, signal);
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
cancelAll(signal) {
|
|
424
|
+
if (this.isCancelling) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
this.isCancelling = true;
|
|
428
|
+
// Cancel the currently active tool call, if there is one.
|
|
429
|
+
if (this.toolCalls.length > 0) {
|
|
430
|
+
const activeCall = this.toolCalls[0];
|
|
431
|
+
// Only cancel if it's in a cancellable state.
|
|
432
|
+
if (activeCall.status === 'awaiting_approval' ||
|
|
433
|
+
activeCall.status === 'executing' ||
|
|
434
|
+
activeCall.status === 'scheduled' ||
|
|
435
|
+
activeCall.status === 'validating') {
|
|
436
|
+
this.setStatusInternal(activeCall.request.callId, 'cancelled', signal, 'User cancelled the operation.');
|
|
437
|
+
}
|
|
281
438
|
}
|
|
282
|
-
|
|
439
|
+
// Clear the queue and mark all queued items as cancelled for completion reporting.
|
|
440
|
+
this._cancelAllQueuedCalls();
|
|
441
|
+
// Finalize the batch immediately.
|
|
442
|
+
void this.checkAndNotifyCompletion(signal);
|
|
283
443
|
}
|
|
284
444
|
async _schedule(request, signal) {
|
|
285
445
|
this.isScheduling = true;
|
|
446
|
+
this.isCancelling = false;
|
|
286
447
|
try {
|
|
287
448
|
if (this.isRunning()) {
|
|
288
449
|
throw new Error('Cannot schedule new tool calls while other tool calls are actively running (executing or awaiting approval).');
|
|
289
450
|
}
|
|
290
451
|
const requestsToProcess = Array.isArray(request) ? request : [request];
|
|
452
|
+
this.completedToolCallsForBatch = [];
|
|
291
453
|
const newToolCalls = requestsToProcess.map((reqInfo) => {
|
|
292
|
-
const toolInstance = this.
|
|
454
|
+
const toolInstance = this.config
|
|
455
|
+
.getToolRegistry()
|
|
456
|
+
.getTool(reqInfo.name);
|
|
293
457
|
if (!toolInstance) {
|
|
458
|
+
const suggestion = this.getToolSuggestion(reqInfo.name);
|
|
459
|
+
const errorMessage = `Tool "${reqInfo.name}" not found in registry. Tools must use the exact names that are registered.${suggestion}`;
|
|
294
460
|
return {
|
|
295
461
|
status: 'error',
|
|
296
462
|
request: reqInfo,
|
|
297
|
-
response: createErrorResponse(reqInfo, new Error(
|
|
463
|
+
response: createErrorResponse(reqInfo, new Error(errorMessage), ToolErrorType.TOOL_NOT_REGISTERED),
|
|
298
464
|
durationMs: 0,
|
|
299
465
|
};
|
|
300
466
|
}
|
|
@@ -316,72 +482,101 @@ export class CoreToolScheduler {
|
|
|
316
482
|
startTime: Date.now(),
|
|
317
483
|
};
|
|
318
484
|
});
|
|
319
|
-
this.
|
|
320
|
-
this.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
485
|
+
this.toolCallQueue.push(...newToolCalls);
|
|
486
|
+
await this._processNextInQueue(signal);
|
|
487
|
+
}
|
|
488
|
+
finally {
|
|
489
|
+
this.isScheduling = false;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
async _processNextInQueue(signal) {
|
|
493
|
+
// If there's already a tool being processed, or the queue is empty, stop.
|
|
494
|
+
if (this.toolCalls.length > 0 || this.toolCallQueue.length === 0) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
// If cancellation happened between steps, handle it.
|
|
498
|
+
if (signal.aborted) {
|
|
499
|
+
this._cancelAllQueuedCalls();
|
|
500
|
+
// Finalize the batch.
|
|
501
|
+
await this.checkAndNotifyCompletion(signal);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
const toolCall = this.toolCallQueue.shift();
|
|
505
|
+
// This is now the single active tool call.
|
|
506
|
+
this.toolCalls = [toolCall];
|
|
507
|
+
this.notifyToolCallsUpdate();
|
|
508
|
+
// Handle tools that were already errored during creation.
|
|
509
|
+
if (toolCall.status === 'error') {
|
|
510
|
+
// An error during validation means this "active" tool is already complete.
|
|
511
|
+
// We need to check for batch completion to either finish or process the next in queue.
|
|
512
|
+
await this.checkAndNotifyCompletion(signal);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
// This logic is moved from the old `for` loop in `_schedule`.
|
|
516
|
+
if (toolCall.status === 'validating') {
|
|
517
|
+
const { request: reqInfo, invocation } = toolCall;
|
|
518
|
+
try {
|
|
519
|
+
if (signal.aborted) {
|
|
520
|
+
this.setStatusInternal(reqInfo.callId, 'cancelled', signal, 'Tool call cancelled by user.');
|
|
521
|
+
// The completion check will handle the cascade.
|
|
522
|
+
await this.checkAndNotifyCompletion(signal);
|
|
523
|
+
return;
|
|
324
524
|
}
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (this.
|
|
525
|
+
const confirmationDetails = await invocation.shouldConfirmExecute(signal);
|
|
526
|
+
if (!confirmationDetails) {
|
|
527
|
+
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
528
|
+
this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
if (this.isAutoApproved(toolCall)) {
|
|
332
532
|
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
333
|
-
this.setStatusInternal(reqInfo.callId, 'scheduled');
|
|
533
|
+
this.setStatusInternal(reqInfo.callId, 'scheduled', signal);
|
|
334
534
|
}
|
|
335
535
|
else {
|
|
336
|
-
|
|
337
|
-
if (confirmationDetails
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
const originalOnConfirm = confirmationDetails.onConfirm;
|
|
351
|
-
const wrappedConfirmationDetails = {
|
|
352
|
-
...confirmationDetails,
|
|
353
|
-
onConfirm: (outcome, payload) => this.handleConfirmationResponse(reqInfo.callId, originalOnConfirm, outcome, signal, payload),
|
|
354
|
-
};
|
|
355
|
-
this.setStatusInternal(reqInfo.callId, 'awaiting_approval', wrappedConfirmationDetails);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
this.setToolCallOutcome(reqInfo.callId, ToolConfirmationOutcome.ProceedAlways);
|
|
359
|
-
this.setStatusInternal(reqInfo.callId, 'scheduled');
|
|
536
|
+
// Allow IDE to resolve confirmation
|
|
537
|
+
if (confirmationDetails.type === 'edit' &&
|
|
538
|
+
confirmationDetails.ideConfirmation) {
|
|
539
|
+
confirmationDetails.ideConfirmation.then((resolution) => {
|
|
540
|
+
if (resolution.status === 'accepted') {
|
|
541
|
+
this.handleConfirmationResponse(reqInfo.callId, confirmationDetails.onConfirm, ToolConfirmationOutcome.ProceedOnce, signal);
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
this.handleConfirmationResponse(reqInfo.callId, confirmationDetails.onConfirm, ToolConfirmationOutcome.Cancel, signal);
|
|
545
|
+
}
|
|
546
|
+
});
|
|
360
547
|
}
|
|
548
|
+
const originalOnConfirm = confirmationDetails.onConfirm;
|
|
549
|
+
const wrappedConfirmationDetails = {
|
|
550
|
+
...confirmationDetails,
|
|
551
|
+
onConfirm: (outcome, payload) => this.handleConfirmationResponse(reqInfo.callId, originalOnConfirm, outcome, signal, payload),
|
|
552
|
+
};
|
|
553
|
+
this.setStatusInternal(reqInfo.callId, 'awaiting_approval', signal, wrappedConfirmationDetails);
|
|
361
554
|
}
|
|
362
555
|
}
|
|
363
|
-
|
|
364
|
-
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
if (signal.aborted) {
|
|
559
|
+
this.setStatusInternal(reqInfo.callId, 'cancelled', signal, 'Tool call cancelled by user.');
|
|
560
|
+
await this.checkAndNotifyCompletion(signal);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
this.setStatusInternal(reqInfo.callId, 'error', signal, createErrorResponse(reqInfo, error instanceof Error ? error : new Error(String(error)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
564
|
+
await this.checkAndNotifyCompletion(signal);
|
|
365
565
|
}
|
|
366
566
|
}
|
|
367
|
-
this.attemptExecutionOfScheduledCalls(signal);
|
|
368
|
-
void this.checkAndNotifyCompletion();
|
|
369
|
-
}
|
|
370
|
-
finally {
|
|
371
|
-
this.isScheduling = false;
|
|
372
567
|
}
|
|
568
|
+
await this.attemptExecutionOfScheduledCalls(signal);
|
|
373
569
|
}
|
|
374
570
|
async handleConfirmationResponse(callId, originalOnConfirm, outcome, signal, payload) {
|
|
375
571
|
const toolCall = this.toolCalls.find((c) => c.request.callId === callId && c.status === 'awaiting_approval');
|
|
376
572
|
if (toolCall && toolCall.status === 'awaiting_approval') {
|
|
377
573
|
await originalOnConfirm(outcome);
|
|
378
574
|
}
|
|
379
|
-
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
380
|
-
await this.autoApproveCompatiblePendingTools(signal, callId);
|
|
381
|
-
}
|
|
382
575
|
this.setToolCallOutcome(callId, outcome);
|
|
383
576
|
if (outcome === ToolConfirmationOutcome.Cancel || signal.aborted) {
|
|
384
|
-
|
|
577
|
+
// Instead of just cancelling one tool, trigger the full cancel cascade.
|
|
578
|
+
this.cancelAll(signal);
|
|
579
|
+
return; // `cancelAll` calls `checkAndNotifyCompletion`, so we can exit here.
|
|
385
580
|
}
|
|
386
581
|
else if (outcome === ToolConfirmationOutcome.ModifyWithEditor) {
|
|
387
582
|
const waitingToolCall = toolCall;
|
|
@@ -391,13 +586,19 @@ export class CoreToolScheduler {
|
|
|
391
586
|
if (!editorType) {
|
|
392
587
|
return;
|
|
393
588
|
}
|
|
394
|
-
this.setStatusInternal(callId, 'awaiting_approval', {
|
|
589
|
+
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
395
590
|
...waitingToolCall.confirmationDetails,
|
|
396
591
|
isModifying: true,
|
|
397
592
|
});
|
|
398
|
-
const
|
|
593
|
+
const contentOverrides = waitingToolCall.confirmationDetails.type === 'edit'
|
|
594
|
+
? {
|
|
595
|
+
currentContent: waitingToolCall.confirmationDetails.originalContent,
|
|
596
|
+
proposedContent: waitingToolCall.confirmationDetails.newContent,
|
|
597
|
+
}
|
|
598
|
+
: undefined;
|
|
599
|
+
const { updatedParams, updatedDiff } = await modifyWithEditor(waitingToolCall.request.args, modifyContext, editorType, signal, contentOverrides);
|
|
399
600
|
this.setArgsInternal(callId, updatedParams);
|
|
400
|
-
this.setStatusInternal(callId, 'awaiting_approval', {
|
|
601
|
+
this.setStatusInternal(callId, 'awaiting_approval', signal, {
|
|
401
602
|
...waitingToolCall.confirmationDetails,
|
|
402
603
|
fileDiff: updatedDiff,
|
|
403
604
|
isModifying: false,
|
|
@@ -409,9 +610,9 @@ export class CoreToolScheduler {
|
|
|
409
610
|
if (payload?.newContent && toolCall) {
|
|
410
611
|
await this._applyInlineModify(toolCall, payload, signal);
|
|
411
612
|
}
|
|
412
|
-
this.setStatusInternal(callId, 'scheduled');
|
|
613
|
+
this.setStatusInternal(callId, 'scheduled', signal);
|
|
413
614
|
}
|
|
414
|
-
this.attemptExecutionOfScheduledCalls(signal);
|
|
615
|
+
await this.attemptExecutionOfScheduledCalls(signal);
|
|
415
616
|
}
|
|
416
617
|
/**
|
|
417
618
|
* Applies user-provided content changes to a tool call that is awaiting confirmation.
|
|
@@ -429,25 +630,25 @@ export class CoreToolScheduler {
|
|
|
429
630
|
const updatedParams = modifyContext.createUpdatedParams(currentContent, payload.newContent, toolCall.request.args);
|
|
430
631
|
const updatedDiff = Diff.createPatch(modifyContext.getFilePath(toolCall.request.args), currentContent, payload.newContent, 'Current', 'Proposed');
|
|
431
632
|
this.setArgsInternal(toolCall.request.callId, updatedParams);
|
|
432
|
-
this.setStatusInternal(toolCall.request.callId, 'awaiting_approval', {
|
|
633
|
+
this.setStatusInternal(toolCall.request.callId, 'awaiting_approval', signal, {
|
|
433
634
|
...toolCall.confirmationDetails,
|
|
434
635
|
fileDiff: updatedDiff,
|
|
435
636
|
});
|
|
436
637
|
}
|
|
437
|
-
attemptExecutionOfScheduledCalls(signal) {
|
|
638
|
+
async attemptExecutionOfScheduledCalls(signal) {
|
|
438
639
|
const allCallsFinalOrScheduled = this.toolCalls.every((call) => call.status === 'scheduled' ||
|
|
439
640
|
call.status === 'cancelled' ||
|
|
440
641
|
call.status === 'success' ||
|
|
441
642
|
call.status === 'error');
|
|
442
643
|
if (allCallsFinalOrScheduled) {
|
|
443
644
|
const callsToExecute = this.toolCalls.filter((call) => call.status === 'scheduled');
|
|
444
|
-
|
|
645
|
+
for (const toolCall of callsToExecute) {
|
|
445
646
|
if (toolCall.status !== 'scheduled')
|
|
446
|
-
|
|
647
|
+
continue;
|
|
447
648
|
const scheduledCall = toolCall;
|
|
448
649
|
const { callId, name: toolName } = scheduledCall.request;
|
|
449
650
|
const invocation = scheduledCall.invocation;
|
|
450
|
-
this.setStatusInternal(callId, 'executing');
|
|
651
|
+
this.setStatusInternal(callId, 'executing', signal);
|
|
451
652
|
const liveOutputCallback = scheduledCall.tool.canUpdateOutput && this.outputUpdateHandler
|
|
452
653
|
? (outputChunk) => {
|
|
453
654
|
if (this.outputUpdateHandler) {
|
|
@@ -459,56 +660,143 @@ export class CoreToolScheduler {
|
|
|
459
660
|
this.notifyToolCallsUpdate();
|
|
460
661
|
}
|
|
461
662
|
: undefined;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
663
|
+
const shellExecutionConfig = this.config.getShellExecutionConfig();
|
|
664
|
+
await runInDevTraceSpan({
|
|
665
|
+
name: toolCall.tool.name,
|
|
666
|
+
attributes: { type: 'tool-call' },
|
|
667
|
+
}, async ({ metadata: spanMetadata }) => {
|
|
668
|
+
spanMetadata.input = {
|
|
669
|
+
request: toolCall.request,
|
|
670
|
+
};
|
|
671
|
+
// TODO: Refactor to remove special casing for ShellToolInvocation.
|
|
672
|
+
// Introduce a generic callbacks object for the execute method to handle
|
|
673
|
+
// things like `onPid` and `onLiveOutput`. This will make the scheduler
|
|
674
|
+
// agnostic to the invocation type.
|
|
675
|
+
let promise;
|
|
676
|
+
if (invocation instanceof ShellToolInvocation) {
|
|
677
|
+
const setPidCallback = (pid) => {
|
|
678
|
+
this.toolCalls = this.toolCalls.map((tc) => tc.request.callId === callId && tc.status === 'executing'
|
|
679
|
+
? { ...tc, pid }
|
|
680
|
+
: tc);
|
|
681
|
+
this.notifyToolCallsUpdate();
|
|
477
682
|
};
|
|
478
|
-
|
|
683
|
+
promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig, setPidCallback);
|
|
479
684
|
}
|
|
480
685
|
else {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
686
|
+
promise = invocation.execute(signal, liveOutputCallback, shellExecutionConfig);
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
const toolResult = await promise;
|
|
690
|
+
spanMetadata.output = toolResult;
|
|
691
|
+
if (signal.aborted) {
|
|
692
|
+
this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
|
|
693
|
+
}
|
|
694
|
+
else if (toolResult.error === undefined) {
|
|
695
|
+
let content = toolResult.llmContent;
|
|
696
|
+
let outputFile = undefined;
|
|
697
|
+
const contentLength = typeof content === 'string' ? content.length : undefined;
|
|
698
|
+
if (typeof content === 'string' &&
|
|
699
|
+
toolName === SHELL_TOOL_NAME &&
|
|
700
|
+
this.config.getEnableToolOutputTruncation() &&
|
|
701
|
+
this.config.getTruncateToolOutputThreshold() > 0 &&
|
|
702
|
+
this.config.getTruncateToolOutputLines() > 0) {
|
|
703
|
+
const originalContentLength = content.length;
|
|
704
|
+
const threshold = this.config.getTruncateToolOutputThreshold();
|
|
705
|
+
const lines = this.config.getTruncateToolOutputLines();
|
|
706
|
+
const truncatedResult = await truncateAndSaveToFile(content, callId, this.config.storage.getProjectTempDir(), threshold, lines);
|
|
707
|
+
content = truncatedResult.content;
|
|
708
|
+
outputFile = truncatedResult.outputFile;
|
|
709
|
+
if (outputFile) {
|
|
710
|
+
logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(scheduledCall.request.prompt_id, {
|
|
711
|
+
toolName,
|
|
712
|
+
originalContentLength,
|
|
713
|
+
truncatedContentLength: content.length,
|
|
714
|
+
threshold,
|
|
715
|
+
lines,
|
|
716
|
+
}));
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const response = convertToFunctionResponse(toolName, callId, content);
|
|
720
|
+
const successResponse = {
|
|
721
|
+
callId,
|
|
722
|
+
responseParts: response,
|
|
723
|
+
resultDisplay: toolResult.returnDisplay,
|
|
724
|
+
error: undefined,
|
|
725
|
+
errorType: undefined,
|
|
726
|
+
outputFile,
|
|
727
|
+
contentLength,
|
|
728
|
+
};
|
|
729
|
+
this.setStatusInternal(callId, 'success', signal, successResponse);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
// It is a failure
|
|
733
|
+
const error = new Error(toolResult.error.message);
|
|
734
|
+
const errorResponse = createErrorResponse(scheduledCall.request, error, toolResult.error.type);
|
|
735
|
+
this.setStatusInternal(callId, 'error', signal, errorResponse);
|
|
736
|
+
}
|
|
485
737
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
738
|
+
catch (executionError) {
|
|
739
|
+
spanMetadata.error = executionError;
|
|
740
|
+
if (signal.aborted) {
|
|
741
|
+
this.setStatusInternal(callId, 'cancelled', signal, 'User cancelled tool execution.');
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
this.setStatusInternal(callId, 'error', signal, createErrorResponse(scheduledCall.request, executionError instanceof Error
|
|
745
|
+
? executionError
|
|
746
|
+
: new Error(String(executionError)), ToolErrorType.UNHANDLED_EXCEPTION));
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
await this.checkAndNotifyCompletion(signal);
|
|
491
750
|
});
|
|
492
|
-
}
|
|
751
|
+
}
|
|
493
752
|
}
|
|
494
753
|
}
|
|
495
|
-
async checkAndNotifyCompletion() {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
754
|
+
async checkAndNotifyCompletion(signal) {
|
|
755
|
+
// This method is now only concerned with the single active tool call.
|
|
756
|
+
if (this.toolCalls.length === 0) {
|
|
757
|
+
// It's possible to be called when a batch is cancelled before any tool has started.
|
|
758
|
+
if (signal.aborted && this.toolCallQueue.length > 0) {
|
|
759
|
+
this._cancelAllQueuedCalls();
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
const activeCall = this.toolCalls[0];
|
|
764
|
+
const isTerminal = activeCall.status === 'success' ||
|
|
765
|
+
activeCall.status === 'error' ||
|
|
766
|
+
activeCall.status === 'cancelled';
|
|
767
|
+
// If the active tool is not in a terminal state (e.g., it's 'executing' or 'awaiting_approval'),
|
|
768
|
+
// then the scheduler is still busy or paused. We should not proceed.
|
|
769
|
+
if (!isTerminal) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
// The active tool is finished. Move it to the completed batch.
|
|
773
|
+
const completedCall = activeCall;
|
|
774
|
+
this.completedToolCallsForBatch.push(completedCall);
|
|
775
|
+
logToolCall(this.config, new ToolCallEvent(completedCall));
|
|
776
|
+
// Clear the active tool slot. This is crucial for the sequential processing.
|
|
501
777
|
this.toolCalls = [];
|
|
502
|
-
|
|
503
|
-
|
|
778
|
+
}
|
|
779
|
+
// Now, check if the entire batch is complete.
|
|
780
|
+
// The batch is complete if the queue is empty or the operation was cancelled.
|
|
781
|
+
if (this.toolCallQueue.length === 0 || signal.aborted) {
|
|
782
|
+
if (signal.aborted) {
|
|
783
|
+
this._cancelAllQueuedCalls();
|
|
784
|
+
}
|
|
785
|
+
// If there's nothing to report and we weren't cancelled, we can stop.
|
|
786
|
+
// But if we were cancelled, we must proceed to potentially start the next queued request.
|
|
787
|
+
if (this.completedToolCallsForBatch.length === 0 && !signal.aborted) {
|
|
788
|
+
return;
|
|
504
789
|
}
|
|
505
790
|
if (this.onAllToolCallsComplete) {
|
|
506
791
|
this.isFinalizingToolCalls = true;
|
|
507
|
-
|
|
792
|
+
// Use the batch array, not the (now empty) active array.
|
|
793
|
+
await this.onAllToolCallsComplete(this.completedToolCallsForBatch);
|
|
794
|
+
this.completedToolCallsForBatch = []; // Clear after reporting.
|
|
508
795
|
this.isFinalizingToolCalls = false;
|
|
509
796
|
}
|
|
797
|
+
this.isCancelling = false;
|
|
510
798
|
this.notifyToolCallsUpdate();
|
|
511
|
-
// After completion, process the next item in the queue.
|
|
799
|
+
// After completion of the entire batch, process the next item in the main request queue.
|
|
512
800
|
if (this.requestQueue.length > 0) {
|
|
513
801
|
const next = this.requestQueue.shift();
|
|
514
802
|
this._schedule(next.request, next.signal)
|
|
@@ -516,10 +804,58 @@ export class CoreToolScheduler {
|
|
|
516
804
|
.catch(next.reject);
|
|
517
805
|
}
|
|
518
806
|
}
|
|
807
|
+
else {
|
|
808
|
+
// The batch is not yet complete, so continue processing the current batch sequence.
|
|
809
|
+
await this._processNextInQueue(signal);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
_cancelAllQueuedCalls() {
|
|
813
|
+
while (this.toolCallQueue.length > 0) {
|
|
814
|
+
const queuedCall = this.toolCallQueue.shift();
|
|
815
|
+
// Don't cancel tools that already errored during validation.
|
|
816
|
+
if (queuedCall.status === 'error') {
|
|
817
|
+
this.completedToolCallsForBatch.push(queuedCall);
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
const durationMs = 'startTime' in queuedCall && queuedCall.startTime
|
|
821
|
+
? Date.now() - queuedCall.startTime
|
|
822
|
+
: undefined;
|
|
823
|
+
const errorMessage = '[Operation Cancelled] User cancelled the operation.';
|
|
824
|
+
this.completedToolCallsForBatch.push({
|
|
825
|
+
request: queuedCall.request,
|
|
826
|
+
tool: queuedCall.tool,
|
|
827
|
+
invocation: queuedCall.invocation,
|
|
828
|
+
status: 'cancelled',
|
|
829
|
+
response: {
|
|
830
|
+
callId: queuedCall.request.callId,
|
|
831
|
+
responseParts: [
|
|
832
|
+
{
|
|
833
|
+
functionResponse: {
|
|
834
|
+
id: queuedCall.request.callId,
|
|
835
|
+
name: queuedCall.request.name,
|
|
836
|
+
response: {
|
|
837
|
+
error: errorMessage,
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
],
|
|
842
|
+
resultDisplay: undefined,
|
|
843
|
+
error: undefined,
|
|
844
|
+
errorType: undefined,
|
|
845
|
+
contentLength: errorMessage.length,
|
|
846
|
+
},
|
|
847
|
+
durationMs,
|
|
848
|
+
outcome: ToolConfirmationOutcome.Cancel,
|
|
849
|
+
});
|
|
850
|
+
}
|
|
519
851
|
}
|
|
520
852
|
notifyToolCallsUpdate() {
|
|
521
853
|
if (this.onToolCallsUpdate) {
|
|
522
|
-
this.onToolCallsUpdate([
|
|
854
|
+
this.onToolCallsUpdate([
|
|
855
|
+
...this.completedToolCallsForBatch,
|
|
856
|
+
...this.toolCalls,
|
|
857
|
+
...this.toolCallQueue,
|
|
858
|
+
]);
|
|
523
859
|
}
|
|
524
860
|
}
|
|
525
861
|
setToolCallOutcome(callId, outcome) {
|
|
@@ -532,21 +868,17 @@ export class CoreToolScheduler {
|
|
|
532
868
|
};
|
|
533
869
|
});
|
|
534
870
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
catch (error) {
|
|
547
|
-
console.error(`Error checking confirmation for tool ${pendingTool.request.callId}:`, error);
|
|
548
|
-
}
|
|
871
|
+
isAutoApproved(toolCall) {
|
|
872
|
+
if (this.config.getApprovalMode() === ApprovalMode.YOLO) {
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
const allowedTools = this.config.getAllowedTools() || [];
|
|
876
|
+
const { tool, invocation } = toolCall;
|
|
877
|
+
const toolName = typeof tool === 'string' ? tool : tool.name;
|
|
878
|
+
if (SHELL_TOOL_NAMES.includes(toolName)) {
|
|
879
|
+
return isShellInvocationAllowlisted(invocation, allowedTools);
|
|
549
880
|
}
|
|
881
|
+
return doesToolInvocationMatch(tool, invocation, allowedTools);
|
|
550
882
|
}
|
|
551
883
|
}
|
|
552
884
|
//# sourceMappingURL=coreToolScheduler.js.map
|