import type { StandardSchemaV1 } from "@standard-schema/spec" export namespace Tool { interface Metadata { [key: string]: any } export type Context = { sessionID: string messageID: string callID?: string abort: AbortSignal metadata(input: { title?: string; metadata?: M }): void } export interface Info { id: string init: () => Promise<{ description: string parameters: Parameters execute( args: StandardSchemaV1.InferOutput, ctx: Context, ): Promise<{ title: string metadata: M output: string }> }> } export function define( id: string, init: Info["init"] | Awaited["init"]>>, ): Info { return { id, init: async () => { if (init instanceof Function) return init() return init }, } } }