mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-23 07:59:33 -10:00
Signed-off-by: Jérôme Benoit <[email protected]> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: rekram1-node <[email protected]>
20 lines
401 B
TypeScript
20 lines
401 B
TypeScript
import { z } from "zod"
|
|
|
|
export type ToolContext = {
|
|
sessionID: string
|
|
messageID: string
|
|
agent: string
|
|
abort: AbortSignal
|
|
}
|
|
|
|
export function tool<Args extends z.ZodRawShape>(input: {
|
|
description: string
|
|
args: Args
|
|
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>
|
|
}) {
|
|
return input
|
|
}
|
|
tool.schema = z
|
|
|
|
export type ToolDefinition = ReturnType<typeof tool>
|