Overview
@ixo/oracles-client-sdk is the official React client for a QiForge oracle. It wraps:
- The streaming chat endpoint over SSE.
- The WebSocket event channel (tool calls, render components, browser tools, AG-UI actions).
- UCAN auth — signing invocations (authentication) and delegations (downstream authorization).
- Browser-side tools and AG-UI actions (so the agent can act on the user’s tab / UI).
Install
react >= 18 and zod ^3 are peer dependencies.
OraclesProvider (required wrapper)
Every hook callsuseOraclesContext(), which throws useOraclesContext must be used within a OraclesProvider if there’s no provider above it. Wrap your app once. The provider holds the wallet, signs transactions, and turns your createDelegation / createInvocation callbacks into the cached auth artifacts the hooks attach to requests.
{ address, did, matrix: { accessToken, homeServer } }
required
The connected user’s wallet + Matrix session. Required.
(messages, memo?) => Promise<unknown>
required
Signs and broadcasts chain transactions (e.g. paying to contract the oracle).
(oracleDid: string) => Promise<{ serialized: string; expiresAt: number }>
required
Mints a user→oracle UCAN delegation. The provider caches it and sends it as
x-ucan-delegation.(oracleDid: string) => Promise<{ serialized: string; expiresAt: number }>
Optional (migration-safe). Mints a short-lived UCAN invocation; the provider sends it as
Authorization: Bearer … + X-Auth-Type: ucan (primary auth). Omit to stay on delegation-only auth.useChat
The primary hook. Provides the message thread, the send function, and live streaming state.IChatOptions):
string
required
The oracle’s DID. The SDK resolves its API/WS URL from the oracle’s on-chain config.
string
required
The chat session to read/write. Create one with
useOracleSessions().createSession().(claimIds: string[]) => void
required
Called when the oracle returns a payment-required error. Surface a paywall.
Record<string, { toolName, description, schema, fn }>
Browser-side tools the agent may call on the user’s tab (see below).
UIComponents
Map of render-component name → React component for
render_component events.{ baseUrl?, wsUrl? }
Override the resolved API / WebSocket URLs (local dev, self-host).
'batched' | 'immediate'
How streamed tokens are flushed to state.
There is no
isStreaming or events field — use status / isSending for streaming state.
Browser tools
Browser tools let the agent call DOM/UI actions on the user’s tab. Pass them as thebrowserTools option to useChat — a map keyed by tool name. The SDK advertises them to the agent, forwards each call to your fn, and returns the result over the WebSocket.
registerBrowserTools export — browser tools are the browserTools option above.
AG-UI actions
useAgAction registers an agent-invokable action with an optional render. The provider tracks registered actions; useChat advertises them and renders their output inline.
Events
Streamed and WebSocket events are surfaced as the typedAnyEvent union and rendered through renderMessageContent / your uiComponents map. The event eventName values match the wire names:
The full server/client WebSocket event catalog is in API endpoints → WebSocket.
Other exports
Auth lifecycle
The provider owns auth. From yourcreateDelegation / createInvocation callbacks it:
- Caches the signed delegation and invocation per
(userDid, oracleDid). - Attaches
Authorization: Bearer <invocation>+X-Auth-Type: ucan(primary) andx-ucan-delegation(downstream / fallback) to every request. - Passes the same artifacts on the WebSocket handshake (
auth.invocation/auth.ucanDelegation).
createDelegation again to mint a fresh one (the client-sdk POSTs it to /delegation).
Where to read next
API endpoints
The HTTP / WebSocket protocol the SDK speaks.
Identity and auth
UCAN delegation and the per-request auth headers.