Skip to content

apomesh-a2a-client

The outbound half of the A2A integration — the HTTP client the orchestrator drives when a session delegates to a configured remote peer as a tool. The orchestrator resolves the peer row and its credential, constructs one client per call, and reads the remote task state back through the inverse state table (delegation_outcome). Deliberately orchestrator-free: only the orchestrator depends on this crate, never the reverse.

  • A2aClient — one peer, one client: card URL + RPC URL + PeerAuth + the resolved credential + per-call timeout. Methods: fetch_card, send_message, send_streaming_message, subscribe_to_task, get_task, cancel_task. The streaming continuation is atomic: resuming a paused remote task rides one SendStreamingMessage request carrying the task id, so resume + attach cannot race the remote task’s completion.
  • PeerAuth — the auth-header discriminator, chosen from the typed kind of the resolved credential, never by sniffing the secret’s bytes: Bearer (Authorization: Bearer …) or ApiKey { header } (DEFAULT_API_KEY_HEADER = X-API-Key for foreign peers unless the peer row names another; X-Apomesh-Api-Key for apomesh peers). Credentials the client cannot represent are rejected with a typed error at admission — never silently sent.
  • EgressPolicy — the SSRF posture: DenySsrfRanges (default) rejects loopback / RFC1918 / link-local (including the cloud metadata address) / CGNAT / ULA / mapped-IPv6 / multicast / special-use targets before any request is issued; AllowPrivate is the deliberate, named knob for loopback stubs and the full-circle e2e — never the production posture.
  • DelegationOutcome + delegation_outcome — the pure, wildcard-free inverse of the inbound adapter’s substrate→TaskState projection: Pending, Completed, Failed, Canceled, Rejected, and InputRequired (the typed input-required tool result carrying the peer’s prompt + task id for continuation).
  • DEFAULT_CALL_TIMEOUT — the 300-second wall clock bounding one whole remote interaction (per-peer override via the peer row’s call_timeout_secs).
  • A2aClientError — the typed error vocabulary; no variant ever carries credential material (the auth header value is marked sensitive, and redaction is part of the constructor’s contract).

The client is substrate plumbing — operators configure peers in [[a2a_peers]] and sessions call the projected a2a:<peer-id> tool; see Delegate to A2A peers for the operator-facing path. Direct construction is for the orchestrator’s delegation module and tests.