@office-ai/aioncli-core 0.18.7 → 0.24.0-preview.1
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/docs/CONTRIBUTING.md +546 -0
- package/dist/docs/architecture.md +80 -0
- package/dist/docs/assets/connected_devtools.png +0 -0
- package/dist/docs/assets/gemini-screenshot.png +0 -0
- package/dist/docs/assets/release_patch.png +0 -0
- package/dist/docs/assets/theme-ansi-light.png +0 -0
- package/dist/docs/assets/theme-ansi.png +0 -0
- package/dist/docs/assets/theme-atom-one.png +0 -0
- package/dist/docs/assets/theme-ayu-light.png +0 -0
- package/dist/docs/assets/theme-ayu.png +0 -0
- package/dist/docs/assets/theme-custom.png +0 -0
- package/dist/docs/assets/theme-default-light.png +0 -0
- package/dist/docs/assets/theme-default.png +0 -0
- package/dist/docs/assets/theme-dracula.png +0 -0
- package/dist/docs/assets/theme-github-light.png +0 -0
- package/dist/docs/assets/theme-github.png +0 -0
- package/dist/docs/assets/theme-google-light.png +0 -0
- package/dist/docs/assets/theme-xcode-light.png +0 -0
- package/dist/docs/changelogs/index.md +592 -0
- package/dist/docs/changelogs/latest.md +225 -0
- package/dist/docs/changelogs/preview.md +129 -0
- package/dist/docs/changelogs/releases.md +896 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +354 -0
- package/dist/docs/cli/configuration.md +780 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +108 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +388 -0
- package/dist/docs/cli/index.md +63 -0
- package/dist/docs/cli/keyboard-shortcuts.md +143 -0
- package/dist/docs/cli/model-routing.md +37 -0
- package/dist/docs/cli/model.md +62 -0
- package/dist/docs/cli/sandbox.md +171 -0
- package/dist/docs/cli/session-management.md +158 -0
- package/dist/docs/cli/settings.md +114 -0
- package/dist/docs/cli/skills.md +156 -0
- package/dist/docs/cli/system-prompt.md +93 -0
- package/dist/docs/cli/telemetry.md +791 -0
- package/dist/docs/cli/themes.md +237 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +124 -0
- package/dist/docs/cli/tutorials.md +87 -0
- package/dist/docs/cli/uninstall.md +47 -0
- package/dist/docs/core/index.md +101 -0
- package/dist/docs/core/memport.md +244 -0
- package/dist/docs/core/policy-engine.md +267 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extension.md +160 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +245 -0
- package/dist/docs/extensions/index.md +293 -0
- package/dist/docs/faq.md +154 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +888 -0
- package/dist/docs/get-started/configuration.md +1536 -0
- package/dist/docs/get-started/deployment.md +143 -0
- package/dist/docs/get-started/examples.md +219 -0
- package/dist/docs/get-started/gemini-3.md +116 -0
- package/dist/docs/get-started/index.md +71 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/hooks/best-practices.md +856 -0
- package/dist/docs/hooks/index.md +687 -0
- package/dist/docs/hooks/reference.md +168 -0
- package/dist/docs/hooks/writing-hooks.md +1026 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +202 -0
- package/dist/docs/index.md +147 -0
- package/dist/docs/integration-tests.md +211 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +128 -0
- package/dist/docs/mermaid/context.mmd +103 -0
- package/dist/docs/mermaid/render-path.mmd +64 -0
- package/dist/docs/npm.md +62 -0
- package/dist/docs/quota-and-pricing.md +158 -0
- package/dist/docs/release-confidence.md +164 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/sidebar.json +301 -0
- package/dist/docs/tools/file-system.md +217 -0
- package/dist/docs/tools/index.md +95 -0
- package/dist/docs/tools/mcp-server.md +1044 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +57 -0
- package/dist/docs/tools/web-fetch.md +59 -0
- package/dist/docs/tools/web-search.md +42 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +158 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.d.ts +78 -0
- package/dist/src/agents/a2a-client-manager.js +295 -0
- package/dist/src/agents/a2a-client-manager.js.map +1 -0
- package/dist/src/agents/a2a-client-manager.test.d.ts +6 -0
- package/dist/src/agents/a2a-client-manager.test.js +237 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +28 -0
- package/dist/src/agents/a2aUtils.js +111 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.d.ts +6 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +5 -4
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/delegate-to-agent-tool.d.ts +19 -0
- package/dist/src/agents/delegate-to-agent-tool.js +115 -0
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -0
- package/dist/src/agents/delegate-to-agent-tool.test.d.ts +6 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js +165 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +23 -0
- package/dist/src/agents/introspection-agent.js +72 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.d.ts +6 -0
- package/dist/src/agents/introspection-agent.test.js +47 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/local-executor.d.ts +108 -0
- package/dist/src/agents/local-executor.js +801 -0
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-executor.test.d.ts +6 -0
- package/dist/src/agents/local-executor.test.js +1380 -0
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +45 -0
- package/dist/src/agents/local-invocation.js +101 -0
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +6 -0
- package/dist/src/agents/local-invocation.test.js +218 -0
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +25 -1
- package/dist/src/agents/registry.js +149 -5
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +247 -25
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.d.ts +35 -0
- package/dist/src/agents/remote-invocation.js +129 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +6 -0
- package/dist/src/agents/remote-invocation.test.js +201 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +2 -2
- package/dist/src/agents/subagent-tool-wrapper.js +11 -6
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +25 -17
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/toml-loader.d.ts +74 -0
- package/dist/src/agents/toml-loader.js +248 -0
- package/dist/src/agents/toml-loader.js.map +1 -0
- package/dist/src/agents/toml-loader.test.d.ts +6 -0
- package/dist/src/agents/toml-loader.test.js +309 -0
- package/dist/src/agents/toml-loader.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +18 -4
- package/dist/src/availability/errorClassification.d.ts +7 -0
- package/dist/src/availability/errorClassification.js +20 -0
- package/dist/src/availability/errorClassification.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +36 -0
- package/dist/src/availability/modelAvailabilityService.js +87 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.test.d.ts +6 -0
- package/dist/src/availability/modelAvailabilityService.test.js +140 -0
- package/dist/src/availability/modelAvailabilityService.test.js.map +1 -0
- package/dist/src/availability/modelPolicy.d.ts +49 -0
- package/dist/src/availability/modelPolicy.js +7 -0
- package/dist/src/availability/modelPolicy.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +23 -0
- package/dist/src/availability/policyCatalog.js +82 -0
- package/dist/src/availability/policyCatalog.js.map +1 -0
- package/dist/src/availability/policyCatalog.test.d.ts +6 -0
- package/dist/src/availability/policyCatalog.test.js +70 -0
- package/dist/src/availability/policyCatalog.test.js.map +1 -0
- package/dist/src/availability/policyHelpers.d.ts +52 -0
- package/dist/src/availability/policyHelpers.js +136 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/policyHelpers.test.d.ts +6 -0
- package/dist/src/availability/policyHelpers.test.js +182 -0
- package/dist/src/availability/policyHelpers.test.js.map +1 -0
- package/dist/src/availability/testUtils.d.ts +10 -0
- package/dist/src/availability/testUtils.js +22 -0
- package/dist/src/availability/testUtils.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.js +3 -2
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.test.js +7 -10
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.js +2 -2
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -0
- package/dist/src/code_assist/oauth2.js +73 -17
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +195 -18
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +10 -1
- package/dist/src/code_assist/server.js +81 -15
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +221 -25
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.js +6 -4
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +63 -0
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.d.ts +14 -0
- package/dist/src/code_assist/telemetry.js +156 -0
- package/dist/src/code_assist/telemetry.js.map +1 -0
- package/dist/src/code_assist/telemetry.test.d.ts +6 -0
- package/dist/src/code_assist/telemetry.test.js +300 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +84 -1
- package/dist/src/code_assist/types.js +21 -0
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/init.d.ts +7 -0
- package/dist/src/commands/init.js +53 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/init.test.d.ts +6 -0
- package/dist/src/commands/init.test.js +25 -0
- package/dist/src/commands/init.test.js.map +1 -0
- package/dist/src/commands/restore.d.ts +9 -0
- package/dist/src/commands/restore.js +46 -0
- package/dist/src/commands/restore.js.map +1 -0
- package/dist/src/commands/restore.test.d.ts +6 -0
- package/dist/src/commands/restore.test.js +137 -0
- package/dist/src/commands/restore.test.js.map +1 -0
- package/dist/src/commands/types.d.ts +41 -0
- package/dist/src/commands/types.js +7 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/config/config.d.ts +120 -23
- package/dist/src/config/config.js +336 -116
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +373 -95
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +46 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +11 -35
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/config/models.d.ts +29 -15
- package/dist/src/config/models.js +78 -28
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +91 -77
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +4 -0
- package/dist/src/config/storage.js +12 -0
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +16 -0
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.js +66 -3
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +29 -2
- package/dist/src/confirmation-bus/types.js +3 -0
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +30 -2
- package/dist/src/core/baseLlmClient.js +107 -49
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +271 -13
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +5 -1
- package/dist/src/core/client.js +241 -63
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +462 -72
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.d.ts +36 -0
- package/dist/src/core/clientHookTriggers.js +76 -0
- package/dist/src/core/clientHookTriggers.js.map +1 -0
- package/dist/src/core/contentGenerator.js +17 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +132 -3
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +55 -0
- package/dist/src/core/coreToolHookTriggers.js +304 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolHookTriggers.test.d.ts +6 -0
- package/dist/src/core/coreToolHookTriggers.test.js +191 -0
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +6 -85
- package/dist/src/core/coreToolScheduler.js +69 -267
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +161 -346
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.js +132 -76
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +240 -257
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +64 -0
- package/dist/src/core/geminiChatHookTriggers.js +136 -0
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -0
- package/dist/src/core/geminiChat_network_retry.test.d.ts +6 -0
- package/dist/src/core/geminiChat_network_retry.test.js +196 -0
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.js +23 -6
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +13 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +82 -26
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +102 -3
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/sessionHookTriggers.d.ts +29 -0
- package/dist/src/core/sessionHookTriggers.js +75 -0
- package/dist/src/core/sessionHookTriggers.js.map +1 -0
- package/dist/src/core/turn.d.ts +34 -21
- package/dist/src/core/turn.js +33 -13
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +0 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +101 -93
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +186 -173
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +8 -0
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +113 -0
- package/dist/src/hooks/hookEventHandler.js +571 -0
- package/dist/src/hooks/hookEventHandler.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.test.d.ts +6 -0
- package/dist/src/hooks/hookEventHandler.test.js +461 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +1 -5
- package/dist/src/hooks/hookPlanner.js +2 -7
- package/dist/src/hooks/hookPlanner.js.map +1 -1
- package/dist/src/hooks/hookPlanner.test.js +62 -2
- package/dist/src/hooks/hookPlanner.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.d.ts +6 -18
- package/dist/src/hooks/hookRegistry.js +49 -35
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +167 -8
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.d.ts +5 -3
- package/dist/src/hooks/hookRunner.js +74 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +174 -36
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +40 -0
- package/dist/src/hooks/hookSystem.js +65 -0
- package/dist/src/hooks/hookSystem.js.map +1 -0
- package/dist/src/hooks/hookSystem.test.d.ts +6 -0
- package/dist/src/hooks/hookSystem.test.js +319 -0
- package/dist/src/hooks/hookSystem.test.js.map +1 -0
- package/dist/src/hooks/index.d.ts +17 -0
- package/dist/src/hooks/index.js +18 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/trustedHooks.d.ts +28 -0
- package/dist/src/hooks/trustedHooks.js +90 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -0
- package/dist/src/hooks/trustedHooks.test.d.ts +6 -0
- package/dist/src/hooks/trustedHooks.test.js +154 -0
- package/dist/src/hooks/trustedHooks.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +21 -11
- package/dist/src/hooks/types.js +31 -27
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +5 -24
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +32 -1
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +9 -4
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +17 -0
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +1 -1
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +4 -4
- package/dist/src/index.d.ts +17 -1
- package/dist/src/index.js +18 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/auth-provider.d.ts +16 -0
- package/dist/src/mcp/auth-provider.js +7 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +10 -2
- package/dist/src/mcp/google-auth-provider.js +28 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +45 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +6 -2
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +4 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +8 -1
- package/dist/src/mcp/oauth-utils.js +31 -2
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +42 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +2 -2
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/output/json-formatter.d.ts +2 -2
- package/dist/src/output/json-formatter.js +6 -3
- package/dist/src/output/json-formatter.js.map +1 -1
- package/dist/src/output/json-formatter.test.js +37 -9
- package/dist/src/output/json-formatter.test.js.map +1 -1
- package/dist/src/output/stream-json-formatter.js +6 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -1
- package/dist/src/output/stream-json-formatter.test.js +98 -100
- package/dist/src/output/stream-json-formatter.test.js.map +1 -1
- package/dist/src/output/types.d.ts +3 -0
- package/dist/src/output/types.js.map +1 -1
- package/dist/src/policy/config.js +140 -15
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +21 -0
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.d.ts +6 -0
- package/dist/src/policy/persistence.test.js +154 -0
- package/dist/src/policy/persistence.test.js.map +1 -0
- package/dist/src/policy/policies/agent.toml +31 -0
- package/dist/src/policy/policies/read-only.toml +5 -0
- package/dist/src/policy/policies/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +30 -1
- package/dist/src/policy/policy-engine.js +192 -5
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +520 -3
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.d.ts +6 -0
- package/dist/src/policy/policy-updater.test.js +116 -0
- package/dist/src/policy/policy-updater.test.js.map +1 -0
- package/dist/src/policy/shell-safety.test.d.ts +6 -0
- package/dist/src/policy/shell-safety.test.js +75 -0
- package/dist/src/policy/shell-safety.test.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +3 -5
- package/dist/src/policy/toml-loader.js +12 -60
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +38 -7
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +72 -1
- package/dist/src/policy/types.js +21 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +42 -0
- package/dist/src/policy/utils.js.map +1 -0
- package/dist/src/policy/utils.test.d.ts +6 -0
- package/dist/src/policy/utils.test.js +64 -0
- package/dist/src/policy/utils.test.js.map +1 -0
- package/dist/src/resources/resource-registry.d.ts +30 -0
- package/dist/src/resources/resource-registry.js +57 -0
- package/dist/src/resources/resource-registry.js.map +1 -0
- package/dist/src/resources/resource-registry.test.d.ts +6 -0
- package/dist/src/resources/resource-registry.test.js +54 -0
- package/dist/src/resources/resource-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +0 -15
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +0 -62
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.js +10 -21
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +2 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +4 -2
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.test.js +11 -10
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +20 -12
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +63 -39
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +3 -2
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/safety/checker-runner.js +17 -6
- package/dist/src/safety/checker-runner.js.map +1 -1
- package/dist/src/scheduler/tool-executor.d.ts +22 -0
- package/dist/src/scheduler/tool-executor.js +198 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/tool-executor.test.d.ts +6 -0
- package/dist/src/scheduler/tool-executor.test.js +231 -0
- package/dist/src/scheduler/tool-executor.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +95 -0
- package/dist/src/scheduler/types.js +7 -0
- package/dist/src/scheduler/types.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +1 -0
- package/dist/src/services/chatCompressionService.js +38 -8
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +35 -31
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +14 -0
- package/dist/src/services/chatRecordingService.js +37 -0
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +29 -0
- package/dist/src/services/contextManager.js +71 -0
- package/dist/src/services/contextManager.js.map +1 -0
- package/dist/src/services/contextManager.test.d.ts +6 -0
- package/dist/src/services/contextManager.test.js +104 -0
- package/dist/src/services/contextManager.test.js.map +1 -0
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +141 -0
- package/dist/src/services/environmentSanitization.js.map +1 -0
- package/dist/src/services/environmentSanitization.test.d.ts +6 -0
- package/dist/src/services/environmentSanitization.test.js +284 -0
- package/dist/src/services/environmentSanitization.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +0 -9
- package/dist/src/services/fileSystemService.js +0 -11
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/gitService.js +18 -2
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +56 -0
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +5 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +14 -8
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.js +32 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +1 -1
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +4 -0
- package/dist/src/services/modelConfigService.js +8 -3
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +221 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/modelConfigServiceTestUtils.d.ts +10 -0
- package/dist/src/services/modelConfigServiceTestUtils.js +17 -0
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryService.d.ts +28 -0
- package/dist/src/services/sessionSummaryService.js +131 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -0
- package/dist/src/services/sessionSummaryService.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryService.test.js +785 -0
- package/dist/src/services/sessionSummaryService.test.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.d.ts +16 -0
- package/dist/src/services/sessionSummaryUtils.js +129 -0
- package/dist/src/services/sessionSummaryUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.test.d.ts +6 -0
- package/dist/src/services/sessionSummaryUtils.test.js +137 -0
- package/dist/src/services/sessionSummaryUtils.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +4 -0
- package/dist/src/services/shellExecutionService.js +45 -27
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +240 -8
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
- package/dist/src/services/test-data/resolved-aliases.golden.json +36 -0
- package/dist/src/skills/skillLoader.d.ts +28 -0
- package/dist/src/skills/skillLoader.js +77 -0
- package/dist/src/skills/skillLoader.js.map +1 -0
- package/dist/src/skills/skillLoader.test.d.ts +1 -0
- package/dist/src/skills/skillLoader.test.js +2 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +51 -0
- package/dist/src/skills/skillManager.js +89 -0
- package/dist/src/skills/skillManager.js.map +1 -0
- package/dist/src/skills/skillManager.test.d.ts +6 -0
- package/dist/src/skills/skillManager.test.js +128 -0
- package/dist/src/skills/skillManager.test.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +11 -7
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +127 -47
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +105 -18
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +9 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +20 -5
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.js +2 -0
- package/dist/src/telemetry/config.js.map +1 -1
- package/dist/src/telemetry/config.test.js +25 -0
- package/dist/src/telemetry/config.test.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +4 -3
- package/dist/src/telemetry/gcp-exporters.js +8 -4
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -1
- package/dist/src/telemetry/index.js +2 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +5 -3
- package/dist/src/telemetry/loggers.js +353 -334
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +1 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +238 -31
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +22 -0
- package/dist/src/telemetry/metrics.js +32 -0
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +64 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sanitize.d.ts +25 -0
- package/dist/src/telemetry/sanitize.js +48 -0
- package/dist/src/telemetry/sanitize.js.map +1 -0
- package/dist/src/telemetry/sanitize.test.d.ts +6 -0
- package/dist/src/telemetry/sanitize.test.js +279 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +9 -2
- package/dist/src/telemetry/sdk.js +142 -17
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +130 -28
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.js +1 -1
- package/dist/src/telemetry/semantic.js.map +1 -1
- package/dist/src/telemetry/startupProfiler.d.ts +51 -0
- package/dist/src/telemetry/startupProfiler.js +170 -0
- package/dist/src/telemetry/startupProfiler.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.test.d.ts +6 -0
- package/dist/src/telemetry/startupProfiler.test.js +285 -0
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.js +10 -3
- package/dist/src/telemetry/telemetry.test.js.map +1 -1
- package/dist/src/telemetry/trace.js +2 -2
- package/dist/src/telemetry/trace.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +62 -16
- package/dist/src/telemetry/types.js +157 -27
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +1 -0
- package/dist/src/telemetry/uiTelemetry.js +2 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +4 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +61 -0
- package/dist/src/test-utils/mock-message-bus.js +160 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +12 -11
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +27 -0
- package/dist/src/tools/activate-skill.js +120 -0
- package/dist/src/tools/activate-skill.js.map +1 -0
- package/dist/src/tools/activate-skill.test.d.ts +6 -0
- package/dist/src/tools/activate-skill.test.js +95 -0
- package/dist/src/tools/activate-skill.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.d.ts +6 -0
- package/dist/src/tools/confirmation-policy.test.js +142 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +27 -5
- package/dist/src/tools/edit.js +449 -137
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +258 -526
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/get-internal-docs.d.ts +27 -0
- package/dist/src/tools/get-internal-docs.js +129 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +6 -0
- package/dist/src/tools/get-internal-docs.test.js +57 -0
- package/dist/src/tools/get-internal-docs.test.js.map +1 -0
- package/dist/src/tools/glob.d.ts +2 -2
- package/dist/src/tools/glob.js +1 -1
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +2 -1
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +2 -2
- package/dist/src/tools/grep.js +1 -1
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +5 -4
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +2 -2
- package/dist/src/tools/ls.js +2 -2
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +2 -1
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +3 -1
- package/dist/src/tools/mcp-client-manager.js +42 -9
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +66 -10
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +44 -6
- package/dist/src/tools/mcp-client.js +476 -176
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +633 -36
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +2 -2
- package/dist/src/tools/mcp-tool.js +20 -7
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +35 -5
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +3 -3
- package/dist/src/tools/memoryTool.js +3 -4
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +5 -2
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.js +10 -37
- package/dist/src/tools/message-bus-integration.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +22 -13
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -2
- package/dist/src/tools/read-file.js +2 -2
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +3 -2
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +2 -2
- package/dist/src/tools/read-many-files.js +7 -6
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +4 -3
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +3 -2
- package/dist/src/tools/ripGrep.js +18 -7
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +60 -4
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +5 -7
- package/dist/src/tools/shell.js +77 -51
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +59 -63
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +2 -1
- package/dist/src/tools/tool-error.js +2 -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 +59 -0
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.d.ts +6 -0
- package/dist/src/tools/tool-names.test.js +43 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +11 -7
- package/dist/src/tools/tool-registry.js +15 -10
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +16 -11
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +25 -6
- package/dist/src/tools/tools.js +44 -25
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +3 -1
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +2 -2
- package/dist/src/tools/web-fetch.js +22 -9
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +18 -19
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +2 -2
- package/dist/src/tools/web-search.js +5 -5
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +2 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +2 -2
- package/dist/src/tools/write-file.js +10 -4
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +4 -1
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +2 -2
- package/dist/src/tools/write-todos.js +5 -4
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/write-todos.test.js +2 -1
- package/dist/src/tools/write-todos.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +8 -0
- package/dist/src/utils/bfsFileSearch.js +63 -23
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +65 -1
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/checkpointUtils.d.ts +82 -0
- package/dist/src/utils/checkpointUtils.js +117 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -0
- package/dist/src/utils/checkpointUtils.test.d.ts +6 -0
- package/dist/src/utils/checkpointUtils.test.js +229 -0
- package/dist/src/utils/checkpointUtils.test.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.d.ts +9 -0
- package/dist/src/utils/customHeaderUtils.js +34 -0
- package/dist/src/utils/customHeaderUtils.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.test.d.ts +6 -0
- package/dist/src/utils/customHeaderUtils.test.js +77 -0
- package/dist/src/utils/customHeaderUtils.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +3 -0
- package/dist/src/utils/debugLogger.js +28 -0
- package/dist/src/utils/debugLogger.js.map +1 -1
- package/dist/src/utils/editCorrector.js +6 -5
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +7 -3
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +9 -1
- package/dist/src/utils/editor.js +23 -14
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +1 -0
- package/dist/src/utils/environmentContext.js +4 -0
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +2 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errorReporting.js +13 -12
- package/dist/src/utils/errorReporting.js.map +1 -1
- package/dist/src/utils/errorReporting.test.js +17 -14
- package/dist/src/utils/errorReporting.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +8 -0
- package/dist/src/utils/errors.js +39 -2
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.d.ts +6 -0
- package/dist/src/utils/errors.test.js +155 -0
- package/dist/src/utils/errors.test.js.map +1 -0
- package/dist/src/utils/events.d.ts +49 -19
- package/dist/src/utils/events.js +21 -9
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +25 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/exitCodes.d.ts +12 -0
- package/dist/src/utils/exitCodes.js +13 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +2 -2
- package/dist/src/utils/extensionLoader.js +5 -6
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +11 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fetch.d.ts +1 -1
- package/dist/src/utils/fetch.js +3 -3
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -0
- package/dist/src/utils/fileUtils.js +53 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +127 -1
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/flashFallback.test.js +1 -1
- package/dist/src/utils/flashFallback.test.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.d.ts +11 -0
- package/dist/src/utils/geminiIgnoreParser.js +20 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -1
- package/dist/src/utils/geminiIgnoreParser.test.js +48 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.d.ts +3 -1
- package/dist/src/utils/generateContentResponseUtilities.js +106 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +279 -2
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.js +7 -2
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/googleErrors.js +31 -18
- package/dist/src/utils/googleErrors.js.map +1 -1
- package/dist/src/utils/googleErrors.test.js +10 -2
- package/dist/src/utils/googleErrors.test.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +3 -3
- package/dist/src/utils/googleQuotaErrors.js +32 -6
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +94 -2
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +5 -0
- package/dist/src/utils/memoryDiscovery.js +9 -5
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +31 -1
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +4 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +14 -0
- package/dist/src/utils/package.js +15 -2
- package/dist/src/utils/package.js.map +1 -1
- package/dist/src/utils/pathCorrector.js +12 -2
- package/dist/src/utils/pathCorrector.js.map +1 -1
- package/dist/src/utils/pathCorrector.test.js +6 -2
- package/dist/src/utils/pathCorrector.test.js.map +1 -1
- package/dist/src/utils/retry.d.ts +11 -0
- package/dist/src/utils/retry.js +62 -21
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +170 -10
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/schemaValidator.d.ts +1 -1
- package/dist/src/utils/schemaValidator.js +1 -1
- package/dist/src/utils/shell-permissions.d.ts +52 -0
- package/dist/src/utils/shell-permissions.js +188 -0
- package/dist/src/utils/shell-permissions.js.map +1 -0
- package/dist/src/utils/shell-permissions.test.d.ts +6 -0
- package/dist/src/utils/shell-permissions.test.js +369 -0
- package/dist/src/utils/shell-permissions.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +16 -47
- package/dist/src/utils/shell-utils.js +99 -195
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +99 -288
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +2 -2
- package/dist/src/utils/stdio.js +2 -2
- package/dist/src/utils/stdio.js.map +1 -1
- package/dist/src/utils/stdio.test.js +5 -5
- package/dist/src/utils/stdio.test.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +3 -2
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +4 -0
- package/dist/src/utils/terminal.js +12 -0
- package/dist/src/utils/terminal.js.map +1 -1
- package/dist/src/utils/terminalSerializer.test.js +17 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +19 -0
- package/dist/src/utils/tokenCalculation.js +85 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tokenCalculation.test.d.ts +6 -0
- package/dist/src/utils/tokenCalculation.test.js +87 -0
- package/dist/src/utils/tokenCalculation.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +9 -0
- package/dist/src/utils/tool-utils.js +29 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +17 -2
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/version.d.ts +6 -0
- package/dist/src/utils/version.js +15 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/version.test.d.ts +6 -0
- package/dist/src/utils/version.test.js +39 -0
- package/dist/src/utils/version.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
|
@@ -9,14 +9,17 @@ import { AuthType, } from './contentGenerator.js';
|
|
|
9
9
|
import {} from './geminiChat.js';
|
|
10
10
|
import { CompressionStatus, GeminiEventType, Turn, } from './turn.js';
|
|
11
11
|
import { getCoreSystemPrompt } from './prompts.js';
|
|
12
|
-
import {
|
|
12
|
+
import { DEFAULT_GEMINI_MODEL_AUTO } from '../config/models.js';
|
|
13
13
|
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
|
14
14
|
import { setSimulate429 } from '../utils/testUtils.js';
|
|
15
15
|
import { tokenLimit } from './tokenLimits.js';
|
|
16
16
|
import { ideContextStore } from '../ide/ideContext.js';
|
|
17
17
|
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
|
18
18
|
import { ChatCompressionService } from '../services/chatCompressionService.js';
|
|
19
|
+
import { createAvailabilityServiceMock } from '../availability/testUtils.js';
|
|
19
20
|
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
|
|
21
|
+
import { HookSystem } from '../hooks/hookSystem.js';
|
|
22
|
+
import * as policyCatalog from '../availability/policyCatalog.js';
|
|
20
23
|
vi.mock('../services/chatCompressionService.js');
|
|
21
24
|
// Mock fs module to prevent actual file system operations during tests
|
|
22
25
|
const mockFileSystem = new Map();
|
|
@@ -35,13 +38,16 @@ vi.mock('node:fs', () => {
|
|
|
35
38
|
});
|
|
36
39
|
}),
|
|
37
40
|
existsSync: vi.fn((path) => mockFileSystem.has(path)),
|
|
41
|
+
createWriteStream: vi.fn(() => ({
|
|
42
|
+
write: vi.fn(),
|
|
43
|
+
on: vi.fn(),
|
|
44
|
+
})),
|
|
38
45
|
};
|
|
39
46
|
return {
|
|
40
47
|
default: fsModule,
|
|
41
48
|
...fsModule,
|
|
42
49
|
};
|
|
43
50
|
});
|
|
44
|
-
// --- Mocks ---
|
|
45
51
|
const mockTurnRunFn = vi.fn();
|
|
46
52
|
vi.mock('./turn', async (importOriginal) => {
|
|
47
53
|
const actual = await importOriginal();
|
|
@@ -53,6 +59,7 @@ vi.mock('./turn', async (importOriginal) => {
|
|
|
53
59
|
constructor() {
|
|
54
60
|
// The constructor can be empty or do some mock setup
|
|
55
61
|
}
|
|
62
|
+
getResponseText = vi.fn().mockReturnValue('Mock Response');
|
|
56
63
|
}
|
|
57
64
|
// Export the mock class as 'Turn'
|
|
58
65
|
return {
|
|
@@ -85,6 +92,16 @@ vi.mock('../telemetry/uiTelemetry.js', () => ({
|
|
|
85
92
|
getLastPromptTokenCount: vi.fn(),
|
|
86
93
|
},
|
|
87
94
|
}));
|
|
95
|
+
vi.mock('../hooks/hookSystem.js');
|
|
96
|
+
vi.mock('./clientHookTriggers.js', () => ({
|
|
97
|
+
fireBeforeAgentHook: vi.fn(),
|
|
98
|
+
fireAfterAgentHook: vi.fn().mockResolvedValue({
|
|
99
|
+
decision: 'allow',
|
|
100
|
+
continue: false,
|
|
101
|
+
suppressOutput: false,
|
|
102
|
+
systemMessage: undefined,
|
|
103
|
+
}),
|
|
104
|
+
}));
|
|
88
105
|
/**
|
|
89
106
|
* Array.fromAsync ponyfill, which will be available in es 2024.
|
|
90
107
|
*
|
|
@@ -102,6 +119,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
102
119
|
let mockConfig;
|
|
103
120
|
let client;
|
|
104
121
|
let mockGenerateContentFn;
|
|
122
|
+
let mockRouterService;
|
|
105
123
|
beforeEach(async () => {
|
|
106
124
|
vi.resetAllMocks();
|
|
107
125
|
ClearcutLogger.clearInstance();
|
|
@@ -119,10 +137,16 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
119
137
|
});
|
|
120
138
|
// Disable 429 simulation for tests
|
|
121
139
|
setSimulate429(false);
|
|
140
|
+
mockRouterService = {
|
|
141
|
+
route: vi
|
|
142
|
+
.fn()
|
|
143
|
+
.mockResolvedValue({ model: 'default-routed-model', reason: 'test' }),
|
|
144
|
+
};
|
|
122
145
|
mockContentGenerator = {
|
|
123
146
|
generateContent: mockGenerateContentFn,
|
|
124
147
|
generateContentStream: vi.fn(),
|
|
125
148
|
batchEmbedContents: vi.fn(),
|
|
149
|
+
countTokens: vi.fn().mockResolvedValue({ totalTokens: 100 }),
|
|
126
150
|
};
|
|
127
151
|
// Because the GeminiClient constructor kicks off an async process (startChat)
|
|
128
152
|
// that depends on a fully-formed Config object, we need to mock the
|
|
@@ -143,11 +167,15 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
143
167
|
.mockReturnValue(contentGeneratorConfig),
|
|
144
168
|
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
|
145
169
|
getModel: vi.fn().mockReturnValue('test-model'),
|
|
170
|
+
getUserTier: vi.fn().mockReturnValue(undefined),
|
|
146
171
|
getEmbeddingModel: vi.fn().mockReturnValue('test-embedding-model'),
|
|
147
172
|
getApiKey: vi.fn().mockReturnValue('test-key'),
|
|
148
173
|
getVertexAI: vi.fn().mockReturnValue(false),
|
|
149
174
|
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
|
150
175
|
getUserMemory: vi.fn().mockReturnValue(''),
|
|
176
|
+
getGlobalMemory: vi.fn().mockReturnValue(''),
|
|
177
|
+
getEnvironmentMemory: vi.fn().mockReturnValue(''),
|
|
178
|
+
isJitContextEnabled: vi.fn().mockReturnValue(false),
|
|
151
179
|
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
|
152
180
|
getProxy: vi.fn().mockReturnValue(undefined),
|
|
153
181
|
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
|
@@ -165,15 +193,13 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
165
193
|
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
|
166
194
|
}),
|
|
167
195
|
getGeminiClient: vi.fn(),
|
|
168
|
-
getModelRouterService: vi
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
196
|
+
getModelRouterService: vi
|
|
197
|
+
.fn()
|
|
198
|
+
.mockReturnValue(mockRouterService),
|
|
199
|
+
getMessageBus: vi.fn().mockReturnValue(undefined),
|
|
200
|
+
getEnableHooks: vi.fn().mockReturnValue(false),
|
|
173
201
|
getChatCompression: vi.fn().mockReturnValue(undefined),
|
|
174
202
|
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
|
175
|
-
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
|
176
|
-
getUseModelRouter: vi.fn().mockReturnValue(false),
|
|
177
203
|
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
|
178
204
|
getContinueOnFailedApiCall: vi.fn(),
|
|
179
205
|
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
|
@@ -199,7 +225,17 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
199
225
|
},
|
|
200
226
|
},
|
|
201
227
|
isInteractive: vi.fn().mockReturnValue(false),
|
|
228
|
+
getExperiments: () => { },
|
|
229
|
+
getActiveModel: vi.fn().mockReturnValue('test-model'),
|
|
230
|
+
setActiveModel: vi.fn(),
|
|
231
|
+
resetTurn: vi.fn(),
|
|
232
|
+
getModelAvailabilityService: vi
|
|
233
|
+
.fn()
|
|
234
|
+
.mockReturnValue(createAvailabilityServiceMock()),
|
|
202
235
|
};
|
|
236
|
+
mockConfig.getHookSystem = vi
|
|
237
|
+
.fn()
|
|
238
|
+
.mockReturnValue(new HookSystem(mockConfig));
|
|
203
239
|
client = new GeminiClient(mockConfig);
|
|
204
240
|
await client.initialize();
|
|
205
241
|
vi.mocked(mockConfig.getGeminiClient).mockReturnValue(client);
|
|
@@ -226,18 +262,18 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
226
262
|
it('should create a new chat session, clearing the old history', async () => {
|
|
227
263
|
// 1. Get the initial chat instance and add some history.
|
|
228
264
|
const initialChat = client.getChat();
|
|
229
|
-
const initialHistory =
|
|
265
|
+
const initialHistory = client.getHistory();
|
|
230
266
|
await client.addHistory({
|
|
231
267
|
role: 'user',
|
|
232
268
|
parts: [{ text: 'some old message' }],
|
|
233
269
|
});
|
|
234
|
-
const historyWithOldMessage =
|
|
270
|
+
const historyWithOldMessage = client.getHistory();
|
|
235
271
|
expect(historyWithOldMessage.length).toBeGreaterThan(initialHistory.length);
|
|
236
272
|
// 2. Call resetChat.
|
|
237
273
|
await client.resetChat();
|
|
238
274
|
// 3. Get the new chat instance and its history.
|
|
239
275
|
const newChat = client.getChat();
|
|
240
|
-
const newHistory =
|
|
276
|
+
const newHistory = client.getHistory();
|
|
241
277
|
// 4. Assert that the chat instance is new and the history is reset.
|
|
242
278
|
expect(newChat).not.toBe(initialChat);
|
|
243
279
|
expect(newHistory.length).toBe(initialHistory.length);
|
|
@@ -384,6 +420,27 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
384
420
|
expect(ChatCompressionService.prototype.compress).toHaveBeenLastCalledWith(expect.anything(), 'prompt-id-5', false, expect.anything(), expect.anything(), true);
|
|
385
421
|
});
|
|
386
422
|
});
|
|
423
|
+
it('should correctly latch hasFailedCompressionAttempt flag', async () => {
|
|
424
|
+
// 1. Setup: Call setup() from this test file
|
|
425
|
+
// This helper function mocks the compression service for us.
|
|
426
|
+
const { client } = setup({
|
|
427
|
+
originalTokenCount: 100,
|
|
428
|
+
newTokenCount: 200, // Inflated
|
|
429
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
430
|
+
});
|
|
431
|
+
// 2. Test Step 1: Trigger a non-forced failure
|
|
432
|
+
await client.tryCompressChat('prompt-1', false); // force = false
|
|
433
|
+
// 3. Assert Step 1: Check that the flag became true
|
|
434
|
+
// 3. Assert Step 1: Check that the flag became true
|
|
435
|
+
expect(client
|
|
436
|
+
.hasFailedCompressionAttempt).toBe(true);
|
|
437
|
+
// 4. Test Step 2: Trigger a forced failure
|
|
438
|
+
await client.tryCompressChat('prompt-2', true); // force = true
|
|
439
|
+
// 5. Assert Step 2: Check that the flag REMAINS true
|
|
440
|
+
// 5. Assert Step 2: Check that the flag REMAINS true
|
|
441
|
+
expect(client
|
|
442
|
+
.hasFailedCompressionAttempt).toBe(true);
|
|
443
|
+
});
|
|
387
444
|
it('should not trigger summarization if token count is below threshold', async () => {
|
|
388
445
|
const MOCKED_TOKEN_LIMIT = 1000;
|
|
389
446
|
const originalTokenCount = MOCKED_TOKEN_LIMIT * 0.699;
|
|
@@ -677,6 +734,50 @@ ${JSON.stringify({
|
|
|
677
734
|
parts: expectedRequest,
|
|
678
735
|
});
|
|
679
736
|
});
|
|
737
|
+
it('should use local estimation for text-only requests and NOT call countTokens', async () => {
|
|
738
|
+
const request = [{ text: 'Hello world' }];
|
|
739
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
740
|
+
const countTokensSpy = vi.spyOn(generator, 'countTokens');
|
|
741
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
742
|
+
await stream.next(); // Trigger the generator
|
|
743
|
+
expect(countTokensSpy).not.toHaveBeenCalled();
|
|
744
|
+
});
|
|
745
|
+
it('should use countTokens API for requests with non-text parts', async () => {
|
|
746
|
+
const request = [
|
|
747
|
+
{ text: 'Describe this image' },
|
|
748
|
+
{ inlineData: { mimeType: 'image/png', data: 'base64...' } },
|
|
749
|
+
];
|
|
750
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
751
|
+
const countTokensSpy = vi
|
|
752
|
+
.spyOn(generator, 'countTokens')
|
|
753
|
+
.mockResolvedValue({ totalTokens: 123 });
|
|
754
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
755
|
+
await stream.next(); // Trigger the generator
|
|
756
|
+
expect(countTokensSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
757
|
+
contents: expect.arrayContaining([
|
|
758
|
+
expect.objectContaining({
|
|
759
|
+
parts: expect.arrayContaining([
|
|
760
|
+
{ text: 'Describe this image' },
|
|
761
|
+
{ inlineData: { mimeType: 'image/png', data: 'base64...' } },
|
|
762
|
+
]),
|
|
763
|
+
}),
|
|
764
|
+
]),
|
|
765
|
+
}));
|
|
766
|
+
});
|
|
767
|
+
it('should estimate CJK characters more conservatively (closer to 1 token/char)', async () => {
|
|
768
|
+
const request = [{ text: '你好世界' }]; // 4 chars
|
|
769
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
770
|
+
const countTokensSpy = vi.spyOn(generator, 'countTokens');
|
|
771
|
+
// 4 chars.
|
|
772
|
+
// Old logic: 4/4 = 1.
|
|
773
|
+
// New logic (heuristic): 4 * 1 = 4. (Or at least > 1).
|
|
774
|
+
// Let's assert it's roughly accurate.
|
|
775
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
776
|
+
await stream.next();
|
|
777
|
+
// Should NOT call countTokens (it's text only)
|
|
778
|
+
expect(countTokensSpy).not.toHaveBeenCalled();
|
|
779
|
+
// The actual token calculation is unit tested in tokenCalculation.test.ts
|
|
780
|
+
});
|
|
680
781
|
it('should return the turn instance after the stream is complete', async () => {
|
|
681
782
|
// Arrange
|
|
682
783
|
const mockStream = (async function* () {
|
|
@@ -859,7 +960,8 @@ ${JSON.stringify({
|
|
|
859
960
|
// A string of length 400 is roughly 100 tokens.
|
|
860
961
|
const longText = 'a'.repeat(400);
|
|
861
962
|
const request = [{ text: longText }];
|
|
862
|
-
|
|
963
|
+
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
964
|
+
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
863
965
|
const remainingTokenCount = MOCKED_TOKEN_LIMIT - lastPromptTokenCount;
|
|
864
966
|
// Mock tryCompressChat to not compress
|
|
865
967
|
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
@@ -905,7 +1007,8 @@ ${JSON.stringify({
|
|
|
905
1007
|
// We need a request > 95 tokens.
|
|
906
1008
|
const longText = 'a'.repeat(400);
|
|
907
1009
|
const request = [{ text: longText }];
|
|
908
|
-
|
|
1010
|
+
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
1011
|
+
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
909
1012
|
const remainingTokenCount = STICKY_MODEL_LIMIT - lastPromptTokenCount;
|
|
910
1013
|
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
911
1014
|
originalTokenCount: lastPromptTokenCount,
|
|
@@ -927,6 +1030,51 @@ ${JSON.stringify({
|
|
|
927
1030
|
expect(tokenLimit).toHaveBeenCalledWith(STICKY_MODEL);
|
|
928
1031
|
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
929
1032
|
});
|
|
1033
|
+
it('should not trigger overflow warning for requests with large binary data (PDFs/images)', async () => {
|
|
1034
|
+
// Arrange
|
|
1035
|
+
const MOCKED_TOKEN_LIMIT = 1000000; // 1M tokens
|
|
1036
|
+
vi.mocked(tokenLimit).mockReturnValue(MOCKED_TOKEN_LIMIT);
|
|
1037
|
+
const lastPromptTokenCount = 10000;
|
|
1038
|
+
const mockChat = {
|
|
1039
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
1040
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1041
|
+
};
|
|
1042
|
+
client['chat'] = mockChat;
|
|
1043
|
+
// Simulate a PDF file with large base64 data (11MB when encoded)
|
|
1044
|
+
// In the old implementation, this would incorrectly estimate ~2.7M tokens
|
|
1045
|
+
// In the new implementation, only the text part is counted
|
|
1046
|
+
const largePdfBase64 = 'A'.repeat(11 * 1024 * 1024);
|
|
1047
|
+
const request = [
|
|
1048
|
+
{ text: 'Please analyze this PDF document' }, // ~35 chars = ~8 tokens
|
|
1049
|
+
{
|
|
1050
|
+
inlineData: {
|
|
1051
|
+
mimeType: 'application/pdf',
|
|
1052
|
+
data: largePdfBase64, // This should be ignored in token estimation
|
|
1053
|
+
},
|
|
1054
|
+
},
|
|
1055
|
+
];
|
|
1056
|
+
// Mock tryCompressChat to not compress
|
|
1057
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
1058
|
+
originalTokenCount: lastPromptTokenCount,
|
|
1059
|
+
newTokenCount: lastPromptTokenCount,
|
|
1060
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
1061
|
+
});
|
|
1062
|
+
// Mock Turn.run to simulate successful processing
|
|
1063
|
+
const mockStream = (async function* () {
|
|
1064
|
+
yield { type: 'content', value: 'Analysis complete' };
|
|
1065
|
+
})();
|
|
1066
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1067
|
+
// Act
|
|
1068
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'prompt-id-pdf-test');
|
|
1069
|
+
const events = await fromAsync(stream);
|
|
1070
|
+
// Assert
|
|
1071
|
+
// Should NOT contain overflow warning
|
|
1072
|
+
expect(events).not.toContainEqual(expect.objectContaining({
|
|
1073
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
1074
|
+
}));
|
|
1075
|
+
// Turn.run should be called (processing should continue)
|
|
1076
|
+
expect(mockTurnRunFn).toHaveBeenCalled();
|
|
1077
|
+
});
|
|
930
1078
|
describe('Model Routing', () => {
|
|
931
1079
|
let mockRouterService;
|
|
932
1080
|
beforeEach(() => {
|
|
@@ -985,37 +1133,23 @@ ${JSON.stringify({
|
|
|
985
1133
|
// Should use the newly routed model
|
|
986
1134
|
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'new-routed-model' }, [{ text: 'A new topic' }], expect.any(AbortSignal));
|
|
987
1135
|
});
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-fallback-stickiness');
|
|
1006
|
-
await fromAsync(stream);
|
|
1007
|
-
// First call should use fallback model
|
|
1008
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: DEFAULT_GEMINI_FLASH_MODEL }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1009
|
-
// End fallback mode
|
|
1010
|
-
vi.mocked(mockConfig.isInFallbackMode).mockReturnValue(false);
|
|
1011
|
-
// Second call in the same sequence
|
|
1012
|
-
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-fallback-stickiness');
|
|
1013
|
-
await fromAsync(stream);
|
|
1014
|
-
// Router should still not be called, and it should stick to the fallback model
|
|
1015
|
-
expect(mockTurnRunFn).toHaveBeenCalledTimes(2); // Ensure it was called again
|
|
1016
|
-
expect(mockTurnRunFn).toHaveBeenLastCalledWith({ model: DEFAULT_GEMINI_FLASH_MODEL }, // Still the fallback model
|
|
1017
|
-
[{ text: 'Continue' }], expect.any(AbortSignal));
|
|
1018
|
-
});
|
|
1136
|
+
});
|
|
1137
|
+
it('should use getGlobalMemory for system instruction when JIT is enabled', async () => {
|
|
1138
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(true);
|
|
1139
|
+
vi.mocked(mockConfig.getGlobalMemory).mockReturnValue('Global JIT Memory');
|
|
1140
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Full JIT Memory');
|
|
1141
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1142
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1143
|
+
await client.updateSystemInstruction();
|
|
1144
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Global JIT Memory');
|
|
1145
|
+
});
|
|
1146
|
+
it('should use getUserMemory for system instruction when JIT is disabled', async () => {
|
|
1147
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(false);
|
|
1148
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Legacy Memory');
|
|
1149
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1150
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1151
|
+
await client.updateSystemInstruction();
|
|
1152
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Legacy Memory');
|
|
1019
1153
|
});
|
|
1020
1154
|
it('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received', async () => {
|
|
1021
1155
|
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
@@ -1045,6 +1179,7 @@ ${JSON.stringify({
|
|
|
1045
1179
|
expect(events).toEqual([
|
|
1046
1180
|
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1047
1181
|
{ type: GeminiEventType.InvalidStream },
|
|
1182
|
+
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1048
1183
|
{ type: GeminiEventType.Content, value: 'Continued content' },
|
|
1049
1184
|
]);
|
|
1050
1185
|
// Verify that turn.run was called twice
|
|
@@ -1101,8 +1236,8 @@ ${JSON.stringify({
|
|
|
1101
1236
|
const stream = client.sendMessageStream(initialRequest, signal, promptId);
|
|
1102
1237
|
const events = await fromAsync(stream);
|
|
1103
1238
|
// Assert
|
|
1104
|
-
// We expect
|
|
1105
|
-
expect(events.length).toBe(
|
|
1239
|
+
// We expect 4 events (model_info + original + model_info + 1 retry)
|
|
1240
|
+
expect(events.length).toBe(4);
|
|
1106
1241
|
expect(events
|
|
1107
1242
|
.filter((e) => e.type !== GeminiEventType.ModelInfo)
|
|
1108
1243
|
.every((e) => e.type === GeminiEventType.InvalidStream)).toBe(true);
|
|
@@ -1328,6 +1463,94 @@ ${JSON.stringify({
|
|
|
1328
1463
|
expect(contextJson.activeFile.path).toBe('/path/to/active/file.ts');
|
|
1329
1464
|
});
|
|
1330
1465
|
});
|
|
1466
|
+
describe('Availability Service Integration', () => {
|
|
1467
|
+
let mockAvailabilityService;
|
|
1468
|
+
beforeEach(() => {
|
|
1469
|
+
mockAvailabilityService = createAvailabilityServiceMock();
|
|
1470
|
+
vi.mocked(mockConfig.getModelAvailabilityService).mockReturnValue(mockAvailabilityService);
|
|
1471
|
+
vi.mocked(mockConfig.setActiveModel).mockClear();
|
|
1472
|
+
mockRouterService.route.mockResolvedValue({
|
|
1473
|
+
model: 'model-a',
|
|
1474
|
+
reason: 'test',
|
|
1475
|
+
});
|
|
1476
|
+
vi.mocked(mockConfig.getModelRouterService).mockReturnValue(mockRouterService);
|
|
1477
|
+
vi.spyOn(policyCatalog, 'getModelPolicyChain').mockReturnValue([
|
|
1478
|
+
{
|
|
1479
|
+
model: 'model-a',
|
|
1480
|
+
isLastResort: false,
|
|
1481
|
+
actions: {},
|
|
1482
|
+
stateTransitions: {},
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
model: 'model-b',
|
|
1486
|
+
isLastResort: true,
|
|
1487
|
+
actions: {},
|
|
1488
|
+
stateTransitions: {},
|
|
1489
|
+
},
|
|
1490
|
+
]);
|
|
1491
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
1492
|
+
yield { type: 'content', value: 'Hello' };
|
|
1493
|
+
})());
|
|
1494
|
+
});
|
|
1495
|
+
it('should select first available model, set active, and not consume sticky attempt (done lower in chain)', async () => {
|
|
1496
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1497
|
+
selectedModel: 'model-a',
|
|
1498
|
+
attempts: 1,
|
|
1499
|
+
skipped: [],
|
|
1500
|
+
});
|
|
1501
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1502
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail');
|
|
1503
|
+
await fromAsync(stream);
|
|
1504
|
+
expect(mockAvailabilityService.selectFirstAvailable).toHaveBeenCalledWith(['model-a', 'model-b']);
|
|
1505
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-a');
|
|
1506
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1507
|
+
// Ensure turn.run used the selected model
|
|
1508
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith(expect.objectContaining({ model: 'model-a' }), expect.anything(), expect.anything());
|
|
1509
|
+
});
|
|
1510
|
+
it('should default to last resort model if selection returns null', async () => {
|
|
1511
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1512
|
+
selectedModel: null,
|
|
1513
|
+
skipped: [],
|
|
1514
|
+
});
|
|
1515
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1516
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail-fallback');
|
|
1517
|
+
await fromAsync(stream);
|
|
1518
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-b'); // Last resort
|
|
1519
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1520
|
+
});
|
|
1521
|
+
it('should reset turn on new message stream', async () => {
|
|
1522
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1523
|
+
selectedModel: 'model-a',
|
|
1524
|
+
skipped: [],
|
|
1525
|
+
});
|
|
1526
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-reset');
|
|
1527
|
+
await fromAsync(stream);
|
|
1528
|
+
expect(mockConfig.resetTurn).toHaveBeenCalled();
|
|
1529
|
+
});
|
|
1530
|
+
it('should NOT reset turn on invalid stream retry', async () => {
|
|
1531
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1532
|
+
selectedModel: 'model-a',
|
|
1533
|
+
skipped: [],
|
|
1534
|
+
});
|
|
1535
|
+
// We simulate a retry by calling sendMessageStream with isInvalidStreamRetry=true
|
|
1536
|
+
// But the public API doesn't expose that argument directly unless we use the private method or simulate the recursion.
|
|
1537
|
+
// We can simulate recursion by mocking turn run to return invalid stream once.
|
|
1538
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1539
|
+
const mockStream1 = (async function* () {
|
|
1540
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1541
|
+
})();
|
|
1542
|
+
const mockStream2 = (async function* () {
|
|
1543
|
+
yield { type: 'content', value: 'ok' };
|
|
1544
|
+
})();
|
|
1545
|
+
mockTurnRunFn
|
|
1546
|
+
.mockReturnValueOnce(mockStream1)
|
|
1547
|
+
.mockReturnValueOnce(mockStream2);
|
|
1548
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-retry');
|
|
1549
|
+
await fromAsync(stream);
|
|
1550
|
+
// resetTurn should be called once (for the initial call) but NOT for the recursive call
|
|
1551
|
+
expect(mockConfig.resetTurn).toHaveBeenCalledTimes(1);
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1331
1554
|
describe('IDE context with pending tool calls', () => {
|
|
1332
1555
|
let mockChat;
|
|
1333
1556
|
beforeEach(() => {
|
|
@@ -1680,9 +1903,9 @@ ${JSON.stringify({
|
|
|
1680
1903
|
it('should call generateContent with the correct parameters', async () => {
|
|
1681
1904
|
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1682
1905
|
const abortSignal = new AbortController().signal;
|
|
1683
|
-
await client.generateContent({ model:
|
|
1906
|
+
await client.generateContent({ model: 'test-model' }, contents, abortSignal);
|
|
1684
1907
|
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1685
|
-
model:
|
|
1908
|
+
model: 'test-model',
|
|
1686
1909
|
config: {
|
|
1687
1910
|
abortSignal,
|
|
1688
1911
|
systemInstruction: getCoreSystemPrompt({}, ''),
|
|
@@ -1693,33 +1916,200 @@ ${JSON.stringify({
|
|
|
1693
1916
|
}, 'test-session-id');
|
|
1694
1917
|
});
|
|
1695
1918
|
it('should use current model from config for content generation', async () => {
|
|
1696
|
-
const initialModel =
|
|
1919
|
+
const initialModel = 'test-model';
|
|
1697
1920
|
const contents = [{ role: 'user', parts: [{ text: 'test' }] }];
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
await client.generateContent({ model: DEFAULT_GEMINI_FLASH_MODEL }, contents, new AbortController().signal);
|
|
1701
|
-
expect(mockContentGenerator.generateContent).not.toHaveBeenCalledWith({
|
|
1921
|
+
await client.generateContent({ model: initialModel }, contents, new AbortController().signal);
|
|
1922
|
+
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(expect.objectContaining({
|
|
1702
1923
|
model: initialModel,
|
|
1703
|
-
config: expect.any(Object),
|
|
1704
|
-
contents,
|
|
1705
|
-
});
|
|
1706
|
-
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1707
|
-
model: DEFAULT_GEMINI_FLASH_MODEL,
|
|
1708
|
-
config: expect.any(Object),
|
|
1709
|
-
contents,
|
|
1710
|
-
}, 'test-session-id');
|
|
1711
|
-
});
|
|
1712
|
-
it('should use the Flash model when fallback mode is active', async () => {
|
|
1713
|
-
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1714
|
-
const abortSignal = new AbortController().signal;
|
|
1715
|
-
const requestedModel = 'gemini-2.5-pro'; // A non-flash model
|
|
1716
|
-
// Mock config to be in fallback mode
|
|
1717
|
-
vi.spyOn(client['config'], 'isInFallbackMode').mockReturnValue(true);
|
|
1718
|
-
await client.generateContent({ model: requestedModel }, contents, abortSignal);
|
|
1719
|
-
expect(mockGenerateContentFn).toHaveBeenCalledWith(expect.objectContaining({
|
|
1720
|
-
model: DEFAULT_GEMINI_FLASH_MODEL,
|
|
1721
1924
|
}), 'test-session-id');
|
|
1722
1925
|
});
|
|
1926
|
+
describe('Hook System', () => {
|
|
1927
|
+
let mockMessageBus;
|
|
1928
|
+
beforeEach(() => {
|
|
1929
|
+
vi.clearAllMocks();
|
|
1930
|
+
mockMessageBus = { publish: vi.fn(), subscribe: vi.fn() };
|
|
1931
|
+
// Force override config methods on the client instance
|
|
1932
|
+
client['config'].getEnableHooks = vi.fn().mockReturnValue(true);
|
|
1933
|
+
client['config'].getMessageBus = vi
|
|
1934
|
+
.fn()
|
|
1935
|
+
.mockReturnValue(mockMessageBus);
|
|
1936
|
+
});
|
|
1937
|
+
it('should fire BeforeAgent and AfterAgent exactly once for a simple turn', async () => {
|
|
1938
|
+
const promptId = 'test-prompt-hook-1';
|
|
1939
|
+
const request = { text: 'Hello Hooks' };
|
|
1940
|
+
const signal = new AbortController().signal;
|
|
1941
|
+
const { fireBeforeAgentHook, fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1942
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1943
|
+
this.getResponseText.mockReturnValue('Hook Response');
|
|
1944
|
+
yield { type: GeminiEventType.Content, value: 'Hook Response' };
|
|
1945
|
+
});
|
|
1946
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1947
|
+
while (!(await stream.next()).done)
|
|
1948
|
+
;
|
|
1949
|
+
expect(fireBeforeAgentHook).toHaveBeenCalledTimes(1);
|
|
1950
|
+
expect(fireAfterAgentHook).toHaveBeenCalledTimes(1);
|
|
1951
|
+
expect(fireAfterAgentHook).toHaveBeenCalledWith(expect.anything(), request, 'Hook Response');
|
|
1952
|
+
// Map should be empty
|
|
1953
|
+
expect(client['hookStateMap'].size).toBe(0);
|
|
1954
|
+
});
|
|
1955
|
+
it('should fire BeforeAgent once and AfterAgent once even with recursion', async () => {
|
|
1956
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
1957
|
+
vi.mocked(checkNextSpeaker)
|
|
1958
|
+
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
|
|
1959
|
+
.mockResolvedValueOnce(null);
|
|
1960
|
+
const promptId = 'test-prompt-hook-recursive';
|
|
1961
|
+
const request = { text: 'Recursion Test' };
|
|
1962
|
+
const signal = new AbortController().signal;
|
|
1963
|
+
const { fireBeforeAgentHook, fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1964
|
+
let callCount = 0;
|
|
1965
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1966
|
+
callCount++;
|
|
1967
|
+
const response = `Response ${callCount}`;
|
|
1968
|
+
this.getResponseText.mockReturnValue(response);
|
|
1969
|
+
yield { type: GeminiEventType.Content, value: response };
|
|
1970
|
+
});
|
|
1971
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1972
|
+
while (!(await stream.next()).done)
|
|
1973
|
+
;
|
|
1974
|
+
// BeforeAgent should fire ONLY once despite multiple internal turns
|
|
1975
|
+
expect(fireBeforeAgentHook).toHaveBeenCalledTimes(1);
|
|
1976
|
+
// AfterAgent should fire ONLY when the stack unwinds
|
|
1977
|
+
expect(fireAfterAgentHook).toHaveBeenCalledTimes(1);
|
|
1978
|
+
// Check cumulative response (separated by newline)
|
|
1979
|
+
expect(fireAfterAgentHook).toHaveBeenCalledWith(expect.anything(), request, 'Response 1\nResponse 2');
|
|
1980
|
+
expect(client['hookStateMap'].size).toBe(0);
|
|
1981
|
+
});
|
|
1982
|
+
it('should use original request in AfterAgent hook even when continuation happened', async () => {
|
|
1983
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
1984
|
+
vi.mocked(checkNextSpeaker)
|
|
1985
|
+
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
|
|
1986
|
+
.mockResolvedValueOnce(null);
|
|
1987
|
+
const promptId = 'test-prompt-hook-original-req';
|
|
1988
|
+
const request = { text: 'Do something' };
|
|
1989
|
+
const signal = new AbortController().signal;
|
|
1990
|
+
const { fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1991
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1992
|
+
this.getResponseText.mockReturnValue('Ok');
|
|
1993
|
+
yield { type: GeminiEventType.Content, value: 'Ok' };
|
|
1994
|
+
});
|
|
1995
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1996
|
+
while (!(await stream.next()).done)
|
|
1997
|
+
;
|
|
1998
|
+
expect(fireAfterAgentHook).toHaveBeenCalledWith(expect.anything(), request, // Should be 'Do something'
|
|
1999
|
+
expect.stringContaining('Ok'));
|
|
2000
|
+
});
|
|
2001
|
+
it('should cleanup state when prompt_id changes', async () => {
|
|
2002
|
+
const signal = new AbortController().signal;
|
|
2003
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2004
|
+
this.getResponseText.mockReturnValue('Ok');
|
|
2005
|
+
yield { type: GeminiEventType.Content, value: 'Ok' };
|
|
2006
|
+
});
|
|
2007
|
+
client['hookStateMap'].set('old-id', {
|
|
2008
|
+
hasFiredBeforeAgent: true,
|
|
2009
|
+
cumulativeResponse: 'Old',
|
|
2010
|
+
activeCalls: 0,
|
|
2011
|
+
originalRequest: { text: 'Old' },
|
|
2012
|
+
});
|
|
2013
|
+
client['lastPromptId'] = 'old-id';
|
|
2014
|
+
const stream = client.sendMessageStream({ text: 'New' }, signal, 'new-id');
|
|
2015
|
+
await stream.next();
|
|
2016
|
+
expect(client['hookStateMap'].has('old-id')).toBe(false);
|
|
2017
|
+
expect(client['hookStateMap'].has('new-id')).toBe(true);
|
|
2018
|
+
});
|
|
2019
|
+
it('should stop execution in BeforeAgent when hook returns continue: false', async () => {
|
|
2020
|
+
const { fireBeforeAgentHook } = await import('./clientHookTriggers.js');
|
|
2021
|
+
vi.mocked(fireBeforeAgentHook).mockResolvedValue({
|
|
2022
|
+
shouldStopExecution: () => true,
|
|
2023
|
+
getEffectiveReason: () => 'Stopped by hook',
|
|
2024
|
+
});
|
|
2025
|
+
const mockChat = {
|
|
2026
|
+
addHistory: vi.fn(),
|
|
2027
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
2028
|
+
getLastPromptTokenCount: vi.fn(),
|
|
2029
|
+
};
|
|
2030
|
+
client['chat'] = mockChat;
|
|
2031
|
+
const request = [{ text: 'Hello' }];
|
|
2032
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt');
|
|
2033
|
+
const events = await fromAsync(stream);
|
|
2034
|
+
expect(events).toContainEqual({
|
|
2035
|
+
type: GeminiEventType.AgentExecutionStopped,
|
|
2036
|
+
value: { reason: 'Stopped by hook' },
|
|
2037
|
+
});
|
|
2038
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
|
2039
|
+
role: 'user',
|
|
2040
|
+
parts: request,
|
|
2041
|
+
});
|
|
2042
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2043
|
+
});
|
|
2044
|
+
it('should block execution in BeforeAgent when hook returns decision: block', async () => {
|
|
2045
|
+
const { fireBeforeAgentHook } = await import('./clientHookTriggers.js');
|
|
2046
|
+
vi.mocked(fireBeforeAgentHook).mockResolvedValue({
|
|
2047
|
+
shouldStopExecution: () => false,
|
|
2048
|
+
isBlockingDecision: () => true,
|
|
2049
|
+
getEffectiveReason: () => 'Blocked by hook',
|
|
2050
|
+
});
|
|
2051
|
+
const mockChat = {
|
|
2052
|
+
addHistory: vi.fn(),
|
|
2053
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
2054
|
+
getLastPromptTokenCount: vi.fn(),
|
|
2055
|
+
};
|
|
2056
|
+
client['chat'] = mockChat;
|
|
2057
|
+
const request = [{ text: 'Hello' }];
|
|
2058
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt');
|
|
2059
|
+
const events = await fromAsync(stream);
|
|
2060
|
+
expect(events).toContainEqual({
|
|
2061
|
+
type: GeminiEventType.AgentExecutionBlocked,
|
|
2062
|
+
value: {
|
|
2063
|
+
reason: 'Blocked by hook',
|
|
2064
|
+
},
|
|
2065
|
+
});
|
|
2066
|
+
expect(mockChat.addHistory).not.toHaveBeenCalled();
|
|
2067
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2068
|
+
});
|
|
2069
|
+
it('should stop execution in AfterAgent when hook returns continue: false', async () => {
|
|
2070
|
+
const { fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
2071
|
+
vi.mocked(fireAfterAgentHook).mockResolvedValue({
|
|
2072
|
+
shouldStopExecution: () => true,
|
|
2073
|
+
getEffectiveReason: () => 'Stopped after agent',
|
|
2074
|
+
});
|
|
2075
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2076
|
+
yield { type: GeminiEventType.Content, value: 'Hello' };
|
|
2077
|
+
});
|
|
2078
|
+
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2079
|
+
const events = await fromAsync(stream);
|
|
2080
|
+
expect(events).toContainEqual({
|
|
2081
|
+
type: GeminiEventType.AgentExecutionStopped,
|
|
2082
|
+
value: { reason: 'Stopped after agent' },
|
|
2083
|
+
});
|
|
2084
|
+
// sendMessageStream should not recurse
|
|
2085
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
|
2086
|
+
});
|
|
2087
|
+
it('should yield AgentExecutionBlocked and recurse in AfterAgent when hook returns decision: block', async () => {
|
|
2088
|
+
const { fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
2089
|
+
vi.mocked(fireAfterAgentHook)
|
|
2090
|
+
.mockResolvedValueOnce({
|
|
2091
|
+
shouldStopExecution: () => false,
|
|
2092
|
+
isBlockingDecision: () => true,
|
|
2093
|
+
getEffectiveReason: () => 'Please explain',
|
|
2094
|
+
})
|
|
2095
|
+
.mockResolvedValueOnce({
|
|
2096
|
+
shouldStopExecution: () => false,
|
|
2097
|
+
isBlockingDecision: () => false,
|
|
2098
|
+
});
|
|
2099
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2100
|
+
yield { type: GeminiEventType.Content, value: 'Response' };
|
|
2101
|
+
});
|
|
2102
|
+
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2103
|
+
const events = await fromAsync(stream);
|
|
2104
|
+
expect(events).toContainEqual({
|
|
2105
|
+
type: GeminiEventType.AgentExecutionBlocked,
|
|
2106
|
+
value: { reason: 'Please explain' },
|
|
2107
|
+
});
|
|
2108
|
+
// Should have called turn run twice (original + re-prompt)
|
|
2109
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
2110
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, expect.anything(), [{ text: 'Please explain' }], expect.anything());
|
|
2111
|
+
});
|
|
2112
|
+
});
|
|
1723
2113
|
});
|
|
1724
2114
|
});
|
|
1725
2115
|
//# sourceMappingURL=client.test.js.map
|