@adcp/client API Reference - v3.3.3
    Preparing search index...

    Class AgentClient

    Per-agent client that maintains conversation context across calls

    This wrapper provides a persistent conversation context for a single agent, making it easy to have multi-turn conversations and maintain state.

    Index

    Constructors

    Methods

    • Handle webhook from agent (async task completion or notifications)

      Parameters

      • payload: any

        Webhook payload from agent

      • Optionalsignature: string

        Optional signature for verification (X-ADCP-Signature)

      • Optionaltimestamp: string | number

        Optional timestamp for verification (X-ADCP-Timestamp)

      • OptionaltaskType: string

        Task type from URL path (e.g., 'create_media_buy')

      Returns Promise<boolean>

      Whether webhook was handled successfully

    • Generate webhook URL for a specific task and operation

      Parameters

      • taskType: string

        Type of task (e.g., 'get_products', 'media_buy_delivery')

      • operationId: string

        Operation ID for this request

      Returns string

      Full webhook URL

    • Verify webhook signature using HMAC-SHA256 per AdCP PR #86 spec

      Parameters

      • payload: any

        Webhook payload object

      • signature: string

        X-ADCP-Signature header value (format: "sha256=...")

      • timestamp: string | number

        X-ADCP-Timestamp header value (Unix timestamp)

      Returns boolean

      true if signature is valid

    • Continue the conversation with a natural language message

      Type Parameters

      • T = any

      Parameters

      • message: string

        Natural language message to send to the agent

      • OptionalinputHandler: InputHandler

        Handler for any clarification requests

      • Optionaloptions: TaskOptions

      Returns Promise<TaskResult<T>>

      const agent = multiClient.agent('my-agent');
      await agent.getProducts({ brief: 'Tech products' });

      // Continue the conversation
      const refined = await agent.continueConversation(
      'Focus only on laptops under $1000'
      );
    • Set a specific conversation context ID

      Parameters

      • contextId: string

      Returns void

    • Get agent information including capabilities

      Returns Promise<
          {
              name: string;
              description?: string;
              protocol: "mcp"
              | "a2a";
              url: string;
              tools: {
                  name: string;
                  description?: string;
                  inputSchema?: any;
                  parameters?: string[];
              }[];
          },
      >

    • Get detailed information about a specific task

      Parameters

      • taskId: string

      Returns Promise<null | TaskInfo>

    • Subscribe to task notifications for this agent

      Parameters

      • callback: (task: TaskInfo) => void

      Returns () => void

    • Subscribe to all task events

      Parameters

      • callbacks: {
            onTaskCreated?: (task: TaskInfo) => void;
            onTaskUpdated?: (task: TaskInfo) => void;
            onTaskCompleted?: (task: TaskInfo) => void;
            onTaskFailed?: (task: TaskInfo, error: string) => void;
        }

      Returns () => void

    • Register webhook for task notifications

      Parameters

      • webhookUrl: string
      • OptionaltaskTypes: string[]

      Returns Promise<void>