Type Alias ToolAction<I, O>

ToolAction: Action<I, O> & {
    __action: { metadata: { type: "tool" } };
    reply(
        interrupt: {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest: { input?: unknown; name: string; ref?: string };
            toolResponse?: undefined;
        },
        replyData: TypeOf<O>,
        options?: { metadata?: Record<string, any> },
    ): {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest?: undefined;
        toolResponse: { name: string; output?: unknown; ref?: string };
    };
}

An action with a tool type.

Type Parameters

Type declaration

  • __action: { metadata: { type: "tool" } }
  • reply:function
    • reply constructs a tool response corresponding to the provided interrupt tool request using the provided reply data, validating it against the output schema of the tool if it exists.

      Parameters

      • interrupt: {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest: { input?: unknown; name: string; ref?: string };
            toolResponse?: undefined;
        }

        The interrupt tool request to which you want to respond.

      • replyData: TypeOf<O>

        The data with which you want to respond. Must conform to a tool's output schema or an interrupt's input schema.

      • Optionaloptions: { metadata?: Record<string, any> }

      Returns {
          custom?: Record<string, unknown>;
          data?: unknown;
          media?: undefined;
          metadata?: Record<string, unknown>;
          text?: undefined;
          toolRequest?: undefined;
          toolResponse: { name: string; output?: unknown; ref?: string };
      }