@machina.ai/cell-cli-core 1.20.2-rc1 → 1.25.0-rc1
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/AFTER_MERGE_PROMPT.md +26 -0
- package/dist/docs/CHANGES.md +124 -0
- package/dist/docs/api-proxy.md +27 -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/monitoring-dashboard-logs.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-overview.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 +612 -0
- package/dist/docs/changelogs/latest.md +153 -0
- package/dist/docs/changelogs/preview.md +131 -0
- package/dist/docs/changelogs/releases.md +1162 -0
- package/dist/docs/cli/authentication.md +3 -0
- package/dist/docs/cli/checkpointing.md +94 -0
- package/dist/docs/cli/commands.md +357 -0
- package/dist/docs/cli/custom-commands.md +315 -0
- package/dist/docs/cli/enterprise.md +564 -0
- package/dist/docs/cli/gemini-ignore.md +71 -0
- package/dist/docs/cli/gemini-md.md +109 -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 +136 -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 +148 -0
- package/dist/docs/cli/skills.md +188 -0
- package/dist/docs/cli/system-prompt.md +94 -0
- package/dist/docs/cli/telemetry.md +813 -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 +246 -0
- package/dist/docs/core/policy-engine.md +268 -0
- package/dist/docs/core/tools-api.md +131 -0
- package/dist/docs/examples/proxy-script.md +83 -0
- package/dist/docs/extensions/extension-releasing.md +183 -0
- package/dist/docs/extensions/getting-started-extensions.md +244 -0
- package/dist/docs/extensions/index.md +343 -0
- package/dist/docs/faq.md +153 -0
- package/dist/docs/get-started/authentication.md +321 -0
- package/dist/docs/get-started/configuration-v1.md +890 -0
- package/dist/docs/get-started/configuration.md +1643 -0
- package/dist/docs/get-started/examples.md +218 -0
- package/dist/docs/get-started/gemini-3.md +101 -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 +723 -0
- package/dist/docs/hooks/reference.md +178 -0
- package/dist/docs/hooks/writing-hooks.md +1044 -0
- package/dist/docs/ide-integration/ide-companion-spec.md +267 -0
- package/dist/docs/ide-integration/index.md +201 -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/mcp_integration.md +160 -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 +1045 -0
- package/dist/docs/tools/memory.md +54 -0
- package/dist/docs/tools/shell.md +260 -0
- package/dist/docs/tools/todos.md +56 -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 +162 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +7 -4
- package/dist/src/agents/a2a-client-manager.d.ts +82 -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.js +281 -0
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -0
- package/dist/src/agents/a2aUtils.d.ts +29 -0
- package/dist/src/agents/a2aUtils.js +113 -0
- package/dist/src/agents/a2aUtils.js.map +1 -0
- package/dist/src/agents/a2aUtils.test.js +147 -0
- package/dist/src/agents/a2aUtils.test.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +68 -0
- package/dist/src/agents/agentLoader.js +255 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/agentLoader.test.js +307 -0
- package/dist/src/agents/agentLoader.test.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +85 -0
- package/dist/src/agents/cli-help-agent.js.map +1 -0
- package/dist/src/agents/cli-help-agent.test.d.ts +6 -0
- package/dist/src/agents/cli-help-agent.test.js +65 -0
- package/dist/src/agents/cli-help-agent.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -2
- package/dist/src/agents/codebase-investigator.js +14 -8
- 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 +122 -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 +213 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/{executor.d.ts → local-executor.d.ts} +5 -11
- package/dist/src/agents/{executor.js → local-executor.js} +124 -63
- 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/{executor.test.js → local-executor.test.js} +136 -58
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/{invocation.d.ts → local-invocation.d.ts} +6 -7
- package/dist/src/agents/{invocation.js → local-invocation.js} +9 -10
- 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/{invocation.test.js → local-invocation.test.js} +29 -20
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +37 -1
- package/dist/src/agents/registry.js +240 -27
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +465 -30
- 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 +126 -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 +33 -19
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/types.d.ts +21 -15
- package/dist/src/agents/types.js.map +1 -1
- 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/fallbackIntegration.test.d.ts +6 -0
- package/dist/src/availability/fallbackIntegration.test.js +58 -0
- package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +3 -1
- package/dist/src/availability/modelAvailabilityService.js +3 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -1
- package/dist/src/availability/modelPolicy.d.ts +8 -1
- package/dist/src/availability/policyCatalog.d.ts +1 -0
- package/dist/src/availability/policyCatalog.js +6 -7
- package/dist/src/availability/policyCatalog.js.map +1 -1
- package/dist/src/availability/policyCatalog.test.js +2 -2
- package/dist/src/availability/policyCatalog.test.js.map +1 -1
- package/dist/src/availability/policyHelpers.d.ts +34 -3
- package/dist/src/availability/policyHelpers.js +104 -13
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +143 -13
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- 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 +2 -1
- 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.d.ts +1 -1
- package/dist/src/code_assist/experiments/experiments.js +21 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments_local.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js +110 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.js +3 -4
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +2 -0
- package/dist/src/code_assist/oauth2.js +70 -14
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +224 -22
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +9 -1
- package/dist/src/code_assist/server.js +74 -11
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +199 -27
- 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 +157 -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 +301 -0
- package/dist/src/code_assist/telemetry.test.js.map +1 -0
- package/dist/src/code_assist/types.d.ts +77 -1
- package/dist/src/code_assist/types.js +28 -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/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +80 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/memory.test.d.ts +6 -0
- package/dist/src/commands/memory.test.js +155 -0
- package/dist/src/commands/memory.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 +145 -25
- package/dist/src/config/config.js +370 -132
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +416 -50
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +21 -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 +36 -15
- package/dist/src/config/models.js +89 -28
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +107 -77
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/storage.d.ts +5 -0
- package/dist/src/config/storage.js +17 -2
- 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.js +3 -1
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +4 -0
- package/dist/src/core/baseLlmClient.d.ts +3 -1
- package/dist/src/core/baseLlmClient.js +60 -22
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +177 -7
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/client.d.ts +7 -1
- package/dist/src/core/client.js +261 -96
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +397 -67
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/clientHookTriggers.js +2 -2
- package/dist/src/core/clientHookTriggers.js.map +1 -1
- package/dist/src/core/contentGenerator.js +6 -4
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +24 -23
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +9 -5
- package/dist/src/core/coreToolHookTriggers.js +119 -21
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- 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 +7 -93
- package/dist/src/core/coreToolScheduler.js +139 -333
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +304 -348
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +26 -1
- package/dist/src/core/geminiChat.js +144 -80
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +334 -253
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +8 -4
- package/dist/src/core/geminiChatHookTriggers.js +34 -12
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -1
- package/dist/src/core/geminiChatHookTriggers.test.d.ts +6 -0
- package/dist/src/core/geminiChatHookTriggers.test.js +153 -0
- package/dist/src/core/geminiChatHookTriggers.test.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 +19 -2
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +30 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +7 -8
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/prompts.js +48 -22
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +66 -11
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/tokenLimits.js +6 -12
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/tokenLimits.test.js +8 -4
- package/dist/src/core/tokenLimits.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +21 -21
- package/dist/src/core/turn.js +32 -22
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +79 -5
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +55 -120
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +115 -288
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +3 -3
- package/dist/src/generated/git-commit.js +3 -3
- package/dist/src/hooks/hookAggregator.js +7 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +9 -5
- package/dist/src/hooks/hookEventHandler.js +120 -16
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +231 -9
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- 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 +68 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookRunner.test.js +173 -36
- package/dist/src/hooks/hookRunner.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +10 -6
- package/dist/src/hooks/hookSystem.js +36 -16
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookSystem.test.js +123 -18
- package/dist/src/hooks/hookSystem.test.js.map +1 -1
- package/dist/src/hooks/hookTranslator.js +2 -1
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/hooks/index.d.ts +2 -1
- package/dist/src/hooks/index.js +1 -0
- package/dist/src/hooks/index.js.map +1 -1
- 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 +42 -11
- package/dist/src/hooks/types.js +31 -42
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +9 -52
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +4 -0
- package/dist/src/ide/detect-ide.js +7 -2
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +42 -1
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.js +6 -1
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-installer.js +2 -2
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +12 -3
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/index.d.ts +23 -1
- package/dist/src/index.js +25 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +7 -3
- 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/token-storage/file-token-storage.js +2 -2
- package/dist/src/mcp/token-storage/file-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 +24 -2
- 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/write.toml +5 -0
- package/dist/src/policy/policies/yolo.toml +1 -0
- package/dist/src/policy/policy-engine.d.ts +14 -1
- package/dist/src/policy/policy-engine.js +165 -7
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +315 -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 +438 -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 +43 -60
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +41 -7
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +25 -0
- package/dist/src/policy/utils.d.ts +21 -0
- package/dist/src/policy/utils.js +45 -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 +92 -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/routingStrategy.d.ts +2 -0
- 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 +18 -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.d.ts +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +21 -13
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +76 -39
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +5 -4
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +14 -0
- package/dist/src/routing/strategies/overrideStrategy.test.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/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +50 -0
- package/dist/src/scheduler/tool-modifier.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.test.d.ts +6 -0
- package/dist/src/scheduler/tool-modifier.test.js +159 -0
- package/dist/src/scheduler/tool-modifier.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.js +8 -1
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +3 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +21 -1
- package/dist/src/services/chatRecordingService.js +57 -2
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +43 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +5 -11
- package/dist/src/services/contextManager.js +20 -17
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +40 -41
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/environmentSanitization.d.ts +15 -0
- package/dist/src/services/environmentSanitization.js +142 -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 +15 -1
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +56 -2
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +4 -3
- 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 +3 -3
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +41 -4
- package/dist/src/services/modelConfigService.js +135 -75
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +226 -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 +2 -0
- package/dist/src/services/shellExecutionService.js +34 -72
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +114 -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 +16 -0
- package/dist/src/skills/skillLoader.d.ts +31 -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 +6 -0
- package/dist/src/skills/skillLoader.test.js +75 -0
- package/dist/src/skills/skillLoader.test.js.map +1 -0
- package/dist/src/skills/skillManager.d.ts +69 -0
- package/dist/src/skills/skillManager.js +127 -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 +210 -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 +19 -9
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +261 -164
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +223 -27
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +12 -3
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +26 -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 +1 -1
- package/dist/src/telemetry/index.js +1 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +4 -3
- package/dist/src/telemetry/loggers.js +351 -340
- 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 +71 -15
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- 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/startupProfiler.js +26 -3
- package/dist/src/telemetry/startupProfiler.js.map +1 -1
- package/dist/src/telemetry/startupProfiler.test.js +49 -7
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -1
- 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.map +1 -1
- package/dist/src/telemetry/types.d.ts +37 -12
- package/dist/src/telemetry/types.js +61 -20
- 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 +1 -0
- package/dist/src/test-utils/mock-message-bus.js +29 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +5 -3
- package/dist/src/test-utils/mock-tool.js +11 -10
- 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 +133 -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 +113 -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 +143 -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 +460 -136
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +292 -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 +122 -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 +2 -1
- package/dist/src/tools/mcp-client-manager.js +32 -9
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +41 -10
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +43 -6
- package/dist/src/tools/mcp-client.js +443 -176
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +664 -39
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +20 -5
- package/dist/src/tools/mcp-tool.js +21 -8
- 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 +35 -49
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +36 -59
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +6 -1
- package/dist/src/tools/tool-error.js +6 -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 +27 -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 +21 -8
- 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 +14 -6
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +49 -7
- 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/apiConversionUtils.d.ts +12 -0
- package/dist/src/utils/apiConversionUtils.js +46 -0
- package/dist/src/utils/apiConversionUtils.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.test.d.ts +6 -0
- package/dist/src/utils/apiConversionUtils.test.js +150 -0
- package/dist/src/utils/apiConversionUtils.test.js.map +1 -0
- 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/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.d.ts +3 -3
- package/dist/src/utils/editCorrector.js +27 -10
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +27 -23
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +10 -1
- package/dist/src/utils/editor.js +48 -19
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +27 -4
- package/dist/src/utils/editor.test.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 +71 -19
- package/dist/src/utils/events.js +35 -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/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/fileDiffUtils.d.ts +18 -0
- package/dist/src/utils/fileDiffUtils.js +37 -0
- package/dist/src/utils/fileDiffUtils.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.test.d.ts +6 -0
- package/dist/src/utils/fileDiffUtils.test.js +84 -0
- package/dist/src/utils/fileDiffUtils.test.js.map +1 -0
- 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/gitIgnoreParser.js +9 -10
- package/dist/src/utils/gitIgnoreParser.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/installationManager.test.js +11 -3
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +3 -4
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +12 -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/partUtils.js +1 -1
- package/dist/src/utils/partUtils.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/paths.d.ts +10 -0
- package/dist/src/utils/paths.js +20 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/retry.d.ts +12 -0
- package/dist/src/utils/retry.js +70 -17
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +181 -21
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +16 -47
- package/dist/src/utils/shell-utils.js +98 -194
- 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/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.js +20 -5
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tokenCalculation.test.js +11 -2
- package/dist/src/utils/tokenCalculation.test.js.map +1 -1
- 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/userAccountManager.test.js +5 -5
- package/dist/src/utils/userAccountManager.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/src/utils/workspaceContext.test.js +1 -1
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
- package/dist/src/agents/executor.js.map +0 -1
- package/dist/src/agents/executor.test.js.map +0 -1
- package/dist/src/agents/invocation.js.map +0 -1
- package/dist/src/agents/invocation.test.js.map +0 -1
- package/dist/src/tools/smart-edit.d.ts +0 -78
- package/dist/src/tools/smart-edit.js +0 -717
- package/dist/src/tools/smart-edit.js.map +0 -1
- package/dist/src/tools/smart-edit.test.js +0 -592
- package/dist/src/tools/smart-edit.test.js.map +0 -1
- /package/dist/src/agents/{executor.test.d.ts → a2a-client-manager.test.d.ts} +0 -0
- /package/dist/src/agents/{invocation.test.d.ts → a2aUtils.test.d.ts} +0 -0
- /package/dist/src/{tools/smart-edit.test.d.ts → agents/agentLoader.test.d.ts} +0 -0
|
@@ -9,15 +9,18 @@ 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';
|
|
20
|
-
import
|
|
21
|
+
import * as policyCatalog from '../availability/policyCatalog.js';
|
|
22
|
+
import { partToString } from '../utils/partUtils.js';
|
|
23
|
+
import { coreEvents } from '../utils/events.js';
|
|
21
24
|
vi.mock('../services/chatCompressionService.js');
|
|
22
25
|
// Mock fs module to prevent actual file system operations during tests
|
|
23
26
|
const mockFileSystem = new Map();
|
|
@@ -36,13 +39,16 @@ vi.mock('node:fs', () => {
|
|
|
36
39
|
});
|
|
37
40
|
}),
|
|
38
41
|
existsSync: vi.fn((path) => mockFileSystem.has(path)),
|
|
42
|
+
createWriteStream: vi.fn(() => ({
|
|
43
|
+
write: vi.fn(),
|
|
44
|
+
on: vi.fn(),
|
|
45
|
+
})),
|
|
39
46
|
};
|
|
40
47
|
return {
|
|
41
48
|
default: fsModule,
|
|
42
49
|
...fsModule,
|
|
43
50
|
};
|
|
44
51
|
});
|
|
45
|
-
// --- Mocks ---
|
|
46
52
|
const mockTurnRunFn = vi.fn();
|
|
47
53
|
vi.mock('./turn', async (importOriginal) => {
|
|
48
54
|
const actual = await importOriginal();
|
|
@@ -54,6 +60,7 @@ vi.mock('./turn', async (importOriginal) => {
|
|
|
54
60
|
constructor() {
|
|
55
61
|
// The constructor can be empty or do some mock setup
|
|
56
62
|
}
|
|
63
|
+
getResponseText = vi.fn().mockReturnValue('Mock Response');
|
|
57
64
|
}
|
|
58
65
|
// Export the mock class as 'Turn'
|
|
59
66
|
return {
|
|
@@ -87,6 +94,10 @@ vi.mock('../telemetry/uiTelemetry.js', () => ({
|
|
|
87
94
|
},
|
|
88
95
|
}));
|
|
89
96
|
vi.mock('../hooks/hookSystem.js');
|
|
97
|
+
const mockHookSystem = {
|
|
98
|
+
fireBeforeAgentEvent: vi.fn().mockResolvedValue(undefined),
|
|
99
|
+
fireAfterAgentEvent: vi.fn().mockResolvedValue(undefined),
|
|
100
|
+
};
|
|
90
101
|
/**
|
|
91
102
|
* Array.fromAsync ponyfill, which will be available in es 2024.
|
|
92
103
|
*
|
|
@@ -104,6 +115,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
104
115
|
let mockConfig;
|
|
105
116
|
let client;
|
|
106
117
|
let mockGenerateContentFn;
|
|
118
|
+
let mockRouterService;
|
|
107
119
|
beforeEach(async () => {
|
|
108
120
|
vi.resetAllMocks();
|
|
109
121
|
ClearcutLogger.clearInstance();
|
|
@@ -121,6 +133,11 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
121
133
|
});
|
|
122
134
|
// Disable 429 simulation for tests
|
|
123
135
|
setSimulate429(false);
|
|
136
|
+
mockRouterService = {
|
|
137
|
+
route: vi
|
|
138
|
+
.fn()
|
|
139
|
+
.mockResolvedValue({ model: 'default-routed-model', reason: 'test' }),
|
|
140
|
+
};
|
|
124
141
|
mockContentGenerator = {
|
|
125
142
|
generateContent: mockGenerateContentFn,
|
|
126
143
|
generateContentStream: vi.fn(),
|
|
@@ -146,11 +163,15 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
146
163
|
.mockReturnValue(contentGeneratorConfig),
|
|
147
164
|
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
|
148
165
|
getModel: vi.fn().mockReturnValue('test-model'),
|
|
166
|
+
getUserTier: vi.fn().mockReturnValue(undefined),
|
|
149
167
|
getEmbeddingModel: vi.fn().mockReturnValue('test-embedding-model'),
|
|
150
168
|
getApiKey: vi.fn().mockReturnValue('test-key'),
|
|
151
169
|
getVertexAI: vi.fn().mockReturnValue(false),
|
|
152
170
|
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
|
153
171
|
getUserMemory: vi.fn().mockReturnValue(''),
|
|
172
|
+
getGlobalMemory: vi.fn().mockReturnValue(''),
|
|
173
|
+
getEnvironmentMemory: vi.fn().mockReturnValue(''),
|
|
174
|
+
isJitContextEnabled: vi.fn().mockReturnValue(false),
|
|
154
175
|
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
|
155
176
|
getProxy: vi.fn().mockReturnValue(undefined),
|
|
156
177
|
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
|
@@ -168,16 +189,13 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
168
189
|
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
|
169
190
|
}),
|
|
170
191
|
getGeminiClient: vi.fn(),
|
|
171
|
-
getModelRouterService: vi
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
getModelRouterService: vi
|
|
193
|
+
.fn()
|
|
194
|
+
.mockReturnValue(mockRouterService),
|
|
174
195
|
getMessageBus: vi.fn().mockReturnValue(undefined),
|
|
175
196
|
getEnableHooks: vi.fn().mockReturnValue(false),
|
|
176
|
-
isInFallbackMode: vi.fn().mockReturnValue(false),
|
|
177
|
-
setFallbackMode: vi.fn(),
|
|
178
197
|
getChatCompression: vi.fn().mockReturnValue(undefined),
|
|
179
198
|
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
|
180
|
-
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
|
181
199
|
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
|
182
200
|
getContinueOnFailedApiCall: vi.fn(),
|
|
183
201
|
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
|
@@ -204,16 +222,21 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
204
222
|
},
|
|
205
223
|
isInteractive: vi.fn().mockReturnValue(false),
|
|
206
224
|
getExperiments: () => { },
|
|
225
|
+
getActiveModel: vi.fn().mockReturnValue('test-model'),
|
|
226
|
+
setActiveModel: vi.fn(),
|
|
227
|
+
resetTurn: vi.fn(),
|
|
228
|
+
getModelAvailabilityService: vi
|
|
229
|
+
.fn()
|
|
230
|
+
.mockReturnValue(createAvailabilityServiceMock()),
|
|
207
231
|
};
|
|
208
|
-
mockConfig.getHookSystem = vi
|
|
209
|
-
.fn()
|
|
210
|
-
.mockReturnValue(new HookSystem(mockConfig));
|
|
232
|
+
mockConfig.getHookSystem = vi.fn().mockReturnValue(mockHookSystem);
|
|
211
233
|
client = new GeminiClient(mockConfig);
|
|
212
234
|
await client.initialize();
|
|
213
235
|
vi.mocked(mockConfig.getGeminiClient).mockReturnValue(client);
|
|
214
236
|
vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
|
|
215
237
|
});
|
|
216
238
|
afterEach(() => {
|
|
239
|
+
client.dispose();
|
|
217
240
|
vi.restoreAllMocks();
|
|
218
241
|
});
|
|
219
242
|
describe('addHistory', () => {
|
|
@@ -234,18 +257,18 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
234
257
|
it('should create a new chat session, clearing the old history', async () => {
|
|
235
258
|
// 1. Get the initial chat instance and add some history.
|
|
236
259
|
const initialChat = client.getChat();
|
|
237
|
-
const initialHistory =
|
|
260
|
+
const initialHistory = client.getHistory();
|
|
238
261
|
await client.addHistory({
|
|
239
262
|
role: 'user',
|
|
240
263
|
parts: [{ text: 'some old message' }],
|
|
241
264
|
});
|
|
242
|
-
const historyWithOldMessage =
|
|
265
|
+
const historyWithOldMessage = client.getHistory();
|
|
243
266
|
expect(historyWithOldMessage.length).toBeGreaterThan(initialHistory.length);
|
|
244
267
|
// 2. Call resetChat.
|
|
245
268
|
await client.resetChat();
|
|
246
269
|
// 3. Get the new chat instance and its history.
|
|
247
270
|
const newChat = client.getChat();
|
|
248
|
-
const newHistory =
|
|
271
|
+
const newHistory = client.getHistory();
|
|
249
272
|
// 4. Assert that the chat instance is new and the history is reset.
|
|
250
273
|
expect(newChat).not.toBe(initialChat);
|
|
251
274
|
expect(newHistory.length).toBe(initialHistory.length);
|
|
@@ -290,6 +313,10 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
290
313
|
getHistory: vi.fn((_curated) => chatHistory),
|
|
291
314
|
setHistory: vi.fn(),
|
|
292
315
|
getLastPromptTokenCount: vi.fn().mockReturnValue(originalTokenCount),
|
|
316
|
+
getChatRecordingService: vi.fn().mockReturnValue({
|
|
317
|
+
getConversation: vi.fn().mockReturnValue(null),
|
|
318
|
+
getConversationFilePath: vi.fn().mockReturnValue(null),
|
|
319
|
+
}),
|
|
293
320
|
};
|
|
294
321
|
client['chat'] = mockOriginalChat;
|
|
295
322
|
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(originalTokenCount);
|
|
@@ -392,6 +419,27 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
392
419
|
expect(ChatCompressionService.prototype.compress).toHaveBeenLastCalledWith(expect.anything(), 'prompt-id-5', false, expect.anything(), expect.anything(), true);
|
|
393
420
|
});
|
|
394
421
|
});
|
|
422
|
+
it('should correctly latch hasFailedCompressionAttempt flag', async () => {
|
|
423
|
+
// 1. Setup: Call setup() from this test file
|
|
424
|
+
// This helper function mocks the compression service for us.
|
|
425
|
+
const { client } = setup({
|
|
426
|
+
originalTokenCount: 100,
|
|
427
|
+
newTokenCount: 200, // Inflated
|
|
428
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
429
|
+
});
|
|
430
|
+
// 2. Test Step 1: Trigger a non-forced failure
|
|
431
|
+
await client.tryCompressChat('prompt-1', false); // force = false
|
|
432
|
+
// 3. Assert Step 1: Check that the flag became true
|
|
433
|
+
// 3. Assert Step 1: Check that the flag became true
|
|
434
|
+
expect(client
|
|
435
|
+
.hasFailedCompressionAttempt).toBe(true);
|
|
436
|
+
// 4. Test Step 2: Trigger a forced failure
|
|
437
|
+
await client.tryCompressChat('prompt-2', true); // force = true
|
|
438
|
+
// 5. Assert Step 2: Check that the flag REMAINS true
|
|
439
|
+
// 5. Assert Step 2: Check that the flag REMAINS true
|
|
440
|
+
expect(client
|
|
441
|
+
.hasFailedCompressionAttempt).toBe(true);
|
|
442
|
+
});
|
|
395
443
|
it('should not trigger summarization if token count is below threshold', async () => {
|
|
396
444
|
const MOCKED_TOKEN_LIMIT = 1000;
|
|
397
445
|
const originalTokenCount = MOCKED_TOKEN_LIMIT * 0.699;
|
|
@@ -427,6 +475,25 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
427
475
|
newTokenCount: 50,
|
|
428
476
|
});
|
|
429
477
|
});
|
|
478
|
+
it('should resume the session file when compression succeeds', async () => {
|
|
479
|
+
const { client, mockOriginalChat } = setup({
|
|
480
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
481
|
+
});
|
|
482
|
+
const mockConversation = { some: 'conversation' };
|
|
483
|
+
const mockFilePath = '/tmp/session.json';
|
|
484
|
+
// Override the mock to return values
|
|
485
|
+
const mockRecordingService = {
|
|
486
|
+
getConversation: vi.fn().mockReturnValue(mockConversation),
|
|
487
|
+
getConversationFilePath: vi.fn().mockReturnValue(mockFilePath),
|
|
488
|
+
};
|
|
489
|
+
vi.mocked(mockOriginalChat.getChatRecordingService).mockReturnValue(mockRecordingService);
|
|
490
|
+
await client.tryCompressChat('prompt-id', false);
|
|
491
|
+
expect(client['startChat']).toHaveBeenCalledWith(expect.anything(), // newHistory
|
|
492
|
+
{
|
|
493
|
+
conversation: mockConversation,
|
|
494
|
+
filePath: mockFilePath,
|
|
495
|
+
});
|
|
496
|
+
});
|
|
430
497
|
});
|
|
431
498
|
describe('sendMessageStream', () => {
|
|
432
499
|
it('emits a compression event when the context was automatically compressed', async () => {
|
|
@@ -1084,38 +1151,48 @@ ${JSON.stringify({
|
|
|
1084
1151
|
// Should use the newly routed model
|
|
1085
1152
|
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'new-routed-model' }, [{ text: 'A new topic' }], expect.any(AbortSignal));
|
|
1086
1153
|
});
|
|
1087
|
-
it('should
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
reason: 'fallback',
|
|
1154
|
+
it('should re-route within the same prompt when the configured model changes', async () => {
|
|
1155
|
+
mockTurnRunFn.mockClear();
|
|
1156
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1157
|
+
yield { type: 'content', value: 'Hello' };
|
|
1092
1158
|
});
|
|
1093
|
-
|
|
1159
|
+
mockRouterService.route.mockResolvedValueOnce({
|
|
1160
|
+
model: 'original-model',
|
|
1161
|
+
reason: 'test',
|
|
1162
|
+
});
|
|
1163
|
+
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1094
1164
|
await fromAsync(stream);
|
|
1095
|
-
expect(
|
|
1096
|
-
|
|
1097
|
-
it('should stick to the fallback model for the entire sequence even if fallback mode ends', async () => {
|
|
1098
|
-
// Start the sequence in fallback mode
|
|
1099
|
-
vi.mocked(mockConfig.isInFallbackMode).mockReturnValue(true);
|
|
1165
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1166
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(1, { model: 'original-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1100
1167
|
mockRouterService.route.mockResolvedValue({
|
|
1101
|
-
model:
|
|
1102
|
-
reason: '
|
|
1168
|
+
model: 'fallback-model',
|
|
1169
|
+
reason: 'test',
|
|
1103
1170
|
});
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: DEFAULT_GEMINI_FLASH_MODEL }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1108
|
-
// End fallback mode
|
|
1109
|
-
vi.mocked(mockConfig.isInFallbackMode).mockReturnValue(false);
|
|
1110
|
-
// Second call in the same sequence
|
|
1111
|
-
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-fallback-stickiness');
|
|
1171
|
+
vi.mocked(mockConfig.getModel).mockReturnValue('gemini-2.5-flash');
|
|
1172
|
+
coreEvents.emitModelChanged('gemini-2.5-flash');
|
|
1173
|
+
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-1');
|
|
1112
1174
|
await fromAsync(stream);
|
|
1113
|
-
|
|
1114
|
-
expect(mockTurnRunFn).
|
|
1115
|
-
expect(mockTurnRunFn).toHaveBeenLastCalledWith({ model: DEFAULT_GEMINI_FLASH_MODEL }, // Still the fallback model
|
|
1116
|
-
[{ text: 'Continue' }], expect.any(AbortSignal));
|
|
1175
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(2);
|
|
1176
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, { model: 'fallback-model' }, [{ text: 'Continue' }], expect.any(AbortSignal));
|
|
1117
1177
|
});
|
|
1118
1178
|
});
|
|
1179
|
+
it('should use getGlobalMemory for system instruction when JIT is enabled', async () => {
|
|
1180
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(true);
|
|
1181
|
+
vi.mocked(mockConfig.getGlobalMemory).mockReturnValue('Global JIT Memory');
|
|
1182
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Full JIT Memory');
|
|
1183
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1184
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1185
|
+
await client.updateSystemInstruction();
|
|
1186
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Global JIT Memory');
|
|
1187
|
+
});
|
|
1188
|
+
it('should use getUserMemory for system instruction when JIT is disabled', async () => {
|
|
1189
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(false);
|
|
1190
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Legacy Memory');
|
|
1191
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1192
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1193
|
+
await client.updateSystemInstruction();
|
|
1194
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Legacy Memory');
|
|
1195
|
+
});
|
|
1119
1196
|
it('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received', async () => {
|
|
1120
1197
|
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1121
1198
|
// Arrange
|
|
@@ -1203,8 +1280,8 @@ ${JSON.stringify({
|
|
|
1203
1280
|
// We expect 3 events (model_info + original + 1 retry)
|
|
1204
1281
|
expect(events.length).toBe(3);
|
|
1205
1282
|
expect(events
|
|
1206
|
-
.filter((e) => e.type
|
|
1207
|
-
.
|
|
1283
|
+
.filter((e) => e.type === GeminiEventType.ModelInfo)
|
|
1284
|
+
.map((e) => e.value)).toEqual(['default-routed-model']);
|
|
1208
1285
|
// Verify that turn.run was called twice
|
|
1209
1286
|
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
1210
1287
|
});
|
|
@@ -1427,6 +1504,94 @@ ${JSON.stringify({
|
|
|
1427
1504
|
expect(contextJson.activeFile.path).toBe('/path/to/active/file.ts');
|
|
1428
1505
|
});
|
|
1429
1506
|
});
|
|
1507
|
+
describe('Availability Service Integration', () => {
|
|
1508
|
+
let mockAvailabilityService;
|
|
1509
|
+
beforeEach(() => {
|
|
1510
|
+
mockAvailabilityService = createAvailabilityServiceMock();
|
|
1511
|
+
vi.mocked(mockConfig.getModelAvailabilityService).mockReturnValue(mockAvailabilityService);
|
|
1512
|
+
vi.mocked(mockConfig.setActiveModel).mockClear();
|
|
1513
|
+
mockRouterService.route.mockResolvedValue({
|
|
1514
|
+
model: 'model-a',
|
|
1515
|
+
reason: 'test',
|
|
1516
|
+
});
|
|
1517
|
+
vi.mocked(mockConfig.getModelRouterService).mockReturnValue(mockRouterService);
|
|
1518
|
+
vi.spyOn(policyCatalog, 'getModelPolicyChain').mockReturnValue([
|
|
1519
|
+
{
|
|
1520
|
+
model: 'model-a',
|
|
1521
|
+
isLastResort: false,
|
|
1522
|
+
actions: {},
|
|
1523
|
+
stateTransitions: {},
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
model: 'model-b',
|
|
1527
|
+
isLastResort: true,
|
|
1528
|
+
actions: {},
|
|
1529
|
+
stateTransitions: {},
|
|
1530
|
+
},
|
|
1531
|
+
]);
|
|
1532
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
1533
|
+
yield { type: 'content', value: 'Hello' };
|
|
1534
|
+
})());
|
|
1535
|
+
});
|
|
1536
|
+
it('should select first available model, set active, and not consume sticky attempt (done lower in chain)', async () => {
|
|
1537
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1538
|
+
selectedModel: 'model-a',
|
|
1539
|
+
attempts: 1,
|
|
1540
|
+
skipped: [],
|
|
1541
|
+
});
|
|
1542
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1543
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail');
|
|
1544
|
+
await fromAsync(stream);
|
|
1545
|
+
expect(mockAvailabilityService.selectFirstAvailable).toHaveBeenCalledWith(['model-a', 'model-b']);
|
|
1546
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-a');
|
|
1547
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1548
|
+
// Ensure turn.run used the selected model
|
|
1549
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith(expect.objectContaining({ model: 'model-a' }), expect.anything(), expect.anything());
|
|
1550
|
+
});
|
|
1551
|
+
it('should default to last resort model if selection returns null', async () => {
|
|
1552
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1553
|
+
selectedModel: null,
|
|
1554
|
+
skipped: [],
|
|
1555
|
+
});
|
|
1556
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1557
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail-fallback');
|
|
1558
|
+
await fromAsync(stream);
|
|
1559
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-b'); // Last resort
|
|
1560
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1561
|
+
});
|
|
1562
|
+
it('should reset turn on new message stream', async () => {
|
|
1563
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1564
|
+
selectedModel: 'model-a',
|
|
1565
|
+
skipped: [],
|
|
1566
|
+
});
|
|
1567
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-reset');
|
|
1568
|
+
await fromAsync(stream);
|
|
1569
|
+
expect(mockConfig.resetTurn).toHaveBeenCalled();
|
|
1570
|
+
});
|
|
1571
|
+
it('should NOT reset turn on invalid stream retry', async () => {
|
|
1572
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1573
|
+
selectedModel: 'model-a',
|
|
1574
|
+
skipped: [],
|
|
1575
|
+
});
|
|
1576
|
+
// We simulate a retry by calling sendMessageStream with isInvalidStreamRetry=true
|
|
1577
|
+
// But the public API doesn't expose that argument directly unless we use the private method or simulate the recursion.
|
|
1578
|
+
// We can simulate recursion by mocking turn run to return invalid stream once.
|
|
1579
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1580
|
+
const mockStream1 = (async function* () {
|
|
1581
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1582
|
+
})();
|
|
1583
|
+
const mockStream2 = (async function* () {
|
|
1584
|
+
yield { type: 'content', value: 'ok' };
|
|
1585
|
+
})();
|
|
1586
|
+
mockTurnRunFn
|
|
1587
|
+
.mockReturnValueOnce(mockStream1)
|
|
1588
|
+
.mockReturnValueOnce(mockStream2);
|
|
1589
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-retry');
|
|
1590
|
+
await fromAsync(stream);
|
|
1591
|
+
// resetTurn should be called once (for the initial call) but NOT for the recursive call
|
|
1592
|
+
expect(mockConfig.resetTurn).toHaveBeenCalledTimes(1);
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1430
1595
|
describe('IDE context with pending tool calls', () => {
|
|
1431
1596
|
let mockChat;
|
|
1432
1597
|
beforeEach(() => {
|
|
@@ -1779,9 +1944,9 @@ ${JSON.stringify({
|
|
|
1779
1944
|
it('should call generateContent with the correct parameters', async () => {
|
|
1780
1945
|
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1781
1946
|
const abortSignal = new AbortController().signal;
|
|
1782
|
-
await client.generateContent({ model:
|
|
1947
|
+
await client.generateContent({ model: 'test-model' }, contents, abortSignal);
|
|
1783
1948
|
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1784
|
-
model:
|
|
1949
|
+
model: 'test-model',
|
|
1785
1950
|
config: {
|
|
1786
1951
|
abortSignal,
|
|
1787
1952
|
systemInstruction: getCoreSystemPrompt({}, ''),
|
|
@@ -1792,33 +1957,198 @@ ${JSON.stringify({
|
|
|
1792
1957
|
}, 'test-session-id');
|
|
1793
1958
|
});
|
|
1794
1959
|
it('should use current model from config for content generation', async () => {
|
|
1795
|
-
const initialModel =
|
|
1960
|
+
const initialModel = 'test-model';
|
|
1796
1961
|
const contents = [{ role: 'user', parts: [{ text: 'test' }] }];
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
await client.generateContent({ model: DEFAULT_GEMINI_FLASH_MODEL }, contents, new AbortController().signal);
|
|
1800
|
-
expect(mockContentGenerator.generateContent).not.toHaveBeenCalledWith({
|
|
1962
|
+
await client.generateContent({ model: initialModel }, contents, new AbortController().signal);
|
|
1963
|
+
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(expect.objectContaining({
|
|
1801
1964
|
model: initialModel,
|
|
1802
|
-
config: expect.any(Object),
|
|
1803
|
-
contents,
|
|
1804
|
-
});
|
|
1805
|
-
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1806
|
-
model: DEFAULT_GEMINI_FLASH_MODEL,
|
|
1807
|
-
config: expect.any(Object),
|
|
1808
|
-
contents,
|
|
1809
|
-
}, 'test-session-id');
|
|
1810
|
-
});
|
|
1811
|
-
it('should use the Flash model when fallback mode is active', async () => {
|
|
1812
|
-
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1813
|
-
const abortSignal = new AbortController().signal;
|
|
1814
|
-
const requestedModel = 'gemini-2.5-pro'; // A non-flash model
|
|
1815
|
-
// Mock config to be in fallback mode
|
|
1816
|
-
vi.spyOn(client['config'], 'isInFallbackMode').mockReturnValue(true);
|
|
1817
|
-
await client.generateContent({ model: requestedModel }, contents, abortSignal);
|
|
1818
|
-
expect(mockGenerateContentFn).toHaveBeenCalledWith(expect.objectContaining({
|
|
1819
|
-
model: DEFAULT_GEMINI_FLASH_MODEL,
|
|
1820
1965
|
}), 'test-session-id');
|
|
1821
1966
|
});
|
|
1967
|
+
describe('Hook System', () => {
|
|
1968
|
+
let mockMessageBus;
|
|
1969
|
+
beforeEach(() => {
|
|
1970
|
+
vi.clearAllMocks();
|
|
1971
|
+
mockMessageBus = { publish: vi.fn(), subscribe: vi.fn() };
|
|
1972
|
+
// Force override config methods on the client instance
|
|
1973
|
+
client['config'].getEnableHooks = vi.fn().mockReturnValue(true);
|
|
1974
|
+
client['config'].getMessageBus = vi
|
|
1975
|
+
.fn()
|
|
1976
|
+
.mockReturnValue(mockMessageBus);
|
|
1977
|
+
});
|
|
1978
|
+
it('should fire BeforeAgent and AfterAgent exactly once for a simple turn', async () => {
|
|
1979
|
+
const promptId = 'test-prompt-hook-1';
|
|
1980
|
+
const request = { text: 'Hello Hooks' };
|
|
1981
|
+
const signal = new AbortController().signal;
|
|
1982
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1983
|
+
this.getResponseText.mockReturnValue('Hook Response');
|
|
1984
|
+
yield { type: GeminiEventType.Content, value: 'Hook Response' };
|
|
1985
|
+
});
|
|
1986
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1987
|
+
while (!(await stream.next()).done)
|
|
1988
|
+
;
|
|
1989
|
+
expect(mockHookSystem.fireBeforeAgentEvent).toHaveBeenCalledTimes(1);
|
|
1990
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledTimes(1);
|
|
1991
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), 'Hook Response');
|
|
1992
|
+
// Map should be empty
|
|
1993
|
+
expect(client['hookStateMap'].size).toBe(0);
|
|
1994
|
+
});
|
|
1995
|
+
it('should fire BeforeAgent once and AfterAgent once even with recursion', async () => {
|
|
1996
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
1997
|
+
vi.mocked(checkNextSpeaker)
|
|
1998
|
+
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
|
|
1999
|
+
.mockResolvedValueOnce(null);
|
|
2000
|
+
const promptId = 'test-prompt-hook-recursive';
|
|
2001
|
+
const request = { text: 'Recursion Test' };
|
|
2002
|
+
const signal = new AbortController().signal;
|
|
2003
|
+
let callCount = 0;
|
|
2004
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2005
|
+
callCount++;
|
|
2006
|
+
const response = `Response ${callCount}`;
|
|
2007
|
+
this.getResponseText.mockReturnValue(response);
|
|
2008
|
+
yield { type: GeminiEventType.Content, value: response };
|
|
2009
|
+
});
|
|
2010
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
2011
|
+
while (!(await stream.next()).done)
|
|
2012
|
+
;
|
|
2013
|
+
// BeforeAgent should fire ONLY once despite multiple internal turns
|
|
2014
|
+
expect(mockHookSystem.fireBeforeAgentEvent).toHaveBeenCalledTimes(1);
|
|
2015
|
+
// AfterAgent should fire ONLY when the stack unwinds
|
|
2016
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledTimes(1);
|
|
2017
|
+
// Check cumulative response (separated by newline)
|
|
2018
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), 'Response 1\nResponse 2');
|
|
2019
|
+
expect(client['hookStateMap'].size).toBe(0);
|
|
2020
|
+
});
|
|
2021
|
+
it('should use original request in AfterAgent hook even when continuation happened', async () => {
|
|
2022
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
2023
|
+
vi.mocked(checkNextSpeaker)
|
|
2024
|
+
.mockResolvedValueOnce({ next_speaker: 'model', reasoning: 'more' })
|
|
2025
|
+
.mockResolvedValueOnce(null);
|
|
2026
|
+
const promptId = 'test-prompt-hook-original-req';
|
|
2027
|
+
const request = { text: 'Do something' };
|
|
2028
|
+
const signal = new AbortController().signal;
|
|
2029
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2030
|
+
this.getResponseText.mockReturnValue('Ok');
|
|
2031
|
+
yield { type: GeminiEventType.Content, value: 'Ok' };
|
|
2032
|
+
});
|
|
2033
|
+
const stream = client.sendMessageStream(request, signal, promptId);
|
|
2034
|
+
while (!(await stream.next()).done)
|
|
2035
|
+
;
|
|
2036
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), // Should be 'Do something'
|
|
2037
|
+
expect.stringContaining('Ok'));
|
|
2038
|
+
});
|
|
2039
|
+
it('should cleanup state when prompt_id changes', async () => {
|
|
2040
|
+
const signal = new AbortController().signal;
|
|
2041
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2042
|
+
this.getResponseText.mockReturnValue('Ok');
|
|
2043
|
+
yield { type: GeminiEventType.Content, value: 'Ok' };
|
|
2044
|
+
});
|
|
2045
|
+
client['hookStateMap'].set('old-id', {
|
|
2046
|
+
hasFiredBeforeAgent: true,
|
|
2047
|
+
cumulativeResponse: 'Old',
|
|
2048
|
+
activeCalls: 0,
|
|
2049
|
+
originalRequest: { text: 'Old' },
|
|
2050
|
+
});
|
|
2051
|
+
client['lastPromptId'] = 'old-id';
|
|
2052
|
+
const stream = client.sendMessageStream({ text: 'New' }, signal, 'new-id');
|
|
2053
|
+
await stream.next();
|
|
2054
|
+
expect(client['hookStateMap'].has('old-id')).toBe(false);
|
|
2055
|
+
expect(client['hookStateMap'].has('new-id')).toBe(true);
|
|
2056
|
+
});
|
|
2057
|
+
it('should stop execution in BeforeAgent when hook returns continue: false', async () => {
|
|
2058
|
+
mockHookSystem.fireBeforeAgentEvent.mockResolvedValue({
|
|
2059
|
+
shouldStopExecution: () => true,
|
|
2060
|
+
getEffectiveReason: () => 'Stopped by hook',
|
|
2061
|
+
systemMessage: undefined,
|
|
2062
|
+
});
|
|
2063
|
+
const mockChat = {
|
|
2064
|
+
addHistory: vi.fn(),
|
|
2065
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
2066
|
+
getLastPromptTokenCount: vi.fn(),
|
|
2067
|
+
};
|
|
2068
|
+
client['chat'] = mockChat;
|
|
2069
|
+
const request = [{ text: 'Hello' }];
|
|
2070
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt');
|
|
2071
|
+
const events = await fromAsync(stream);
|
|
2072
|
+
expect(events).toContainEqual({
|
|
2073
|
+
type: GeminiEventType.AgentExecutionStopped,
|
|
2074
|
+
value: { reason: 'Stopped by hook' },
|
|
2075
|
+
});
|
|
2076
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
|
2077
|
+
role: 'user',
|
|
2078
|
+
parts: request,
|
|
2079
|
+
});
|
|
2080
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2081
|
+
});
|
|
2082
|
+
it('should block execution in BeforeAgent when hook returns decision: block', async () => {
|
|
2083
|
+
mockHookSystem.fireBeforeAgentEvent.mockResolvedValue({
|
|
2084
|
+
shouldStopExecution: () => false,
|
|
2085
|
+
isBlockingDecision: () => true,
|
|
2086
|
+
getEffectiveReason: () => 'Blocked by hook',
|
|
2087
|
+
systemMessage: undefined,
|
|
2088
|
+
});
|
|
2089
|
+
const mockChat = {
|
|
2090
|
+
addHistory: vi.fn(),
|
|
2091
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
2092
|
+
getLastPromptTokenCount: vi.fn(),
|
|
2093
|
+
};
|
|
2094
|
+
client['chat'] = mockChat;
|
|
2095
|
+
const request = [{ text: 'Hello' }];
|
|
2096
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt');
|
|
2097
|
+
const events = await fromAsync(stream);
|
|
2098
|
+
expect(events).toContainEqual({
|
|
2099
|
+
type: GeminiEventType.AgentExecutionBlocked,
|
|
2100
|
+
value: {
|
|
2101
|
+
reason: 'Blocked by hook',
|
|
2102
|
+
},
|
|
2103
|
+
});
|
|
2104
|
+
expect(mockChat.addHistory).not.toHaveBeenCalled();
|
|
2105
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2106
|
+
});
|
|
2107
|
+
it('should stop execution in AfterAgent when hook returns continue: false', async () => {
|
|
2108
|
+
mockHookSystem.fireAfterAgentEvent.mockResolvedValue({
|
|
2109
|
+
shouldStopExecution: () => true,
|
|
2110
|
+
getEffectiveReason: () => 'Stopped after agent',
|
|
2111
|
+
systemMessage: undefined,
|
|
2112
|
+
});
|
|
2113
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2114
|
+
yield { type: GeminiEventType.Content, value: 'Hello' };
|
|
2115
|
+
});
|
|
2116
|
+
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2117
|
+
const events = await fromAsync(stream);
|
|
2118
|
+
expect(events).toContainEqual({
|
|
2119
|
+
type: GeminiEventType.AgentExecutionStopped,
|
|
2120
|
+
value: { reason: 'Stopped after agent' },
|
|
2121
|
+
});
|
|
2122
|
+
// sendMessageStream should not recurse
|
|
2123
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
|
2124
|
+
});
|
|
2125
|
+
it('should yield AgentExecutionBlocked and recurse in AfterAgent when hook returns decision: block', async () => {
|
|
2126
|
+
mockHookSystem.fireAfterAgentEvent
|
|
2127
|
+
.mockResolvedValueOnce({
|
|
2128
|
+
shouldStopExecution: () => false,
|
|
2129
|
+
isBlockingDecision: () => true,
|
|
2130
|
+
getEffectiveReason: () => 'Please explain',
|
|
2131
|
+
systemMessage: undefined,
|
|
2132
|
+
})
|
|
2133
|
+
.mockResolvedValueOnce({
|
|
2134
|
+
shouldStopExecution: () => false,
|
|
2135
|
+
isBlockingDecision: () => false,
|
|
2136
|
+
systemMessage: undefined,
|
|
2137
|
+
});
|
|
2138
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2139
|
+
yield { type: GeminiEventType.Content, value: 'Response' };
|
|
2140
|
+
});
|
|
2141
|
+
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2142
|
+
const events = await fromAsync(stream);
|
|
2143
|
+
expect(events).toContainEqual({
|
|
2144
|
+
type: GeminiEventType.AgentExecutionBlocked,
|
|
2145
|
+
value: { reason: 'Please explain' },
|
|
2146
|
+
});
|
|
2147
|
+
// Should have called turn run twice (original + re-prompt)
|
|
2148
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
2149
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, expect.anything(), [{ text: 'Please explain' }], expect.anything());
|
|
2150
|
+
});
|
|
2151
|
+
});
|
|
1822
2152
|
});
|
|
1823
2153
|
});
|
|
1824
2154
|
//# sourceMappingURL=client.test.js.map
|