import type { A2AAgentCard } from '../../types/a2a/index.js'; import type { Delegate, DelegateCapabilities, DelegateRequest, DelegateResult } from '../../types/agent/delegate.js'; /** * The client half of the A2A bridge, as a `Delegate`. * * This kernel could SERVE an agent card and answer `message/send` for two * versions and could not read anybody else's — the bridge was a one-way * door. So the seam added in NZ-PEER-05 had no driven consumer, which is * the state this repo has a ratified rule about: a seam with no caller is * an untested guess at what a caller needs. * * It is deliberately small. Everything about scheduling, cancellation * bookkeeping, sibling policy and outcome predicates already lives in * `DelegatingTaskScheduler`; this only knows how to talk to a peer. */ /** Anything that answers like `fetch`. Injected so a test needs no socket. */ export type FetchLike = (input: string, init?: { method?: string; headers?: Record; body?: string; signal?: AbortSignal; }) => Promise<{ ok: boolean; status: number; json(): Promise; text(): Promise; }>; export interface FetchAgentCardOptions { readonly fetch: FetchLike; /** Cancels discovery; a pre-aborted signal starts no request. */ readonly signal?: AbortSignal; /** Whole fetch-and-body deadline. Defaults to 30 seconds; `0` opts out. */ readonly timeoutMs?: number; } /** A peer that answered with something that is not an agent card. */ export declare class InvalidAgentCardError extends Error { readonly details: { url: string; reason: string; }; constructor(details: { url: string; reason: string; }); } /** A peer speaking a protocol version this kernel does not implement. */ export declare class A2AProtocolMismatchError extends Error { readonly details: { url: string; theirs: string; ours: string; }; constructor(details: { url: string; theirs: string; ours: string; }); } /** The peer answered, and said no. */ export declare class A2ARequestError extends Error { readonly details: { method: string; status?: number; code?: string; }; constructor(message: string, details: { method: string; status?: number; code?: string; }); } /** * Read a peer's card, and refuse one this kernel cannot honestly use. * * Two refusals rather than a best effort. A card that does not parse is not * a peer with quirks, it is an unknown service at a URL somebody typed — * and a protocol version this kernel does not implement means every * subsequent request is a guess. Both are found once, at wiring time, which * is the only moment a human is looking; degrade here and the failure moves * to the middle of a delegation with a turn waiting on it. * * The version comparison is on major.minor, not the patch. A2A is * pre-1.0, where the minor carries breaking changes — matching on the full * string would refuse a peer over a patch bump that changes nothing. */ export declare function fetchAgentCard(baseUrl: string, opts: FetchAgentCardOptions): Promise; export interface A2ADelegateConfig { /** The id the delegation tools name. See `Delegate.id`. */ readonly id: string; readonly card: A2AAgentCard; readonly fetch: FetchLike; /** Headers every request carries — an authorization header, in practice. */ readonly headers?: Readonly>; /** How often to ask `tasks/get` while the peer is still working. */ readonly pollIntervalMs?: number; /** Give up on the whole delegation, including `message/send`, after this long. */ readonly timeoutMs?: number; } export declare class A2ADelegate implements Delegate { private readonly config; readonly id: string; readonly capabilities: DelegateCapabilities; private readonly endpoint; private readonly pollIntervalMs; private readonly timeoutMs; constructor(config: A2ADelegateConfig); private rpc; /** Bounded best effort; cancellation is never allowed to create a second hang. */ private cancelPeer; /** A client-terminal state may still be live on the peer. */ private settleKnownTask; /** * Give an in-flight `message/send` one short chance to reveal its task id. * * Aborting that first transport immediately can abandon remote work while * claiming cancellation locally. A2A cannot address a task until the peer * returns its id, so this bounded grace is the only honest cleanup attempt. */ private recoverInitialTask; private parseTask; dispatch(request: DelegateRequest, opts: { readonly signal?: AbortSignal; }): Promise; } //# sourceMappingURL=client.d.ts.map