Skip to main content

Connect to an agent

from() fetches /.well-known/agent.json, loads the public key, and generates a local Ed25519 keypair stored in .samvad/client-keys/ (created if absent).

Sync call

call() builds a signed envelope, sends it to POST /agent/message, and returns the parsed result. Throws SamvadError on protocol errors.

Async task

SSE streaming

stream() sends to POST /agent/stream and returns an async generator over SSE chunks. The stream ends when the agent sends "done": true.

Calling a trusted-peers skill

A trusted-peers skill only accepts callers whose agent:// ID and public key are registered on the server. Use AgentClient.prepare() to generate the client keypair before connecting, so you can register it first:

Error handling

See Error Codes for the full list.