mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-21 13:21:17 +08:00
refactor(tool): convert invalid tool internals to Effect
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import z from "zod"
|
||||
import { Effect } from "effect"
|
||||
import { Tool } from "./tool"
|
||||
|
||||
const parameters = z.object({
|
||||
tool: z.string(),
|
||||
error: z.string(),
|
||||
})
|
||||
|
||||
export const InvalidTool = Tool.define("invalid", {
|
||||
description: "Do not use",
|
||||
parameters: z.object({
|
||||
tool: z.string(),
|
||||
error: z.string(),
|
||||
}),
|
||||
async execute(params) {
|
||||
return {
|
||||
parameters,
|
||||
execute: (params: z.infer<typeof parameters>) =>
|
||||
Effect.succeed({
|
||||
title: "Invalid Tool",
|
||||
output: `The arguments provided to the tool are invalid: ${params.error}`,
|
||||
metadata: {},
|
||||
}
|
||||
},
|
||||
}).pipe(Effect.runPromise),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user