@terminai/core 0.21.0
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/.last_build +0 -0
- package/dist/docs/CONTRIBUTING.md +327 -0
- package/dist/docs/architecture.md +95 -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/termai-banner.png +0 -0
- package/dist/docs/assets/termai-demo.gif +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 +897 -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 +784 -0
- package/dist/docs/cli/custom-commands.md +385 -0
- package/dist/docs/cli/enterprise.md +565 -0
- package/dist/docs/cli/gemini-ignore.md +74 -0
- package/dist/docs/cli/generation-settings.md +210 -0
- package/dist/docs/cli/headless.md +391 -0
- package/dist/docs/cli/index.md +66 -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 +174 -0
- package/dist/docs/cli/session-management.md +161 -0
- package/dist/docs/cli/settings.md +112 -0
- package/dist/docs/cli/system-prompt.md +101 -0
- package/dist/docs/cli/telemetry.md +793 -0
- package/dist/docs/cli/terminaI-md.md +109 -0
- package/dist/docs/cli/themes.md +253 -0
- package/dist/docs/cli/token-caching.md +20 -0
- package/dist/docs/cli/trusted-folders.md +95 -0
- package/dist/docs/cli/tutorials.md +130 -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/demos.md +74 -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 +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 +892 -0
- package/dist/docs/get-started/configuration.md +1647 -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-2.0-flash-exp.md +118 -0
- package/dist/docs/get-started/index.md +76 -0
- package/dist/docs/get-started/installation.md +141 -0
- package/dist/docs/handoff_professionalization.md +69 -0
- package/dist/docs/hooks/best-practices.md +806 -0
- package/dist/docs/hooks/index.md +665 -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 +201 -0
- package/dist/docs/index.md +170 -0
- package/dist/docs/integration-tests.md +52 -0
- package/dist/docs/issue-and-pr-automation.md +134 -0
- package/dist/docs/local-development.md +129 -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 +162 -0
- package/dist/docs/releases.md +540 -0
- package/dist/docs/security-posture.md +52 -0
- package/dist/docs/sidebar.json +329 -0
- package/dist/docs/termai-comparison.md +91 -0
- package/dist/docs/termai-examples.md +51 -0
- package/dist/docs/termai-operator-recipes.md +93 -0
- package/dist/docs/termai-process-manager.md +68 -0
- package/dist/docs/termai-quickstart.md +59 -0
- package/dist/docs/termai-system.md +64 -0
- package/dist/docs/tools/file-system.md +268 -0
- package/dist/docs/tools/index.md +105 -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 +57 -0
- package/dist/docs/tools/web-fetch.md +69 -0
- package/dist/docs/tools/web-search.md +50 -0
- package/dist/docs/tos-privacy.md +96 -0
- package/dist/docs/troubleshooting.md +162 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__mocks__/fs/promises.d.ts +12 -0
- package/dist/src/__mocks__/fs/promises.js +18 -0
- package/dist/src/__mocks__/fs/promises.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +47 -0
- package/dist/src/agents/codebase-investigator.js +134 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/codebase-investigator.test.d.ts +7 -0
- package/dist/src/agents/codebase-investigator.test.js +36 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/delegate-to-agent-tool.d.ts +20 -0
- package/dist/src/agents/delegate-to-agent-tool.js +116 -0
- package/dist/src/agents/delegate-to-agent-tool.js.map +1 -0
- package/dist/src/agents/delegate-to-agent-tool.test.d.ts +7 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js +136 -0
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +24 -0
- package/dist/src/agents/introspection-agent.js +73 -0
- package/dist/src/agents/introspection-agent.js.map +1 -0
- package/dist/src/agents/introspection-agent.test.d.ts +7 -0
- package/dist/src/agents/introspection-agent.test.js +48 -0
- package/dist/src/agents/introspection-agent.test.js.map +1 -0
- package/dist/src/agents/local-executor.d.ts +109 -0
- package/dist/src/agents/local-executor.js +805 -0
- package/dist/src/agents/local-executor.js.map +1 -0
- package/dist/src/agents/local-executor.test.d.ts +7 -0
- package/dist/src/agents/local-executor.test.js +1381 -0
- package/dist/src/agents/local-executor.test.js.map +1 -0
- package/dist/src/agents/local-invocation.d.ts +46 -0
- package/dist/src/agents/local-invocation.js +102 -0
- package/dist/src/agents/local-invocation.js.map +1 -0
- package/dist/src/agents/local-invocation.test.d.ts +7 -0
- package/dist/src/agents/local-invocation.test.js +217 -0
- package/dist/src/agents/local-invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +57 -0
- package/dist/src/agents/registry.js +210 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +7 -0
- package/dist/src/agents/registry.test.js +334 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/remote-invocation.d.ts +22 -0
- package/dist/src/agents/remote-invocation.js +32 -0
- package/dist/src/agents/remote-invocation.js.map +1 -0
- package/dist/src/agents/remote-invocation.test.d.ts +7 -0
- package/dist/src/agents/remote-invocation.test.js +36 -0
- package/dist/src/agents/remote-invocation.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +40 -0
- package/dist/src/agents/schema-utils.js +58 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +7 -0
- package/dist/src/agents/schema-utils.test.js +145 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +39 -0
- package/dist/src/agents/subagent-tool-wrapper.js +53 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +7 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +112 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/toml-loader.d.ts +66 -0
- package/dist/src/agents/toml-loader.js +177 -0
- package/dist/src/agents/toml-loader.js.map +1 -0
- package/dist/src/agents/toml-loader.test.d.ts +7 -0
- package/dist/src/agents/toml-loader.test.js +191 -0
- package/dist/src/agents/toml-loader.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +155 -0
- package/dist/src/agents/types.js +20 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +16 -0
- package/dist/src/agents/utils.js +30 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +7 -0
- package/dist/src/agents/utils.test.js +88 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/audit/export.d.ts +10 -0
- package/dist/src/audit/export.js +30 -0
- package/dist/src/audit/export.js.map +1 -0
- package/dist/src/audit/hashChain.d.ts +16 -0
- package/dist/src/audit/hashChain.js +43 -0
- package/dist/src/audit/hashChain.js.map +1 -0
- package/dist/src/audit/index.d.ts +16 -0
- package/dist/src/audit/index.js +15 -0
- package/dist/src/audit/index.js.map +1 -0
- package/dist/src/audit/ledger.d.ts +46 -0
- package/dist/src/audit/ledger.js +113 -0
- package/dist/src/audit/ledger.js.map +1 -0
- package/dist/src/audit/ledger.test.d.ts +7 -0
- package/dist/src/audit/ledger.test.js +68 -0
- package/dist/src/audit/ledger.test.js.map +1 -0
- package/dist/src/audit/redaction.d.ts +11 -0
- package/dist/src/audit/redaction.js +77 -0
- package/dist/src/audit/redaction.js.map +1 -0
- package/dist/src/audit/schema.d.ts +52 -0
- package/dist/src/audit/schema.js +8 -0
- package/dist/src/audit/schema.js.map +1 -0
- package/dist/src/auth/geminiAuthStatus.d.ts +17 -0
- package/dist/src/auth/geminiAuthStatus.js +96 -0
- package/dist/src/auth/geminiAuthStatus.js.map +1 -0
- package/dist/src/auth/geminiAuthStatus.test.d.ts +7 -0
- package/dist/src/auth/geminiAuthStatus.test.js +88 -0
- package/dist/src/auth/geminiAuthStatus.test.js.map +1 -0
- package/dist/src/auth/providerRegistry.d.ts +26 -0
- package/dist/src/auth/providerRegistry.js +76 -0
- package/dist/src/auth/providerRegistry.js.map +1 -0
- package/dist/src/auth/wizardSettings.d.ts +25 -0
- package/dist/src/auth/wizardSettings.js +70 -0
- package/dist/src/auth/wizardSettings.js.map +1 -0
- package/dist/src/auth/wizardSettings.test.d.ts +7 -0
- package/dist/src/auth/wizardSettings.test.js +63 -0
- package/dist/src/auth/wizardSettings.test.js.map +1 -0
- package/dist/src/auth/wizardState.d.ts +80 -0
- package/dist/src/auth/wizardState.js +142 -0
- package/dist/src/auth/wizardState.js.map +1 -0
- package/dist/src/auth/wizardState.test.d.ts +7 -0
- package/dist/src/auth/wizardState.test.js +220 -0
- package/dist/src/auth/wizardState.test.js.map +1 -0
- package/dist/src/availability/errorClassification.d.ts +8 -0
- package/dist/src/availability/errorClassification.js +21 -0
- package/dist/src/availability/errorClassification.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.d.ts +37 -0
- package/dist/src/availability/modelAvailabilityService.js +88 -0
- package/dist/src/availability/modelAvailabilityService.js.map +1 -0
- package/dist/src/availability/modelAvailabilityService.test.d.ts +7 -0
- package/dist/src/availability/modelAvailabilityService.test.js +141 -0
- package/dist/src/availability/modelAvailabilityService.test.js.map +1 -0
- package/dist/src/availability/modelPolicy.d.ts +50 -0
- package/dist/src/availability/modelPolicy.js +8 -0
- package/dist/src/availability/modelPolicy.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +24 -0
- package/dist/src/availability/policyCatalog.js +83 -0
- package/dist/src/availability/policyCatalog.js.map +1 -0
- package/dist/src/availability/policyCatalog.test.d.ts +7 -0
- package/dist/src/availability/policyCatalog.test.js +71 -0
- package/dist/src/availability/policyCatalog.test.js.map +1 -0
- package/dist/src/availability/policyHelpers.d.ts +53 -0
- package/dist/src/availability/policyHelpers.js +139 -0
- package/dist/src/availability/policyHelpers.js.map +1 -0
- package/dist/src/availability/policyHelpers.test.d.ts +7 -0
- package/dist/src/availability/policyHelpers.test.js +183 -0
- package/dist/src/availability/policyHelpers.test.js.map +1 -0
- package/dist/src/availability/testUtils.d.ts +11 -0
- package/dist/src/availability/testUtils.js +23 -0
- package/dist/src/availability/testUtils.js.map +1 -0
- package/dist/src/brain/__tests__/advisors.test.d.ts +7 -0
- package/dist/src/brain/__tests__/advisors.test.js +77 -0
- package/dist/src/brain/__tests__/advisors.test.js.map +1 -0
- package/dist/src/brain/__tests__/cognitiveArchitecture.test.d.ts +7 -0
- package/dist/src/brain/__tests__/cognitiveArchitecture.test.js +61 -0
- package/dist/src/brain/__tests__/cognitiveArchitecture.test.js.map +1 -0
- package/dist/src/brain/__tests__/confidenceHandler.test.d.ts +7 -0
- package/dist/src/brain/__tests__/confidenceHandler.test.js +29 -0
- package/dist/src/brain/__tests__/confidenceHandler.test.js.map +1 -0
- package/dist/src/brain/__tests__/environmentDetector.test.d.ts +7 -0
- package/dist/src/brain/__tests__/environmentDetector.test.js +73 -0
- package/dist/src/brain/__tests__/environmentDetector.test.js.map +1 -0
- package/dist/src/brain/__tests__/executionRouter.test.d.ts +7 -0
- package/dist/src/brain/__tests__/executionRouter.test.js +67 -0
- package/dist/src/brain/__tests__/executionRouter.test.js.map +1 -0
- package/dist/src/brain/__tests__/frameworkSelector.test.d.ts +7 -0
- package/dist/src/brain/__tests__/frameworkSelector.test.js +47 -0
- package/dist/src/brain/__tests__/frameworkSelector.test.js.map +1 -0
- package/dist/src/brain/__tests__/historyTracker.test.d.ts +7 -0
- package/dist/src/brain/__tests__/historyTracker.test.js +78 -0
- package/dist/src/brain/__tests__/historyTracker.test.js.map +1 -0
- package/dist/src/brain/__tests__/pacLoop.test.d.ts +7 -0
- package/dist/src/brain/__tests__/pacLoop.test.js +49 -0
- package/dist/src/brain/__tests__/pacLoop.test.js.map +1 -0
- package/dist/src/brain/__tests__/riskAssessor.test.d.ts +7 -0
- package/dist/src/brain/__tests__/riskAssessor.test.js +87 -0
- package/dist/src/brain/__tests__/riskAssessor.test.js.map +1 -0
- package/dist/src/brain/__tests__/taskDecomposer.test.d.ts +7 -0
- package/dist/src/brain/__tests__/taskDecomposer.test.js +86 -0
- package/dist/src/brain/__tests__/taskDecomposer.test.js.map +1 -0
- package/dist/src/brain/__tests__/thinkingOrchestrator.test.d.ts +7 -0
- package/dist/src/brain/__tests__/thinkingOrchestrator.test.js +77 -0
- package/dist/src/brain/__tests__/thinkingOrchestrator.test.js.map +1 -0
- package/dist/src/brain/advisors/codeGenerator.d.ts +18 -0
- package/dist/src/brain/advisors/codeGenerator.js +68 -0
- package/dist/src/brain/advisors/codeGenerator.js.map +1 -0
- package/dist/src/brain/advisors/depScanner.d.ts +18 -0
- package/dist/src/brain/advisors/depScanner.js +76 -0
- package/dist/src/brain/advisors/depScanner.js.map +1 -0
- package/dist/src/brain/advisors/enumerator.d.ts +18 -0
- package/dist/src/brain/advisors/enumerator.js +65 -0
- package/dist/src/brain/advisors/enumerator.js.map +1 -0
- package/dist/src/brain/advisors/fallbackChain.d.ts +18 -0
- package/dist/src/brain/advisors/fallbackChain.js +66 -0
- package/dist/src/brain/advisors/fallbackChain.js.map +1 -0
- package/dist/src/brain/advisors/patternMatcher.d.ts +18 -0
- package/dist/src/brain/advisors/patternMatcher.js +65 -0
- package/dist/src/brain/advisors/patternMatcher.js.map +1 -0
- package/dist/src/brain/advisors/types.d.ts +24 -0
- package/dist/src/brain/advisors/types.js +8 -0
- package/dist/src/brain/advisors/types.js.map +1 -0
- package/dist/src/brain/codeThinker.d.ts +24 -0
- package/dist/src/brain/codeThinker.js +56 -0
- package/dist/src/brain/codeThinker.js.map +1 -0
- package/dist/src/brain/confidenceHandler.d.ts +13 -0
- package/dist/src/brain/confidenceHandler.js +50 -0
- package/dist/src/brain/confidenceHandler.js.map +1 -0
- package/dist/src/brain/consensus.d.ts +29 -0
- package/dist/src/brain/consensus.js +103 -0
- package/dist/src/brain/consensus.js.map +1 -0
- package/dist/src/brain/environmentDetector.d.ts +9 -0
- package/dist/src/brain/environmentDetector.js +87 -0
- package/dist/src/brain/environmentDetector.js.map +1 -0
- package/dist/src/brain/executionRouter.d.ts +28 -0
- package/dist/src/brain/executionRouter.js +71 -0
- package/dist/src/brain/executionRouter.js.map +1 -0
- package/dist/src/brain/frameworkSelector.d.ts +34 -0
- package/dist/src/brain/frameworkSelector.js +155 -0
- package/dist/src/brain/frameworkSelector.js.map +1 -0
- package/dist/src/brain/historyTracker.d.ts +47 -0
- package/dist/src/brain/historyTracker.js +195 -0
- package/dist/src/brain/historyTracker.js.map +1 -0
- package/dist/src/brain/index.d.ts +29 -0
- package/dist/src/brain/index.js +31 -0
- package/dist/src/brain/index.js.map +1 -0
- package/dist/src/brain/modelAdapter.d.ts +26 -0
- package/dist/src/brain/modelAdapter.js +43 -0
- package/dist/src/brain/modelAdapter.js.map +1 -0
- package/dist/src/brain/pacLoop.d.ts +46 -0
- package/dist/src/brain/pacLoop.js +110 -0
- package/dist/src/brain/pacLoop.js.map +1 -0
- package/dist/src/brain/patterns.d.ts +13 -0
- package/dist/src/brain/patterns.js +82 -0
- package/dist/src/brain/patterns.js.map +1 -0
- package/dist/src/brain/prompts/riskAssessment.d.ts +7 -0
- package/dist/src/brain/prompts/riskAssessment.js +29 -0
- package/dist/src/brain/prompts/riskAssessment.js.map +1 -0
- package/dist/src/brain/reflectiveCritique.d.ts +28 -0
- package/dist/src/brain/reflectiveCritique.js +51 -0
- package/dist/src/brain/reflectiveCritique.js.map +1 -0
- package/dist/src/brain/riskAssessor.d.ts +41 -0
- package/dist/src/brain/riskAssessor.js +185 -0
- package/dist/src/brain/riskAssessor.js.map +1 -0
- package/dist/src/brain/sequentialThinking.d.ts +25 -0
- package/dist/src/brain/sequentialThinking.js +52 -0
- package/dist/src/brain/sequentialThinking.js.map +1 -0
- package/dist/src/brain/stepBackEvaluator.d.ts +30 -0
- package/dist/src/brain/stepBackEvaluator.js +35 -0
- package/dist/src/brain/stepBackEvaluator.js.map +1 -0
- package/dist/src/brain/systemSpec.d.ts +75 -0
- package/dist/src/brain/systemSpec.js +194 -0
- package/dist/src/brain/systemSpec.js.map +1 -0
- package/dist/src/brain/systemSpecPrompt.d.ts +13 -0
- package/dist/src/brain/systemSpecPrompt.js +51 -0
- package/dist/src/brain/systemSpecPrompt.js.map +1 -0
- package/dist/src/brain/taskDecomposer.d.ts +29 -0
- package/dist/src/brain/taskDecomposer.js +96 -0
- package/dist/src/brain/taskDecomposer.js.map +1 -0
- package/dist/src/brain/thinkingOrchestrator.d.ts +48 -0
- package/dist/src/brain/thinkingOrchestrator.js +151 -0
- package/dist/src/brain/thinkingOrchestrator.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +13 -0
- package/dist/src/code_assist/codeAssist.js +32 -0
- package/dist/src/code_assist/codeAssist.js.map +1 -0
- package/dist/src/code_assist/codeAssist.test.d.ts +7 -0
- package/dist/src/code_assist/codeAssist.test.js +100 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +76 -0
- package/dist/src/code_assist/converter.js +162 -0
- package/dist/src/code_assist/converter.js.map +1 -0
- package/dist/src/code_assist/converter.test.d.ts +7 -0
- package/dist/src/code_assist/converter.test.js +392 -0
- package/dist/src/code_assist/converter.test.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.d.ts +13 -0
- package/dist/src/code_assist/experiments/client_metadata.js +52 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +7 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +97 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +18 -0
- package/dist/src/code_assist/experiments/experiments.js +37 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +7 -0
- package/dist/src/code_assist/experiments/experiments.test.js +93 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +14 -0
- package/dist/src/code_assist/experiments/flagNames.js +14 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +36 -0
- package/dist/src/code_assist/experiments/types.js +8 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +26 -0
- package/dist/src/code_assist/oauth-credential-storage.js +111 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +7 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +199 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.begin.test.d.ts +7 -0
- package/dist/src/code_assist/oauth2.begin.test.js +57 -0
- package/dist/src/code_assist/oauth2.begin.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +35 -0
- package/dist/src/code_assist/oauth2.js +568 -0
- package/dist/src/code_assist/oauth2.js.map +1 -0
- package/dist/src/code_assist/oauth2.test.d.ts +7 -0
- package/dist/src/code_assist/oauth2.test.js +1065 -0
- package/dist/src/code_assist/oauth2.test.js.map +1 -0
- package/dist/src/code_assist/server.d.ts +44 -0
- package/dist/src/code_assist/server.js +203 -0
- package/dist/src/code_assist/server.js.map +1 -0
- package/dist/src/code_assist/server.test.d.ts +7 -0
- package/dist/src/code_assist/server.test.js +432 -0
- package/dist/src/code_assist/server.test.js.map +1 -0
- package/dist/src/code_assist/setup.d.ts +21 -0
- package/dist/src/code_assist/setup.js +104 -0
- package/dist/src/code_assist/setup.js.map +1 -0
- package/dist/src/code_assist/setup.test.d.ts +7 -0
- package/dist/src/code_assist/setup.test.js +172 -0
- package/dist/src/code_assist/setup.test.js.map +1 -0
- package/dist/src/code_assist/telemetry.d.ts +15 -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 +7 -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 +229 -0
- package/dist/src/code_assist/types.js +68 -0
- package/dist/src/code_assist/types.js.map +1 -0
- package/dist/src/commands/extensions.d.ts +8 -0
- package/dist/src/commands/extensions.js +10 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +7 -0
- package/dist/src/commands/extensions.test.js +20 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/commands/init.d.ts +8 -0
- package/dist/src/commands/init.js +54 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/init.test.d.ts +7 -0
- package/dist/src/commands/init.test.js +26 -0
- package/dist/src/commands/init.test.js.map +1 -0
- package/dist/src/commands/restore.d.ts +10 -0
- package/dist/src/commands/restore.js +47 -0
- package/dist/src/commands/restore.js.map +1 -0
- package/dist/src/commands/restore.test.d.ts +7 -0
- package/dist/src/commands/restore.test.js +138 -0
- package/dist/src/commands/restore.test.js.map +1 -0
- package/dist/src/commands/types.d.ts +42 -0
- package/dist/src/commands/types.js +8 -0
- package/dist/src/commands/types.js.map +1 -0
- package/dist/src/computer/ComputerSessionManager.d.ts +46 -0
- package/dist/src/computer/ComputerSessionManager.js +201 -0
- package/dist/src/computer/ComputerSessionManager.js.map +1 -0
- package/dist/src/computer/ComputerSessionManager.test.d.ts +7 -0
- package/dist/src/computer/ComputerSessionManager.test.js +98 -0
- package/dist/src/computer/ComputerSessionManager.test.js.map +1 -0
- package/dist/src/computer/PersistentShell.d.ts +27 -0
- package/dist/src/computer/PersistentShell.js +148 -0
- package/dist/src/computer/PersistentShell.js.map +1 -0
- package/dist/src/computer/PersistentShell.test.d.ts +7 -0
- package/dist/src/computer/PersistentShell.test.js +141 -0
- package/dist/src/computer/PersistentShell.test.js.map +1 -0
- package/dist/src/computer/index.d.ts +8 -0
- package/dist/src/computer/index.js +9 -0
- package/dist/src/computer/index.js.map +1 -0
- package/dist/src/computer/truncateOutput.d.ts +7 -0
- package/dist/src/computer/truncateOutput.js +20 -0
- package/dist/src/computer/truncateOutput.js.map +1 -0
- package/dist/src/config/brainAuthority.d.ts +11 -0
- package/dist/src/config/brainAuthority.js +27 -0
- package/dist/src/config/brainAuthority.js.map +1 -0
- package/dist/src/config/builder.d.ts +24 -0
- package/dist/src/config/builder.js +198 -0
- package/dist/src/config/builder.js.map +1 -0
- package/dist/src/config/config.d.ts +639 -0
- package/dist/src/config/config.js +1478 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/config/config.test.d.ts +7 -0
- package/dist/src/config/config.test.js +1579 -0
- package/dist/src/config/config.test.js.map +1 -0
- package/dist/src/config/constants.d.ts +12 -0
- package/dist/src/config/constants.js +17 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/defaultModelConfigs.d.ts +8 -0
- package/dist/src/config/defaultModelConfigs.js +232 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/flashFallback.test.d.ts +7 -0
- package/dist/src/config/flashFallback.test.js +51 -0
- package/dist/src/config/flashFallback.test.js.map +1 -0
- package/dist/src/config/models.d.ts +69 -0
- package/dist/src/config/models.js +141 -0
- package/dist/src/config/models.js.map +1 -0
- package/dist/src/config/models.test.d.ts +7 -0
- package/dist/src/config/models.test.js +111 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/settings/comment-json.d.ts +10 -0
- package/dist/src/config/settings/comment-json.js +121 -0
- package/dist/src/config/settings/comment-json.js.map +1 -0
- package/dist/src/config/settings/constants.d.ts +8 -0
- package/dist/src/config/settings/constants.js +9 -0
- package/dist/src/config/settings/constants.js.map +1 -0
- package/dist/src/config/settings/env-vars.d.ts +13 -0
- package/dist/src/config/settings/env-vars.js +38 -0
- package/dist/src/config/settings/env-vars.js.map +1 -0
- package/dist/src/config/settings/loader.d.ts +52 -0
- package/dist/src/config/settings/loader.js +196 -0
- package/dist/src/config/settings/loader.js.map +1 -0
- package/dist/src/config/settings/loader.test.d.ts +7 -0
- package/dist/src/config/settings/loader.test.js +80 -0
- package/dist/src/config/settings/loader.test.js.map +1 -0
- package/dist/src/config/settings/migrate.d.ts +30 -0
- package/dist/src/config/settings/migrate.js +202 -0
- package/dist/src/config/settings/migrate.js.map +1 -0
- package/dist/src/config/settings/parity.test.d.ts +7 -0
- package/dist/src/config/settings/parity.test.js +147 -0
- package/dist/src/config/settings/parity.test.js.map +1 -0
- package/dist/src/config/settings/schema-types.d.ts +47 -0
- package/dist/src/config/settings/schema-types.js +14 -0
- package/dist/src/config/settings/schema-types.js.map +1 -0
- package/dist/src/config/settings/schema.d.ts +2126 -0
- package/dist/src/config/settings/schema.js +2345 -0
- package/dist/src/config/settings/schema.js.map +1 -0
- package/dist/src/config/settings/settings.test.d.ts +7 -0
- package/dist/src/config/settings/settings.test.js +90 -0
- package/dist/src/config/settings/settings.test.js.map +1 -0
- package/dist/src/config/settings/trust.d.ts +27 -0
- package/dist/src/config/settings/trust.js +175 -0
- package/dist/src/config/settings/trust.js.map +1 -0
- package/dist/src/config/settings/trust.test.d.ts +7 -0
- package/dist/src/config/settings/trust.test.js +63 -0
- package/dist/src/config/settings/trust.test.js.map +1 -0
- package/dist/src/config/settings/types.d.ts +134 -0
- package/dist/src/config/settings/types.js +30 -0
- package/dist/src/config/settings/types.js.map +1 -0
- package/dist/src/config/settings/utils.d.ts +19 -0
- package/dist/src/config/settings/utils.js +67 -0
- package/dist/src/config/settings/utils.js.map +1 -0
- package/dist/src/config/settings/validate.d.ts +24 -0
- package/dist/src/config/settings/validate.js +250 -0
- package/dist/src/config/settings/validate.js.map +1 -0
- package/dist/src/config/storage.d.ts +45 -0
- package/dist/src/config/storage.js +140 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +7 -0
- package/dist/src/config/storage.test.js +57 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +8 -0
- package/dist/src/confirmation-bus/index.js +9 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +25 -0
- package/dist/src/confirmation-bus/message-bus.js +150 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +7 -0
- package/dist/src/confirmation-bus/message-bus.test.js +171 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +77 -0
- package/dist/src/confirmation-bus/types.js +20 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.d.ts +18 -0
- package/dist/src/core/apiKeyCredentialStorage.js +65 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +7 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +72 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +75 -0
- package/dist/src/core/baseLlmClient.js +168 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +7 -0
- package/dist/src/core/baseLlmClient.test.js +570 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +54 -0
- package/dist/src/core/client.js +539 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/client.test.d.ts +7 -0
- package/dist/src/core/client.test.js +1919 -0
- package/dist/src/core/client.test.js.map +1 -0
- package/dist/src/core/clientHookTriggers.d.ts +37 -0
- package/dist/src/core/clientHookTriggers.js +77 -0
- package/dist/src/core/clientHookTriggers.js.map +1 -0
- package/dist/src/core/contentGenerator.d.ts +35 -0
- package/dist/src/core/contentGenerator.js +134 -0
- package/dist/src/core/contentGenerator.js.map +1 -0
- package/dist/src/core/contentGenerator.test.d.ts +7 -0
- package/dist/src/core/contentGenerator.test.js +435 -0
- package/dist/src/core/contentGenerator.test.js.map +1 -0
- package/dist/src/core/coreToolHookTriggers.d.ts +56 -0
- package/dist/src/core/coreToolHookTriggers.js +262 -0
- package/dist/src/core/coreToolHookTriggers.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +145 -0
- package/dist/src/core/coreToolScheduler.js +1119 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/coreToolScheduler.test.d.ts +7 -0
- package/dist/src/core/coreToolScheduler.test.js +1857 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.d.ts +34 -0
- package/dist/src/core/fakeContentGenerator.js +59 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +7 -0
- package/dist/src/core/fakeContentGenerator.test.js +128 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +137 -0
- package/dist/src/core/geminiChat.js +663 -0
- package/dist/src/core/geminiChat.js.map +1 -0
- package/dist/src/core/geminiChat.test.d.ts +7 -0
- package/dist/src/core/geminiChat.test.js +1653 -0
- package/dist/src/core/geminiChat.test.js.map +1 -0
- package/dist/src/core/geminiChatHookTriggers.d.ts +65 -0
- package/dist/src/core/geminiChatHookTriggers.js +137 -0
- package/dist/src/core/geminiChatHookTriggers.js.map +1 -0
- package/dist/src/core/geminiChat_network_retry.test.d.ts +7 -0
- package/dist/src/core/geminiChat_network_retry.test.js +197 -0
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -0
- package/dist/src/core/geminiRequest.d.ts +14 -0
- package/dist/src/core/geminiRequest.js +12 -0
- package/dist/src/core/geminiRequest.js.map +1 -0
- package/dist/src/core/logger.d.ts +74 -0
- package/dist/src/core/logger.js +337 -0
- package/dist/src/core/logger.js.map +1 -0
- package/dist/src/core/logger.test.d.ts +7 -0
- package/dist/src/core/logger.test.js +537 -0
- package/dist/src/core/logger.test.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.d.ts +27 -0
- package/dist/src/core/loggingContentGenerator.js +180 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/loggingContentGenerator.test.d.ts +7 -0
- package/dist/src/core/loggingContentGenerator.test.js +181 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +12 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +30 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +7 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js +306 -0
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
- package/dist/src/core/openaiContentGenerator.d.ts +28 -0
- package/dist/src/core/openaiContentGenerator.js +507 -0
- package/dist/src/core/openaiContentGenerator.js.map +1 -0
- package/dist/src/core/openaiContentGenerator.test.d.ts +7 -0
- package/dist/src/core/openaiContentGenerator.test.js +502 -0
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +19 -0
- package/dist/src/core/prompts.js +384 -0
- package/dist/src/core/prompts.js.map +1 -0
- package/dist/src/core/prompts.test.d.ts +7 -0
- package/dist/src/core/prompts.test.js +332 -0
- package/dist/src/core/prompts.test.js.map +1 -0
- package/dist/src/core/providerTypes.d.ts +37 -0
- package/dist/src/core/providerTypes.js +54 -0
- package/dist/src/core/providerTypes.js.map +1 -0
- package/dist/src/core/providerTypes.test.d.ts +7 -0
- package/dist/src/core/providerTypes.test.js +55 -0
- package/dist/src/core/providerTypes.test.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.d.ts +19 -0
- package/dist/src/core/recordingContentGenerator.js +78 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +7 -0
- package/dist/src/core/recordingContentGenerator.test.js +102 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- package/dist/src/core/sessionHookTriggers.d.ts +29 -0
- package/dist/src/core/sessionHookTriggers.js +69 -0
- package/dist/src/core/sessionHookTriggers.js.map +1 -0
- package/dist/src/core/tokenLimits.d.ts +11 -0
- package/dist/src/core/tokenLimits.js +29 -0
- package/dist/src/core/tokenLimits.js.map +1 -0
- package/dist/src/core/tokenLimits.test.d.ts +7 -0
- package/dist/src/core/tokenLimits.test.js +27 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +177 -0
- package/dist/src/core/turn.js +230 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turn.test.d.ts +7 -0
- package/dist/src/core/turn.test.js +650 -0
- package/dist/src/core/turn.test.js.map +1 -0
- package/dist/src/evaluation/index.d.ts +7 -0
- package/dist/src/evaluation/index.js +8 -0
- package/dist/src/evaluation/index.js.map +1 -0
- package/dist/src/evaluation/sessionEvaluator.d.ts +59 -0
- package/dist/src/evaluation/sessionEvaluator.js +222 -0
- package/dist/src/evaluation/sessionEvaluator.js.map +1 -0
- package/dist/src/fallback/handler.d.ts +8 -0
- package/dist/src/fallback/handler.js +117 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +7 -0
- package/dist/src/fallback/handler.test.js +248 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +23 -0
- package/dist/src/fallback/types.js +8 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +8 -0
- package/dist/src/generated/git-commit.js +11 -0
- package/dist/src/generated/git-commit.js.map +1 -0
- package/dist/src/gui/config.d.ts +19 -0
- package/dist/src/gui/config.js +53 -0
- package/dist/src/gui/config.js.map +1 -0
- package/dist/src/gui/drivers/__tests__/sidecarContract.test.d.ts +7 -0
- package/dist/src/gui/drivers/__tests__/sidecarContract.test.js +161 -0
- package/dist/src/gui/drivers/__tests__/sidecarContract.test.js.map +1 -0
- package/dist/src/gui/drivers/driverRegistry.d.ts +8 -0
- package/dist/src/gui/drivers/driverRegistry.js +31 -0
- package/dist/src/gui/drivers/driverRegistry.js.map +1 -0
- package/dist/src/gui/drivers/linuxAtspiDriver.d.ts +33 -0
- package/dist/src/gui/drivers/linuxAtspiDriver.js +200 -0
- package/dist/src/gui/drivers/linuxAtspiDriver.js.map +1 -0
- package/dist/src/gui/drivers/mockDriver.d.ts +25 -0
- package/dist/src/gui/drivers/mockDriver.js +123 -0
- package/dist/src/gui/drivers/mockDriver.js.map +1 -0
- package/dist/src/gui/drivers/noOpDriver.d.ts +31 -0
- package/dist/src/gui/drivers/noOpDriver.js +110 -0
- package/dist/src/gui/drivers/noOpDriver.js.map +1 -0
- package/dist/src/gui/drivers/types.d.ts +50 -0
- package/dist/src/gui/drivers/types.js +8 -0
- package/dist/src/gui/drivers/types.js.map +1 -0
- package/dist/src/gui/drivers/windowsUiaDriver.d.ts +32 -0
- package/dist/src/gui/drivers/windowsUiaDriver.js +134 -0
- package/dist/src/gui/drivers/windowsUiaDriver.js.map +1 -0
- package/dist/src/gui/protocol/__tests__/schema.test.d.ts +7 -0
- package/dist/src/gui/protocol/__tests__/schema.test.js +72 -0
- package/dist/src/gui/protocol/__tests__/schema.test.js.map +1 -0
- package/dist/src/gui/protocol/schemas.d.ts +960 -0
- package/dist/src/gui/protocol/schemas.js +252 -0
- package/dist/src/gui/protocol/schemas.js.map +1 -0
- package/dist/src/gui/protocol/types.d.ts +149 -0
- package/dist/src/gui/protocol/types.js +8 -0
- package/dist/src/gui/protocol/types.js.map +1 -0
- package/dist/src/gui/selectors/__tests__/selectors.test.d.ts +7 -0
- package/dist/src/gui/selectors/__tests__/selectors.test.js +125 -0
- package/dist/src/gui/selectors/__tests__/selectors.test.js.map +1 -0
- package/dist/src/gui/selectors/ast.d.ts +34 -0
- package/dist/src/gui/selectors/ast.js +8 -0
- package/dist/src/gui/selectors/ast.js.map +1 -0
- package/dist/src/gui/selectors/matcher.d.ts +19 -0
- package/dist/src/gui/selectors/matcher.js +118 -0
- package/dist/src/gui/selectors/matcher.js.map +1 -0
- package/dist/src/gui/selectors/parser.d.ts +26 -0
- package/dist/src/gui/selectors/parser.js +235 -0
- package/dist/src/gui/selectors/parser.js.map +1 -0
- package/dist/src/gui/selectors/resolve.d.ts +18 -0
- package/dist/src/gui/selectors/resolve.js +74 -0
- package/dist/src/gui/selectors/resolve.js.map +1 -0
- package/dist/src/gui/service/DesktopAutomationService.d.ts +46 -0
- package/dist/src/gui/service/DesktopAutomationService.js +689 -0
- package/dist/src/gui/service/DesktopAutomationService.js.map +1 -0
- package/dist/src/gui/service/__tests__/capabilities.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/capabilities.test.js +95 -0
- package/dist/src/gui/service/__tests__/capabilities.test.js.map +1 -0
- package/dist/src/gui/service/__tests__/diagnose.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/diagnose.test.js +91 -0
- package/dist/src/gui/service/__tests__/diagnose.test.js.map +1 -0
- package/dist/src/gui/service/__tests__/progressive.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/progressive.test.js +94 -0
- package/dist/src/gui/service/__tests__/progressive.test.js.map +1 -0
- package/dist/src/gui/service/__tests__/redaction.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/redaction.test.js +94 -0
- package/dist/src/gui/service/__tests__/redaction.test.js.map +1 -0
- package/dist/src/gui/service/__tests__/selectorError.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/selectorError.test.js +28 -0
- package/dist/src/gui/service/__tests__/selectorError.test.js.map +1 -0
- package/dist/src/gui/service/__tests__/wait.test.d.ts +1 -0
- package/dist/src/gui/service/__tests__/wait.test.js +84 -0
- package/dist/src/gui/service/__tests__/wait.test.js.map +1 -0
- package/dist/src/hooks/hookAggregator.d.ts +69 -0
- package/dist/src/hooks/hookAggregator.js +263 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +7 -0
- package/dist/src/hooks/hookAggregator.test.js +388 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.d.ts +110 -0
- package/dist/src/hooks/hookEventHandler.js +551 -0
- package/dist/src/hooks/hookEventHandler.js.map +1 -0
- package/dist/src/hooks/hookEventHandler.test.d.ts +7 -0
- package/dist/src/hooks/hookEventHandler.test.js +432 -0
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +47 -0
- package/dist/src/hooks/hookPlanner.js +111 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +7 -0
- package/dist/src/hooks/hookPlanner.test.js +317 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +81 -0
- package/dist/src/hooks/hookRegistry.js +186 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +7 -0
- package/dist/src/hooks/hookRegistry.test.js +410 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +43 -0
- package/dist/src/hooks/hookRunner.js +295 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +7 -0
- package/dist/src/hooks/hookRunner.test.js +518 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookSystem.d.ts +41 -0
- package/dist/src/hooks/hookSystem.js +66 -0
- package/dist/src/hooks/hookSystem.js.map +1 -0
- package/dist/src/hooks/hookSystem.test.d.ts +7 -0
- package/dist/src/hooks/hookSystem.test.js +320 -0
- package/dist/src/hooks/hookSystem.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +114 -0
- package/dist/src/hooks/hookTranslator.js +233 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +7 -0
- package/dist/src/hooks/hookTranslator.test.js +193 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/index.d.ts +18 -0
- package/dist/src/hooks/index.js +19 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/hooks/types.d.ts +386 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +7 -0
- package/dist/src/hooks/types.test.js +314 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- package/dist/src/ide/constants.d.ts +10 -0
- package/dist/src/ide/constants.js +11 -0
- package/dist/src/ide/constants.js.map +1 -0
- package/dist/src/ide/detect-ide.d.ts +61 -0
- package/dist/src/ide/detect-ide.js +73 -0
- package/dist/src/ide/detect-ide.js.map +1 -0
- package/dist/src/ide/detect-ide.test.d.ts +7 -0
- package/dist/src/ide/detect-ide.test.js +140 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +113 -0
- package/dist/src/ide/ide-client.js +650 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ide-client.test.d.ts +7 -0
- package/dist/src/ide/ide-client.test.js +565 -0
- package/dist/src/ide/ide-client.test.js.map +1 -0
- package/dist/src/ide/ide-installer.d.ts +15 -0
- package/dist/src/ide/ide-installer.js +157 -0
- package/dist/src/ide/ide-installer.js.map +1 -0
- package/dist/src/ide/ide-installer.test.d.ts +7 -0
- package/dist/src/ide/ide-installer.test.js +185 -0
- package/dist/src/ide/ide-installer.test.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +45 -0
- package/dist/src/ide/ideContext.js +102 -0
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/ide/ideContext.test.d.ts +7 -0
- package/dist/src/ide/ideContext.test.js +394 -0
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/ide/process-utils.d.ts +22 -0
- package/dist/src/ide/process-utils.js +182 -0
- package/dist/src/ide/process-utils.js.map +1 -0
- package/dist/src/ide/process-utils.test.d.ts +7 -0
- package/dist/src/ide/process-utils.test.js +152 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +487 -0
- package/dist/src/ide/types.js +139 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +154 -0
- package/dist/src/index.js +172 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.test.d.ts +7 -0
- package/dist/src/index.test.js +13 -0
- package/dist/src/index.test.js.map +1 -0
- package/dist/src/mcp/auth-provider.d.ts +17 -0
- package/dist/src/mcp/auth-provider.js +8 -0
- package/dist/src/mcp/auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.d.ts +34 -0
- package/dist/src/mcp/google-auth-provider.js +119 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.test.d.ts +7 -0
- package/dist/src/mcp/google-auth-provider.test.js +168 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +154 -0
- package/dist/src/mcp/oauth-provider.js +703 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-provider.test.d.ts +7 -0
- package/dist/src/mcp/oauth-provider.test.js +1218 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.d.ts +66 -0
- package/dist/src/mcp/oauth-token-storage.js +182 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -0
- package/dist/src/mcp/oauth-token-storage.test.d.ts +7 -0
- package/dist/src/mcp/oauth-token-storage.test.js +306 -0
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -0
- package/dist/src/mcp/oauth-utils.d.ts +134 -0
- package/dist/src/mcp/oauth-utils.js +286 -0
- package/dist/src/mcp/oauth-utils.js.map +1 -0
- package/dist/src/mcp/oauth-utils.test.d.ts +7 -0
- package/dist/src/mcp/oauth-utils.test.js +285 -0
- package/dist/src/mcp/oauth-utils.test.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.d.ts +28 -0
- package/dist/src/mcp/sa-impersonation-provider.js +114 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +7 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +118 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +20 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +37 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +7 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +152 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +25 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +146 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +7 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +239 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +79 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +7 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +194 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +12 -0
- package/dist/src/mcp/token-storage/index.js +13 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +36 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +247 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +7 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +306 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +45 -0
- package/dist/src/mcp/token-storage/types.js +12 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/mocks/msw.d.ts +7 -0
- package/dist/src/mocks/msw.js +9 -0
- package/dist/src/mocks/msw.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +12 -0
- package/dist/src/output/json-formatter.js +34 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +7 -0
- package/dist/src/output/json-formatter.test.js +295 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/stream-json-formatter.d.ts +33 -0
- package/dist/src/output/stream-json-formatter.js +59 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +7 -0
- package/dist/src/output/stream-json-formatter.test.js +478 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +86 -0
- package/dist/src/output/types.js +23 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/config.d.ts +34 -0
- package/dist/src/policy/config.js +334 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +7 -0
- package/dist/src/policy/config.test.js +540 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +10 -0
- package/dist/src/policy/index.js +11 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/persistence.test.d.ts +7 -0
- package/dist/src/policy/persistence.test.js +150 -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/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +96 -0
- package/dist/src/policy/policies/write.toml +110 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +56 -0
- package/dist/src/policy/policy-engine.js +302 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +7 -0
- package/dist/src/policy/policy-engine.test.js +1122 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/recipes/dns-debug.toml +28 -0
- package/dist/src/policy/recipes/docker-prune.toml +28 -0
- package/dist/src/policy/recipes/wifi-fix.toml +31 -0
- package/dist/src/policy/shell-safety.test.d.ts +7 -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/stable-stringify.d.ts +59 -0
- package/dist/src/policy/stable-stringify.js +123 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +56 -0
- package/dist/src/policy/toml-loader.js +412 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +7 -0
- package/dist/src/policy/toml-loader.test.js +377 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +181 -0
- package/dist/src/policy/types.js +44 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +9 -0
- package/dist/src/prompts/mcp-prompts.js +14 -0
- package/dist/src/prompts/mcp-prompts.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.test.d.ts +7 -0
- package/dist/src/prompts/mcp-prompts.test.js +40 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +35 -0
- package/dist/src/prompts/prompt-registry.js +65 -0
- package/dist/src/prompts/prompt-registry.js.map +1 -0
- package/dist/src/prompts/prompt-registry.test.d.ts +7 -0
- package/dist/src/prompts/prompt-registry.test.js +97 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/recipes/builtins/index.d.ts +8 -0
- package/dist/src/recipes/builtins/index.js +115 -0
- package/dist/src/recipes/builtins/index.js.map +1 -0
- package/dist/src/recipes/executor.d.ts +23 -0
- package/dist/src/recipes/executor.js +86 -0
- package/dist/src/recipes/executor.js.map +1 -0
- package/dist/src/recipes/executor.test.d.ts +7 -0
- package/dist/src/recipes/executor.test.js +86 -0
- package/dist/src/recipes/executor.test.js.map +1 -0
- package/dist/src/recipes/index.d.ts +10 -0
- package/dist/src/recipes/index.js +11 -0
- package/dist/src/recipes/index.js.map +1 -0
- package/dist/src/recipes/loader.d.ts +27 -0
- package/dist/src/recipes/loader.js +187 -0
- package/dist/src/recipes/loader.js.map +1 -0
- package/dist/src/recipes/loader.test.d.ts +7 -0
- package/dist/src/recipes/loader.test.js +84 -0
- package/dist/src/recipes/loader.test.js.map +1 -0
- package/dist/src/recipes/schema.d.ts +43 -0
- package/dist/src/recipes/schema.js +8 -0
- package/dist/src/recipes/schema.js.map +1 -0
- package/dist/src/resources/resource-registry.d.ts +31 -0
- package/dist/src/resources/resource-registry.js +58 -0
- package/dist/src/resources/resource-registry.js.map +1 -0
- package/dist/src/resources/resource-registry.test.d.ts +7 -0
- package/dist/src/resources/resource-registry.test.js +55 -0
- package/dist/src/resources/resource-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +24 -0
- package/dist/src/routing/modelRouterService.js +71 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +7 -0
- package/dist/src/routing/modelRouterService.test.js +99 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +63 -0
- package/dist/src/routing/routingStrategy.js +8 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/classifierStrategy.js +156 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +7 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +198 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +27 -0
- package/dist/src/routing/strategies/compositeStrategy.js +69 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +7 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +124 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/defaultStrategy.js +21 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +7 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +27 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +34 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +7 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +84 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +16 -0
- package/dist/src/routing/strategies/overrideStrategy.js +30 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +7 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +46 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/safety/approval-ladder/__tests__/buildShellActionProfile.test.d.ts +7 -0
- package/dist/src/safety/approval-ladder/__tests__/buildShellActionProfile.test.js +203 -0
- package/dist/src/safety/approval-ladder/__tests__/buildShellActionProfile.test.js.map +1 -0
- package/dist/src/safety/approval-ladder/__tests__/buildToolActionProfile.test.d.ts +7 -0
- package/dist/src/safety/approval-ladder/__tests__/buildToolActionProfile.test.js +81 -0
- package/dist/src/safety/approval-ladder/__tests__/buildToolActionProfile.test.js.map +1 -0
- package/dist/src/safety/approval-ladder/__tests__/computeMinimumReviewLevel.test.d.ts +7 -0
- package/dist/src/safety/approval-ladder/__tests__/computeMinimumReviewLevel.test.js +252 -0
- package/dist/src/safety/approval-ladder/__tests__/computeMinimumReviewLevel.test.js.map +1 -0
- package/dist/src/safety/approval-ladder/buildShellActionProfile.d.ts +19 -0
- package/dist/src/safety/approval-ladder/buildShellActionProfile.js +285 -0
- package/dist/src/safety/approval-ladder/buildShellActionProfile.js.map +1 -0
- package/dist/src/safety/approval-ladder/buildToolActionProfile.d.ts +16 -0
- package/dist/src/safety/approval-ladder/buildToolActionProfile.js +255 -0
- package/dist/src/safety/approval-ladder/buildToolActionProfile.js.map +1 -0
- package/dist/src/safety/approval-ladder/classifyDomain.d.ts +9 -0
- package/dist/src/safety/approval-ladder/classifyDomain.js +81 -0
- package/dist/src/safety/approval-ladder/classifyDomain.js.map +1 -0
- package/dist/src/safety/approval-ladder/classifyIntention.d.ts +16 -0
- package/dist/src/safety/approval-ladder/classifyIntention.js +64 -0
- package/dist/src/safety/approval-ladder/classifyIntention.js.map +1 -0
- package/dist/src/safety/approval-ladder/classifyOutcome.d.ts +9 -0
- package/dist/src/safety/approval-ladder/classifyOutcome.js +62 -0
- package/dist/src/safety/approval-ladder/classifyOutcome.js.map +1 -0
- package/dist/src/safety/approval-ladder/computeBalancedRisk.d.ts +8 -0
- package/dist/src/safety/approval-ladder/computeBalancedRisk.js +49 -0
- package/dist/src/safety/approval-ladder/computeBalancedRisk.js.map +1 -0
- package/dist/src/safety/approval-ladder/computeMinimalRisk.d.ts +8 -0
- package/dist/src/safety/approval-ladder/computeMinimalRisk.js +23 -0
- package/dist/src/safety/approval-ladder/computeMinimalRisk.js.map +1 -0
- package/dist/src/safety/approval-ladder/computeMinimumReviewLevel.d.ts +17 -0
- package/dist/src/safety/approval-ladder/computeMinimumReviewLevel.js +124 -0
- package/dist/src/safety/approval-ladder/computeMinimumReviewLevel.js.map +1 -0
- package/dist/src/safety/approval-ladder/computeRisk.d.ts +8 -0
- package/dist/src/safety/approval-ladder/computeRisk.js +29 -0
- package/dist/src/safety/approval-ladder/computeRisk.js.map +1 -0
- package/dist/src/safety/approval-ladder/computeStrictRisk.d.ts +8 -0
- package/dist/src/safety/approval-ladder/computeStrictRisk.js +32 -0
- package/dist/src/safety/approval-ladder/computeStrictRisk.js.map +1 -0
- package/dist/src/safety/approval-ladder/safetyInvariants.d.ts +29 -0
- package/dist/src/safety/approval-ladder/safetyInvariants.js +77 -0
- package/dist/src/safety/approval-ladder/safetyInvariants.js.map +1 -0
- package/dist/src/safety/approval-ladder/types.d.ts +81 -0
- package/dist/src/safety/approval-ladder/types.js +8 -0
- package/dist/src/safety/approval-ladder/types.js.map +1 -0
- package/dist/src/safety/built-in.d.ts +30 -0
- package/dist/src/safety/built-in.js +124 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +7 -0
- package/dist/src/safety/built-in.test.js +200 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +49 -0
- package/dist/src/safety/checker-runner.js +220 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +7 -0
- package/dist/src/safety/checker-runner.test.js +239 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +24 -0
- package/dist/src/safety/context-builder.js +48 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +7 -0
- package/dist/src/safety/context-builder.test.js +50 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +89 -0
- package/dist/src/safety/protocol.js +16 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +27 -0
- package/dist/src/safety/registry.js +66 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +7 -0
- package/dist/src/safety/registry.test.js +32 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/safety/risk-classifier.d.ts +8 -0
- package/dist/src/safety/risk-classifier.js +36 -0
- package/dist/src/safety/risk-classifier.js.map +1 -0
- package/dist/src/safety/risk-classifier.test.d.ts +7 -0
- package/dist/src/safety/risk-classifier.test.js +28 -0
- package/dist/src/safety/risk-classifier.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +34 -0
- package/dist/src/services/chatCompressionService.js +195 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +7 -0
- package/dist/src/services/chatCompressionService.test.js +215 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +160 -0
- package/dist/src/services/chatRecordingService.js +370 -0
- package/dist/src/services/chatRecordingService.js.map +1 -0
- package/dist/src/services/chatRecordingService.test.d.ts +7 -0
- package/dist/src/services/chatRecordingService.test.js +333 -0
- package/dist/src/services/chatRecordingService.test.js.map +1 -0
- package/dist/src/services/contextManager.d.ts +30 -0
- package/dist/src/services/contextManager.js +72 -0
- package/dist/src/services/contextManager.js.map +1 -0
- package/dist/src/services/contextManager.test.d.ts +7 -0
- package/dist/src/services/contextManager.test.js +105 -0
- package/dist/src/services/contextManager.test.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.d.ts +34 -0
- package/dist/src/services/fileDiscoveryService.js +70 -0
- package/dist/src/services/fileDiscoveryService.js.map +1 -0
- package/dist/src/services/fileDiscoveryService.test.d.ts +7 -0
- package/dist/src/services/fileDiscoveryService.test.js +224 -0
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
- package/dist/src/services/fileSystemService.d.ts +32 -0
- package/dist/src/services/fileSystemService.js +19 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/fileSystemService.test.d.ts +7 -0
- package/dist/src/services/fileSystemService.test.js +42 -0
- package/dist/src/services/fileSystemService.test.js.map +1 -0
- package/dist/src/services/gitService.d.ts +24 -0
- package/dist/src/services/gitService.js +115 -0
- package/dist/src/services/gitService.js.map +1 -0
- package/dist/src/services/gitService.test.d.ts +7 -0
- package/dist/src/services/gitService.test.js +241 -0
- package/dist/src/services/gitService.test.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +107 -0
- package/dist/src/services/loopDetectionService.js +434 -0
- package/dist/src/services/loopDetectionService.js.map +1 -0
- package/dist/src/services/loopDetectionService.test.d.ts +7 -0
- package/dist/src/services/loopDetectionService.test.js +802 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -0
- package/dist/src/services/modelConfig.golden.test.d.ts +7 -0
- package/dist/src/services/modelConfig.golden.test.js +75 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +7 -0
- package/dist/src/services/modelConfig.integration.test.js +248 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +53 -0
- package/dist/src/services/modelConfigService.js +157 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +7 -0
- package/dist/src/services/modelConfigService.test.js +753 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/modelConfigServiceTestUtils.d.ts +11 -0
- package/dist/src/services/modelConfigServiceTestUtils.js +18 -0
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryService.d.ts +29 -0
- package/dist/src/services/sessionSummaryService.js +132 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -0
- package/dist/src/services/sessionSummaryService.test.d.ts +7 -0
- package/dist/src/services/sessionSummaryService.test.js +786 -0
- package/dist/src/services/sessionSummaryService.test.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.d.ts +17 -0
- package/dist/src/services/sessionSummaryUtils.js +130 -0
- package/dist/src/services/sessionSummaryUtils.js.map +1 -0
- package/dist/src/services/sessionSummaryUtils.test.d.ts +7 -0
- package/dist/src/services/sessionSummaryUtils.test.js +138 -0
- package/dist/src/services/sessionSummaryUtils.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +122 -0
- package/dist/src/services/shellExecutionService.js +759 -0
- package/dist/src/services/shellExecutionService.js.map +1 -0
- package/dist/src/services/shellExecutionService.test.d.ts +7 -0
- package/dist/src/services/shellExecutionService.test.js +1040 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -0
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +238 -0
- package/dist/src/services/test-data/resolved-aliases.golden.json +238 -0
- package/dist/src/telemetry/activity-detector.d.ts +42 -0
- package/dist/src/telemetry/activity-detector.js +62 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +7 -0
- package/dist/src/telemetry/activity-detector.test.js +137 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.d.ts +117 -0
- package/dist/src/telemetry/activity-monitor.js +210 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +7 -0
- package/dist/src/telemetry/activity-monitor.test.js +252 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +20 -0
- package/dist/src/telemetry/activity-types.js +22 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +159 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +1210 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +20 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +835 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +140 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +350 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
- package/dist/src/telemetry/config.d.ts +32 -0
- package/dist/src/telemetry/config.js +79 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +7 -0
- package/dist/src/telemetry/config.test.js +150 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +7 -0
- package/dist/src/telemetry/constants.js +8 -0
- package/dist/src/telemetry/constants.js.map +1 -0
- package/dist/src/telemetry/file-exporters.d.ts +30 -0
- package/dist/src/telemetry/file-exporters.js +63 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.d.ts +36 -0
- package/dist/src/telemetry/gcp-exporters.js +121 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +7 -0
- package/dist/src/telemetry/gcp-exporters.test.js +319 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +44 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +89 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +7 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +153 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +34 -0
- package/dist/src/telemetry/index.js +45 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/integration.test.circular.d.ts +7 -0
- package/dist/src/telemetry/integration.test.circular.js +55 -0
- package/dist/src/telemetry/integration.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +45 -0
- package/dist/src/telemetry/loggers.js +499 -0
- package/dist/src/telemetry/loggers.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.d.ts +7 -0
- package/dist/src/telemetry/loggers.test.circular.js +107 -0
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -0
- package/dist/src/telemetry/loggers.test.d.ts +7 -0
- package/dist/src/telemetry/loggers.test.js +1578 -0
- package/dist/src/telemetry/loggers.test.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.d.ts +150 -0
- package/dist/src/telemetry/memory-monitor.js +336 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +7 -0
- package/dist/src/telemetry/memory-monitor.test.js +473 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +534 -0
- package/dist/src/telemetry/metrics.js +842 -0
- package/dist/src/telemetry/metrics.js.map +1 -0
- package/dist/src/telemetry/metrics.test.d.ts +7 -0
- package/dist/src/telemetry/metrics.test.js +1170 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.d.ts +49 -0
- package/dist/src/telemetry/rate-limiter.js +101 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +7 -0
- package/dist/src/telemetry/rate-limiter.test.js +208 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sanitize.d.ts +26 -0
- package/dist/src/telemetry/sanitize.js +49 -0
- package/dist/src/telemetry/sanitize.js.map +1 -0
- package/dist/src/telemetry/sanitize.test.d.ts +7 -0
- package/dist/src/telemetry/sanitize.test.js +280 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +17 -0
- package/dist/src/telemetry/sdk.js +309 -0
- package/dist/src/telemetry/sdk.js.map +1 -0
- package/dist/src/telemetry/sdk.test.d.ts +7 -0
- package/dist/src/telemetry/sdk.test.js +293 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -0
- package/dist/src/telemetry/semantic.d.ts +83 -0
- package/dist/src/telemetry/semantic.js +270 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +7 -0
- package/dist/src/telemetry/semantic.test.js +388 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.d.ts +52 -0
- package/dist/src/telemetry/startupProfiler.js +171 -0
- package/dist/src/telemetry/startupProfiler.js.map +1 -0
- package/dist/src/telemetry/startupProfiler.test.d.ts +7 -0
- package/dist/src/telemetry/startupProfiler.test.js +276 -0
- package/dist/src/telemetry/startupProfiler.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +7 -0
- package/dist/src/telemetry/telemetry-utils.js +15 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +7 -0
- package/dist/src/telemetry/telemetry-utils.test.js +42 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetry.test.d.ts +7 -0
- package/dist/src/telemetry/telemetry.test.js +58 -0
- package/dist/src/telemetry/telemetry.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.d.ts +9 -0
- package/dist/src/telemetry/telemetryAttributes.js +20 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/tool-call-decision.d.ts +14 -0
- package/dist/src/telemetry/tool-call-decision.js +30 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +47 -0
- package/dist/src/telemetry/trace.js +122 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +545 -0
- package/dist/src/telemetry/types.js +1435 -0
- package/dist/src/telemetry/types.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.d.ts +77 -0
- package/dist/src/telemetry/uiTelemetry.js +155 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -0
- package/dist/src/telemetry/uiTelemetry.test.d.ts +7 -0
- package/dist/src/telemetry/uiTelemetry.test.js +585 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
- package/dist/src/test-utils/config.d.ts +18 -0
- package/dist/src/test-utils/config.js +33 -0
- package/dist/src/test-utils/config.js.map +1 -0
- package/dist/src/test-utils/index.d.ts +7 -0
- package/dist/src/test-utils/index.js +8 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-message-bus.d.ts +61 -0
- package/dist/src/test-utils/mock-message-bus.js +132 -0
- package/dist/src/test-utils/mock-message-bus.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +67 -0
- package/dist/src/test-utils/mock-tool.js +122 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +14 -0
- package/dist/src/test-utils/mockWorkspaceContext.js +25 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -0
- package/dist/src/tools/__tests__/shell.pin.test.d.ts +7 -0
- package/dist/src/tools/__tests__/shell.pin.test.js +177 -0
- package/dist/src/tools/__tests__/shell.pin.test.js.map +1 -0
- package/dist/src/tools/__tests__/shell.provenance.test.d.ts +7 -0
- package/dist/src/tools/__tests__/shell.provenance.test.js +36 -0
- package/dist/src/tools/__tests__/shell.provenance.test.js.map +1 -0
- package/dist/src/tools/__tests__/ui-diagnose.test.d.ts +1 -0
- package/dist/src/tools/__tests__/ui-diagnose.test.js +68 -0
- package/dist/src/tools/__tests__/ui-diagnose.test.js.map +1 -0
- package/dist/src/tools/__tests__/ui-health.test.d.ts +1 -0
- package/dist/src/tools/__tests__/ui-health.test.js +108 -0
- package/dist/src/tools/__tests__/ui-health.test.js.map +1 -0
- package/dist/src/tools/__tests__/ui-tool-utils.test.d.ts +7 -0
- package/dist/src/tools/__tests__/ui-tool-utils.test.js +45 -0
- package/dist/src/tools/__tests__/ui-tool-utils.test.js.map +1 -0
- package/dist/src/tools/agent-control.d.ts +33 -0
- package/dist/src/tools/agent-control.js +238 -0
- package/dist/src/tools/agent-control.js.map +1 -0
- package/dist/src/tools/agent-control.test.d.ts +7 -0
- package/dist/src/tools/agent-control.test.js +126 -0
- package/dist/src/tools/agent-control.test.js.map +1 -0
- package/dist/src/tools/base-tool-invocation.test.d.ts +7 -0
- package/dist/src/tools/base-tool-invocation.test.js +86 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.d.ts +7 -0
- package/dist/src/tools/confirmation-policy.test.js +160 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +10 -0
- package/dist/src/tools/diffOptions.js +47 -0
- package/dist/src/tools/diffOptions.js.map +1 -0
- package/dist/src/tools/diffOptions.test.d.ts +7 -0
- package/dist/src/tools/diffOptions.test.js +156 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -0
- package/dist/src/tools/edit.d.ts +58 -0
- package/dist/src/tools/edit.js +445 -0
- package/dist/src/tools/edit.js.map +1 -0
- package/dist/src/tools/edit.test.d.ts +7 -0
- package/dist/src/tools/edit.test.js +960 -0
- package/dist/src/tools/edit.test.js.map +1 -0
- package/dist/src/tools/file-ops.d.ts +29 -0
- package/dist/src/tools/file-ops.js +440 -0
- package/dist/src/tools/file-ops.js.map +1 -0
- package/dist/src/tools/file-ops.test.d.ts +7 -0
- package/dist/src/tools/file-ops.test.js +150 -0
- package/dist/src/tools/file-ops.test.js.map +1 -0
- package/dist/src/tools/get-internal-docs.d.ts +28 -0
- package/dist/src/tools/get-internal-docs.js +130 -0
- package/dist/src/tools/get-internal-docs.js.map +1 -0
- package/dist/src/tools/get-internal-docs.test.d.ts +7 -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 +58 -0
- package/dist/src/tools/glob.js +242 -0
- package/dist/src/tools/glob.js.map +1 -0
- package/dist/src/tools/glob.test.d.ts +7 -0
- package/dist/src/tools/glob.test.js +434 -0
- package/dist/src/tools/glob.test.js.map +1 -0
- package/dist/src/tools/grep.d.ts +49 -0
- package/dist/src/tools/grep.js +524 -0
- package/dist/src/tools/grep.js.map +1 -0
- package/dist/src/tools/grep.test.d.ts +7 -0
- package/dist/src/tools/grep.test.js +299 -0
- package/dist/src/tools/grep.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +70 -0
- package/dist/src/tools/ls.js +209 -0
- package/dist/src/tools/ls.js.map +1 -0
- package/dist/src/tools/ls.test.d.ts +7 -0
- package/dist/src/tools/ls.test.js +242 -0
- package/dist/src/tools/ls.test.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.d.ts +81 -0
- package/dist/src/tools/mcp-client-manager.js +270 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client-manager.test.d.ts +7 -0
- package/dist/src/tools/mcp-client-manager.test.js +194 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +234 -0
- package/dist/src/tools/mcp-client.js +1276 -0
- package/dist/src/tools/mcp-client.js.map +1 -0
- package/dist/src/tools/mcp-client.test.d.ts +7 -0
- package/dist/src/tools/mcp-client.test.js +1285 -0
- package/dist/src/tools/mcp-client.test.js.map +1 -0
- package/dist/src/tools/mcp-tool.d.ts +29 -0
- package/dist/src/tools/mcp-tool.js +293 -0
- package/dist/src/tools/mcp-tool.js.map +1 -0
- package/dist/src/tools/mcp-tool.test.d.ts +7 -0
- package/dist/src/tools/mcp-tool.test.js +653 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -0
- package/dist/src/tools/memoryTool.d.ts +43 -0
- package/dist/src/tools/memoryTool.js +272 -0
- package/dist/src/tools/memoryTool.js.map +1 -0
- package/dist/src/tools/memoryTool.test.d.ts +7 -0
- package/dist/src/tools/memoryTool.test.js +300 -0
- package/dist/src/tools/memoryTool.test.js.map +1 -0
- package/dist/src/tools/message-bus-integration.test.d.ts +7 -0
- package/dist/src/tools/message-bus-integration.test.js +197 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +37 -0
- package/dist/src/tools/modifiable-tool.js +111 -0
- package/dist/src/tools/modifiable-tool.js.map +1 -0
- package/dist/src/tools/modifiable-tool.test.d.ts +7 -0
- package/dist/src/tools/modifiable-tool.test.js +238 -0
- package/dist/src/tools/modifiable-tool.test.js.map +1 -0
- package/dist/src/tools/process-manager.d.ts +117 -0
- package/dist/src/tools/process-manager.js +659 -0
- package/dist/src/tools/process-manager.js.map +1 -0
- package/dist/src/tools/process-manager.test.d.ts +7 -0
- package/dist/src/tools/process-manager.test.js +161 -0
- package/dist/src/tools/process-manager.test.js.map +1 -0
- package/dist/src/tools/process-notifications.d.ts +19 -0
- package/dist/src/tools/process-notifications.js +14 -0
- package/dist/src/tools/process-notifications.js.map +1 -0
- package/dist/src/tools/read-file.d.ts +37 -0
- package/dist/src/tools/read-file.js +134 -0
- package/dist/src/tools/read-file.js.map +1 -0
- package/dist/src/tools/read-file.test.d.ts +7 -0
- package/dist/src/tools/read-file.test.js +376 -0
- package/dist/src/tools/read-file.test.js.map +1 -0
- package/dist/src/tools/read-many-files.d.ts +55 -0
- package/dist/src/tools/read-many-files.js +356 -0
- package/dist/src/tools/read-many-files.js.map +1 -0
- package/dist/src/tools/read-many-files.test.d.ts +7 -0
- package/dist/src/tools/read-many-files.test.js +567 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -0
- package/dist/src/tools/repl.d.ts +21 -0
- package/dist/src/tools/repl.js +386 -0
- package/dist/src/tools/repl.js.map +1 -0
- package/dist/src/tools/repl.test.d.ts +7 -0
- package/dist/src/tools/repl.test.js +287 -0
- package/dist/src/tools/repl.test.js.map +1 -0
- package/dist/src/tools/ripGrep.d.ts +74 -0
- package/dist/src/tools/ripGrep.js +396 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +7 -0
- package/dist/src/tools/ripGrep.test.js +1306 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +44 -0
- package/dist/src/tools/shell.js +649 -0
- package/dist/src/tools/shell.js.map +1 -0
- package/dist/src/tools/shell.test.d.ts +7 -0
- package/dist/src/tools/shell.test.js +431 -0
- package/dist/src/tools/shell.test.js.map +1 -0
- package/dist/src/tools/smart-edit.d.ts +79 -0
- package/dist/src/tools/smart-edit.js +739 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +7 -0
- package/dist/src/tools/smart-edit.test.js +597 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +66 -0
- package/dist/src/tools/tool-error.js +87 -0
- package/dist/src/tools/tool-error.js.map +1 -0
- package/dist/src/tools/tool-names.d.ts +48 -0
- package/dist/src/tools/tool-names.js +108 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-names.test.d.ts +7 -0
- package/dist/src/tools/tool-names.test.js +44 -0
- package/dist/src/tools/tool-names.test.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +99 -0
- package/dist/src/tools/tool-registry.js +415 -0
- package/dist/src/tools/tool-registry.js.map +1 -0
- package/dist/src/tools/tool-registry.test.d.ts +7 -0
- package/dist/src/tools/tool-registry.test.js +411 -0
- package/dist/src/tools/tool-registry.test.js.map +1 -0
- package/dist/src/tools/tools.d.ts +361 -0
- package/dist/src/tools/tools.js +409 -0
- package/dist/src/tools/tools.js.map +1 -0
- package/dist/src/tools/tools.test.d.ts +7 -0
- package/dist/src/tools/tools.test.js +206 -0
- package/dist/src/tools/tools.test.js.map +1 -0
- package/dist/src/tools/ui-assert.d.ts +16 -0
- package/dist/src/tools/ui-assert.js +51 -0
- package/dist/src/tools/ui-assert.js.map +1 -0
- package/dist/src/tools/ui-capabilities.d.ts +17 -0
- package/dist/src/tools/ui-capabilities.js +43 -0
- package/dist/src/tools/ui-capabilities.js.map +1 -0
- package/dist/src/tools/ui-click-xy.d.ts +16 -0
- package/dist/src/tools/ui-click-xy.js +65 -0
- package/dist/src/tools/ui-click-xy.js.map +1 -0
- package/dist/src/tools/ui-click.d.ts +16 -0
- package/dist/src/tools/ui-click.js +67 -0
- package/dist/src/tools/ui-click.js.map +1 -0
- package/dist/src/tools/ui-describe.d.ts +16 -0
- package/dist/src/tools/ui-describe.js +129 -0
- package/dist/src/tools/ui-describe.js.map +1 -0
- package/dist/src/tools/ui-diagnose.d.ts +16 -0
- package/dist/src/tools/ui-diagnose.js +87 -0
- package/dist/src/tools/ui-diagnose.js.map +1 -0
- package/dist/src/tools/ui-focus.d.ts +16 -0
- package/dist/src/tools/ui-focus.js +61 -0
- package/dist/src/tools/ui-focus.js.map +1 -0
- package/dist/src/tools/ui-health.d.ts +17 -0
- package/dist/src/tools/ui-health.js +84 -0
- package/dist/src/tools/ui-health.js.map +1 -0
- package/dist/src/tools/ui-key.d.ts +16 -0
- package/dist/src/tools/ui-key.js +65 -0
- package/dist/src/tools/ui-key.js.map +1 -0
- package/dist/src/tools/ui-query.d.ts +16 -0
- package/dist/src/tools/ui-query.js +48 -0
- package/dist/src/tools/ui-query.js.map +1 -0
- package/dist/src/tools/ui-scroll.d.ts +16 -0
- package/dist/src/tools/ui-scroll.js +62 -0
- package/dist/src/tools/ui-scroll.js.map +1 -0
- package/dist/src/tools/ui-snapshot.d.ts +16 -0
- package/dist/src/tools/ui-snapshot.js +69 -0
- package/dist/src/tools/ui-snapshot.js.map +1 -0
- package/dist/src/tools/ui-tool-base.d.ts +22 -0
- package/dist/src/tools/ui-tool-base.js +27 -0
- package/dist/src/tools/ui-tool-base.js.map +1 -0
- package/dist/src/tools/ui-tool-utils.d.ts +21 -0
- package/dist/src/tools/ui-tool-utils.js +126 -0
- package/dist/src/tools/ui-tool-utils.js.map +1 -0
- package/dist/src/tools/ui-type.d.ts +16 -0
- package/dist/src/tools/ui-type.js +67 -0
- package/dist/src/tools/ui-type.js.map +1 -0
- package/dist/src/tools/ui-wait.d.ts +16 -0
- package/dist/src/tools/ui-wait.js +51 -0
- package/dist/src/tools/ui-wait.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +36 -0
- package/dist/src/tools/web-fetch.js +316 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/tools/web-fetch.test.d.ts +7 -0
- package/dist/src/tools/web-fetch.test.js +477 -0
- package/dist/src/tools/web-fetch.test.js.map +1 -0
- package/dist/src/tools/web-search.d.ts +51 -0
- package/dist/src/tools/web-search.js +142 -0
- package/dist/src/tools/web-search.js.map +1 -0
- package/dist/src/tools/web-search.test.d.ts +7 -0
- package/dist/src/tools/web-search.test.js +242 -0
- package/dist/src/tools/web-search.test.js.map +1 -0
- package/dist/src/tools/write-file.d.ts +54 -0
- package/dist/src/tools/write-file.js +332 -0
- package/dist/src/tools/write-file.js.map +1 -0
- package/dist/src/tools/write-file.test.d.ts +7 -0
- package/dist/src/tools/write-file.test.js +623 -0
- package/dist/src/tools/write-file.test.js.map +1 -0
- package/dist/src/tools/write-todos.d.ts +51 -0
- package/dist/src/tools/write-todos.js +194 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +7 -0
- package/dist/src/tools/write-todos.test.js +90 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/LruCache.d.ts +14 -0
- package/dist/src/utils/LruCache.js +39 -0
- package/dist/src/utils/LruCache.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +33 -0
- package/dist/src/utils/bfsFileSearch.js +137 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.test.d.ts +7 -0
- package/dist/src/utils/bfsFileSearch.test.js +228 -0
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
- package/dist/src/utils/browser.d.ts +14 -0
- package/dist/src/utils/browser.js +51 -0
- package/dist/src/utils/browser.js.map +1 -0
- package/dist/src/utils/channel.d.ts +20 -0
- package/dist/src/utils/channel.js +50 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +7 -0
- package/dist/src/utils/channel.test.js +171 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/checkpointUtils.d.ts +83 -0
- package/dist/src/utils/checkpointUtils.js +118 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -0
- package/dist/src/utils/checkpointUtils.test.d.ts +7 -0
- package/dist/src/utils/checkpointUtils.test.js +230 -0
- package/dist/src/utils/checkpointUtils.test.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.d.ts +10 -0
- package/dist/src/utils/customHeaderUtils.js +35 -0
- package/dist/src/utils/customHeaderUtils.js.map +1 -0
- package/dist/src/utils/customHeaderUtils.test.d.ts +7 -0
- package/dist/src/utils/customHeaderUtils.test.js +78 -0
- package/dist/src/utils/customHeaderUtils.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +29 -0
- package/dist/src/utils/debugLogger.js +61 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +7 -0
- package/dist/src/utils/debugLogger.test.js +70 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/deepMerge.d.ts +10 -0
- package/dist/src/utils/deepMerge.js +64 -0
- package/dist/src/utils/deepMerge.js.map +1 -0
- package/dist/src/utils/delay.d.ts +17 -0
- package/dist/src/utils/delay.js +44 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +7 -0
- package/dist/src/utils/delay.test.js +89 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +55 -0
- package/dist/src/utils/editCorrector.js +574 -0
- package/dist/src/utils/editCorrector.js.map +1 -0
- package/dist/src/utils/editCorrector.test.d.ts +7 -0
- package/dist/src/utils/editCorrector.test.js +534 -0
- package/dist/src/utils/editCorrector.test.js.map +1 -0
- package/dist/src/utils/editor.d.ts +39 -0
- package/dist/src/utils/editor.js +197 -0
- package/dist/src/utils/editor.js.map +1 -0
- package/dist/src/utils/editor.test.d.ts +7 -0
- package/dist/src/utils/editor.test.js +405 -0
- package/dist/src/utils/editor.test.js.map +1 -0
- package/dist/src/utils/envAliases.d.ts +11 -0
- package/dist/src/utils/envAliases.js +33 -0
- package/dist/src/utils/envAliases.js.map +1 -0
- package/dist/src/utils/envAliases.test.d.ts +7 -0
- package/dist/src/utils/envAliases.test.js +43 -0
- package/dist/src/utils/envAliases.test.js.map +1 -0
- package/dist/src/utils/envVarResolver.d.ts +15 -0
- package/dist/src/utils/envVarResolver.js +68 -0
- package/dist/src/utils/envVarResolver.js.map +1 -0
- package/dist/src/utils/environmentContext.d.ts +24 -0
- package/dist/src/utils/environmentContext.js +116 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/environmentContext.test.d.ts +7 -0
- package/dist/src/utils/environmentContext.test.js +115 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -0
- package/dist/src/utils/errorParsing.d.ts +9 -0
- package/dist/src/utils/errorParsing.js +66 -0
- package/dist/src/utils/errorParsing.js.map +1 -0
- package/dist/src/utils/errorParsing.test.d.ts +7 -0
- package/dist/src/utils/errorParsing.test.js +85 -0
- package/dist/src/utils/errorParsing.test.js.map +1 -0
- package/dist/src/utils/errorReporting.d.ts +15 -0
- package/dist/src/utils/errorReporting.js +89 -0
- package/dist/src/utils/errorReporting.js.map +1 -0
- package/dist/src/utils/errorReporting.test.d.ts +7 -0
- package/dist/src/utils/errorReporting.test.js +131 -0
- package/dist/src/utils/errorReporting.test.js.map +1 -0
- package/dist/src/utils/errors.d.ts +51 -0
- package/dist/src/utils/errors.js +140 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/errors.test.d.ts +7 -0
- package/dist/src/utils/errors.test.js +156 -0
- package/dist/src/utils/errors.test.js.map +1 -0
- package/dist/src/utils/events.d.ts +107 -0
- package/dist/src/utils/events.js +76 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +7 -0
- package/dist/src/utils/events.test.js +213 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/exitCodes.d.ts +13 -0
- package/dist/src/utils/exitCodes.js +14 -0
- package/dist/src/utils/exitCodes.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +87 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +7 -0
- package/dist/src/utils/extensionLoader.test.js +166 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +13 -0
- package/dist/src/utils/fetch.js +56 -0
- package/dist/src/utils/fetch.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +74 -0
- package/dist/src/utils/fileUtils.js +438 -0
- package/dist/src/utils/fileUtils.js.map +1 -0
- package/dist/src/utils/fileUtils.test.d.ts +7 -0
- package/dist/src/utils/fileUtils.test.js +724 -0
- package/dist/src/utils/fileUtils.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.d.ts +26 -0
- package/dist/src/utils/filesearch/crawlCache.js +58 -0
- package/dist/src/utils/filesearch/crawlCache.js.map +1 -0
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +7 -0
- package/dist/src/utils/filesearch/crawlCache.test.js +104 -0
- package/dist/src/utils/filesearch/crawlCache.test.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.d.ts +16 -0
- package/dist/src/utils/filesearch/crawler.js +51 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/crawler.test.d.ts +7 -0
- package/dist/src/utils/filesearch/crawler.test.js +469 -0
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +39 -0
- package/dist/src/utils/filesearch/fileSearch.js +192 -0
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +7 -0
- package/dist/src/utils/filesearch/fileSearch.test.js +643 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.d.ts +43 -0
- package/dist/src/utils/filesearch/ignore.js +107 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -0
- package/dist/src/utils/filesearch/ignore.test.d.ts +7 -0
- package/dist/src/utils/filesearch/ignore.test.js +145 -0
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.d.ts +34 -0
- package/dist/src/utils/filesearch/result-cache.js +60 -0
- package/dist/src/utils/filesearch/result-cache.js.map +1 -0
- package/dist/src/utils/filesearch/result-cache.test.d.ts +7 -0
- package/dist/src/utils/filesearch/result-cache.test.js +47 -0
- package/dist/src/utils/filesearch/result-cache.test.js.map +1 -0
- package/dist/src/utils/flashFallback.test.d.ts +7 -0
- package/dist/src/utils/flashFallback.test.js +104 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +8 -0
- package/dist/src/utils/formatters.js +18 -0
- package/dist/src/utils/formatters.js.map +1 -0
- package/dist/src/utils/formatters.test.d.ts +7 -0
- package/dist/src/utils/formatters.test.js +27 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +19 -0
- package/dist/src/utils/geminiIgnoreParser.js +62 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +7 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +51 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +15 -0
- package/dist/src/utils/generateContentResponseUtilities.js +91 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +7 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js +293 -0
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
- package/dist/src/utils/getFolderStructure.d.ts +32 -0
- package/dist/src/utils/getFolderStructure.js +239 -0
- package/dist/src/utils/getFolderStructure.js.map +1 -0
- package/dist/src/utils/getFolderStructure.test.d.ts +7 -0
- package/dist/src/utils/getFolderStructure.test.js +284 -0
- package/dist/src/utils/getFolderStructure.test.js.map +1 -0
- package/dist/src/utils/getPty.d.ts +20 -0
- package/dist/src/utils/getPty.js +24 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/gitHelpers.d.ts +11 -0
- package/dist/src/utils/gitHelpers.js +33 -0
- package/dist/src/utils/gitHelpers.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.d.ts +20 -0
- package/dist/src/utils/gitIgnoreParser.js +171 -0
- package/dist/src/utils/gitIgnoreParser.js.map +1 -0
- package/dist/src/utils/gitIgnoreParser.test.d.ts +7 -0
- package/dist/src/utils/gitIgnoreParser.test.js +244 -0
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/gitUtils.d.ts +18 -0
- package/dist/src/utils/gitUtils.js +62 -0
- package/dist/src/utils/gitUtils.js.map +1 -0
- package/dist/src/utils/googleErrors.d.ts +105 -0
- package/dist/src/utils/googleErrors.js +166 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +7 -0
- package/dist/src/utils/googleErrors.test.js +310 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +38 -0
- package/dist/src/utils/googleQuotaErrors.js +181 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +7 -0
- package/dist/src/utils/googleQuotaErrors.test.js +404 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +19 -0
- package/dist/src/utils/httpErrors.js +37 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +104 -0
- package/dist/src/utils/ignorePatterns.js +221 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +7 -0
- package/dist/src/utils/ignorePatterns.test.js +247 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +17 -0
- package/dist/src/utils/installationManager.js +52 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +7 -0
- package/dist/src/utils/installationManager.test.js +86 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +7 -0
- package/dist/src/utils/language-detection.js +102 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +27 -0
- package/dist/src/utils/llm-edit-fixer.js +156 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +7 -0
- package/dist/src/utils/llm-edit-fixer.test.js +224 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +41 -0
- package/dist/src/utils/memoryDiscovery.js +423 -0
- package/dist/src/utils/memoryDiscovery.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.test.d.ts +7 -0
- package/dist/src/utils/memoryDiscovery.test.js +534 -0
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.d.ts +43 -0
- package/dist/src/utils/memoryImportProcessor.js +291 -0
- package/dist/src/utils/memoryImportProcessor.js.map +1 -0
- package/dist/src/utils/memoryImportProcessor.test.d.ts +7 -0
- package/dist/src/utils/memoryImportProcessor.test.js +582 -0
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
- package/dist/src/utils/messageInspectors.d.ts +9 -0
- package/dist/src/utils/messageInspectors.js +17 -0
- package/dist/src/utils/messageInspectors.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.d.ts +13 -0
- package/dist/src/utils/nextSpeakerChecker.js +98 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +7 -0
- package/dist/src/utils/nextSpeakerChecker.test.js +192 -0
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
- package/dist/src/utils/package.d.ts +27 -0
- package/dist/src/utils/package.js +29 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +36 -0
- package/dist/src/utils/partUtils.js +134 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/partUtils.test.d.ts +7 -0
- package/dist/src/utils/partUtils.test.js +242 -0
- package/dist/src/utils/partUtils.test.js.map +1 -0
- package/dist/src/utils/pathCorrector.d.ts +26 -0
- package/dist/src/utils/pathCorrector.js +44 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +7 -0
- package/dist/src/utils/pathCorrector.test.js +88 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +18 -0
- package/dist/src/utils/pathReader.js +93 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +7 -0
- package/dist/src/utils/pathReader.test.js +407 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +75 -0
- package/dist/src/utils/paths.js +311 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/paths.test.d.ts +7 -0
- package/dist/src/utils/paths.test.js +358 -0
- package/dist/src/utils/paths.test.js.map +1 -0
- package/dist/src/utils/promptIdContext.d.ts +8 -0
- package/dist/src/utils/promptIdContext.js +9 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/pythonDepsInstaller.d.ts +23 -0
- package/dist/src/utils/pythonDepsInstaller.js +132 -0
- package/dist/src/utils/pythonDepsInstaller.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +17 -0
- package/dist/src/utils/quotaErrorDetection.js +20 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -0
- package/dist/src/utils/retry.d.ts +37 -0
- package/dist/src/utils/retry.js +233 -0
- package/dist/src/utils/retry.js.map +1 -0
- package/dist/src/utils/retry.test.d.ts +7 -0
- package/dist/src/utils/retry.test.js +549 -0
- package/dist/src/utils/retry.test.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.d.ts +14 -0
- package/dist/src/utils/safeJsonStringify.js +50 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -0
- package/dist/src/utils/safeJsonStringify.test.d.ts +7 -0
- package/dist/src/utils/safeJsonStringify.test.js +62 -0
- package/dist/src/utils/safeJsonStringify.test.js.map +1 -0
- package/dist/src/utils/schemaValidator.d.ts +16 -0
- package/dist/src/utils/schemaValidator.js +49 -0
- package/dist/src/utils/schemaValidator.js.map +1 -0
- package/dist/src/utils/schemaValidator.test.d.ts +7 -0
- package/dist/src/utils/schemaValidator.test.js +114 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.d.ts +24 -0
- package/dist/src/utils/secure-browser-launcher.js +166 -0
- package/dist/src/utils/secure-browser-launcher.js.map +1 -0
- package/dist/src/utils/secure-browser-launcher.test.d.ts +7 -0
- package/dist/src/utils/secure-browser-launcher.test.js +150 -0
- package/dist/src/utils/secure-browser-launcher.test.js.map +1 -0
- package/dist/src/utils/session.d.ts +7 -0
- package/dist/src/utils/session.js +9 -0
- package/dist/src/utils/session.js.map +1 -0
- package/dist/src/utils/shell-permissions.d.ts +53 -0
- package/dist/src/utils/shell-permissions.js +189 -0
- package/dist/src/utils/shell-permissions.js.map +1 -0
- package/dist/src/utils/shell-permissions.test.d.ts +7 -0
- package/dist/src/utils/shell-permissions.test.js +345 -0
- package/dist/src/utils/shell-permissions.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +100 -0
- package/dist/src/utils/shell-utils.js +789 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/shell-utils.test.d.ts +7 -0
- package/dist/src/utils/shell-utils.test.js +233 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -0
- package/dist/src/utils/stdio.d.ts +33 -0
- package/dist/src/utils/stdio.js +86 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +7 -0
- package/dist/src/utils/stdio.test.js +48 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +28 -0
- package/dist/src/utils/summarizer.js +51 -0
- package/dist/src/utils/summarizer.js.map +1 -0
- package/dist/src/utils/summarizer.test.d.ts +7 -0
- package/dist/src/utils/summarizer.test.js +152 -0
- package/dist/src/utils/summarizer.test.js.map +1 -0
- package/dist/src/utils/systemEncoding.d.ts +41 -0
- package/dist/src/utils/systemEncoding.js +151 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/systemEncoding.test.d.ts +7 -0
- package/dist/src/utils/systemEncoding.test.js +370 -0
- package/dist/src/utils/systemEncoding.test.js.map +1 -0
- package/dist/src/utils/terminal.d.ts +15 -0
- package/dist/src/utils/terminal.js +39 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +26 -0
- package/dist/src/utils/terminalSerializer.js +433 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +7 -0
- package/dist/src/utils/terminalSerializer.test.js +194 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/testUtils.d.ts +30 -0
- package/dist/src/utils/testUtils.js +71 -0
- package/dist/src/utils/testUtils.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +19 -0
- package/dist/src/utils/textUtils.js +43 -0
- package/dist/src/utils/textUtils.js.map +1 -0
- package/dist/src/utils/textUtils.test.d.ts +7 -0
- package/dist/src/utils/textUtils.test.js +60 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +22 -0
- package/dist/src/utils/thoughtUtils.js +40 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +7 -0
- package/dist/src/utils/thoughtUtils.test.js +79 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tokenCalculation.d.ts +20 -0
- package/dist/src/utils/tokenCalculation.js +71 -0
- package/dist/src/utils/tokenCalculation.js.map +1 -0
- package/dist/src/utils/tokenCalculation.test.d.ts +7 -0
- package/dist/src/utils/tokenCalculation.test.js +79 -0
- package/dist/src/utils/tokenCalculation.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +20 -0
- package/dist/src/utils/tool-utils.js +68 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +7 -0
- package/dist/src/utils/tool-utils.test.js +70 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +21 -0
- package/dist/src/utils/userAccountManager.js +116 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +7 -0
- package/dist/src/utils/userAccountManager.test.js +226 -0
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/version.d.ts +7 -0
- package/dist/src/utils/version.js +16 -0
- package/dist/src/utils/version.js.map +1 -0
- package/dist/src/utils/version.test.d.ts +7 -0
- package/dist/src/utils/version.test.js +40 -0
- package/dist/src/utils/version.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +68 -0
- package/dist/src/utils/workspaceContext.js +172 -0
- package/dist/src/utils/workspaceContext.js.map +1 -0
- package/dist/src/utils/workspaceContext.test.d.ts +7 -0
- package/dist/src/utils/workspaceContext.test.js +320 -0
- package/dist/src/utils/workspaceContext.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +94 -0
|
@@ -0,0 +1,1919 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* Portions Copyright 2025 TerminaI Authors
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect, vi, beforeEach, afterEach, } from 'vitest';
|
|
8
|
+
import { GeminiClient } from './client.js';
|
|
9
|
+
import { AuthType, } from './contentGenerator.js';
|
|
10
|
+
import {} from './geminiChat.js';
|
|
11
|
+
import { CompressionStatus, GeminiEventType, Turn, } from './turn.js';
|
|
12
|
+
import { getCoreSystemPrompt } from './prompts.js';
|
|
13
|
+
import { DEFAULT_GEMINI_MODEL_AUTO } from '../config/models.js';
|
|
14
|
+
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
|
15
|
+
import { setSimulate429 } from '../utils/testUtils.js';
|
|
16
|
+
import { tokenLimit } from './tokenLimits.js';
|
|
17
|
+
import { ideContextStore } from '../ide/ideContext.js';
|
|
18
|
+
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
|
19
|
+
import { ChatCompressionService } from '../services/chatCompressionService.js';
|
|
20
|
+
import { createAvailabilityServiceMock } from '../availability/testUtils.js';
|
|
21
|
+
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
|
|
22
|
+
import { HookSystem } from '../hooks/hookSystem.js';
|
|
23
|
+
import * as policyCatalog from '../availability/policyCatalog.js';
|
|
24
|
+
vi.mock('../services/chatCompressionService.js');
|
|
25
|
+
// Mock fs module to prevent actual file system operations during tests
|
|
26
|
+
const mockFileSystem = new Map();
|
|
27
|
+
vi.mock('node:fs', () => {
|
|
28
|
+
const fsModule = {
|
|
29
|
+
mkdirSync: vi.fn(),
|
|
30
|
+
writeFileSync: vi.fn((path, data) => {
|
|
31
|
+
mockFileSystem.set(path, data);
|
|
32
|
+
}),
|
|
33
|
+
readFileSync: vi.fn((path) => {
|
|
34
|
+
if (mockFileSystem.has(path)) {
|
|
35
|
+
return mockFileSystem.get(path);
|
|
36
|
+
}
|
|
37
|
+
throw Object.assign(new Error('ENOENT: no such file or directory'), {
|
|
38
|
+
code: 'ENOENT',
|
|
39
|
+
});
|
|
40
|
+
}),
|
|
41
|
+
existsSync: vi.fn((path) => mockFileSystem.has(path)),
|
|
42
|
+
createWriteStream: vi.fn(() => ({
|
|
43
|
+
write: vi.fn(),
|
|
44
|
+
on: vi.fn(),
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
default: fsModule,
|
|
49
|
+
...fsModule,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
// --- Mocks ---
|
|
53
|
+
const mockTurnRunFn = vi.fn();
|
|
54
|
+
vi.mock('./turn', async (importOriginal) => {
|
|
55
|
+
const actual = await importOriginal();
|
|
56
|
+
// Define a mock class that has the same shape as the real Turn
|
|
57
|
+
class MockTurn {
|
|
58
|
+
pendingToolCalls = [];
|
|
59
|
+
// The run method is a property that holds our mock function
|
|
60
|
+
run = mockTurnRunFn;
|
|
61
|
+
constructor() {
|
|
62
|
+
// The constructor can be empty or do some mock setup
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Export the mock class as 'Turn'
|
|
66
|
+
return {
|
|
67
|
+
...actual,
|
|
68
|
+
Turn: MockTurn,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
vi.mock('../config/config.js');
|
|
72
|
+
vi.mock('./prompts');
|
|
73
|
+
vi.mock('../utils/getFolderStructure', () => ({
|
|
74
|
+
getFolderStructure: vi.fn().mockResolvedValue('Mock Folder Structure'),
|
|
75
|
+
}));
|
|
76
|
+
vi.mock('../utils/errorReporting', () => ({ reportError: vi.fn() }));
|
|
77
|
+
vi.mock('../utils/nextSpeakerChecker', () => ({
|
|
78
|
+
checkNextSpeaker: vi.fn().mockResolvedValue(null),
|
|
79
|
+
}));
|
|
80
|
+
vi.mock('../utils/generateContentResponseUtilities', () => ({
|
|
81
|
+
getResponseText: (result) => result.candidates?.[0]?.content?.parts?.map((part) => part.text).join('') ||
|
|
82
|
+
undefined,
|
|
83
|
+
}));
|
|
84
|
+
vi.mock('../telemetry/index.js', () => ({
|
|
85
|
+
logApiRequest: vi.fn(),
|
|
86
|
+
logApiResponse: vi.fn(),
|
|
87
|
+
logApiError: vi.fn(),
|
|
88
|
+
}));
|
|
89
|
+
vi.mock('../ide/ideContext.js');
|
|
90
|
+
vi.mock('../telemetry/uiTelemetry.js', () => ({
|
|
91
|
+
uiTelemetryService: {
|
|
92
|
+
setLastPromptTokenCount: vi.fn(),
|
|
93
|
+
getLastPromptTokenCount: vi.fn(),
|
|
94
|
+
},
|
|
95
|
+
}));
|
|
96
|
+
vi.mock('../hooks/hookSystem.js');
|
|
97
|
+
/**
|
|
98
|
+
* Array.fromAsync ponyfill, which will be available in es 2024.
|
|
99
|
+
*
|
|
100
|
+
* Buffers an async generator into an array and returns the result.
|
|
101
|
+
*/
|
|
102
|
+
async function fromAsync(promise) {
|
|
103
|
+
const results = [];
|
|
104
|
+
for await (const result of promise) {
|
|
105
|
+
results.push(result);
|
|
106
|
+
}
|
|
107
|
+
return results;
|
|
108
|
+
}
|
|
109
|
+
describe('Gemini Client (client.ts)', () => {
|
|
110
|
+
let mockContentGenerator;
|
|
111
|
+
let mockConfig;
|
|
112
|
+
let client;
|
|
113
|
+
let mockGenerateContentFn;
|
|
114
|
+
let mockRouterService;
|
|
115
|
+
beforeEach(async () => {
|
|
116
|
+
vi.resetAllMocks();
|
|
117
|
+
ClearcutLogger.clearInstance();
|
|
118
|
+
vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
|
|
119
|
+
vi.mocked(ChatCompressionService.prototype.compress).mockResolvedValue({
|
|
120
|
+
newHistory: null,
|
|
121
|
+
info: {
|
|
122
|
+
originalTokenCount: 0,
|
|
123
|
+
newTokenCount: 0,
|
|
124
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
mockGenerateContentFn = vi.fn().mockResolvedValue({
|
|
128
|
+
candidates: [{ content: { parts: [{ text: '{"key": "value"}' }] } }],
|
|
129
|
+
});
|
|
130
|
+
// Disable 429 simulation for tests
|
|
131
|
+
setSimulate429(false);
|
|
132
|
+
mockRouterService = {
|
|
133
|
+
route: vi
|
|
134
|
+
.fn()
|
|
135
|
+
.mockResolvedValue({ model: 'default-routed-model', reason: 'test' }),
|
|
136
|
+
};
|
|
137
|
+
mockContentGenerator = {
|
|
138
|
+
generateContent: mockGenerateContentFn,
|
|
139
|
+
generateContentStream: vi.fn(),
|
|
140
|
+
batchEmbedContents: vi.fn(),
|
|
141
|
+
countTokens: vi.fn().mockResolvedValue({ totalTokens: 100 }),
|
|
142
|
+
};
|
|
143
|
+
// Because the GeminiClient constructor kicks off an async process (startChat)
|
|
144
|
+
// that depends on a fully-formed Config object, we need to mock the
|
|
145
|
+
// entire implementation of Config for these tests.
|
|
146
|
+
const mockToolRegistry = {
|
|
147
|
+
getFunctionDeclarations: vi.fn().mockReturnValue([]),
|
|
148
|
+
getTool: vi.fn().mockReturnValue(null),
|
|
149
|
+
};
|
|
150
|
+
const fileService = new FileDiscoveryService('/test/dir');
|
|
151
|
+
const contentGeneratorConfig = {
|
|
152
|
+
apiKey: 'test-key',
|
|
153
|
+
vertexai: false,
|
|
154
|
+
authType: AuthType.USE_GEMINI,
|
|
155
|
+
};
|
|
156
|
+
mockConfig = {
|
|
157
|
+
getContentGeneratorConfig: vi
|
|
158
|
+
.fn()
|
|
159
|
+
.mockReturnValue(contentGeneratorConfig),
|
|
160
|
+
getToolRegistry: vi.fn().mockReturnValue(mockToolRegistry),
|
|
161
|
+
getModel: vi.fn().mockReturnValue('test-model'),
|
|
162
|
+
getUserTier: vi.fn().mockReturnValue(undefined),
|
|
163
|
+
getEmbeddingModel: vi.fn().mockReturnValue('test-embedding-model'),
|
|
164
|
+
getApiKey: vi.fn().mockReturnValue('test-key'),
|
|
165
|
+
getVertexAI: vi.fn().mockReturnValue(false),
|
|
166
|
+
getUserAgent: vi.fn().mockReturnValue('test-agent'),
|
|
167
|
+
getUserMemory: vi.fn().mockReturnValue(''),
|
|
168
|
+
getGlobalMemory: vi.fn().mockReturnValue(''),
|
|
169
|
+
getEnvironmentMemory: vi.fn().mockReturnValue(''),
|
|
170
|
+
isJitContextEnabled: vi.fn().mockReturnValue(false),
|
|
171
|
+
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
|
172
|
+
getProxy: vi.fn().mockReturnValue(undefined),
|
|
173
|
+
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
|
174
|
+
getFileService: vi.fn().mockReturnValue(fileService),
|
|
175
|
+
getMaxSessionTurns: vi.fn().mockReturnValue(0),
|
|
176
|
+
getQuotaErrorOccurred: vi.fn().mockReturnValue(false),
|
|
177
|
+
setQuotaErrorOccurred: vi.fn(),
|
|
178
|
+
getNoBrowser: vi.fn().mockReturnValue(false),
|
|
179
|
+
getUsageStatisticsEnabled: vi.fn().mockReturnValue(true),
|
|
180
|
+
getIdeModeFeature: vi.fn().mockReturnValue(false),
|
|
181
|
+
getIdeMode: vi.fn().mockReturnValue(true),
|
|
182
|
+
getDebugMode: vi.fn().mockReturnValue(false),
|
|
183
|
+
getPreviewFeatures: vi.fn().mockReturnValue(false),
|
|
184
|
+
getWorkspaceContext: vi.fn().mockReturnValue({
|
|
185
|
+
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
|
186
|
+
}),
|
|
187
|
+
getGeminiClient: vi.fn(),
|
|
188
|
+
getModelRouterService: vi
|
|
189
|
+
.fn()
|
|
190
|
+
.mockReturnValue(mockRouterService),
|
|
191
|
+
getMessageBus: vi.fn().mockReturnValue(undefined),
|
|
192
|
+
getEnableHooks: vi.fn().mockReturnValue(false),
|
|
193
|
+
getChatCompression: vi.fn().mockReturnValue(undefined),
|
|
194
|
+
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
|
195
|
+
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
|
196
|
+
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
|
197
|
+
getContinueOnFailedApiCall: vi.fn(),
|
|
198
|
+
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
|
199
|
+
storage: {
|
|
200
|
+
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
|
|
201
|
+
},
|
|
202
|
+
getContentGenerator: vi.fn().mockReturnValue(mockContentGenerator),
|
|
203
|
+
getBaseLlmClient: vi.fn().mockReturnValue({
|
|
204
|
+
generateJson: vi.fn().mockResolvedValue({
|
|
205
|
+
next_speaker: 'user',
|
|
206
|
+
reasoning: 'test',
|
|
207
|
+
}),
|
|
208
|
+
}),
|
|
209
|
+
modelConfigService: {
|
|
210
|
+
getResolvedConfig(modelConfigKey) {
|
|
211
|
+
return {
|
|
212
|
+
model: modelConfigKey.model,
|
|
213
|
+
generateContentConfig: {
|
|
214
|
+
temperature: 0,
|
|
215
|
+
topP: 1,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
isInteractive: vi.fn().mockReturnValue(false),
|
|
221
|
+
getExperiments: () => { },
|
|
222
|
+
getActiveModel: vi.fn().mockReturnValue('test-model'),
|
|
223
|
+
setActiveModel: vi.fn(),
|
|
224
|
+
resetTurn: vi.fn(),
|
|
225
|
+
getModelAvailabilityService: vi
|
|
226
|
+
.fn()
|
|
227
|
+
.mockReturnValue(createAvailabilityServiceMock()),
|
|
228
|
+
};
|
|
229
|
+
mockConfig.getHookSystem = vi
|
|
230
|
+
.fn()
|
|
231
|
+
.mockReturnValue(new HookSystem(mockConfig));
|
|
232
|
+
client = new GeminiClient(mockConfig);
|
|
233
|
+
await client.initialize();
|
|
234
|
+
vi.mocked(mockConfig.getGeminiClient).mockReturnValue(client);
|
|
235
|
+
vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
|
|
236
|
+
});
|
|
237
|
+
afterEach(() => {
|
|
238
|
+
vi.restoreAllMocks();
|
|
239
|
+
});
|
|
240
|
+
describe('addHistory', () => {
|
|
241
|
+
it('should call chat.addHistory with the provided content', async () => {
|
|
242
|
+
const mockChat = {
|
|
243
|
+
addHistory: vi.fn(),
|
|
244
|
+
};
|
|
245
|
+
client['chat'] = mockChat;
|
|
246
|
+
const newContent = {
|
|
247
|
+
role: 'user',
|
|
248
|
+
parts: [{ text: 'New history item' }],
|
|
249
|
+
};
|
|
250
|
+
await client.addHistory(newContent);
|
|
251
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith(newContent);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
describe('resetChat', () => {
|
|
255
|
+
it('should create a new chat session, clearing the old history', async () => {
|
|
256
|
+
// 1. Get the initial chat instance and add some history.
|
|
257
|
+
const initialChat = client.getChat();
|
|
258
|
+
const initialHistory = client.getHistory();
|
|
259
|
+
await client.addHistory({
|
|
260
|
+
role: 'user',
|
|
261
|
+
parts: [{ text: 'some old message' }],
|
|
262
|
+
});
|
|
263
|
+
const historyWithOldMessage = client.getHistory();
|
|
264
|
+
expect(historyWithOldMessage.length).toBeGreaterThan(initialHistory.length);
|
|
265
|
+
// 2. Call resetChat.
|
|
266
|
+
await client.resetChat();
|
|
267
|
+
// 3. Get the new chat instance and its history.
|
|
268
|
+
const newChat = client.getChat();
|
|
269
|
+
const newHistory = client.getHistory();
|
|
270
|
+
// 4. Assert that the chat instance is new and the history is reset.
|
|
271
|
+
expect(newChat).not.toBe(initialChat);
|
|
272
|
+
expect(newHistory.length).toBe(initialHistory.length);
|
|
273
|
+
expect(JSON.stringify(newHistory)).not.toContain('some old message');
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
describe('startChat', () => {
|
|
277
|
+
it('should include environment context when resuming a session', async () => {
|
|
278
|
+
const extraHistory = [
|
|
279
|
+
{ role: 'user', parts: [{ text: 'Old message' }] },
|
|
280
|
+
{ role: 'model', parts: [{ text: 'Old response' }] },
|
|
281
|
+
];
|
|
282
|
+
const chat = await client.startChat(extraHistory);
|
|
283
|
+
const history = chat.getHistory();
|
|
284
|
+
// The first message should be the environment context
|
|
285
|
+
expect(history[0].role).toBe('user');
|
|
286
|
+
expect(history[0].parts?.[0]?.text).toContain('This is TerminaI');
|
|
287
|
+
expect(history[0].parts?.[0]?.text).toContain("The project's temporary directory is:");
|
|
288
|
+
// The subsequent messages should be the extra history
|
|
289
|
+
expect(history[1]).toEqual(extraHistory[0]);
|
|
290
|
+
expect(history[2]).toEqual(extraHistory[1]);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
describe('tryCompressChat', () => {
|
|
294
|
+
const mockGetHistory = vi.fn();
|
|
295
|
+
beforeEach(() => {
|
|
296
|
+
vi.mock('./tokenLimits', () => ({
|
|
297
|
+
tokenLimit: vi.fn(),
|
|
298
|
+
}));
|
|
299
|
+
client['chat'] = {
|
|
300
|
+
getHistory: mockGetHistory,
|
|
301
|
+
addHistory: vi.fn(),
|
|
302
|
+
setHistory: vi.fn(),
|
|
303
|
+
getLastPromptTokenCount: vi.fn(),
|
|
304
|
+
};
|
|
305
|
+
});
|
|
306
|
+
function setup({ chatHistory = [
|
|
307
|
+
{ role: 'user', parts: [{ text: 'Long conversation' }] },
|
|
308
|
+
{ role: 'model', parts: [{ text: 'Long response' }] },
|
|
309
|
+
], originalTokenCount = 1000, newTokenCount = 500, compressionStatus = CompressionStatus.COMPRESSED, } = {}) {
|
|
310
|
+
const mockOriginalChat = {
|
|
311
|
+
getHistory: vi.fn((_curated) => chatHistory),
|
|
312
|
+
setHistory: vi.fn(),
|
|
313
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(originalTokenCount),
|
|
314
|
+
};
|
|
315
|
+
client['chat'] = mockOriginalChat;
|
|
316
|
+
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(originalTokenCount);
|
|
317
|
+
const newHistory = [
|
|
318
|
+
{ role: 'user', parts: [{ text: 'Summary' }] },
|
|
319
|
+
{ role: 'model', parts: [{ text: 'Got it' }] },
|
|
320
|
+
];
|
|
321
|
+
vi.mocked(ChatCompressionService.prototype.compress).mockResolvedValue({
|
|
322
|
+
newHistory: compressionStatus === CompressionStatus.COMPRESSED
|
|
323
|
+
? newHistory
|
|
324
|
+
: null,
|
|
325
|
+
info: {
|
|
326
|
+
originalTokenCount,
|
|
327
|
+
newTokenCount,
|
|
328
|
+
compressionStatus,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
const mockNewChat = {
|
|
332
|
+
getHistory: vi.fn().mockReturnValue(newHistory),
|
|
333
|
+
setHistory: vi.fn(),
|
|
334
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(newTokenCount),
|
|
335
|
+
};
|
|
336
|
+
client['startChat'] = vi
|
|
337
|
+
.fn()
|
|
338
|
+
.mockResolvedValue(mockNewChat);
|
|
339
|
+
return {
|
|
340
|
+
client,
|
|
341
|
+
mockOriginalChat,
|
|
342
|
+
mockNewChat,
|
|
343
|
+
estimatedNewTokenCount: newTokenCount,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
describe('when compression inflates the token count', () => {
|
|
347
|
+
it('allows compression to be forced/manual after a failure', async () => {
|
|
348
|
+
// Call 1 (Fails): Setup with inflated tokens
|
|
349
|
+
setup({
|
|
350
|
+
originalTokenCount: 100,
|
|
351
|
+
newTokenCount: 200,
|
|
352
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
353
|
+
});
|
|
354
|
+
await client.tryCompressChat('prompt-id-4', false); // Fails
|
|
355
|
+
// Call 2 (Forced): Re-setup with compressed tokens
|
|
356
|
+
const { estimatedNewTokenCount: compressedTokenCount } = setup({
|
|
357
|
+
originalTokenCount: 100,
|
|
358
|
+
newTokenCount: 50,
|
|
359
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
360
|
+
});
|
|
361
|
+
const result = await client.tryCompressChat('prompt-id-4', true); // Forced
|
|
362
|
+
expect(result).toEqual({
|
|
363
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
364
|
+
newTokenCount: compressedTokenCount,
|
|
365
|
+
originalTokenCount: 100,
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
it('yields the result even if the compression inflated the tokens', async () => {
|
|
369
|
+
const { client, estimatedNewTokenCount } = setup({
|
|
370
|
+
originalTokenCount: 100,
|
|
371
|
+
newTokenCount: 200,
|
|
372
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
373
|
+
});
|
|
374
|
+
const result = await client.tryCompressChat('prompt-id-4', false);
|
|
375
|
+
expect(result).toEqual({
|
|
376
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
377
|
+
newTokenCount: estimatedNewTokenCount,
|
|
378
|
+
originalTokenCount: 100,
|
|
379
|
+
});
|
|
380
|
+
// IMPORTANT: The change in client.ts means setLastPromptTokenCount is NOT called on failure
|
|
381
|
+
expect(uiTelemetryService.setLastPromptTokenCount).not.toHaveBeenCalled();
|
|
382
|
+
});
|
|
383
|
+
it('does not manipulate the source chat', async () => {
|
|
384
|
+
const { client, mockOriginalChat } = setup({
|
|
385
|
+
originalTokenCount: 100,
|
|
386
|
+
newTokenCount: 200,
|
|
387
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
388
|
+
});
|
|
389
|
+
await client.tryCompressChat('prompt-id-4', false);
|
|
390
|
+
// On failure, the chat should NOT be replaced
|
|
391
|
+
expect(client['chat']).toBe(mockOriginalChat);
|
|
392
|
+
});
|
|
393
|
+
it.skip('will not attempt to compress context after a failure', async () => {
|
|
394
|
+
const { client } = setup({
|
|
395
|
+
originalTokenCount: 100,
|
|
396
|
+
newTokenCount: 200,
|
|
397
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
398
|
+
});
|
|
399
|
+
await client.tryCompressChat('prompt-id-4', false); // This fails and sets hasFailedCompressionAttempt = true
|
|
400
|
+
// Mock the next call to return NOOP
|
|
401
|
+
vi.mocked(ChatCompressionService.prototype.compress).mockResolvedValueOnce({
|
|
402
|
+
newHistory: null,
|
|
403
|
+
info: {
|
|
404
|
+
originalTokenCount: 0,
|
|
405
|
+
newTokenCount: 0,
|
|
406
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
// This call should now be a NOOP
|
|
410
|
+
const result = await client.tryCompressChat('prompt-id-5', false);
|
|
411
|
+
expect(result.compressionStatus).toBe(CompressionStatus.NOOP);
|
|
412
|
+
expect(ChatCompressionService.prototype.compress).toHaveBeenCalledTimes(2);
|
|
413
|
+
expect(ChatCompressionService.prototype.compress).toHaveBeenLastCalledWith(expect.anything(), 'prompt-id-5', false, expect.anything(), expect.anything(), true);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
it('should correctly latch hasFailedCompressionAttempt flag', async () => {
|
|
417
|
+
// 1. Setup: Call setup() from this test file
|
|
418
|
+
// This helper function mocks the compression service for us.
|
|
419
|
+
const { client } = setup({
|
|
420
|
+
originalTokenCount: 100,
|
|
421
|
+
newTokenCount: 200, // Inflated
|
|
422
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
423
|
+
});
|
|
424
|
+
// 2. Test Step 1: Trigger a non-forced failure
|
|
425
|
+
await client.tryCompressChat('prompt-1', false); // force = false
|
|
426
|
+
// 3. Assert Step 1: Check that the flag became true
|
|
427
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
428
|
+
expect(client.hasFailedCompressionAttempt).toBe(true);
|
|
429
|
+
// 4. Test Step 2: Trigger a forced failure
|
|
430
|
+
await client.tryCompressChat('prompt-2', true); // force = true
|
|
431
|
+
// 5. Assert Step 2: Check that the flag REMAINS true
|
|
432
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
433
|
+
expect(client.hasFailedCompressionAttempt).toBe(true);
|
|
434
|
+
});
|
|
435
|
+
it('should not trigger summarization if token count is below threshold', async () => {
|
|
436
|
+
const MOCKED_TOKEN_LIMIT = 1000;
|
|
437
|
+
const originalTokenCount = MOCKED_TOKEN_LIMIT * 0.699;
|
|
438
|
+
vi.mocked(ChatCompressionService.prototype.compress).mockResolvedValue({
|
|
439
|
+
newHistory: null,
|
|
440
|
+
info: {
|
|
441
|
+
originalTokenCount,
|
|
442
|
+
newTokenCount: originalTokenCount,
|
|
443
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
const initialChat = client.getChat();
|
|
447
|
+
const result = await client.tryCompressChat('prompt-id-2', false);
|
|
448
|
+
const newChat = client.getChat();
|
|
449
|
+
expect(result).toEqual({
|
|
450
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
451
|
+
newTokenCount: originalTokenCount,
|
|
452
|
+
originalTokenCount,
|
|
453
|
+
});
|
|
454
|
+
expect(newChat).toBe(initialChat);
|
|
455
|
+
});
|
|
456
|
+
it('should return NOOP if history is too short to compress', async () => {
|
|
457
|
+
const { client } = setup({
|
|
458
|
+
chatHistory: [{ role: 'user', parts: [{ text: 'hi' }] }],
|
|
459
|
+
originalTokenCount: 50,
|
|
460
|
+
newTokenCount: 50,
|
|
461
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
462
|
+
});
|
|
463
|
+
const result = await client.tryCompressChat('prompt-id-noop', false);
|
|
464
|
+
expect(result).toEqual({
|
|
465
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
466
|
+
originalTokenCount: 50,
|
|
467
|
+
newTokenCount: 50,
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
describe('sendMessageStream', () => {
|
|
472
|
+
it('emits a compression event when the context was automatically compressed', async () => {
|
|
473
|
+
// Arrange
|
|
474
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
475
|
+
yield { type: 'content', value: 'Hello' };
|
|
476
|
+
})());
|
|
477
|
+
const compressionInfo = {
|
|
478
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
479
|
+
originalTokenCount: 1000,
|
|
480
|
+
newTokenCount: 500,
|
|
481
|
+
};
|
|
482
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValueOnce(compressionInfo);
|
|
483
|
+
// Act
|
|
484
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-1');
|
|
485
|
+
const events = await fromAsync(stream);
|
|
486
|
+
// Assert
|
|
487
|
+
expect(events).toContainEqual({
|
|
488
|
+
type: GeminiEventType.ChatCompressed,
|
|
489
|
+
value: compressionInfo,
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
it.each([
|
|
493
|
+
{
|
|
494
|
+
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
495
|
+
},
|
|
496
|
+
{ compressionStatus: CompressionStatus.NOOP },
|
|
497
|
+
])('does not emit a compression event when the status is $compressionStatus', async ({ compressionStatus }) => {
|
|
498
|
+
// Arrange
|
|
499
|
+
const mockStream = (async function* () {
|
|
500
|
+
yield { type: 'content', value: 'Hello' };
|
|
501
|
+
})();
|
|
502
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
503
|
+
const compressionInfo = {
|
|
504
|
+
compressionStatus,
|
|
505
|
+
originalTokenCount: 1000,
|
|
506
|
+
newTokenCount: 500,
|
|
507
|
+
};
|
|
508
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValueOnce(compressionInfo);
|
|
509
|
+
// Act
|
|
510
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-1');
|
|
511
|
+
const events = await fromAsync(stream);
|
|
512
|
+
// Assert
|
|
513
|
+
expect(events).not.toContainEqual({
|
|
514
|
+
type: GeminiEventType.ChatCompressed,
|
|
515
|
+
value: expect.anything(),
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
it('should include editor context when ideMode is enabled', async () => {
|
|
519
|
+
// Arrange
|
|
520
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
521
|
+
workspaceState: {
|
|
522
|
+
openFiles: [
|
|
523
|
+
{
|
|
524
|
+
path: '/path/to/active/file.ts',
|
|
525
|
+
timestamp: Date.now(),
|
|
526
|
+
isActive: true,
|
|
527
|
+
selectedText: 'hello',
|
|
528
|
+
cursor: { line: 5, character: 10 },
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
path: '/path/to/recent/file1.ts',
|
|
532
|
+
timestamp: Date.now(),
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
path: '/path/to/recent/file2.ts',
|
|
536
|
+
timestamp: Date.now(),
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
vi.mocked(mockConfig.getIdeMode).mockReturnValue(true);
|
|
542
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
543
|
+
originalTokenCount: 0,
|
|
544
|
+
newTokenCount: 0,
|
|
545
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
546
|
+
});
|
|
547
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
548
|
+
yield { type: 'content', value: 'Hello' };
|
|
549
|
+
})());
|
|
550
|
+
const mockChat = {
|
|
551
|
+
addHistory: vi.fn(),
|
|
552
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
553
|
+
getLastPromptTokenCount: vi.fn(),
|
|
554
|
+
};
|
|
555
|
+
client['chat'] = mockChat;
|
|
556
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
557
|
+
// Act
|
|
558
|
+
const stream = client.sendMessageStream(initialRequest, new AbortController().signal, 'prompt-id-ide');
|
|
559
|
+
for await (const _ of stream) {
|
|
560
|
+
// consume stream
|
|
561
|
+
}
|
|
562
|
+
// Assert
|
|
563
|
+
expect(ideContextStore.get).toHaveBeenCalled();
|
|
564
|
+
const expectedContext = `
|
|
565
|
+
Here is the user's editor context as a JSON object. This is for your information only.
|
|
566
|
+
\`\`\`json
|
|
567
|
+
${JSON.stringify({
|
|
568
|
+
activeFile: {
|
|
569
|
+
path: '/path/to/active/file.ts',
|
|
570
|
+
cursor: {
|
|
571
|
+
line: 5,
|
|
572
|
+
character: 10,
|
|
573
|
+
},
|
|
574
|
+
selectedText: 'hello',
|
|
575
|
+
},
|
|
576
|
+
otherOpenFiles: ['/path/to/recent/file1.ts', '/path/to/recent/file2.ts'],
|
|
577
|
+
}, null, 2)}
|
|
578
|
+
\`\`\`
|
|
579
|
+
`.trim();
|
|
580
|
+
const expectedRequest = [{ text: expectedContext }];
|
|
581
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
|
582
|
+
role: 'user',
|
|
583
|
+
parts: expectedRequest,
|
|
584
|
+
});
|
|
585
|
+
});
|
|
586
|
+
it('should not add context if ideMode is enabled but no open files', async () => {
|
|
587
|
+
// Arrange
|
|
588
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
589
|
+
workspaceState: {
|
|
590
|
+
openFiles: [],
|
|
591
|
+
},
|
|
592
|
+
});
|
|
593
|
+
vi.spyOn(client['config'], 'getIdeMode').mockReturnValue(true);
|
|
594
|
+
const mockStream = (async function* () {
|
|
595
|
+
yield { type: 'content', value: 'Hello' };
|
|
596
|
+
})();
|
|
597
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
598
|
+
const mockChat = {
|
|
599
|
+
addHistory: vi.fn(),
|
|
600
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
601
|
+
getLastPromptTokenCount: vi.fn(),
|
|
602
|
+
};
|
|
603
|
+
client['chat'] = mockChat;
|
|
604
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
605
|
+
// Act
|
|
606
|
+
const stream = client.sendMessageStream(initialRequest, new AbortController().signal, 'prompt-id-ide');
|
|
607
|
+
for await (const _ of stream) {
|
|
608
|
+
// consume stream
|
|
609
|
+
}
|
|
610
|
+
// Assert
|
|
611
|
+
expect(ideContextStore.get).toHaveBeenCalled();
|
|
612
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'default-routed-model' }, initialRequest, expect.any(AbortSignal));
|
|
613
|
+
});
|
|
614
|
+
it('should add context if ideMode is enabled and there is one active file', async () => {
|
|
615
|
+
// Arrange
|
|
616
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
617
|
+
workspaceState: {
|
|
618
|
+
openFiles: [
|
|
619
|
+
{
|
|
620
|
+
path: '/path/to/active/file.ts',
|
|
621
|
+
timestamp: Date.now(),
|
|
622
|
+
isActive: true,
|
|
623
|
+
selectedText: 'hello',
|
|
624
|
+
cursor: { line: 5, character: 10 },
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
},
|
|
628
|
+
});
|
|
629
|
+
vi.spyOn(client['config'], 'getIdeMode').mockReturnValue(true);
|
|
630
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
631
|
+
originalTokenCount: 0,
|
|
632
|
+
newTokenCount: 0,
|
|
633
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
634
|
+
});
|
|
635
|
+
const mockStream = (async function* () {
|
|
636
|
+
yield { type: 'content', value: 'Hello' };
|
|
637
|
+
})();
|
|
638
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
639
|
+
const mockChat = {
|
|
640
|
+
addHistory: vi.fn(),
|
|
641
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
642
|
+
getLastPromptTokenCount: vi.fn(),
|
|
643
|
+
};
|
|
644
|
+
client['chat'] = mockChat;
|
|
645
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
646
|
+
// Act
|
|
647
|
+
const stream = client.sendMessageStream(initialRequest, new AbortController().signal, 'prompt-id-ide');
|
|
648
|
+
for await (const _ of stream) {
|
|
649
|
+
// consume stream
|
|
650
|
+
}
|
|
651
|
+
// Assert
|
|
652
|
+
expect(ideContextStore.get).toHaveBeenCalled();
|
|
653
|
+
const expectedContext = `
|
|
654
|
+
Here is the user's editor context as a JSON object. This is for your information only.
|
|
655
|
+
\`\`\`json
|
|
656
|
+
${JSON.stringify({
|
|
657
|
+
activeFile: {
|
|
658
|
+
path: '/path/to/active/file.ts',
|
|
659
|
+
cursor: {
|
|
660
|
+
line: 5,
|
|
661
|
+
character: 10,
|
|
662
|
+
},
|
|
663
|
+
selectedText: 'hello',
|
|
664
|
+
},
|
|
665
|
+
}, null, 2)}
|
|
666
|
+
\`\`\`
|
|
667
|
+
`.trim();
|
|
668
|
+
const expectedRequest = [{ text: expectedContext }];
|
|
669
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
|
670
|
+
role: 'user',
|
|
671
|
+
parts: expectedRequest,
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
it('should add context if ideMode is enabled and there are open files but no active file', async () => {
|
|
675
|
+
// Arrange
|
|
676
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
677
|
+
workspaceState: {
|
|
678
|
+
openFiles: [
|
|
679
|
+
{
|
|
680
|
+
path: '/path/to/recent/file1.ts',
|
|
681
|
+
timestamp: Date.now(),
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
path: '/path/to/recent/file2.ts',
|
|
685
|
+
timestamp: Date.now(),
|
|
686
|
+
},
|
|
687
|
+
],
|
|
688
|
+
},
|
|
689
|
+
});
|
|
690
|
+
vi.spyOn(client['config'], 'getIdeMode').mockReturnValue(true);
|
|
691
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
692
|
+
originalTokenCount: 0,
|
|
693
|
+
newTokenCount: 0,
|
|
694
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
695
|
+
});
|
|
696
|
+
const mockStream = (async function* () {
|
|
697
|
+
yield { type: 'content', value: 'Hello' };
|
|
698
|
+
})();
|
|
699
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
700
|
+
const mockChat = {
|
|
701
|
+
addHistory: vi.fn(),
|
|
702
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
703
|
+
getLastPromptTokenCount: vi.fn(),
|
|
704
|
+
};
|
|
705
|
+
client['chat'] = mockChat;
|
|
706
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
707
|
+
// Act
|
|
708
|
+
const stream = client.sendMessageStream(initialRequest, new AbortController().signal, 'prompt-id-ide');
|
|
709
|
+
for await (const _ of stream) {
|
|
710
|
+
// consume stream
|
|
711
|
+
}
|
|
712
|
+
// Assert
|
|
713
|
+
expect(ideContextStore.get).toHaveBeenCalled();
|
|
714
|
+
const expectedContext = `
|
|
715
|
+
Here is the user's editor context as a JSON object. This is for your information only.
|
|
716
|
+
\`\`\`json
|
|
717
|
+
${JSON.stringify({
|
|
718
|
+
otherOpenFiles: ['/path/to/recent/file1.ts', '/path/to/recent/file2.ts'],
|
|
719
|
+
}, null, 2)}
|
|
720
|
+
\`\`\`
|
|
721
|
+
`.trim();
|
|
722
|
+
const expectedRequest = [{ text: expectedContext }];
|
|
723
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith({
|
|
724
|
+
role: 'user',
|
|
725
|
+
parts: expectedRequest,
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
it('should use local estimation for text-only requests and NOT call countTokens', async () => {
|
|
729
|
+
const request = [{ text: 'Hello world' }];
|
|
730
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
731
|
+
const countTokensSpy = vi.spyOn(generator, 'countTokens');
|
|
732
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
733
|
+
await stream.next(); // Trigger the generator
|
|
734
|
+
expect(countTokensSpy).not.toHaveBeenCalled();
|
|
735
|
+
});
|
|
736
|
+
it('should use countTokens API for requests with non-text parts', async () => {
|
|
737
|
+
const request = [
|
|
738
|
+
{ text: 'Describe this image' },
|
|
739
|
+
{ inlineData: { mimeType: 'image/png', data: 'base64...' } },
|
|
740
|
+
];
|
|
741
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
742
|
+
const countTokensSpy = vi
|
|
743
|
+
.spyOn(generator, 'countTokens')
|
|
744
|
+
.mockResolvedValue({ totalTokens: 123 });
|
|
745
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
746
|
+
await stream.next(); // Trigger the generator
|
|
747
|
+
expect(countTokensSpy).toHaveBeenCalledWith(expect.objectContaining({
|
|
748
|
+
contents: expect.arrayContaining([
|
|
749
|
+
expect.objectContaining({
|
|
750
|
+
parts: expect.arrayContaining([
|
|
751
|
+
{ text: 'Describe this image' },
|
|
752
|
+
{ inlineData: { mimeType: 'image/png', data: 'base64...' } },
|
|
753
|
+
]),
|
|
754
|
+
}),
|
|
755
|
+
]),
|
|
756
|
+
}));
|
|
757
|
+
});
|
|
758
|
+
it('should estimate CJK characters more conservatively (closer to 1 token/char)', async () => {
|
|
759
|
+
const request = [{ text: '你好世界' }]; // 4 chars
|
|
760
|
+
const generator = client['getContentGeneratorOrFail']();
|
|
761
|
+
const countTokensSpy = vi.spyOn(generator, 'countTokens');
|
|
762
|
+
// 4 chars.
|
|
763
|
+
// Old logic: 4/4 = 1.
|
|
764
|
+
// New logic (heuristic): 4 * 1 = 4. (Or at least > 1).
|
|
765
|
+
// Let's assert it's roughly accurate.
|
|
766
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-prompt-id');
|
|
767
|
+
await stream.next();
|
|
768
|
+
// Should NOT call countTokens (it's text only)
|
|
769
|
+
expect(countTokensSpy).not.toHaveBeenCalled();
|
|
770
|
+
// The actual token calculation is unit tested in tokenCalculation.test.ts
|
|
771
|
+
});
|
|
772
|
+
it('should return the turn instance after the stream is complete', async () => {
|
|
773
|
+
// Arrange
|
|
774
|
+
const mockStream = (async function* () {
|
|
775
|
+
yield { type: 'content', value: 'Hello' };
|
|
776
|
+
})();
|
|
777
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
778
|
+
const mockChat = {
|
|
779
|
+
addHistory: vi.fn(),
|
|
780
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
781
|
+
getLastPromptTokenCount: vi.fn(),
|
|
782
|
+
};
|
|
783
|
+
client['chat'] = mockChat;
|
|
784
|
+
// Act
|
|
785
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-1');
|
|
786
|
+
// Consume the stream manually to get the final return value.
|
|
787
|
+
let finalResult;
|
|
788
|
+
while (true) {
|
|
789
|
+
const result = await stream.next();
|
|
790
|
+
if (result.done) {
|
|
791
|
+
finalResult = result.value;
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
// Assert
|
|
796
|
+
expect(finalResult).toBeInstanceOf(Turn);
|
|
797
|
+
});
|
|
798
|
+
it('should stop infinite loop after MAX_TURNS when nextSpeaker always returns model', async () => {
|
|
799
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
800
|
+
// Get the mocked checkNextSpeaker function and configure it to trigger infinite loop
|
|
801
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
802
|
+
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
|
|
803
|
+
mockCheckNextSpeaker.mockResolvedValue({
|
|
804
|
+
next_speaker: 'model',
|
|
805
|
+
reasoning: 'Test case - always continue',
|
|
806
|
+
});
|
|
807
|
+
// Mock Turn to have no pending tool calls (which would allow nextSpeaker check)
|
|
808
|
+
const mockStream = (async function* () {
|
|
809
|
+
yield { type: 'content', value: 'Continue...' };
|
|
810
|
+
})();
|
|
811
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
812
|
+
const mockChat = {
|
|
813
|
+
addHistory: vi.fn(),
|
|
814
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
815
|
+
getLastPromptTokenCount: vi.fn(),
|
|
816
|
+
};
|
|
817
|
+
client['chat'] = mockChat;
|
|
818
|
+
// Use a signal that never gets aborted
|
|
819
|
+
const abortController = new AbortController();
|
|
820
|
+
const signal = abortController.signal;
|
|
821
|
+
// Act - Start the stream that should loop
|
|
822
|
+
const stream = client.sendMessageStream([{ text: 'Start conversation' }], signal, 'prompt-id-2');
|
|
823
|
+
// Count how many stream events we get
|
|
824
|
+
let eventCount = 0;
|
|
825
|
+
let finalResult;
|
|
826
|
+
// Consume the stream and count iterations
|
|
827
|
+
while (true) {
|
|
828
|
+
const result = await stream.next();
|
|
829
|
+
if (result.done) {
|
|
830
|
+
finalResult = result.value;
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
eventCount++;
|
|
834
|
+
// Safety check to prevent actual infinite loop in test
|
|
835
|
+
if (eventCount > 200) {
|
|
836
|
+
abortController.abort();
|
|
837
|
+
throw new Error('Test exceeded expected event limit - possible actual infinite loop');
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
// Assert
|
|
841
|
+
expect(finalResult).toBeInstanceOf(Turn);
|
|
842
|
+
// If infinite loop protection is working, checkNextSpeaker should be called many times
|
|
843
|
+
// but stop at MAX_TURNS (100). Since each recursive call should trigger checkNextSpeaker,
|
|
844
|
+
// we expect it to be called multiple times before hitting the limit
|
|
845
|
+
expect(mockCheckNextSpeaker).toHaveBeenCalled();
|
|
846
|
+
// The stream should produce events and eventually terminate
|
|
847
|
+
expect(eventCount).toBeGreaterThanOrEqual(1);
|
|
848
|
+
expect(eventCount).toBeLessThan(200); // Should not exceed our safety limit
|
|
849
|
+
});
|
|
850
|
+
it('should yield MaxSessionTurns and stop when session turn limit is reached', async () => {
|
|
851
|
+
// Arrange
|
|
852
|
+
const MAX_SESSION_TURNS = 5;
|
|
853
|
+
vi.spyOn(client['config'], 'getMaxSessionTurns').mockReturnValue(MAX_SESSION_TURNS);
|
|
854
|
+
const mockStream = (async function* () {
|
|
855
|
+
yield { type: 'content', value: 'Hello' };
|
|
856
|
+
})();
|
|
857
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
858
|
+
const mockChat = {
|
|
859
|
+
addHistory: vi.fn(),
|
|
860
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
861
|
+
getLastPromptTokenCount: vi.fn(),
|
|
862
|
+
};
|
|
863
|
+
client['chat'] = mockChat;
|
|
864
|
+
// Act & Assert
|
|
865
|
+
// Run up to the limit
|
|
866
|
+
for (let i = 0; i < MAX_SESSION_TURNS; i++) {
|
|
867
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-4');
|
|
868
|
+
// consume stream
|
|
869
|
+
for await (const _event of stream) {
|
|
870
|
+
// do nothing
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
// This call should exceed the limit
|
|
874
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-5');
|
|
875
|
+
const events = [];
|
|
876
|
+
for await (const event of stream) {
|
|
877
|
+
events.push(event);
|
|
878
|
+
}
|
|
879
|
+
expect(events).toEqual([{ type: GeminiEventType.MaxSessionTurns }]);
|
|
880
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(MAX_SESSION_TURNS);
|
|
881
|
+
});
|
|
882
|
+
it('should respect MAX_TURNS limit even when turns parameter is set to a large value', async () => {
|
|
883
|
+
// This test verifies that the infinite loop protection works even when
|
|
884
|
+
// someone tries to bypass it by calling with a very large turns value
|
|
885
|
+
// Get the mocked checkNextSpeaker function and configure it to trigger infinite loop
|
|
886
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
887
|
+
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
|
|
888
|
+
mockCheckNextSpeaker.mockResolvedValue({
|
|
889
|
+
next_speaker: 'model',
|
|
890
|
+
reasoning: 'Test case - always continue',
|
|
891
|
+
});
|
|
892
|
+
// Mock Turn to have no pending tool calls (which would allow nextSpeaker check)
|
|
893
|
+
const mockStream = (async function* () {
|
|
894
|
+
yield { type: 'content', value: 'Continue...' };
|
|
895
|
+
})();
|
|
896
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
897
|
+
const mockChat = {
|
|
898
|
+
addHistory: vi.fn(),
|
|
899
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
900
|
+
getLastPromptTokenCount: vi.fn(),
|
|
901
|
+
};
|
|
902
|
+
client['chat'] = mockChat;
|
|
903
|
+
// Use a signal that never gets aborted
|
|
904
|
+
const abortController = new AbortController();
|
|
905
|
+
const signal = abortController.signal;
|
|
906
|
+
// Act - Start the stream with an extremely high turns value
|
|
907
|
+
// This simulates a case where the turns protection is bypassed
|
|
908
|
+
const stream = client.sendMessageStream([{ text: 'Start conversation' }], signal, 'prompt-id-3', Number.MAX_SAFE_INTEGER);
|
|
909
|
+
// Count how many stream events we get
|
|
910
|
+
let eventCount = 0;
|
|
911
|
+
const maxTestIterations = 1000; // Higher limit to show the loop continues
|
|
912
|
+
// Consume the stream and count iterations
|
|
913
|
+
try {
|
|
914
|
+
while (true) {
|
|
915
|
+
const result = await stream.next();
|
|
916
|
+
if (result.done) {
|
|
917
|
+
break;
|
|
918
|
+
}
|
|
919
|
+
eventCount++;
|
|
920
|
+
// This test should hit this limit, demonstrating the infinite loop
|
|
921
|
+
if (eventCount > maxTestIterations) {
|
|
922
|
+
abortController.abort();
|
|
923
|
+
// This is the expected behavior - we hit the infinite loop
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
catch (_) {
|
|
929
|
+
// If the test framework times out, that also demonstrates the infinite loop
|
|
930
|
+
}
|
|
931
|
+
// Assert that the fix works - the loop should stop at MAX_TURNS
|
|
932
|
+
const callCount = mockCheckNextSpeaker.mock.calls.length;
|
|
933
|
+
// With the fix: even when turns is set to a very high value,
|
|
934
|
+
// the loop should stop at MAX_TURNS (100)
|
|
935
|
+
expect(callCount).toBeLessThanOrEqual(100); // Should not exceed MAX_TURNS
|
|
936
|
+
expect(eventCount).toBeLessThanOrEqual(200); // Should have reasonable number of events
|
|
937
|
+
});
|
|
938
|
+
it('should yield ContextWindowWillOverflow when the context window is about to overflow', async () => {
|
|
939
|
+
// Arrange
|
|
940
|
+
const MOCKED_TOKEN_LIMIT = 1000;
|
|
941
|
+
vi.mocked(tokenLimit).mockReturnValue(MOCKED_TOKEN_LIMIT);
|
|
942
|
+
// Set last prompt token count
|
|
943
|
+
const lastPromptTokenCount = 900;
|
|
944
|
+
const mockChat = {
|
|
945
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
946
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
947
|
+
};
|
|
948
|
+
client['chat'] = mockChat;
|
|
949
|
+
// Remaining = 100. Threshold (95%) = 95.
|
|
950
|
+
// We need a request > 95 tokens.
|
|
951
|
+
// A string of length 400 is roughly 100 tokens.
|
|
952
|
+
const longText = 'a'.repeat(400);
|
|
953
|
+
const request = [{ text: longText }];
|
|
954
|
+
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
955
|
+
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
956
|
+
const remainingTokenCount = MOCKED_TOKEN_LIMIT - lastPromptTokenCount;
|
|
957
|
+
// Mock tryCompressChat to not compress
|
|
958
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
959
|
+
originalTokenCount: lastPromptTokenCount,
|
|
960
|
+
newTokenCount: lastPromptTokenCount,
|
|
961
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
962
|
+
});
|
|
963
|
+
// Act
|
|
964
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'prompt-id-overflow');
|
|
965
|
+
const events = await fromAsync(stream);
|
|
966
|
+
// Assert
|
|
967
|
+
expect(events).toContainEqual({
|
|
968
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
969
|
+
value: {
|
|
970
|
+
estimatedRequestTokenCount,
|
|
971
|
+
remainingTokenCount,
|
|
972
|
+
},
|
|
973
|
+
});
|
|
974
|
+
// Ensure turn.run is not called
|
|
975
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
976
|
+
});
|
|
977
|
+
it("should use the sticky model's token limit for the overflow check", async () => {
|
|
978
|
+
// Arrange
|
|
979
|
+
const STICKY_MODEL = 'gemini-1.5-flash';
|
|
980
|
+
const STICKY_MODEL_LIMIT = 1000;
|
|
981
|
+
const CONFIG_MODEL_LIMIT = 2000;
|
|
982
|
+
// Set up token limits
|
|
983
|
+
vi.mocked(tokenLimit).mockImplementation((model) => {
|
|
984
|
+
if (model === STICKY_MODEL)
|
|
985
|
+
return STICKY_MODEL_LIMIT;
|
|
986
|
+
return CONFIG_MODEL_LIMIT;
|
|
987
|
+
});
|
|
988
|
+
// Set the sticky model
|
|
989
|
+
client['currentSequenceModel'] = STICKY_MODEL;
|
|
990
|
+
// Set token count
|
|
991
|
+
const lastPromptTokenCount = 900;
|
|
992
|
+
const mockChat = {
|
|
993
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
994
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
995
|
+
};
|
|
996
|
+
client['chat'] = mockChat;
|
|
997
|
+
// Remaining (sticky) = 100. Threshold (95%) = 95.
|
|
998
|
+
// We need a request > 95 tokens.
|
|
999
|
+
const longText = 'a'.repeat(400);
|
|
1000
|
+
const request = [{ text: longText }];
|
|
1001
|
+
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
1002
|
+
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
1003
|
+
const remainingTokenCount = STICKY_MODEL_LIMIT - lastPromptTokenCount;
|
|
1004
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
1005
|
+
originalTokenCount: lastPromptTokenCount,
|
|
1006
|
+
newTokenCount: lastPromptTokenCount,
|
|
1007
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
1008
|
+
});
|
|
1009
|
+
// Act
|
|
1010
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'test-session-id');
|
|
1011
|
+
const events = await fromAsync(stream);
|
|
1012
|
+
// Assert
|
|
1013
|
+
// Should overflow based on the sticky model's limit
|
|
1014
|
+
expect(events).toContainEqual({
|
|
1015
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
1016
|
+
value: {
|
|
1017
|
+
estimatedRequestTokenCount,
|
|
1018
|
+
remainingTokenCount,
|
|
1019
|
+
},
|
|
1020
|
+
});
|
|
1021
|
+
expect(tokenLimit).toHaveBeenCalledWith(STICKY_MODEL);
|
|
1022
|
+
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
1023
|
+
});
|
|
1024
|
+
it('should not trigger overflow warning for requests with large binary data (PDFs/images)', async () => {
|
|
1025
|
+
// Arrange
|
|
1026
|
+
const MOCKED_TOKEN_LIMIT = 1000000; // 1M tokens
|
|
1027
|
+
vi.mocked(tokenLimit).mockReturnValue(MOCKED_TOKEN_LIMIT);
|
|
1028
|
+
const lastPromptTokenCount = 10000;
|
|
1029
|
+
const mockChat = {
|
|
1030
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
1031
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1032
|
+
};
|
|
1033
|
+
client['chat'] = mockChat;
|
|
1034
|
+
// Simulate a PDF file with large base64 data (11MB when encoded)
|
|
1035
|
+
// In the old implementation, this would incorrectly estimate ~2.7M tokens
|
|
1036
|
+
// In the new implementation, only the text part is counted
|
|
1037
|
+
const largePdfBase64 = 'A'.repeat(11 * 1024 * 1024);
|
|
1038
|
+
const request = [
|
|
1039
|
+
{ text: 'Please analyze this PDF document' }, // ~35 chars = ~8 tokens
|
|
1040
|
+
{
|
|
1041
|
+
inlineData: {
|
|
1042
|
+
mimeType: 'application/pdf',
|
|
1043
|
+
data: largePdfBase64, // This should be ignored in token estimation
|
|
1044
|
+
},
|
|
1045
|
+
},
|
|
1046
|
+
];
|
|
1047
|
+
// Mock tryCompressChat to not compress
|
|
1048
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
1049
|
+
originalTokenCount: lastPromptTokenCount,
|
|
1050
|
+
newTokenCount: lastPromptTokenCount,
|
|
1051
|
+
compressionStatus: CompressionStatus.NOOP,
|
|
1052
|
+
});
|
|
1053
|
+
// Mock Turn.run to simulate successful processing
|
|
1054
|
+
const mockStream = (async function* () {
|
|
1055
|
+
yield { type: 'content', value: 'Analysis complete' };
|
|
1056
|
+
})();
|
|
1057
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1058
|
+
// Act
|
|
1059
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'prompt-id-pdf-test');
|
|
1060
|
+
const events = await fromAsync(stream);
|
|
1061
|
+
// Assert
|
|
1062
|
+
// Should NOT contain overflow warning
|
|
1063
|
+
expect(events).not.toContainEqual(expect.objectContaining({
|
|
1064
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
1065
|
+
}));
|
|
1066
|
+
// Turn.run should be called (processing should continue)
|
|
1067
|
+
expect(mockTurnRunFn).toHaveBeenCalled();
|
|
1068
|
+
});
|
|
1069
|
+
describe('Model Routing', () => {
|
|
1070
|
+
let mockRouterService;
|
|
1071
|
+
beforeEach(() => {
|
|
1072
|
+
mockRouterService = {
|
|
1073
|
+
route: vi
|
|
1074
|
+
.fn()
|
|
1075
|
+
.mockResolvedValue({ model: 'routed-model', reason: 'test' }),
|
|
1076
|
+
};
|
|
1077
|
+
vi.mocked(mockConfig.getModelRouterService).mockReturnValue(mockRouterService);
|
|
1078
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
1079
|
+
yield { type: 'content', value: 'Hello' };
|
|
1080
|
+
})());
|
|
1081
|
+
const mockChat = {
|
|
1082
|
+
addHistory: vi.fn(),
|
|
1083
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1084
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1085
|
+
};
|
|
1086
|
+
client['chat'] = mockChat;
|
|
1087
|
+
});
|
|
1088
|
+
it('should use the model router service to select a model on the first turn', async () => {
|
|
1089
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1090
|
+
await fromAsync(stream); // consume stream
|
|
1091
|
+
expect(mockConfig.getModelRouterService).toHaveBeenCalled();
|
|
1092
|
+
expect(mockRouterService.route).toHaveBeenCalled();
|
|
1093
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1094
|
+
});
|
|
1095
|
+
it('should use the same model for subsequent turns in the same prompt (stickiness)', async () => {
|
|
1096
|
+
// First turn
|
|
1097
|
+
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1098
|
+
await fromAsync(stream);
|
|
1099
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1100
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1101
|
+
// Second turn
|
|
1102
|
+
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-1');
|
|
1103
|
+
await fromAsync(stream);
|
|
1104
|
+
// Router should not be called again
|
|
1105
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1106
|
+
// Should stick to the first model
|
|
1107
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Continue' }], expect.any(AbortSignal));
|
|
1108
|
+
});
|
|
1109
|
+
it('should reset the sticky model and re-route when the prompt_id changes', async () => {
|
|
1110
|
+
// First prompt
|
|
1111
|
+
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1112
|
+
await fromAsync(stream);
|
|
1113
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1114
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1115
|
+
// New prompt
|
|
1116
|
+
mockRouterService.route.mockResolvedValue({
|
|
1117
|
+
model: 'new-routed-model',
|
|
1118
|
+
reason: 'test',
|
|
1119
|
+
});
|
|
1120
|
+
stream = client.sendMessageStream([{ text: 'A new topic' }], new AbortController().signal, 'prompt-2');
|
|
1121
|
+
await fromAsync(stream);
|
|
1122
|
+
// Router should be called again for the new prompt
|
|
1123
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(2);
|
|
1124
|
+
// Should use the newly routed model
|
|
1125
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'new-routed-model' }, [{ text: 'A new topic' }], expect.any(AbortSignal));
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1128
|
+
it('should use getGlobalMemory for system instruction when JIT is enabled', async () => {
|
|
1129
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(true);
|
|
1130
|
+
vi.mocked(mockConfig.getGlobalMemory).mockReturnValue('Global JIT Memory');
|
|
1131
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Full JIT Memory');
|
|
1132
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1133
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1134
|
+
await client.updateSystemInstruction();
|
|
1135
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Global JIT Memory');
|
|
1136
|
+
});
|
|
1137
|
+
it('should use getUserMemory for system instruction when JIT is disabled', async () => {
|
|
1138
|
+
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(false);
|
|
1139
|
+
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Legacy Memory');
|
|
1140
|
+
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1141
|
+
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1142
|
+
await client.updateSystemInstruction();
|
|
1143
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Legacy Memory');
|
|
1144
|
+
});
|
|
1145
|
+
it('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received', async () => {
|
|
1146
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1147
|
+
// Arrange
|
|
1148
|
+
const mockStream1 = (async function* () {
|
|
1149
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1150
|
+
})();
|
|
1151
|
+
const mockStream2 = (async function* () {
|
|
1152
|
+
yield { type: GeminiEventType.Content, value: 'Continued content' };
|
|
1153
|
+
})();
|
|
1154
|
+
mockTurnRunFn
|
|
1155
|
+
.mockReturnValueOnce(mockStream1)
|
|
1156
|
+
.mockReturnValueOnce(mockStream2);
|
|
1157
|
+
const mockChat = {
|
|
1158
|
+
addHistory: vi.fn(),
|
|
1159
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1160
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1161
|
+
};
|
|
1162
|
+
client['chat'] = mockChat;
|
|
1163
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
1164
|
+
const promptId = 'prompt-id-invalid-stream';
|
|
1165
|
+
const signal = new AbortController().signal;
|
|
1166
|
+
// Act
|
|
1167
|
+
const stream = client.sendMessageStream(initialRequest, signal, promptId);
|
|
1168
|
+
const events = await fromAsync(stream);
|
|
1169
|
+
// Assert
|
|
1170
|
+
expect(events).toEqual([
|
|
1171
|
+
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1172
|
+
{ type: GeminiEventType.InvalidStream },
|
|
1173
|
+
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1174
|
+
{ type: GeminiEventType.Content, value: 'Continued content' },
|
|
1175
|
+
]);
|
|
1176
|
+
// Verify that turn.run was called twice
|
|
1177
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
1178
|
+
// First call with original request
|
|
1179
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(1, { model: 'default-routed-model' }, initialRequest, expect.any(AbortSignal));
|
|
1180
|
+
// Second call with "Please continue."
|
|
1181
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, { model: 'default-routed-model' }, [{ text: 'System: Please continue.' }], expect.any(AbortSignal));
|
|
1182
|
+
});
|
|
1183
|
+
it('should not recursively call sendMessageStream with "Please continue." when InvalidStream event is received and flag is false', async () => {
|
|
1184
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(false);
|
|
1185
|
+
// Arrange
|
|
1186
|
+
const mockStream1 = (async function* () {
|
|
1187
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1188
|
+
})();
|
|
1189
|
+
mockTurnRunFn.mockReturnValueOnce(mockStream1);
|
|
1190
|
+
const mockChat = {
|
|
1191
|
+
addHistory: vi.fn(),
|
|
1192
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1193
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1194
|
+
};
|
|
1195
|
+
client['chat'] = mockChat;
|
|
1196
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
1197
|
+
const promptId = 'prompt-id-invalid-stream';
|
|
1198
|
+
const signal = new AbortController().signal;
|
|
1199
|
+
// Act
|
|
1200
|
+
const stream = client.sendMessageStream(initialRequest, signal, promptId);
|
|
1201
|
+
const events = await fromAsync(stream);
|
|
1202
|
+
// Assert
|
|
1203
|
+
expect(events).toEqual([
|
|
1204
|
+
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1205
|
+
{ type: GeminiEventType.InvalidStream },
|
|
1206
|
+
]);
|
|
1207
|
+
// Verify that turn.run was called only once
|
|
1208
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
|
1209
|
+
});
|
|
1210
|
+
it('should stop recursing after one retry when InvalidStream events are repeatedly received', async () => {
|
|
1211
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1212
|
+
// Arrange
|
|
1213
|
+
// Always return a new invalid stream
|
|
1214
|
+
mockTurnRunFn.mockImplementation(() => (async function* () {
|
|
1215
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1216
|
+
})());
|
|
1217
|
+
const mockChat = {
|
|
1218
|
+
addHistory: vi.fn(),
|
|
1219
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1220
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1221
|
+
};
|
|
1222
|
+
client['chat'] = mockChat;
|
|
1223
|
+
const initialRequest = [{ text: 'Hi' }];
|
|
1224
|
+
const promptId = 'prompt-id-infinite-invalid-stream';
|
|
1225
|
+
const signal = new AbortController().signal;
|
|
1226
|
+
// Act
|
|
1227
|
+
const stream = client.sendMessageStream(initialRequest, signal, promptId);
|
|
1228
|
+
const events = await fromAsync(stream);
|
|
1229
|
+
// Assert
|
|
1230
|
+
// We expect 4 events (model_info + original + model_info + 1 retry)
|
|
1231
|
+
expect(events.length).toBe(4);
|
|
1232
|
+
expect(events
|
|
1233
|
+
.filter((e) => e.type !== GeminiEventType.ModelInfo)
|
|
1234
|
+
.every((e) => e.type === GeminiEventType.InvalidStream)).toBe(true);
|
|
1235
|
+
// Verify that turn.run was called twice
|
|
1236
|
+
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
1237
|
+
});
|
|
1238
|
+
describe('Editor context delta', () => {
|
|
1239
|
+
const mockStream = (async function* () {
|
|
1240
|
+
yield { type: 'content', value: 'Hello' };
|
|
1241
|
+
})();
|
|
1242
|
+
beforeEach(() => {
|
|
1243
|
+
client['forceFullIdeContext'] = false; // Reset before each delta test
|
|
1244
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
1245
|
+
originalTokenCount: 0,
|
|
1246
|
+
newTokenCount: 0,
|
|
1247
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
1248
|
+
});
|
|
1249
|
+
vi.spyOn(client['config'], 'getIdeMode').mockReturnValue(true);
|
|
1250
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1251
|
+
const mockChat = {
|
|
1252
|
+
addHistory: vi.fn(),
|
|
1253
|
+
setHistory: vi.fn(),
|
|
1254
|
+
// Assume history is not empty for delta checks
|
|
1255
|
+
getHistory: vi
|
|
1256
|
+
.fn()
|
|
1257
|
+
.mockReturnValue([
|
|
1258
|
+
{ role: 'user', parts: [{ text: 'previous message' }] },
|
|
1259
|
+
]),
|
|
1260
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1261
|
+
};
|
|
1262
|
+
client['chat'] = mockChat;
|
|
1263
|
+
});
|
|
1264
|
+
const testCases = [
|
|
1265
|
+
{
|
|
1266
|
+
description: 'sends delta when active file changes',
|
|
1267
|
+
previousActiveFile: {
|
|
1268
|
+
path: '/path/to/old/file.ts',
|
|
1269
|
+
cursor: { line: 5, character: 10 },
|
|
1270
|
+
selectedText: 'hello',
|
|
1271
|
+
},
|
|
1272
|
+
currentActiveFile: {
|
|
1273
|
+
path: '/path/to/active/file.ts',
|
|
1274
|
+
cursor: { line: 5, character: 10 },
|
|
1275
|
+
selectedText: 'hello',
|
|
1276
|
+
},
|
|
1277
|
+
shouldSendContext: true,
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
description: 'sends delta when cursor line changes',
|
|
1281
|
+
previousActiveFile: {
|
|
1282
|
+
path: '/path/to/active/file.ts',
|
|
1283
|
+
cursor: { line: 1, character: 10 },
|
|
1284
|
+
selectedText: 'hello',
|
|
1285
|
+
},
|
|
1286
|
+
currentActiveFile: {
|
|
1287
|
+
path: '/path/to/active/file.ts',
|
|
1288
|
+
cursor: { line: 5, character: 10 },
|
|
1289
|
+
selectedText: 'hello',
|
|
1290
|
+
},
|
|
1291
|
+
shouldSendContext: true,
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
description: 'sends delta when cursor character changes',
|
|
1295
|
+
previousActiveFile: {
|
|
1296
|
+
path: '/path/to/active/file.ts',
|
|
1297
|
+
cursor: { line: 5, character: 1 },
|
|
1298
|
+
selectedText: 'hello',
|
|
1299
|
+
},
|
|
1300
|
+
currentActiveFile: {
|
|
1301
|
+
path: '/path/to/active/file.ts',
|
|
1302
|
+
cursor: { line: 5, character: 10 },
|
|
1303
|
+
selectedText: 'hello',
|
|
1304
|
+
},
|
|
1305
|
+
shouldSendContext: true,
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
description: 'sends delta when selected text changes',
|
|
1309
|
+
previousActiveFile: {
|
|
1310
|
+
path: '/path/to/active/file.ts',
|
|
1311
|
+
cursor: { line: 5, character: 10 },
|
|
1312
|
+
selectedText: 'world',
|
|
1313
|
+
},
|
|
1314
|
+
currentActiveFile: {
|
|
1315
|
+
path: '/path/to/active/file.ts',
|
|
1316
|
+
cursor: { line: 5, character: 10 },
|
|
1317
|
+
selectedText: 'hello',
|
|
1318
|
+
},
|
|
1319
|
+
shouldSendContext: true,
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
description: 'sends delta when selected text is added',
|
|
1323
|
+
previousActiveFile: {
|
|
1324
|
+
path: '/path/to/active/file.ts',
|
|
1325
|
+
cursor: { line: 5, character: 10 },
|
|
1326
|
+
},
|
|
1327
|
+
currentActiveFile: {
|
|
1328
|
+
path: '/path/to/active/file.ts',
|
|
1329
|
+
cursor: { line: 5, character: 10 },
|
|
1330
|
+
selectedText: 'hello',
|
|
1331
|
+
},
|
|
1332
|
+
shouldSendContext: true,
|
|
1333
|
+
},
|
|
1334
|
+
{
|
|
1335
|
+
description: 'sends delta when selected text is removed',
|
|
1336
|
+
previousActiveFile: {
|
|
1337
|
+
path: '/path/to/active/file.ts',
|
|
1338
|
+
cursor: { line: 5, character: 10 },
|
|
1339
|
+
selectedText: 'hello',
|
|
1340
|
+
},
|
|
1341
|
+
currentActiveFile: {
|
|
1342
|
+
path: '/path/to/active/file.ts',
|
|
1343
|
+
cursor: { line: 5, character: 10 },
|
|
1344
|
+
},
|
|
1345
|
+
shouldSendContext: true,
|
|
1346
|
+
},
|
|
1347
|
+
{
|
|
1348
|
+
description: 'does not send context when nothing changes',
|
|
1349
|
+
previousActiveFile: {
|
|
1350
|
+
path: '/path/to/active/file.ts',
|
|
1351
|
+
cursor: { line: 5, character: 10 },
|
|
1352
|
+
selectedText: 'hello',
|
|
1353
|
+
},
|
|
1354
|
+
currentActiveFile: {
|
|
1355
|
+
path: '/path/to/active/file.ts',
|
|
1356
|
+
cursor: { line: 5, character: 10 },
|
|
1357
|
+
selectedText: 'hello',
|
|
1358
|
+
},
|
|
1359
|
+
shouldSendContext: false,
|
|
1360
|
+
},
|
|
1361
|
+
];
|
|
1362
|
+
it.each(testCases)('$description', async ({ previousActiveFile, currentActiveFile, shouldSendContext, }) => {
|
|
1363
|
+
// Setup previous context
|
|
1364
|
+
client['lastSentIdeContext'] = {
|
|
1365
|
+
workspaceState: {
|
|
1366
|
+
openFiles: [
|
|
1367
|
+
{
|
|
1368
|
+
path: previousActiveFile.path,
|
|
1369
|
+
cursor: previousActiveFile.cursor,
|
|
1370
|
+
selectedText: previousActiveFile.selectedText,
|
|
1371
|
+
isActive: true,
|
|
1372
|
+
timestamp: Date.now() - 1000,
|
|
1373
|
+
},
|
|
1374
|
+
],
|
|
1375
|
+
},
|
|
1376
|
+
};
|
|
1377
|
+
// Setup current context
|
|
1378
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
1379
|
+
workspaceState: {
|
|
1380
|
+
openFiles: [
|
|
1381
|
+
{
|
|
1382
|
+
...currentActiveFile,
|
|
1383
|
+
isActive: true,
|
|
1384
|
+
timestamp: Date.now(),
|
|
1385
|
+
},
|
|
1386
|
+
],
|
|
1387
|
+
},
|
|
1388
|
+
});
|
|
1389
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-delta');
|
|
1390
|
+
for await (const _ of stream) {
|
|
1391
|
+
// consume stream
|
|
1392
|
+
}
|
|
1393
|
+
const mockChat = client['chat'];
|
|
1394
|
+
if (shouldSendContext) {
|
|
1395
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith(expect.objectContaining({
|
|
1396
|
+
parts: expect.arrayContaining([
|
|
1397
|
+
expect.objectContaining({
|
|
1398
|
+
text: expect.stringContaining("Here is a summary of changes in the user's editor context"),
|
|
1399
|
+
}),
|
|
1400
|
+
]),
|
|
1401
|
+
}));
|
|
1402
|
+
}
|
|
1403
|
+
else {
|
|
1404
|
+
expect(mockChat.addHistory).not.toHaveBeenCalled();
|
|
1405
|
+
}
|
|
1406
|
+
});
|
|
1407
|
+
it('sends full context when history is cleared, even if editor state is unchanged', async () => {
|
|
1408
|
+
const activeFile = {
|
|
1409
|
+
path: '/path/to/active/file.ts',
|
|
1410
|
+
cursor: { line: 5, character: 10 },
|
|
1411
|
+
selectedText: 'hello',
|
|
1412
|
+
};
|
|
1413
|
+
// Setup previous context
|
|
1414
|
+
client['lastSentIdeContext'] = {
|
|
1415
|
+
workspaceState: {
|
|
1416
|
+
openFiles: [
|
|
1417
|
+
{
|
|
1418
|
+
path: activeFile.path,
|
|
1419
|
+
cursor: activeFile.cursor,
|
|
1420
|
+
selectedText: activeFile.selectedText,
|
|
1421
|
+
isActive: true,
|
|
1422
|
+
timestamp: Date.now() - 1000,
|
|
1423
|
+
},
|
|
1424
|
+
],
|
|
1425
|
+
},
|
|
1426
|
+
};
|
|
1427
|
+
// Setup current context (same as previous)
|
|
1428
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
1429
|
+
workspaceState: {
|
|
1430
|
+
openFiles: [
|
|
1431
|
+
{ ...activeFile, isActive: true, timestamp: Date.now() },
|
|
1432
|
+
],
|
|
1433
|
+
},
|
|
1434
|
+
});
|
|
1435
|
+
// Make history empty
|
|
1436
|
+
const mockChat = client['chat'];
|
|
1437
|
+
mockChat.getHistory.mockReturnValue([]);
|
|
1438
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-history-cleared');
|
|
1439
|
+
for await (const _ of stream) {
|
|
1440
|
+
// consume stream
|
|
1441
|
+
}
|
|
1442
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith(expect.objectContaining({
|
|
1443
|
+
parts: expect.arrayContaining([
|
|
1444
|
+
expect.objectContaining({
|
|
1445
|
+
text: expect.stringContaining("Here is the user's editor context"),
|
|
1446
|
+
}),
|
|
1447
|
+
]),
|
|
1448
|
+
}));
|
|
1449
|
+
// Also verify it's the full context, not a delta.
|
|
1450
|
+
const call = mockChat.addHistory.mock.calls[0][0];
|
|
1451
|
+
const contextText = call.parts[0].text;
|
|
1452
|
+
const contextJson = JSON.parse(contextText.match(/```json\n(.*)\n```/s)[1]);
|
|
1453
|
+
expect(contextJson).toHaveProperty('activeFile');
|
|
1454
|
+
expect(contextJson.activeFile.path).toBe('/path/to/active/file.ts');
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
describe('Availability Service Integration', () => {
|
|
1458
|
+
let mockAvailabilityService;
|
|
1459
|
+
beforeEach(() => {
|
|
1460
|
+
mockAvailabilityService = createAvailabilityServiceMock();
|
|
1461
|
+
vi.mocked(mockConfig.getModelAvailabilityService).mockReturnValue(mockAvailabilityService);
|
|
1462
|
+
vi.mocked(mockConfig.setActiveModel).mockClear();
|
|
1463
|
+
mockRouterService.route.mockResolvedValue({
|
|
1464
|
+
model: 'model-a',
|
|
1465
|
+
reason: 'test',
|
|
1466
|
+
});
|
|
1467
|
+
vi.mocked(mockConfig.getModelRouterService).mockReturnValue(mockRouterService);
|
|
1468
|
+
vi.spyOn(policyCatalog, 'getModelPolicyChain').mockReturnValue([
|
|
1469
|
+
{
|
|
1470
|
+
model: 'model-a',
|
|
1471
|
+
isLastResort: false,
|
|
1472
|
+
actions: {},
|
|
1473
|
+
stateTransitions: {},
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
model: 'model-b',
|
|
1477
|
+
isLastResort: true,
|
|
1478
|
+
actions: {},
|
|
1479
|
+
stateTransitions: {},
|
|
1480
|
+
},
|
|
1481
|
+
]);
|
|
1482
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
1483
|
+
yield { type: 'content', value: 'Hello' };
|
|
1484
|
+
})());
|
|
1485
|
+
});
|
|
1486
|
+
it('should select first available model, set active, and not consume sticky attempt (done lower in chain)', async () => {
|
|
1487
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1488
|
+
selectedModel: 'model-a',
|
|
1489
|
+
attempts: 1,
|
|
1490
|
+
skipped: [],
|
|
1491
|
+
});
|
|
1492
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1493
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail');
|
|
1494
|
+
await fromAsync(stream);
|
|
1495
|
+
expect(mockAvailabilityService.selectFirstAvailable).toHaveBeenCalledWith(['model-a', 'model-b']);
|
|
1496
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-a');
|
|
1497
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1498
|
+
// Ensure turn.run used the selected model
|
|
1499
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith(expect.objectContaining({ model: 'model-a' }), expect.anything(), expect.anything());
|
|
1500
|
+
});
|
|
1501
|
+
it('should default to last resort model if selection returns null', async () => {
|
|
1502
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1503
|
+
selectedModel: null,
|
|
1504
|
+
skipped: [],
|
|
1505
|
+
});
|
|
1506
|
+
vi.mocked(mockConfig.getModel).mockReturnValue(DEFAULT_GEMINI_MODEL_AUTO);
|
|
1507
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-avail-fallback');
|
|
1508
|
+
await fromAsync(stream);
|
|
1509
|
+
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-b'); // Last resort
|
|
1510
|
+
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1511
|
+
});
|
|
1512
|
+
it('should reset turn on new message stream', async () => {
|
|
1513
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1514
|
+
selectedModel: 'model-a',
|
|
1515
|
+
skipped: [],
|
|
1516
|
+
});
|
|
1517
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-reset');
|
|
1518
|
+
await fromAsync(stream);
|
|
1519
|
+
expect(mockConfig.resetTurn).toHaveBeenCalled();
|
|
1520
|
+
});
|
|
1521
|
+
it('should NOT reset turn on invalid stream retry', async () => {
|
|
1522
|
+
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
1523
|
+
selectedModel: 'model-a',
|
|
1524
|
+
skipped: [],
|
|
1525
|
+
});
|
|
1526
|
+
// We simulate a retry by calling sendMessageStream with isInvalidStreamRetry=true
|
|
1527
|
+
// But the public API doesn't expose that argument directly unless we use the private method or simulate the recursion.
|
|
1528
|
+
// We can simulate recursion by mocking turn run to return invalid stream once.
|
|
1529
|
+
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(true);
|
|
1530
|
+
const mockStream1 = (async function* () {
|
|
1531
|
+
yield { type: GeminiEventType.InvalidStream };
|
|
1532
|
+
})();
|
|
1533
|
+
const mockStream2 = (async function* () {
|
|
1534
|
+
yield { type: 'content', value: 'ok' };
|
|
1535
|
+
})();
|
|
1536
|
+
mockTurnRunFn
|
|
1537
|
+
.mockReturnValueOnce(mockStream1)
|
|
1538
|
+
.mockReturnValueOnce(mockStream2);
|
|
1539
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-retry');
|
|
1540
|
+
await fromAsync(stream);
|
|
1541
|
+
// resetTurn should be called once (for the initial call) but NOT for the recursive call
|
|
1542
|
+
expect(mockConfig.resetTurn).toHaveBeenCalledTimes(1);
|
|
1543
|
+
});
|
|
1544
|
+
});
|
|
1545
|
+
describe('IDE context with pending tool calls', () => {
|
|
1546
|
+
let mockChat;
|
|
1547
|
+
beforeEach(() => {
|
|
1548
|
+
vi.spyOn(client, 'tryCompressChat').mockResolvedValue({
|
|
1549
|
+
originalTokenCount: 0,
|
|
1550
|
+
newTokenCount: 0,
|
|
1551
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
1552
|
+
});
|
|
1553
|
+
const mockStream = (async function* () {
|
|
1554
|
+
yield { type: 'content', value: 'response' };
|
|
1555
|
+
})();
|
|
1556
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1557
|
+
mockChat = {
|
|
1558
|
+
addHistory: vi.fn(),
|
|
1559
|
+
getHistory: vi.fn().mockReturnValue([]), // Default empty history
|
|
1560
|
+
setHistory: vi.fn(),
|
|
1561
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1562
|
+
};
|
|
1563
|
+
client['chat'] = mockChat;
|
|
1564
|
+
vi.spyOn(client['config'], 'getIdeMode').mockReturnValue(true);
|
|
1565
|
+
vi.mocked(ideContextStore.get).mockReturnValue({
|
|
1566
|
+
workspaceState: {
|
|
1567
|
+
openFiles: [{ path: '/path/to/file.ts', timestamp: Date.now() }],
|
|
1568
|
+
},
|
|
1569
|
+
});
|
|
1570
|
+
});
|
|
1571
|
+
it('should NOT add IDE context when a tool call is pending', async () => {
|
|
1572
|
+
// Arrange: History ends with a functionCall from the model
|
|
1573
|
+
const historyWithPendingCall = [
|
|
1574
|
+
{ role: 'user', parts: [{ text: 'Please use a tool.' }] },
|
|
1575
|
+
{
|
|
1576
|
+
role: 'model',
|
|
1577
|
+
parts: [{ functionCall: { name: 'some_tool', args: {} } }],
|
|
1578
|
+
},
|
|
1579
|
+
];
|
|
1580
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(historyWithPendingCall);
|
|
1581
|
+
// Act: Simulate sending the tool's response back
|
|
1582
|
+
const stream = client.sendMessageStream([
|
|
1583
|
+
{
|
|
1584
|
+
functionResponse: {
|
|
1585
|
+
name: 'some_tool',
|
|
1586
|
+
response: { success: true },
|
|
1587
|
+
},
|
|
1588
|
+
},
|
|
1589
|
+
], new AbortController().signal, 'prompt-id-tool-response');
|
|
1590
|
+
for await (const _ of stream) {
|
|
1591
|
+
// consume stream to complete the call
|
|
1592
|
+
}
|
|
1593
|
+
// Assert: The IDE context message should NOT have been added to the history.
|
|
1594
|
+
expect(mockChat.addHistory).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
1595
|
+
parts: expect.arrayContaining([
|
|
1596
|
+
expect.objectContaining({
|
|
1597
|
+
text: expect.stringContaining("user's editor context"),
|
|
1598
|
+
}),
|
|
1599
|
+
]),
|
|
1600
|
+
}));
|
|
1601
|
+
});
|
|
1602
|
+
it('should add IDE context when no tool call is pending', async () => {
|
|
1603
|
+
// Arrange: History is normal, no pending calls
|
|
1604
|
+
const normalHistory = [
|
|
1605
|
+
{ role: 'user', parts: [{ text: 'A normal message.' }] },
|
|
1606
|
+
{ role: 'model', parts: [{ text: 'A normal response.' }] },
|
|
1607
|
+
];
|
|
1608
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(normalHistory);
|
|
1609
|
+
// Act
|
|
1610
|
+
const stream = client.sendMessageStream([{ text: 'Another normal message' }], new AbortController().signal, 'prompt-id-normal');
|
|
1611
|
+
for await (const _ of stream) {
|
|
1612
|
+
// consume stream
|
|
1613
|
+
}
|
|
1614
|
+
// Assert: The IDE context message SHOULD have been added.
|
|
1615
|
+
expect(mockChat.addHistory).toHaveBeenCalledWith(expect.objectContaining({
|
|
1616
|
+
role: 'user',
|
|
1617
|
+
parts: expect.arrayContaining([
|
|
1618
|
+
expect.objectContaining({
|
|
1619
|
+
text: expect.stringContaining("user's editor context"),
|
|
1620
|
+
}),
|
|
1621
|
+
]),
|
|
1622
|
+
}));
|
|
1623
|
+
});
|
|
1624
|
+
it('should send the latest IDE context on the next message after a skipped context', async () => {
|
|
1625
|
+
// --- Step 1: A tool call is pending, context should be skipped ---
|
|
1626
|
+
// Arrange: History ends with a functionCall
|
|
1627
|
+
const historyWithPendingCall = [
|
|
1628
|
+
{ role: 'user', parts: [{ text: 'Please use a tool.' }] },
|
|
1629
|
+
{
|
|
1630
|
+
role: 'model',
|
|
1631
|
+
parts: [{ functionCall: { name: 'some_tool', args: {} } }],
|
|
1632
|
+
},
|
|
1633
|
+
];
|
|
1634
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(historyWithPendingCall);
|
|
1635
|
+
// Arrange: Set the initial IDE context
|
|
1636
|
+
const initialIdeContext = {
|
|
1637
|
+
workspaceState: {
|
|
1638
|
+
openFiles: [{ path: '/path/to/fileA.ts', timestamp: Date.now() }],
|
|
1639
|
+
},
|
|
1640
|
+
};
|
|
1641
|
+
vi.mocked(ideContextStore.get).mockReturnValue(initialIdeContext);
|
|
1642
|
+
// Act: Send the tool response
|
|
1643
|
+
let stream = client.sendMessageStream([
|
|
1644
|
+
{
|
|
1645
|
+
functionResponse: {
|
|
1646
|
+
name: 'some_tool',
|
|
1647
|
+
response: { success: true },
|
|
1648
|
+
},
|
|
1649
|
+
},
|
|
1650
|
+
], new AbortController().signal, 'prompt-id-tool-response');
|
|
1651
|
+
for await (const _ of stream) {
|
|
1652
|
+
/* consume */
|
|
1653
|
+
}
|
|
1654
|
+
// Assert: The initial context was NOT sent
|
|
1655
|
+
expect(mockChat.addHistory).not.toHaveBeenCalledWith(expect.objectContaining({
|
|
1656
|
+
parts: expect.arrayContaining([
|
|
1657
|
+
expect.objectContaining({
|
|
1658
|
+
text: expect.stringContaining("user's editor context"),
|
|
1659
|
+
}),
|
|
1660
|
+
]),
|
|
1661
|
+
}));
|
|
1662
|
+
// --- Step 2: A new message is sent, latest context should be included ---
|
|
1663
|
+
// Arrange: The model has responded to the tool, and the user is sending a new message.
|
|
1664
|
+
const historyAfterToolResponse = [
|
|
1665
|
+
...historyWithPendingCall,
|
|
1666
|
+
{
|
|
1667
|
+
role: 'user',
|
|
1668
|
+
parts: [
|
|
1669
|
+
{
|
|
1670
|
+
functionResponse: {
|
|
1671
|
+
name: 'some_tool',
|
|
1672
|
+
response: { success: true },
|
|
1673
|
+
},
|
|
1674
|
+
},
|
|
1675
|
+
],
|
|
1676
|
+
},
|
|
1677
|
+
{ role: 'model', parts: [{ text: 'The tool ran successfully.' }] },
|
|
1678
|
+
];
|
|
1679
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(historyAfterToolResponse);
|
|
1680
|
+
vi.mocked(mockChat.addHistory).mockClear(); // Clear previous calls for the next assertion
|
|
1681
|
+
// Arrange: The IDE context has now changed
|
|
1682
|
+
const newIdeContext = {
|
|
1683
|
+
workspaceState: {
|
|
1684
|
+
openFiles: [{ path: '/path/to/fileB.ts', timestamp: Date.now() }],
|
|
1685
|
+
},
|
|
1686
|
+
};
|
|
1687
|
+
vi.mocked(ideContextStore.get).mockReturnValue(newIdeContext);
|
|
1688
|
+
// Act: Send a new, regular user message
|
|
1689
|
+
stream = client.sendMessageStream([{ text: 'Thanks!' }], new AbortController().signal, 'prompt-id-final');
|
|
1690
|
+
for await (const _ of stream) {
|
|
1691
|
+
/* consume */
|
|
1692
|
+
}
|
|
1693
|
+
// Assert: The NEW context was sent as a FULL context because there was no previously sent context.
|
|
1694
|
+
const addHistoryCalls = vi.mocked(mockChat.addHistory).mock.calls;
|
|
1695
|
+
const contextCall = addHistoryCalls.find((call) => JSON.stringify(call[0]).includes("user's editor context"));
|
|
1696
|
+
expect(contextCall).toBeDefined();
|
|
1697
|
+
expect(JSON.stringify(contextCall[0])).toContain("Here is the user's editor context as a JSON object");
|
|
1698
|
+
// Check that the sent context is the new one (fileB.ts)
|
|
1699
|
+
expect(JSON.stringify(contextCall[0])).toContain('fileB.ts');
|
|
1700
|
+
// Check that the sent context is NOT the old one (fileA.ts)
|
|
1701
|
+
expect(JSON.stringify(contextCall[0])).not.toContain('fileA.ts');
|
|
1702
|
+
});
|
|
1703
|
+
it('should send a context DELTA on the next message after a skipped context', async () => {
|
|
1704
|
+
// --- Step 0: Establish an initial context ---
|
|
1705
|
+
vi.mocked(mockChat.getHistory).mockReturnValue([]); // Start with empty history
|
|
1706
|
+
const contextA = {
|
|
1707
|
+
workspaceState: {
|
|
1708
|
+
openFiles: [
|
|
1709
|
+
{
|
|
1710
|
+
path: '/path/to/fileA.ts',
|
|
1711
|
+
isActive: true,
|
|
1712
|
+
timestamp: Date.now(),
|
|
1713
|
+
},
|
|
1714
|
+
],
|
|
1715
|
+
},
|
|
1716
|
+
};
|
|
1717
|
+
vi.mocked(ideContextStore.get).mockReturnValue(contextA);
|
|
1718
|
+
// Act: Send a regular message to establish the initial context
|
|
1719
|
+
let stream = client.sendMessageStream([{ text: 'Initial message' }], new AbortController().signal, 'prompt-id-initial');
|
|
1720
|
+
for await (const _ of stream) {
|
|
1721
|
+
/* consume */
|
|
1722
|
+
}
|
|
1723
|
+
// Assert: Full context for fileA.ts was sent and stored.
|
|
1724
|
+
const initialCall = vi.mocked(mockChat.addHistory).mock.calls[0][0];
|
|
1725
|
+
expect(JSON.stringify(initialCall)).toContain("user's editor context as a JSON object");
|
|
1726
|
+
expect(JSON.stringify(initialCall)).toContain('fileA.ts');
|
|
1727
|
+
// This implicitly tests that `lastSentIdeContext` is now set internally by the client.
|
|
1728
|
+
vi.mocked(mockChat.addHistory).mockClear();
|
|
1729
|
+
// --- Step 1: A tool call is pending, context should be skipped ---
|
|
1730
|
+
const historyWithPendingCall = [
|
|
1731
|
+
{ role: 'user', parts: [{ text: 'Please use a tool.' }] },
|
|
1732
|
+
{
|
|
1733
|
+
role: 'model',
|
|
1734
|
+
parts: [{ functionCall: { name: 'some_tool', args: {} } }],
|
|
1735
|
+
},
|
|
1736
|
+
];
|
|
1737
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(historyWithPendingCall);
|
|
1738
|
+
// Arrange: IDE context changes, but this should be skipped
|
|
1739
|
+
const contextB = {
|
|
1740
|
+
workspaceState: {
|
|
1741
|
+
openFiles: [
|
|
1742
|
+
{
|
|
1743
|
+
path: '/path/to/fileB.ts',
|
|
1744
|
+
isActive: true,
|
|
1745
|
+
timestamp: Date.now(),
|
|
1746
|
+
},
|
|
1747
|
+
],
|
|
1748
|
+
},
|
|
1749
|
+
};
|
|
1750
|
+
vi.mocked(ideContextStore.get).mockReturnValue(contextB);
|
|
1751
|
+
// Act: Send the tool response
|
|
1752
|
+
stream = client.sendMessageStream([
|
|
1753
|
+
{
|
|
1754
|
+
functionResponse: {
|
|
1755
|
+
name: 'some_tool',
|
|
1756
|
+
response: { success: true },
|
|
1757
|
+
},
|
|
1758
|
+
},
|
|
1759
|
+
], new AbortController().signal, 'prompt-id-tool-response');
|
|
1760
|
+
for await (const _ of stream) {
|
|
1761
|
+
/* consume */
|
|
1762
|
+
}
|
|
1763
|
+
// Assert: No context was sent
|
|
1764
|
+
expect(mockChat.addHistory).not.toHaveBeenCalled();
|
|
1765
|
+
// --- Step 2: A new message is sent, latest context DELTA should be included ---
|
|
1766
|
+
const historyAfterToolResponse = [
|
|
1767
|
+
...historyWithPendingCall,
|
|
1768
|
+
{
|
|
1769
|
+
role: 'user',
|
|
1770
|
+
parts: [
|
|
1771
|
+
{
|
|
1772
|
+
functionResponse: {
|
|
1773
|
+
name: 'some_tool',
|
|
1774
|
+
response: { success: true },
|
|
1775
|
+
},
|
|
1776
|
+
},
|
|
1777
|
+
],
|
|
1778
|
+
},
|
|
1779
|
+
{ role: 'model', parts: [{ text: 'The tool ran successfully.' }] },
|
|
1780
|
+
];
|
|
1781
|
+
vi.mocked(mockChat.getHistory).mockReturnValue(historyAfterToolResponse);
|
|
1782
|
+
// Arrange: The IDE context has changed again
|
|
1783
|
+
const contextC = {
|
|
1784
|
+
workspaceState: {
|
|
1785
|
+
openFiles: [
|
|
1786
|
+
// fileA is now closed, fileC is open
|
|
1787
|
+
{
|
|
1788
|
+
path: '/path/to/fileC.ts',
|
|
1789
|
+
isActive: true,
|
|
1790
|
+
timestamp: Date.now(),
|
|
1791
|
+
},
|
|
1792
|
+
],
|
|
1793
|
+
},
|
|
1794
|
+
};
|
|
1795
|
+
vi.mocked(ideContextStore.get).mockReturnValue(contextC);
|
|
1796
|
+
// Act: Send a new, regular user message
|
|
1797
|
+
stream = client.sendMessageStream([{ text: 'Thanks!' }], new AbortController().signal, 'prompt-id-final');
|
|
1798
|
+
for await (const _ of stream) {
|
|
1799
|
+
/* consume */
|
|
1800
|
+
}
|
|
1801
|
+
// Assert: The DELTA context was sent
|
|
1802
|
+
const finalCall = vi.mocked(mockChat.addHistory).mock.calls[0][0];
|
|
1803
|
+
expect(JSON.stringify(finalCall)).toContain('summary of changes');
|
|
1804
|
+
// The delta should reflect fileA being closed and fileC being opened.
|
|
1805
|
+
expect(JSON.stringify(finalCall)).toContain('filesClosed');
|
|
1806
|
+
expect(JSON.stringify(finalCall)).toContain('fileA.ts');
|
|
1807
|
+
expect(JSON.stringify(finalCall)).toContain('activeFileChanged');
|
|
1808
|
+
expect(JSON.stringify(finalCall)).toContain('fileC.ts');
|
|
1809
|
+
});
|
|
1810
|
+
});
|
|
1811
|
+
it('should not call checkNextSpeaker when turn.run() yields an error', async () => {
|
|
1812
|
+
// Arrange
|
|
1813
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
1814
|
+
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
|
|
1815
|
+
const mockStream = (async function* () {
|
|
1816
|
+
yield {
|
|
1817
|
+
type: GeminiEventType.Error,
|
|
1818
|
+
value: { error: { message: 'test error' } },
|
|
1819
|
+
};
|
|
1820
|
+
})();
|
|
1821
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1822
|
+
const mockChat = {
|
|
1823
|
+
addHistory: vi.fn(),
|
|
1824
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1825
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1826
|
+
};
|
|
1827
|
+
client['chat'] = mockChat;
|
|
1828
|
+
// Act
|
|
1829
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-error');
|
|
1830
|
+
for await (const _ of stream) {
|
|
1831
|
+
// consume stream
|
|
1832
|
+
}
|
|
1833
|
+
// Assert
|
|
1834
|
+
expect(mockCheckNextSpeaker).not.toHaveBeenCalled();
|
|
1835
|
+
});
|
|
1836
|
+
it('should not call checkNextSpeaker when turn.run() yields a value then an error', async () => {
|
|
1837
|
+
// Arrange
|
|
1838
|
+
const { checkNextSpeaker } = await import('../utils/nextSpeakerChecker.js');
|
|
1839
|
+
const mockCheckNextSpeaker = vi.mocked(checkNextSpeaker);
|
|
1840
|
+
const mockStream = (async function* () {
|
|
1841
|
+
yield { type: GeminiEventType.Content, value: 'some content' };
|
|
1842
|
+
yield {
|
|
1843
|
+
type: GeminiEventType.Error,
|
|
1844
|
+
value: { error: { message: 'test error' } },
|
|
1845
|
+
};
|
|
1846
|
+
})();
|
|
1847
|
+
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1848
|
+
const mockChat = {
|
|
1849
|
+
addHistory: vi.fn(),
|
|
1850
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1851
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1852
|
+
};
|
|
1853
|
+
client['chat'] = mockChat;
|
|
1854
|
+
// Act
|
|
1855
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-error');
|
|
1856
|
+
for await (const _ of stream) {
|
|
1857
|
+
// consume stream
|
|
1858
|
+
}
|
|
1859
|
+
// Assert
|
|
1860
|
+
expect(mockCheckNextSpeaker).not.toHaveBeenCalled();
|
|
1861
|
+
});
|
|
1862
|
+
it('should abort linked signal when loop is detected', async () => {
|
|
1863
|
+
// Arrange
|
|
1864
|
+
vi.spyOn(client['loopDetector'], 'turnStarted').mockResolvedValue(false);
|
|
1865
|
+
vi.spyOn(client['loopDetector'], 'addAndCheck')
|
|
1866
|
+
.mockReturnValueOnce(false)
|
|
1867
|
+
.mockReturnValueOnce(true);
|
|
1868
|
+
let capturedSignal;
|
|
1869
|
+
mockTurnRunFn.mockImplementation((_modelConfigKey, _request, signal) => {
|
|
1870
|
+
capturedSignal = signal;
|
|
1871
|
+
return (async function* () {
|
|
1872
|
+
yield { type: 'content', value: 'First event' };
|
|
1873
|
+
yield { type: 'content', value: 'Second event' };
|
|
1874
|
+
})();
|
|
1875
|
+
});
|
|
1876
|
+
const mockChat = {
|
|
1877
|
+
addHistory: vi.fn(),
|
|
1878
|
+
getHistory: vi.fn().mockReturnValue([]),
|
|
1879
|
+
getLastPromptTokenCount: vi.fn(),
|
|
1880
|
+
};
|
|
1881
|
+
client['chat'] = mockChat;
|
|
1882
|
+
// Act
|
|
1883
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-id-loop');
|
|
1884
|
+
const events = [];
|
|
1885
|
+
for await (const event of stream) {
|
|
1886
|
+
events.push(event);
|
|
1887
|
+
}
|
|
1888
|
+
// Assert
|
|
1889
|
+
expect(events).toContainEqual({ type: GeminiEventType.LoopDetected });
|
|
1890
|
+
expect(capturedSignal.aborted).toBe(true);
|
|
1891
|
+
});
|
|
1892
|
+
});
|
|
1893
|
+
describe('generateContent', () => {
|
|
1894
|
+
it('should call generateContent with the correct parameters', async () => {
|
|
1895
|
+
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1896
|
+
const abortSignal = new AbortController().signal;
|
|
1897
|
+
await client.generateContent({ model: 'test-model' }, contents, abortSignal);
|
|
1898
|
+
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1899
|
+
model: 'test-model',
|
|
1900
|
+
config: {
|
|
1901
|
+
abortSignal,
|
|
1902
|
+
systemInstruction: getCoreSystemPrompt({}, ''),
|
|
1903
|
+
temperature: 0,
|
|
1904
|
+
topP: 1,
|
|
1905
|
+
},
|
|
1906
|
+
contents,
|
|
1907
|
+
}, 'test-session-id');
|
|
1908
|
+
});
|
|
1909
|
+
it('should use current model from config for content generation', async () => {
|
|
1910
|
+
const initialModel = 'test-model';
|
|
1911
|
+
const contents = [{ role: 'user', parts: [{ text: 'test' }] }];
|
|
1912
|
+
await client.generateContent({ model: initialModel }, contents, new AbortController().signal);
|
|
1913
|
+
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(expect.objectContaining({
|
|
1914
|
+
model: initialModel,
|
|
1915
|
+
}), 'test-session-id');
|
|
1916
|
+
});
|
|
1917
|
+
});
|
|
1918
|
+
});
|
|
1919
|
+
//# sourceMappingURL=client.test.js.map
|