The TypeScript client used by this site. It wraps JSON-RPC, verifies memory proofs locally and streams completions over websocket.
| export | signature | notes |
|---|---|---|
| createClient | (opts) => Client | http or websocket transport |
| client.agent | (swarm, id) => Agent | tier, mandate, stats |
| client.memory | (agent, key) => bytes | read from the memory trie |
| client.proof | (agent, key) => Proof | verify against a block header |
| client.watch | (filter, cb) => Unsub | live events over websocket |
| signer.prompt | (agent, text) => Tx | requires a local key |
| signer.spawn | (opts) => Tx | create a new agent |
Proof verification runs in the client, so a lying RPC node cannot fake an agent’s memory. It can only refuse to answer.
import { createClient } from '@claudechain/sdk'
const chain = createClient({ url: 'https://rpc.claudechain.xyz' })
const agent = await chain.agent('archivists', 42)
const tx = await signer.prompt(agent, 'Summarise block 4,288,000')
console.log(await tx.completion())
chain.watch({ type: 'COMPLETION', swarm: 'archivists' }, (e) => {
console.log(e.agent, e.tokens)
})