import type { A2ACorrelationMetadata, A2ASourceContextReference, A2AReadOnlyActionResult, AgentCard, A2AProtocolVersion, FilePart, Message, Task } from "./types.js"; export declare const MAX_A2A_CALLER_RESPONSE_CHARS = 32768; export declare function clearA2ACardCache(): void; export declare class A2ATaskTimeoutError extends Error { readonly taskId: string; readonly lastTask: Task; readonly lastState: string; readonly timeoutMs: number; constructor(taskId: string, lastTask: Task, timeoutMs: number); } export type A2AProtocolErrorCode = "a2a_invalid_json" | "a2a_missing_jsonrpc" | "a2a_invalid_jsonrpc" | "a2a_no_jsonrpc_interface" | "a2a_insecure_endpoint"; export declare class A2AProtocolError extends Error { readonly errorCode: A2AProtocolErrorCode; readonly code: A2AProtocolErrorCode; readonly url?: string; readonly responseText?: string; constructor(message: string, errorCode: A2AProtocolErrorCode, options?: { url?: string; responseText?: string; }); } export declare class A2AMissingJsonRpcResponseError extends A2AProtocolError { constructor(url: string, responseText?: string); } export declare class A2AJsonRpcResponseError extends A2AProtocolError { constructor(message: string, options?: { url?: string; responseText?: string; }); } export declare class A2ANoJsonRpcInterfaceError extends A2AProtocolError { readonly interfaces: string[]; constructor(interfaces: string[]); } export declare class A2AInsecureEndpointError extends A2AProtocolError { constructor(url: string); } export type A2ATerminalTaskErrorState = "failed" | "canceled" | "input-required" | "completed"; export declare class A2ATaskTerminalError extends Error { readonly taskId: string; readonly state: A2ATerminalTaskErrorState; readonly responseText: string; readonly errorCode: string; readonly task: Task; constructor(task: Task, state: A2ATerminalTaskErrorState, responseText: string, errorCode?: string); } export declare function boundA2ACallerResponseText(value: string): string; export declare function signA2AToken(email: string, orgDomain?: string, orgSecret?: string, options?: { expiresIn?: string | number; preferGlobalSecret?: boolean; audience?: string | string[]; /** * Extra JWT claims to merge alongside `sub` / `org_domain`. Used by * first-party MCP calls to add a `jti` and a `scope: "mcp-connect"` * marker. Reserved claims (`sub`, `org_domain`) cannot be overridden — * they are spread last so a caller can never spoof identity via this map. */ extraClaims?: Record; }): Promise; export declare function getGlobalA2ASecret(): string | undefined; export declare function signA2AOrganizationToken(orgDomain: string | undefined, orgSecret?: string, orgId?: string, options?: { expiresIn?: string | number; audience?: string | string[]; preferGlobalSecret?: boolean; extraClaims?: Record; }): Promise; export declare function signA2AOrgMemberDelegationToken(email: string, orgDomain: string, orgSecret: string, audience: string | string[]): Promise; export declare function shouldPreferGlobalA2ASecret(orgSecret?: string): boolean; export declare class A2AClient { private baseUrl; private apiKey?; private apiKeyAttempts; private endpointCandidates; private endpointResolved; private requestTimeoutMs?; private transportHeaders?; private cardUrl?; private protocolVersion?; private streaming?; constructor(baseUrl: string, apiKey?: string, options?: { requestTimeoutMs?: number; fallbackApiKeys?: string[]; transportHeaders?: Record; cardUrl?: string; agentCardUrl?: string; protocolVersion?: A2AProtocolVersion; a2aVersion?: A2AProtocolVersion; }); resolveEndpoint(): Promise; resolveEndpointUrl(timeoutMs?: number): Promise; setAuthentication(apiKey?: string, fallbackApiKeys?: string[]): void; private headers; private markApiKeySucceeded; private rpc; getAgentCard(options?: { timeoutMs?: number; token?: string; cardUrl?: string; }): Promise; private fetchAgentCard; send(message: Message, opts?: { contextId?: string; metadata?: Record; idempotencyKey?: string; requestTimeoutMs?: number; deadlineMs?: number; async?: boolean; }): Promise; getTask(taskId: string, opts?: { requestTimeoutMs?: number; deadlineMs?: number; }): Promise; invokeAction(action: string, input?: Record, opts?: { metadata?: A2ACorrelationMetadata; }): Promise; sendAndWait(message: Message, opts?: { contextId?: string; metadata?: Record; idempotencyKey?: string; timeoutMs?: number; submissionTimeoutMs?: number; pollIntervalMs?: number; onUpdate?: (task: Task) => void; }): Promise; waitForTask(taskId: string, opts?: { timeoutMs?: number; pollIntervalMs?: number; onUpdate?: (task: Task) => void; }): Promise; private pollTask; stream(message: Message, opts?: { contextId?: string; metadata?: Record; }): AsyncGenerator; private ensureEndpointCandidates; private postJson; private transportHeadersFor; } export declare function assertCredentialedA2AUrl(url: string, credentialed: boolean): void; export declare function callAgent(url: string, text: string, opts?: { apiKey?: string; apiKeyFallbacks?: string[]; metadata?: Record; transportHeaders?: Record; cardUrl?: string; agentCardUrl?: string; protocolVersion?: A2AProtocolVersion; a2aVersion?: A2AProtocolVersion; contextId?: string; userEmail?: string; orgId?: string; orgDomain?: string; orgSecret?: string; requestOrigin?: string; sourceContext?: A2ASourceContextReference; correlation?: A2ACorrelationMetadata; idempotencyKey?: string; async?: boolean; timeoutMs?: number; submissionTimeoutMs?: number; taskId?: string; pollIntervalMs?: number; returnRecoverableArtifactsOnTimeout?: boolean; onUpdate?: (task: Task) => void; files?: FilePart["file"][]; }): Promise; /** * Invoke one receiver-approved read-only action with an audience-bound user * token. Unlike conversational delegation, this never starts the receiver's * model loop. */ export declare function callAction(url: string, action: string, input?: Record, opts?: { apiKey?: string; userEmail?: string; orgId?: string; orgDomain?: string; orgSecret?: string; requestTimeoutMs?: number; correlation?: A2ACorrelationMetadata; cardUrl?: string; agentCardUrl?: string; protocolVersion?: A2AProtocolVersion; a2aVersion?: A2AProtocolVersion; }): Promise;