Tool result refactor (return an object instead of a string)

This commit is contained in:
Alex Gleason committed 2025-12-08 15:13:34 -06:00
1 parent 9c86ced552
commit f7b2d754e9
40 files changed
+315 -276

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
import { join, dirname } from "path-browserify";
import { z } from "zod";
import type { Tool } from "./Tool";
import type { Tool, ToolResult } from "./Tool";
import type { JSRuntimeFS } from "../JSRuntime";
import { isAbsolutePath, isWriteAllowed, createWriteAccessDeniedError } from "../security";
@@ -34,7 +34,7 @@ export class TextEditorWriteTool implements Tool<TextEditorWriteParams> {
this.onFileChanged = options?.onFileChanged;
}
async execute(args: TextEditorWriteParams): Promise<string> {
async execute(args: TextEditorWriteParams): Promise<ToolResult> {
const { path, file_text } = args;
// Check write permissions
@@ -66,7 +66,7 @@ export class TextEditorWriteTool implements Tool<TextEditorWriteParams> {
this.onFileChanged(path);
}
return `File successfully written to ${path}`;
return { content: `File successfully written to ${path}` };
} catch (error) {
throw new Error(String(error));
}