Type Alias ToolAction<I, O>

ToolAction: Action<I, O, ZodTypeAny, ToolRunOptions> & {
    __action: { metadata: { type: "tool" } };
    respond(
        interrupt: {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest: { input?: unknown; name: string; ref?: string };
            toolResponse?: undefined;
        },
        outputData: 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 };
    };
    restart(
        interrupt: {
            custom?: Record<string, unknown>;
            data?: unknown;
            media?: undefined;
            metadata?: Record<string, unknown>;
            text?: undefined;
            toolRequest: { input?: unknown; name: string; ref?: string };
            toolResponse?: undefined;
        },
        resumedMetadata?: any,
        options?: { replaceInput?: TypeOf<I> },
    ): {
        custom?: Record<string, unknown>;
        data?: unknown;
        media?: undefined;
        metadata?: Record<string, unknown>;
        text?: undefined;
        toolRequest: { input?: unknown; name: string; ref?: string };
        toolResponse?: undefined;
    };
}

An action with a tool type.

Type Parameters

Type declaration

  • __action: { metadata: { type: "tool" } }
  • respond:function
    • Beta

      respond 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.

      • outputData: 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 };
      }

  • restart:function
    • Beta

      restart constructs a tool request corresponding to the provided interrupt tool request that will then re-trigger the tool after e.g. a user confirms. The resumedMetadata supplied to this method will be passed to the tool to allow for custom handling of restart logic.

      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 you want to restart.

      • OptionalresumedMetadata: any

        The metadata you want to provide to the tool to aide in reprocessing. Defaults to true if none is supplied.

      • Optionaloptions: { replaceInput?: TypeOf<I> }

        Additional options for restarting the tool.

        • OptionalreplaceInput?: TypeOf<I>

          Replace the existing input arguments to the tool with different ones, for example if the user revised an action before confirming. When input is replaced, the existing tool request will be amended in the message history.

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