refactor(tool): migrate tool framework + all 18 built-in tools to Effect Schema (#23244)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import z from "zod"
|
||||
import { Schema } from "effect"
|
||||
import * as path from "path"
|
||||
import { Effect } from "effect"
|
||||
import * as Tool from "./tool"
|
||||
@@ -17,6 +17,13 @@ import * as Bom from "@/util/bom"
|
||||
|
||||
const MAX_PROJECT_DIAGNOSTICS_FILES = 5
|
||||
|
||||
export const Parameters = Schema.Struct({
|
||||
content: Schema.String.annotate({ description: "The content to write to the file" }),
|
||||
filePath: Schema.String.annotate({
|
||||
description: "The absolute path to the file to write (must be absolute, not relative)",
|
||||
}),
|
||||
})
|
||||
|
||||
export const WriteTool = Tool.define(
|
||||
"write",
|
||||
Effect.gen(function* () {
|
||||
@@ -27,10 +34,7 @@ export const WriteTool = Tool.define(
|
||||
|
||||
return {
|
||||
description: DESCRIPTION,
|
||||
parameters: z.object({
|
||||
content: z.string().describe("The content to write to the file"),
|
||||
filePath: z.string().describe("The absolute path to the file to write (must be absolute, not relative)"),
|
||||
}),
|
||||
parameters: Parameters,
|
||||
execute: (params: { content: string; filePath: string }, ctx: Tool.Context) =>
|
||||
Effect.gen(function* () {
|
||||
const filepath = path.isAbsolute(params.filePath)
|
||||
|
||||
Reference in New Issue
Block a user