Package Exports
- @getmarrow/sdk
- @getmarrow/sdk/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@getmarrow/sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@getmarrow/sdk
Memory and decision intelligence for agents that need to get better over time.
Most agents still work like this:
- they plan something
- they do something
- they forget what happened
- then they repeat the same mistake next session
That's fine for a toy. It's a problem for anything real.
@getmarrow/sdk gives your agent a memory that compounds. It lets you log intent before meaningful work, pull back useful decision intelligence, and commit the outcome afterward so the next run starts smarter instead of blank.
Marrow turns agent memory from a passive log into an operating loop.
What's New in v2.7.0
marrow.run()— single-call wrapper. Auto-orients, thinks, runs your function, commits outcome. Zero ceremony.marrowFromEnv()— create client from env vars, defaults tomode: 'auto'createMarrowClient()— clean factory export- Session identity — pass
sessionIdto tag all requests withX-Marrow-Session-Id - Auto mode — set
mode: 'auto'and Marrow handles orient + think + commit around your actions
The Problem
Without durable decision memory:
- agents repeat bad calls
- successful patterns get lost
- work gets marked "done" without outcome context
- external actions happen with no structured trail
- every new session wastes time rediscovering what already failed
A bigger context window doesn't solve this. You need a system that remembers:
- what the agent was trying to do
- what it actually did
- whether it worked
- what pattern that should teach the next attempt
The Solution
Marrow gives you a simple SDK for decision memory and loop discipline.
With @getmarrow/sdk, your agent can:
- orient at session start
- think before meaningful action
- check whether the loop is still open
- wrap important actions so intent and outcome stay connected
- commit the result back into memory
That gives you a usable operating loop:
orient -> think -> act -> check -> commitNot just memory for memory's sake — memory that improves execution.
Install
npm install @getmarrow/sdkGet your API key at getmarrow.ai
Quick Start
import { createMarrowClient } from '@getmarrow/sdk';
const marrow = createMarrowClient(process.env.MARROW_API_KEY!);
await marrow.orient();
await marrow.think({ action: 'deploy to production', type: 'deployment' });
await deployToProduction();
await marrow.commit({ success: true, outcome: 'Deployed v2.7.0 — 0 errors' });Zero-Ceremony Mode
The simplest integration — one call handles everything:
import { marrowFromEnv } from '@getmarrow/sdk';
const marrow = marrowFromEnv(); // reads MARROW_API_KEY, defaults to auto mode
await marrow.run('deploy to production', async () => {
await deployToProduction();
});
// orient + think + commit fire automaticallyHow It Works
1. Orient
Start the session with context from prior decisions.
await marrow.orient();This gives the agent a cleaner starting point instead of acting cold.
2. Think
Log intent before meaningful work.
const decision = await marrow.think({
action: 'Deploy auth refactor to staging',
type: 'implementation',
});Now the work has a decision trail and Marrow can return relevant intelligence.
3. Act
Do the actual work.
For low-friction usage, wrap the action directly:
await marrow.wrap(
{
action: 'Call deployment API',
type: 'implementation',
external: true,
result: 'Staging deploy succeeded',
},
async () => deployToStaging()
);4. Check
Inspect whether the loop is still open.
const state = marrow.check();
console.log(state.recommendedNext);This is what tells the agent whether it's actually ready to move on.
5. Commit
Close the loop with outcome memory.
await marrow.commit({
decision_id: decision.decision_id,
success: true,
outcome: 'Deployment passed smoke tests',
});Now the next session doesn't start from scratch.
Creating a Client
Factory (recommended)
import { createMarrowClient } from '@getmarrow/sdk';
const marrow = createMarrowClient('mrw_...', {
sessionId: 'my-agent-run-42', // optional — sent as X-Marrow-Session-Id header
mode: 'warn', // optional — off | warn | require | auto
});From environment variables
import { marrowFromEnv } from '@getmarrow/sdk';
// Reads MARROW_API_KEY (required) and MARROW_BASE_URL (optional)
// Defaults to mode: 'auto'
const marrow = marrowFromEnv({ sessionId: 'my-agent-run-42' });Direct constructor
import MarrowClient from '@getmarrow/sdk';
const marrow = new MarrowClient('mrw_...', { baseUrl: '...', sessionId: '...', mode: 'warn' });Why This Matters
A normal memory system stores notes.
Marrow stores decision history:
- what was attempted
- what happened
- what patterns are emerging
- what the agent should do better next time
That's the difference between:
- an agent that "has memory"
- and an agent that actually improves
Privacy, Sanitization, and Data Ownership
Marrow is designed to be useful without treating user data casually.
Key trust properties:
- sensitive inputs can be sanitized before storage when possible
- privacy-preserving pattern learning matters more than hoarding raw user data
- API keys should be passed through environment variables, not hardcoded in source
- the product direction is anonymized learning, not leaking raw private context across agents
- users should be able to export and own their memory data instead of feeling trapped inside a black box
In plain English:
- Marrow should help agents learn from patterns
- while minimizing unnecessary exposure of personal or sensitive information
What's New in v2.5.4
Loop enforcement is live in the SDK
Marrow now helps agents run a real operating loop, not just log isolated thoughts after the fact.
You can now:
- start the session with
orient() - inspect loop state with
check() - enable enforcement with
enforce({ mode }) - gate important work with
beforeAction()/afterAction() - wrap real actions with
wrap()so intent/outcome stay connected
const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
marrow.enforce({ mode: 'warn' });
await marrow.orient();
await marrow.think({
action: 'Deploy auth refactor to staging',
type: 'implementation',
});
await marrow.wrap(
{
action: 'Call deployment API',
type: 'implementation',
external: true,
result: 'Staging deploy succeeded',
},
async () => deployToStaging()
);
console.log(marrow.check().recommendedNext);
// → "done"Enforcement modes
off— track state without nudges or blockingwarn— default; remind agents to close the loop without blocking workrequire— block important external actions until intent is loggedauto— auto-log intent/outcome around wrapped actions
Also included in this release
think()returns loop metadata alongside intelligence- session-start guidance now nudges agents toward
marrow_think agentPatterns()still surfaces failure patterns, recurring decisions, and behavioral driftanalytics()still returns health score and performance breakdownthink()still returnssanitizedandupgradeHintwhen applicable
Loop Enforcement
Marrow now helps agents actually close the loop instead of treating memory like decorative trim.
const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
marrow.enforce({ mode: 'warn' }); // default
await marrow.orient();
const intent = await marrow.think({
action: 'Deploy auth refactor to staging',
type: 'implementation',
});
await marrow.wrap(
{ action: 'Call deployment API', type: 'implementation', external: true, result: 'Staging deploy succeeded' },
async () => deployToStaging()
);
console.log(marrow.check().state.recommendedNext);
// → "done"Modes
off— no loop enforcementwarn— non-blocking reminders, defaultrequire— throws before important external actions if intent is missing, and reminds on incomplete exitsauto— auto-logs intent/outcome around wrapped actions
New SDK APIs
marrow.enforce({...})marrow.check()marrow.wrap(meta, fn)marrow.beforeAction(meta)marrow.afterAction(meta)
Session start copy
Tip: log plans, decisions, and outcomes to Marrow so your agent improves over time.You have not logged any decisions yet this session. Before acting, call marrow_think.
API Reference
Exports
| Export | Description |
|---|---|
MarrowClient |
Main client class |
createMarrowClient(apiKey, options?) |
Factory — creates a MarrowClient |
marrowFromEnv(options?) |
Creates client from MARROW_API_KEY / MARROW_BASE_URL env vars (auto mode default) |
MarrowLoopRequiredError |
Thrown in require mode when loop is violated |
MarrowClient Methods
| Method | Description |
|---|---|
run(description, fn, options?) |
Zero-ceremony wrapper: orient + think + fn + commit |
orient(params?) |
Start session with context from prior decisions |
think(params) |
Log intent, get intelligence |
commit(params) |
Close the loop with outcome |
check() |
Inspect current loop state |
enforce(options?) |
Set enforcement mode |
wrap(meta, fn) |
Wrap an action with intent/outcome tracking |
beforeAction(meta) |
Pre-action enforcement check |
afterAction(meta) |
Post-action state update |
wrapPublish(action, fn) |
Wrap a publish action |
wrapDeploy(action, fn) |
Wrap a deploy action |
wrapExternalWrite(action, fn) |
Wrap an external write |
wrapHandoff(action, fn) |
Wrap a handoff |
agentPatterns(params?) |
Get failure patterns and behavioral drift |
analytics() |
Get health score and performance breakdown |