DAFT - v1.0.0
    Preparing search index...

    Interface Tool<I, O>

    A tool is a function that transforms data.

    Tools are executed by steps and can report usage (tokens, cost, duration).

    const tool: Tool<{ text: string }, { summary: string }> = {
    name: 'summarize',
    input: { text: '' },
    output: { summary: '' },
    description: 'Summarize the input text',
    run: async (input) => {
    return {
    output: { summary: input.text.substring(0, 100) },
    usage: { tokens: 50, cost: 0, duration: 100 }
    };
    }
    };
    interface Tool<I = any, O = any> {
        name: string;
        input: I;
        output: O;
        description?: string;
        run: (input: I) => Promise<{ output: O; usage?: Partial<Usage> }>;
    }

    Type Parameters

    • I = any

      Input type for the tool

    • O = any

      Output type for the tool

    Index

    Properties

    name: string

    Unique identifier for this tool. Referenced by name in step.tools arrays.

    input: I

    Type signature for input data. Used for type-checking and documentation.

    output: O

    Type signature for output data. Used for type-checking and documentation.

    description?: string

    Human-readable description of what this tool does.

    run: (input: I) => Promise<{ output: O; usage?: Partial<Usage> }>

    Execute the tool with the given input.

    Type Declaration

      • (input: I): Promise<{ output: O; usage?: Partial<Usage> }>
      • Parameters

        • input: I

          The data to transform

        Returns Promise<{ output: O; usage?: Partial<Usage> }>

        Object with output data and optional usage statistics