@adcp/sdk API Reference - v7.9.0
    Preparing search index...

    Class TaskExecutor

    Core task execution engine that handles the conversation loop with agents

    Index

    Constructors

    • Parameters

      • config: {
            workingTimeout?: number;
            pollingInterval?: number;
            defaultMaxClarifications?: number;
            enableConversationStorage?: boolean;
            webhookManager?: WebhookManager;
            deferredStorage?: Storage<DeferredTaskState>;
            webhookUrlTemplate?: string;
            agentId?: string;
            webhookSecret?: string;
            strictSchemaValidation?: boolean;
            logSchemaViolations?: boolean;
            validation?: ValidationHookConfig;
            filterInvalidProducts?: boolean;
            onActivity?: (activity: Activity) => void | Promise<void>;
            governance?: GovernanceConfig;
            adcpVersion?: string;
            transport?: TransportOptions;
        } = {}
        • OptionalworkingTimeout?: number

          Default timeout for 'working' status (max 120s per PR #78)

        • OptionalpollingInterval?: number

          Polling interval for 'working' status in milliseconds (default: 2000ms)

        • OptionaldefaultMaxClarifications?: number

          Default max clarification attempts

        • OptionalenableConversationStorage?: boolean

          Enable conversation storage

        • OptionalwebhookManager?: WebhookManager

          Webhook manager for submitted tasks

        • OptionaldeferredStorage?: Storage<DeferredTaskState>

          Storage for deferred task state

        • OptionalwebhookUrlTemplate?: string

          Webhook URL template for protocol-level webhook support

        • OptionalagentId?: string

          Agent ID for webhook URL generation

        • OptionalwebhookSecret?: string

          Webhook secret for HMAC authentication (min 32 chars)

        • OptionalstrictSchemaValidation?: boolean

          Fail tasks when response schema validation fails (default: true)

        • OptionallogSchemaViolations?: boolean

          Log all schema validation violations to debug logs (default: true)

        • Optionalvalidation?: ValidationHookConfig

          Schema-driven validation using the bundled AdCP JSON schemas. Controls outgoing request and incoming response checks independently. Defaults: strict in dev/test, warn in prod. Set a mode to off to skip the validator entirely on that side (zero overhead).

        • OptionalfilterInvalidProducts?: boolean

          Filter out invalid products from get_products responses instead of rejecting the entire response (default: false)

        • OptionalonActivity?: (activity: Activity) => void | Promise<void>

          Global activity callback for observability

        • Optionalgovernance?: GovernanceConfig

          Governance configuration for buyer-side campaign governance

        • OptionaladcpVersion?: string

          AdCP version this executor speaks. Selects which schema bundle validateIncomingResponse / validateOutgoingRequest validate against, and which adcp_major_version value goes on the wire. Defaults to the SDK-pinned ADCP_VERSION when omitted.

          Plumbed from SingleAgentClient.resolvedAdcpVersion so the client/agent's getAdcpVersion() value is the single source of truth for both validation and wire-level major.

        • Optionaltransport?: TransportOptions

          Transport-level safeguards applied to every call this executor dispatches. Per-call options can override individual fields.

      Returns TaskExecutor

    Methods

    • Run the configured pre-send schema check against the user-facing request shape. Callers invoke this on the unadapted (v3) params before any wire adaptation runs, so the validator sees the same object the caller wrote. Throws in strict, logs to debugLogs in warn, no-ops in off.

      Parameters

      • taskName: string
      • params: unknown
      • OptionaldebugLogs: any[]

      Returns void

    • After adaptRequestForServerVersion has rewritten a v3 request into v2 wire format, validate the adapted shape against the cached v2.5 schema bundle. Always warn-only — adapter bugs shouldn't break user requests, and the v3 pre-send pass already vouched for the user-facing input. This pass exists to surface drift between what the adapter emits and what a v2.5 server expects on the wire (primarily as CI signal via the adapter-conformance test suite).

      Skips silently for tasks without a v2.5 schema or when the v2.5 bundle isn't cached. Caller is responsible for gating on serverVersion === 'v2' so v3-targeted traffic doesn't pay the validation cost.

      Parameters

      • taskName: string
      • adaptedParams: unknown
      • OptionaldebugLogs: any[]

      Returns void

    • Get detailed information about a specific task

      Parameters

      • taskId: string

      Returns Promise<TaskInfo | null>

    • Subscribe to task updates for a specific agent

      Parameters

      • agentId: string
      • callback: (task: TaskInfo) => void

      Returns () => void

    • Subscribe to task events with detailed callbacks

      Parameters

      • agentId: string
      • 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

      • agent: AgentConfig
      • webhookUrl: string
      • OptionaltaskTypes: string[]

      Returns Promise<void>