mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 12:54:42 +00:00
refactor(tool): convert invalid tool internals to Effect
This commit is contained in:
parent
eca11ca71a
commit
835bc1cc52
1 changed files with 10 additions and 8 deletions
|
|
@ -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),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue