@google/gemini-cli-core 0.26.0-preview.4 → 0.27.0-nightly.20260126.cb772a5b7
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/README.md +18 -1
- package/dist/docs/changelogs/index.md +87 -0
- package/dist/docs/changelogs/latest.md +355 -150
- package/dist/docs/changelogs/preview.md +318 -210
- package/dist/docs/cli/commands.md +0 -6
- package/dist/docs/cli/keyboard-shortcuts.md +32 -31
- package/dist/docs/cli/settings.md +16 -18
- package/dist/docs/cli/system-prompt.md +32 -0
- package/dist/docs/cli/uninstall.md +18 -0
- package/dist/docs/extensions/index.md +1 -1
- package/dist/docs/get-started/configuration.md +9 -34
- package/dist/docs/hooks/best-practices.md +219 -398
- package/dist/docs/hooks/index.md +111 -656
- package/dist/docs/hooks/reference.md +280 -136
- package/dist/docs/hooks/writing-hooks.md +202 -796
- package/dist/docs/sidebar.json +1 -5
- package/dist/docs/tools/mcp-server.md +24 -1
- package/dist/google-gemini-cli-core-0.27.0-nightly.20260121.97aac696f.tgz +0 -0
- package/dist/src/agents/agentLoader.js +10 -10
- package/dist/src/agents/agentLoader.js.map +1 -1
- package/dist/src/agents/agentLoader.test.js +16 -19
- package/dist/src/agents/agentLoader.test.js.map +1 -1
- package/dist/src/agents/cli-help-agent.js +8 -5
- package/dist/src/agents/cli-help-agent.js.map +1 -1
- package/dist/src/agents/cli-help-agent.test.js +4 -2
- package/dist/src/agents/cli-help-agent.test.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +2 -1
- package/dist/src/agents/codebase-investigator.js +62 -41
- package/dist/src/agents/codebase-investigator.js.map +1 -1
- package/dist/src/agents/codebase-investigator.test.js +15 -8
- package/dist/src/agents/codebase-investigator.test.js.map +1 -1
- package/dist/src/agents/generalist-agent.js +9 -11
- package/dist/src/agents/generalist-agent.js.map +1 -1
- package/dist/src/agents/generalist-agent.test.js +3 -3
- package/dist/src/agents/generalist-agent.test.js.map +1 -1
- package/dist/src/agents/local-executor.js +25 -9
- package/dist/src/agents/local-executor.js.map +1 -1
- package/dist/src/agents/local-executor.test.js +74 -7
- package/dist/src/agents/local-executor.test.js.map +1 -1
- package/dist/src/agents/local-invocation.test.js +7 -3
- package/dist/src/agents/local-invocation.test.js.map +1 -1
- package/dist/src/agents/registry.d.ts +8 -5
- package/dist/src/agents/registry.js +31 -75
- package/dist/src/agents/registry.js.map +1 -1
- package/dist/src/agents/registry.test.js +93 -30
- package/dist/src/agents/registry.test.js.map +1 -1
- package/dist/src/agents/remote-invocation.js +2 -1
- package/dist/src/agents/remote-invocation.js.map +1 -1
- package/dist/src/agents/remote-invocation.test.js +15 -3
- 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 +10 -25
- 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 +61 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/types.d.ts +6 -9
- package/dist/src/agents/types.js +4 -0
- package/dist/src/agents/types.js.map +1 -1
- package/dist/src/code_assist/codeAssist.js +1 -1
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.js +2 -2
- package/dist/src/code_assist/codeAssist.test.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.js +11 -6
- package/dist/src/code_assist/experiments/experiments_local.test.js.map +1 -1
- package/dist/src/code_assist/experiments/flagNames.d.ts +2 -0
- package/dist/src/code_assist/experiments/flagNames.js +2 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +3 -3
- package/dist/src/code_assist/oauth2.test.js +1 -1
- package/dist/src/code_assist/server.d.ts +2 -1
- package/dist/src/code_assist/server.js +3 -1
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +1 -0
- package/dist/src/code_assist/setup.js +5 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +10 -4
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/config/config.d.ts +25 -18
- package/dist/src/config/config.js +70 -40
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +48 -21
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/confirmation-bus/message-bus.js +2 -32
- package/dist/src/confirmation-bus/message-bus.js.map +1 -1
- package/dist/src/confirmation-bus/types.d.ts +35 -21
- package/dist/src/confirmation-bus/types.js +8 -3
- package/dist/src/confirmation-bus/types.js.map +1 -1
- package/dist/src/core/client.js +25 -7
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +52 -6
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +1 -0
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolHookTriggers.d.ts +2 -38
- package/dist/src/core/coreToolHookTriggers.js +12 -159
- 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.js +3 -5
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +3 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +1 -0
- package/dist/src/core/fakeContentGenerator.js +1 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -1
- package/dist/src/core/geminiChat.js +1 -0
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +21 -0
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiChat_network_retry.test.js +17 -12
- package/dist/src/core/geminiChat_network_retry.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +3 -0
- package/dist/src/core/loggingContentGenerator.js +6 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.js +11 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts-substitution.test.js +101 -0
- package/dist/src/core/prompts-substitution.test.js.map +1 -0
- package/dist/src/core/prompts.js +115 -31
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +32 -0
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +2 -1
- package/dist/src/core/recordingContentGenerator.js +6 -1
- package/dist/src/core/recordingContentGenerator.js.map +1 -1
- package/dist/src/core/turn.d.ts +2 -0
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.js +13 -3
- package/dist/src/hooks/hookAggregator.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.d.ts +1 -13
- package/dist/src/hooks/hookEventHandler.js +1 -289
- package/dist/src/hooks/hookEventHandler.js.map +1 -1
- package/dist/src/hooks/hookEventHandler.test.js +1 -4
- package/dist/src/hooks/hookEventHandler.test.js.map +1 -1
- package/dist/src/hooks/hookSystem.d.ts +47 -3
- package/dist/src/hooks/hookSystem.js +90 -6
- package/dist/src/hooks/hookSystem.js.map +1 -1
- package/dist/src/hooks/hookSystem.test.js +19 -8
- package/dist/src/hooks/hookSystem.test.js.map +1 -1
- package/dist/src/hooks/types.d.ts +23 -1
- package/dist/src/hooks/types.js +28 -2
- package/dist/src/hooks/types.js.map +1 -1
- package/dist/src/hooks/types.test.js +9 -1
- package/dist/src/hooks/types.test.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +41 -0
- package/dist/src/ide/detect-ide.js +47 -3
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +46 -0
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +1 -0
- package/dist/src/ide/ide-client.js +36 -9
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +154 -6
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +1 -2
- package/dist/src/mcp/oauth-provider.js +4 -8
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +32 -0
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +13 -4
- package/dist/src/mcp/oauth-utils.js +23 -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/policy/policy-engine.d.ts +1 -8
- package/dist/src/policy/policy-engine.js +1 -75
- package/dist/src/policy/policy-engine.js.map +1 -1
- package/dist/src/policy/policy-engine.test.js +0 -222
- package/dist/src/policy/policy-engine.test.js.map +1 -1
- 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/strategies/classifierStrategy.js +4 -7
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -1
- package/dist/src/routing/strategies/classifierStrategy.test.js +10 -4
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -1
- package/dist/src/routing/strategies/numericalClassifierStrategy.d.ts +13 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js +178 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js +347 -0
- package/dist/src/routing/strategies/numericalClassifierStrategy.test.js.map +1 -0
- package/dist/src/scheduler/confirmation.js +2 -3
- package/dist/src/scheduler/confirmation.js.map +1 -1
- package/dist/src/scheduler/confirmation.test.js +8 -8
- package/dist/src/scheduler/confirmation.test.js.map +1 -1
- package/dist/src/scheduler/scheduler.test.js +0 -3
- package/dist/src/scheduler/scheduler.test.js.map +1 -1
- package/dist/src/scheduler/state-manager.js +4 -0
- package/dist/src/scheduler/state-manager.js.map +1 -1
- package/dist/src/scheduler/state-manager.test.js +11 -0
- package/dist/src/scheduler/state-manager.test.js.map +1 -1
- package/dist/src/scheduler/tool-executor.js +2 -4
- package/dist/src/scheduler/tool-executor.js.map +1 -1
- package/dist/src/scheduler/tool-executor.test.js +1 -1
- package/dist/src/scheduler/tool-executor.test.js.map +1 -1
- package/dist/src/services/chatRecordingService.d.ts +1 -1
- package/dist/src/services/chatRecordingService.js +23 -1
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +111 -0
- package/dist/src/services/chatRecordingService.test.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/telemetry/metrics.js +15 -4
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +7 -0
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +3 -1
- package/dist/src/telemetry/types.js +19 -4
- package/dist/src/telemetry/types.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 +1 -65
- package/dist/src/test-utils/mock-message-bus.js.map +1 -1
- package/dist/src/tools/ask-user.d.ts +20 -0
- package/dist/src/tools/ask-user.js +142 -0
- package/dist/src/tools/ask-user.js.map +1 -0
- package/dist/src/{core/geminiChatHookTriggers.test.d.ts → tools/ask-user.test.d.ts} +1 -1
- package/dist/src/tools/ask-user.test.js +187 -0
- package/dist/src/tools/ask-user.test.js.map +1 -0
- package/dist/src/tools/confirmation-policy.test.js +1 -1
- package/dist/src/tools/confirmation-policy.test.js.map +1 -1
- 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.js +1 -1
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +11 -3
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +13 -4
- package/dist/src/tools/mcp-client-manager.js +53 -21
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +1 -0
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +1 -2
- package/dist/src/tools/mcp-client.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-many-files.js +3 -2
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/ripGrep.js +7 -2
- package/dist/src/tools/ripGrep.js.map +1 -1
- package/dist/src/tools/ripGrep.test.js +2 -2
- package/dist/src/tools/ripGrep.test.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +8 -2
- package/dist/src/tools/tool-names.js +14 -2
- package/dist/src/tools/tool-names.js.map +1 -1
- package/dist/src/tools/tools.d.ts +1 -0
- package/dist/src/tools/tools.js +2 -1
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/write-file.test.js +7 -7
- package/dist/src/tools/write-file.test.js.map +1 -1
- 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/editCorrector.js +1 -1
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editor.js +4 -1
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +6 -4
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/events.d.ts +2 -0
- package/dist/src/utils/events.js +1 -0
- package/dist/src/utils/events.js.map +1 -1
- package/dist/src/utils/extensionLoader.js +1 -0
- package/dist/src/utils/extensionLoader.js.map +1 -1
- package/dist/src/utils/extensionLoader.test.js +11 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.d.ts +3 -3
- package/dist/src/utils/googleQuotaErrors.js +6 -17
- package/dist/src/utils/googleQuotaErrors.js.map +1 -1
- package/dist/src/utils/googleQuotaErrors.test.js +4 -22
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -1
- package/dist/src/utils/llm-edit-fixer.js +4 -7
- 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/memoryImportProcessor.js +7 -24
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- 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/schemaValidator.d.ts +6 -0
- package/dist/src/utils/schemaValidator.js +12 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +15 -0
- package/dist/src/utils/workspaceContext.js +32 -11
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +55 -0
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/dist/docs/changelogs/releases.md +0 -1543
- package/dist/google-gemini-cli-core-0.26.0-preview.3.tgz +0 -0
- package/dist/src/agents/delegate-to-agent-tool.d.ts +0 -19
- package/dist/src/agents/delegate-to-agent-tool.js +0 -178
- package/dist/src/agents/delegate-to-agent-tool.js.map +0 -1
- package/dist/src/agents/delegate-to-agent-tool.test.js +0 -213
- package/dist/src/agents/delegate-to-agent-tool.test.js.map +0 -1
- package/dist/src/agents/schema-utils.d.ts +0 -39
- package/dist/src/agents/schema-utils.js +0 -57
- package/dist/src/agents/schema-utils.js.map +0 -1
- package/dist/src/agents/schema-utils.test.js +0 -144
- package/dist/src/agents/schema-utils.test.js.map +0 -1
- package/dist/src/core/clientHookTriggers.d.ts +0 -36
- package/dist/src/core/clientHookTriggers.js +0 -76
- package/dist/src/core/clientHookTriggers.js.map +0 -1
- package/dist/src/core/geminiChatHookTriggers.d.ts +0 -68
- package/dist/src/core/geminiChatHookTriggers.js +0 -158
- package/dist/src/core/geminiChatHookTriggers.js.map +0 -1
- package/dist/src/core/geminiChatHookTriggers.test.js +0 -153
- package/dist/src/core/geminiChatHookTriggers.test.js.map +0 -1
- /package/dist/src/{agents/delegate-to-agent-tool.test.d.ts → core/prompts-substitution.test.d.ts} +0 -0
- /package/dist/src/{agents/schema-utils.test.d.ts → routing/strategies/numericalClassifierStrategy.test.d.ts} +0 -0
|
@@ -3,96 +3,11 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { createHookOutput, NotificationType, BeforeToolHookOutput, } from '../hooks/types.js';
|
|
6
|
+
import { BeforeToolHookOutput } from '../hooks/types.js';
|
|
8
7
|
import { ToolErrorType } from '../tools/tool-error.js';
|
|
9
8
|
import { debugLogger } from '../utils/debugLogger.js';
|
|
10
9
|
import { ShellToolInvocation } from '../tools/shell.js';
|
|
11
10
|
import { DiscoveredMCPToolInvocation } from '../tools/mcp-tool.js';
|
|
12
|
-
/**
|
|
13
|
-
* Converts ToolCallConfirmationDetails to a serializable format for hooks.
|
|
14
|
-
* Excludes function properties (onConfirm, ideConfirmation) that can't be serialized.
|
|
15
|
-
*/
|
|
16
|
-
function toSerializableDetails(details) {
|
|
17
|
-
const base = {
|
|
18
|
-
type: details.type,
|
|
19
|
-
title: details.title,
|
|
20
|
-
};
|
|
21
|
-
switch (details.type) {
|
|
22
|
-
case 'edit':
|
|
23
|
-
return {
|
|
24
|
-
...base,
|
|
25
|
-
fileName: details.fileName,
|
|
26
|
-
filePath: details.filePath,
|
|
27
|
-
fileDiff: details.fileDiff,
|
|
28
|
-
originalContent: details.originalContent,
|
|
29
|
-
newContent: details.newContent,
|
|
30
|
-
isModifying: details.isModifying,
|
|
31
|
-
};
|
|
32
|
-
case 'exec':
|
|
33
|
-
return {
|
|
34
|
-
...base,
|
|
35
|
-
command: details.command,
|
|
36
|
-
rootCommand: details.rootCommand,
|
|
37
|
-
};
|
|
38
|
-
case 'mcp':
|
|
39
|
-
return {
|
|
40
|
-
...base,
|
|
41
|
-
serverName: details.serverName,
|
|
42
|
-
toolName: details.toolName,
|
|
43
|
-
toolDisplayName: details.toolDisplayName,
|
|
44
|
-
};
|
|
45
|
-
case 'info':
|
|
46
|
-
return {
|
|
47
|
-
...base,
|
|
48
|
-
prompt: details.prompt,
|
|
49
|
-
urls: details.urls,
|
|
50
|
-
};
|
|
51
|
-
default:
|
|
52
|
-
return base;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Gets the message to display in the notification hook for tool confirmation.
|
|
57
|
-
*/
|
|
58
|
-
function getNotificationMessage(confirmationDetails) {
|
|
59
|
-
switch (confirmationDetails.type) {
|
|
60
|
-
case 'edit':
|
|
61
|
-
return `Tool ${confirmationDetails.title} requires editing`;
|
|
62
|
-
case 'exec':
|
|
63
|
-
return `Tool ${confirmationDetails.title} requires execution`;
|
|
64
|
-
case 'mcp':
|
|
65
|
-
return `Tool ${confirmationDetails.title} requires MCP`;
|
|
66
|
-
case 'info':
|
|
67
|
-
return `Tool ${confirmationDetails.title} requires information`;
|
|
68
|
-
default:
|
|
69
|
-
return `Tool requires confirmation`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Fires the ToolPermission notification hook for a tool that needs confirmation.
|
|
74
|
-
*
|
|
75
|
-
* @param messageBus The message bus to use for hook communication
|
|
76
|
-
* @param confirmationDetails The tool confirmation details
|
|
77
|
-
*/
|
|
78
|
-
export async function fireToolNotificationHook(messageBus, confirmationDetails) {
|
|
79
|
-
try {
|
|
80
|
-
const message = getNotificationMessage(confirmationDetails);
|
|
81
|
-
const serializedDetails = toSerializableDetails(confirmationDetails);
|
|
82
|
-
await messageBus.request({
|
|
83
|
-
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
84
|
-
eventName: 'Notification',
|
|
85
|
-
input: {
|
|
86
|
-
notification_type: NotificationType.ToolPermission,
|
|
87
|
-
message,
|
|
88
|
-
details: serializedDetails,
|
|
89
|
-
},
|
|
90
|
-
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
debugLogger.debug(`Notification hook failed for ${confirmationDetails.title}:`, error);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
11
|
/**
|
|
97
12
|
* Extracts MCP context from a tool invocation if it's an MCP tool.
|
|
98
13
|
*
|
|
@@ -123,89 +38,27 @@ function extractMcpContext(invocation, config) {
|
|
|
123
38
|
tcp: serverConfig.tcp,
|
|
124
39
|
};
|
|
125
40
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Fires the BeforeTool hook and returns the hook output.
|
|
128
|
-
*
|
|
129
|
-
* @param messageBus The message bus to use for hook communication
|
|
130
|
-
* @param toolName The name of the tool being executed
|
|
131
|
-
* @param toolInput The input parameters for the tool
|
|
132
|
-
* @param mcpContext Optional MCP context for MCP tools
|
|
133
|
-
* @returns The hook output, or undefined if no hook was executed or on error
|
|
134
|
-
*/
|
|
135
|
-
export async function fireBeforeToolHook(messageBus, toolName, toolInput, mcpContext) {
|
|
136
|
-
try {
|
|
137
|
-
const response = await messageBus.request({
|
|
138
|
-
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
139
|
-
eventName: 'BeforeTool',
|
|
140
|
-
input: {
|
|
141
|
-
tool_name: toolName,
|
|
142
|
-
tool_input: toolInput,
|
|
143
|
-
...(mcpContext && { mcp_context: mcpContext }),
|
|
144
|
-
},
|
|
145
|
-
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
146
|
-
return response.output
|
|
147
|
-
? createHookOutput('BeforeTool', response.output)
|
|
148
|
-
: undefined;
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
debugLogger.debug(`BeforeTool hook failed for ${toolName}:`, error);
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Fires the AfterTool hook and returns the hook output.
|
|
157
|
-
*
|
|
158
|
-
* @param messageBus The message bus to use for hook communication
|
|
159
|
-
* @param toolName The name of the tool that was executed
|
|
160
|
-
* @param toolInput The input parameters for the tool
|
|
161
|
-
* @param toolResponse The result from the tool execution
|
|
162
|
-
* @param mcpContext Optional MCP context for MCP tools
|
|
163
|
-
* @returns The hook output, or undefined if no hook was executed or on error
|
|
164
|
-
*/
|
|
165
|
-
export async function fireAfterToolHook(messageBus, toolName, toolInput, toolResponse, mcpContext) {
|
|
166
|
-
try {
|
|
167
|
-
const response = await messageBus.request({
|
|
168
|
-
type: MessageBusType.HOOK_EXECUTION_REQUEST,
|
|
169
|
-
eventName: 'AfterTool',
|
|
170
|
-
input: {
|
|
171
|
-
tool_name: toolName,
|
|
172
|
-
tool_input: toolInput,
|
|
173
|
-
tool_response: toolResponse,
|
|
174
|
-
...(mcpContext && { mcp_context: mcpContext }),
|
|
175
|
-
},
|
|
176
|
-
}, MessageBusType.HOOK_EXECUTION_RESPONSE);
|
|
177
|
-
return response.output
|
|
178
|
-
? createHookOutput('AfterTool', response.output)
|
|
179
|
-
: undefined;
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
debugLogger.debug(`AfterTool hook failed for ${toolName}:`, error);
|
|
183
|
-
return undefined;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
41
|
/**
|
|
187
42
|
* Execute a tool with BeforeTool and AfterTool hooks.
|
|
188
43
|
*
|
|
189
44
|
* @param invocation The tool invocation to execute
|
|
190
45
|
* @param toolName The name of the tool
|
|
191
46
|
* @param signal Abort signal for cancellation
|
|
192
|
-
* @param messageBus Optional message bus for hook communication
|
|
193
|
-
* @param hooksEnabled Whether hooks are enabled
|
|
194
47
|
* @param liveOutputCallback Optional callback for live output updates
|
|
195
48
|
* @param shellExecutionConfig Optional shell execution config
|
|
196
49
|
* @param setPidCallback Optional callback to set the PID for shell invocations
|
|
197
50
|
* @param config Config to look up MCP server details for hook context
|
|
198
51
|
* @returns The tool result
|
|
199
52
|
*/
|
|
200
|
-
export async function executeToolWithHooks(invocation, toolName, signal,
|
|
53
|
+
export async function executeToolWithHooks(invocation, toolName, signal, tool, liveOutputCallback, shellExecutionConfig, setPidCallback, config) {
|
|
201
54
|
const toolInput = (invocation.params || {});
|
|
202
55
|
let inputWasModified = false;
|
|
203
56
|
let modifiedKeys = [];
|
|
204
57
|
// Extract MCP context if this is an MCP tool (only if config is provided)
|
|
205
58
|
const mcpContext = config ? extractMcpContext(invocation, config) : undefined;
|
|
206
|
-
|
|
207
|
-
if (
|
|
208
|
-
const beforeOutput = await
|
|
59
|
+
const hookSystem = config?.getHookSystem();
|
|
60
|
+
if (hookSystem) {
|
|
61
|
+
const beforeOutput = await hookSystem.fireBeforeToolEvent(toolName, toolInput, mcpContext);
|
|
209
62
|
// Check if hook requested to stop entire agent execution
|
|
210
63
|
if (beforeOutput?.shouldStopExecution()) {
|
|
211
64
|
const reason = beforeOutput.getEffectiveReason();
|
|
@@ -285,9 +138,8 @@ export async function executeToolWithHooks(invocation, toolName, signal, message
|
|
|
285
138
|
];
|
|
286
139
|
}
|
|
287
140
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const afterOutput = await fireAfterToolHook(messageBus, toolName, toolInput, {
|
|
141
|
+
if (hookSystem) {
|
|
142
|
+
const afterOutput = await hookSystem.fireAfterToolEvent(toolName, toolInput, {
|
|
291
143
|
llmContent: toolResult.llmContent,
|
|
292
144
|
returnDisplay: toolResult.returnDisplay,
|
|
293
145
|
error: toolResult.error,
|
|
@@ -319,21 +171,22 @@ export async function executeToolWithHooks(invocation, toolName, signal, message
|
|
|
319
171
|
// Add additional context from hooks to the tool result
|
|
320
172
|
const additionalContext = afterOutput?.getAdditionalContext();
|
|
321
173
|
if (additionalContext) {
|
|
174
|
+
const wrappedContext = `\n\n<hook_context>${additionalContext}</hook_context>`;
|
|
322
175
|
if (typeof toolResult.llmContent === 'string') {
|
|
323
|
-
toolResult.llmContent +=
|
|
176
|
+
toolResult.llmContent += wrappedContext;
|
|
324
177
|
}
|
|
325
178
|
else if (Array.isArray(toolResult.llmContent)) {
|
|
326
|
-
toolResult.llmContent.push({ text:
|
|
179
|
+
toolResult.llmContent.push({ text: wrappedContext });
|
|
327
180
|
}
|
|
328
181
|
else if (toolResult.llmContent) {
|
|
329
182
|
// Handle single Part case by converting to an array
|
|
330
183
|
toolResult.llmContent = [
|
|
331
184
|
toolResult.llmContent,
|
|
332
|
-
{ text:
|
|
185
|
+
{ text: wrappedContext },
|
|
333
186
|
];
|
|
334
187
|
}
|
|
335
188
|
else {
|
|
336
|
-
toolResult.llmContent =
|
|
189
|
+
toolResult.llmContent = wrappedContext;
|
|
337
190
|
}
|
|
338
191
|
}
|
|
339
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreToolHookTriggers.js","sourceRoot":"","sources":["../../../src/core/coreToolHookTriggers.ts"],"names":[],"mappings":"AAAA;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Aa,GAAG,WAAW,EAAE,gBAAgB,EAAE,CAAC;QACtD,IAAI,aAAa,EAAE,OAAO,EAAE,CAAC;YAC3B,OAAO;gBACL,UAAU,EAAE,wBAAwB,aAAa,CAAC,MAAM,EAAE;gBAC1D,aAAa,EAAE,wBAAwB,aAAa,CAAC,MAAM,EAAE;gBAC7D,KAAK,EAAE;oBACL,IAAI,EAAE,aAAa,CAAC,gBAAgB;oBACpC,OAAO,EAAE,aAAa,CAAC,MAAM;iBAC9B;aACF,CAAC;QACJ,CAAC;QAED,uDAAuD;QACvD,MAAM,iBAAiB,GAAG,WAAW,EAAE,oBAAoB,EAAE,CAAC;QAC9D,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,cAAc,GAAG,qBAAqB,iBAAiB,iBAAiB,CAAC;YAC/E,IAAI,OAAO,UAAU,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;gBAC9C,UAAU,CAAC,UAAU,IAAI,cAAc,CAAC;YAC1C,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChD,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;YACvD,CAAC;iBAAM,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;gBACjC,oDAAoD;gBACpD,UAAU,CAAC,UAAU,GAAG;oBACtB,UAAU,CAAC,UAAU;oBACrB,EAAE,IAAI,EAAE,cAAc,EAAE;iBACzB,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,UAAU,GAAG,cAAc,CAAC;YACzC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
|
7
7
|
import { executeToolWithHooks } from './coreToolHookTriggers.js';
|
|
8
8
|
import { ToolErrorType } from '../tools/tool-error.js';
|
|
9
9
|
import { BaseToolInvocation, } from '../tools/tools.js';
|
|
10
|
-
import {
|
|
10
|
+
import { BeforeToolHookOutput, } from '../hooks/types.js';
|
|
11
11
|
class MockInvocation extends BaseToolInvocation {
|
|
12
12
|
constructor(params, messageBus) {
|
|
13
13
|
super(params, messageBus);
|
|
@@ -27,6 +27,8 @@ class MockInvocation extends BaseToolInvocation {
|
|
|
27
27
|
describe('executeToolWithHooks', () => {
|
|
28
28
|
let messageBus;
|
|
29
29
|
let mockTool;
|
|
30
|
+
let mockHookSystem;
|
|
31
|
+
let mockConfig;
|
|
30
32
|
beforeEach(() => {
|
|
31
33
|
messageBus = {
|
|
32
34
|
request: vi.fn(),
|
|
@@ -34,6 +36,15 @@ describe('executeToolWithHooks', () => {
|
|
|
34
36
|
subscribe: vi.fn(),
|
|
35
37
|
unsubscribe: vi.fn(),
|
|
36
38
|
};
|
|
39
|
+
mockHookSystem = {
|
|
40
|
+
fireBeforeToolEvent: vi.fn(),
|
|
41
|
+
fireAfterToolEvent: vi.fn(),
|
|
42
|
+
};
|
|
43
|
+
mockConfig = {
|
|
44
|
+
getHookSystem: vi.fn().mockReturnValue(mockHookSystem),
|
|
45
|
+
getMcpClientManager: vi.fn().mockReturnValue(undefined),
|
|
46
|
+
getMcpServers: vi.fn().mockReturnValue({}),
|
|
47
|
+
};
|
|
37
48
|
mockTool = {
|
|
38
49
|
build: vi
|
|
39
50
|
.fn()
|
|
@@ -43,34 +54,27 @@ describe('executeToolWithHooks', () => {
|
|
|
43
54
|
it('should prioritize continue: false over decision: block in BeforeTool', async () => {
|
|
44
55
|
const invocation = new MockInvocation({}, messageBus);
|
|
45
56
|
const abortSignal = new AbortController().signal;
|
|
46
|
-
vi.mocked(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
continue: false,
|
|
52
|
-
stopReason: 'Stop immediately',
|
|
53
|
-
decision: 'block',
|
|
57
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue({
|
|
58
|
+
shouldStopExecution: () => true,
|
|
59
|
+
getEffectiveReason: () => 'Stop immediately',
|
|
60
|
+
getBlockingError: () => ({
|
|
61
|
+
blocked: false,
|
|
54
62
|
reason: 'Should be ignored because continue is false',
|
|
55
|
-
},
|
|
63
|
+
}),
|
|
56
64
|
});
|
|
57
|
-
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal,
|
|
65
|
+
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
58
66
|
expect(result.error?.type).toBe(ToolErrorType.STOP_EXECUTION);
|
|
59
67
|
expect(result.error?.message).toBe('Stop immediately');
|
|
60
68
|
});
|
|
61
69
|
it('should block execution in BeforeTool if decision is block', async () => {
|
|
62
70
|
const invocation = new MockInvocation({}, messageBus);
|
|
63
71
|
const abortSignal = new AbortController().signal;
|
|
64
|
-
vi.mocked(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
output: {
|
|
69
|
-
decision: 'block',
|
|
70
|
-
reason: 'Execution blocked',
|
|
71
|
-
},
|
|
72
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue({
|
|
73
|
+
shouldStopExecution: () => false,
|
|
74
|
+
getEffectiveReason: () => '',
|
|
75
|
+
getBlockingError: () => ({ blocked: true, reason: 'Execution blocked' }),
|
|
72
76
|
});
|
|
73
|
-
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal,
|
|
77
|
+
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
74
78
|
expect(result.error?.type).toBe(ToolErrorType.EXECUTION_FAILED);
|
|
75
79
|
expect(result.error?.message).toBe('Execution blocked');
|
|
76
80
|
});
|
|
@@ -78,25 +82,17 @@ describe('executeToolWithHooks', () => {
|
|
|
78
82
|
const invocation = new MockInvocation({}, messageBus);
|
|
79
83
|
const abortSignal = new AbortController().signal;
|
|
80
84
|
const spy = vi.spyOn(invocation, 'execute');
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
correlationId: 'test-id',
|
|
86
|
-
success: true,
|
|
87
|
-
output: { decision: 'allow' },
|
|
88
|
-
})
|
|
89
|
-
// AfterTool stop
|
|
90
|
-
.mockResolvedValueOnce({
|
|
91
|
-
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
|
92
|
-
correlationId: 'test-id',
|
|
93
|
-
success: true,
|
|
94
|
-
output: {
|
|
95
|
-
continue: false,
|
|
96
|
-
stopReason: 'Stop after execution',
|
|
97
|
-
},
|
|
85
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue({
|
|
86
|
+
shouldStopExecution: () => false,
|
|
87
|
+
getEffectiveReason: () => '',
|
|
88
|
+
getBlockingError: () => ({ blocked: false, reason: '' }),
|
|
98
89
|
});
|
|
99
|
-
|
|
90
|
+
vi.mocked(mockHookSystem.fireAfterToolEvent).mockResolvedValue({
|
|
91
|
+
shouldStopExecution: () => true,
|
|
92
|
+
getEffectiveReason: () => 'Stop after execution',
|
|
93
|
+
getBlockingError: () => ({ blocked: false, reason: '' }),
|
|
94
|
+
});
|
|
95
|
+
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
100
96
|
expect(result.error?.type).toBe(ToolErrorType.STOP_EXECUTION);
|
|
101
97
|
expect(result.error?.message).toBe('Stop after execution');
|
|
102
98
|
expect(spy).toHaveBeenCalled();
|
|
@@ -104,25 +100,17 @@ describe('executeToolWithHooks', () => {
|
|
|
104
100
|
it('should block result in AfterTool if decision is deny', async () => {
|
|
105
101
|
const invocation = new MockInvocation({}, messageBus);
|
|
106
102
|
const abortSignal = new AbortController().signal;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
correlationId: 'test-id',
|
|
112
|
-
success: true,
|
|
113
|
-
output: { decision: 'allow' },
|
|
114
|
-
})
|
|
115
|
-
// AfterTool deny
|
|
116
|
-
.mockResolvedValueOnce({
|
|
117
|
-
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
|
118
|
-
correlationId: 'test-id',
|
|
119
|
-
success: true,
|
|
120
|
-
output: {
|
|
121
|
-
decision: 'deny',
|
|
122
|
-
reason: 'Result denied',
|
|
123
|
-
},
|
|
103
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue({
|
|
104
|
+
shouldStopExecution: () => false,
|
|
105
|
+
getEffectiveReason: () => '',
|
|
106
|
+
getBlockingError: () => ({ blocked: false, reason: '' }),
|
|
124
107
|
});
|
|
125
|
-
|
|
108
|
+
vi.mocked(mockHookSystem.fireAfterToolEvent).mockResolvedValue({
|
|
109
|
+
shouldStopExecution: () => false,
|
|
110
|
+
getEffectiveReason: () => '',
|
|
111
|
+
getBlockingError: () => ({ blocked: true, reason: 'Result denied' }),
|
|
112
|
+
});
|
|
113
|
+
const result = await executeToolWithHooks(invocation, 'test_tool', abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
126
114
|
expect(result.error?.type).toBe(ToolErrorType.EXECUTION_FAILED);
|
|
127
115
|
expect(result.error?.message).toBe('Result denied');
|
|
128
116
|
});
|
|
@@ -131,38 +119,21 @@ describe('executeToolWithHooks', () => {
|
|
|
131
119
|
const invocation = new MockInvocation(params, messageBus);
|
|
132
120
|
const toolName = 'test-tool';
|
|
133
121
|
const abortSignal = new AbortController().signal;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
|
141
|
-
correlationId: 'test-id',
|
|
142
|
-
success: true,
|
|
143
|
-
output: {
|
|
144
|
-
hookSpecificOutput: {
|
|
145
|
-
hookEventName: 'BeforeTool',
|
|
146
|
-
tool_input: { key: 'modified' },
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
|
|
153
|
-
correlationId: 'test-id',
|
|
154
|
-
success: true,
|
|
155
|
-
output: {},
|
|
156
|
-
};
|
|
122
|
+
const mockBeforeOutput = new BeforeToolHookOutput({
|
|
123
|
+
continue: true,
|
|
124
|
+
hookSpecificOutput: {
|
|
125
|
+
hookEventName: 'BeforeTool',
|
|
126
|
+
tool_input: { key: 'modified' },
|
|
127
|
+
},
|
|
157
128
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
mockTool);
|
|
129
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue(mockBeforeOutput);
|
|
130
|
+
vi.mocked(mockHookSystem.fireAfterToolEvent).mockResolvedValue(undefined);
|
|
131
|
+
const result = await executeToolWithHooks(invocation, toolName, abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
161
132
|
// Verify result reflects modified input
|
|
162
133
|
expect(result.llmContent).toBe('key: modified\n\n[System] Tool input parameters (key) were modified by a hook before execution.');
|
|
163
134
|
// Verify params object was modified in place
|
|
164
135
|
expect(invocation.params.key).toBe('modified');
|
|
165
|
-
expect(
|
|
136
|
+
expect(mockHookSystem.fireBeforeToolEvent).toHaveBeenCalled();
|
|
166
137
|
expect(mockTool.build).toHaveBeenCalledWith({ key: 'modified' });
|
|
167
138
|
});
|
|
168
139
|
it('should not modify input if hook does not provide tool_input', async () => {
|
|
@@ -170,19 +141,16 @@ describe('executeToolWithHooks', () => {
|
|
|
170
141
|
const invocation = new MockInvocation(params, messageBus);
|
|
171
142
|
const toolName = 'test-tool';
|
|
172
143
|
const abortSignal = new AbortController().signal;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
hookSpecificOutput: {
|
|
179
|
-
hookEventName: 'BeforeTool',
|
|
180
|
-
// No tool_input
|
|
181
|
-
},
|
|
144
|
+
const mockBeforeOutput = new BeforeToolHookOutput({
|
|
145
|
+
continue: true,
|
|
146
|
+
hookSpecificOutput: {
|
|
147
|
+
hookEventName: 'BeforeTool',
|
|
148
|
+
// No tool input
|
|
182
149
|
},
|
|
183
150
|
});
|
|
184
|
-
|
|
185
|
-
|
|
151
|
+
vi.mocked(mockHookSystem.fireBeforeToolEvent).mockResolvedValue(mockBeforeOutput);
|
|
152
|
+
vi.mocked(mockHookSystem.fireAfterToolEvent).mockResolvedValue(undefined);
|
|
153
|
+
const result = await executeToolWithHooks(invocation, toolName, abortSignal, mockTool, undefined, undefined, undefined, mockConfig);
|
|
186
154
|
expect(result.llmContent).toBe('key: original');
|
|
187
155
|
expect(invocation.params.key).toBe('original');
|
|
188
156
|
expect(mockTool.build).not.toHaveBeenCalled();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreToolHookTriggers.test.js","sourceRoot":"","sources":["../../../src/core/coreToolHookTriggers.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,kBAAkB,GAGnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"coreToolHookTriggers.test.js","sourceRoot":"","sources":["../../../src/core/coreToolHookTriggers.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EACL,kBAAkB,GAGnB,M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C,kBAAkB,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE1E,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,CACX,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAChD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -12,7 +12,6 @@ import { runInDevTraceSpan } from '../telemetry/trace.js';
|
|
|
12
12
|
import { ToolModificationHandler } from '../scheduler/tool-modifier.js';
|
|
13
13
|
import { getToolSuggestion } from '../utils/tool-utils.js';
|
|
14
14
|
import { MessageBusType } from '../confirmation-bus/types.js';
|
|
15
|
-
import { fireToolNotificationHook } from './coreToolHookTriggers.js';
|
|
16
15
|
import {} from '../scheduler/types.js';
|
|
17
16
|
import { ToolExecutor } from '../scheduler/tool-executor.js';
|
|
18
17
|
import { DiscoveredMCPTool } from '../tools/mcp-tool.js';
|
|
@@ -427,10 +426,9 @@ export class CoreToolScheduler {
|
|
|
427
426
|
throw new Error(`Tool execution for "${toolCall.tool.displayName || toolCall.tool.name}" requires user confirmation, which is not supported in non-interactive mode.`);
|
|
428
427
|
}
|
|
429
428
|
// Fire Notification hook before showing confirmation to user
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
await fireToolNotificationHook(messageBus, confirmationDetails);
|
|
429
|
+
const hookSystem = this.config.getHookSystem();
|
|
430
|
+
if (hookSystem) {
|
|
431
|
+
await hookSystem.fireToolNotificationEvent(confirmationDetails);
|
|
434
432
|
}
|
|
435
433
|
// Allow IDE to resolve confirmation
|
|
436
434
|
if (confirmationDetails.type === 'edit' &&
|