@getmarrow/sdk 2.5.3 → 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.
package/README.md CHANGED
@@ -1,305 +1,246 @@
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.
8
12
 
9
- ---
10
-
11
- ## Install
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.
12
14
 
13
- ```bash
14
- npm install @getmarrow/sdk
15
- ```
16
-
17
- Get your API key at [getmarrow.ai](https://getmarrow.ai)
15
+ **Marrow turns agent memory from a passive log into an operating loop.**
18
16
 
19
17
  ---
20
18
 
21
- ## What's New in v2.4.0
22
-
23
- ### `agentPatterns()` — Failure patterns, recurring decisions, behavioral drift
24
-
25
- ```typescript
26
- const patterns = await marrow.agentPatterns({ type: 'implementation', limit: 10 });
27
-
28
- console.log(patterns.failurePatterns);
29
- // → [{ decisionType: "implementation", failureRate: 0.23, count: 12, lastSeen: "2026-03-28T..." }]
19
+ ## The Problem
30
20
 
31
- console.log(patterns.behavioralDrift);
32
- // { successRate7d: 0.91, successRate30d: 0.85, drift: "improving", direction: "up" }
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
33
27
 
34
- console.log(patterns.topFailureTypes);
35
- // ["timeout", "auth_error", "rate_limit"]
36
- ```
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
37
34
 
38
- ### `analytics()` — Health score and performance breakdown
39
-
40
- ```typescript
41
- const stats = await marrow.analytics();
35
+ ---
42
36
 
43
- console.log(stats.healthScore);
44
- // → { score: 87, label: "Healthy", breakdown: { successRate: 0.91, decisionVelocity: 42, patternDiscovery: 7, improvementTrend: "up" }, trend: "improving", vsLastWeek: "+5%" }
45
- ```
37
+ ## The Solution
46
38
 
47
- ### `think()` now returns `sanitized` and `upgradeHint`
39
+ Marrow gives you a simple SDK for decision memory and loop discipline.
48
40
 
49
- ```typescript
50
- const { sanitized, upgradeHint } = await marrow.think({
51
- action: 'Deploy production build',
52
- type: 'implementation',
53
- });
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
54
47
 
55
- console.log(sanitized);
56
- // → true (input was sanitized by Marrow)
48
+ That gives you a usable operating loop:
57
49
 
58
- console.log(upgradeHint);
59
- // { message: "Unlock pattern history with Pro", tier: "pro", url: "https://getmarrow.ai/upgrade" }
60
- // → undefined if no upgrade hint
50
+ ```text
51
+ orient -> think -> act -> check -> commit
61
52
  ```
62
53
 
63
- ---
64
-
65
- ## The Problem
66
-
67
- 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.
68
-
69
- **Marrow fixes this.**
54
+ Not just memory for memory’s sake —
55
+ memory that improves execution.
70
56
 
71
57
  ---
72
58
 
73
59
  ## How It Works
74
60
 
75
- 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.
61
+ ### 1. Orient
62
+ Start the session with context from prior decisions.
76
63
 
77
64
  ```typescript
78
- import { MarrowClient } from '@getmarrow/sdk';
79
-
80
- const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
81
-
82
- // ── Before your agent acts ──────────────────────────────────
83
- const { decisionId, intelligence } = await marrow.think({
84
- action: 'Summarizing user research findings and drafting report',
85
- type: 'implementation'
86
- });
87
-
88
- console.log(intelligence.similar);
89
- // → [{ outcome: "Used bullet points + TL;DR header. User engagement +40%.", confidence: 0.94 }]
90
- // ↑ What worked for other agents doing the same thing
65
+ await marrow.orient();
66
+ ```
91
67
 
92
- console.log(intelligence.successRate);
93
- // → 0.87
94
- // ↑ How agents like you are performing on this type of task
68
+ This gives the agent a cleaner starting point instead of acting cold.
95
69
 
96
- console.log(intelligence.patterns);
97
- // [{ patternId: "a1b2c3", decisionType: "implementation", frequency: 47, confidence: 0.9 }]
98
- // ↑ Patterns the hive has discovered across thousands of runs
70
+ ### 2. Think
71
+ Log intent before meaningful work.
99
72
 
100
- console.log(intelligence.insight);
101
- // "Workflow gap detected — audit missing after build"
102
- // Actionable intelligence from pattern engine
73
+ ```typescript
74
+ const decision = await marrow.think({
75
+ action: 'Deploy auth refactor to staging',
76
+ type: 'implementation',
77
+ });
78
+ ```
103
79
 
104
- console.log(intelligence.insights);
105
- // → [{ type: "workflow_gap", summary: "audit not logged after build", action: "Run audit", severity: "critical", count: 3 }]
106
- // ↑ Structured actionable insights: failure patterns, workflow gaps, hive trends
80
+ Now the work has a decision trail and Marrow can return relevant intelligence.
107
81
 
108
- console.log(intelligence.clusterId);
109
- // "818df2fa-6365-49f6-b478-bc3dcb748469"
110
- // ↑ Semantic cluster ID — similar actions grouped together
82
+ ### 3. Act
83
+ Do the actual work.
111
84
 
112
- // ── Your agent does its work ────────────────────────────────
113
- // (armed with collective intelligence from the hive)
85
+ For low-friction usage, wrap the action directly:
114
86
 
115
- // ── After your agent acts ───────────────────────────────────
116
- const next = await marrow.think({
117
- action: 'Next task',
118
- previousSuccess: true,
119
- previousOutcome: 'Report delivered. User approved on first pass, no revisions needed.'
120
- });
121
- // Auto-commits the previous session, opens a new one
122
- // The hive just got smarter from your agent's experience
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
+ );
123
97
  ```
124
98
 
125
- That's it. Two lines that transform your agent from amnesiac to experienced.
99
+ ### 4. Check
100
+ Inspect whether the loop is still open.
126
101
 
127
- ---
102
+ ```typescript
103
+ const state = marrow.check();
104
+ console.log(state.recommendedNext);
105
+ ```
128
106
 
129
- ## What Your Agent Gets Back
107
+ This is what tells the agent whether it’s actually ready to move on.
130
108
 
131
- Every `think()` call returns collective intelligence from the entire Marrow hive:
109
+ ### 5. Commit
110
+ Close the loop with outcome memory.
132
111
 
133
112
  ```typescript
134
- intelligence: {
135
- similar // What worked for other agents in this exact situation
136
- patterns // Patterns discovered across thousands of agent runs
137
- templates // Proven step-by-step playbooks for this action type
138
- shared // Knowledge other agents have explicitly shared
139
- causalChain // What sequence of decisions led to similar outcomes
140
- successRate // How well agents like yours are performing (0-1)
141
- priorityScore // How urgent/impactful this decision is
142
- }
113
+ await marrow.commit({
114
+ decision_id: decision.decision_id,
115
+ success: true,
116
+ outcome: 'Deployment passed smoke tests',
117
+ });
143
118
  ```
144
119
 
120
+ Now the next session doesn’t start from scratch.
121
+
145
122
  ---
146
123
 
147
- ## Real Examples
124
+ ## Why This Matters
148
125
 
149
- ### AI coding agent
150
- ```typescript
151
- const marrow = new MarrowClient(process.env.MARROW_API_KEY);
152
- let decisionId = null;
126
+ A normal memory system stores notes.
153
127
 
154
- async function beforeTask(description: string) {
155
- const { decisionId: id, intelligence } = await marrow.think({
156
- action: description,
157
- type: 'implementation',
158
- previousSuccess: lastTaskSucceeded,
159
- previousOutcome: lastTaskOutcome,
160
- });
161
- decisionId = id;
162
-
163
- // Use hive intelligence to guide the task
164
- if (intelligence.similar.length > 0) {
165
- console.log(`Similar task succeeded with: ${intelligence.similar[0].outcome}`);
166
- }
167
- return intelligence;
168
- }
169
- ```
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
170
133
 
171
- ### Research agent
172
- ```typescript
173
- const { intelligence } = await marrow.think({
174
- action: 'Analyzing competitor pricing strategy',
175
- type: 'architecture',
176
- });
134
+ That’s the difference between:
135
+ - an agent that “has memory”
136
+ - and an agent that actually **improves**
177
137
 
178
- // intelligence.templates gives you the proven research framework
179
- // other agents used for the same type of analysis
180
- const framework = intelligence.templates[0]?.steps;
181
- ```
138
+ ---
182
139
 
183
- ### Customer support agent
184
- ```typescript
185
- // Each ticket resolution feeds the hive
186
- const { intelligence } = await marrow.think({
187
- action: 'Resolving billing dispute — customer charged twice',
188
- type: 'process',
189
- previousSuccess: true,
190
- previousOutcome: 'Refund issued in 2 minutes. Customer gave 5-star rating.'
191
- });
140
+ ## Install
192
141
 
193
- // Next agent handling a similar dispute gets this outcome surfaced
194
- // intelligence.similar → "Issue refund immediately, explain in plain language. 5-star result."
142
+ ```bash
143
+ npm install @getmarrow/sdk
195
144
  ```
196
145
 
146
+ Get your API key at [getmarrow.ai](https://getmarrow.ai)
147
+
197
148
  ---
198
149
 
199
- ## API Reference
150
+ ## What's New in v2.5.4
200
151
 
201
- ### `marrow.think(params)`
152
+ ### Loop enforcement is live in the SDK
202
153
 
203
- **The core method.** Call before every agent action. Automatically commits your previous session if you pass `previousOutcome`.
154
+ Marrow now helps agents run a real operating loop, not just log isolated thoughts after the fact.
204
155
 
205
- | Param | Type | Description |
206
- |-------|------|-------------|
207
- | `action` | `string` | What your agent is about to do |
208
- | `type` | `string` | `'implementation'` \| `'security'` \| `'architecture'` \| `'process'` \| `'general'` |
209
- | `context` | `object` | Optional extra context to share with the hive |
210
- | `previousSuccess` | `boolean` | Did the last action succeed? |
211
- | `previousOutcome` | `string` | What happened — the hive learns from this |
212
- | `previousCausedBy` | `string` | Link to a prior decision for causal tracking |
156
+ You can now:
157
+ - start the session with `orient()`
158
+ - inspect loop state with `check()`
159
+ - enable enforcement with `enforce({ mode })`
160
+ - gate important work with `beforeAction()` / `afterAction()`
161
+ - wrap real actions with `wrap()` so intent/outcome stay connected
213
162
 
214
- **Returns:**
215
163
  ```typescript
216
- {
217
- decisionId: string // Pass back on next think() to auto-commit this one
218
- intelligence: {
219
- similar: Array<{ outcome: string, confidence: number }>
220
- patterns: Array<{ pattern: string, frequency: number }>
221
- templates: Array<{ steps: object[], success_rate: number }>
222
- shared: Array<{ outcome: string }>
223
- causalChain: object | null
224
- successRate: number
225
- priorityScore: number
226
- }
227
- streamUrl: string // Subscribe for live hive updates via SSE
228
- previousCommitted: boolean
229
- }
230
- ```
164
+ const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
231
165
 
232
- ### `marrow.commit(params)`
166
+ marrow.enforce({ mode: 'warn' });
233
167
 
234
- Explicit commit when you need more control. `think()` auto-commits on the next call, so this is optional.
168
+ await marrow.orient();
235
169
 
236
- ```typescript
237
- await marrow.commit({
238
- success: true,
239
- outcome: 'Task completed successfully — latency under 200ms',
240
- causedBy: previousDecisionId, // optional: link decisions causally
170
+ await marrow.think({
171
+ action: 'Deploy auth refactor to staging',
172
+ type: 'implementation',
241
173
  });
242
- ```
243
-
244
- ---
245
-
246
- ## Why Marrow?
247
-
248
- | Without Marrow | With Marrow |
249
- |---|---|
250
- | Agent starts from zero every session | Agent inherits collective intelligence from the hive |
251
- | Same mistakes repeated across runs | Patterns detected, failures don't repeat |
252
- | No visibility into agent performance | Real-time success rate, velocity, trend data |
253
- | Memory dies when context ends | Persistent memory that compounds forever |
254
- | Works for one model only | Claude, GPT, Gemini, Llama — any model |
255
174
 
256
- ---
175
+ await marrow.wrap(
176
+ {
177
+ action: 'Call deployment API',
178
+ type: 'implementation',
179
+ external: true,
180
+ result: 'Staging deploy succeeded',
181
+ },
182
+ async () => deployToStaging()
183
+ );
184
+
185
+ console.log(marrow.check().recommendedNext);
186
+ // → "done"
187
+ ```
257
188
 
258
- ## Get Started
189
+ ### Enforcement modes
259
190
 
260
- ```bash
261
- npm install @getmarrow/sdk
262
- ```
191
+ - `off` — track state without nudges or blocking
192
+ - `warn` — default; remind agents to close the loop without blocking work
193
+ - `require` — block important external actions until intent is logged
194
+ - `auto` — auto-log intent/outcome around wrapped actions
263
195
 
264
- 1. Get your API key at [getmarrow.ai](https://getmarrow.ai)
265
- 2. Add `marrow.think()` before your agent's first action
266
- 3. Pass `previousOutcome` on every subsequent call
267
- 4. Watch your agent's success rate climb
196
+ ### Also included in this release
268
197
 
269
- **Your agent gets smarter with every run. So does every other agent on the hive.**
198
+ - `think()` returns loop metadata alongside intelligence
199
+ - session-start guidance now nudges agents toward `marrow_think`
200
+ - `agentPatterns()` still surfaces failure patterns, recurring decisions, and behavioral drift
201
+ - `analytics()` still returns health score and performance breakdown
202
+ - `think()` still returns `sanitized` and `upgradeHint` when applicable
270
203
 
271
204
  ---
272
205
 
273
- *Works with Claude, GPT-4, Gemini, Llama, Mistral, and any model with a system prompt.*
206
+ ## Loop Enforcement
274
207
 
275
- ---
208
+ Marrow now helps agents actually close the loop instead of treating memory like decorative trim.
276
209
 
277
- ## Privacy & Data
210
+ ```typescript
211
+ const marrow = new MarrowClient(process.env.MARROW_API_KEY!);
278
212
 
279
- **What Marrow collects:**
280
- - The `action` string and `type` you pass to `think()` and `commit()`
281
- - The `outcome` you report — used to train collective intelligence
282
- - Decision metadata: timestamps, success/failure, confidence scores
213
+ marrow.enforce({ mode: 'warn' }); // default
283
214
 
284
- **What Marrow does NOT collect:**
285
- - No PII (names, emails, user IDs, IP addresses)
286
- - No conversation content or message history
287
- - No code, credentials, or file contents
288
- - No agent identity beyond your anonymous API key hash
215
+ await marrow.orient();
289
216
 
290
- **How data is anonymized:**
291
- - All inputs are stripped of PII patterns before storage (emails, phone numbers, UUIDs matching user ID formats, IP addresses)
292
- - Your API key is stored as a SHA-256 hash — never in plaintext
293
- - Hive intelligence is aggregated across agents — individual decisions are never exposed to other users
294
- - You can opt out of hive contribution at any time by setting `contributeToHive: false` in your client config
217
+ const intent = await marrow.think({
218
+ action: 'Deploy auth refactor to staging',
219
+ type: 'implementation',
220
+ });
295
221
 
296
- **Hive data model:**
297
- - Decisions you log contribute anonymously to collective patterns
298
- - No one can trace a pattern back to your agent or your account
299
- - Enterprise plans include private org hive mode — your data never leaves your org
222
+ await marrow.wrap(
223
+ { action: 'Call deployment API', type: 'implementation', external: true, result: 'Staging deploy succeeded' },
224
+ async () => deployToStaging()
225
+ );
300
226
 
301
- **Data retention:**
302
- - Decision data: 30 days on Free tier, 90 days on Pro, unlimited on Enterprise
303
- - You can delete all your data at any time via the dashboard or API
227
+ console.log(marrow.check().state.recommendedNext);
228
+ // "done"
229
+ ```
304
230
 
305
- For full details, see our [Privacy Policy](https://getmarrow.ai/privacy).
231
+ ### Modes
232
+ - `off` — no loop enforcement
233
+ - `warn` — non-blocking reminders, default
234
+ - `require` — throws before important external actions if intent is missing, and reminds on incomplete exits
235
+ - `auto` — auto-logs intent/outcome around wrapped actions
236
+
237
+ ### New SDK APIs
238
+ - `marrow.enforce({...})`
239
+ - `marrow.check()`
240
+ - `marrow.wrap(meta, fn)`
241
+ - `marrow.beforeAction(meta)`
242
+ - `marrow.afterAction(meta)`
243
+
244
+ ### Session start copy
245
+ - `Tip: log plans, decisions, and outcomes to Marrow so your agent improves over time.`
246
+ - `You have not logged any decisions yet this session. Before acting, call marrow_think.`
package/dist/index.d.ts CHANGED
@@ -5,80 +5,156 @@ export interface ActionableInsight {
5
5
  severity: 'info' | 'warning' | 'critical';
6
6
  count: number;
7
7
  }
8
+ export type MarrowDecisionType = 'implementation' | 'security' | 'architecture' | 'process' | 'general';
9
+ export type MarrowEnforcementMode = 'off' | 'warn' | 'require' | 'auto';
10
+ export type MarrowLoopRecommendation = 'orient' | 'think' | 'act' | 'commit' | 'done';
11
+ export interface MarrowLoopState {
12
+ mode: MarrowEnforcementMode;
13
+ orientedAt: string | null;
14
+ lastThinkAt: string | null;
15
+ lastOutcomeAt: string | null;
16
+ hasIntentLog: boolean;
17
+ hasOutcomeLog: boolean;
18
+ actionCountSinceLastThink: number;
19
+ externalActionCountSinceLastThink: number;
20
+ lastDecisionId: string | null;
21
+ pendingDecisionId: string | null;
22
+ pendingAction: string | null;
23
+ inFlightAction: string | null;
24
+ lastActionAt: string | null;
25
+ recommendedNext: MarrowLoopRecommendation;
26
+ loopState: 'idle' | 'oriented' | 'intent_logged' | 'acting' | 'outcome_logged';
27
+ message: string | null;
28
+ hints: string[];
29
+ }
30
+ export interface MarrowCheckResult {
31
+ ok: boolean;
32
+ mode: MarrowEnforcementMode;
33
+ state: MarrowLoopState;
34
+ warnings: string[];
35
+ recommendedNext: MarrowLoopRecommendation;
36
+ shouldBlock: boolean;
37
+ }
38
+ export interface MarrowEnforceOptions {
39
+ mode?: MarrowEnforcementMode;
40
+ remindEveryActions?: number;
41
+ externalActions?: string[];
42
+ classifyExternal?: (meta: MarrowActionMeta) => boolean;
43
+ }
44
+ export interface MarrowActionMeta {
45
+ action: string;
46
+ type?: MarrowDecisionType;
47
+ external?: boolean;
48
+ name?: string;
49
+ context?: Record<string, unknown>;
50
+ result?: string;
51
+ success?: boolean;
52
+ causedBy?: string;
53
+ skipAutoOutcome?: boolean;
54
+ }
55
+ export interface MarrowOrientResult {
56
+ warnings: Array<{
57
+ type: string;
58
+ failureRate: number;
59
+ message: string;
60
+ }>;
61
+ lessons: Array<{
62
+ summary: string;
63
+ severity: string;
64
+ }>;
65
+ shouldPause: boolean;
66
+ loop: MarrowCheckResult;
67
+ recommendedNext: MarrowLoopRecommendation;
68
+ nudge: string | null;
69
+ text: string;
70
+ }
71
+ export interface MarrowThinkResult {
72
+ decisionId: string;
73
+ intelligence: {
74
+ similar: Array<{
75
+ outcome: string;
76
+ confidence: number;
77
+ }>;
78
+ similarCount: number;
79
+ patterns: Array<{
80
+ patternId: string;
81
+ decisionType: string;
82
+ frequency: number;
83
+ confidence: number;
84
+ }>;
85
+ patternsCount: number;
86
+ templates: Array<{
87
+ steps: unknown[];
88
+ success_rate: number;
89
+ }>;
90
+ shared: Array<{
91
+ outcome: string;
92
+ }>;
93
+ causalChain: unknown | null;
94
+ successRate: number;
95
+ priorityScore: number;
96
+ insight: string | null;
97
+ insights: ActionableInsight[];
98
+ clusterId: string | null;
99
+ };
100
+ streamUrl: string;
101
+ previousCommitted?: boolean;
102
+ sanitized: boolean;
103
+ upgradeHint?: {
104
+ message: string;
105
+ tier: string;
106
+ url: string;
107
+ };
108
+ acceptedAs: 'intent';
109
+ warnings: string[];
110
+ recommendedNext: MarrowLoopRecommendation;
111
+ loop: MarrowCheckResult;
112
+ summary: string;
113
+ }
114
+ export interface MarrowCommitResult {
115
+ committed: boolean;
116
+ successRate: number;
117
+ insight: string | null;
118
+ acceptedAs: 'outcome';
119
+ recommendedNext: MarrowLoopRecommendation;
120
+ loop: MarrowCheckResult;
121
+ summary: string;
122
+ }
123
+ export declare class MarrowLoopRequiredError extends Error {
124
+ readonly code = "MARROW_LOOP_REQUIRED";
125
+ readonly state: MarrowLoopState;
126
+ constructor(message: string, state: MarrowLoopState);
127
+ }
8
128
  export declare class MarrowClient {
9
129
  private apiKey;
10
130
  private baseUrl;
11
131
  private decisionId;
12
132
  private orientWarnings;
133
+ private enforcement;
134
+ private loopState;
135
+ private reminderBudget;
13
136
  constructor(apiKey: string, baseUrl?: string);
137
+ enforce(options?: MarrowEnforceOptions): MarrowCheckResult;
138
+ check(): MarrowCheckResult;
139
+ beforeAction(meta: MarrowActionMeta): Promise<MarrowCheckResult>;
140
+ afterAction(meta: MarrowActionMeta): Promise<MarrowCheckResult>;
141
+ wrap<T>(meta: MarrowActionMeta, fn: () => Promise<T> | T): Promise<T>;
14
142
  think(params: {
15
143
  action: string;
16
- type?: 'implementation' | 'security' | 'architecture' | 'process' | 'general';
144
+ type?: MarrowDecisionType;
17
145
  context?: Record<string, unknown>;
18
146
  previousSuccess?: boolean;
19
147
  previousOutcome?: string;
20
148
  previousCausedBy?: string;
21
- }): Promise<{
22
- decisionId: string;
23
- intelligence: {
24
- similar: Array<{
25
- outcome: string;
26
- confidence: number;
27
- }>;
28
- similarCount: number;
29
- patterns: Array<{
30
- patternId: string;
31
- decisionType: string;
32
- frequency: number;
33
- confidence: number;
34
- }>;
35
- patternsCount: number;
36
- templates: Array<{
37
- steps: unknown[];
38
- success_rate: number;
39
- }>;
40
- shared: Array<{
41
- outcome: string;
42
- }>;
43
- causalChain: unknown | null;
44
- successRate: number;
45
- priorityScore: number;
46
- insight: string | null;
47
- insights: ActionableInsight[];
48
- clusterId: string | null;
49
- };
50
- streamUrl: string;
51
- previousCommitted?: boolean;
52
- sanitized: boolean;
53
- upgradeHint?: {
54
- message: string;
55
- tier: string;
56
- url: string;
57
- };
58
- }>;
149
+ }): Promise<MarrowThinkResult>;
59
150
  commit(params: {
60
151
  success: boolean;
61
152
  outcome: string;
62
153
  causedBy?: string;
63
- }): Promise<{
64
- committed: boolean;
65
- successRate: number;
66
- insight: string | null;
67
- }>;
154
+ }): Promise<MarrowCommitResult>;
68
155
  orient(params?: {
69
156
  taskType?: string;
70
- }): Promise<{
71
- warnings: Array<{
72
- type: string;
73
- failureRate: number;
74
- message: string;
75
- }>;
76
- lessons: Array<{
77
- summary: string;
78
- severity: string;
79
- }>;
80
- shouldPause: boolean;
81
- }>;
157
+ }): Promise<MarrowOrientResult>;
82
158
  agentPatterns(params?: {
83
159
  type?: string;
84
160
  limit?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,YAAY,CAAC;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,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M,CAAC;gBAAC,gBAAgB,EAAE,MAAM,CAAC;gBAAC,gBAAgB,EAAE,MAAM,CAAA;aAAE,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAC;QACnM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;YAeY,OAAO;CAatB;AAED,eAAe,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,25 +1,218 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarrowClient = void 0;
3
+ exports.MarrowClient = exports.MarrowLoopRequiredError = void 0;
4
+ class MarrowLoopRequiredError extends Error {
5
+ constructor(message, state) {
6
+ super(message);
7
+ this.code = 'MARROW_LOOP_REQUIRED';
8
+ this.name = 'MarrowLoopRequiredError';
9
+ this.state = state;
10
+ }
11
+ }
12
+ exports.MarrowLoopRequiredError = MarrowLoopRequiredError;
13
+ const DEFAULT_HINT = 'Tip: log plans, decisions, and outcomes to Marrow so your agent improves over time.';
14
+ const POST_ORIENT_NUDGE = 'You have not logged any decisions yet this session. Before acting, call marrow_think.';
15
+ const PRE_EXIT_REMINDER = 'Before ending the session, log the outcome to Marrow so the loop closes cleanly.';
16
+ const REQUIRE_EXTERNAL_ERROR = 'Marrow require mode: log intent with marrow.think() before external actions.';
17
+ const REQUIRE_COMPLETION_ERROR = 'Marrow require mode: log the outcome with marrow.commit() before completing the session.';
18
+ function nowIso() {
19
+ return new Date().toISOString();
20
+ }
21
+ function cloneState(state) {
22
+ return {
23
+ ...state,
24
+ hints: [...state.hints],
25
+ };
26
+ }
27
+ function safeErrorMessage(error) {
28
+ return error instanceof Error ? error.message : String(error);
29
+ }
4
30
  class MarrowClient {
5
31
  constructor(apiKey, baseUrl = 'https://api.getmarrow.ai') {
6
32
  this.apiKey = apiKey;
7
33
  this.baseUrl = baseUrl;
8
34
  this.decisionId = null;
9
35
  this.orientWarnings = [];
10
- // Best practice: key should come from env var, not hardcoded string literal.
11
- // Warn if it looks like a real key passed directly (not via process.env).
36
+ this.reminderBudget = {
37
+ noIntentHintShown: false,
38
+ outcomeReminderShown: false,
39
+ lastWarnedActionCount: -1,
40
+ };
12
41
  if (typeof process !== 'undefined' && apiKey && apiKey.startsWith('mrw_')) {
13
42
  const fromEnv = Object.values(process.env || {}).includes(apiKey);
14
43
  if (!fromEnv) {
15
44
  console.warn('[marrow] ⚠️ API key appears hardcoded. Use process.env.MARROW_API_KEY instead. See: https://getmarrow.ai/docs/security');
16
45
  }
17
46
  }
18
- // Auto-orient on init — runs silently, no await needed.
19
- // Warnings are cached and surfaced in the next think() call's intelligence.insights.
20
- this.orient().then(r => { this.orientWarnings = r.warnings; }).catch(() => { });
47
+ this.enforcement = {
48
+ mode: 'warn',
49
+ remindEveryActions: 3,
50
+ externalActions: ['http', 'fetch', 'api', 'deploy', 'publish', 'send', 'email', 'message', 'payment', 'write', 'delete', 'update', 'create'],
51
+ classifyExternal: (meta) => {
52
+ if (meta.external !== undefined)
53
+ return meta.external;
54
+ const haystack = `${meta.name || ''} ${meta.action}`.toLowerCase();
55
+ return this.enforcement.externalActions.some(keyword => haystack.includes(keyword));
56
+ },
57
+ };
58
+ this.loopState = {
59
+ mode: this.enforcement.mode,
60
+ orientedAt: null,
61
+ lastThinkAt: null,
62
+ lastOutcomeAt: null,
63
+ hasIntentLog: false,
64
+ hasOutcomeLog: false,
65
+ actionCountSinceLastThink: 0,
66
+ externalActionCountSinceLastThink: 0,
67
+ lastDecisionId: null,
68
+ pendingDecisionId: null,
69
+ pendingAction: null,
70
+ inFlightAction: null,
71
+ lastActionAt: null,
72
+ recommendedNext: 'orient',
73
+ loopState: 'idle',
74
+ message: DEFAULT_HINT,
75
+ hints: [DEFAULT_HINT],
76
+ };
77
+ }
78
+ enforce(options = {}) {
79
+ this.enforcement = {
80
+ ...this.enforcement,
81
+ ...options,
82
+ mode: options.mode || this.enforcement.mode,
83
+ remindEveryActions: options.remindEveryActions ?? this.enforcement.remindEveryActions,
84
+ externalActions: options.externalActions ?? this.enforcement.externalActions,
85
+ classifyExternal: options.classifyExternal ?? this.enforcement.classifyExternal,
86
+ };
87
+ this.loopState.mode = this.enforcement.mode;
88
+ return this.check();
89
+ }
90
+ check() {
91
+ const state = cloneState(this.loopState);
92
+ const warnings = [];
93
+ let shouldBlock = false;
94
+ if (state.mode === 'off') {
95
+ state.message = null;
96
+ state.hints = [];
97
+ return {
98
+ ok: true,
99
+ mode: state.mode,
100
+ state,
101
+ warnings: [],
102
+ recommendedNext: state.recommendedNext,
103
+ shouldBlock: false,
104
+ };
105
+ }
106
+ if (!state.orientedAt) {
107
+ warnings.push(DEFAULT_HINT);
108
+ state.recommendedNext = 'orient';
109
+ state.loopState = 'idle';
110
+ state.message = DEFAULT_HINT;
111
+ }
112
+ else if (state.hasOutcomeLog) {
113
+ state.recommendedNext = 'done';
114
+ state.loopState = 'outcome_logged';
115
+ state.message = 'Loop closed. Ready for the next task.';
116
+ }
117
+ else if (!state.hasIntentLog) {
118
+ warnings.push(POST_ORIENT_NUDGE);
119
+ state.recommendedNext = 'think';
120
+ state.loopState = 'oriented';
121
+ state.message = POST_ORIENT_NUDGE;
122
+ }
123
+ else if (state.hasIntentLog && !state.hasOutcomeLog && state.actionCountSinceLastThink > 0) {
124
+ state.recommendedNext = 'commit';
125
+ state.loopState = 'acting';
126
+ state.message = PRE_EXIT_REMINDER;
127
+ if (state.externalActionCountSinceLastThink > 0)
128
+ warnings.push(PRE_EXIT_REMINDER);
129
+ }
130
+ else if (state.hasIntentLog && !state.hasOutcomeLog) {
131
+ state.recommendedNext = 'act';
132
+ state.loopState = 'intent_logged';
133
+ state.message = 'Intent logged. Act, then log the outcome.';
134
+ }
135
+ else {
136
+ state.recommendedNext = state.hasOutcomeLog ? 'done' : 'act';
137
+ state.loopState = state.hasOutcomeLog ? 'outcome_logged' : 'intent_logged';
138
+ state.message = state.hasOutcomeLog ? 'Loop closed. Ready for the next task.' : state.message;
139
+ }
140
+ if (state.mode === 'require' && state.hasIntentLog && !state.hasOutcomeLog && state.externalActionCountSinceLastThink > 0) {
141
+ warnings.push(REQUIRE_COMPLETION_ERROR);
142
+ shouldBlock = true;
143
+ }
144
+ return {
145
+ ok: !shouldBlock,
146
+ mode: state.mode,
147
+ state,
148
+ warnings,
149
+ recommendedNext: state.recommendedNext,
150
+ shouldBlock,
151
+ };
152
+ }
153
+ async beforeAction(meta) {
154
+ const isExternal = this.enforcement.classifyExternal(meta);
155
+ const actionTime = nowIso();
156
+ if (this.enforcement.mode === 'auto' && !this.loopState.hasIntentLog) {
157
+ await this.think({
158
+ action: meta.action,
159
+ type: meta.type || 'general',
160
+ context: meta.context,
161
+ });
162
+ }
163
+ if (this.enforcement.mode === 'require' && isExternal && !this.loopState.hasIntentLog) {
164
+ throw new MarrowLoopRequiredError(REQUIRE_EXTERNAL_ERROR, cloneState(this.loopState));
165
+ }
166
+ this.loopState.lastActionAt = actionTime;
167
+ this.loopState.inFlightAction = meta.action;
168
+ this.loopState.actionCountSinceLastThink += 1;
169
+ if (isExternal)
170
+ this.loopState.externalActionCountSinceLastThink += 1;
171
+ if (this.enforcement.mode === 'off') {
172
+ return this.check();
173
+ }
174
+ const check = this.check();
175
+ const shouldWarn = this.enforcement.mode === 'warn'
176
+ && !this.loopState.hasIntentLog
177
+ && this.loopState.actionCountSinceLastThink >= this.enforcement.remindEveryActions
178
+ && this.reminderBudget.lastWarnedActionCount !== this.loopState.actionCountSinceLastThink;
179
+ if (shouldWarn) {
180
+ this.reminderBudget.lastWarnedActionCount = this.loopState.actionCountSinceLastThink;
181
+ check.warnings.push(POST_ORIENT_NUDGE);
182
+ }
183
+ return check;
184
+ }
185
+ async afterAction(meta) {
186
+ if (this.enforcement.mode === 'auto' && this.loopState.pendingDecisionId && !meta.skipAutoOutcome) {
187
+ await this.commit({
188
+ success: meta.success ?? true,
189
+ outcome: meta.result || 'Action completed',
190
+ causedBy: meta.causedBy,
191
+ });
192
+ }
193
+ this.loopState.inFlightAction = null;
194
+ return this.check();
195
+ }
196
+ async wrap(meta, fn) {
197
+ await this.beforeAction(meta);
198
+ try {
199
+ const result = await fn();
200
+ await this.afterAction({
201
+ ...meta,
202
+ success: meta.success ?? true,
203
+ result: meta.result || 'Action completed successfully',
204
+ });
205
+ return result;
206
+ }
207
+ catch (error) {
208
+ await this.afterAction({
209
+ ...meta,
210
+ success: false,
211
+ result: meta.result || safeErrorMessage(error),
212
+ });
213
+ throw error;
214
+ }
21
215
  }
22
- // PRIMARY METHOD — call before every agent action
23
216
  async think(params) {
24
217
  const body = {
25
218
  action: params.action,
@@ -36,7 +229,6 @@ class MarrowClient {
36
229
  const res = await this.request('POST', '/v1/agent/think', body);
37
230
  this.decisionId = res.decision_id;
38
231
  const intel = (res.intelligence || {});
39
- // Inject cached orient warnings into insights on first think() call
40
232
  if (this.orientWarnings.length > 0) {
41
233
  const existingInsights = intel.insights || [];
42
234
  intel.insights = [
@@ -49,36 +241,64 @@ class MarrowClient {
49
241
  })),
50
242
  ...existingInsights,
51
243
  ];
52
- this.orientWarnings = []; // clear after first think
244
+ this.orientWarnings = [];
53
245
  }
246
+ this.loopState.orientedAt = this.loopState.orientedAt || nowIso();
247
+ this.loopState.lastThinkAt = nowIso();
248
+ this.loopState.hasIntentLog = true;
249
+ this.loopState.hasOutcomeLog = false;
250
+ this.loopState.actionCountSinceLastThink = 0;
251
+ this.loopState.externalActionCountSinceLastThink = 0;
252
+ this.loopState.pendingDecisionId = this.decisionId;
253
+ this.loopState.lastDecisionId = this.decisionId;
254
+ this.loopState.pendingAction = params.action;
255
+ this.loopState.recommendedNext = 'act';
256
+ this.loopState.loopState = 'intent_logged';
257
+ this.loopState.message = 'Intent logged. Act, then log the outcome.';
258
+ this.loopState.hints = [this.loopState.message];
259
+ this.reminderBudget.noIntentHintShown = true;
260
+ this.reminderBudget.outcomeReminderShown = false;
261
+ this.reminderBudget.lastWarnedActionCount = -1;
262
+ const intelligence = {
263
+ similar: intel.similar || [],
264
+ similarCount: intel.similar_count || 0,
265
+ patterns: (intel.patterns || []).map(p => ({
266
+ patternId: (p.pattern_id || p.id || ''),
267
+ decisionType: (p.decision_type || ''),
268
+ frequency: (p.frequency || 0),
269
+ confidence: (p.confidence || 0),
270
+ })),
271
+ patternsCount: intel.patterns_count || 0,
272
+ templates: intel.templates || [],
273
+ shared: intel.shared || [],
274
+ causalChain: intel.causal_chain || null,
275
+ successRate: intel.success_rate || 0,
276
+ priorityScore: intel.priority_score || 0,
277
+ insight: intel.insight || null,
278
+ insights: intel.insights || [],
279
+ clusterId: intel.cluster_id || null,
280
+ };
281
+ const loop = this.check();
282
+ const warnings = [...loop.warnings];
283
+ const summary = [
284
+ 'Intent logged to Marrow.',
285
+ intelligence.insight ? `Pattern hint: ${intelligence.insight}` : intelligence.insights[0]?.summary ? `Pattern hint: ${intelligence.insights[0].summary}` : null,
286
+ `Recommended next step: ${loop.recommendedNext}.`,
287
+ ].filter(Boolean).join(' ');
54
288
  return {
55
289
  decisionId: res.decision_id,
56
- intelligence: {
57
- similar: intel.similar || [],
58
- similarCount: intel.similar_count || 0,
59
- patterns: (intel.patterns || []).map(p => ({
60
- patternId: (p.pattern_id || p.id || ''),
61
- decisionType: (p.decision_type || ''),
62
- frequency: (p.frequency || 0),
63
- confidence: (p.confidence || 0),
64
- })),
65
- patternsCount: intel.patterns_count || 0,
66
- templates: intel.templates || [],
67
- shared: intel.shared || [],
68
- causalChain: intel.causal_chain || null,
69
- successRate: intel.success_rate || 0,
70
- priorityScore: intel.priority_score || 0,
71
- insight: intel.insight || null,
72
- insights: intel.insights || [],
73
- clusterId: intel.cluster_id || null,
74
- },
290
+ intelligence,
75
291
  streamUrl: res.stream_url,
76
292
  previousCommitted: res.previous_committed,
77
293
  sanitized: Boolean(res.sanitized),
78
294
  upgradeHint: res.upgrade_hint ? res.upgrade_hint : undefined,
295
+ acceptedAs: 'intent',
296
+ warnings,
297
+ recommendedNext: loop.recommendedNext,
298
+ loop,
299
+ summary,
79
300
  };
80
301
  }
81
- // Explicit commit (optional — think() auto-commits on next call)
82
302
  async commit(params) {
83
303
  if (!this.decisionId)
84
304
  throw new Error('No active decision. Call think() first.');
@@ -89,15 +309,32 @@ class MarrowClient {
89
309
  caused_by: params.causedBy,
90
310
  });
91
311
  this.decisionId = null;
312
+ this.loopState.lastOutcomeAt = nowIso();
313
+ this.loopState.hasOutcomeLog = true;
314
+ this.loopState.hasIntentLog = false;
315
+ this.loopState.pendingDecisionId = null;
316
+ this.loopState.pendingAction = null;
317
+ this.loopState.recommendedNext = 'done';
318
+ this.loopState.loopState = 'outcome_logged';
319
+ this.loopState.message = 'Loop closed. Ready for the next task.';
320
+ this.loopState.hints = [this.loopState.message];
321
+ this.reminderBudget.outcomeReminderShown = true;
322
+ const loop = this.check();
323
+ const summary = [
324
+ 'Outcome logged to Marrow.',
325
+ res.insight ? `Pattern hint: ${String(res.insight)}` : null,
326
+ 'Loop closed.',
327
+ ].filter(Boolean).join(' ');
92
328
  return {
93
329
  committed: res.committed,
94
330
  successRate: res.success_rate,
95
331
  insight: res.insight,
332
+ acceptedAs: 'outcome',
333
+ recommendedNext: loop.recommendedNext,
334
+ loop,
335
+ summary,
96
336
  };
97
337
  }
98
- // Session orientation — call this FIRST at every session start before any action.
99
- // Returns failure patterns + lessons so agent avoids known mistakes immediately.
100
- // This is the method that makes Marrow compound — write-only = useless, orient() closes the loop.
101
338
  async orient(params) {
102
339
  const patterns = await this.agentPatterns(params?.taskType ? { type: params.taskType } : undefined);
103
340
  const warnings = patterns.failurePatterns
@@ -107,7 +344,6 @@ class MarrowClient {
107
344
  failureRate: p.failureRate,
108
345
  message: `${p.decisionType} has ${Math.round(p.failureRate * 100)}% failure rate over ${p.count} decisions — check lessons before proceeding`,
109
346
  }));
110
- // Pull recent lessons from think() logs
111
347
  let lessons = [];
112
348
  try {
113
349
  const res = await this.request('GET', `/v1/agent/think/history?type=lesson&limit=5`);
@@ -118,13 +354,30 @@ class MarrowClient {
118
354
  }));
119
355
  }
120
356
  catch { /* lessons endpoint optional */ }
357
+ this.loopState.orientedAt = nowIso();
358
+ this.loopState.recommendedNext = this.loopState.hasIntentLog ? 'act' : 'think';
359
+ this.loopState.loopState = this.loopState.hasIntentLog ? 'intent_logged' : 'oriented';
360
+ this.loopState.message = this.loopState.hasIntentLog ? 'Intent already logged. Proceed or log the outcome when done.' : POST_ORIENT_NUDGE;
361
+ this.loopState.hints = [DEFAULT_HINT, this.loopState.message];
362
+ const loop = this.check();
363
+ const nudge = this.loopState.hasIntentLog ? null : POST_ORIENT_NUDGE;
364
+ const text = [
365
+ DEFAULT_HINT,
366
+ nudge,
367
+ warnings[0]?.message ? `Warning: ${warnings[0].message}` : null,
368
+ lessons[0]?.summary ? `Recent lesson: ${lessons[0].summary}` : null,
369
+ `Recommended next step: ${loop.recommendedNext}.`,
370
+ ].filter(Boolean).join(' ');
121
371
  return {
122
372
  warnings,
123
373
  lessons,
124
374
  shouldPause: warnings.some(w => w.failureRate > 0.4),
375
+ loop,
376
+ recommendedNext: loop.recommendedNext,
377
+ nudge,
378
+ text,
125
379
  };
126
380
  }
127
- // Agent pattern analysis — failure patterns, recurring decisions, behavioral drift
128
381
  async agentPatterns(params) {
129
382
  const qs = new URLSearchParams();
130
383
  if (params?.type)
@@ -140,7 +393,6 @@ class MarrowClient {
140
393
  generatedAt: String(res.generated_at || ''),
141
394
  };
142
395
  }
143
- // Analytics — health score, trends, performance breakdown
144
396
  async analytics() {
145
397
  const res = await this.request('GET', '/v1/analytics');
146
398
  const hs = (res.health_score || {});
@@ -155,7 +407,6 @@ class MarrowClient {
155
407
  },
156
408
  };
157
409
  }
158
- // Raw request helper
159
410
  async request(method, path, body) {
160
411
  const res = await fetch(`${this.baseUrl}${path}`, {
161
412
  method,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAQA,MAAa,YAAY;IAKvB,YAAoB,MAAc,EAAU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AAE,MAAM,CAAC,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC;aAC1C;SACF,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY,EAAE,IAAc;QAChE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE;YAChD,MAAM;YACN,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACxC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD;YACD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC9C,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAuD,CAAC;QACnF,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF;AAlbD,oCAkbC;AAED,kBAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@getmarrow/sdk",
3
- "version": "2.5.3",
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",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node dist/index.js"
9
+ "test": "npm run build && node --test test/*.test.js",
10
+ "prepublishOnly": "npm test"
10
11
  },
11
12
  "keywords": [
12
13
  "ai",