Skip to main content
The TypeScript SDK (@rkat/mobkit-sdk) provides type-safe access to the MobKit JSON-RPC gateway from Node.js.

Installation

Quick start

For identity-first builds with a rosterProvider, .agentMemory() enables optional identity-scoped hot memory injection from <persistentState>/agent-memory with contextual recall by default. Options include realm, selection, maxEntries, recallTimeoutMs, recallFailurePolicy, and instructionHeader; automatic injection defaults to a 500 ms timeout and skips the memory block if recall fails. Write records with handle.rememberAgentMemory(identity, { title, body, tags, realm }), read them with handle.recallAgentMemory(identity, { realm, selection, queryText, queryTerms, maxEntries }), and delete them with handle.forgetAgentMemory(identity, memoryId, { realm }); new records are available on the next identity-first send and during later materialize/resume/respawn/reset flows. Forgetting a record removes it from future recall/injection, but does not erase text already delivered into an active model context.

Type definitions

The SDK exports TypeScript interfaces matching the Rust contracts:

Module support

The SDK supports both ESM and CommonJS:

Cross-module identity check

Because dual CJS+ESM packaging, vitest module isolation, and hoisted-vs-nested monorepos can ship two distinct RpcError constructors in the same process, prefer the structural type guards over instanceof:

Structural mob events + flow runs

Both APIs return the full meerkat ledger projection:

Mobpack authoring

MobHandle wraps the full Flow Editor authoring surface (mobkit/mobpacks/*) with typed methods: mobpackTemplates, mobpackCatalogs, mobpackValidate, mobpackSource, mobpackExport, mobpackImport, mobpackList, mobpackGet, mobpackCreate, mobpackSave, mobpackDelete, mobpackUndo, mobpackRedo, mobpackApplyOperation, mobpackDeployCommand, and mobpackDeploy.
mobpackDeploy(document, true) sends execute: true, which writes the archive and runs rkat mob run on the host — gated by the surface’s advertised authoring_capabilities and, on ABAC-enforced runtimes, the caller’s mobpack.deploy grant. See the Flow Editor guide.

Rust parity notes

The TypeScript SDK targets the JSON-RPC gateway. Rust also exposes lower-level native builder options for in-process embedding; those remain Rust-native and are not mirrored one-for-one in the gateway SDKs. External identity providers are all-or-nothing: configure continuityStore(), leaseProvider(), and scratchDir() together. The SDK sends the corresponding init flags to Rust, and provider callbacks use Rust’s wire shape (result tags and ttl). LeaseProvider.renewLeases(...) is atomic from the caller’s perspective: a rejected promise means no input grant was changed, while every returned renewed or lost result is already committed for that identity. Providers must not commit a replacement grant and then reject. Continuity stores should treat checkpoint_version as monotonic per identity and continuity generation. A live session rebind changes session_id without resetting the version; only destructive reset advances generation and starts the version stream over. Gateway memory config accepts { backend: "local_json" } with an optional healthCheckEndpoint (memory.localJson(...)); the legacy Elephant { backend, endpoint } shape still works but is deprecated. Store, collection, and space selectors are retained on the helper object for app code but are not sent to the Rust gateway. Gateway auth config supports JWT validation; Google/OIDC helpers are model objects, not accepted by mobkit/init today. The builder forwards consoleConfig(path) as runtime_options.console_config_path, which lets the bundled console consume the same console_config contract projected by /console/experience. Use consoleAuthRequired(false) only for explicit local demos.

HTTP transport timeout

createJsonRpcHttpTransport defaults to a 60-second timeout (via AbortController) so a server that accepts but never replies cannot hang the caller’s await forever. Override per-call:

Contract parity

The TypeScript SDK includes parity tests that validate type definitions against the Rust core. This ensures the SDK stays in sync with the runtime API across releases.

See also