@vybestack/llxprt-code-core 0.1.21 → 0.1.23
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/src/auth/types.d.ts +4 -4
- package/dist/src/code_assist/codeAssist.d.ts +1 -1
- package/dist/src/code_assist/codeAssist.js +5 -2
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/converter.d.ts +2 -1
- package/dist/src/code_assist/converter.js +6 -4
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/oauth2.d.ts +1 -0
- package/dist/src/code_assist/oauth2.js +32 -15
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +1 -2
- package/dist/src/code_assist/server.js +10 -5
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/setup.js +2 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/config/config.d.ts +14 -1
- package/dist/src/config/config.js +28 -3
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/core/client.js +13 -4
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +2 -1
- package/dist/src/core/coreToolScheduler.js +23 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/geminiChat.js +73 -17
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +1 -5
- package/dist/src/core/loggingContentGenerator.js +4 -6
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +2 -2
- package/dist/src/core/nonInteractiveToolExecutor.js +13 -9
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/subagent.js +5 -5
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/debug/ConfigurationManager.d.ts +28 -0
- package/dist/src/debug/ConfigurationManager.js +211 -0
- package/dist/src/debug/ConfigurationManager.js.map +1 -0
- package/dist/src/debug/DebugLogger.d.ts +26 -0
- package/dist/src/debug/DebugLogger.js +230 -0
- package/dist/src/debug/DebugLogger.js.map +1 -0
- package/dist/src/debug/FileOutput.d.ts +23 -0
- package/dist/src/debug/FileOutput.js +144 -0
- package/dist/src/debug/FileOutput.js.map +1 -0
- package/dist/src/debug/MockConfigurationManager.d.ts +28 -0
- package/dist/src/debug/MockConfigurationManager.js +45 -0
- package/dist/src/debug/MockConfigurationManager.js.map +1 -0
- package/dist/src/debug/MockFileOutput.d.ts +20 -0
- package/dist/src/debug/MockFileOutput.js +25 -0
- package/dist/src/debug/MockFileOutput.js.map +1 -0
- package/dist/src/debug/index.d.ts +8 -0
- package/dist/src/debug/index.js +9 -0
- package/dist/src/debug/index.js.map +1 -0
- package/dist/src/debug/types.d.ts +23 -0
- package/dist/src/debug/types.js +2 -0
- package/dist/src/debug/types.js.map +1 -0
- package/dist/src/ide/ide-client.d.ts +4 -0
- package/dist/src/ide/ide-client.js +41 -2
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-installer.js +17 -4
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +10 -5
- package/dist/src/ide/process-utils.js +113 -30
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/oauth-provider.js +176 -58
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +3 -1
- package/dist/src/mcp/oauth-utils.js +52 -22
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/prompt-config/defaults/core.md +34 -230
- package/dist/src/prompt-config/defaults/tools/read-file.md +1 -1
- package/dist/src/providers/BaseProvider.js +13 -2
- package/dist/src/providers/BaseProvider.js.map +1 -1
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +1 -0
- package/dist/src/providers/anthropic/AnthropicProvider.js +165 -127
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +1 -0
- package/dist/src/providers/gemini/GeminiProvider.js +29 -53
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.d.ts +9 -0
- package/dist/src/providers/openai/OpenAIProvider.js +671 -128
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/buildResponsesRequest.js +9 -6
- package/dist/src/providers/openai/buildResponsesRequest.js.map +1 -1
- package/dist/src/providers/openai/getOpenAIProviderInfo.js +8 -3
- package/dist/src/providers/openai/getOpenAIProviderInfo.js.map +1 -1
- package/dist/src/providers/openai/parseResponsesStream.js +13 -4
- package/dist/src/providers/openai/parseResponsesStream.js.map +1 -1
- package/dist/src/providers/openai/syntheticToolResponses.d.ts +0 -9
- package/dist/src/providers/openai/syntheticToolResponses.js +87 -16
- package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +31 -0
- package/dist/src/services/fileSystemService.js +18 -0
- package/dist/src/services/fileSystemService.js.map +1 -0
- package/dist/src/services/loopDetectionService.d.ts +5 -0
- package/dist/src/services/loopDetectionService.js +89 -1
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.d.ts +8 -6
- package/dist/src/services/shellExecutionService.js +297 -133
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/telemetry/index.d.ts +2 -2
- package/dist/src/telemetry/index.js +2 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +2 -1
- package/dist/src/telemetry/loggers.js +15 -1
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +1 -1
- package/dist/src/telemetry/metrics.js +2 -1
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/sdk.js +3 -3
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +9 -1
- package/dist/src/telemetry/types.js +32 -0
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +4 -0
- package/dist/src/telemetry/uiTelemetry.js +16 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/test-utils/tools.d.ts +29 -8
- package/dist/src/test-utils/tools.js +79 -15
- package/dist/src/test-utils/tools.js.map +1 -1
- package/dist/src/tools/ToolFormatter.d.ts +1 -0
- package/dist/src/tools/ToolFormatter.js +90 -9
- package/dist/src/tools/ToolFormatter.js.map +1 -1
- package/dist/src/tools/edit.d.ts +2 -2
- package/dist/src/tools/edit.js +60 -28
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/glob.d.ts +1 -1
- package/dist/src/tools/glob.js +8 -8
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/grep.d.ts +1 -1
- package/dist/src/tools/grep.js +1 -6
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/ls.d.ts +1 -1
- package/dist/src/tools/ls.js +1 -6
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +38 -0
- package/dist/src/tools/mcp-client-manager.js +74 -0
- package/dist/src/tools/mcp-client-manager.js.map +1 -0
- package/dist/src/tools/mcp-client.d.ts +43 -0
- package/dist/src/tools/mcp-client.js +163 -32
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +1 -1
- package/dist/src/tools/memoryTool.js +1 -6
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +1 -1
- package/dist/src/tools/read-file.js +5 -7
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +0 -1
- package/dist/src/tools/read-many-files.js +16 -11
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/shell.d.ts +1 -1
- package/dist/src/tools/shell.js +57 -36
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/tool-error.d.ts +1 -0
- package/dist/src/tools/tool-error.js +1 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +5 -0
- package/dist/src/tools/tool-registry.js +13 -4
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tools.d.ts +56 -76
- package/dist/src/tools/tools.js +119 -106
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +1 -1
- package/dist/src/tools/web-fetch.js +1 -6
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +6 -1
- package/dist/src/tools/web-search.js +6 -6
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +1 -1
- package/dist/src/tools/write-file.js +7 -8
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/utils/environmentContext.js +2 -2
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/errorReporting.js +1 -1
- package/dist/src/utils/fileUtils.d.ts +2 -1
- package/dist/src/utils/fileUtils.js +3 -3
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +15 -0
- package/dist/src/utils/filesearch/crawler.js +50 -0
- package/dist/src/utils/filesearch/crawler.js.map +1 -0
- package/dist/src/utils/filesearch/fileSearch.d.ts +9 -53
- package/dist/src/utils/filesearch/fileSearch.js +62 -117
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/ignore.d.ts +7 -0
- package/dist/src/utils/filesearch/ignore.js +25 -0
- package/dist/src/utils/filesearch/ignore.js.map +1 -1
- package/dist/src/utils/getPty.d.ts +19 -0
- package/dist/src/utils/getPty.js +23 -0
- package/dist/src/utils/getPty.js.map +1 -0
- package/dist/src/utils/shell-utils.d.ts +39 -0
- package/dist/src/utils/shell-utils.js +68 -0
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/user_account.js +58 -53
- package/dist/src/utils/user_account.js.map +1 -1
- package/dist/src/utils/workspaceContext.d.ts +9 -0
- package/dist/src/utils/workspaceContext.js +37 -3
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/package.json +22 -7
@@ -54,19 +54,6 @@ export declare abstract class BaseToolInvocation<TParams extends object, TResult
|
|
54
54
|
* A type alias for a tool invocation where the specific parameter and result types are not known.
|
55
55
|
*/
|
56
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, terminalColumns?: number, terminalRows?: number): Promise<TResult>;
|
69
|
-
}
|
70
57
|
/**
|
71
58
|
* Interface for a tool builder that validates parameters and creates invocations.
|
72
59
|
*/
|
@@ -127,7 +114,7 @@ export declare abstract class DeclarativeTool<TParams extends object, TResult ex
|
|
127
114
|
* @param params The raw parameters from the model.
|
128
115
|
* @returns An error message string if invalid, null otherwise.
|
129
116
|
*/
|
130
|
-
|
117
|
+
validateToolParams(_params: TParams): string | null;
|
131
118
|
/**
|
132
119
|
* The core of the new pattern. It validates parameters and, if successful,
|
133
120
|
* returns a `ToolInvocation` object that encapsulates the logic for the
|
@@ -145,6 +132,20 @@ export declare abstract class DeclarativeTool<TParams extends object, TResult ex
|
|
145
132
|
* @returns The result of the tool execution.
|
146
133
|
*/
|
147
134
|
buildAndExecute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
135
|
+
/**
|
136
|
+
* Similar to `build` but never throws.
|
137
|
+
* @param params The raw, untrusted parameters from the model.
|
138
|
+
* @returns A `ToolInvocation` instance.
|
139
|
+
*/
|
140
|
+
private silentBuild;
|
141
|
+
/**
|
142
|
+
* A convenience method that builds and executes the tool in one step.
|
143
|
+
* Never throws.
|
144
|
+
* @param params The raw, untrusted parameters from the model.
|
145
|
+
* @params abortSignal a signal to abort.
|
146
|
+
* @returns The result of the tool execution.
|
147
|
+
*/
|
148
|
+
validateBuildAndExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolResult>;
|
148
149
|
}
|
149
150
|
/**
|
150
151
|
* New base class for declarative tools that separates validation from execution.
|
@@ -154,74 +155,14 @@ export declare abstract class DeclarativeTool<TParams extends object, TResult ex
|
|
154
155
|
*/
|
155
156
|
export declare abstract class BaseDeclarativeTool<TParams extends object, TResult extends ToolResult> extends DeclarativeTool<TParams, TResult> {
|
156
157
|
build(params: TParams): ToolInvocation<TParams, TResult>;
|
158
|
+
validateToolParams(params: TParams): string | null;
|
159
|
+
protected validateToolParamValues(_params: TParams): string | null;
|
157
160
|
protected abstract createInvocation(params: TParams): ToolInvocation<TParams, TResult>;
|
158
161
|
}
|
159
162
|
/**
|
160
163
|
* A type alias for a declarative tool where the specific parameter and result types are not known.
|
161
164
|
*/
|
162
165
|
export type AnyDeclarativeTool = DeclarativeTool<object, ToolResult>;
|
163
|
-
/**
|
164
|
-
* Base implementation for tools with common functionality
|
165
|
-
* @deprecated Use `DeclarativeTool` for new tools.
|
166
|
-
*/
|
167
|
-
export declare abstract class BaseTool<TParams extends object = object, TResult extends ToolResult = ToolResult> extends DeclarativeTool<TParams, TResult> implements ContextAwareTool {
|
168
|
-
readonly name: string;
|
169
|
-
readonly displayName: string;
|
170
|
-
readonly description: string;
|
171
|
-
readonly kind: Kind;
|
172
|
-
readonly parameterSchema: unknown;
|
173
|
-
readonly isOutputMarkdown: boolean;
|
174
|
-
readonly canUpdateOutput: boolean;
|
175
|
-
/** Tool execution context containing session and agent information */
|
176
|
-
context?: ToolContext;
|
177
|
-
/**
|
178
|
-
* Creates a new instance of BaseTool
|
179
|
-
* @param name Internal name of the tool (used for API calls)
|
180
|
-
* @param displayName User-friendly display name of the tool
|
181
|
-
* @param description Description of what the tool does
|
182
|
-
* @param isOutputMarkdown Whether the tool's output should be rendered as markdown
|
183
|
-
* @param canUpdateOutput Whether the tool supports live (streaming) output
|
184
|
-
* @param parameterSchema JSON Schema defining the parameters
|
185
|
-
*/
|
186
|
-
constructor(name: string, displayName: string, description: string, kind: Kind, parameterSchema: unknown, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
|
187
|
-
build(params: TParams): ToolInvocation<TParams, TResult>;
|
188
|
-
/**
|
189
|
-
* Validates the parameters for the tool
|
190
|
-
* This is a placeholder implementation and should be overridden
|
191
|
-
* Should be called from both `shouldConfirmExecute` and `execute`
|
192
|
-
* `shouldConfirmExecute` should return false immediately if invalid
|
193
|
-
* @param params Parameters to validate
|
194
|
-
* @returns An error message string if invalid, null otherwise
|
195
|
-
*/
|
196
|
-
validateToolParams(params: TParams): string | null;
|
197
|
-
/**
|
198
|
-
* Gets a pre-execution description of the tool operation
|
199
|
-
* Default implementation that should be overridden by derived classes
|
200
|
-
* @param params Parameters for the tool execution
|
201
|
-
* @returns A markdown string describing what the tool will do
|
202
|
-
*/
|
203
|
-
getDescription(params: TParams): string;
|
204
|
-
/**
|
205
|
-
* Determines if the tool should prompt for confirmation before execution
|
206
|
-
* @param params Parameters for the tool execution
|
207
|
-
* @returns Whether or not execute should be confirmed by the user.
|
208
|
-
*/
|
209
|
-
shouldConfirmExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolCallConfirmationDetails | false>;
|
210
|
-
/**
|
211
|
-
* Determines what file system paths the tool will affect
|
212
|
-
* @param params Parameters for the tool execution
|
213
|
-
* @returns A list of such paths
|
214
|
-
*/
|
215
|
-
toolLocations(params: TParams): ToolLocation[];
|
216
|
-
/**
|
217
|
-
* Abstract method to execute the tool with the given parameters
|
218
|
-
* Must be implemented by derived classes
|
219
|
-
* @param params Parameters for the tool execution
|
220
|
-
* @param signal AbortSignal for tool cancellation
|
221
|
-
* @returns Result of the tool execution
|
222
|
-
*/
|
223
|
-
abstract execute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void, terminalColumns?: number, terminalRows?: number): Promise<TResult>;
|
224
|
-
}
|
225
166
|
export interface ToolResult {
|
226
167
|
/**
|
227
168
|
* A short, one-line summary of the tool's action and result.
|
@@ -334,3 +275,42 @@ export interface ToolLocation {
|
|
334
275
|
path: string;
|
335
276
|
line?: number;
|
336
277
|
}
|
278
|
+
/**
|
279
|
+
* Legacy BaseTool class for backward compatibility with existing LLxprt tools.
|
280
|
+
* New tools should use BaseDeclarativeTool instead.
|
281
|
+
* @deprecated Use BaseDeclarativeTool for new tools
|
282
|
+
*/
|
283
|
+
export declare abstract class BaseTool<TParams extends object, TResult extends ToolResult> extends DeclarativeTool<TParams, TResult> implements ContextAwareTool {
|
284
|
+
context?: ToolContext;
|
285
|
+
constructor(name: string, displayName: string, description: string, kind: Kind, parameterSchema: unknown, isOutputMarkdown?: boolean, canUpdateOutput?: boolean);
|
286
|
+
/**
|
287
|
+
* Get the schema for this tool. Maintains backward compatibility.
|
288
|
+
*/
|
289
|
+
get schema(): FunctionDeclaration;
|
290
|
+
/**
|
291
|
+
* Legacy method signature for getDescription.
|
292
|
+
* Subclasses can override this method.
|
293
|
+
*/
|
294
|
+
getDescription(_params: TParams): string;
|
295
|
+
/**
|
296
|
+
* Legacy method signature for validateToolParams.
|
297
|
+
* Subclasses can override this method.
|
298
|
+
* Note: The base class expects TParams, but legacy tools pass unknown.
|
299
|
+
*/
|
300
|
+
validateToolParams(params: TParams): string | null;
|
301
|
+
/**
|
302
|
+
* Legacy validateToolParams method that accepts unknown params.
|
303
|
+
* This maintains compatibility with existing tool implementations.
|
304
|
+
*/
|
305
|
+
validateToolParamsLegacy?(params: unknown): string | null;
|
306
|
+
/**
|
307
|
+
* Legacy execute method signature.
|
308
|
+
* Subclasses should implement this method.
|
309
|
+
*/
|
310
|
+
abstract execute(params: TParams, signal: AbortSignal, updateOutput?: (output: string) => void): Promise<TResult>;
|
311
|
+
/**
|
312
|
+
* Implementation of the new declarative pattern.
|
313
|
+
* Creates a tool invocation that bridges to the legacy execute method.
|
314
|
+
*/
|
315
|
+
build(params: TParams): ToolInvocation<TParams, TResult>;
|
316
|
+
}
|
package/dist/src/tools/tools.js
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
* Copyright 2025 Google LLC
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
+
import { ToolErrorType } from './tool-error.js';
|
7
|
+
import { SchemaValidator } from '../utils/schemaValidator.js';
|
6
8
|
/**
|
7
9
|
* A convenience base class for ToolInvocation.
|
8
10
|
*/
|
@@ -18,30 +20,6 @@ export class BaseToolInvocation {
|
|
18
20
|
return Promise.resolve(false);
|
19
21
|
}
|
20
22
|
}
|
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, terminalColumns, terminalRows) {
|
42
|
-
return this.legacyTool.execute(this.params, signal, updateOutput, terminalColumns, terminalRows);
|
43
|
-
}
|
44
|
-
}
|
45
23
|
/**
|
46
24
|
* New base class for tools that separates validation from execution.
|
47
25
|
* New tools should extend this class.
|
@@ -93,6 +71,57 @@ export class DeclarativeTool {
|
|
93
71
|
const invocation = this.build(params);
|
94
72
|
return invocation.execute(signal, updateOutput);
|
95
73
|
}
|
74
|
+
/**
|
75
|
+
* Similar to `build` but never throws.
|
76
|
+
* @param params The raw, untrusted parameters from the model.
|
77
|
+
* @returns A `ToolInvocation` instance.
|
78
|
+
*/
|
79
|
+
silentBuild(params) {
|
80
|
+
try {
|
81
|
+
return this.build(params);
|
82
|
+
}
|
83
|
+
catch (e) {
|
84
|
+
if (e instanceof Error) {
|
85
|
+
return e;
|
86
|
+
}
|
87
|
+
return new Error(String(e));
|
88
|
+
}
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* A convenience method that builds and executes the tool in one step.
|
92
|
+
* Never throws.
|
93
|
+
* @param params The raw, untrusted parameters from the model.
|
94
|
+
* @params abortSignal a signal to abort.
|
95
|
+
* @returns The result of the tool execution.
|
96
|
+
*/
|
97
|
+
async validateBuildAndExecute(params, abortSignal) {
|
98
|
+
const invocationOrError = this.silentBuild(params);
|
99
|
+
if (invocationOrError instanceof Error) {
|
100
|
+
const errorMessage = invocationOrError.message;
|
101
|
+
return {
|
102
|
+
llmContent: `Error: Invalid parameters provided. Reason: ${errorMessage}`,
|
103
|
+
returnDisplay: errorMessage,
|
104
|
+
error: {
|
105
|
+
message: errorMessage,
|
106
|
+
type: ToolErrorType.INVALID_TOOL_PARAMS,
|
107
|
+
},
|
108
|
+
};
|
109
|
+
}
|
110
|
+
try {
|
111
|
+
return await invocationOrError.execute(abortSignal);
|
112
|
+
}
|
113
|
+
catch (error) {
|
114
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
115
|
+
return {
|
116
|
+
llmContent: `Error: Tool call execution failed. Reason: ${errorMessage}`,
|
117
|
+
returnDisplay: errorMessage,
|
118
|
+
error: {
|
119
|
+
message: errorMessage,
|
120
|
+
type: ToolErrorType.EXECUTION_FAILED,
|
121
|
+
},
|
122
|
+
};
|
123
|
+
}
|
124
|
+
}
|
96
125
|
}
|
97
126
|
/**
|
98
127
|
* New base class for declarative tools that separates validation from execution.
|
@@ -108,92 +137,17 @@ export class BaseDeclarativeTool extends DeclarativeTool {
|
|
108
137
|
}
|
109
138
|
return this.createInvocation(params);
|
110
139
|
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
*/
|
116
|
-
export class BaseTool extends DeclarativeTool {
|
117
|
-
name;
|
118
|
-
displayName;
|
119
|
-
description;
|
120
|
-
kind;
|
121
|
-
parameterSchema;
|
122
|
-
isOutputMarkdown;
|
123
|
-
canUpdateOutput;
|
124
|
-
/** Tool execution context containing session and agent information */
|
125
|
-
context;
|
126
|
-
/**
|
127
|
-
* Creates a new instance of BaseTool
|
128
|
-
* @param name Internal name of the tool (used for API calls)
|
129
|
-
* @param displayName User-friendly display name of the tool
|
130
|
-
* @param description Description of what the tool does
|
131
|
-
* @param isOutputMarkdown Whether the tool's output should be rendered as markdown
|
132
|
-
* @param canUpdateOutput Whether the tool supports live (streaming) output
|
133
|
-
* @param parameterSchema JSON Schema defining the parameters
|
134
|
-
*/
|
135
|
-
constructor(name, displayName, description, kind, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
|
136
|
-
super(name, displayName, description, kind, parameterSchema, isOutputMarkdown, canUpdateOutput);
|
137
|
-
this.name = name;
|
138
|
-
this.displayName = displayName;
|
139
|
-
this.description = description;
|
140
|
-
this.kind = kind;
|
141
|
-
this.parameterSchema = parameterSchema;
|
142
|
-
this.isOutputMarkdown = isOutputMarkdown;
|
143
|
-
this.canUpdateOutput = canUpdateOutput;
|
144
|
-
}
|
145
|
-
build(params) {
|
146
|
-
const validationError = this.validateToolParams(params);
|
147
|
-
if (validationError) {
|
148
|
-
throw new Error(validationError);
|
140
|
+
validateToolParams(params) {
|
141
|
+
const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
|
142
|
+
if (errors) {
|
143
|
+
return errors;
|
149
144
|
}
|
150
|
-
return
|
145
|
+
return this.validateToolParamValues(params);
|
151
146
|
}
|
152
|
-
|
153
|
-
|
154
|
-
* This is a placeholder implementation and should be overridden
|
155
|
-
* Should be called from both `shouldConfirmExecute` and `execute`
|
156
|
-
* `shouldConfirmExecute` should return false immediately if invalid
|
157
|
-
* @param params Parameters to validate
|
158
|
-
* @returns An error message string if invalid, null otherwise
|
159
|
-
*/
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
161
|
-
validateToolParams(params) {
|
162
|
-
// Implementation would typically use a JSON Schema validator
|
163
|
-
// This is a placeholder that should be implemented by derived classes
|
147
|
+
validateToolParamValues(_params) {
|
148
|
+
// Base implementation can be extended by subclasses.
|
164
149
|
return null;
|
165
150
|
}
|
166
|
-
/**
|
167
|
-
* Gets a pre-execution description of the tool operation
|
168
|
-
* Default implementation that should be overridden by derived classes
|
169
|
-
* @param params Parameters for the tool execution
|
170
|
-
* @returns A markdown string describing what the tool will do
|
171
|
-
*/
|
172
|
-
getDescription(params) {
|
173
|
-
return JSON.stringify(params);
|
174
|
-
}
|
175
|
-
/**
|
176
|
-
* Determines if the tool should prompt for confirmation before execution
|
177
|
-
* @param params Parameters for the tool execution
|
178
|
-
* @returns Whether or not execute should be confirmed by the user.
|
179
|
-
*/
|
180
|
-
shouldConfirmExecute(
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
182
|
-
params,
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
184
|
-
abortSignal) {
|
185
|
-
return Promise.resolve(false);
|
186
|
-
}
|
187
|
-
/**
|
188
|
-
* Determines what file system paths the tool will affect
|
189
|
-
* @param params Parameters for the tool execution
|
190
|
-
* @returns A list of such paths
|
191
|
-
*/
|
192
|
-
toolLocations(
|
193
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
194
|
-
params) {
|
195
|
-
return [];
|
196
|
-
}
|
197
151
|
}
|
198
152
|
/**
|
199
153
|
* Detects cycles in a JSON schemas due to `$ref`s.
|
@@ -281,4 +235,63 @@ export var Kind;
|
|
281
235
|
Kind["Fetch"] = "fetch";
|
282
236
|
Kind["Other"] = "other";
|
283
237
|
})(Kind || (Kind = {}));
|
238
|
+
/**
|
239
|
+
* Legacy BaseTool class for backward compatibility with existing LLxprt tools.
|
240
|
+
* New tools should use BaseDeclarativeTool instead.
|
241
|
+
* @deprecated Use BaseDeclarativeTool for new tools
|
242
|
+
*/
|
243
|
+
export class BaseTool extends DeclarativeTool {
|
244
|
+
context;
|
245
|
+
constructor(name, displayName, description, kind, parameterSchema, isOutputMarkdown = true, canUpdateOutput = false) {
|
246
|
+
super(name, displayName, description, kind, parameterSchema, isOutputMarkdown, canUpdateOutput);
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* Get the schema for this tool. Maintains backward compatibility.
|
250
|
+
*/
|
251
|
+
get schema() {
|
252
|
+
return super.schema;
|
253
|
+
}
|
254
|
+
/**
|
255
|
+
* Legacy method signature for getDescription.
|
256
|
+
* Subclasses can override this method.
|
257
|
+
*/
|
258
|
+
getDescription(_params) {
|
259
|
+
return `Execute ${this.displayName}`;
|
260
|
+
}
|
261
|
+
/**
|
262
|
+
* Legacy method signature for validateToolParams.
|
263
|
+
* Subclasses can override this method.
|
264
|
+
* Note: The base class expects TParams, but legacy tools pass unknown.
|
265
|
+
*/
|
266
|
+
validateToolParams(params) {
|
267
|
+
return super.validateToolParams(params);
|
268
|
+
}
|
269
|
+
/**
|
270
|
+
* Implementation of the new declarative pattern.
|
271
|
+
* Creates a tool invocation that bridges to the legacy execute method.
|
272
|
+
*/
|
273
|
+
build(params) {
|
274
|
+
const validationError = this.validateToolParams(params);
|
275
|
+
if (validationError) {
|
276
|
+
throw new Error(validationError);
|
277
|
+
}
|
278
|
+
return new BaseToolLegacyInvocation(this, params);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
/**
|
282
|
+
* Tool invocation wrapper for BaseTool legacy API.
|
283
|
+
*/
|
284
|
+
class BaseToolLegacyInvocation extends BaseToolInvocation {
|
285
|
+
tool;
|
286
|
+
constructor(tool, params) {
|
287
|
+
super(params);
|
288
|
+
this.tool = tool;
|
289
|
+
}
|
290
|
+
getDescription() {
|
291
|
+
return this.tool.getDescription(this.params);
|
292
|
+
}
|
293
|
+
async execute(signal, updateOutput) {
|
294
|
+
return this.tool.execute(this.params, signal, updateOutput);
|
295
|
+
}
|
296
|
+
}
|
284
297
|
//# sourceMappingURL=tools.js.map
|
@@ -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;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AA+C9D;;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;AAyDD;;;GAGG;AACH,MAAM,OAAgB,eAAe;IAMxB;IACA;IACA;IACA;IACA;IACA;IACA;IAPX,YACW,IAAY,EACZ,WAAmB,EACnB,WAAmB,EACnB,IAAU,EACV,eAAwB,EACxB,mBAA4B,IAAI,EAChC,kBAA2B,KAAK;QANhC,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAM;Q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AoC;IAEzB;IADnB,YACmB,IAAgC,EACjD,MAAe;QAEf,KAAK,CAAC,MAAM,CAAC,CAAC;QAHG,SAAI,GAAJ,IAAI,CAA4B;IAInD,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAmB,EACnB,YAAuC;QAEvC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
@@ -21,6 +21,6 @@ export declare class WebFetchTool extends BaseDeclarativeTool<WebFetchToolParams
|
|
21
21
|
private readonly config;
|
22
22
|
static readonly Name: string;
|
23
23
|
constructor(config: Config);
|
24
|
-
protected
|
24
|
+
protected validateToolParamValues(params: WebFetchToolParams): string | null;
|
25
25
|
protected createInvocation(params: WebFetchToolParams): ToolInvocation<WebFetchToolParams, ToolResult>;
|
26
26
|
}
|
@@ -3,7 +3,6 @@
|
|
3
3
|
* Copyright 2025 Google LLC
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
-
import { SchemaValidator } from '../utils/schemaValidator.js';
|
7
6
|
import { BaseDeclarativeTool, BaseToolInvocation, Kind, ToolConfirmationOutcome, } from './tools.js';
|
8
7
|
import { getErrorMessage } from '../utils/errors.js';
|
9
8
|
import { ApprovalMode } from '../config/config.js';
|
@@ -241,11 +240,7 @@ export class WebFetchTool extends BaseDeclarativeTool {
|
|
241
240
|
setGlobalDispatcher(new ProxyAgent(proxy));
|
242
241
|
}
|
243
242
|
}
|
244
|
-
|
245
|
-
const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
|
246
|
-
if (errors) {
|
247
|
-
return errors;
|
248
|
-
}
|
243
|
+
validateToolParamValues(params) {
|
249
244
|
if (!params.prompt || params.prompt.trim() === '') {
|
250
245
|
return "The 'prompt' parameter cannot be empty and must contain URL(s) and instructions.";
|
251
246
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-fetch.js","sourceRoot":"","sources":["../../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
1
|
+
{"version":3,"file":"web-fetch.js","sourceRoot":"","sources":["../../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,IAAI,EAEJ,uBAAuB,GAGxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAU,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAEzD,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,gDAAgD;AAChD,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,QAAQ,GAAG,sBAAsB,CAAC;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAiCD,MAAM,sBAAuB,SAAQ,kBAGpC;IAEoB;IADnB,YACmB,MAAc,EAC/B,MAA0B;QAE1B,KAAK,CAAC,MAAM,CAAC,CAAC;QAHG,WAAM,GAAN,MAAM,CAAQ;IAIjC,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,OAAoB;QAChD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC7C,I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,MAAM,EAAE;oBACN,WAAW,EACT,sSAAsS;oBACxS,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,IAAI,EAAE,QAAQ;SACf,CACF,CAAC;QAjByB,WAAM,GAAN,MAAM,CAAQ;QAkBzC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,IAAI,KAAK,EAAE,CAAC;YACV,mBAAmB,CAAC,IAAI,UAAU,CAAC,KAAe,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAEkB,uBAAuB,CACxC,MAA0B;QAE1B,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,OAAO,kFAAkF,CAAC;QAC5F,CAAC;QACD,IACE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAClC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EACnC,CAAC;YACD,OAAO,uFAAuF,CAAC;QACjG,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAES,gBAAgB,CACxB,MAA0B;QAE1B,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC"}
|
@@ -14,6 +14,11 @@ export declare class WebSearchTool extends BaseDeclarativeTool<WebSearchToolPara
|
|
14
14
|
private readonly config;
|
15
15
|
static readonly Name: string;
|
16
16
|
constructor(config: Config);
|
17
|
-
|
17
|
+
/**
|
18
|
+
* Validates the parameters for the WebSearchTool.
|
19
|
+
* @param params The parameters to validate
|
20
|
+
* @returns An error message string if validation fails, null if valid
|
21
|
+
*/
|
22
|
+
protected validateToolParamValues(params: WebSearchToolParams): string | null;
|
18
23
|
protected createInvocation(params: WebSearchToolParams): ToolInvocation<WebSearchToolParams, WebSearchToolResult>;
|
19
24
|
}
|
@@ -4,7 +4,6 @@
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
6
|
import { BaseDeclarativeTool, Kind } from './tools.js';
|
7
|
-
import { SchemaValidator } from '../utils/schemaValidator.js';
|
8
7
|
import { WebSearchToolInvocation, } from './web-search-invocation.js';
|
9
8
|
/**
|
10
9
|
* A tool to perform web searches using Google Search via the Gemini API.
|
@@ -25,11 +24,12 @@ export class WebSearchTool extends BaseDeclarativeTool {
|
|
25
24
|
});
|
26
25
|
this.config = config;
|
27
26
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
/**
|
28
|
+
* Validates the parameters for the WebSearchTool.
|
29
|
+
* @param params The parameters to validate
|
30
|
+
* @returns An error message string if validation fails, null if valid
|
31
|
+
*/
|
32
|
+
validateToolParamValues(params) {
|
33
33
|
if (!params.query || params.query.trim() === '') {
|
34
34
|
return "The 'query' parameter cannot be empty.";
|
35
35
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;AAEvE,OAAO,EACL,uBAAuB,GAGxB,MAAM,4BAA4B,CAAC;AAQpC;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,mBAGlC;IAG8B;IAF7B,MAAM,CAAU,IAAI,GAAW,mBAAmB,CAAC;IAEnD,YAA6B,MAAc;QACzC,KAAK,CACH,aAAa,CAAC,IAAI,EAClB,cAAc,EACd,uKAAuK,EACvK,IAAI,CAAC,MAAM,EACX;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kDAAkD;iBAChE;aACF;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB,CACF,CAAC;QAhByB,WAAM,GAAN,MAAM,CAAQ;IAiB3C,CAAC;IAED;;;;OAIG;IACgB,uBAAuB,CACxC,MAA2B;QAE3B,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChD,OAAO,wCAAwC,CAAC;QAClD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAES,gBAAgB,CACxB,MAA2B;QAE3B,OAAO,IAAI,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC"}
|
@@ -47,7 +47,7 @@ export declare class WriteFileTool extends BaseDeclarativeTool<WriteFileToolPara
|
|
47
47
|
private readonly config;
|
48
48
|
static readonly Name: string;
|
49
49
|
constructor(config: Config);
|
50
|
-
|
50
|
+
protected validateToolParamValues(params: WriteFileToolParams): string | null;
|
51
51
|
protected createInvocation(params: WriteFileToolParams): ToolInvocation<WriteFileToolParams, ToolResult>;
|
52
52
|
getModifyContext(abortSignal: AbortSignal): ModifyContext<WriteFileToolParams>;
|
53
53
|
}
|
@@ -9,7 +9,6 @@ import * as Diff from 'diff';
|
|
9
9
|
import { ApprovalMode } from '../config/config.js';
|
10
10
|
import { BaseDeclarativeTool, BaseToolInvocation, ToolConfirmationOutcome, Kind, } from './tools.js';
|
11
11
|
import { ToolErrorType } from './tool-error.js';
|
12
|
-
import { SchemaValidator } from '../utils/schemaValidator.js';
|
13
12
|
import { makeRelative, shortenPath } from '../utils/paths.js';
|
14
13
|
import { getErrorMessage, isNodeError } from '../utils/errors.js';
|
15
14
|
import { ensureCorrectEdit, ensureCorrectFileContent, } from '../utils/editCorrector.js';
|
@@ -46,7 +45,9 @@ export async function getCorrectedFileContent(filePath, proposedContent, config,
|
|
46
45
|
let fileExists = false;
|
47
46
|
let correctedContent = proposedContent;
|
48
47
|
try {
|
49
|
-
originalContent =
|
48
|
+
originalContent = await config
|
49
|
+
.getFileSystemService()
|
50
|
+
.readTextFile(filePath);
|
50
51
|
fileExists = true; // File exists and was read
|
51
52
|
}
|
52
53
|
catch (err) {
|
@@ -211,7 +212,9 @@ class WriteFileToolInvocation extends BaseToolInvocation {
|
|
211
212
|
if (!fs.existsSync(dirName)) {
|
212
213
|
fs.mkdirSync(dirName, { recursive: true });
|
213
214
|
}
|
214
|
-
|
215
|
+
await this.config
|
216
|
+
.getFileSystemService()
|
217
|
+
.writeTextFile(filteredParams.file_path, fileContent);
|
215
218
|
// Track git stats if logging is enabled and service is available
|
216
219
|
let gitStats = null;
|
217
220
|
if (this.config.getConversationLoggingEnabled()) {
|
@@ -345,11 +348,7 @@ export class WriteFileTool extends BaseDeclarativeTool {
|
|
345
348
|
});
|
346
349
|
this.config = config;
|
347
350
|
}
|
348
|
-
|
349
|
-
const errors = SchemaValidator.validate(this.schema.parametersJsonSchema, params);
|
350
|
-
if (errors) {
|
351
|
-
return errors;
|
352
|
-
}
|
351
|
+
validateToolParamValues(params) {
|
353
352
|
const filePath = params.file_path;
|
354
353
|
if (!path.isAbsolute(filePath)) {
|
355
354
|
return `File path must be absolute: ${filePath}`;
|