TypeScript SDK
The TypeScript SDK (@senselab-ai/amfs) connects Node.js and TypeScript agents to your SenseLab account — briefings, reads and writes, search, outcomes and decision traces over the HttpAdapter — and ships an in-memory adapter with ReadTracker, auto-causal linking, scopes, transactions and integrity verification for tests and prototypes.
Installation
fetch. The package name still carries the project’s original name, AMFS (Agent Memory File System); npm install @senselab-ai/amfs gets you SenseLab.
Two ways to run it
TheHttpAdapter is how the SDK reaches your account. Its *Async methods are what you use in an agent; the synchronous API exists for the in-memory adapter.
Quick start: connected to SenseLab
Get an API key from Settings → API Keys (see Connect to SenseLab), then:causalEntryKeys on remote commits: the SDK’s ReadTracker only sees synchronous reads, so it has nothing to credit for entries fetched with searchAsync or readAsync.
The SDK does not read
AMFS_HTTP_URL or AMFS_API_KEY on its own. Those
variables are honoured by the MCP server and the CLI; in TypeScript, pass the
URL and key to HttpAdapter yourself, as above.Connecting to SenseLab
Using the HttpAdapter
HttpAdapter provides async methods for everything that reaches your account:
Error("AMFS API <status>: <body>"), so a wrong key surfaces as a 401 on the first call rather than as silently missing data.
Direct REST calls
Quick start: in memory
The sections from here through Stats describe the synchronous API, which runs on the in-memory adapter. Use it in unit tests and prototypes; in an agent, use the*Async methods above.
Constructor
HttpAdapter to reach your SenseLab account. Without adapter, the SDK uses the in-memory adapter and nothing leaves the process.
ReadTracker & Auto-Causal Linking
The TypeScript SDK includes aReadTracker 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. Userecall, myEntries, and readFrom for explicit agent-level operations.
Scopes
AMemoryScope provides a focused view bound to a single entity path, reducing boilerplate when working with one service or module.
Search
Composite Scoring with RecallConfig
Pass arecallConfig 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
Rooms & Collaboration
The SDK includes room-based collaboration APIs for multi-agent knowledge sharing and negotiation. These require anHttpAdapter 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. Whenreadonly is true, writes throw an error.
TransactionContext
Exports
OutcomeType Values
Troubleshooting
Nothing shows up on the dashboard. Either the memory is on the default in-memory adapter, or you called the synchronous methods over anHttpAdapter — they are stubs and never reach the server. Pass { adapter: new HttpAdapter({ url, apiKey }) } and use adapter.readAsync / writeAsync / commitOutcomeAsync. See Two ways to run it.
Error: AMFS API 401.
The API key is missing or wrong. Keys come from Settings → API Keys on the dashboard; the SDK does not read AMFS_API_KEY from the environment for you.
commitOutcomeAsync moved no confidence.
Pass causalEntryKeys — the entries the run relied on, as "entity/key" strings. The local ReadTracker cannot see reads made with the async methods.
Room calls fail with 401.
Known limitation of 0.3.2 — see the warning under Rooms & Collaboration above. Use the MCP server or the REST API for rooms in the meantime.
See also
- Connect to SenseLab — get an API key
- Python SDK
- MCP server — the same memory from Cursor, Claude Code and Codex
- REST API reference — every endpoint the adapter calls
- Instrument your agent — send steps, LLM calls and cost with every run over OpenTelemetry or HTTP
