@office-ai/aioncli-core 0.8.1 → 0.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +36 -1
- package/dist/src/agents/codebase-investigator.js +93 -34
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/codebase-investigator.test.d.ts +6 -0
- package/dist/src/agents/codebase-investigator.test.js +35 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/executor.d.ts +37 -11
- package/dist/src/agents/executor.js +512 -150
- package/dist/src/agents/executor.js.map +1 -1
- package/dist/src/agents/executor.test.js +1188 -245
- package/dist/src/agents/executor.test.js.map +1 -1
- package/dist/src/agents/invocation.d.ts +5 -2
- package/dist/src/agents/invocation.js +4 -2
- package/dist/src/agents/invocation.js.map +1 -1
- package/dist/src/agents/invocation.test.js +9 -0
- package/dist/src/agents/invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +6 -1
- package/dist/src/agents/registry.js +51 -4
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +30 -16
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.d.ts +3 -1
- package/dist/src/agents/subagent-tool-wrapper.js +4 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +9 -4
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +37 -7
- package/dist/src/agents/types.js +2 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/code_assist/codeAssist.js +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
- package/dist/src/code_assist/codeAssist.test.js +99 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +1 -0
- package/dist/src/code_assist/converter.js +1 -0
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +19 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +50 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +36 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments.test.js +92 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
- package/dist/src/code_assist/experiments/flagNames.js +13 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +6 -5
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.test.js +65 -3
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -2
- package/dist/src/code_assist/oauth2.js +161 -93
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +103 -57
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +6 -4
- package/dist/src/code_assist/server.js +16 -8
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +126 -28
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -2
- package/dist/src/code_assist/setup.js +4 -2
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +1 -1
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +6 -0
- package/dist/src/commands/extensions.test.js +19 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/config/config.d.ts +169 -43
- package/dist/src/config/config.js +418 -79
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +684 -49
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +185 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +23 -2
- package/dist/src/config/models.js +50 -7
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +71 -10
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +3 -1
- package/dist/src/config/storage.js +22 -2
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +7 -6
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.d.ts +3 -2
- package/dist/src/confirmation-bus/message-bus.js +9 -3
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.test.js +30 -24
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +13 -2
- package/dist/src/confirmation-bus/types.js +1 -0
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +4 -8
- package/dist/src/core/baseLlmClient.js +6 -11
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +22 -27
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +12 -19
- package/dist/src/core/client.js +104 -206
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +329 -452
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +3 -2
- package/dist/src/core/contentGenerator.js +56 -41
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +49 -1
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +8 -4
- package/dist/src/core/coreToolScheduler.js +348 -179
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +575 -219
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +33 -0
- package/dist/src/core/fakeContentGenerator.js +58 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
- package/dist/src/core/fakeContentGenerator.test.js +127 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +23 -18
- package/dist/src/core/geminiChat.js +186 -108
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +581 -270
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/logger.d.ts +7 -2
- package/dist/src/core/logger.js +35 -27
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +45 -29
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +1 -0
- package/dist/src/core/loggingContentGenerator.js +113 -33
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/loggingContentGenerator.test.js +180 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +3 -2
- package/dist/src/core/nonInteractiveToolExecutor.js +12 -7
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +12 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +15 -1
- package/dist/src/core/openaiContentGenerator.js +139 -22
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/prompts.d.ts +2 -1
- package/dist/src/core/prompts.js +135 -154
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +128 -189
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +18 -0
- package/dist/src/core/recordingContentGenerator.js +77 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/recordingContentGenerator.test.js +101 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +26 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +23 -3
- package/dist/src/core/turn.js +18 -9
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +98 -104
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +60 -8
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +132 -17
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +262 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
- package/dist/src/hooks/hookAggregator.test.js +387 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +46 -0
- package/dist/src/hooks/hookPlanner.js +108 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
- package/dist/src/hooks/hookPlanner.test.js +255 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +87 -0
- package/dist/src/hooks/hookRegistry.js +198 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
- package/dist/src/hooks/hookRegistry.test.js +341 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +42 -0
- package/dist/src/hooks/hookRunner.js +272 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +6 -0
- package/dist/src/hooks/hookRunner.test.js +468 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +232 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
- package/dist/src/hooks/hookTranslator.test.js +192 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +384 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +6 -0
- package/dist/src/hooks/types.test.js +313 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +4 -0
- package/dist/src/ide/detect-ide.js +6 -1
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +16 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +3 -1
- package/dist/src/ide/ide-client.js +12 -10
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +163 -4
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.js +66 -21
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +54 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/process-utils.js +85 -75
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.js +83 -90
- package/dist/src/ide/process-utils.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +5 -5
- package/dist/src/ide/types.js +1 -1
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +2 -0
- package/dist/src/mcp/google-auth-provider.js +21 -3
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +42 -9
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +8 -5
- package/dist/src/mcp/oauth-provider.js +140 -55
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +369 -2
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.js +5 -4
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +17 -11
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +7 -0
- package/dist/src/mcp/oauth-utils.js +28 -8
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +45 -2
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +0 -6
- package/dist/src/mcp/sa-impersonation-provider.js +6 -23
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/base-token-storage.test.js +75 -84
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +3 -2
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.test.js +11 -8
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +6 -2
- package/dist/src/mcp/token-storage/keychain-token-storage.js +63 -7
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +54 -3
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/types.d.ts +6 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -1
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +63 -1
- package/dist/src/output/types.js +11 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +199 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +6 -0
- package/dist/src/policy/config.test.js +538 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +2 -0
- package/dist/src/policy/index.js +2 -0
- package/dist/src/policy/index.js.map +1 -1
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +56 -0
- package/dist/src/policy/policies/write.toml +73 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +12 -3
- package/dist/src/policy/policy-engine.js +74 -8
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +460 -76
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +47 -0
- package/dist/src/policy/toml-loader.js +411 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +6 -0
- package/dist/src/policy/toml-loader.test.js +376 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +83 -0
- package/dist/src/policy/types.js +10 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
- package/dist/src/prompts/mcp-prompts.test.js +39 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.js +2 -1
- package/dist/src/prompts/prompt-registry.js.map +1 -1
- package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
- package/dist/src/prompts/prompt-registry.test.js +96 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +15 -0
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +62 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js +9 -16
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +17 -13
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +4 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +2 -2
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +3 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +6 -0
- package/dist/src/safety/built-in.test.js +199 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +208 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +6 -0
- package/dist/src/safety/checker-runner.test.js +238 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +6 -0
- package/dist/src/safety/context-builder.test.js +49 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +6 -0
- package/dist/src/safety/registry.test.js +31 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +162 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +6 -0
- package/dist/src/services/chatCompressionService.test.js +210 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +3 -2
- package/dist/src/services/chatRecordingService.js +11 -9
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +2 -14
- package/dist/src/services/fileDiscoveryService.js +19 -55
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +91 -11
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +4 -1
- package/dist/src/services/loopDetectionService.js +95 -42
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +220 -12
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
- package/dist/src/services/modelConfig.golden.test.js +42 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
- package/dist/src/services/modelConfig.integration.test.js +247 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +48 -0
- package/dist/src/services/modelConfigService.js +151 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +6 -0
- package/dist/src/services/modelConfigService.test.js +531 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +1 -0
- package/dist/src/services/shellExecutionService.js +195 -92
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +137 -14
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +251 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +294 -76
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +192 -66
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +25 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +59 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +0 -28
- package/dist/src/telemetry/constants.js +0 -29
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.js +0 -1
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.test.js +1 -1
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +7 -3
- package/dist/src/telemetry/index.js +13 -4
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +14 -7
- package/dist/src/telemetry/loggers.js +197 -320
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +0 -1
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +460 -59
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +180 -4
- package/dist/src/telemetry/metrics.js +270 -6
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +502 -184
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +3 -2
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +269 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +6 -0
- package/dist/src/telemetry/semantic.test.js +387 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.js +29 -28
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -1
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +227 -29
- package/dist/src/telemetry/types.js +858 -72
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -1
- package/dist/src/telemetry/uiTelemetry.js +7 -7
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +89 -67
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +1 -1
- package/dist/src/test-utils/config.js +1 -1
- package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
- package/dist/src/tools/base-tool-invocation.test.js +85 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +4 -3
- package/dist/src/tools/edit.js +50 -47
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +306 -216
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +4 -3
- package/dist/src/tools/glob.js +24 -27
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +212 -205
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +4 -3
- package/dist/src/tools/grep.js +31 -25
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +15 -12
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +4 -3
- package/dist/src/tools/ls.js +29 -35
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +34 -42
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +49 -11
- package/dist/src/tools/mcp-client-manager.js +191 -31
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +132 -25
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +12 -5
- package/dist/src/tools/mcp-client.js +287 -267
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +352 -45
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +6 -2
- package/dist/src/tools/mcp-tool.js +19 -8
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +186 -273
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +7 -5
- package/dist/src/tools/memoryTool.js +14 -12
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +10 -9
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +14 -1
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.d.ts +5 -1
- package/dist/src/tools/modifiable-tool.js +38 -16
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +66 -31
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +6 -5
- package/dist/src/tools/read-file.js +26 -32
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +68 -33
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +6 -12
- package/dist/src/tools/read-many-files.js +28 -57
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +37 -36
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +28 -10
- package/dist/src/tools/ripGrep.js +195 -193
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +533 -204
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +8 -6
- package/dist/src/tools/shell.js +64 -38
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +134 -43
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +10 -23
- package/dist/src/tools/smart-edit.js +100 -85
- package/dist/src/tools/smart-edit.js.map +1 -1
- package/dist/src/tools/smart-edit.test.js +229 -179
- package/dist/src/tools/smart-edit.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +21 -0
- package/dist/src/tools/tool-error.js +27 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +21 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +32 -20
- package/dist/src/tools/tool-registry.js +122 -78
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +167 -90
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +23 -8
- package/dist/src/tools/tools.js +69 -37
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +11 -3
- package/dist/src/tools/web-fetch.js +80 -38
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +338 -9
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +4 -3
- package/dist/src/tools/web-search.js +11 -9
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +6 -0
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +3 -2
- package/dist/src/tools/write-file.js +41 -40
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +130 -123
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +34 -9
- package/dist/src/tools/write-todos.js +54 -11
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -2
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.js +3 -2
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +6 -0
- package/dist/src/utils/channel.test.js +170 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +69 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.js +10 -25
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +19 -5
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +4 -2
- package/dist/src/utils/editor.js +53 -39
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +18 -45
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +2 -1
- package/dist/src/utils/environmentContext.js +20 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +6 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +6 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +121 -0
- package/dist/src/utils/events.js +84 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +6 -0
- package/dist/src/utils/events.test.js +212 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +6 -0
- package/dist/src/utils/extensionLoader.test.js +154 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +1 -0
- package/dist/src/utils/fetch.js +4 -0
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +34 -2
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +87 -61
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.js +1 -1
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +28 -47
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.js +9 -17
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +7 -6
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +4 -1
- package/dist/src/utils/gitIgnoreParser.js +28 -10
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +58 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +152 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +301 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
- package/dist/src/utils/googleQuotaErrors.js +157 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +311 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.js +26 -30
- package/dist/src/utils/ignorePatterns.test.js.map +1 -1
- package/dist/src/utils/installationManager.js +2 -1
- package/dist/src/utils/installationManager.js.map +1 -1
- package/dist/src/utils/installationManager.test.js +6 -4
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.d.ts +1 -1
- package/dist/src/utils/llm-edit-fixer.js +33 -9
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +38 -1
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +20 -1
- package/dist/src/utils/memoryDiscovery.js +176 -12
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +299 -40
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +4 -3
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +8 -14
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.js +3 -3
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +13 -5
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +15 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.js +4 -4
- package/dist/src/utils/pathReader.js.map +1 -1
- package/dist/src/utils/pathReader.test.js +44 -1
- package/dist/src/utils/pathReader.test.js.map +1 -1
- package/dist/src/utils/paths.d.ts +1 -1
- package/dist/src/utils/paths.js +131 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +200 -68
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.d.ts +0 -2
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +3 -10
- package/dist/src/utils/retry.js +97 -195
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +179 -145
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +15 -2
- package/dist/src/utils/shell-utils.js +387 -140
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +244 -62
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +6 -0
- package/dist/src/utils/stdio.test.js +47 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +4 -2
- package/dist/src/utils/summarizer.js +8 -9
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +32 -12
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +5 -4
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +2 -1
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +14 -0
- package/dist/src/utils/terminal.js +38 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +2 -2
- package/dist/src/utils/tool-utils.js +15 -6
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +8 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/userAccountManager.js +5 -4
- package/dist/src/utils/userAccountManager.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +9 -7
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +13 -13
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +8 -7
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -7
|
@@ -5,28 +5,30 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { reportError } from '../utils/errorReporting.js';
|
|
7
7
|
import { GeminiChat, StreamEventType } from '../core/geminiChat.js';
|
|
8
|
+
import { Type } from '@google/genai';
|
|
8
9
|
import { executeToolCall } from '../core/nonInteractiveToolExecutor.js';
|
|
9
10
|
import { ToolRegistry } from '../tools/tool-registry.js';
|
|
11
|
+
import { CompressionStatus } from '../core/turn.js';
|
|
12
|
+
import { ChatCompressionService } from '../services/chatCompressionService.js';
|
|
10
13
|
import { getDirectoryContextString } from '../utils/environmentContext.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { MemoryTool } from '../tools/memoryTool.js';
|
|
16
|
-
import { ReadFileTool } from '../tools/read-file.js';
|
|
17
|
-
import { ReadManyFilesTool } from '../tools/read-many-files.js';
|
|
18
|
-
import { WebSearchTool } from '../tools/web-search.js';
|
|
14
|
+
import { GLOB_TOOL_NAME, GREP_TOOL_NAME, LS_TOOL_NAME, MEMORY_TOOL_NAME, READ_FILE_TOOL_NAME, READ_MANY_FILES_TOOL_NAME, WEB_SEARCH_TOOL_NAME, } from '../tools/tool-names.js';
|
|
15
|
+
import { promptIdContext } from '../utils/promptIdContext.js';
|
|
16
|
+
import { logAgentStart, logAgentFinish, logRecoveryAttempt, } from '../telemetry/loggers.js';
|
|
17
|
+
import { AgentStartEvent, AgentFinishEvent, RecoveryAttemptEvent, } from '../telemetry/types.js';
|
|
19
18
|
import { AgentTerminateMode } from './types.js';
|
|
20
19
|
import { templateString } from './utils.js';
|
|
21
20
|
import { parseThought } from '../utils/thoughtUtils.js';
|
|
21
|
+
import {} from 'zod';
|
|
22
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
23
|
+
import { debugLogger } from '../utils/debugLogger.js';
|
|
24
|
+
import { getModelConfigAlias } from './registry.js';
|
|
25
|
+
const TASK_COMPLETE_TOOL_NAME = 'complete_task';
|
|
26
|
+
const GRACE_PERIOD_MS = 60 * 1000; // 1 min
|
|
22
27
|
/**
|
|
23
28
|
* Executes an agent loop based on an {@link AgentDefinition}.
|
|
24
29
|
*
|
|
25
|
-
* This executor
|
|
26
|
-
*
|
|
27
|
-
* gathered all necessary information to fulfill its goal.
|
|
28
|
-
* 2. **Extraction Phase:** A final prompt is sent to the model to summarize
|
|
29
|
-
* the work and extract the final result in the desired format.
|
|
30
|
+
* This executor runs the agent in a loop, calling tools until it calls the
|
|
31
|
+
* mandatory `complete_task` tool to signal completion.
|
|
30
32
|
*/
|
|
31
33
|
export class AgentExecutor {
|
|
32
34
|
definition;
|
|
@@ -34,6 +36,8 @@ export class AgentExecutor {
|
|
|
34
36
|
toolRegistry;
|
|
35
37
|
runtimeContext;
|
|
36
38
|
onActivity;
|
|
39
|
+
compressionService;
|
|
40
|
+
hasFailedCompressionAttempt = false;
|
|
37
41
|
/**
|
|
38
42
|
* Creates and validates a new `AgentExecutor` instance.
|
|
39
43
|
*
|
|
@@ -67,11 +71,14 @@ export class AgentExecutor {
|
|
|
67
71
|
// Note: Raw `FunctionDeclaration` objects in the config don't need to be
|
|
68
72
|
// registered; their schemas are passed directly to the model later.
|
|
69
73
|
}
|
|
74
|
+
agentToolRegistry.sortTools();
|
|
70
75
|
// Validate that all registered tools are safe for non-interactive
|
|
71
76
|
// execution.
|
|
72
77
|
await AgentExecutor.validateTools(agentToolRegistry, definition.name);
|
|
73
78
|
}
|
|
74
|
-
|
|
79
|
+
// Get the parent prompt ID from context
|
|
80
|
+
const parentPromptId = promptIdContext.getStore();
|
|
81
|
+
return new AgentExecutor(definition, runtimeContext, agentToolRegistry, parentPromptId, onActivity);
|
|
75
82
|
}
|
|
76
83
|
/**
|
|
77
84
|
* Constructs a new AgentExecutor instance.
|
|
@@ -79,13 +86,141 @@ export class AgentExecutor {
|
|
|
79
86
|
* @private This constructor is private. Use the static `create` method to
|
|
80
87
|
* instantiate the class.
|
|
81
88
|
*/
|
|
82
|
-
constructor(definition, runtimeContext, toolRegistry, onActivity) {
|
|
89
|
+
constructor(definition, runtimeContext, toolRegistry, parentPromptId, onActivity) {
|
|
83
90
|
this.definition = definition;
|
|
84
91
|
this.runtimeContext = runtimeContext;
|
|
85
92
|
this.toolRegistry = toolRegistry;
|
|
86
93
|
this.onActivity = onActivity;
|
|
94
|
+
this.compressionService = new ChatCompressionService();
|
|
87
95
|
const randomIdPart = Math.random().toString(36).slice(2, 8);
|
|
88
|
-
this
|
|
96
|
+
// parentPromptId will be undefined if this agent is invoked directly
|
|
97
|
+
// (top-level), rather than as a sub-agent.
|
|
98
|
+
const parentPrefix = parentPromptId ? `${parentPromptId}-` : '';
|
|
99
|
+
this.agentId = `${parentPrefix}${this.definition.name}-${randomIdPart}`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Executes a single turn of the agent's logic, from calling the model
|
|
103
|
+
* to processing its response.
|
|
104
|
+
*
|
|
105
|
+
* @returns An {@link AgentTurnResult} object indicating whether to continue
|
|
106
|
+
* or stop the agent loop.
|
|
107
|
+
*/
|
|
108
|
+
async executeTurn(chat, currentMessage, tools, turnCounter, combinedSignal, timeoutSignal) {
|
|
109
|
+
const promptId = `${this.agentId}#${turnCounter}`;
|
|
110
|
+
await this.tryCompressChat(chat, promptId);
|
|
111
|
+
const { functionCalls } = await promptIdContext.run(promptId, async () => this.callModel(chat, currentMessage, tools, combinedSignal, promptId));
|
|
112
|
+
if (combinedSignal.aborted) {
|
|
113
|
+
const terminateReason = timeoutSignal.aborted
|
|
114
|
+
? AgentTerminateMode.TIMEOUT
|
|
115
|
+
: AgentTerminateMode.ABORTED;
|
|
116
|
+
return {
|
|
117
|
+
status: 'stop',
|
|
118
|
+
terminateReason,
|
|
119
|
+
finalResult: null, // 'run' method will set the final timeout string
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// If the model stops calling tools without calling complete_task, it's an error.
|
|
123
|
+
if (functionCalls.length === 0) {
|
|
124
|
+
this.emitActivity('ERROR', {
|
|
125
|
+
error: `Agent stopped calling tools but did not call '${TASK_COMPLETE_TOOL_NAME}' to finalize the session.`,
|
|
126
|
+
context: 'protocol_violation',
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
status: 'stop',
|
|
130
|
+
terminateReason: AgentTerminateMode.ERROR_NO_COMPLETE_TASK_CALL,
|
|
131
|
+
finalResult: null,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const { nextMessage, submittedOutput, taskCompleted } = await this.processFunctionCalls(functionCalls, combinedSignal, promptId);
|
|
135
|
+
if (taskCompleted) {
|
|
136
|
+
const finalResult = submittedOutput ?? 'Task completed successfully.';
|
|
137
|
+
return {
|
|
138
|
+
status: 'stop',
|
|
139
|
+
terminateReason: AgentTerminateMode.GOAL,
|
|
140
|
+
finalResult,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Task is not complete, continue to the next turn.
|
|
144
|
+
return {
|
|
145
|
+
status: 'continue',
|
|
146
|
+
nextMessage,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Generates a specific warning message for the agent's final turn.
|
|
151
|
+
*/
|
|
152
|
+
getFinalWarningMessage(reason) {
|
|
153
|
+
let explanation = '';
|
|
154
|
+
switch (reason) {
|
|
155
|
+
case AgentTerminateMode.TIMEOUT:
|
|
156
|
+
explanation = 'You have exceeded the time limit.';
|
|
157
|
+
break;
|
|
158
|
+
case AgentTerminateMode.MAX_TURNS:
|
|
159
|
+
explanation = 'You have exceeded the maximum number of turns.';
|
|
160
|
+
break;
|
|
161
|
+
case AgentTerminateMode.ERROR_NO_COMPLETE_TASK_CALL:
|
|
162
|
+
explanation = 'You have stopped calling tools without finishing.';
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
throw new Error(`Unknown terminate reason: ${reason}`);
|
|
166
|
+
}
|
|
167
|
+
return `${explanation} You have one final chance to complete the task with a short grace period. You MUST call \`${TASK_COMPLETE_TOOL_NAME}\` immediately with your best answer and explain that your investigation was interrupted. Do not call any other tools.`;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Attempts a single, final recovery turn if the agent stops for a recoverable reason.
|
|
171
|
+
* Gives the agent a grace period to call `complete_task`.
|
|
172
|
+
*
|
|
173
|
+
* @returns The final result string if recovery was successful, or `null` if it failed.
|
|
174
|
+
*/
|
|
175
|
+
async executeFinalWarningTurn(chat, tools, turnCounter, reason, externalSignal) {
|
|
176
|
+
this.emitActivity('THOUGHT_CHUNK', {
|
|
177
|
+
text: `Execution limit reached (${reason}). Attempting one final recovery turn with a grace period.`,
|
|
178
|
+
});
|
|
179
|
+
const recoveryStartTime = Date.now();
|
|
180
|
+
let success = false;
|
|
181
|
+
const gracePeriodMs = GRACE_PERIOD_MS;
|
|
182
|
+
const graceTimeoutController = new AbortController();
|
|
183
|
+
const graceTimeoutId = setTimeout(() => graceTimeoutController.abort(new Error('Grace period timed out.')), gracePeriodMs);
|
|
184
|
+
try {
|
|
185
|
+
const recoveryMessage = {
|
|
186
|
+
role: 'user',
|
|
187
|
+
parts: [{ text: this.getFinalWarningMessage(reason) }],
|
|
188
|
+
};
|
|
189
|
+
// We monitor both the external signal and our new grace period timeout
|
|
190
|
+
const combinedSignal = AbortSignal.any([
|
|
191
|
+
externalSignal,
|
|
192
|
+
graceTimeoutController.signal,
|
|
193
|
+
]);
|
|
194
|
+
const turnResult = await this.executeTurn(chat, recoveryMessage, tools, turnCounter, // This will be the "last" turn number
|
|
195
|
+
combinedSignal, graceTimeoutController.signal);
|
|
196
|
+
if (turnResult.status === 'stop' &&
|
|
197
|
+
turnResult.terminateReason === AgentTerminateMode.GOAL) {
|
|
198
|
+
// Success!
|
|
199
|
+
this.emitActivity('THOUGHT_CHUNK', {
|
|
200
|
+
text: 'Graceful recovery succeeded.',
|
|
201
|
+
});
|
|
202
|
+
success = true;
|
|
203
|
+
return turnResult.finalResult ?? 'Task completed during grace period.';
|
|
204
|
+
}
|
|
205
|
+
// Any other outcome (continue, error, non-GOAL stop) is a failure.
|
|
206
|
+
this.emitActivity('ERROR', {
|
|
207
|
+
error: `Graceful recovery attempt failed. Reason: ${turnResult.status}`,
|
|
208
|
+
context: 'recovery_turn',
|
|
209
|
+
});
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
// This catch block will likely catch the 'Grace period timed out' error.
|
|
214
|
+
this.emitActivity('ERROR', {
|
|
215
|
+
error: `Graceful recovery attempt failed: ${String(error)}`,
|
|
216
|
+
context: 'recovery_turn',
|
|
217
|
+
});
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
clearTimeout(graceTimeoutId);
|
|
222
|
+
logRecoveryAttempt(this.runtimeContext, new RecoveryAttemptEvent(this.agentId, this.definition.name, reason, Date.now() - recoveryStartTime, success, turnCounter));
|
|
223
|
+
}
|
|
89
224
|
}
|
|
90
225
|
/**
|
|
91
226
|
* Runs the agent.
|
|
@@ -97,64 +232,156 @@ export class AgentExecutor {
|
|
|
97
232
|
async run(inputs, signal) {
|
|
98
233
|
const startTime = Date.now();
|
|
99
234
|
let turnCounter = 0;
|
|
235
|
+
let terminateReason = AgentTerminateMode.ERROR;
|
|
236
|
+
let finalResult = null;
|
|
237
|
+
const { max_time_minutes } = this.definition.runConfig;
|
|
238
|
+
const timeoutController = new AbortController();
|
|
239
|
+
const timeoutId = setTimeout(() => timeoutController.abort(new Error('Agent timed out.')), max_time_minutes * 60 * 1000);
|
|
240
|
+
// Combine the external signal with the internal timeout signal.
|
|
241
|
+
const combinedSignal = AbortSignal.any([signal, timeoutController.signal]);
|
|
242
|
+
logAgentStart(this.runtimeContext, new AgentStartEvent(this.agentId, this.definition.name));
|
|
243
|
+
let chat;
|
|
244
|
+
let tools;
|
|
100
245
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let
|
|
107
|
-
{ role: 'user', parts: [{ text: 'Get Started!' }] },
|
|
108
|
-
];
|
|
246
|
+
chat = await this.createChatObject(inputs);
|
|
247
|
+
tools = this.prepareToolsList();
|
|
248
|
+
const query = this.definition.promptConfig.query
|
|
249
|
+
? templateString(this.definition.promptConfig.query, inputs)
|
|
250
|
+
: 'Get Started!';
|
|
251
|
+
let currentMessage = { role: 'user', parts: [{ text: query }] };
|
|
109
252
|
while (true) {
|
|
110
|
-
// Check for termination conditions like max turns
|
|
253
|
+
// Check for termination conditions like max turns.
|
|
111
254
|
const reason = this.checkTermination(startTime, turnCounter);
|
|
112
255
|
if (reason) {
|
|
113
256
|
terminateReason = reason;
|
|
114
257
|
break;
|
|
115
258
|
}
|
|
116
|
-
|
|
117
|
-
|
|
259
|
+
// Check for timeout or external abort.
|
|
260
|
+
if (combinedSignal.aborted) {
|
|
261
|
+
// Determine which signal caused the abort.
|
|
262
|
+
terminateReason = timeoutController.signal.aborted
|
|
263
|
+
? AgentTerminateMode.TIMEOUT
|
|
264
|
+
: AgentTerminateMode.ABORTED;
|
|
118
265
|
break;
|
|
119
266
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
267
|
+
const turnResult = await this.executeTurn(chat, currentMessage, tools, turnCounter++, combinedSignal, timeoutController.signal);
|
|
268
|
+
if (turnResult.status === 'stop') {
|
|
269
|
+
terminateReason = turnResult.terminateReason;
|
|
270
|
+
// Only set finalResult if the turn provided one (e.g., error or goal).
|
|
271
|
+
if (turnResult.finalResult) {
|
|
272
|
+
finalResult = turnResult.finalResult;
|
|
273
|
+
}
|
|
274
|
+
break; // Exit the loop for *any* stop reason.
|
|
126
275
|
}
|
|
127
|
-
// If
|
|
128
|
-
|
|
129
|
-
|
|
276
|
+
// If status is 'continue', update message for the next loop
|
|
277
|
+
currentMessage = turnResult.nextMessage;
|
|
278
|
+
}
|
|
279
|
+
// === UNIFIED RECOVERY BLOCK ===
|
|
280
|
+
// Only attempt recovery if it's a known recoverable reason.
|
|
281
|
+
// We don't recover from GOAL (already done) or ABORTED (user cancelled).
|
|
282
|
+
if (terminateReason !== AgentTerminateMode.ERROR &&
|
|
283
|
+
terminateReason !== AgentTerminateMode.ABORTED &&
|
|
284
|
+
terminateReason !== AgentTerminateMode.GOAL) {
|
|
285
|
+
const recoveryResult = await this.executeFinalWarningTurn(chat, tools, turnCounter, // Use current turnCounter for the recovery attempt
|
|
286
|
+
terminateReason, signal);
|
|
287
|
+
if (recoveryResult !== null) {
|
|
288
|
+
// Recovery Succeeded
|
|
289
|
+
terminateReason = AgentTerminateMode.GOAL;
|
|
290
|
+
finalResult = recoveryResult;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
// Recovery Failed. Set the final error message based on the *original* reason.
|
|
294
|
+
if (terminateReason === AgentTerminateMode.TIMEOUT) {
|
|
295
|
+
finalResult = `Agent timed out after ${this.definition.runConfig.max_time_minutes} minutes.`;
|
|
296
|
+
this.emitActivity('ERROR', {
|
|
297
|
+
error: finalResult,
|
|
298
|
+
context: 'timeout',
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else if (terminateReason === AgentTerminateMode.MAX_TURNS) {
|
|
302
|
+
finalResult = `Agent reached max turns limit (${this.definition.runConfig.max_turns}).`;
|
|
303
|
+
this.emitActivity('ERROR', {
|
|
304
|
+
error: finalResult,
|
|
305
|
+
context: 'max_turns',
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
else if (terminateReason === AgentTerminateMode.ERROR_NO_COMPLETE_TASK_CALL) {
|
|
309
|
+
// The finalResult was already set by executeTurn, but we re-emit just in case.
|
|
310
|
+
finalResult =
|
|
311
|
+
finalResult ||
|
|
312
|
+
`Agent stopped calling tools but did not call '${TASK_COMPLETE_TOOL_NAME}'.`;
|
|
313
|
+
this.emitActivity('ERROR', {
|
|
314
|
+
error: finalResult,
|
|
315
|
+
context: 'protocol_violation',
|
|
316
|
+
});
|
|
317
|
+
}
|
|
130
318
|
}
|
|
131
|
-
currentMessages = await this.processFunctionCalls(functionCalls, signal, promptId);
|
|
132
319
|
}
|
|
133
|
-
//
|
|
134
|
-
if (terminateReason
|
|
320
|
+
// === FINAL RETURN LOGIC ===
|
|
321
|
+
if (terminateReason === AgentTerminateMode.GOAL) {
|
|
135
322
|
return {
|
|
136
|
-
result:
|
|
323
|
+
result: finalResult || 'Task completed.',
|
|
137
324
|
terminate_reason: terminateReason,
|
|
138
325
|
};
|
|
139
326
|
}
|
|
140
|
-
// Phase 2: Extraction Phase
|
|
141
|
-
// A final message is sent to summarize findings and produce the output.
|
|
142
|
-
const extractionMessage = this.buildExtractionMessage();
|
|
143
|
-
const extractionMessages = [
|
|
144
|
-
{ role: 'user', parts: [{ text: extractionMessage }] },
|
|
145
|
-
];
|
|
146
|
-
const extractionPromptId = `${this.runtimeContext.getSessionId()}#${this.agentId}#extraction`;
|
|
147
|
-
// TODO: Consider if we should keep tools to avoid cache reset.
|
|
148
|
-
const { textResponse } = await this.callModel(chat, extractionMessages, [], // No tools are available in the extraction phase.
|
|
149
|
-
signal, extractionPromptId);
|
|
150
327
|
return {
|
|
151
|
-
result:
|
|
328
|
+
result: finalResult || 'Agent execution was terminated before completion.',
|
|
152
329
|
terminate_reason: terminateReason,
|
|
153
330
|
};
|
|
154
331
|
}
|
|
155
332
|
catch (error) {
|
|
333
|
+
// Check if the error is an AbortError caused by our internal timeout.
|
|
334
|
+
if (error instanceof Error &&
|
|
335
|
+
error.name === 'AbortError' &&
|
|
336
|
+
timeoutController.signal.aborted &&
|
|
337
|
+
!signal.aborted // Ensure the external signal was not the cause
|
|
338
|
+
) {
|
|
339
|
+
terminateReason = AgentTerminateMode.TIMEOUT;
|
|
340
|
+
// Also use the unified recovery logic here
|
|
341
|
+
if (chat && tools) {
|
|
342
|
+
const recoveryResult = await this.executeFinalWarningTurn(chat, tools, turnCounter, // Use current turnCounter
|
|
343
|
+
AgentTerminateMode.TIMEOUT, signal);
|
|
344
|
+
if (recoveryResult !== null) {
|
|
345
|
+
// Recovery Succeeded
|
|
346
|
+
terminateReason = AgentTerminateMode.GOAL;
|
|
347
|
+
finalResult = recoveryResult;
|
|
348
|
+
return {
|
|
349
|
+
result: finalResult,
|
|
350
|
+
terminate_reason: terminateReason,
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Recovery failed or wasn't possible
|
|
355
|
+
finalResult = `Agent timed out after ${this.definition.runConfig.max_time_minutes} minutes.`;
|
|
356
|
+
this.emitActivity('ERROR', {
|
|
357
|
+
error: finalResult,
|
|
358
|
+
context: 'timeout',
|
|
359
|
+
});
|
|
360
|
+
return {
|
|
361
|
+
result: finalResult,
|
|
362
|
+
terminate_reason: terminateReason,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
156
365
|
this.emitActivity('ERROR', { error: String(error) });
|
|
157
|
-
throw error; // Re-throw
|
|
366
|
+
throw error; // Re-throw other errors or external aborts.
|
|
367
|
+
}
|
|
368
|
+
finally {
|
|
369
|
+
clearTimeout(timeoutId);
|
|
370
|
+
logAgentFinish(this.runtimeContext, new AgentFinishEvent(this.agentId, this.definition.name, Date.now() - startTime, turnCounter, terminateReason));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async tryCompressChat(chat, prompt_id) {
|
|
374
|
+
const model = this.definition.modelConfig.model;
|
|
375
|
+
const { newHistory, info } = await this.compressionService.compress(chat, prompt_id, false, model, this.runtimeContext, this.hasFailedCompressionAttempt);
|
|
376
|
+
if (info.compressionStatus ===
|
|
377
|
+
CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
|
|
378
|
+
this.hasFailedCompressionAttempt = true;
|
|
379
|
+
}
|
|
380
|
+
else if (info.compressionStatus === CompressionStatus.COMPRESSED) {
|
|
381
|
+
if (newHistory) {
|
|
382
|
+
chat.setHistory(newHistory);
|
|
383
|
+
this.hasFailedCompressionAttempt = false;
|
|
384
|
+
}
|
|
158
385
|
}
|
|
159
386
|
}
|
|
160
387
|
/**
|
|
@@ -162,15 +389,15 @@ export class AgentExecutor {
|
|
|
162
389
|
*
|
|
163
390
|
* @returns The model's response, including any tool calls or text.
|
|
164
391
|
*/
|
|
165
|
-
async callModel(chat,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
392
|
+
async callModel(chat, message, tools, signal, promptId) {
|
|
393
|
+
if (tools.length > 0) {
|
|
394
|
+
// TODO(12622): Move tools back to config.
|
|
395
|
+
chat.setTools([{ functionDeclarations: tools }]);
|
|
396
|
+
}
|
|
397
|
+
const responseStream = await chat.sendMessageStream({
|
|
398
|
+
model: getModelConfigAlias(this.definition),
|
|
399
|
+
overrideScope: this.definition.name,
|
|
400
|
+
}, message.parts || [], promptId, signal);
|
|
174
401
|
const functionCalls = [];
|
|
175
402
|
let textResponse = '';
|
|
176
403
|
for await (const resp of responseStream) {
|
|
@@ -202,28 +429,18 @@ export class AgentExecutor {
|
|
|
202
429
|
}
|
|
203
430
|
/** Initializes a `GeminiChat` instance for the agent run. */
|
|
204
431
|
async createChatObject(inputs) {
|
|
205
|
-
const { promptConfig
|
|
432
|
+
const { promptConfig } = this.definition;
|
|
206
433
|
if (!promptConfig.systemPrompt && !promptConfig.initialMessages) {
|
|
207
434
|
throw new Error('PromptConfig must define either `systemPrompt` or `initialMessages`.');
|
|
208
435
|
}
|
|
209
|
-
const startHistory =
|
|
436
|
+
const startHistory = this.applyTemplateToInitialMessages(promptConfig.initialMessages ?? [], inputs);
|
|
210
437
|
// Build system instruction from the templated prompt string.
|
|
211
438
|
const systemInstruction = promptConfig.systemPrompt
|
|
212
439
|
? await this.buildSystemPrompt(inputs)
|
|
213
440
|
: undefined;
|
|
214
441
|
try {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
topP: modelConfig.top_p,
|
|
218
|
-
thinkingConfig: {
|
|
219
|
-
includeThoughts: true,
|
|
220
|
-
thinkingBudget: modelConfig.thinkingBudget ?? -1,
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
if (systemInstruction) {
|
|
224
|
-
generationConfig.systemInstruction = systemInstruction;
|
|
225
|
-
}
|
|
226
|
-
return new GeminiChat(this.runtimeContext, generationConfig, startHistory);
|
|
442
|
+
return new GeminiChat(this.runtimeContext, systemInstruction, [], // set in `callModel`,
|
|
443
|
+
startHistory);
|
|
227
444
|
}
|
|
228
445
|
catch (error) {
|
|
229
446
|
await reportError(error, `Error initializing Gemini chat for agent ${this.definition.name}.`, startHistory, 'startChat');
|
|
@@ -234,68 +451,199 @@ export class AgentExecutor {
|
|
|
234
451
|
/**
|
|
235
452
|
* Executes function calls requested by the model and returns the results.
|
|
236
453
|
*
|
|
237
|
-
* @returns A new `Content` object
|
|
454
|
+
* @returns A new `Content` object for history, any submitted output, and completion status.
|
|
238
455
|
*/
|
|
239
456
|
async processFunctionCalls(functionCalls, signal, promptId) {
|
|
240
457
|
const allowedToolNames = new Set(this.toolRegistry.getAllToolNames());
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
const args = functionCall.args ?? {};
|
|
458
|
+
// Always allow the completion tool
|
|
459
|
+
allowedToolNames.add(TASK_COMPLETE_TOOL_NAME);
|
|
460
|
+
let submittedOutput = null;
|
|
461
|
+
let taskCompleted = false;
|
|
462
|
+
// We'll collect promises for the tool executions
|
|
463
|
+
const toolExecutionPromises = [];
|
|
464
|
+
// And we'll need a place to store the synchronous results (like complete_task or blocked calls)
|
|
465
|
+
const syncResponseParts = [];
|
|
466
|
+
for (const [index, functionCall] of functionCalls.entries()) {
|
|
467
|
+
const callId = functionCall.id ?? `${promptId}-${index}`;
|
|
468
|
+
const args = (functionCall.args ?? {});
|
|
253
469
|
this.emitActivity('TOOL_CALL_START', {
|
|
254
470
|
name: functionCall.name,
|
|
255
471
|
args,
|
|
256
472
|
});
|
|
473
|
+
if (functionCall.name === TASK_COMPLETE_TOOL_NAME) {
|
|
474
|
+
if (taskCompleted) {
|
|
475
|
+
// We already have a completion from this turn. Ignore subsequent ones.
|
|
476
|
+
const error = 'Task already marked complete in this turn. Ignoring duplicate call.';
|
|
477
|
+
syncResponseParts.push({
|
|
478
|
+
functionResponse: {
|
|
479
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
480
|
+
response: { error },
|
|
481
|
+
id: callId,
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
this.emitActivity('ERROR', {
|
|
485
|
+
context: 'tool_call',
|
|
486
|
+
name: functionCall.name,
|
|
487
|
+
error,
|
|
488
|
+
});
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const { outputConfig } = this.definition;
|
|
492
|
+
taskCompleted = true; // Signal completion regardless of output presence
|
|
493
|
+
if (outputConfig) {
|
|
494
|
+
const outputName = outputConfig.outputName;
|
|
495
|
+
if (args[outputName] !== undefined) {
|
|
496
|
+
const outputValue = args[outputName];
|
|
497
|
+
const validationResult = outputConfig.schema.safeParse(outputValue);
|
|
498
|
+
if (!validationResult.success) {
|
|
499
|
+
taskCompleted = false; // Validation failed, revoke completion
|
|
500
|
+
const error = `Output validation failed: ${JSON.stringify(validationResult.error.flatten())}`;
|
|
501
|
+
syncResponseParts.push({
|
|
502
|
+
functionResponse: {
|
|
503
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
504
|
+
response: { error },
|
|
505
|
+
id: callId,
|
|
506
|
+
},
|
|
507
|
+
});
|
|
508
|
+
this.emitActivity('ERROR', {
|
|
509
|
+
context: 'tool_call',
|
|
510
|
+
name: functionCall.name,
|
|
511
|
+
error,
|
|
512
|
+
});
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const validatedOutput = validationResult.data;
|
|
516
|
+
if (this.definition.processOutput) {
|
|
517
|
+
submittedOutput = this.definition.processOutput(validatedOutput);
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
submittedOutput =
|
|
521
|
+
typeof outputValue === 'string'
|
|
522
|
+
? outputValue
|
|
523
|
+
: JSON.stringify(outputValue, null, 2);
|
|
524
|
+
}
|
|
525
|
+
syncResponseParts.push({
|
|
526
|
+
functionResponse: {
|
|
527
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
528
|
+
response: { result: 'Output submitted and task completed.' },
|
|
529
|
+
id: callId,
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
this.emitActivity('TOOL_CALL_END', {
|
|
533
|
+
name: functionCall.name,
|
|
534
|
+
output: 'Output submitted and task completed.',
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// Failed to provide required output.
|
|
539
|
+
taskCompleted = false; // Revoke completion status
|
|
540
|
+
const error = `Missing required argument '${outputName}' for completion.`;
|
|
541
|
+
syncResponseParts.push({
|
|
542
|
+
functionResponse: {
|
|
543
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
544
|
+
response: { error },
|
|
545
|
+
id: callId,
|
|
546
|
+
},
|
|
547
|
+
});
|
|
548
|
+
this.emitActivity('ERROR', {
|
|
549
|
+
context: 'tool_call',
|
|
550
|
+
name: functionCall.name,
|
|
551
|
+
error,
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
// No output expected. Just signal completion.
|
|
557
|
+
submittedOutput = 'Task completed successfully.';
|
|
558
|
+
syncResponseParts.push({
|
|
559
|
+
functionResponse: {
|
|
560
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
561
|
+
response: { status: 'Task marked complete.' },
|
|
562
|
+
id: callId,
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
this.emitActivity('TOOL_CALL_END', {
|
|
566
|
+
name: functionCall.name,
|
|
567
|
+
output: 'Task marked complete.',
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
// Handle standard tools
|
|
573
|
+
if (!allowedToolNames.has(functionCall.name)) {
|
|
574
|
+
const error = `Unauthorized tool call: '${functionCall.name}' is not available to this agent.`;
|
|
575
|
+
debugLogger.warn(`[AgentExecutor] Blocked call: ${error}`);
|
|
576
|
+
syncResponseParts.push({
|
|
577
|
+
functionResponse: {
|
|
578
|
+
name: functionCall.name,
|
|
579
|
+
id: callId,
|
|
580
|
+
response: { error },
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
this.emitActivity('ERROR', {
|
|
584
|
+
context: 'tool_call_unauthorized',
|
|
585
|
+
name: functionCall.name,
|
|
586
|
+
callId,
|
|
587
|
+
error,
|
|
588
|
+
});
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
257
591
|
const requestInfo = {
|
|
258
592
|
callId,
|
|
259
593
|
name: functionCall.name,
|
|
260
|
-
args
|
|
594
|
+
args,
|
|
261
595
|
isClientInitiated: true,
|
|
262
596
|
prompt_id: promptId,
|
|
263
597
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
this.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
598
|
+
// Create a promise for the tool execution
|
|
599
|
+
const executionPromise = (async () => {
|
|
600
|
+
const { response: toolResponse } = await executeToolCall(this.runtimeContext, requestInfo, signal);
|
|
601
|
+
if (toolResponse.error) {
|
|
602
|
+
this.emitActivity('ERROR', {
|
|
603
|
+
context: 'tool_call',
|
|
604
|
+
name: functionCall.name,
|
|
605
|
+
error: toolResponse.error.message,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
609
|
+
this.emitActivity('TOOL_CALL_END', {
|
|
610
|
+
name: functionCall.name,
|
|
611
|
+
output: toolResponse.resultDisplay,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
return toolResponse.responseParts;
|
|
615
|
+
})();
|
|
616
|
+
toolExecutionPromises.push(executionPromise);
|
|
617
|
+
}
|
|
618
|
+
// Wait for all tool executions to complete
|
|
619
|
+
const asyncResults = await Promise.all(toolExecutionPromises);
|
|
620
|
+
// Combine all response parts
|
|
621
|
+
const toolResponseParts = [...syncResponseParts];
|
|
622
|
+
for (const result of asyncResults) {
|
|
623
|
+
if (result) {
|
|
624
|
+
toolResponseParts.push(...result);
|
|
277
625
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
.filter((part) => part !== undefined);
|
|
284
|
-
// If all authorized tool calls failed, provide a generic error message
|
|
285
|
-
// to the model so it can try a different approach.
|
|
286
|
-
if (functionCalls.length > 0 && toolResponseParts.length === 0) {
|
|
626
|
+
}
|
|
627
|
+
// If all authorized tool calls failed (and task isn't complete), provide a generic error.
|
|
628
|
+
if (functionCalls.length > 0 &&
|
|
629
|
+
toolResponseParts.length === 0 &&
|
|
630
|
+
!taskCompleted) {
|
|
287
631
|
toolResponseParts.push({
|
|
288
|
-
text: 'All tool calls failed. Please analyze the errors and try an alternative approach.',
|
|
632
|
+
text: 'All tool calls failed or were unauthorized. Please analyze the errors and try an alternative approach.',
|
|
289
633
|
});
|
|
290
634
|
}
|
|
291
|
-
return
|
|
635
|
+
return {
|
|
636
|
+
nextMessage: { role: 'user', parts: toolResponseParts },
|
|
637
|
+
submittedOutput,
|
|
638
|
+
taskCompleted,
|
|
639
|
+
};
|
|
292
640
|
}
|
|
293
641
|
/**
|
|
294
642
|
* Prepares the list of tool function declarations to be sent to the model.
|
|
295
643
|
*/
|
|
296
644
|
prepareToolsList() {
|
|
297
645
|
const toolsList = [];
|
|
298
|
-
const { toolConfig } = this.definition;
|
|
646
|
+
const { toolConfig, outputConfig } = this.definition;
|
|
299
647
|
if (toolConfig) {
|
|
300
648
|
const toolNamesToLoad = [];
|
|
301
649
|
for (const toolRef of toolConfig.tools) {
|
|
@@ -314,11 +662,32 @@ export class AgentExecutor {
|
|
|
314
662
|
// Add schemas from tools that were registered by name.
|
|
315
663
|
toolsList.push(...this.toolRegistry.getFunctionDeclarationsFiltered(toolNamesToLoad));
|
|
316
664
|
}
|
|
665
|
+
// Always inject complete_task.
|
|
666
|
+
// Configure its schema based on whether output is expected.
|
|
667
|
+
const completeTool = {
|
|
668
|
+
name: TASK_COMPLETE_TOOL_NAME,
|
|
669
|
+
description: outputConfig
|
|
670
|
+
? 'Call this tool to submit your final answer and complete the task. This is the ONLY way to finish.'
|
|
671
|
+
: 'Call this tool to signal that you have completed your task. This is the ONLY way to finish.',
|
|
672
|
+
parameters: {
|
|
673
|
+
type: Type.OBJECT,
|
|
674
|
+
properties: {},
|
|
675
|
+
required: [],
|
|
676
|
+
},
|
|
677
|
+
};
|
|
678
|
+
if (outputConfig) {
|
|
679
|
+
const jsonSchema = zodToJsonSchema(outputConfig.schema);
|
|
680
|
+
const { $schema: _$schema, definitions: _definitions, ...schema } = jsonSchema;
|
|
681
|
+
completeTool.parameters.properties[outputConfig.outputName] =
|
|
682
|
+
schema;
|
|
683
|
+
completeTool.parameters.required.push(outputConfig.outputName);
|
|
684
|
+
}
|
|
685
|
+
toolsList.push(completeTool);
|
|
317
686
|
return toolsList;
|
|
318
687
|
}
|
|
319
688
|
/** Builds the system prompt from the agent definition and inputs. */
|
|
320
689
|
async buildSystemPrompt(inputs) {
|
|
321
|
-
const { promptConfig
|
|
690
|
+
const { promptConfig } = this.definition;
|
|
322
691
|
if (!promptConfig.systemPrompt) {
|
|
323
692
|
return '';
|
|
324
693
|
}
|
|
@@ -327,37 +696,35 @@ export class AgentExecutor {
|
|
|
327
696
|
// Append environment context (CWD and folder structure).
|
|
328
697
|
const dirContext = await getDirectoryContextString(this.runtimeContext);
|
|
329
698
|
finalPrompt += `\n\n# Environment Context\n${dirContext}`;
|
|
330
|
-
// Append completion criteria to guide the model's output.
|
|
331
|
-
if (outputConfig?.completion_criteria) {
|
|
332
|
-
finalPrompt += '\n\nEnsure you complete the following:\n';
|
|
333
|
-
for (const criteria of outputConfig.completion_criteria) {
|
|
334
|
-
finalPrompt += `- ${criteria}\n`;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
699
|
// Append standard rules for non-interactive execution.
|
|
338
700
|
finalPrompt += `
|
|
339
701
|
Important Rules:
|
|
340
702
|
* You are running in a non-interactive mode. You CANNOT ask the user for input or clarification.
|
|
341
703
|
* Work systematically using available tools to complete your task.
|
|
342
|
-
* Always use absolute paths for file operations. Construct them using the provided "Environment Context"
|
|
343
|
-
|
|
704
|
+
* Always use absolute paths for file operations. Construct them using the provided "Environment Context".`;
|
|
705
|
+
finalPrompt += `
|
|
706
|
+
* When you have completed your task, you MUST call the \`${TASK_COMPLETE_TOOL_NAME}\` tool.
|
|
707
|
+
* Do not call any other tools in the same turn as \`${TASK_COMPLETE_TOOL_NAME}\`.
|
|
708
|
+
* This is the ONLY way to complete your mission. If you stop calling tools without calling this, you have failed.`;
|
|
344
709
|
return finalPrompt;
|
|
345
710
|
}
|
|
346
|
-
/**
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Applies template strings to initial messages.
|
|
713
|
+
*
|
|
714
|
+
* @param initialMessages The initial messages from the prompt config.
|
|
715
|
+
* @param inputs The validated input parameters for this invocation.
|
|
716
|
+
* @returns A new array of `Content` with templated strings.
|
|
717
|
+
*/
|
|
718
|
+
applyTemplateToInitialMessages(initialMessages, inputs) {
|
|
719
|
+
return initialMessages.map((content) => {
|
|
720
|
+
const newParts = (content.parts ?? []).map((part) => {
|
|
721
|
+
if ('text' in part && part.text !== undefined) {
|
|
722
|
+
return { text: templateString(part.text, inputs) };
|
|
355
723
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return 'Based on your work so far, provide a comprehensive summary of your analysis and findings. Do not perform any more function calls.';
|
|
724
|
+
return part;
|
|
725
|
+
});
|
|
726
|
+
return { ...content, parts: newParts };
|
|
727
|
+
});
|
|
361
728
|
}
|
|
362
729
|
/**
|
|
363
730
|
* Validates that all tools in a registry are safe for non-interactive use.
|
|
@@ -368,14 +735,13 @@ Important Rules:
|
|
|
368
735
|
// Tools that are non-interactive. This is temporary until we have tool
|
|
369
736
|
// confirmations for subagents.
|
|
370
737
|
const allowlist = new Set([
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
WebSearchTool.Name,
|
|
738
|
+
LS_TOOL_NAME,
|
|
739
|
+
READ_FILE_TOOL_NAME,
|
|
740
|
+
GREP_TOOL_NAME,
|
|
741
|
+
GLOB_TOOL_NAME,
|
|
742
|
+
READ_MANY_FILES_TOOL_NAME,
|
|
743
|
+
MEMORY_TOOL_NAME,
|
|
744
|
+
WEB_SEARCH_TOOL_NAME,
|
|
379
745
|
]);
|
|
380
746
|
for (const tool of toolRegistry.getAllTools()) {
|
|
381
747
|
if (!allowlist.has(tool.name)) {
|
|
@@ -395,10 +761,6 @@ Important Rules:
|
|
|
395
761
|
if (runConfig.max_turns && turnCounter >= runConfig.max_turns) {
|
|
396
762
|
return AgentTerminateMode.MAX_TURNS;
|
|
397
763
|
}
|
|
398
|
-
const elapsedMinutes = (Date.now() - startTime) / (1000 * 60);
|
|
399
|
-
if (elapsedMinutes >= runConfig.max_time_minutes) {
|
|
400
|
-
return AgentTerminateMode.TIMEOUT;
|
|
401
|
-
}
|
|
402
764
|
return null;
|
|
403
765
|
}
|
|
404
766
|
/** Emits an activity event to the configured callback. */
|