Skip to main content

TypeScript SDK

The TypeScript SDK (@senselab-ai/amfs) provides full parity with the Python SDK for Node.js and TypeScript applications — including ReadTracker, auto-causal linking, search, history, stats, scopes, transactions, integrity verification, and explainability.

Installation


Quick Start


Constructor

By default, the SDK uses an in-memory adapter. Pass an HttpAdapter to connect to a remote AMFS server, or implement AmfsAdapter for custom storage.

ReadTracker & Auto-Causal Linking

The TypeScript SDK includes a ReadTracker that automatically logs every read() call and external context. When you call commitOutcome() without explicit causal keys, the SDK uses the read log to build the causal chain — identical to the Python SDK behavior.

Agent-Scoped Memory

The SDK distinguishes between shared memory and agent-scoped memory. Use recall, myEntries, and readFrom for explicit agent-level operations.

Scopes

A MemoryScope provides a focused view bound to a single entity path, reducing boilerplate when working with one service or module.

Composite Scoring with RecallConfig

Pass a recallConfig to get scored results with breakdown information:

Version History


Watch

Subscribe to changes on an entity path:

Transactions

Group multiple writes into an atomic commit:

Integrity Verification

Verify content hashes and integrity chains for stored entries:

Commit Log & DAG

Inspect the commit history and navigate the commit DAG:

Stats


Connecting to AMFS

Using the HttpAdapter

The HttpAdapter provides async methods for remote operations:

Direct REST calls

See the Connect to AMFS guide, MCP server, and REST API reference for details.

Rooms & Collaboration

The SDK includes room-based collaboration APIs for multi-agent knowledge sharing and negotiation. These require an HttpAdapter connection.

Negotiation

Rooms support structured negotiation sessions between agents:

Full API Reference

AgentMemory

Constructor

read

write

list

search

history

stats

watch

verify

transaction

commitLog

commonAncestor

recordContext

explain

commitOutcome

recall

myEntries

readFrom

scope

listScopes

info

tree

clearReadLog


MemoryScope

A scoped view bound to a fixed entity path. When readonly is true, writes throw an error.

TransactionContext


Exports


OutcomeType Values


Notes

The TypeScript SDK uses an in-memory adapter by default. To persist data remotely, pass an HttpAdapter instance configured with your AMFS server URL and API key. The HttpAdapter provides both sync (stub) and async methods — use the async variants (readAsync, writeAsync, etc.) for remote operations.
Room and negotiation APIs require an HTTP connection to AMFS and return Promises. They are available on the AgentMemory instance when using an adapter that exposes a base URL.