@steerprotocol/agentconnect-provider
v0.4.0
Published
Browser-safe EIP-1193 provider client for the local AgentConnect daemon.
Readme
AgentConnect Provider
EIP-1193 provider for browser apps that send wallet requests to the local AgentConnect daemon.
import { createAgentConnectProvider } from "@steerprotocol/agentconnect-provider";
const provider = createAgentConnectProvider({
appName: "Example Dapp",
autoPairing: true,
origin: window.location.origin,
url: "http://127.0.0.1:48745",
});Pairing
eth_requestAccounts is the pairing entrypoint. If the app is not paired, the daemon creates an origin-bound pairing challenge. With autoPairing: true, the provider waits while an MCP/control-plane operator discovers the challenge with agentconnect_list_pairing_challenges and approves it with agentconnect_pair_app; the browser provider then claims the approved app-scoped token and stores it automatically.
Without autoPairing, the provider rejects with 4100 and includes daemon challenge metadata in error.data.challenge so a host app can drive its own trusted pairing UX. The browser does not approve that challenge itself.
Provider storage accepts only app_ tokens. MCP/admin tokens are rejected or cleared before use.
Each provider instance includes a stable opaque tab_... identifier in daemon request context. If tabId is not provided, the provider creates a random session-scoped id in provider storage. The id is not derived from origin, app name, account, user agent, or other browser fingerprinting data.
Request Lifecycle
eth_sendTransaction returns a pending AgentConnect envelope while the daemon waits for MCP/operator review. The original provider.request(...) promise remains pending through approved, signing, and signed lifecycle events and resolves only on broadcast with a transaction hash. rejected maps to 4001; expired and failed reject with daemon error metadata when available. Duplicate or late lifecycle events after settlement are ignored.
Allowlisted read-only RPC methods such as eth_blockNumber, eth_call, eth_getBalance, eth_getCode, and eth_getTransactionCount are proxied through the daemon's configured chain RPC. They do not enter the signing queue and do not grant browser-side approval authority.
Events And Errors
The provider emits standard connect, accountsChanged, chainChanged, disconnect, and message events. Account and chain results from direct EIP-1193 calls update those events immediately; daemon lifecycle events can update them later.
Error mapping:
4001: user/operator rejection.4100: unauthorized, unpaired, or invalidated app token.4200: unsupported or browser-forbidden methods.4900: daemon offline, transport failure, or provider disposal.4901: requested chain is unavailable from the daemon.
Reconnect And Resync Limits
The provider opens a WebSocket lifecycle stream when a browser WebSocket implementation and app token are available. It also polls daemon lifecycle events for pending requests as a fallback. WebSocket reconnects use bounded exponential backoff with jitter, refresh account and chain state after reconnect, and resync local pending requests from daemon lifecycle truth by request id. Cursor-based replay remains future hardening. When the provider is disposed or its app token is invalidated, it rejects local pending promises instead of silently resubmitting signing or transaction requests.
Boundaries
The provider creates browser requests only. It never imports, exports, or reveals private keys, never exposes MCP/admin approval methods, and never sends browser-visible approval/rejection/signing/broadcast commands.
Use @steerprotocol/agentconnect-wagmi for Wagmi integration. Viem can consume the provider through custom(provider) for representative wallet reads.
License
BUSL-1.1. See LICENSE.
