@rkat/sdk) is a thin wrapper over Meerkat’s settled runtime-backed contracts. It spawns a local rkat-rpc subprocess and exposes the same session lifecycle used by the CLI, REST, JSON-RPC, and MCP surfaces as TypeScript-native Session and DeferredSession handles.
Getting started
Install the RPC binary
ANTHROPIC_API_KEY).Method overview
MeerkatClient methods
| Method | Description |
|---|---|
connect(options?) | Spawn rkat-rpc, handshake, fetch capabilities |
close() | Kill the subprocess |
createSession(prompt, options?) | Create a session, run the first turn, return a Session |
createSessionStreaming(prompt, options?) | Create a session and stream typed events from the first turn |
listSessions() | List active sessions |
readSession(sessionId) | Read raw session state |
readSessionHistory(sessionId, options?) | Read committed session transcript history |
createMob(options?) | Create a mob, return a Mob |
createDeferredSession(prompt, options?) | Create a session without running the first turn; returns a DeferredSession |
listMobs() | List mobs |
getConfig() | Read runtime configuration |
setConfig(config) | Replace runtime configuration |
patchConfig(patch) | Merge-patch runtime configuration |
Capability methods
| Method | Description |
|---|---|
client.capabilities | Read-only array of all Capability objects |
client.hasCapability(id) | Returns true if capability is "Available" |
client.requireCapability(id) | Throws CapabilityUnavailableError if unavailable |
Session methods
| Method | Description |
|---|---|
session.turn(prompt, options?) | Run another turn (non-streaming), returns RunResult |
session.stream(prompt, options?) | Run another turn with streaming, returns EventStream |
session.history(options?) | Read committed transcript history for this session |
session.interrupt() | Cancel the currently running turn |
session.archive() | Remove the session from the server |
session.invokeSkill(skillRef, prompt) | Invoke a skill in this session |
session.send(command) | Send a comms command scoped to this session |
session.peers() | List peers visible to this session’s comms runtime |
session.subscribeEvents() | Open a standalone event subscription; returns EventSubscription<AgentEventEnvelope> |
Mob methods
| Method | Description |
|---|---|
mob.mobId | The mob’s identifier |
mob.status() | Get mob status |
mob.lifecycle(action) | Stop, resume, complete, destroy, or reset the mob |
mob.spawn(spec) | Spawn a member |
mob.retire(meerkatId) | Retire a member |
mob.respawn(meerkatId) | Respawn a member |
mob.wire(a, b) | Wire two members |
mob.unwire(a, b) | Remove wiring |
mob.listMembers() | List mob members |
mob.member(meerkatId).send(content, handlingMode?) | Send work to a member |
mob.listFlows() | List available flows |
mob.runFlow(flowId, params) | Start a flow run |
mob.flowStatus(runId) | Get flow run status |
mob.cancelFlow(runId) | Cancel a flow run |
mob.subscribeMemberEvents(meerkatId) | Subscribe to member events; returns EventSubscription<AgentEventEnvelope> |
mob.subscribeEvents() | Subscribe to mob-wide events; returns EventSubscription<AttributedMobEvent> |
MeerkatClient
Constructor
$PATH for rkat-rpc. If not found, automatically downloads the correct binary for the current platform and caches it in ~/.cache/meerkat/bin/rkat-rpc. Pass an explicit path or set MEERKAT_BIN_PATH to override.
connect()
rkat-rpc, performs initialize handshake, checks contract version compatibility, and fetches capabilities. Returns this for chaining.
realmId and isolated are mutually exclusive. If realmId is omitted and isolated is not set, sessions are stored in the default realm. Reuse realmId to share sessions and config across processes or surfaces.
createSession()
prompt, and returns a Session object. The Session holds the last RunResult and exposes convenience accessors for the most recent text, usage, and tool call counts.
createSessionStreaming()
EventStream for the first turn. Iterate the stream to receive typed events as they arrive. The final RunResult is available on stream.result after iteration completes.
SessionOptions
All fields are camelCase:Session
createSession() and createSessionStreaming() both produce a Session object that acts as the handle for all subsequent turns on the same conversation. The SDK does not own a second execution path; it only wraps the canonical runtime session identity.
Identity
Last-result shortcuts
These accessors always reflect the most recent completed turn:turn()
RunResult. Also updates the session’s last-result shortcuts.
stream()
EventStream. Iterating it yields typed AgentEvent objects. The session’s last-result shortcuts are updated when iteration completes.
interrupt()
turn/interrupt for this session. Has no effect if no turn is running.
archive()
Session object should not be used after calling archive().
invokeSkill()
requireCapability("skills"), then runs a turn with the provided skill reference injected. SkillRef is either a SkillKey object or a legacy string:
send() and peers()
comms capability.
subscribeEvents()
EventSubscription that yields typed AgentEventEnvelope objects.
Capabilities
Capabilities are fetched automatically duringconnect(). Use them to guard code paths that depend on optional features.
Known capability IDs
Known capability IDs
| ID | Description |
|---|---|
sessions | Session lifecycle |
streaming | Real-time event streaming |
structured_output | JSON schema structured output |
hooks | Lifecycle hooks |
builtins | Built-in tools |
shell | Shell tool |
comms | Inter-agent communication |
memory_store | Semantic memory |
session_store | Session persistence |
session_compaction | Context compaction |
skills | Skill loading |
Config management
Examples
Structured output
Structured output
Multi-turn conversation
Multi-turn conversation
Streaming a turn
Streaming a turn
Invoking a skill
Invoking a skill
Multimodal prompt (image input)
Multimodal prompt (image input)
Using collectText() for simple streaming
Using collectText() for simple streaming
See also
- TypeScript SDK reference - types, events, errors, and version compatibility
- Rust SDK overview - Rust library API
- RPC reference - JSON-RPC protocol specification
