tool2agent API Documentation - v0.0.0
    Preparing search index...

    Type Alias ToolBuilderParams<InputSchema, OutputSchema, DynamicFields>

    Parameters for creating a tool builder.

    type ToolBuilderParams<
        InputSchema extends z.ZodObject<z.ZodRawShape>,
        OutputSchema extends z.ZodTypeAny,
        DynamicFields extends keyof z.infer<InputSchema>,
    > = {
        description?: string;
        dynamicFields: readonly DynamicFields[];
        execute: (
            input: z.infer<InputSchema>,
        ) => Promise<ToolCallResult<z.infer<InputSchema>, z.infer<OutputSchema>>>;
        inputSchema: InputSchema;
        outputSchema: OutputSchema;
    }

    Type Parameters

    • InputSchema extends z.ZodObject<z.ZodRawShape>

      The Zod schema for the tool's input (must be a schema of a record).

    • OutputSchema extends z.ZodTypeAny

      The Zod schema for the tool's output. Can be z.never() for tools that do not return a value.

    • DynamicFields extends keyof z.infer<InputSchema>

      The keys of InputSchema that are dynamic (allows the LLM to provide them incrementally).

    Index

    Properties

    description?: string

    Optional description of the tool for the LLM.

    dynamicFields: readonly DynamicFields[]

    Array of field names from InputSchema that are dynamic (will be made optional at runtime).

    execute: (
        input: z.infer<InputSchema>,
    ) => Promise<ToolCallResult<z.infer<InputSchema>, z.infer<OutputSchema>>>

    Function that executes the tool after all dynamic fields have passed validation.

    The input parameter is fully validated and matches the InputSchema (all required fields are present).

    Must return a ToolCallResult that indicates success or failure:

    • Success: { ok: true, ...output } where output matches OutputSchema (if OutputSchema is a record, spread it directly; otherwise use { value: output })
    • Failure: { ok: false, validationResults: {...}, problems: [...], feedback: [...], instructions: [...], ... } with structured feedback

    Type Declaration

    inputSchema: InputSchema

    The Zod schema defining the tool's input structure.

    outputSchema: OutputSchema

    The Zod schema defining the tool's output structure.