The Delegatee class is responsible for executing tools on behalf of the PKP Admin. They are limited to the tools and policies that the PKP Admin has permitted. The class manages the delegatee's authentication and wallet, retrieves permitted tools and their policies, executes tools within permitted boundaries, manages tool-specific credentials, and handles capacity credits for execution. It provides secure access to authorized tools while enforcing policy constraints set by the PKP Admin.

Implements

Properties

litNetwork: LitNetwork

Methods

  • Executes a tool with the provided parameters.

    Parameters

    • params: Omit<JsonExecutionSdkParams, "sessionSigs">

      The parameters for tool execution, excluding session signatures.

    Returns Promise<ExecuteJsResponse>

    A promise that resolves to the tool execution response.

    Throws

    If the execution fails or if the delegatee is not properly initialized.

  • Retrieves stored credentials required by a tool.

    Type Parameters

    • T

    Parameters

    • requiredCredentialNames: readonly string[]

      Names of the required credentials.

    Returns Promise<{
        foundCredentials: Partial<CredentialsFor<T>>;
        missingCredentials: string[];
    }>

    Object containing found credentials and list of any missing credentials.

  • Get all registered tools and categorize them based on whether they have policies

    Parameters

    • pkpTokenId: string

    Returns Promise<PermittedToolsResult>

    Object containing:

    • toolsWithPolicies: Object mapping tool IPFS CIDs to their metadata and delegatee policies
    • toolsWithoutPolicies: Array of tools that don't have policies
    • toolsUnknownWithPolicies: Object mapping unknown tool IPFS CIDs to their delegatee policies
    • toolsUnknownWithoutPolicies: Array of tool CIDs without policies that aren't in the registry
  • Retrieves the policy for a specific tool.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • ipfsCid: string

      The IPFS CID of the tool.

    Returns Promise<any>

    An object containing the policy and version for the tool.

    Throws

    If the tool policy registry contract is not initialized.

  • Matches a user's intent to an appropriate permitted tool.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • intent: string

      The user's intent string.

    • intentMatcher: IntentMatcher

      The intent matcher implementation to use.

    Returns Promise<IntentMatcherResponse<any>>

    A promise that resolves to the matched tool and any extracted parameters.

    Throws

    If no matching tool is found or if the tool is not permitted.

  • Creates an instance of the Delegatee class. Initializes the Lit node client, contracts, and capacity credit.

    Parameters

    • Optional delegateePrivateKey: string

      Optional. The private key for the Delegatee role.

    • agentConfig: AgentConfig = {}

      Configuration for the agent, including the Lit network and debug mode.

    Returns Promise<Delegatee>

    A promise that resolves to an instance of the Delegatee class.

    Throws

    If the Lit network is not provided or the private key is missing.