@adcp/client API Reference - v3.11.2
    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

      • taskType: string

        Task type (e.g create_media_buy) from url param or url part of the webhook delivery

      • operationId: string

        Operation id (e.g used for client app to track the operation) from the param or url part of the webhook delivery

      • Optionalsignature: string

        Optional signature for verification (X-ADCP-Signature)

      • Optionaltimestamp: string | number

        Optional timestamp for verification (X-ADCP-Timestamp)

      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 the canonical base URL for this agent

      Returns the canonical URL if already resolved, or computes it synchronously. For guaranteed canonical URL (especially for A2A), use resolveCanonicalUrl() first.

      Returns string

    • Resolve and return the canonical base URL for this agent

      For A2A: Fetches the agent card and uses its 'url' field For MCP: Performs endpoint discovery and strips /mcp suffix

      Returns Promise<string>

    • 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>