@vybestack/llxprt-code-core 0.1.18 → 0.1.19-alpha
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 +1 -0
- package/dist/src/config/config.alwaysAllow.test.d.ts +6 -0
- package/dist/src/config/config.alwaysAllow.test.js +84 -0
- package/dist/src/config/config.alwaysAllow.test.js.map +1 -0
- package/dist/src/config/config.d.ts +26 -0
- package/dist/src/config/config.js +43 -0
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +8 -0
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/core/client.d.ts +0 -2
- package/dist/src/core/client.js +10 -85
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +7 -2
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.js +1 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +17 -7
- package/dist/src/core/coreToolScheduler.js +121 -18
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +25 -37
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +3 -0
- package/dist/src/core/geminiChat.js +17 -13
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.js +4 -1
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +8 -31
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/subagent.d.ts +230 -0
- package/dist/src/core/subagent.js +453 -0
- package/dist/src/core/subagent.js.map +1 -0
- package/dist/src/core/subagent.test.d.ts +6 -0
- package/dist/src/core/subagent.test.js +519 -0
- package/dist/src/core/subagent.test.js.map +1 -0
- package/dist/src/hooks/tool-render-suppression-hook.d.ts +16 -0
- package/dist/src/hooks/tool-render-suppression-hook.js +26 -0
- package/dist/src/hooks/tool-render-suppression-hook.js.map +1 -0
- package/dist/src/hooks/tool-render-suppression-hook.test.d.ts +6 -0
- package/dist/src/hooks/tool-render-suppression-hook.test.js +59 -0
- package/dist/src/hooks/tool-render-suppression-hook.test.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +22 -1
- package/dist/src/ide/ide-client.js +145 -15
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +127 -32
- package/dist/src/ide/ideContext.js +45 -0
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration-tests/todo-system.test.js +38 -602
- package/dist/src/integration-tests/todo-system.test.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.js +5 -5
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.js +8 -1
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.test.js +106 -0
- package/dist/src/providers/openai/OpenAIProvider.test.js.map +1 -1
- package/dist/src/providers/types/IProviderConfig.d.ts +5 -0
- package/dist/src/services/shellExecutionService.js +29 -5
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +8 -0
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/todo-context-tracker.d.ts +31 -0
- package/dist/src/services/todo-context-tracker.js +45 -0
- package/dist/src/services/todo-context-tracker.js.map +1 -0
- package/dist/src/services/tool-call-tracker-service.d.ts +52 -0
- package/dist/src/services/tool-call-tracker-service.js +170 -0
- package/dist/src/services/tool-call-tracker-service.js.map +1 -0
- package/dist/src/services/tool-call-tracker-service.test.d.ts +6 -0
- package/dist/src/services/tool-call-tracker-service.test.js +99 -0
- package/dist/src/services/tool-call-tracker-service.test.js.map +1 -0
- package/dist/src/telemetry/loggers.test.circular.js +7 -2
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +5 -1
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +1 -1
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +2 -1
- package/dist/src/telemetry/types.js +3 -1
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -0
- package/dist/src/telemetry/uiTelemetry.js +2 -0
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +11 -1
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/tools.d.ts +23 -0
- package/dist/src/test-utils/tools.js +41 -0
- package/dist/src/test-utils/tools.js.map +1 -0
- package/dist/src/tools/edit.d.ts +5 -33
- package/dist/src/tools/edit.js +129 -124
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +123 -50
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +3 -10
- package/dist/src/tools/glob.js +97 -99
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +37 -26
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +3 -35
- package/dist/src/tools/grep.js +117 -88
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +36 -22
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +10 -0
- package/dist/src/tools/mcp-client.js +59 -0
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +294 -1
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +2 -2
- package/dist/src/tools/memoryTool.js +1 -0
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.d.ts +8 -5
- package/dist/src/tools/modifiable-tool.js +4 -1
- package/dist/src/tools/modifiable-tool.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 +4 -6
- package/dist/src/tools/read-file.js +55 -46
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +201 -126
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.js +8 -2
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +16 -0
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/todo-events.d.ts +22 -0
- package/dist/src/tools/todo-events.js +24 -0
- package/dist/src/tools/todo-events.js.map +1 -0
- package/dist/src/tools/todo-read.js.map +1 -1
- package/dist/src/tools/todo-schemas.d.ts +232 -4
- package/dist/src/tools/todo-schemas.js +13 -0
- package/dist/src/tools/todo-schemas.js.map +1 -1
- package/dist/src/tools/todo-schemas.test.js +190 -1
- package/dist/src/tools/todo-schemas.test.js.map +1 -1
- package/dist/src/tools/todo-store.d.ts +1 -4
- package/dist/src/tools/todo-store.js +41 -40
- package/dist/src/tools/todo-store.js.map +1 -1
- package/dist/src/tools/todo-store.test.js +34 -40
- package/dist/src/tools/todo-store.test.js.map +1 -1
- package/dist/src/tools/todo-write.d.ts +1 -1
- package/dist/src/tools/todo-write.js +84 -47
- package/dist/src/tools/todo-write.js.map +1 -1
- package/dist/src/tools/todo-write.test.js +23 -9
- package/dist/src/tools/todo-write.test.js.map +1 -1
- package/dist/src/tools/tool-context.d.ts +2 -0
- package/dist/src/tools/tool-registry.d.ts +12 -6
- package/dist/src/tools/tool-registry.js +16 -1
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +1 -18
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +127 -39
- package/dist/src/tools/tools.js +115 -10
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +2 -2
- package/dist/src/tools/write-file.js +16 -0
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +20 -3
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/types/modelParams.d.ts +2 -0
- package/dist/src/utils/environmentContext.d.ts +21 -0
- package/dist/src/utils/environmentContext.js +90 -0
- package/dist/src/utils/environmentContext.js.map +1 -0
- package/dist/src/utils/environmentContext.test.d.ts +6 -0
- package/dist/src/utils/environmentContext.test.js +139 -0
- package/dist/src/utils/environmentContext.test.js.map +1 -0
- package/dist/src/utils/fileUtils.js +2 -10
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +1 -4
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +27 -5
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +21 -1
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.js +4 -1
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/shell-utils.js +14 -2
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.shellReplacement.test.d.ts +6 -0
- package/dist/src/utils/shell-utils.shellReplacement.test.js +149 -0
- package/dist/src/utils/shell-utils.shellReplacement.test.js.map +1 -0
- package/package.json +2 -1
|
@@ -6,76 +6,165 @@
|
|
|
6
6
|
import { FunctionDeclaration, PartListUnion, Schema } from '@google/genai';
|
|
7
7
|
import { ToolContext, ContextAwareTool } from './tool-context.js';
|
|
8
8
|
import { ToolErrorType } from './tool-error.js';
|
|
9
|
+
import { DiffUpdateResult } from '../ide/ideContext.js';
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Represents a validated and ready-to-execute tool call.
|
|
12
|
+
* An instance of this is created by a `ToolBuilder`.
|
|
11
13
|
*/
|
|
12
|
-
export interface
|
|
14
|
+
export interface ToolInvocation<TParams extends object, TResult extends ToolResult> {
|
|
13
15
|
/**
|
|
14
|
-
* The
|
|
16
|
+
* The validated parameters for this specific invocation.
|
|
17
|
+
*/
|
|
18
|
+
params: TParams;
|
|
19
|
+
/**
|
|
20
|
+
* Gets a pre-execution description of the tool operation.
|
|
21
|
+
* @returns A markdown string describing what the tool will do.
|
|
22
|
+
*/
|
|
23
|
+
getDescription(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Determines what file system paths the tool will affect.
|
|
26
|
+
* @returns A list of such paths.
|
|
27
|
+
*/
|
|
28
|
+
toolLocations(): ToolLocation[];
|
|
29
|
+
/**
|
|
30
|
+
* Determines if the tool should prompt for confirmation before execution.
|
|
31
|
+
* @returns Confirmation details or false if no confirmation is needed.
|
|
32
|
+
*/
|
|
33
|
+
shouldConfirmExecute(abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
|
|
34
|
+
/**
|
|
35
|
+
* Executes the tool with the validated parameters.
|
|
36
|
+
* @param signal AbortSignal for tool cancellation.
|
|
37
|
+
* @param updateOutput Optional callback to stream output.
|
|
38
|
+
* @returns Result of the tool execution.
|
|
39
|
+
*/
|
|
40
|
+
execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A convenience base class for ToolInvocation.
|
|
44
|
+
*/
|
|
45
|
+
export declare abstract class BaseToolInvocation<TParams extends object, TResult extends ToolResult> implements ToolInvocation<TParams, TResult> {
|
|
46
|
+
readonly params: TParams;
|
|
47
|
+
constructor(params: TParams);
|
|
48
|
+
abstract getDescription(): string;
|
|
49
|
+
toolLocations(): ToolLocation[];
|
|
50
|
+
shouldConfirmExecute(_abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
|
|
51
|
+
abstract execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A type alias for a tool invocation where the specific parameter and result types are not known.
|
|
55
|
+
*/
|
|
56
|
+
export type AnyToolInvocation = ToolInvocation<object, ToolResult>;
|
|
57
|
+
/**
|
|
58
|
+
* An adapter that wraps the legacy `Tool` interface to make it compatible
|
|
59
|
+
* with the new `ToolInvocation` pattern.
|
|
60
|
+
*/
|
|
61
|
+
export declare class LegacyToolInvocation<TParams extends object, TResult extends ToolResult> implements ToolInvocation<TParams, TResult> {
|
|
62
|
+
private readonly legacyTool;
|
|
63
|
+
readonly params: TParams;
|
|
64
|
+
constructor(legacyTool: BaseTool<TParams, TResult>, params: TParams);
|
|
65
|
+
getDescription(): string;
|
|
66
|
+
toolLocations(): ToolLocation[];
|
|
67
|
+
shouldConfirmExecute(abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
|
|
68
|
+
execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Interface for a tool builder that validates parameters and creates invocations.
|
|
72
|
+
*/
|
|
73
|
+
export interface ToolBuilder<TParams extends object, TResult extends ToolResult> {
|
|
74
|
+
/**
|
|
75
|
+
* The internal name of the tool (used for API calls).
|
|
15
76
|
*/
|
|
16
77
|
name: string;
|
|
17
78
|
/**
|
|
18
|
-
* The user-friendly display name of the tool
|
|
79
|
+
* The user-friendly display name of the tool.
|
|
19
80
|
*/
|
|
20
81
|
displayName: string;
|
|
21
82
|
/**
|
|
22
|
-
* Description of what the tool does
|
|
83
|
+
* Description of what the tool does.
|
|
23
84
|
*/
|
|
24
85
|
description: string;
|
|
25
86
|
/**
|
|
26
|
-
* The icon to display when interacting via ACP
|
|
87
|
+
* The icon to display when interacting via ACP.
|
|
27
88
|
*/
|
|
28
89
|
icon: Icon;
|
|
29
90
|
/**
|
|
30
|
-
* Function declaration schema from @google/genai
|
|
91
|
+
* Function declaration schema from @google/genai.
|
|
31
92
|
*/
|
|
32
93
|
schema: FunctionDeclaration;
|
|
33
94
|
/**
|
|
34
|
-
* Whether the tool's output should be rendered as markdown
|
|
95
|
+
* Whether the tool's output should be rendered as markdown.
|
|
35
96
|
*/
|
|
36
97
|
isOutputMarkdown: boolean;
|
|
37
98
|
/**
|
|
38
|
-
* Whether the tool supports live (streaming) output
|
|
99
|
+
* Whether the tool supports live (streaming) output.
|
|
39
100
|
*/
|
|
40
101
|
canUpdateOutput: boolean;
|
|
41
102
|
/**
|
|
42
|
-
* Validates
|
|
43
|
-
*
|
|
44
|
-
* `
|
|
45
|
-
* @param params Parameters to validate
|
|
46
|
-
* @returns An error message string if invalid, null otherwise
|
|
47
|
-
*/
|
|
48
|
-
validateToolParams(params: TParams): string | null;
|
|
49
|
-
/**
|
|
50
|
-
* Gets a pre-execution description of the tool operation
|
|
51
|
-
* @param params Parameters for the tool execution
|
|
52
|
-
* @returns A markdown string describing what the tool will do
|
|
53
|
-
* Optional for backward compatibility
|
|
103
|
+
* Validates raw parameters and builds a ready-to-execute invocation.
|
|
104
|
+
* @param params The raw, untrusted parameters from the model.
|
|
105
|
+
* @returns A valid `ToolInvocation` if successful. Throws an error if validation fails.
|
|
54
106
|
*/
|
|
55
|
-
|
|
107
|
+
build(params: TParams): ToolInvocation<TParams, TResult>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* New base class for tools that separates validation from execution.
|
|
111
|
+
* New tools should extend this class.
|
|
112
|
+
*/
|
|
113
|
+
export declare abstract class DeclarativeTool<TParams extends object, TResult extends ToolResult> implements ToolBuilder<TParams, TResult> {
|
|
114
|
+
readonly name: string;
|
|
115
|
+
readonly displayName: string;
|
|
116
|
+
readonly description: string;
|
|
117
|
+
readonly icon: Icon;
|
|
118
|
+
readonly parameterSchema: Schema;
|
|
119
|
+
readonly isOutputMarkdown: boolean;
|
|
120
|
+
readonly canUpdateOutput: boolean;
|
|
121
|
+
constructor(name: string, displayName: string, description: string, icon: Icon, parameterSchema: Schema, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
|
|
122
|
+
get schema(): FunctionDeclaration;
|
|
56
123
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
124
|
+
* Validates the raw tool parameters.
|
|
125
|
+
* Subclasses should override this to add custom validation logic
|
|
126
|
+
* beyond the JSON schema check.
|
|
127
|
+
* @param params The raw parameters from the model.
|
|
128
|
+
* @returns An error message string if invalid, null otherwise.
|
|
60
129
|
*/
|
|
61
|
-
|
|
130
|
+
protected validateToolParams(_params: TParams): string | null;
|
|
62
131
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
132
|
+
* The core of the new pattern. It validates parameters and, if successful,
|
|
133
|
+
* returns a `ToolInvocation` object that encapsulates the logic for the
|
|
134
|
+
* specific, validated call.
|
|
135
|
+
* @param params The raw, untrusted parameters from the model.
|
|
136
|
+
* @returns A `ToolInvocation` instance.
|
|
66
137
|
*/
|
|
67
|
-
|
|
138
|
+
abstract build(params: TParams): ToolInvocation<TParams, TResult>;
|
|
68
139
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
140
|
+
* A convenience method that builds and executes the tool in one step.
|
|
141
|
+
* Throws an error if validation fails.
|
|
142
|
+
* @param params The raw, untrusted parameters from the model.
|
|
143
|
+
* @param signal AbortSignal for tool cancellation.
|
|
144
|
+
* @param updateOutput Optional callback to stream output.
|
|
145
|
+
* @returns The result of the tool execution.
|
|
72
146
|
*/
|
|
73
|
-
|
|
147
|
+
buildAndExecute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
|
74
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* New base class for declarative tools that separates validation from execution.
|
|
151
|
+
* New tools should extend this class, which provides a `build` method that
|
|
152
|
+
* validates parameters before deferring to a `createInvocation` method for
|
|
153
|
+
* the final `ToolInvocation` object instantiation.
|
|
154
|
+
*/
|
|
155
|
+
export declare abstract class BaseDeclarativeTool<TParams extends object, TResult extends ToolResult> extends DeclarativeTool<TParams, TResult> {
|
|
156
|
+
build(params: TParams): ToolInvocation<TParams, TResult>;
|
|
157
|
+
protected abstract createInvocation(params: TParams): ToolInvocation<TParams, TResult>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A type alias for a declarative tool where the specific parameter and result types are not known.
|
|
161
|
+
*/
|
|
162
|
+
export type AnyDeclarativeTool = DeclarativeTool<object, ToolResult>;
|
|
75
163
|
/**
|
|
76
164
|
* Base implementation for tools with common functionality
|
|
165
|
+
* @deprecated Use `DeclarativeTool` for new tools.
|
|
77
166
|
*/
|
|
78
|
-
export declare abstract class BaseTool<TParams =
|
|
167
|
+
export declare abstract class BaseTool<TParams extends object = object, TResult extends ToolResult = ToolResult> extends DeclarativeTool<TParams, TResult> implements ContextAwareTool {
|
|
79
168
|
readonly name: string;
|
|
80
169
|
readonly displayName: string;
|
|
81
170
|
readonly description: string;
|
|
@@ -95,10 +184,7 @@ export declare abstract class BaseTool<TParams = unknown, TResult extends ToolRe
|
|
|
95
184
|
* @param parameterSchema Open API 3.0 Schema defining the parameters
|
|
96
185
|
*/
|
|
97
186
|
constructor(name: string, displayName: string, description: string, icon: Icon, parameterSchema: Schema, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
|
|
98
|
-
|
|
99
|
-
* Function declaration schema computed from name, description, and parameterSchema
|
|
100
|
-
*/
|
|
101
|
-
get schema(): FunctionDeclaration;
|
|
187
|
+
build(params: TParams): ToolInvocation<TParams, TResult>;
|
|
102
188
|
/**
|
|
103
189
|
* Validates the parameters for the tool
|
|
104
190
|
* This is a placeholder implementation and should be overridden
|
|
@@ -185,10 +271,12 @@ export interface ToolEditConfirmationDetails {
|
|
|
185
271
|
title: string;
|
|
186
272
|
onConfirm: (outcome: ToolConfirmationOutcome, payload?: ToolConfirmationPayload) => Promise<void>;
|
|
187
273
|
fileName: string;
|
|
274
|
+
filePath: string;
|
|
188
275
|
fileDiff: string;
|
|
189
276
|
originalContent: string | null;
|
|
190
277
|
newContent: string;
|
|
191
278
|
isModifying?: boolean;
|
|
279
|
+
ideConfirmation?: Promise<DiffUpdateResult>;
|
|
192
280
|
}
|
|
193
281
|
export interface ToolConfirmationPayload {
|
|
194
282
|
newContent: string;
|
package/dist/src/tools/tools.js
CHANGED
|
@@ -3,10 +3,117 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A convenience base class for ToolInvocation.
|
|
8
|
+
*/
|
|
9
|
+
export class BaseToolInvocation {
|
|
10
|
+
params;
|
|
11
|
+
constructor(params) {
|
|
12
|
+
this.params = params;
|
|
13
|
+
}
|
|
14
|
+
toolLocations() {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
shouldConfirmExecute(_abortSignal) {
|
|
18
|
+
return Promise.resolve(false);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An adapter that wraps the legacy `Tool` interface to make it compatible
|
|
23
|
+
* with the new `ToolInvocation` pattern.
|
|
24
|
+
*/
|
|
25
|
+
export class LegacyToolInvocation {
|
|
26
|
+
legacyTool;
|
|
27
|
+
params;
|
|
28
|
+
constructor(legacyTool, params) {
|
|
29
|
+
this.legacyTool = legacyTool;
|
|
30
|
+
this.params = params;
|
|
31
|
+
}
|
|
32
|
+
getDescription() {
|
|
33
|
+
return this.legacyTool.getDescription(this.params);
|
|
34
|
+
}
|
|
35
|
+
toolLocations() {
|
|
36
|
+
return this.legacyTool.toolLocations(this.params);
|
|
37
|
+
}
|
|
38
|
+
shouldConfirmExecute(abortSignal) {
|
|
39
|
+
return this.legacyTool.shouldConfirmExecute(this.params, abortSignal);
|
|
40
|
+
}
|
|
41
|
+
execute(signal, updateOutput) {
|
|
42
|
+
return this.legacyTool.execute(this.params, signal, updateOutput);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* New base class for tools that separates validation from execution.
|
|
47
|
+
* New tools should extend this class.
|
|
48
|
+
*/
|
|
49
|
+
export class DeclarativeTool {
|
|
50
|
+
name;
|
|
51
|
+
displayName;
|
|
52
|
+
description;
|
|
53
|
+
icon;
|
|
54
|
+
parameterSchema;
|
|
55
|
+
isOutputMarkdown;
|
|
56
|
+
canUpdateOutput;
|
|
57
|
+
constructor(name, displayName, description, icon, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
|
|
58
|
+
this.name = name;
|
|
59
|
+
this.displayName = displayName;
|
|
60
|
+
this.description = description;
|
|
61
|
+
this.icon = icon;
|
|
62
|
+
this.parameterSchema = parameterSchema;
|
|
63
|
+
this.isOutputMarkdown = isOutputMarkdown;
|
|
64
|
+
this.canUpdateOutput = canUpdateOutput;
|
|
65
|
+
}
|
|
66
|
+
get schema() {
|
|
67
|
+
return {
|
|
68
|
+
name: this.name,
|
|
69
|
+
description: this.description,
|
|
70
|
+
parameters: this.parameterSchema,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Validates the raw tool parameters.
|
|
75
|
+
* Subclasses should override this to add custom validation logic
|
|
76
|
+
* beyond the JSON schema check.
|
|
77
|
+
* @param params The raw parameters from the model.
|
|
78
|
+
* @returns An error message string if invalid, null otherwise.
|
|
79
|
+
*/
|
|
80
|
+
validateToolParams(_params) {
|
|
81
|
+
// Base implementation can be extended by subclasses.
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A convenience method that builds and executes the tool in one step.
|
|
86
|
+
* Throws an error if validation fails.
|
|
87
|
+
* @param params The raw, untrusted parameters from the model.
|
|
88
|
+
* @param signal AbortSignal for tool cancellation.
|
|
89
|
+
* @param updateOutput Optional callback to stream output.
|
|
90
|
+
* @returns The result of the tool execution.
|
|
91
|
+
*/
|
|
92
|
+
async buildAndExecute(params, signal, updateOutput) {
|
|
93
|
+
const invocation = this.build(params);
|
|
94
|
+
return invocation.execute(signal, updateOutput);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* New base class for declarative tools that separates validation from execution.
|
|
99
|
+
* New tools should extend this class, which provides a `build` method that
|
|
100
|
+
* validates parameters before deferring to a `createInvocation` method for
|
|
101
|
+
* the final `ToolInvocation` object instantiation.
|
|
102
|
+
*/
|
|
103
|
+
export class BaseDeclarativeTool extends DeclarativeTool {
|
|
104
|
+
build(params) {
|
|
105
|
+
const validationError = this.validateToolParams(params);
|
|
106
|
+
if (validationError) {
|
|
107
|
+
throw new Error(validationError);
|
|
108
|
+
}
|
|
109
|
+
return this.createInvocation(params);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
6
112
|
/**
|
|
7
113
|
* Base implementation for tools with common functionality
|
|
114
|
+
* @deprecated Use `DeclarativeTool` for new tools.
|
|
8
115
|
*/
|
|
9
|
-
export class BaseTool {
|
|
116
|
+
export class BaseTool extends DeclarativeTool {
|
|
10
117
|
name;
|
|
11
118
|
displayName;
|
|
12
119
|
description;
|
|
@@ -26,6 +133,7 @@ export class BaseTool {
|
|
|
26
133
|
* @param parameterSchema Open API 3.0 Schema defining the parameters
|
|
27
134
|
*/
|
|
28
135
|
constructor(name, displayName, description, icon, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
|
|
136
|
+
super(name, displayName, description, icon, parameterSchema, isOutputMarkdown, canUpdateOutput);
|
|
29
137
|
this.name = name;
|
|
30
138
|
this.displayName = displayName;
|
|
31
139
|
this.description = description;
|
|
@@ -34,15 +142,12 @@ export class BaseTool {
|
|
|
34
142
|
this.isOutputMarkdown = isOutputMarkdown;
|
|
35
143
|
this.canUpdateOutput = canUpdateOutput;
|
|
36
144
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
description: this.description,
|
|
44
|
-
parameters: this.parameterSchema,
|
|
45
|
-
};
|
|
145
|
+
build(params) {
|
|
146
|
+
const validationError = this.validateToolParams(params);
|
|
147
|
+
if (validationError) {
|
|
148
|
+
throw new Error(validationError);
|
|
149
|
+
}
|
|
150
|
+
return new LegacyToolInvocation(this, params);
|
|
46
151
|
}
|
|
47
152
|
/**
|
|
48
153
|
* Validates the parameters for the tool
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/tools/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/tools/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoDH;;GAEG;AACH,MAAM,OAAgB,kBAAkB;IAKjB;IAArB,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAIxC,aAAa;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,oBAAoB,CAClB,YAAyB;QAEzB,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CAMF;AAOD;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAMZ;IACR;IAFX,YACmB,UAAsC,EAC9C,MAAe;QADP,eAAU,GAAV,UAAU,CAA4B;QAC9C,WAAM,GAAN,MAAM,CAAS;IACvB,CAAC;IAEJ,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,oBAAoB,CAClB,WAAwB;QAExB,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,CACL,MAAmB,EACnB,YAAuC;QAEvC,OAAO,IAAI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AG,EAAU,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;AAChE,CAAC;AAgED,MAAM,CAAN,IAAY,uBAOX;AAPD,WAAY,uBAAuB;IACjC,uDAA4B,CAAA;IAC5B,2DAAgC,CAAA;IAChC,wEAA6C,CAAA;IAC7C,oEAAyC,CAAA;IACzC,kEAAuC,CAAA;IACvC,4CAAiB,CAAA;AACnB,CAAC,EAPW,uBAAuB,KAAvB,uBAAuB,QAOlC;AAED,MAAM,CAAN,IAAY,IASX;AATD,WAAY,IAAI;IACd,iCAAyB,CAAA;IACzB,yBAAiB,CAAA;IACjB,uBAAe,CAAA;IACf,yBAAiB,CAAA;IACjB,+BAAuB,CAAA;IACvB,yBAAiB,CAAA;IACjB,uBAAe,CAAA;IACf,6BAAqB,CAAA;AACvB,CAAC,EATW,IAAI,KAAJ,IAAI,QASf"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Config } from '../config/config.js';
|
|
7
7
|
import { BaseTool, ToolResult, ToolCallConfirmationDetails } from './tools.js';
|
|
8
|
-
import {
|
|
8
|
+
import { ModifiableDeclarativeTool, ModifyContext } from './modifiable-tool.js';
|
|
9
9
|
/**
|
|
10
10
|
* Parameters for the WriteFile tool
|
|
11
11
|
*/
|
|
@@ -26,7 +26,7 @@ export interface WriteFileToolParams {
|
|
|
26
26
|
/**
|
|
27
27
|
* Implementation of the WriteFile tool logic
|
|
28
28
|
*/
|
|
29
|
-
export declare class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> implements
|
|
29
|
+
export declare class WriteFileTool extends BaseTool<WriteFileToolParams, ToolResult> implements ModifiableDeclarativeTool<WriteFileToolParams> {
|
|
30
30
|
private readonly config;
|
|
31
31
|
static readonly Name: string;
|
|
32
32
|
constructor(config: Config);
|
|
@@ -16,6 +16,7 @@ import { ensureCorrectEdit, ensureCorrectFileContent, } from '../utils/editCorre
|
|
|
16
16
|
import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js';
|
|
17
17
|
import { getSpecificMimeType } from '../utils/fileUtils.js';
|
|
18
18
|
import { recordFileOperationMetric, FileOperation, } from '../telemetry/metrics.js';
|
|
19
|
+
import { IDEConnectionStatus } from '../ide/ide-client.js';
|
|
19
20
|
/**
|
|
20
21
|
* Implementation of the WriteFile tool logic
|
|
21
22
|
*/
|
|
@@ -103,10 +104,18 @@ export class WriteFileTool extends BaseTool {
|
|
|
103
104
|
const fileDiff = Diff.createPatch(fileName, originalContent, // Original content (empty if new file or unreadable)
|
|
104
105
|
correctedContent, // Content after potential correction
|
|
105
106
|
'Current', 'Proposed', DEFAULT_DIFF_OPTIONS);
|
|
107
|
+
const ideClient = this.config.getIdeClient();
|
|
108
|
+
const ideConfirmation = this.config.getIdeModeFeature() &&
|
|
109
|
+
this.config.getIdeMode() &&
|
|
110
|
+
ideClient &&
|
|
111
|
+
ideClient.getConnectionStatus().status === IDEConnectionStatus.Connected
|
|
112
|
+
? ideClient.openDiff(params.file_path, correctedContent)
|
|
113
|
+
: undefined;
|
|
106
114
|
const confirmationDetails = {
|
|
107
115
|
type: 'edit',
|
|
108
116
|
title: `Confirm Write: ${shortenPath(relativePath)}`,
|
|
109
117
|
fileName,
|
|
118
|
+
filePath: params.file_path,
|
|
110
119
|
fileDiff,
|
|
111
120
|
originalContent,
|
|
112
121
|
newContent: correctedContent,
|
|
@@ -114,7 +123,14 @@ export class WriteFileTool extends BaseTool {
|
|
|
114
123
|
if (outcome === ToolConfirmationOutcome.ProceedAlways) {
|
|
115
124
|
this.config.setApprovalMode(ApprovalMode.AUTO_EDIT);
|
|
116
125
|
}
|
|
126
|
+
if (ideConfirmation) {
|
|
127
|
+
const result = await ideConfirmation;
|
|
128
|
+
if (result.status === 'accepted' && result.content) {
|
|
129
|
+
params.content = result.content;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
117
132
|
},
|
|
133
|
+
ideConfirmation,
|
|
118
134
|
};
|
|
119
135
|
return confirmationDetails;
|
|
120
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-file.js","sourceRoot":"","sources":["../../../src/tools/write-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAU,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,QAAQ,EAIR,uBAAuB,EAEvB,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,yBAAyB,EACzB,aAAa,GACd,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"write-file.js","sourceRoot":"","sources":["../../../src/tools/write-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAU,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,QAAQ,EAIR,uBAAuB,EAEvB,IAAI,GACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM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C,CAAC;gBACJ,GAAG,cAAc;gBACjB,OAAO,EAAE,uBAAuB;gBAChC,gBAAgB,EAAE,IAAI;aACvB,CAAC;SACH,CAAC;IACJ,CAAC"}
|
|
@@ -29,6 +29,9 @@ const mockConfigInternal = {
|
|
|
29
29
|
getApprovalMode: vi.fn(() => ApprovalMode.DEFAULT),
|
|
30
30
|
setApprovalMode: vi.fn(),
|
|
31
31
|
getGeminiClient: vi.fn(), // Initialize as a plain mock function
|
|
32
|
+
getIdeClient: vi.fn(),
|
|
33
|
+
getIdeMode: vi.fn(() => false),
|
|
34
|
+
getIdeModeFeature: vi.fn(() => false),
|
|
32
35
|
getWorkspaceContext: () => createMockWorkspaceContext(rootDir),
|
|
33
36
|
getApiKey: () => 'test-key',
|
|
34
37
|
getModel: () => 'test-model',
|
|
@@ -70,6 +73,14 @@ describe('WriteFileTool', () => {
|
|
|
70
73
|
vi.mocked(ensureCorrectFileContent).mockImplementation(mockEnsureCorrectFileContent);
|
|
71
74
|
// Now that mockGeminiClientInstance is initialized, set the mock implementation for getGeminiClient
|
|
72
75
|
mockConfigInternal.getGeminiClient.mockReturnValue(mockGeminiClientInstance);
|
|
76
|
+
mockConfigInternal.getIdeClient.mockReturnValue({
|
|
77
|
+
openDiff: vi.fn(),
|
|
78
|
+
closeDiff: vi.fn(),
|
|
79
|
+
getIdeContext: vi.fn(),
|
|
80
|
+
subscribeToIdeContext: vi.fn(),
|
|
81
|
+
isCodeTrackerEnabled: vi.fn(),
|
|
82
|
+
getTrackedCode: vi.fn(),
|
|
83
|
+
});
|
|
73
84
|
tool = new WriteFileTool(mockConfig);
|
|
74
85
|
// Reset mocks before each test
|
|
75
86
|
mockConfigInternal.getApprovalMode.mockReturnValue(ApprovalMode.DEFAULT);
|
|
@@ -316,7 +327,9 @@ describe('WriteFileTool', () => {
|
|
|
316
327
|
mockEnsureCorrectFileContent.mockResolvedValue(correctedContent);
|
|
317
328
|
const params = { file_path: filePath, content: proposedContent };
|
|
318
329
|
const confirmDetails = await tool.shouldConfirmExecute(params, abortSignal);
|
|
319
|
-
if (typeof confirmDetails === 'object' &&
|
|
330
|
+
if (typeof confirmDetails === 'object' &&
|
|
331
|
+
'onConfirm' in confirmDetails &&
|
|
332
|
+
confirmDetails.onConfirm) {
|
|
320
333
|
await confirmDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce);
|
|
321
334
|
}
|
|
322
335
|
const result = await tool.execute(params, abortSignal);
|
|
@@ -346,7 +359,9 @@ describe('WriteFileTool', () => {
|
|
|
346
359
|
});
|
|
347
360
|
const params = { file_path: filePath, content: proposedContent };
|
|
348
361
|
const confirmDetails = await tool.shouldConfirmExecute(params, abortSignal);
|
|
349
|
-
if (typeof confirmDetails === 'object' &&
|
|
362
|
+
if (typeof confirmDetails === 'object' &&
|
|
363
|
+
'onConfirm' in confirmDetails &&
|
|
364
|
+
confirmDetails.onConfirm) {
|
|
350
365
|
await confirmDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce);
|
|
351
366
|
}
|
|
352
367
|
const result = await tool.execute(params, abortSignal);
|
|
@@ -370,7 +385,9 @@ describe('WriteFileTool', () => {
|
|
|
370
385
|
const params = { file_path: filePath, content };
|
|
371
386
|
// Simulate confirmation if your logic requires it before execute, or remove if not needed for this path
|
|
372
387
|
const confirmDetails = await tool.shouldConfirmExecute(params, abortSignal);
|
|
373
|
-
if (typeof confirmDetails === 'object' &&
|
|
388
|
+
if (typeof confirmDetails === 'object' &&
|
|
389
|
+
'onConfirm' in confirmDetails &&
|
|
390
|
+
confirmDetails.onConfirm) {
|
|
374
391
|
await confirmDetails.onConfirm(ToolConfirmationOutcome.ProceedOnce);
|
|
375
392
|
}
|
|
376
393
|
await tool.execute(params, abortSignal);
|