@office-ai/aioncli-core 0.26.0 → 0.30.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/docs/CONTRIBUTING.md +19 -10
- package/dist/docs/admin/enterprise-controls.md +115 -0
- package/dist/docs/architecture.md +3 -3
- package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
- package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
- package/dist/docs/bedrock-integration-plan.md +595 -0
- package/dist/docs/changelogs/index.md +187 -0
- package/dist/docs/changelogs/latest.md +299 -209
- package/dist/docs/changelogs/preview.md +353 -115
- package/dist/docs/cli/checkpointing.md +2 -3
- package/dist/docs/cli/cli-reference.md +115 -0
- package/dist/docs/cli/commands.md +360 -247
- package/dist/docs/cli/creating-skills.md +80 -0
- package/dist/docs/cli/custom-commands.md +12 -9
- package/dist/docs/cli/enterprise.md +25 -5
- package/dist/docs/cli/gemini-md.md +20 -12
- package/dist/docs/cli/headless.md +34 -372
- package/dist/docs/cli/index.md +123 -63
- package/dist/docs/cli/keyboard-shortcuts.md +95 -84
- package/dist/docs/cli/model-routing.md +7 -2
- package/dist/docs/cli/model.md +1 -1
- package/dist/docs/cli/plan-mode.md +190 -0
- package/dist/docs/cli/rewind.md +51 -0
- package/dist/docs/cli/sandbox.md +4 -3
- package/dist/docs/cli/session-management.md +61 -44
- package/dist/docs/cli/settings.md +95 -61
- package/dist/docs/cli/skills.md +49 -71
- package/dist/docs/cli/system-prompt.md +32 -0
- package/dist/docs/cli/telemetry.md +75 -4
- package/dist/docs/cli/themes.md +85 -53
- package/dist/docs/cli/tutorials/automation.md +187 -0
- package/dist/docs/cli/tutorials/file-management.md +142 -0
- package/dist/docs/cli/tutorials/mcp-setup.md +105 -0
- package/dist/docs/cli/tutorials/memory-management.md +126 -0
- package/dist/docs/cli/tutorials/session-management.md +105 -0
- package/dist/docs/cli/tutorials/shell-commands.md +107 -0
- package/dist/docs/cli/tutorials/skills-getting-started.md +36 -58
- package/dist/docs/cli/tutorials/task-planning.md +93 -0
- package/dist/docs/cli/tutorials/web-tools.md +78 -0
- package/dist/docs/cli/uninstall.md +18 -0
- package/dist/docs/core/concepts.md +137 -0
- package/dist/docs/core/index.md +6 -0
- package/dist/docs/core/memport.md +2 -0
- package/dist/docs/core/policy-engine.md +57 -7
- package/dist/docs/core/remote-agents.md +84 -0
- package/dist/docs/core/subagents.md +191 -0
- package/dist/docs/extensions/best-practices.md +188 -0
- package/dist/docs/extensions/index.md +38 -270
- package/dist/docs/extensions/reference.md +265 -0
- package/dist/docs/extensions/releasing.md +154 -0
- package/dist/docs/extensions/writing-extensions.md +292 -0
- package/dist/docs/get-started/authentication.md +162 -0
- package/dist/docs/get-started/configuration-v1.md +5 -11
- package/dist/docs/get-started/configuration.md +228 -99
- package/dist/docs/get-started/examples.md +39 -119
- package/dist/docs/get-started/gemini-3.md +2 -17
- package/dist/docs/get-started/index.md +6 -4
- package/dist/docs/get-started/installation.md +110 -77
- package/dist/docs/hooks/best-practices.md +219 -398
- package/dist/docs/hooks/index.md +99 -622
- package/dist/docs/hooks/reference.md +269 -115
- package/dist/docs/hooks/writing-hooks.md +203 -779
- package/dist/docs/index.md +146 -147
- package/dist/docs/local-development.md +1 -1
- package/dist/docs/releases.md +3 -3
- package/dist/docs/sidebar.json +105 -217
- package/dist/docs/tools/activate-skill.md +43 -0
- package/dist/docs/tools/ask-user.md +95 -0
- package/dist/docs/tools/file-system.md +48 -139
- package/dist/docs/tools/index.md +92 -85
- package/dist/docs/tools/internal-docs.md +46 -0
- package/dist/docs/tools/mcp-server.md +29 -5
- package/dist/docs/tools/memory.md +21 -40
- package/dist/docs/tools/planning.md +55 -0
- package/dist/docs/tools/shell.md +45 -89
- package/dist/docs/tools/todos.md +22 -44
- package/dist/docs/tools/web-fetch.md +22 -46
- package/dist/docs/tools/web-search.md +19 -29
- package/dist/docs/tos-privacy.md +1 -1
- package/dist/docs/troubleshooting.md +20 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.d.ts +4 -5
- package/dist/src/agents/a2a-client-manager.js +9 -131
- package/dist/src/agents/a2a-client-manager.js.map +1 -1
- package/dist/src/agents/a2a-client-manager.test.js +10 -27
- package/dist/src/agents/a2a-client-manager.test.js.map +1 -1
- package/dist/src/agents/a2aUtils.d.ts +3 -2
- package/dist/src/agents/a2aUtils.js +28 -26
- package/dist/src/agents/a2aUtils.js.map +1 -1
- package/dist/src/agents/a2aUtils.test.js +9 -9
- package/dist/src/agents/a2aUtils.test.js.map +1 -1
- package/dist/src/agents/acknowledgedAgents.d.ts +18 -0
- package/dist/src/agents/acknowledgedAgents.js +58 -0
- package/dist/src/agents/acknowledgedAgents.js.map +1 -0
- package/dist/src/agents/acknowledgedAgents.test.d.ts +6 -0
- package/dist/src/agents/acknowledgedAgents.test.js +70 -0
- package/dist/src/agents/acknowledgedAgents.test.js.map +1 -0
- package/dist/src/agents/agent-scheduler.d.ts +35 -0
- package/dist/src/agents/agent-scheduler.js +30 -0
- package/dist/src/agents/agent-scheduler.js.map +1 -0
- package/dist/src/agents/agent-scheduler.test.d.ts +6 -0
- package/dist/src/agents/agent-scheduler.test.js +56 -0
- package/dist/src/agents/agent-scheduler.test.js.map +1 -0
- package/dist/src/agents/agentLoader.d.ts +88 -0
- package/dist/src/agents/agentLoader.js +394 -0
- package/dist/src/agents/agentLoader.js.map +1 -0
- package/dist/src/agents/agentLoader.test.d.ts +6 -0
- package/dist/src/agents/agentLoader.test.js +458 -0
- package/dist/src/agents/agentLoader.test.js.map +1 -0
- package/dist/src/agents/auth-provider/base-provider.d.ts +40 -0
- package/dist/src/agents/auth-provider/base-provider.js +43 -0
- package/dist/src/agents/auth-provider/base-provider.js.map +1 -0
- package/dist/src/agents/auth-provider/base-provider.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/base-provider.test.js +107 -0
- package/dist/src/agents/auth-provider/base-provider.test.js.map +1 -0
- package/dist/src/agents/auth-provider/factory.d.ts +27 -0
- package/dist/src/agents/auth-provider/factory.js +161 -0
- package/dist/src/agents/auth-provider/factory.js.map +1 -0
- package/dist/src/agents/auth-provider/factory.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/factory.test.js +344 -0
- package/dist/src/agents/auth-provider/factory.test.js.map +1 -0
- package/dist/src/agents/auth-provider/types.d.ts +74 -0
- package/dist/src/agents/auth-provider/types.js +7 -0
- package/dist/src/agents/auth-provider/types.js.map +1 -0
- package/dist/src/agents/auth-provider/value-resolver.d.ts +29 -0
- package/dist/src/agents/auth-provider/value-resolver.js +85 -0
- package/dist/src/agents/auth-provider/value-resolver.js.map +1 -0
- package/dist/src/agents/auth-provider/value-resolver.test.d.ts +6 -0
- package/dist/src/agents/auth-provider/value-resolver.test.js +100 -0
- package/dist/src/agents/auth-provider/value-resolver.test.js.map +1 -0
- package/dist/src/agents/cli-help-agent.d.ts +24 -0
- package/dist/src/agents/cli-help-agent.js +80 -0
- package/dist/src/agents/cli-help-agent.js.map +1 -0
- package/dist/src/agents/cli-help-agent.test.d.ts +6 -0
- package/dist/src/agents/cli-help-agent.test.js +53 -0
- package/dist/src/agents/cli-help-agent.test.js.map +1 -0
- package/dist/src/agents/codebase-investigator.d.ts +2 -1
- package/dist/src/agents/codebase-investigator.js +68 -39
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/codebase-investigator.test.js +37 -9
- package/dist/src/agents/codebase-investigator.test.js.map +1 -1
- package/dist/src/agents/generalist-agent.d.ts +21 -0
- package/dist/src/agents/generalist-agent.js +60 -0
- package/dist/src/agents/generalist-agent.js.map +1 -0
- package/dist/src/agents/generalist-agent.test.d.ts +6 -0
- package/dist/src/agents/generalist-agent.test.js +32 -0
- package/dist/src/agents/generalist-agent.test.js.map +1 -0
- package/dist/src/agents/introspection-agent.d.ts +2 -2
- package/dist/src/agents/local-executor.d.ts +2 -0
- package/dist/src/agents/local-executor.js +186 -90
- package/dist/src/agents/local-executor.js.map +1 -1
- package/dist/src/agents/local-executor.test.js +431 -256
- package/dist/src/agents/local-executor.test.js.map +1 -1
- package/dist/src/agents/local-invocation.test.js +15 -5
- package/dist/src/agents/local-invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +24 -8
- package/dist/src/agents/registry.js +193 -96
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +509 -58
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/registry_acknowledgement.test.d.ts +6 -0
- package/dist/src/agents/registry_acknowledgement.test.js +130 -0
- package/dist/src/agents/registry_acknowledgement.test.js.map +1 -0
- package/dist/src/agents/remote-invocation.js +12 -14
- package/dist/src/agents/remote-invocation.js.map +1 -1
- package/dist/src/agents/remote-invocation.test.js +16 -4
- package/dist/src/agents/remote-invocation.test.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.js +1 -3
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -1
- package/dist/src/agents/subagent-tool-wrapper.test.js +18 -27
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -1
- package/dist/src/agents/subagent-tool.d.ts +15 -0
- package/dist/src/agents/subagent-tool.js +57 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/subagent-tool.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool.test.js +97 -0
- package/dist/src/agents/subagent-tool.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +37 -22
- package/dist/src/agents/types.js +12 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/availability/fallbackIntegration.test.d.ts +6 -0
- package/dist/src/availability/fallbackIntegration.test.js +57 -0
- package/dist/src/availability/fallbackIntegration.test.js.map +1 -0
- package/dist/src/availability/policyCatalog.d.ts +3 -0
- package/dist/src/availability/policyCatalog.js +29 -5
- package/dist/src/availability/policyCatalog.js.map +1 -1
- package/dist/src/availability/policyCatalog.test.js +20 -1
- package/dist/src/availability/policyCatalog.test.js.map +1 -1
- package/dist/src/availability/policyHelpers.js +40 -11
- package/dist/src/availability/policyHelpers.js.map +1 -1
- package/dist/src/availability/policyHelpers.test.js +72 -2
- package/dist/src/availability/policyHelpers.test.js.map +1 -1
- package/dist/src/availability/testUtils.js +1 -0
- package/dist/src/availability/testUtils.js.map +1 -1
- package/dist/src/code_assist/admin/admin_controls.d.ts +49 -0
- package/dist/src/code_assist/admin/admin_controls.js +197 -0
- package/dist/src/code_assist/admin/admin_controls.js.map +1 -0
- package/dist/src/code_assist/admin/admin_controls.test.d.ts +6 -0
- package/dist/src/code_assist/admin/admin_controls.test.js +589 -0
- package/dist/src/code_assist/admin/admin_controls.test.js.map +1 -0
- package/dist/src/code_assist/admin/mcpUtils.d.ts +22 -0
- package/dist/src/code_assist/admin/mcpUtils.js +53 -0
- package/dist/src/code_assist/admin/mcpUtils.js.map +1 -0
- package/dist/src/code_assist/admin/mcpUtils.test.d.ts +6 -0
- package/dist/src/code_assist/admin/mcpUtils.test.js +101 -0
- package/dist/src/code_assist/admin/mcpUtils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.js +2 -2
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +1 -1
- package/dist/src/code_assist/codeAssist.test.js +10 -6
- package/dist/src/code_assist/codeAssist.test.js.map +1 -1
- package/dist/src/code_assist/converter.js +8 -3
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +8 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.d.ts +1 -1
- package/dist/src/code_assist/experiments/experiments.js +22 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments.test.js +1 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -1
- package/dist/src/code_assist/experiments/experiments_local.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js +115 -0
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +7 -0
- package/dist/src/code_assist/experiments/flagNames.js +7 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -1
- package/dist/src/code_assist/oauth-credential-storage.js +4 -4
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +10 -3
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +7 -4
- package/dist/src/code_assist/server.js +20 -4
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +18 -5
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +35 -3
- package/dist/src/code_assist/setup.js +98 -16
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +322 -5
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/telemetry.js +2 -1
- package/dist/src/code_assist/telemetry.js.map +1 -1
- package/dist/src/code_assist/telemetry.test.js +2 -1
- package/dist/src/code_assist/telemetry.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +255 -24
- package/dist/src/code_assist/types.js +57 -7
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/memory.d.ts +11 -0
- package/dist/src/commands/memory.js +81 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/memory.test.d.ts +6 -0
- package/dist/src/commands/memory.test.js +155 -0
- package/dist/src/commands/memory.test.js.map +1 -0
- package/dist/src/commands/restore.js +1 -0
- package/dist/src/commands/restore.js.map +1 -1
- package/dist/src/config/config.d.ts +267 -58
- package/dist/src/config/config.js +663 -164
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.d.ts +1 -1
- package/dist/src/config/config.test.js +585 -166
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +4 -0
- package/dist/src/config/constants.js +8 -0
- package/dist/src/config/constants.js.map +1 -1
- package/dist/src/config/defaultModelConfigs.js +27 -8
- package/dist/src/config/defaultModelConfigs.js.map +1 -1
- package/dist/src/config/memory.d.ts +14 -0
- package/dist/src/config/memory.js +28 -0
- package/dist/src/config/memory.js.map +1 -0
- package/dist/src/config/memory.test.d.ts +6 -0
- package/dist/src/config/memory.test.js +82 -0
- package/dist/src/config/memory.test.js.map +1 -0
- package/dist/src/config/models.d.ts +77 -6
- package/dist/src/config/models.js +240 -23
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.js +153 -47
- package/dist/src/config/models.test.js.map +1 -1
- package/dist/src/config/projectRegistry.d.ts +36 -0
- package/dist/src/config/projectRegistry.js +262 -0
- package/dist/src/config/projectRegistry.js.map +1 -0
- package/dist/src/config/projectRegistry.test.d.ts +6 -0
- package/dist/src/config/projectRegistry.test.js +219 -0
- package/dist/src/config/projectRegistry.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +23 -1
- package/dist/src/config/storage.js +104 -15
- package/dist/src/config/storage.js.map +1 -1
- package/dist/src/config/storage.test.js +118 -2
- package/dist/src/config/storage.test.js.map +1 -1
- package/dist/src/config/storageMigration.d.ts +16 -0
- package/dist/src/config/storageMigration.js +42 -0
- package/dist/src/config/storageMigration.js.map +1 -0
- package/dist/src/config/storageMigration.test.d.ts +6 -0
- package/dist/src/config/storageMigration.test.js +70 -0
- package/dist/src/config/storageMigration.test.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.js +3 -33
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +95 -20
- package/dist/src/confirmation-bus/types.js +9 -3
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/anthropicContentGenerator.d.ts +3 -2
- package/dist/src/core/anthropicContentGenerator.js +2 -2
- package/dist/src/core/anthropicContentGenerator.js.map +1 -1
- package/dist/src/core/baseLlmClient.d.ts +9 -0
- package/dist/src/core/baseLlmClient.js +9 -8
- package/dist/src/core/baseLlmClient.js.map +1 -1
- package/dist/src/core/baseLlmClient.test.js +17 -7
- package/dist/src/core/baseLlmClient.test.js.map +1 -1
- package/dist/src/core/bedrockContentGenerator.d.ts +73 -0
- package/dist/src/core/bedrockContentGenerator.js +628 -0
- package/dist/src/core/bedrockContentGenerator.js.map +1 -0
- package/dist/src/core/client.d.ts +13 -4
- package/dist/src/core/client.js +132 -41
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +333 -79
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +16 -3
- package/dist/src/core/contentGenerator.js +56 -2
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.d.ts +1 -1
- package/dist/src/core/contentGenerator.test.js +127 -24
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +4 -36
- package/dist/src/core/coreToolHookTriggers.js +42 -150
- package/dist/src/core/coreToolHookTriggers.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.test.js +62 -94
- package/dist/src/core/coreToolHookTriggers.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +1 -8
- package/dist/src/core/coreToolScheduler.js +160 -125
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +480 -62
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +4 -2
- package/dist/src/core/fakeContentGenerator.js +9 -2
- package/dist/src/core/fakeContentGenerator.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.test.js +8 -7
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +31 -3
- package/dist/src/core/geminiChat.js +144 -34
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +175 -50
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChat_network_retry.test.js +146 -16
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -1
- package/dist/src/core/logger.js +11 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +2 -4
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +7 -3
- package/dist/src/core/loggingContentGenerator.js +40 -21
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +50 -8
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +3 -2
- package/dist/src/core/openaiContentGenerator.js +18 -10
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +57 -4
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts-substitution.test.d.ts +6 -0
- package/dist/src/core/prompts-substitution.test.js +109 -0
- package/dist/src/core/prompts-substitution.test.js.map +1 -0
- package/dist/src/core/prompts.d.ts +11 -9
- package/dist/src/core/prompts.js +14 -405
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +290 -56
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +5 -3
- package/dist/src/core/recordingContentGenerator.js +12 -5
- package/dist/src/core/recordingContentGenerator.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.test.js +5 -4
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -1
- package/dist/src/core/tokenLimits.js +6 -10
- package/dist/src/core/tokenLimits.js.map +1 -1
- package/dist/src/core/tokenLimits.test.js +8 -4
- package/dist/src/core/tokenLimits.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +10 -2
- package/dist/src/core/turn.js +36 -17
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +82 -2
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.js +1 -1
- package/dist/src/fallback/handler.js.map +1 -1
- package/dist/src/fallback/handler.test.js +10 -12
- package/dist/src/fallback/handler.test.js.map +1 -1
- package/dist/src/fallback/types.d.ts +9 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/hooks/hookAggregator.js +16 -4
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +10 -16
- package/dist/src/hooks/hookEventHandler.js +35 -281
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +189 -4
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookRegistry.js +8 -3
- package/dist/src/hooks/hookRegistry.js.map +1 -1
- package/dist/src/hooks/hookRegistry.test.js +31 -2
- package/dist/src/hooks/hookRegistry.test.js.map +1 -1
- package/dist/src/hooks/hookRunner.js +21 -18
- package/dist/src/hooks/hookRunner.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +59 -0
- package/dist/src/hooks/hookSystem.js +206 -6
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookSystem.test.js +20 -9
- package/dist/src/hooks/hookSystem.test.js.map +1 -1
- package/dist/src/hooks/hookTranslator.js +13 -6
- package/dist/src/hooks/hookTranslator.js.map +1 -1
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/hooks/index.js +0 -2
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/trustedHooks.js +2 -0
- package/dist/src/hooks/trustedHooks.js.map +1 -1
- package/dist/src/hooks/types.d.ts +49 -1
- package/dist/src/hooks/types.js +43 -19
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +13 -29
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +49 -0
- package/dist/src/ide/detect-ide.js +56 -3
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +70 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +0 -10
- package/dist/src/ide/ide-client.js +31 -199
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +39 -191
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-connection-utils.d.ts +27 -0
- package/dist/src/ide/ide-connection-utils.js +195 -0
- package/dist/src/ide/ide-connection-utils.js.map +1 -0
- package/dist/src/ide/ide-connection-utils.test.d.ts +6 -0
- package/dist/src/ide/ide-connection-utils.test.js +372 -0
- package/dist/src/ide/ide-connection-utils.test.js.map +1 -0
- package/dist/src/ide/ide-installer.js +76 -5
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +40 -2
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/types.d.ts +46 -46
- package/dist/src/index.d.ts +30 -2
- package/dist/src/index.js +31 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +10 -3
- package/dist/src/mcp/oauth-provider.js +49 -14
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +180 -1
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.js +3 -0
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +13 -4
- package/dist/src/mcp/oauth-utils.js +25 -19
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +13 -8
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.js +3 -1
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -1
- package/dist/src/mcp/token-storage/file-token-storage.js +6 -2
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +4 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +12 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.js +8 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -1
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +10 -5
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -1
- package/dist/src/output/json-formatter.test.js +2 -0
- package/dist/src/output/json-formatter.test.js.map +1 -1
- package/dist/src/output/stream-json-formatter.test.js +4 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -1
- package/dist/src/policy/config.d.ts +5 -3
- package/dist/src/policy/config.js +137 -64
- package/dist/src/policy/config.js.map +1 -1
- package/dist/src/policy/config.test.js +218 -12
- package/dist/src/policy/config.test.js.map +1 -1
- package/dist/src/policy/persistence.test.js +31 -11
- package/dist/src/policy/persistence.test.js.map +1 -1
- package/dist/src/policy/policies/plan.toml +56 -0
- package/dist/src/policy/policies/read-only.toml +1 -11
- package/dist/src/policy/policies/yolo.toml +13 -2
- package/dist/src/policy/policy-engine.d.ts +16 -11
- package/dist/src/policy/policy-engine.js +208 -101
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +538 -199
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- package/dist/src/policy/policy-updater.test.js +20 -6
- package/dist/src/policy/policy-updater.test.js.map +1 -1
- package/dist/src/policy/shell-safety.test.js +371 -8
- package/dist/src/policy/shell-safety.test.js.map +1 -1
- package/dist/src/policy/stable-stringify.js +1 -0
- package/dist/src/policy/stable-stringify.js.map +1 -1
- package/dist/src/policy/toml-loader.d.ts +5 -5
- package/dist/src/policy/toml-loader.js +65 -22
- package/dist/src/policy/toml-loader.js.map +1 -1
- package/dist/src/policy/toml-loader.test.js +88 -9
- package/dist/src/policy/toml-loader.test.js.map +1 -1
- package/dist/src/policy/types.d.ts +26 -1
- package/dist/src/policy/types.js +8 -0
- package/dist/src/policy/types.js.map +1 -1
- package/dist/src/policy/utils.d.ts +5 -0
- package/dist/src/policy/utils.js +32 -1
- package/dist/src/policy/utils.js.map +1 -1
- package/dist/src/policy/utils.test.js +67 -7
- package/dist/src/policy/utils.test.js.map +1 -1
- package/dist/src/prompts/promptProvider.d.ts +19 -0
- package/dist/src/prompts/promptProvider.js +174 -0
- package/dist/src/prompts/promptProvider.js.map +1 -0
- package/dist/src/prompts/promptProvider.test.d.ts +6 -0
- package/dist/src/prompts/promptProvider.test.js +71 -0
- package/dist/src/prompts/promptProvider.test.js.map +1 -0
- package/dist/src/prompts/snippets.d.ts +86 -0
- package/dist/src/prompts/snippets.js +573 -0
- package/dist/src/prompts/snippets.js.map +1 -0
- package/dist/src/prompts/snippets.legacy.d.ts +91 -0
- package/dist/src/prompts/snippets.legacy.js +573 -0
- package/dist/src/prompts/snippets.legacy.js.map +1 -0
- package/dist/src/prompts/utils.d.ts +23 -0
- package/dist/src/prompts/utils.js +82 -0
- package/dist/src/prompts/utils.js.map +1 -0
- package/dist/src/routing/modelRouterService.js +18 -8
- package/dist/src/routing/modelRouterService.js.map +1 -1
- package/dist/src/routing/modelRouterService.test.js +14 -6
- package/dist/src/routing/modelRouterService.test.js.map +1 -1
- package/dist/src/routing/routingStrategy.d.ts +2 -0
- package/dist/src/routing/strategies/classifierStrategy.js +14 -9
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +72 -7
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/compositeStrategy.js +1 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/defaultStrategy.js +5 -4
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -1
- package/dist/src/routing/strategies/defaultStrategy.test.js +58 -4
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.js +3 -3
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js +13 -1
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js +188 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js +401 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +1 -1
- package/dist/src/routing/strategies/overrideStrategy.js +6 -6
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -1
- package/dist/src/routing/strategies/overrideStrategy.test.js +13 -3
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -1
- package/dist/src/safety/built-in.js +1 -0
- package/dist/src/safety/built-in.js.map +1 -1
- package/dist/src/safety/context-builder.js +3 -1
- package/dist/src/safety/context-builder.js.map +1 -1
- package/dist/src/scheduler/confirmation.d.ts +50 -0
- package/dist/src/scheduler/confirmation.js +204 -0
- package/dist/src/scheduler/confirmation.js.map +1 -0
- package/dist/src/scheduler/confirmation.test.d.ts +6 -0
- package/dist/src/scheduler/confirmation.test.js +310 -0
- package/dist/src/scheduler/confirmation.test.js.map +1 -0
- package/dist/src/scheduler/policy.d.ts +33 -0
- package/dist/src/scheduler/policy.js +119 -0
- package/dist/src/scheduler/policy.js.map +1 -0
- package/dist/src/scheduler/policy.test.d.ts +6 -0
- package/dist/src/scheduler/policy.test.js +419 -0
- package/dist/src/scheduler/policy.test.js.map +1 -0
- package/dist/src/scheduler/scheduler.d.ts +63 -0
- package/dist/src/scheduler/scheduler.js +371 -0
- package/dist/src/scheduler/scheduler.js.map +1 -0
- package/dist/src/scheduler/scheduler.test.d.ts +6 -0
- package/dist/src/scheduler/scheduler.test.js +937 -0
- package/dist/src/scheduler/scheduler.test.js.map +1 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.d.ts +6 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.js +62 -0
- package/dist/src/scheduler/scheduler_waiting_callback.test.js.map +1 -0
- package/dist/src/scheduler/state-manager.d.ts +74 -0
- package/dist/src/scheduler/state-manager.js +368 -0
- package/dist/src/scheduler/state-manager.js.map +1 -0
- package/dist/src/scheduler/state-manager.test.d.ts +6 -0
- package/dist/src/scheduler/state-manager.test.js +433 -0
- package/dist/src/scheduler/state-manager.test.js.map +1 -0
- package/dist/src/scheduler/tool-executor.js +25 -27
- package/dist/src/scheduler/tool-executor.js.map +1 -1
- package/dist/src/scheduler/tool-executor.test.js +26 -25
- package/dist/src/scheduler/tool-executor.test.js.map +1 -1
- package/dist/src/scheduler/tool-modifier.d.ts +23 -0
- package/dist/src/scheduler/tool-modifier.js +53 -0
- package/dist/src/scheduler/tool-modifier.js.map +1 -0
- package/dist/src/scheduler/tool-modifier.test.d.ts +6 -0
- package/dist/src/scheduler/tool-modifier.test.js +179 -0
- package/dist/src/scheduler/tool-modifier.test.js.map +1 -0
- package/dist/src/scheduler/types.d.ts +51 -8
- package/dist/src/scheduler/types.js +15 -1
- package/dist/src/scheduler/types.js.map +1 -1
- package/dist/src/services/chatCompressionService.d.ts +5 -1
- package/dist/src/services/chatCompressionService.js +169 -23
- package/dist/src/services/chatCompressionService.js.map +1 -1
- package/dist/src/services/chatCompressionService.test.js +382 -18
- package/dist/src/services/chatCompressionService.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +23 -3
- package/dist/src/services/chatRecordingService.js +137 -7
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +450 -186
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/contextManager.d.ts +7 -4
- package/dist/src/services/contextManager.js +43 -18
- package/dist/src/services/contextManager.js.map +1 -1
- package/dist/src/services/contextManager.test.js +54 -27
- package/dist/src/services/contextManager.test.js.map +1 -1
- package/dist/src/services/environmentSanitization.js +4 -3
- package/dist/src/services/environmentSanitization.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +14 -2
- package/dist/src/services/fileDiscoveryService.js +79 -7
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +142 -10
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +2 -1
- package/dist/src/services/gitService.js +16 -6
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +26 -10
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.js +23 -4
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +24 -0
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.integration.test.js +2 -2
- package/dist/src/services/modelConfig.integration.test.js.map +1 -1
- package/dist/src/services/modelConfigService.d.ts +39 -4
- package/dist/src/services/modelConfigService.js +153 -76
- package/dist/src/services/modelConfigService.js.map +1 -1
- package/dist/src/services/modelConfigService.test.js +175 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -1
- package/dist/src/services/modelConfigServiceTestUtils.js +3 -1
- package/dist/src/services/modelConfigServiceTestUtils.js.map +1 -1
- package/dist/src/services/sessionSummaryService.js +2 -0
- package/dist/src/services/sessionSummaryService.js.map +1 -1
- package/dist/src/services/sessionSummaryService.test.js +1 -1
- package/dist/src/services/sessionSummaryService.test.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +48 -0
- package/dist/src/services/shellExecutionService.js +339 -97
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +132 -17
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases-retry.golden.json +26 -8
- package/dist/src/services/test-data/resolved-aliases.golden.json +26 -8
- package/dist/src/services/toolOutputMaskingService.d.ts +43 -0
- package/dist/src/services/toolOutputMaskingService.js +286 -0
- package/dist/src/services/toolOutputMaskingService.js.map +1 -0
- package/dist/src/services/toolOutputMaskingService.test.d.ts +6 -0
- package/dist/src/services/toolOutputMaskingService.test.js +546 -0
- package/dist/src/services/toolOutputMaskingService.test.js.map +1 -0
- package/dist/src/skills/builtin/skill-creator/SKILL.md +382 -0
- package/dist/src/skills/builtin/skill-creator/scripts/init_skill.cjs +239 -0
- package/dist/src/skills/builtin/skill-creator/scripts/package_skill.cjs +106 -0
- package/dist/src/skills/builtin/skill-creator/scripts/validate_skill.cjs +131 -0
- package/dist/src/skills/skillLoader.d.ts +3 -0
- package/dist/src/skills/skillLoader.js +73 -12
- package/dist/src/skills/skillLoader.js.map +1 -1
- package/dist/src/skills/skillLoader.test.d.ts +5 -0
- package/dist/src/skills/skillLoader.test.js +195 -1
- package/dist/src/skills/skillLoader.test.js.map +1 -1
- package/dist/src/skills/skillManager.d.ts +25 -3
- package/dist/src/skills/skillManager.js +76 -11
- package/dist/src/skills/skillManager.js.map +1 -1
- package/dist/src/skills/skillManager.test.js +209 -9
- package/dist/src/skills/skillManager.test.js.map +1 -1
- package/dist/src/skills/skillManagerAlias.test.d.ts +6 -0
- package/dist/src/skills/skillManagerAlias.test.js +140 -0
- package/dist/src/skills/skillManagerAlias.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.js +1 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +25 -4
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +207 -12
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +210 -6
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +23 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +61 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/file-exporters.js +2 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/file-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/file-exporters.test.js +142 -0
- package/dist/src/telemetry/file-exporters.test.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.js +1 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +3 -2
- package/dist/src/telemetry/index.js +3 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/integration.test.circular.js +2 -1
- package/dist/src/telemetry/integration.test.circular.js.map +1 -1
- package/dist/src/telemetry/llmRole.d.ts +18 -0
- package/dist/src/telemetry/llmRole.js +20 -0
- package/dist/src/telemetry/llmRole.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +8 -1
- package/dist/src/telemetry/loggers.js +113 -10
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +5 -2
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +169 -19
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.test.js +1 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +39 -1
- package/dist/src/telemetry/metrics.js +105 -4
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +84 -4
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/sanitize.test.js +2 -0
- package/dist/src/telemetry/sanitize.test.js.map +1 -1
- package/dist/src/telemetry/sdk.js +24 -0
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +5 -1
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.js +92 -0
- package/dist/src/telemetry/semantic.js.map +1 -1
- package/dist/src/telemetry/semantic.truncation.test.d.ts +1 -0
- package/dist/src/telemetry/semantic.truncation.test.js +92 -0
- package/dist/src/telemetry/semantic.truncation.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.js +5 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +98 -15
- package/dist/src/telemetry/types.js +227 -16
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +16 -0
- package/dist/src/telemetry/uiTelemetry.js +39 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +29 -0
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/mock-message-bus.d.ts +1 -19
- package/dist/src/test-utils/mock-message-bus.js +5 -65
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/test-utils/mock-tool.d.ts +1 -0
- package/dist/src/test-utils/mock-tool.js +1 -0
- package/dist/src/test-utils/mock-tool.js.map +1 -1
- package/dist/src/test-utils/mockWorkspaceContext.js +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.js.map +1 -1
- package/dist/src/tools/activate-skill.d.ts +1 -0
- package/dist/src/tools/activate-skill.js +28 -25
- package/dist/src/tools/activate-skill.js.map +1 -1
- package/dist/src/tools/activate-skill.test.js +24 -6
- package/dist/src/tools/activate-skill.test.js.map +1 -1
- package/dist/src/tools/ask-user.d.ts +29 -0
- package/dist/src/tools/ask-user.js +141 -0
- package/dist/src/tools/ask-user.js.map +1 -0
- package/dist/src/tools/ask-user.test.d.ts +6 -0
- package/dist/src/tools/ask-user.test.js +446 -0
- package/dist/src/tools/ask-user.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.js +21 -0
- package/dist/src/tools/confirmation-policy.test.js.map +1 -1
- package/dist/src/tools/constants.d.ts +7 -0
- package/dist/src/tools/constants.js +8 -0
- package/dist/src/tools/constants.js.map +1 -0
- package/dist/src/tools/definitions/base-declarations.d.ts +26 -0
- package/dist/src/tools/definitions/base-declarations.js +30 -0
- package/dist/src/tools/definitions/base-declarations.js.map +1 -0
- package/dist/src/tools/definitions/coreTools.d.ts +36 -0
- package/dist/src/tools/definitions/coreTools.js +143 -0
- package/dist/src/tools/definitions/coreTools.js.map +1 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.d.ts +6 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.js +82 -0
- package/dist/src/tools/definitions/coreToolsModelSnapshots.test.js.map +1 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.d.ts +30 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.js +135 -0
- package/dist/src/tools/definitions/dynamic-declaration-helpers.js.map +1 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.d.ts +11 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js +575 -0
- package/dist/src/tools/definitions/model-family-sets/default-legacy.js.map +1 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.d.ts +14 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js +578 -0
- package/dist/src/tools/definitions/model-family-sets/gemini-3.js.map +1 -0
- package/dist/src/tools/definitions/modelFamilyService.d.ts +14 -0
- package/dist/src/tools/definitions/modelFamilyService.js +29 -0
- package/dist/src/tools/definitions/modelFamilyService.js.map +1 -0
- package/dist/src/tools/definitions/resolver.d.ts +15 -0
- package/dist/src/tools/definitions/resolver.js +27 -0
- package/dist/src/tools/definitions/resolver.js.map +1 -0
- package/dist/src/tools/definitions/resolver.test.d.ts +6 -0
- package/dist/src/tools/definitions/resolver.test.js +58 -0
- package/dist/src/tools/definitions/resolver.test.js.map +1 -0
- package/dist/src/tools/definitions/types.d.ts +44 -0
- package/dist/src/tools/definitions/types.js +7 -0
- package/dist/src/tools/definitions/types.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +7 -3
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +17 -0
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +1 -0
- package/dist/src/tools/edit.js +52 -82
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +96 -1
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/enter-plan-mode.d.ts +25 -0
- package/dist/src/tools/enter-plan-mode.js +69 -0
- package/dist/src/tools/enter-plan-mode.js.map +1 -0
- package/dist/src/tools/enter-plan-mode.test.d.ts +6 -0
- package/dist/src/tools/enter-plan-mode.test.js +102 -0
- package/dist/src/tools/enter-plan-mode.test.js.map +1 -0
- package/dist/src/tools/exit-plan-mode.d.ts +33 -0
- package/dist/src/tools/exit-plan-mode.js +173 -0
- package/dist/src/tools/exit-plan-mode.js.map +1 -0
- package/dist/src/tools/exit-plan-mode.test.d.ts +6 -0
- package/dist/src/tools/exit-plan-mode.test.js +311 -0
- package/dist/src/tools/exit-plan-mode.test.js.map +1 -0
- package/dist/src/tools/get-internal-docs.d.ts +1 -0
- package/dist/src/tools/get-internal-docs.js +17 -27
- package/dist/src/tools/get-internal-docs.js.map +1 -1
- package/dist/src/tools/glob.d.ts +1 -0
- package/dist/src/tools/glob.js +15 -36
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +219 -280
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +18 -8
- package/dist/src/tools/grep.js +273 -247
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +165 -16
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/line-endings.test.d.ts +6 -0
- package/dist/src/tools/line-endings.test.js +209 -0
- package/dist/src/tools/line-endings.test.js.map +1 -0
- package/dist/src/tools/ls.d.ts +1 -0
- package/dist/src/tools/ls.js +18 -37
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +25 -3
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +18 -5
- package/dist/src/tools/mcp-client-manager.js +118 -37
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +124 -16
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +18 -7
- package/dist/src/tools/mcp-client.js +137 -42
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +248 -29
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +26 -4
- package/dist/src/tools/mcp-tool.js +17 -5
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +5 -5
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +2 -7
- package/dist/src/tools/memoryTool.js +54 -80
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +62 -114
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +3 -3
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +2 -0
- package/dist/src/tools/read-file.js +26 -30
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +90 -3
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +1 -0
- package/dist/src/tools/read-many-files.js +21 -63
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +43 -1
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +20 -3
- package/dist/src/tools/ripGrep.js +217 -189
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +745 -567
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +1 -0
- package/dist/src/tools/shell.js +8 -3
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +248 -11
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +4 -0
- package/dist/src/tools/tool-error.js +4 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +27 -17
- package/dist/src/tools/tool-names.js +59 -20
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tool-names.test.js +55 -2
- package/dist/src/tools/tool-names.test.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +10 -2
- package/dist/src/tools/tool-registry.js +58 -11
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +113 -1
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +52 -5
- package/dist/src/tools/tools.js +35 -18
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +1 -0
- package/dist/src/tools/web-fetch.js +12 -12
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +1 -0
- package/dist/src/tools/web-search.js +9 -11
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +1 -4
- package/dist/src/tools/write-file.js +42 -35
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +105 -18
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +1 -30
- package/dist/src/tools/write-todos.js +5 -123
- package/dist/src/tools/write-todos.js.map +1 -1
- package/dist/src/tools/xcode-mcp-fix-transport.d.ts +30 -0
- package/dist/src/tools/xcode-mcp-fix-transport.js +82 -0
- package/dist/src/tools/xcode-mcp-fix-transport.js.map +1 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.d.ts +1 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.js +98 -0
- package/dist/src/tools/xcode-mcp-fix-transport.test.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.d.ts +12 -0
- package/dist/src/utils/apiConversionUtils.js +46 -0
- package/dist/src/utils/apiConversionUtils.js.map +1 -0
- package/dist/src/utils/apiConversionUtils.test.d.ts +6 -0
- package/dist/src/utils/apiConversionUtils.test.js +150 -0
- package/dist/src/utils/apiConversionUtils.test.js.map +1 -0
- package/dist/src/utils/authConsent.d.ts +10 -0
- package/dist/src/utils/authConsent.js +52 -0
- package/dist/src/utils/authConsent.js.map +1 -0
- package/dist/src/utils/authConsent.test.d.ts +6 -0
- package/dist/src/utils/authConsent.test.js +74 -0
- package/dist/src/utils/authConsent.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.js +2 -0
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +6 -1
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/checkpointUtils.d.ts +2 -2
- package/dist/src/utils/checkpointUtils.js +2 -0
- package/dist/src/utils/checkpointUtils.js.map +1 -1
- package/dist/src/utils/checks.d.ts +19 -0
- package/dist/src/utils/checks.js +24 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/utils/checks.test.d.ts +6 -0
- package/dist/src/utils/checks.test.js +29 -0
- package/dist/src/utils/checks.test.js.map +1 -0
- package/dist/src/utils/constants.d.ts +7 -0
- package/dist/src/utils/constants.js +8 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/deadlineTimer.d.ts +36 -0
- package/dist/src/utils/deadlineTimer.js +87 -0
- package/dist/src/utils/deadlineTimer.js.map +1 -0
- package/dist/src/utils/deadlineTimer.test.d.ts +6 -0
- package/dist/src/utils/deadlineTimer.test.js +64 -0
- package/dist/src/utils/deadlineTimer.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +3 -3
- package/dist/src/utils/editCorrector.js +37 -10
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +49 -20
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +17 -3
- package/dist/src/utils/editor.js +84 -15
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +160 -17
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.js +9 -20
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +31 -14
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +13 -3
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/errors.test.js +23 -1
- package/dist/src/utils/errors.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +107 -3
- package/dist/src/utils/events.js +65 -1
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/events.test.js +43 -0
- package/dist/src/utils/events.test.js.map +1 -1
- package/dist/src/utils/extensionLoader.js +2 -0
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +21 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/fastAckHelper.d.ts +30 -0
- package/dist/src/utils/fastAckHelper.js +142 -0
- package/dist/src/utils/fastAckHelper.js.map +1 -0
- package/dist/src/utils/fastAckHelper.test.d.ts +6 -0
- package/dist/src/utils/fastAckHelper.test.js +115 -0
- package/dist/src/utils/fastAckHelper.test.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.d.ts +18 -0
- package/dist/src/utils/fileDiffUtils.js +37 -0
- package/dist/src/utils/fileDiffUtils.js.map +1 -0
- package/dist/src/utils/fileDiffUtils.test.d.ts +6 -0
- package/dist/src/utils/fileDiffUtils.test.js +84 -0
- package/dist/src/utils/fileDiffUtils.test.js.map +1 -0
- package/dist/src/utils/fileUtils.d.ts +27 -3
- package/dist/src/utils/fileUtils.js +104 -60
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +129 -109
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -0
- package/dist/src/utils/filesearch/crawler.js +18 -1
- package/dist/src/utils/filesearch/crawler.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +101 -82
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +4 -3
- package/dist/src/utils/filesearch/fileSearch.js +5 -4
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +172 -84
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/filesearch/ignore.d.ts +2 -7
- package/dist/src/utils/filesearch/ignore.js +7 -14
- package/dist/src/utils/filesearch/ignore.js.map +1 -1
- package/dist/src/utils/filesearch/ignore.test.js +30 -32
- package/dist/src/utils/filesearch/ignore.test.js.map +1 -1
- package/dist/src/utils/formatters.d.ts +1 -1
- package/dist/src/utils/formatters.js +1 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.js +5 -5
- package/dist/src/utils/formatters.test.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.js +3 -0
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +5 -2
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/getPty.js +3 -0
- package/dist/src/utils/getPty.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.js +10 -11
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/googleErrors.js +4 -0
- package/dist/src/utils/googleErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +23 -9
- package/dist/src/utils/googleQuotaErrors.js +90 -23
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +168 -23
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/headless.d.ts +26 -0
- package/dist/src/utils/headless.js +33 -0
- package/dist/src/utils/headless.js.map +1 -0
- package/dist/src/utils/headless.test.d.ts +6 -0
- package/dist/src/utils/headless.test.js +167 -0
- package/dist/src/utils/headless.test.js.map +1 -0
- package/dist/src/utils/httpErrors.js +4 -1
- package/dist/src/utils/httpErrors.js.map +1 -1
- package/dist/src/utils/ignoreFileParser.d.ts +30 -0
- package/dist/src/utils/ignoreFileParser.js +100 -0
- package/dist/src/utils/ignoreFileParser.js.map +1 -0
- package/dist/src/utils/ignoreFileParser.test.d.ts +6 -0
- package/dist/src/utils/ignoreFileParser.test.js +167 -0
- package/dist/src/utils/ignoreFileParser.test.js.map +1 -0
- package/dist/src/utils/installationManager.test.js +11 -3
- package/dist/src/utils/installationManager.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +9 -9
- package/dist/src/utils/llm-edit-fixer.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.test.js +2 -2
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +11 -3
- package/dist/src/utils/memoryDiscovery.js +122 -102
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +163 -109
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +7 -24
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.js +3 -0
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/package.js +10 -3
- package/dist/src/utils/package.js.map +1 -1
- package/dist/src/utils/package.test.d.ts +6 -0
- package/dist/src/utils/package.test.js +57 -0
- package/dist/src/utils/package.test.js.map +1 -0
- package/dist/src/utils/partUtils.js +2 -1
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/paths.d.ts +33 -9
- package/dist/src/utils/paths.js +88 -29
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +206 -110
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/planUtils.d.ts +29 -0
- package/dist/src/utils/planUtils.js +55 -0
- package/dist/src/utils/planUtils.js.map +1 -0
- package/dist/src/utils/planUtils.test.d.ts +6 -0
- package/dist/src/utils/planUtils.test.js +76 -0
- package/dist/src/utils/planUtils.test.js.map +1 -0
- package/dist/src/utils/process-utils.d.ts +32 -0
- package/dist/src/utils/process-utils.js +88 -0
- package/dist/src/utils/process-utils.js.map +1 -0
- package/dist/src/utils/process-utils.test.d.ts +6 -0
- package/dist/src/utils/process-utils.test.js +103 -0
- package/dist/src/utils/process-utils.test.js.map +1 -0
- package/dist/src/utils/promptIdContext.d.ts +6 -0
- package/dist/src/utils/promptIdContext.js +15 -0
- package/dist/src/utils/promptIdContext.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.js +3 -0
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +4 -0
- package/dist/src/utils/retry.js +84 -5
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +70 -3
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.js +1 -0
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/schemaValidator.d.ts +8 -1
- package/dist/src/utils/schemaValidator.js +78 -11
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.js +77 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -1
- package/dist/src/utils/security.d.ts +16 -0
- package/dist/src/utils/security.js +91 -0
- package/dist/src/utils/security.js.map +1 -0
- package/dist/src/utils/security.test.d.ts +1 -0
- package/dist/src/utils/security.test.js +121 -0
- package/dist/src/utils/security.test.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +14 -0
- package/dist/src/utils/shell-utils.integration.test.d.ts +1 -0
- package/dist/src/utils/shell-utils.integration.test.js +58 -0
- package/dist/src/utils/shell-utils.integration.test.js.map +1 -0
- package/dist/src/utils/shell-utils.js +191 -30
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +108 -1
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/summarizer.js +2 -1
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +4 -0
- package/dist/src/utils/terminal.js +12 -0
- package/dist/src/utils/terminal.js.map +1 -1
- package/dist/src/utils/terminalSerializer.d.ts +1 -1
- package/dist/src/utils/terminalSerializer.js +25 -13
- package/dist/src/utils/terminalSerializer.js.map +1 -1
- package/dist/src/utils/testUtils.js +1 -0
- package/dist/src/utils/testUtils.js.map +1 -1
- package/dist/src/utils/textUtils.d.ts +14 -0
- package/dist/src/utils/textUtils.js +23 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.js +18 -1
- package/dist/src/utils/textUtils.test.js.map +1 -1
- package/dist/src/utils/tokenCalculation.d.ts +2 -2
- package/dist/src/utils/tokenCalculation.js +87 -21
- package/dist/src/utils/tokenCalculation.js.map +1 -1
- package/dist/src/utils/tokenCalculation.test.js +189 -76
- package/dist/src/utils/tokenCalculation.test.js.map +1 -1
- package/dist/src/utils/tool-utils.d.ts +26 -0
- package/dist/src/utils/tool-utils.js +36 -0
- package/dist/src/utils/tool-utils.js.map +1 -1
- package/dist/src/utils/tool-utils.test.js +73 -3
- package/dist/src/utils/tool-utils.test.js.map +1 -1
- package/dist/src/utils/toolCallContext.d.ts +35 -0
- package/dist/src/utils/toolCallContext.js +29 -0
- package/dist/src/utils/toolCallContext.js.map +1 -0
- package/dist/src/utils/toolCallContext.test.d.ts +6 -0
- package/dist/src/utils/toolCallContext.test.js +68 -0
- package/dist/src/utils/toolCallContext.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.js +1 -0
- package/dist/src/utils/userAccountManager.js.map +1 -1
- package/dist/src/utils/userAccountManager.test.js +5 -5
- package/dist/src/utils/userAccountManager.test.js.map +1 -1
- package/dist/src/utils/version.d.ts +2 -0
- package/dist/src/utils/version.js +14 -3
- package/dist/src/utils/version.js.map +1 -1
- package/dist/src/utils/version.test.js +15 -1
- package/dist/src/utils/version.test.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +28 -0
- package/dist/src/utils/workspaceContext.js +74 -9
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +56 -1
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -15
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { describe, it, expect, vi, beforeEach, afterEach, } from 'vitest';
|
|
7
7
|
import { GeminiClient } from './client.js';
|
|
8
8
|
import { AuthType, } from './contentGenerator.js';
|
|
9
|
-
import {} from './geminiChat.js';
|
|
9
|
+
import { GeminiChat } from './geminiChat.js';
|
|
10
10
|
import { CompressionStatus, GeminiEventType, Turn, } from './turn.js';
|
|
11
11
|
import { getCoreSystemPrompt } from './prompts.js';
|
|
12
12
|
import { DEFAULT_GEMINI_MODEL_AUTO } from '../config/models.js';
|
|
@@ -18,9 +18,10 @@ import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
|
|
18
18
|
import { ChatCompressionService } from '../services/chatCompressionService.js';
|
|
19
19
|
import { createAvailabilityServiceMock } from '../availability/testUtils.js';
|
|
20
20
|
import { ClearcutLogger } from '../telemetry/clearcut-logger/clearcut-logger.js';
|
|
21
|
-
import { HookSystem } from '../hooks/hookSystem.js';
|
|
22
21
|
import * as policyCatalog from '../availability/policyCatalog.js';
|
|
23
|
-
|
|
22
|
+
import { LlmRole } from '../telemetry/types.js';
|
|
23
|
+
import { partToString } from '../utils/partUtils.js';
|
|
24
|
+
import { coreEvents } from '../utils/events.js';
|
|
24
25
|
// Mock fs module to prevent actual file system operations during tests
|
|
25
26
|
const mockFileSystem = new Map();
|
|
26
27
|
vi.mock('node:fs', () => {
|
|
@@ -93,15 +94,11 @@ vi.mock('../telemetry/uiTelemetry.js', () => ({
|
|
|
93
94
|
},
|
|
94
95
|
}));
|
|
95
96
|
vi.mock('../hooks/hookSystem.js');
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
suppressOutput: false,
|
|
102
|
-
systemMessage: undefined,
|
|
103
|
-
}),
|
|
104
|
-
}));
|
|
97
|
+
const mockHookSystem = {
|
|
98
|
+
fireBeforeAgentEvent: vi.fn().mockResolvedValue(undefined),
|
|
99
|
+
fireAfterAgentEvent: vi.fn().mockResolvedValue(undefined),
|
|
100
|
+
firePreCompressEvent: vi.fn().mockResolvedValue(undefined),
|
|
101
|
+
};
|
|
105
102
|
/**
|
|
106
103
|
* Array.fromAsync ponyfill, which will be available in es 2024.
|
|
107
104
|
*
|
|
@@ -124,14 +121,6 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
124
121
|
vi.resetAllMocks();
|
|
125
122
|
ClearcutLogger.clearInstance();
|
|
126
123
|
vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
|
|
127
|
-
vi.mocked(ChatCompressionService.prototype.compress).mockResolvedValue({
|
|
128
|
-
newHistory: null,
|
|
129
|
-
info: {
|
|
130
|
-
originalTokenCount: 0,
|
|
131
|
-
newTokenCount: 0,
|
|
132
|
-
compressionStatus: CompressionStatus.NOOP,
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
124
|
mockGenerateContentFn = vi.fn().mockResolvedValue({
|
|
136
125
|
candidates: [{ content: { parts: [{ text: '{"key": "value"}' }] } }],
|
|
137
126
|
});
|
|
@@ -176,6 +165,8 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
176
165
|
getGlobalMemory: vi.fn().mockReturnValue(''),
|
|
177
166
|
getEnvironmentMemory: vi.fn().mockReturnValue(''),
|
|
178
167
|
isJitContextEnabled: vi.fn().mockReturnValue(false),
|
|
168
|
+
getToolOutputMaskingEnabled: vi.fn().mockReturnValue(false),
|
|
169
|
+
getDisableLoopDetection: vi.fn().mockReturnValue(false),
|
|
179
170
|
getSessionId: vi.fn().mockReturnValue('test-session-id'),
|
|
180
171
|
getProxy: vi.fn().mockReturnValue(undefined),
|
|
181
172
|
getWorkingDir: vi.fn().mockReturnValue('/test/dir'),
|
|
@@ -188,7 +179,6 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
188
179
|
getIdeModeFeature: vi.fn().mockReturnValue(false),
|
|
189
180
|
getIdeMode: vi.fn().mockReturnValue(true),
|
|
190
181
|
getDebugMode: vi.fn().mockReturnValue(false),
|
|
191
|
-
getPreviewFeatures: vi.fn().mockReturnValue(false),
|
|
192
182
|
getWorkspaceContext: vi.fn().mockReturnValue({
|
|
193
183
|
getDirectories: vi.fn().mockReturnValue(['/test/dir']),
|
|
194
184
|
}),
|
|
@@ -199,10 +189,12 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
199
189
|
getMessageBus: vi.fn().mockReturnValue(undefined),
|
|
200
190
|
getEnableHooks: vi.fn().mockReturnValue(false),
|
|
201
191
|
getChatCompression: vi.fn().mockReturnValue(undefined),
|
|
192
|
+
getCompressionThreshold: vi.fn().mockReturnValue(undefined),
|
|
202
193
|
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
|
203
194
|
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
|
204
195
|
getContinueOnFailedApiCall: vi.fn(),
|
|
205
196
|
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
|
197
|
+
getIncludeDirectoryTree: vi.fn().mockReturnValue(true),
|
|
206
198
|
storage: {
|
|
207
199
|
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
|
|
208
200
|
},
|
|
@@ -233,21 +225,21 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
233
225
|
.fn()
|
|
234
226
|
.mockReturnValue(createAvailabilityServiceMock()),
|
|
235
227
|
};
|
|
236
|
-
mockConfig.getHookSystem = vi
|
|
237
|
-
.fn()
|
|
238
|
-
.mockReturnValue(new HookSystem(mockConfig));
|
|
228
|
+
mockConfig.getHookSystem = vi.fn().mockReturnValue(mockHookSystem);
|
|
239
229
|
client = new GeminiClient(mockConfig);
|
|
240
230
|
await client.initialize();
|
|
241
231
|
vi.mocked(mockConfig.getGeminiClient).mockReturnValue(client);
|
|
242
232
|
vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
|
|
243
233
|
});
|
|
244
234
|
afterEach(() => {
|
|
235
|
+
client.dispose();
|
|
245
236
|
vi.restoreAllMocks();
|
|
246
237
|
});
|
|
247
238
|
describe('addHistory', () => {
|
|
248
239
|
it('should call chat.addHistory with the provided content', async () => {
|
|
249
240
|
const mockChat = {
|
|
250
241
|
addHistory: vi.fn(),
|
|
242
|
+
setTools: vi.fn(),
|
|
251
243
|
};
|
|
252
244
|
client['chat'] = mockChat;
|
|
253
245
|
const newContent = {
|
|
@@ -258,6 +250,24 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
258
250
|
expect(mockChat.addHistory).toHaveBeenCalledWith(newContent);
|
|
259
251
|
});
|
|
260
252
|
});
|
|
253
|
+
describe('setHistory', () => {
|
|
254
|
+
it('should update telemetry token count when history is set', () => {
|
|
255
|
+
const history = [
|
|
256
|
+
{ role: 'user', parts: [{ text: 'some message' }] },
|
|
257
|
+
];
|
|
258
|
+
client.setHistory(history);
|
|
259
|
+
expect(uiTelemetryService.setLastPromptTokenCount).toHaveBeenCalled();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
describe('resumeChat', () => {
|
|
263
|
+
it('should update telemetry token count when a chat is resumed', async () => {
|
|
264
|
+
const history = [
|
|
265
|
+
{ role: 'user', parts: [{ text: 'resumed message' }] },
|
|
266
|
+
];
|
|
267
|
+
await client.resumeChat(history);
|
|
268
|
+
expect(uiTelemetryService.setLastPromptTokenCount).toHaveBeenCalled();
|
|
269
|
+
});
|
|
270
|
+
});
|
|
261
271
|
describe('resetChat', () => {
|
|
262
272
|
it('should create a new chat session, clearing the old history', async () => {
|
|
263
273
|
// 1. Get the initial chat instance and add some history.
|
|
@@ -307,6 +317,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
307
317
|
getHistory: mockGetHistory,
|
|
308
318
|
addHistory: vi.fn(),
|
|
309
319
|
setHistory: vi.fn(),
|
|
320
|
+
setTools: vi.fn(),
|
|
310
321
|
getLastPromptTokenCount: vi.fn(),
|
|
311
322
|
};
|
|
312
323
|
});
|
|
@@ -318,6 +329,10 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
318
329
|
getHistory: vi.fn((_curated) => chatHistory),
|
|
319
330
|
setHistory: vi.fn(),
|
|
320
331
|
getLastPromptTokenCount: vi.fn().mockReturnValue(originalTokenCount),
|
|
332
|
+
getChatRecordingService: vi.fn().mockReturnValue({
|
|
333
|
+
getConversation: vi.fn().mockReturnValue(null),
|
|
334
|
+
getConversationFilePath: vi.fn().mockReturnValue(null),
|
|
335
|
+
}),
|
|
321
336
|
};
|
|
322
337
|
client['chat'] = mockOriginalChat;
|
|
323
338
|
vi.mocked(uiTelemetryService.getLastPromptTokenCount).mockReturnValue(originalTokenCount);
|
|
@@ -325,7 +340,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
325
340
|
{ role: 'user', parts: [{ text: 'Summary' }] },
|
|
326
341
|
{ role: 'model', parts: [{ text: 'Got it' }] },
|
|
327
342
|
];
|
|
328
|
-
vi.
|
|
343
|
+
vi.spyOn(ChatCompressionService.prototype, 'compress').mockResolvedValue({
|
|
329
344
|
newHistory: compressionStatus === CompressionStatus.COMPRESSED
|
|
330
345
|
? newHistory
|
|
331
346
|
: null,
|
|
@@ -444,7 +459,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
444
459
|
it('should not trigger summarization if token count is below threshold', async () => {
|
|
445
460
|
const MOCKED_TOKEN_LIMIT = 1000;
|
|
446
461
|
const originalTokenCount = MOCKED_TOKEN_LIMIT * 0.699;
|
|
447
|
-
vi.
|
|
462
|
+
vi.spyOn(ChatCompressionService.prototype, 'compress').mockResolvedValue({
|
|
448
463
|
newHistory: null,
|
|
449
464
|
info: {
|
|
450
465
|
originalTokenCount,
|
|
@@ -476,6 +491,25 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
476
491
|
newTokenCount: 50,
|
|
477
492
|
});
|
|
478
493
|
});
|
|
494
|
+
it('should resume the session file when compression succeeds', async () => {
|
|
495
|
+
const { client, mockOriginalChat } = setup({
|
|
496
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
497
|
+
});
|
|
498
|
+
const mockConversation = { some: 'conversation' };
|
|
499
|
+
const mockFilePath = '/tmp/session.json';
|
|
500
|
+
// Override the mock to return values
|
|
501
|
+
const mockRecordingService = {
|
|
502
|
+
getConversation: vi.fn().mockReturnValue(mockConversation),
|
|
503
|
+
getConversationFilePath: vi.fn().mockReturnValue(mockFilePath),
|
|
504
|
+
};
|
|
505
|
+
vi.mocked(mockOriginalChat.getChatRecordingService).mockReturnValue(mockRecordingService);
|
|
506
|
+
await client.tryCompressChat('prompt-id', false);
|
|
507
|
+
expect(client['startChat']).toHaveBeenCalledWith(expect.anything(), // newHistory
|
|
508
|
+
{
|
|
509
|
+
conversation: mockConversation,
|
|
510
|
+
filePath: mockFilePath,
|
|
511
|
+
});
|
|
512
|
+
});
|
|
479
513
|
});
|
|
480
514
|
describe('sendMessageStream', () => {
|
|
481
515
|
it('emits a compression event when the context was automatically compressed', async () => {
|
|
@@ -498,6 +532,21 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
498
532
|
value: compressionInfo,
|
|
499
533
|
});
|
|
500
534
|
});
|
|
535
|
+
it('does not emit ModelInfo event if signal is aborted', async () => {
|
|
536
|
+
// Arrange
|
|
537
|
+
mockTurnRunFn.mockReturnValue((async function* () {
|
|
538
|
+
yield { type: 'content', value: 'Hello' };
|
|
539
|
+
})());
|
|
540
|
+
const controller = new AbortController();
|
|
541
|
+
controller.abort();
|
|
542
|
+
// Act
|
|
543
|
+
const stream = client.sendMessageStream([{ text: 'Hi' }], controller.signal, 'prompt-id-1');
|
|
544
|
+
const events = await fromAsync(stream);
|
|
545
|
+
// Assert
|
|
546
|
+
expect(events).not.toContainEqual(expect.objectContaining({
|
|
547
|
+
type: GeminiEventType.ModelInfo,
|
|
548
|
+
}));
|
|
549
|
+
});
|
|
501
550
|
it.each([
|
|
502
551
|
{
|
|
503
552
|
compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT,
|
|
@@ -558,6 +607,7 @@ describe('Gemini Client (client.ts)', () => {
|
|
|
558
607
|
})());
|
|
559
608
|
const mockChat = {
|
|
560
609
|
addHistory: vi.fn(),
|
|
610
|
+
setTools: vi.fn(),
|
|
561
611
|
getHistory: vi.fn().mockReturnValue([]),
|
|
562
612
|
getLastPromptTokenCount: vi.fn(),
|
|
563
613
|
};
|
|
@@ -606,6 +656,7 @@ ${JSON.stringify({
|
|
|
606
656
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
607
657
|
const mockChat = {
|
|
608
658
|
addHistory: vi.fn(),
|
|
659
|
+
setTools: vi.fn(),
|
|
609
660
|
getHistory: vi.fn().mockReturnValue([]),
|
|
610
661
|
getLastPromptTokenCount: vi.fn(),
|
|
611
662
|
};
|
|
@@ -618,7 +669,7 @@ ${JSON.stringify({
|
|
|
618
669
|
}
|
|
619
670
|
// Assert
|
|
620
671
|
expect(ideContextStore.get).toHaveBeenCalled();
|
|
621
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'default-routed-model' }, initialRequest, expect.any(AbortSignal));
|
|
672
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'default-routed-model', isChatModel: true }, initialRequest, expect.any(AbortSignal), undefined);
|
|
622
673
|
});
|
|
623
674
|
it('should add context if ideMode is enabled and there is one active file', async () => {
|
|
624
675
|
// Arrange
|
|
@@ -647,6 +698,7 @@ ${JSON.stringify({
|
|
|
647
698
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
648
699
|
const mockChat = {
|
|
649
700
|
addHistory: vi.fn(),
|
|
701
|
+
setTools: vi.fn(),
|
|
650
702
|
getHistory: vi.fn().mockReturnValue([]),
|
|
651
703
|
getLastPromptTokenCount: vi.fn(),
|
|
652
704
|
};
|
|
@@ -708,6 +760,7 @@ ${JSON.stringify({
|
|
|
708
760
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
709
761
|
const mockChat = {
|
|
710
762
|
addHistory: vi.fn(),
|
|
763
|
+
setTools: vi.fn(),
|
|
711
764
|
getHistory: vi.fn().mockReturnValue([]),
|
|
712
765
|
getLastPromptTokenCount: vi.fn(),
|
|
713
766
|
};
|
|
@@ -786,6 +839,7 @@ ${JSON.stringify({
|
|
|
786
839
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
787
840
|
const mockChat = {
|
|
788
841
|
addHistory: vi.fn(),
|
|
842
|
+
setTools: vi.fn(),
|
|
789
843
|
getHistory: vi.fn().mockReturnValue([]),
|
|
790
844
|
getLastPromptTokenCount: vi.fn(),
|
|
791
845
|
};
|
|
@@ -820,6 +874,7 @@ ${JSON.stringify({
|
|
|
820
874
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
821
875
|
const mockChat = {
|
|
822
876
|
addHistory: vi.fn(),
|
|
877
|
+
setTools: vi.fn(),
|
|
823
878
|
getHistory: vi.fn().mockReturnValue([]),
|
|
824
879
|
getLastPromptTokenCount: vi.fn(),
|
|
825
880
|
};
|
|
@@ -866,6 +921,7 @@ ${JSON.stringify({
|
|
|
866
921
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
867
922
|
const mockChat = {
|
|
868
923
|
addHistory: vi.fn(),
|
|
924
|
+
setTools: vi.fn(),
|
|
869
925
|
getHistory: vi.fn().mockReturnValue([]),
|
|
870
926
|
getLastPromptTokenCount: vi.fn(),
|
|
871
927
|
};
|
|
@@ -905,6 +961,7 @@ ${JSON.stringify({
|
|
|
905
961
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
906
962
|
const mockChat = {
|
|
907
963
|
addHistory: vi.fn(),
|
|
964
|
+
setTools: vi.fn(),
|
|
908
965
|
getHistory: vi.fn().mockReturnValue([]),
|
|
909
966
|
getLastPromptTokenCount: vi.fn(),
|
|
910
967
|
};
|
|
@@ -952,13 +1009,14 @@ ${JSON.stringify({
|
|
|
952
1009
|
const lastPromptTokenCount = 900;
|
|
953
1010
|
const mockChat = {
|
|
954
1011
|
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
1012
|
+
setTools: vi.fn(),
|
|
955
1013
|
getHistory: vi.fn().mockReturnValue([]),
|
|
956
1014
|
};
|
|
957
1015
|
client['chat'] = mockChat;
|
|
958
|
-
// Remaining = 100.
|
|
959
|
-
// We need a request >
|
|
960
|
-
// A string of length
|
|
961
|
-
const longText = 'a'.repeat(
|
|
1016
|
+
// Remaining = 100.
|
|
1017
|
+
// We need a request > 100 tokens.
|
|
1018
|
+
// A string of length 404 is roughly 101 tokens.
|
|
1019
|
+
const longText = 'a'.repeat(404);
|
|
962
1020
|
const request = [{ text: longText }];
|
|
963
1021
|
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
964
1022
|
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
@@ -1000,12 +1058,13 @@ ${JSON.stringify({
|
|
|
1000
1058
|
const lastPromptTokenCount = 900;
|
|
1001
1059
|
const mockChat = {
|
|
1002
1060
|
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
1061
|
+
setTools: vi.fn(),
|
|
1003
1062
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1004
1063
|
};
|
|
1005
1064
|
client['chat'] = mockChat;
|
|
1006
|
-
// Remaining (sticky) = 100.
|
|
1007
|
-
// We need a request >
|
|
1008
|
-
const longText = 'a'.repeat(
|
|
1065
|
+
// Remaining (sticky) = 100.
|
|
1066
|
+
// We need a request > 100 tokens.
|
|
1067
|
+
const longText = 'a'.repeat(404);
|
|
1009
1068
|
const request = [{ text: longText }];
|
|
1010
1069
|
// estimateTextOnlyLength counts only text content (400 chars), not JSON structure
|
|
1011
1070
|
const estimatedRequestTokenCount = Math.floor(longText.length / 4);
|
|
@@ -1030,6 +1089,131 @@ ${JSON.stringify({
|
|
|
1030
1089
|
expect(tokenLimit).toHaveBeenCalledWith(STICKY_MODEL);
|
|
1031
1090
|
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
1032
1091
|
});
|
|
1092
|
+
it('should attempt compression before overflow check and proceed if compression frees space', async () => {
|
|
1093
|
+
// Arrange
|
|
1094
|
+
const MOCKED_TOKEN_LIMIT = 1000;
|
|
1095
|
+
vi.mocked(tokenLimit).mockReturnValue(MOCKED_TOKEN_LIMIT);
|
|
1096
|
+
// Initial state: 950 tokens used, 50 remaining.
|
|
1097
|
+
const initialTokenCount = 950;
|
|
1098
|
+
// Request: 60 tokens. (950 + 60 = 1010 > 1000) -> Would overflow without compression.
|
|
1099
|
+
const longText = 'a'.repeat(240); // 240 / 4 = 60 tokens
|
|
1100
|
+
const request = [{ text: longText }];
|
|
1101
|
+
// Use the real GeminiChat to manage state and token counts more realistically
|
|
1102
|
+
const mockChatCompressed = {
|
|
1103
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(400),
|
|
1104
|
+
getHistory: vi
|
|
1105
|
+
.fn()
|
|
1106
|
+
.mockReturnValue([{ role: 'user', parts: [{ text: 'old' }] }]),
|
|
1107
|
+
addHistory: vi.fn(),
|
|
1108
|
+
setTools: vi.fn(),
|
|
1109
|
+
getChatRecordingService: vi.fn().mockReturnValue({
|
|
1110
|
+
getConversation: vi.fn(),
|
|
1111
|
+
getConversationFilePath: vi.fn(),
|
|
1112
|
+
}),
|
|
1113
|
+
};
|
|
1114
|
+
const mockChatInitial = {
|
|
1115
|
+
getLastPromptTokenCount: vi.fn().mockReturnValue(initialTokenCount),
|
|
1116
|
+
getHistory: vi
|
|
1117
|
+
.fn()
|
|
1118
|
+
.mockReturnValue([{ role: 'user', parts: [{ text: 'old' }] }]),
|
|
1119
|
+
addHistory: vi.fn(),
|
|
1120
|
+
setTools: vi.fn(),
|
|
1121
|
+
getChatRecordingService: vi.fn().mockReturnValue({
|
|
1122
|
+
getConversation: vi.fn(),
|
|
1123
|
+
getConversationFilePath: vi.fn(),
|
|
1124
|
+
}),
|
|
1125
|
+
};
|
|
1126
|
+
client['chat'] = mockChatInitial;
|
|
1127
|
+
// Mock tryCompressChat to simulate successful compression
|
|
1128
|
+
const tryCompressSpy = vi
|
|
1129
|
+
.spyOn(client, 'tryCompressChat')
|
|
1130
|
+
.mockImplementation(async () => {
|
|
1131
|
+
// In reality, tryCompressChat replaces this.chat
|
|
1132
|
+
client['chat'] = mockChatCompressed;
|
|
1133
|
+
return {
|
|
1134
|
+
originalTokenCount: initialTokenCount,
|
|
1135
|
+
newTokenCount: 400,
|
|
1136
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
1137
|
+
};
|
|
1138
|
+
});
|
|
1139
|
+
// Use a manual spy on Turn.prototype.run since Turn is a real class in this test context
|
|
1140
|
+
// but mocked at the top of the file
|
|
1141
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1142
|
+
yield { type: 'content', value: 'Success after compression' };
|
|
1143
|
+
});
|
|
1144
|
+
// Act
|
|
1145
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'prompt-id-compression-test');
|
|
1146
|
+
const events = await fromAsync(stream);
|
|
1147
|
+
// Assert
|
|
1148
|
+
// 1. Should NOT contain overflow warning
|
|
1149
|
+
expect(events).not.toContainEqual(expect.objectContaining({
|
|
1150
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
1151
|
+
}));
|
|
1152
|
+
// 2. Should contain compression event
|
|
1153
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1154
|
+
type: GeminiEventType.ChatCompressed,
|
|
1155
|
+
}));
|
|
1156
|
+
// 3. Should have called tryCompressChat
|
|
1157
|
+
expect(tryCompressSpy).toHaveBeenCalled();
|
|
1158
|
+
// 4. Should have called Turn.run (proceeded with the request)
|
|
1159
|
+
expect(mockTurnRunFn).toHaveBeenCalled();
|
|
1160
|
+
});
|
|
1161
|
+
it('should handle massive function responses by truncating them and then yielding overflow warning', async () => {
|
|
1162
|
+
// Arrange
|
|
1163
|
+
const MOCKED_TOKEN_LIMIT = 1000;
|
|
1164
|
+
vi.mocked(tokenLimit).mockReturnValue(MOCKED_TOKEN_LIMIT);
|
|
1165
|
+
// History has a large compressible part and a massive function response at the end.
|
|
1166
|
+
const massiveText = 'a'.repeat(200000);
|
|
1167
|
+
const history = [
|
|
1168
|
+
{ role: 'user', parts: [{ text: 'a'.repeat(100000) }] }, // compressible part
|
|
1169
|
+
{ role: 'model', parts: [{ text: 'ok' }] },
|
|
1170
|
+
{
|
|
1171
|
+
role: 'model',
|
|
1172
|
+
parts: [{ functionCall: { name: 'huge_tool', args: {} } }],
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
role: 'user',
|
|
1176
|
+
parts: [
|
|
1177
|
+
{
|
|
1178
|
+
functionResponse: {
|
|
1179
|
+
name: 'huge_tool',
|
|
1180
|
+
response: { data: massiveText },
|
|
1181
|
+
},
|
|
1182
|
+
},
|
|
1183
|
+
],
|
|
1184
|
+
},
|
|
1185
|
+
];
|
|
1186
|
+
const realChat = new GeminiChat(mockConfig, '', [], history);
|
|
1187
|
+
client['chat'] = realChat;
|
|
1188
|
+
// Use a realistic mock for compression that simulates the 40k truncation effect.
|
|
1189
|
+
// We spy on the instance directly to ensure it intercepts correctly.
|
|
1190
|
+
const compressSpy = vi
|
|
1191
|
+
.spyOn(client['compressionService'], 'compress')
|
|
1192
|
+
.mockResolvedValue({
|
|
1193
|
+
newHistory: history, // Keep history large for the overflow check
|
|
1194
|
+
info: {
|
|
1195
|
+
originalTokenCount: 50000,
|
|
1196
|
+
newTokenCount: 10000, // Reduced from 50k but still > 1000 limit
|
|
1197
|
+
compressionStatus: CompressionStatus.COMPRESSED,
|
|
1198
|
+
},
|
|
1199
|
+
});
|
|
1200
|
+
// The new request
|
|
1201
|
+
const request = [{ text: 'next question' }];
|
|
1202
|
+
// Act
|
|
1203
|
+
const stream = client.sendMessageStream(request, new AbortController().signal, 'prompt-id-massive-test');
|
|
1204
|
+
const events = await fromAsync(stream);
|
|
1205
|
+
// Assert
|
|
1206
|
+
// 1. Should have attempted compression
|
|
1207
|
+
expect(compressSpy).toHaveBeenCalled();
|
|
1208
|
+
// 2. Should yield overflow warning because 10000 > 1000 limit.
|
|
1209
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
1210
|
+
type: GeminiEventType.ContextWindowWillOverflow,
|
|
1211
|
+
value: expect.objectContaining({
|
|
1212
|
+
estimatedRequestTokenCount: expect.any(Number),
|
|
1213
|
+
remainingTokenCount: expect.any(Number),
|
|
1214
|
+
}),
|
|
1215
|
+
}));
|
|
1216
|
+
});
|
|
1033
1217
|
it('should not trigger overflow warning for requests with large binary data (PDFs/images)', async () => {
|
|
1034
1218
|
// Arrange
|
|
1035
1219
|
const MOCKED_TOKEN_LIMIT = 1000000; // 1M tokens
|
|
@@ -1037,6 +1221,7 @@ ${JSON.stringify({
|
|
|
1037
1221
|
const lastPromptTokenCount = 10000;
|
|
1038
1222
|
const mockChat = {
|
|
1039
1223
|
getLastPromptTokenCount: vi.fn().mockReturnValue(lastPromptTokenCount),
|
|
1224
|
+
setTools: vi.fn(),
|
|
1040
1225
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1041
1226
|
};
|
|
1042
1227
|
client['chat'] = mockChat;
|
|
@@ -1089,6 +1274,7 @@ ${JSON.stringify({
|
|
|
1089
1274
|
})());
|
|
1090
1275
|
const mockChat = {
|
|
1091
1276
|
addHistory: vi.fn(),
|
|
1277
|
+
setTools: vi.fn(),
|
|
1092
1278
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1093
1279
|
getLastPromptTokenCount: vi.fn(),
|
|
1094
1280
|
};
|
|
@@ -1099,28 +1285,28 @@ ${JSON.stringify({
|
|
|
1099
1285
|
await fromAsync(stream); // consume stream
|
|
1100
1286
|
expect(mockConfig.getModelRouterService).toHaveBeenCalled();
|
|
1101
1287
|
expect(mockRouterService.route).toHaveBeenCalled();
|
|
1102
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1288
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model', isChatModel: true }, [{ text: 'Hi' }], expect.any(AbortSignal), undefined);
|
|
1103
1289
|
});
|
|
1104
1290
|
it('should use the same model for subsequent turns in the same prompt (stickiness)', async () => {
|
|
1105
1291
|
// First turn
|
|
1106
1292
|
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1107
1293
|
await fromAsync(stream);
|
|
1108
1294
|
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1109
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1295
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model', isChatModel: true }, [{ text: 'Hi' }], expect.any(AbortSignal), undefined);
|
|
1110
1296
|
// Second turn
|
|
1111
1297
|
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-1');
|
|
1112
1298
|
await fromAsync(stream);
|
|
1113
1299
|
// Router should not be called again
|
|
1114
1300
|
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1115
1301
|
// Should stick to the first model
|
|
1116
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Continue' }], expect.any(AbortSignal));
|
|
1302
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model', isChatModel: true }, [{ text: 'Continue' }], expect.any(AbortSignal), undefined);
|
|
1117
1303
|
});
|
|
1118
1304
|
it('should reset the sticky model and re-route when the prompt_id changes', async () => {
|
|
1119
1305
|
// First prompt
|
|
1120
1306
|
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1121
1307
|
await fromAsync(stream);
|
|
1122
1308
|
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1123
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model' }, [{ text: 'Hi' }], expect.any(AbortSignal));
|
|
1309
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'routed-model', isChatModel: true }, [{ text: 'Hi' }], expect.any(AbortSignal), undefined);
|
|
1124
1310
|
// New prompt
|
|
1125
1311
|
mockRouterService.route.mockResolvedValue({
|
|
1126
1312
|
model: 'new-routed-model',
|
|
@@ -1131,7 +1317,31 @@ ${JSON.stringify({
|
|
|
1131
1317
|
// Router should be called again for the new prompt
|
|
1132
1318
|
expect(mockRouterService.route).toHaveBeenCalledTimes(2);
|
|
1133
1319
|
// Should use the newly routed model
|
|
1134
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'new-routed-model' }, [{ text: 'A new topic' }], expect.any(AbortSignal));
|
|
1320
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith({ model: 'new-routed-model', isChatModel: true }, [{ text: 'A new topic' }], expect.any(AbortSignal), undefined);
|
|
1321
|
+
});
|
|
1322
|
+
it('should re-route within the same prompt when the configured model changes', async () => {
|
|
1323
|
+
mockTurnRunFn.mockClear();
|
|
1324
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
1325
|
+
yield { type: 'content', value: 'Hello' };
|
|
1326
|
+
});
|
|
1327
|
+
mockRouterService.route.mockResolvedValueOnce({
|
|
1328
|
+
model: 'original-model',
|
|
1329
|
+
reason: 'test',
|
|
1330
|
+
});
|
|
1331
|
+
let stream = client.sendMessageStream([{ text: 'Hi' }], new AbortController().signal, 'prompt-1');
|
|
1332
|
+
await fromAsync(stream);
|
|
1333
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(1);
|
|
1334
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(1, { model: 'original-model', isChatModel: true }, [{ text: 'Hi' }], expect.any(AbortSignal), undefined);
|
|
1335
|
+
mockRouterService.route.mockResolvedValue({
|
|
1336
|
+
model: 'fallback-model',
|
|
1337
|
+
reason: 'test',
|
|
1338
|
+
});
|
|
1339
|
+
vi.mocked(mockConfig.getModel).mockReturnValue('gemini-2.5-flash');
|
|
1340
|
+
coreEvents.emitModelChanged('gemini-2.5-flash');
|
|
1341
|
+
stream = client.sendMessageStream([{ text: 'Continue' }], new AbortController().signal, 'prompt-1');
|
|
1342
|
+
await fromAsync(stream);
|
|
1343
|
+
expect(mockRouterService.route).toHaveBeenCalledTimes(2);
|
|
1344
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, { model: 'fallback-model', isChatModel: true }, [{ text: 'Continue' }], expect.any(AbortSignal), undefined);
|
|
1135
1345
|
});
|
|
1136
1346
|
});
|
|
1137
1347
|
it('should use getGlobalMemory for system instruction when JIT is enabled', async () => {
|
|
@@ -1140,15 +1350,15 @@ ${JSON.stringify({
|
|
|
1140
1350
|
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Full JIT Memory');
|
|
1141
1351
|
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1142
1352
|
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1143
|
-
|
|
1144
|
-
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, '
|
|
1353
|
+
client.updateSystemInstruction();
|
|
1354
|
+
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Full JIT Memory');
|
|
1145
1355
|
});
|
|
1146
1356
|
it('should use getUserMemory for system instruction when JIT is disabled', async () => {
|
|
1147
1357
|
vi.mocked(mockConfig.isJitContextEnabled).mockReturnValue(false);
|
|
1148
1358
|
vi.mocked(mockConfig.getUserMemory).mockReturnValue('Legacy Memory');
|
|
1149
1359
|
const { getCoreSystemPrompt } = await import('./prompts.js');
|
|
1150
1360
|
const mockGetCoreSystemPrompt = vi.mocked(getCoreSystemPrompt);
|
|
1151
|
-
|
|
1361
|
+
client.updateSystemInstruction();
|
|
1152
1362
|
expect(mockGetCoreSystemPrompt).toHaveBeenCalledWith(mockConfig, 'Legacy Memory');
|
|
1153
1363
|
});
|
|
1154
1364
|
it('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received', async () => {
|
|
@@ -1165,6 +1375,7 @@ ${JSON.stringify({
|
|
|
1165
1375
|
.mockReturnValueOnce(mockStream2);
|
|
1166
1376
|
const mockChat = {
|
|
1167
1377
|
addHistory: vi.fn(),
|
|
1378
|
+
setTools: vi.fn(),
|
|
1168
1379
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1169
1380
|
getLastPromptTokenCount: vi.fn(),
|
|
1170
1381
|
};
|
|
@@ -1179,15 +1390,14 @@ ${JSON.stringify({
|
|
|
1179
1390
|
expect(events).toEqual([
|
|
1180
1391
|
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1181
1392
|
{ type: GeminiEventType.InvalidStream },
|
|
1182
|
-
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
|
1183
1393
|
{ type: GeminiEventType.Content, value: 'Continued content' },
|
|
1184
1394
|
]);
|
|
1185
1395
|
// Verify that turn.run was called twice
|
|
1186
1396
|
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
1187
1397
|
// First call with original request
|
|
1188
|
-
expect(mockTurnRunFn).toHaveBeenNthCalledWith(1, { model: 'default-routed-model' }, initialRequest, expect.any(AbortSignal));
|
|
1398
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(1, { model: 'default-routed-model', isChatModel: true }, initialRequest, expect.any(AbortSignal), undefined);
|
|
1189
1399
|
// Second call with "Please continue."
|
|
1190
|
-
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, { model: 'default-routed-model' }, [{ text: 'System: Please continue.' }], expect.any(AbortSignal));
|
|
1400
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, { model: 'default-routed-model', isChatModel: true }, [{ text: 'System: Please continue.' }], expect.any(AbortSignal), undefined);
|
|
1191
1401
|
});
|
|
1192
1402
|
it('should not recursively call sendMessageStream with "Please continue." when InvalidStream event is received and flag is false', async () => {
|
|
1193
1403
|
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(false);
|
|
@@ -1198,6 +1408,7 @@ ${JSON.stringify({
|
|
|
1198
1408
|
mockTurnRunFn.mockReturnValueOnce(mockStream1);
|
|
1199
1409
|
const mockChat = {
|
|
1200
1410
|
addHistory: vi.fn(),
|
|
1411
|
+
setTools: vi.fn(),
|
|
1201
1412
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1202
1413
|
getLastPromptTokenCount: vi.fn(),
|
|
1203
1414
|
};
|
|
@@ -1225,6 +1436,7 @@ ${JSON.stringify({
|
|
|
1225
1436
|
})());
|
|
1226
1437
|
const mockChat = {
|
|
1227
1438
|
addHistory: vi.fn(),
|
|
1439
|
+
setTools: vi.fn(),
|
|
1228
1440
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1229
1441
|
getLastPromptTokenCount: vi.fn(),
|
|
1230
1442
|
};
|
|
@@ -1236,11 +1448,11 @@ ${JSON.stringify({
|
|
|
1236
1448
|
const stream = client.sendMessageStream(initialRequest, signal, promptId);
|
|
1237
1449
|
const events = await fromAsync(stream);
|
|
1238
1450
|
// Assert
|
|
1239
|
-
// We expect
|
|
1240
|
-
expect(events.length).toBe(
|
|
1451
|
+
// We expect 3 events (model_info + original + 1 retry)
|
|
1452
|
+
expect(events.length).toBe(3);
|
|
1241
1453
|
expect(events
|
|
1242
|
-
.filter((e) => e.type
|
|
1243
|
-
.
|
|
1454
|
+
.filter((e) => e.type === GeminiEventType.ModelInfo)
|
|
1455
|
+
.map((e) => e.value)).toEqual(['default-routed-model']);
|
|
1244
1456
|
// Verify that turn.run was called twice
|
|
1245
1457
|
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
1246
1458
|
});
|
|
@@ -1260,6 +1472,7 @@ ${JSON.stringify({
|
|
|
1260
1472
|
const mockChat = {
|
|
1261
1473
|
addHistory: vi.fn(),
|
|
1262
1474
|
setHistory: vi.fn(),
|
|
1475
|
+
setTools: vi.fn(),
|
|
1263
1476
|
// Assume history is not empty for delta checks
|
|
1264
1477
|
getHistory: vi
|
|
1265
1478
|
.fn()
|
|
@@ -1505,7 +1718,7 @@ ${JSON.stringify({
|
|
|
1505
1718
|
expect(mockConfig.setActiveModel).toHaveBeenCalledWith('model-a');
|
|
1506
1719
|
expect(mockAvailabilityService.consumeStickyAttempt).not.toHaveBeenCalled();
|
|
1507
1720
|
// Ensure turn.run used the selected model
|
|
1508
|
-
expect(mockTurnRunFn).toHaveBeenCalledWith(expect.objectContaining({ model: 'model-a' }), expect.anything(), expect.anything());
|
|
1721
|
+
expect(mockTurnRunFn).toHaveBeenCalledWith(expect.objectContaining({ model: 'model-a' }), expect.anything(), expect.anything(), undefined);
|
|
1509
1722
|
});
|
|
1510
1723
|
it('should default to last resort model if selection returns null', async () => {
|
|
1511
1724
|
vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
|
|
@@ -1567,6 +1780,7 @@ ${JSON.stringify({
|
|
|
1567
1780
|
addHistory: vi.fn(),
|
|
1568
1781
|
getHistory: vi.fn().mockReturnValue([]), // Default empty history
|
|
1569
1782
|
setHistory: vi.fn(),
|
|
1783
|
+
setTools: vi.fn(),
|
|
1570
1784
|
getLastPromptTokenCount: vi.fn(),
|
|
1571
1785
|
};
|
|
1572
1786
|
client['chat'] = mockChat;
|
|
@@ -1830,6 +2044,7 @@ ${JSON.stringify({
|
|
|
1830
2044
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1831
2045
|
const mockChat = {
|
|
1832
2046
|
addHistory: vi.fn(),
|
|
2047
|
+
setTools: vi.fn(),
|
|
1833
2048
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1834
2049
|
getLastPromptTokenCount: vi.fn(),
|
|
1835
2050
|
};
|
|
@@ -1856,6 +2071,7 @@ ${JSON.stringify({
|
|
|
1856
2071
|
mockTurnRunFn.mockReturnValue(mockStream);
|
|
1857
2072
|
const mockChat = {
|
|
1858
2073
|
addHistory: vi.fn(),
|
|
2074
|
+
setTools: vi.fn(),
|
|
1859
2075
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1860
2076
|
getLastPromptTokenCount: vi.fn(),
|
|
1861
2077
|
};
|
|
@@ -1884,6 +2100,7 @@ ${JSON.stringify({
|
|
|
1884
2100
|
});
|
|
1885
2101
|
const mockChat = {
|
|
1886
2102
|
addHistory: vi.fn(),
|
|
2103
|
+
setTools: vi.fn(),
|
|
1887
2104
|
getHistory: vi.fn().mockReturnValue([]),
|
|
1888
2105
|
getLastPromptTokenCount: vi.fn(),
|
|
1889
2106
|
};
|
|
@@ -1903,7 +2120,7 @@ ${JSON.stringify({
|
|
|
1903
2120
|
it('should call generateContent with the correct parameters', async () => {
|
|
1904
2121
|
const contents = [{ role: 'user', parts: [{ text: 'hello' }] }];
|
|
1905
2122
|
const abortSignal = new AbortController().signal;
|
|
1906
|
-
await client.generateContent({ model: 'test-model' }, contents, abortSignal);
|
|
2123
|
+
await client.generateContent({ model: 'test-model' }, contents, abortSignal, LlmRole.MAIN);
|
|
1907
2124
|
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith({
|
|
1908
2125
|
model: 'test-model',
|
|
1909
2126
|
config: {
|
|
@@ -1913,15 +2130,15 @@ ${JSON.stringify({
|
|
|
1913
2130
|
topP: 1,
|
|
1914
2131
|
},
|
|
1915
2132
|
contents,
|
|
1916
|
-
}, 'test-session-id');
|
|
2133
|
+
}, 'test-session-id', LlmRole.MAIN);
|
|
1917
2134
|
});
|
|
1918
2135
|
it('should use current model from config for content generation', async () => {
|
|
1919
2136
|
const initialModel = 'test-model';
|
|
1920
2137
|
const contents = [{ role: 'user', parts: [{ text: 'test' }] }];
|
|
1921
|
-
await client.generateContent({ model: initialModel }, contents, new AbortController().signal);
|
|
2138
|
+
await client.generateContent({ model: initialModel }, contents, new AbortController().signal, LlmRole.MAIN);
|
|
1922
2139
|
expect(mockContentGenerator.generateContent).toHaveBeenCalledWith(expect.objectContaining({
|
|
1923
2140
|
model: initialModel,
|
|
1924
|
-
}), 'test-session-id');
|
|
2141
|
+
}), 'test-session-id', LlmRole.MAIN);
|
|
1925
2142
|
});
|
|
1926
2143
|
describe('Hook System', () => {
|
|
1927
2144
|
let mockMessageBus;
|
|
@@ -1938,7 +2155,6 @@ ${JSON.stringify({
|
|
|
1938
2155
|
const promptId = 'test-prompt-hook-1';
|
|
1939
2156
|
const request = { text: 'Hello Hooks' };
|
|
1940
2157
|
const signal = new AbortController().signal;
|
|
1941
|
-
const { fireBeforeAgentHook, fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1942
2158
|
mockTurnRunFn.mockImplementation(async function* () {
|
|
1943
2159
|
this.getResponseText.mockReturnValue('Hook Response');
|
|
1944
2160
|
yield { type: GeminiEventType.Content, value: 'Hook Response' };
|
|
@@ -1946,9 +2162,9 @@ ${JSON.stringify({
|
|
|
1946
2162
|
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1947
2163
|
while (!(await stream.next()).done)
|
|
1948
2164
|
;
|
|
1949
|
-
expect(
|
|
1950
|
-
expect(
|
|
1951
|
-
expect(
|
|
2165
|
+
expect(mockHookSystem.fireBeforeAgentEvent).toHaveBeenCalledTimes(1);
|
|
2166
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledTimes(1);
|
|
2167
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), 'Hook Response');
|
|
1952
2168
|
// Map should be empty
|
|
1953
2169
|
expect(client['hookStateMap'].size).toBe(0);
|
|
1954
2170
|
});
|
|
@@ -1960,7 +2176,6 @@ ${JSON.stringify({
|
|
|
1960
2176
|
const promptId = 'test-prompt-hook-recursive';
|
|
1961
2177
|
const request = { text: 'Recursion Test' };
|
|
1962
2178
|
const signal = new AbortController().signal;
|
|
1963
|
-
const { fireBeforeAgentHook, fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1964
2179
|
let callCount = 0;
|
|
1965
2180
|
mockTurnRunFn.mockImplementation(async function* () {
|
|
1966
2181
|
callCount++;
|
|
@@ -1972,11 +2187,11 @@ ${JSON.stringify({
|
|
|
1972
2187
|
while (!(await stream.next()).done)
|
|
1973
2188
|
;
|
|
1974
2189
|
// BeforeAgent should fire ONLY once despite multiple internal turns
|
|
1975
|
-
expect(
|
|
2190
|
+
expect(mockHookSystem.fireBeforeAgentEvent).toHaveBeenCalledTimes(1);
|
|
1976
2191
|
// AfterAgent should fire ONLY when the stack unwinds
|
|
1977
|
-
expect(
|
|
2192
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledTimes(1);
|
|
1978
2193
|
// Check cumulative response (separated by newline)
|
|
1979
|
-
expect(
|
|
2194
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), 'Response 1\nResponse 2');
|
|
1980
2195
|
expect(client['hookStateMap'].size).toBe(0);
|
|
1981
2196
|
});
|
|
1982
2197
|
it('should use original request in AfterAgent hook even when continuation happened', async () => {
|
|
@@ -1987,7 +2202,6 @@ ${JSON.stringify({
|
|
|
1987
2202
|
const promptId = 'test-prompt-hook-original-req';
|
|
1988
2203
|
const request = { text: 'Do something' };
|
|
1989
2204
|
const signal = new AbortController().signal;
|
|
1990
|
-
const { fireAfterAgentHook } = await import('./clientHookTriggers.js');
|
|
1991
2205
|
mockTurnRunFn.mockImplementation(async function* () {
|
|
1992
2206
|
this.getResponseText.mockReturnValue('Ok');
|
|
1993
2207
|
yield { type: GeminiEventType.Content, value: 'Ok' };
|
|
@@ -1995,7 +2209,7 @@ ${JSON.stringify({
|
|
|
1995
2209
|
const stream = client.sendMessageStream(request, signal, promptId);
|
|
1996
2210
|
while (!(await stream.next()).done)
|
|
1997
2211
|
;
|
|
1998
|
-
expect(
|
|
2212
|
+
expect(mockHookSystem.fireAfterAgentEvent).toHaveBeenCalledWith(partToString(request), // Should be 'Do something'
|
|
1999
2213
|
expect.stringContaining('Ok'));
|
|
2000
2214
|
});
|
|
2001
2215
|
it('should cleanup state when prompt_id changes', async () => {
|
|
@@ -2017,13 +2231,14 @@ ${JSON.stringify({
|
|
|
2017
2231
|
expect(client['hookStateMap'].has('new-id')).toBe(true);
|
|
2018
2232
|
});
|
|
2019
2233
|
it('should stop execution in BeforeAgent when hook returns continue: false', async () => {
|
|
2020
|
-
|
|
2021
|
-
vi.mocked(fireBeforeAgentHook).mockResolvedValue({
|
|
2234
|
+
mockHookSystem.fireBeforeAgentEvent.mockResolvedValue({
|
|
2022
2235
|
shouldStopExecution: () => true,
|
|
2023
2236
|
getEffectiveReason: () => 'Stopped by hook',
|
|
2237
|
+
systemMessage: undefined,
|
|
2024
2238
|
});
|
|
2025
2239
|
const mockChat = {
|
|
2026
2240
|
addHistory: vi.fn(),
|
|
2241
|
+
setTools: vi.fn(),
|
|
2027
2242
|
getHistory: vi.fn().mockReturnValue([]),
|
|
2028
2243
|
getLastPromptTokenCount: vi.fn(),
|
|
2029
2244
|
};
|
|
@@ -2042,14 +2257,15 @@ ${JSON.stringify({
|
|
|
2042
2257
|
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2043
2258
|
});
|
|
2044
2259
|
it('should block execution in BeforeAgent when hook returns decision: block', async () => {
|
|
2045
|
-
|
|
2046
|
-
vi.mocked(fireBeforeAgentHook).mockResolvedValue({
|
|
2260
|
+
mockHookSystem.fireBeforeAgentEvent.mockResolvedValue({
|
|
2047
2261
|
shouldStopExecution: () => false,
|
|
2048
2262
|
isBlockingDecision: () => true,
|
|
2049
2263
|
getEffectiveReason: () => 'Blocked by hook',
|
|
2264
|
+
systemMessage: undefined,
|
|
2050
2265
|
});
|
|
2051
2266
|
const mockChat = {
|
|
2052
2267
|
addHistory: vi.fn(),
|
|
2268
|
+
setTools: vi.fn(),
|
|
2053
2269
|
getHistory: vi.fn().mockReturnValue([]),
|
|
2054
2270
|
getLastPromptTokenCount: vi.fn(),
|
|
2055
2271
|
};
|
|
@@ -2067,47 +2283,85 @@ ${JSON.stringify({
|
|
|
2067
2283
|
expect(mockTurnRunFn).not.toHaveBeenCalled();
|
|
2068
2284
|
});
|
|
2069
2285
|
it('should stop execution in AfterAgent when hook returns continue: false', async () => {
|
|
2070
|
-
|
|
2071
|
-
vi.mocked(fireAfterAgentHook).mockResolvedValue({
|
|
2286
|
+
mockHookSystem.fireAfterAgentEvent.mockResolvedValue({
|
|
2072
2287
|
shouldStopExecution: () => true,
|
|
2073
2288
|
getEffectiveReason: () => 'Stopped after agent',
|
|
2289
|
+
shouldClearContext: () => false,
|
|
2290
|
+
systemMessage: undefined,
|
|
2074
2291
|
});
|
|
2075
2292
|
mockTurnRunFn.mockImplementation(async function* () {
|
|
2076
2293
|
yield { type: GeminiEventType.Content, value: 'Hello' };
|
|
2077
2294
|
});
|
|
2078
2295
|
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2079
2296
|
const events = await fromAsync(stream);
|
|
2080
|
-
expect(events).toContainEqual({
|
|
2297
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
2081
2298
|
type: GeminiEventType.AgentExecutionStopped,
|
|
2082
|
-
value: { reason: 'Stopped after agent' },
|
|
2083
|
-
});
|
|
2299
|
+
value: expect.objectContaining({ reason: 'Stopped after agent' }),
|
|
2300
|
+
}));
|
|
2084
2301
|
// sendMessageStream should not recurse
|
|
2085
2302
|
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
|
2086
2303
|
});
|
|
2087
2304
|
it('should yield AgentExecutionBlocked and recurse in AfterAgent when hook returns decision: block', async () => {
|
|
2088
|
-
|
|
2089
|
-
vi.mocked(fireAfterAgentHook)
|
|
2305
|
+
mockHookSystem.fireAfterAgentEvent
|
|
2090
2306
|
.mockResolvedValueOnce({
|
|
2091
2307
|
shouldStopExecution: () => false,
|
|
2092
2308
|
isBlockingDecision: () => true,
|
|
2093
2309
|
getEffectiveReason: () => 'Please explain',
|
|
2310
|
+
shouldClearContext: () => false,
|
|
2311
|
+
systemMessage: undefined,
|
|
2094
2312
|
})
|
|
2095
2313
|
.mockResolvedValueOnce({
|
|
2096
2314
|
shouldStopExecution: () => false,
|
|
2097
2315
|
isBlockingDecision: () => false,
|
|
2316
|
+
shouldClearContext: () => false,
|
|
2317
|
+
systemMessage: undefined,
|
|
2098
2318
|
});
|
|
2099
2319
|
mockTurnRunFn.mockImplementation(async function* () {
|
|
2100
2320
|
yield { type: GeminiEventType.Content, value: 'Response' };
|
|
2101
2321
|
});
|
|
2102
2322
|
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2103
2323
|
const events = await fromAsync(stream);
|
|
2104
|
-
expect(events).toContainEqual({
|
|
2324
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
2105
2325
|
type: GeminiEventType.AgentExecutionBlocked,
|
|
2106
|
-
value: { reason: 'Please explain' },
|
|
2107
|
-
});
|
|
2326
|
+
value: expect.objectContaining({ reason: 'Please explain' }),
|
|
2327
|
+
}));
|
|
2108
2328
|
// Should have called turn run twice (original + re-prompt)
|
|
2109
2329
|
expect(mockTurnRunFn).toHaveBeenCalledTimes(2);
|
|
2110
|
-
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, expect.anything(), [{ text: 'Please explain' }], expect.anything());
|
|
2330
|
+
expect(mockTurnRunFn).toHaveBeenNthCalledWith(2, expect.anything(), [{ text: 'Please explain' }], expect.anything(), undefined);
|
|
2331
|
+
});
|
|
2332
|
+
it('should call resetChat when AfterAgent hook returns shouldClearContext: true', async () => {
|
|
2333
|
+
const resetChatSpy = vi
|
|
2334
|
+
.spyOn(client, 'resetChat')
|
|
2335
|
+
.mockResolvedValue(undefined);
|
|
2336
|
+
mockHookSystem.fireAfterAgentEvent
|
|
2337
|
+
.mockResolvedValueOnce({
|
|
2338
|
+
shouldStopExecution: () => false,
|
|
2339
|
+
isBlockingDecision: () => true,
|
|
2340
|
+
getEffectiveReason: () => 'Blocked and clearing context',
|
|
2341
|
+
shouldClearContext: () => true,
|
|
2342
|
+
systemMessage: undefined,
|
|
2343
|
+
})
|
|
2344
|
+
.mockResolvedValueOnce({
|
|
2345
|
+
shouldStopExecution: () => false,
|
|
2346
|
+
isBlockingDecision: () => false,
|
|
2347
|
+
shouldClearContext: () => false,
|
|
2348
|
+
systemMessage: undefined,
|
|
2349
|
+
});
|
|
2350
|
+
mockTurnRunFn.mockImplementation(async function* () {
|
|
2351
|
+
yield { type: GeminiEventType.Content, value: 'Response' };
|
|
2352
|
+
});
|
|
2353
|
+
const stream = client.sendMessageStream({ text: 'Hi' }, new AbortController().signal, 'test-prompt');
|
|
2354
|
+
const events = await fromAsync(stream);
|
|
2355
|
+
expect(events).toContainEqual({
|
|
2356
|
+
type: GeminiEventType.AgentExecutionBlocked,
|
|
2357
|
+
value: {
|
|
2358
|
+
reason: 'Blocked and clearing context',
|
|
2359
|
+
systemMessage: undefined,
|
|
2360
|
+
contextCleared: true,
|
|
2361
|
+
},
|
|
2362
|
+
});
|
|
2363
|
+
expect(resetChatSpy).toHaveBeenCalledTimes(1);
|
|
2364
|
+
resetChatSpy.mockRestore();
|
|
2111
2365
|
});
|
|
2112
2366
|
});
|
|
2113
2367
|
});
|