Interface AwTool<TParams, TPolicy>

Represents a generic AW (Function-as-a-Service) tool.

interface AwTool<TParams, TPolicy> {
    defaultPolicyIpfsCid: string;
    description: string;
    ipfsCid: string;
    name: string;
    parameters: {
        descriptions: Readonly<Record<keyof TParams, string>>;
        schema: ZodType<TParams, ZodTypeDef, TParams>;
        type: TParams;
        validate: ((params) => true | {
            error: string;
            param: string;
        }[]);
    };
    policy: {
        decode: ((encodedPolicy) => TPolicy);
        encode: ((policy) => string);
        schema: ZodType<TPolicy, ZodTypeDef, TPolicy>;
        type: TPolicy;
        version: string;
    };
}

Type Parameters

  • TParams extends Record<string, any> = Record<string, any>

    The type of the tool's parameters.

  • TPolicy extends {
        type: string;
    } = {
        type: string;
    }

    The type of the tool's policy.

Properties

defaultPolicyIpfsCid: string

The IPFS Content Identifier (CID) that points to the tool's default policy configuration. This policy is used when no custom policy is specified for the tool.

description: string

A detailed description of the tool's functionality, including its purpose, use cases, and any important notes.

ipfsCid: string

The IPFS Content Identifier (CID) that points to the tool's Lit Action implementation. This is used to locate and execute the tool's code.

name: string

The name of the tool. This should be a unique identifier that clearly describes the tool's purpose.

parameters: {
    descriptions: Readonly<Record<keyof TParams, string>>;
    schema: ZodType<TParams, ZodTypeDef, TParams>;
    type: TParams;
    validate: ((params) => true | {
        error: string;
        param: string;
    }[]);
}

Configuration for the tool's parameters. Defines the structure, validation, and documentation of the tool's input parameters.

Type declaration

  • descriptions: Readonly<Record<keyof TParams, string>>

    Human-readable descriptions of each parameter. Provides documentation about what each parameter does and how it should be used.

  • schema: ZodType<TParams, ZodTypeDef, TParams>

    Zod schema for runtime validation of parameter values. Ensures that parameters meet the required format and constraints.

  • type: TParams

    The TypeScript type definition for the tool's parameters. This serves as a compile-time type check for parameter values.

  • validate: ((params) => true | {
        error: string;
        param: string;
    }[])

    Function to validate parameter values at runtime.

    Returns

    true if validation succeeds, or an array of validation errors if it fails.

      • (params): true | {
            error: string;
            param: string;
        }[]
      • Parameters

        • params: unknown

          The parameters to validate.

        Returns true | {
            error: string;
            param: string;
        }[]

policy: {
    decode: ((encodedPolicy) => TPolicy);
    encode: ((policy) => string);
    schema: ZodType<TPolicy, ZodTypeDef, TPolicy>;
    type: TPolicy;
    version: string;
}

Configuration for the tool's policy. Defines how the tool's execution policies are structured, validated, and encoded.

Type declaration

  • decode: ((encodedPolicy) => TPolicy)

    Function to decode a policy string back into a policy object.

    Returns

    The decoded policy object.

      • (encodedPolicy): TPolicy
      • Parameters

        • encodedPolicy: string

          The encoded policy string to decode.

        Returns TPolicy

  • encode: ((policy) => string)

    Function to encode a policy object into a string format for storage or transmission.

    Returns

    The encoded policy string.

      • (policy): string
      • Parameters

        • policy: TPolicy

          The policy object to encode.

        Returns string

  • schema: ZodType<TPolicy, ZodTypeDef, TPolicy>

    Zod schema for runtime validation of policy values. Ensures that policies meet the required format and constraints.

  • type: TPolicy

    The TypeScript type definition for the tool's policy. This serves as a compile-time type check for policy values.

  • version: string

    The version string for the policy format. Used to track policy compatibility and handle upgrades.