@getmarrow/sdk 2.5.4 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +132 -245
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,139 @@
1
1
  # @getmarrow/sdk
2
2
 
3
- > **Your go-to memory provider for all agents, for any AI model.**
3
+ > **Memory and decision intelligence for agents that need to get better over time.**
4
4
 
5
- Marrow gives your AI agent a memory that compounds. Every decision your agent makes gets shared with the Marrow hive. Every other agent's experience flows back into yours. The more agents use Marrow, the smarter every single one of them gets.
5
+ Most agents still work like this:
6
+ - they plan something
7
+ - they do something
8
+ - they forget what happened
9
+ - then they repeat the same mistake next session
6
10
 
7
- **Your agent stops making the same mistakes. It learns from thousands of others — instantly.**
11
+ That’s fine for a toy. It’s a problem for anything real.
12
+
13
+ `@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.
14
+
15
+ **Marrow turns agent memory from a passive log into an operating loop.**
16
+
17
+ ---
18
+
19
+ ## The Problem
20
+
21
+ Without durable decision memory:
22
+ - agents repeat bad calls
23
+ - successful patterns get lost
24
+ - work gets marked “done” without outcome context
25
+ - external actions happen with no structured trail
26
+ - every new session wastes time rediscovering what already failed
27
+
28
+ A bigger context window doesn’t solve this.
29
+ You need a system that remembers:
30
+ - what the agent was trying to do
31
+ - what it actually did
32
+ - whether it worked
33
+ - what pattern that should teach the next attempt
34
+
35
+ ---
36
+
37
+ ## The Solution
38
+
39
+ Marrow gives you a simple SDK for decision memory and loop discipline.
40
+
41
+ With `@getmarrow/sdk`, your agent can:
42
+ - **orient** at session start
43
+ - **think** before meaningful action
44
+ - **check** whether the loop is still open
45
+ - **wrap** important actions so intent and outcome stay connected
46
+ - **commit** the result back into memory
47
+
48
+ That gives you a usable operating loop:
49
+
50
+ ```text
51
+ orient -> think -> act -> check -> commit
52
+ ```
53
+
54
+ Not just memory for memory’s sake —
55
+ memory that improves execution.
56
+
57
+ ---
58
+
59
+ ## How It Works
60
+
61
+ ### 1. Orient
62
+ Start the session with context from prior decisions.
63
+
64
+ ```typescript
65
+ await marrow.orient();
66
+ ```
67
+
68
+ This gives the agent a cleaner starting point instead of acting cold.
69
+
70
+ ### 2. Think
71
+ Log intent before meaningful work.
72
+
73
+ ```typescript
74
+ const decision = await marrow.think({
75
+ action: 'Deploy auth refactor to staging',
76
+ type: 'implementation',
77
+ });
78
+ ```
79
+
80
+ Now the work has a decision trail and Marrow can return relevant intelligence.
81
+
82
+ ### 3. Act
83
+ Do the actual work.
84
+
85
+ For low-friction usage, wrap the action directly:
86
+
87
+ ```typescript
88
+ await marrow.wrap(
89
+ {
90
+ action: 'Call deployment API',
91
+ type: 'implementation',
92
+ external: true,
93
+ result: 'Staging deploy succeeded',
94
+ },
95
+ async () => deployToStaging()
96
+ );
97
+ ```
98
+
99
+ ### 4. Check
100
+ Inspect whether the loop is still open.
101
+
102
+ ```typescript
103
+ const state = marrow.check();
104
+ console.log(state.recommendedNext);
105
+ ```
106
+
107
+ This is what tells the agent whether it’s actually ready to move on.
108
+
109
+ ### 5. Commit
110
+ Close the loop with outcome memory.
111
+
112
+ ```typescript
113
+ await marrow.commit({
114
+ decision_id: decision.decision_id,
115
+ success: true,
116
+ outcome: 'Deployment passed smoke tests',
117
+ });
118
+ ```
119
+
120
+ Now the next session doesn’t start from scratch.
121
+
122
+ ---
123
+
124
+ ## Why This Matters
125
+
126
+ A normal memory system stores notes.
127
+
128
+ Marrow stores **decision history**:
129
+ - what was attempted
130
+ - what happened
131
+ - what patterns are emerging
132
+ - what the agent should do better next time
133
+
134
+ That’s the difference between:
135
+ - an agent that “has memory”
136
+ - and an agent that actually **improves**
8
137
 
9
138
  ---
10
139
 
@@ -115,245 +244,3 @@ console.log(marrow.check().state.recommendedNext);
115
244
  ### Session start copy
116
245
  - `Tip: log plans, decisions, and outcomes to Marrow so your agent improves over time.`
117
246
  - `You have not logged any decisions yet this session. Before acting, call marrow_think.`
118
-
119
- ## The Problem
120
-
121
- Every AI agent starts from zero. No memory of what worked. No memory of what failed. Every session, your agent makes the same mistakes — because it has no way to learn from its own history, let alone anyone else's.
122
-
123
- **Marrow fixes this.**
124
-
125
- ---
126
-
127
- ## How It Works
128
-
129
- One call before your agent acts. One call when it's done. Marrow handles everything in between — querying collective intelligence from the hive, recording outcomes, detecting patterns, building your agent's memory over time.
130
-
131
- ```typescript
132
- import { MarrowClient } from '@getmarrow/sdk';
133
-
134
- const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
135
-
136
- // ── Before your agent acts ──────────────────────────────────
137
- const { decisionId, intelligence } = await marrow.think({
138
- action: 'Summarizing user research findings and drafting report',
139
- type: 'implementation'
140
- });
141
-
142
- console.log(intelligence.similar);
143
- // → [{ outcome: "Used bullet points + TL;DR header. User engagement +40%.", confidence: 0.94 }]
144
- // ↑ What worked for other agents doing the same thing
145
-
146
- console.log(intelligence.successRate);
147
- // → 0.87
148
- // ↑ How agents like you are performing on this type of task
149
-
150
- console.log(intelligence.patterns);
151
- // → [{ patternId: "a1b2c3", decisionType: "implementation", frequency: 47, confidence: 0.9 }]
152
- // ↑ Patterns the hive has discovered across thousands of runs
153
-
154
- console.log(intelligence.insight);
155
- // → "Workflow gap detected — audit missing after build"
156
- // ↑ Actionable intelligence from pattern engine
157
-
158
- console.log(intelligence.insights);
159
- // → [{ type: "workflow_gap", summary: "audit not logged after build", action: "Run audit", severity: "critical", count: 3 }]
160
- // ↑ Structured actionable insights: failure patterns, workflow gaps, hive trends
161
-
162
- console.log(intelligence.clusterId);
163
- // → "818df2fa-6365-49f6-b478-bc3dcb748469"
164
- // ↑ Semantic cluster ID — similar actions grouped together
165
-
166
- // ── Your agent does its work ────────────────────────────────
167
- // (armed with collective intelligence from the hive)
168
-
169
- // ── After your agent acts ───────────────────────────────────
170
- const next = await marrow.think({
171
- action: 'Next task',
172
- previousSuccess: true,
173
- previousOutcome: 'Report delivered. User approved on first pass, no revisions needed.'
174
- });
175
- // ↑ Auto-commits the previous session, opens a new one
176
- // The hive just got smarter from your agent's experience
177
- ```
178
-
179
- That's it. Two lines that transform your agent from amnesiac to experienced.
180
-
181
- ---
182
-
183
- ## What Your Agent Gets Back
184
-
185
- Every `think()` call returns collective intelligence from the entire Marrow hive:
186
-
187
- ```typescript
188
- intelligence: {
189
- similar // What worked for other agents in this exact situation
190
- patterns // Patterns discovered across thousands of agent runs
191
- templates // Proven step-by-step playbooks for this action type
192
- shared // Knowledge other agents have explicitly shared
193
- causalChain // What sequence of decisions led to similar outcomes
194
- successRate // How well agents like yours are performing (0-1)
195
- priorityScore // How urgent/impactful this decision is
196
- }
197
- ```
198
-
199
- ---
200
-
201
- ## Real Examples
202
-
203
- ### AI coding agent
204
- ```typescript
205
- const marrow = new MarrowClient(process.env.MARROW_API_KEY);
206
- let decisionId = null;
207
-
208
- async function beforeTask(description: string) {
209
- const { decisionId: id, intelligence } = await marrow.think({
210
- action: description,
211
- type: 'implementation',
212
- previousSuccess: lastTaskSucceeded,
213
- previousOutcome: lastTaskOutcome,
214
- });
215
- decisionId = id;
216
-
217
- // Use hive intelligence to guide the task
218
- if (intelligence.similar.length > 0) {
219
- console.log(`Similar task succeeded with: ${intelligence.similar[0].outcome}`);
220
- }
221
- return intelligence;
222
- }
223
- ```
224
-
225
- ### Research agent
226
- ```typescript
227
- const { intelligence } = await marrow.think({
228
- action: 'Analyzing competitor pricing strategy',
229
- type: 'architecture',
230
- });
231
-
232
- // intelligence.templates gives you the proven research framework
233
- // other agents used for the same type of analysis
234
- const framework = intelligence.templates[0]?.steps;
235
- ```
236
-
237
- ### Customer support agent
238
- ```typescript
239
- // Each ticket resolution feeds the hive
240
- const { intelligence } = await marrow.think({
241
- action: 'Resolving billing dispute — customer charged twice',
242
- type: 'process',
243
- previousSuccess: true,
244
- previousOutcome: 'Refund issued in 2 minutes. Customer gave 5-star rating.'
245
- });
246
-
247
- // Next agent handling a similar dispute gets this outcome surfaced
248
- // intelligence.similar → "Issue refund immediately, explain in plain language. 5-star result."
249
- ```
250
-
251
- ---
252
-
253
- ## API Reference
254
-
255
- ### `marrow.think(params)`
256
-
257
- **The core method.** Call before every agent action. Automatically commits your previous session if you pass `previousOutcome`.
258
-
259
- | Param | Type | Description |
260
- |-------|------|-------------|
261
- | `action` | `string` | What your agent is about to do |
262
- | `type` | `string` | `'implementation'` \| `'security'` \| `'architecture'` \| `'process'` \| `'general'` |
263
- | `context` | `object` | Optional extra context to share with the hive |
264
- | `previousSuccess` | `boolean` | Did the last action succeed? |
265
- | `previousOutcome` | `string` | What happened — the hive learns from this |
266
- | `previousCausedBy` | `string` | Link to a prior decision for causal tracking |
267
-
268
- **Returns:**
269
- ```typescript
270
- {
271
- decisionId: string // Pass back on next think() to auto-commit this one
272
- intelligence: {
273
- similar: Array<{ outcome: string, confidence: number }>
274
- patterns: Array<{ pattern: string, frequency: number }>
275
- templates: Array<{ steps: object[], success_rate: number }>
276
- shared: Array<{ outcome: string }>
277
- causalChain: object | null
278
- successRate: number
279
- priorityScore: number
280
- }
281
- streamUrl: string // Subscribe for live hive updates via SSE
282
- previousCommitted: boolean
283
- }
284
- ```
285
-
286
- ### `marrow.commit(params)`
287
-
288
- Explicit commit when you need more control. `think()` auto-commits on the next call, so this is optional.
289
-
290
- ```typescript
291
- await marrow.commit({
292
- success: true,
293
- outcome: 'Task completed successfully — latency under 200ms',
294
- causedBy: previousDecisionId, // optional: link decisions causally
295
- });
296
- ```
297
-
298
- ---
299
-
300
- ## Why Marrow?
301
-
302
- | Without Marrow | With Marrow |
303
- |---|---|
304
- | Agent starts from zero every session | Agent inherits collective intelligence from the hive |
305
- | Same mistakes repeated across runs | Patterns detected, failures don't repeat |
306
- | No visibility into agent performance | Real-time success rate, velocity, trend data |
307
- | Memory dies when context ends | Persistent memory that compounds forever |
308
- | Works for one model only | Claude, GPT, Gemini, Llama — any model |
309
-
310
- ---
311
-
312
- ## Get Started
313
-
314
- ```bash
315
- npm install @getmarrow/sdk
316
- ```
317
-
318
- 1. Get your API key at [getmarrow.ai](https://getmarrow.ai)
319
- 2. Add `marrow.think()` before your agent's first action
320
- 3. Pass `previousOutcome` on every subsequent call
321
- 4. Watch your agent's success rate climb
322
-
323
- **Your agent gets smarter with every run. So does every other agent on the hive.**
324
-
325
- ---
326
-
327
- *Works with Claude, GPT-4, Gemini, Llama, Mistral, and any model with a system prompt.*
328
-
329
- ---
330
-
331
- ## Privacy & Data
332
-
333
- **What Marrow collects:**
334
- - The `action` string and `type` you pass to `think()` and `commit()`
335
- - The `outcome` you report — used to train collective intelligence
336
- - Decision metadata: timestamps, success/failure, confidence scores
337
-
338
- **What Marrow does NOT collect:**
339
- - No PII (names, emails, user IDs, IP addresses)
340
- - No conversation content or message history
341
- - No code, credentials, or file contents
342
- - No agent identity beyond your anonymous API key hash
343
-
344
- **How data is anonymized:**
345
- - All inputs are stripped of PII patterns before storage (emails, phone numbers, UUIDs matching user ID formats, IP addresses)
346
- - Your API key is stored as a SHA-256 hash — never in plaintext
347
- - Hive intelligence is aggregated across agents — individual decisions are never exposed to other users
348
- - You can opt out of hive contribution at any time by setting `contributeToHive: false` in your client config
349
-
350
- **Hive data model:**
351
- - Decisions you log contribute anonymously to collective patterns
352
- - No one can trace a pattern back to your agent or your account
353
- - Enterprise plans include private org hive mode — your data never leaves your org
354
-
355
- **Data retention:**
356
- - Decision data: 30 days on Free tier, 90 days on Pro, unlimited on Enterprise
357
- - You can delete all your data at any time via the dashboard or API
358
-
359
- For full details, see our [Privacy Policy](https://getmarrow.ai/privacy).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getmarrow/sdk",
3
- "version": "2.5.4",
3
+ "version": "2.5.5",
4
4
  "description": "Your go-to memory provider for all agents, for any AI model.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",