@getmarrow/sdk 2.2.0

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 ADDED
@@ -0,0 +1,69 @@
1
+ # @getmarrow/sdk
2
+
3
+ **Your go-to memory provider for all agents, for any AI model.**
4
+
5
+ Every decision your agent makes compounds into the Marrow hive. Every agent using Marrow makes yours smarter.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @getmarrow/sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { MarrowClient } from '@getmarrow/sdk';
17
+
18
+ const marrow = new MarrowClient('mrw_your_key');
19
+
20
+ let decisionId = null;
21
+
22
+ // Before every action — ask the hive
23
+ const { decisionId: id, intelligence } = await marrow.think({
24
+ action: 'deploying auth system',
25
+ type: 'implementation',
26
+ // Auto-commits previous action:
27
+ previousSuccess: true,
28
+ previousOutcome: 'Last deploy succeeded, 0 errors'
29
+ });
30
+
31
+ decisionId = id;
32
+
33
+ // intelligence.similar → what worked before in the hive
34
+ // intelligence.patterns → patterns the hive has discovered
35
+ // intelligence.successRate → how you're doing vs other agents
36
+ // intelligence.templates → proven playbooks
37
+
38
+ // ... your agent acts ...
39
+
40
+ // Next think() auto-commits this one
41
+ ```
42
+
43
+ ## API
44
+
45
+ ### `marrow.think(params)` — primary method
46
+
47
+ ```typescript
48
+ const { decisionId, intelligence } = await marrow.think({
49
+ action: string,
50
+ type?: 'implementation' | 'security' | 'architecture' | 'process' | 'general',
51
+ context?: Record<string, unknown>,
52
+ previousSuccess?: boolean,
53
+ previousOutcome?: string,
54
+ });
55
+ ```
56
+
57
+ ### `marrow.commit(params)` — explicit commit (optional)
58
+
59
+ ```typescript
60
+ await marrow.commit({
61
+ success: boolean,
62
+ outcome: string,
63
+ causedBy?: string,
64
+ });
65
+ ```
66
+
67
+ ## Get a Key
68
+
69
+ [portal.getmarrow.ai](https://portal.getmarrow.ai)
@@ -0,0 +1,50 @@
1
+ export declare class MarrowClient {
2
+ private apiKey;
3
+ private baseUrl;
4
+ private decisionId;
5
+ constructor(apiKey: string, baseUrl?: string);
6
+ think(params: {
7
+ action: string;
8
+ type?: 'implementation' | 'security' | 'architecture' | 'process' | 'general';
9
+ context?: Record<string, unknown>;
10
+ previousSuccess?: boolean;
11
+ previousOutcome?: string;
12
+ previousCausedBy?: string;
13
+ }): Promise<{
14
+ decisionId: string;
15
+ intelligence: {
16
+ similar: Array<{
17
+ outcome: string;
18
+ confidence: number;
19
+ }>;
20
+ patterns: Array<{
21
+ pattern: string;
22
+ frequency: number;
23
+ }>;
24
+ templates: Array<{
25
+ steps: unknown[];
26
+ success_rate: number;
27
+ }>;
28
+ shared: Array<{
29
+ outcome: string;
30
+ }>;
31
+ causalChain: unknown | null;
32
+ successRate: number;
33
+ priorityScore: number;
34
+ };
35
+ streamUrl: string;
36
+ previousCommitted?: boolean;
37
+ }>;
38
+ commit(params: {
39
+ success: boolean;
40
+ outcome: string;
41
+ causedBy?: string;
42
+ }): Promise<{
43
+ committed: boolean;
44
+ successRate: number;
45
+ insight: string | null;
46
+ }>;
47
+ private request;
48
+ }
49
+ export default MarrowClient;
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IAGX,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IAFnD,OAAO,CAAC,UAAU,CAAuB;gBAErB,MAAM,EAAE,MAAM,EAAU,OAAO,SAA6B;IAG1E,KAAK,CAAC,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;QAC9E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAElC,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,GAAG,OAAO,CAAC;QACV,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE;YACZ,OAAO,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YACxD,QAAQ,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YACxD,SAAS,EAAE,KAAK,CAAC;gBAAE,KAAK,EAAE,OAAO,EAAE,CAAC;gBAAC,YAAY,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YAC7D,MAAM,EAAE,KAAK,CAAC;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;YACnC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;YAC5B,WAAW,EAAE,MAAM,CAAC;YACpB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;QACF,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,CAAC;IA+BI,MAAM,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;YAiBlE,OAAO;CAatB;AAED,eAAe,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MarrowClient = void 0;
4
+ class MarrowClient {
5
+ constructor(apiKey, baseUrl = 'https://api.getmarrow.ai') {
6
+ this.apiKey = apiKey;
7
+ this.baseUrl = baseUrl;
8
+ this.decisionId = null;
9
+ }
10
+ // PRIMARY METHOD — call before every agent action
11
+ async think(params) {
12
+ const body = {
13
+ action: params.action,
14
+ type: params.type || 'general',
15
+ context: params.context,
16
+ };
17
+ if (this.decisionId) {
18
+ body.previous_decision_id = this.decisionId;
19
+ body.previous_success = params.previousSuccess ?? true;
20
+ body.previous_outcome = params.previousOutcome ?? '';
21
+ if (params.previousCausedBy)
22
+ body.previous_caused_by = params.previousCausedBy;
23
+ }
24
+ const res = await this.request('POST', '/v1/agent/think', body);
25
+ this.decisionId = res.decision_id;
26
+ return {
27
+ decisionId: res.decision_id,
28
+ intelligence: {
29
+ similar: res.intelligence?.similar || [],
30
+ patterns: res.intelligence?.patterns || [],
31
+ templates: res.intelligence?.templates || [],
32
+ shared: res.intelligence?.shared || [],
33
+ causalChain: res.intelligence?.causal_chain || null,
34
+ successRate: res.intelligence?.success_rate || 0,
35
+ priorityScore: res.intelligence?.priority_score || 0,
36
+ },
37
+ streamUrl: res.stream_url,
38
+ previousCommitted: res.previous_committed,
39
+ };
40
+ }
41
+ // Explicit commit (optional — think() auto-commits on next call)
42
+ async commit(params) {
43
+ if (!this.decisionId)
44
+ throw new Error('No active decision. Call think() first.');
45
+ const res = await this.request('POST', '/v1/agent/commit', {
46
+ decision_id: this.decisionId,
47
+ success: params.success,
48
+ outcome: params.outcome,
49
+ caused_by: params.causedBy,
50
+ });
51
+ this.decisionId = null;
52
+ return {
53
+ committed: res.committed,
54
+ successRate: res.success_rate,
55
+ insight: res.insight,
56
+ };
57
+ }
58
+ // Raw request helper
59
+ async request(method, path, body) {
60
+ const res = await fetch(`${this.baseUrl}${path}`, {
61
+ method,
62
+ headers: {
63
+ 'Authorization': `Bearer ${this.apiKey}`,
64
+ 'Content-Type': 'application/json',
65
+ },
66
+ body: body ? JSON.stringify(body) : undefined,
67
+ });
68
+ const json = await res.json();
69
+ if (json.error)
70
+ throw new Error(json.error);
71
+ return json.data;
72
+ }
73
+ }
74
+ exports.MarrowClient = MarrowClient;
75
+ exports.default = MarrowClient;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IAGvB,YAAoB,MAAc,EAAU,UAAU,0BAA0B;QAA5D,WAAM,GAAN,MAAM,CAAQ;QAAU,YAAO,GAAP,OAAO,CAA6B;QAFxE,eAAU,GAAkB,IAAI,CAAC;IAE0C,CAAC;IAEpF,kDAAkD;IAClD,KAAK,CAAC,KAAK,CAAC,MAQX;QAcC,MAAM,IAAI,GAA4B;YACpC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS;YAC9B,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;QACF,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,UAAU,CAAC;YAC5C,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;YACvD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;YACrD,IAAI,MAAM,CAAC,gBAAgB;gBAAE,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QACjF,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,WAAqB,CAAC;QAC5C,OAAO;YACL,UAAU,EAAE,GAAG,CAAC,WAAqB;YACrC,YAAY,EAAE;gBACZ,OAAO,EAAG,GAAG,CAAC,YAAwC,EAAE,OAAyD,IAAI,EAAE;gBACvH,QAAQ,EAAG,GAAG,CAAC,YAAwC,EAAE,Q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AAI,CAAC,MAAM,EAAE;gBACxC,cAAc,EAAE,kBAAkB;aACnC;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;AA5FD,oCA4FC;AAED,kBAAe,YAAY,CAAC"}
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@getmarrow/sdk",
3
+ "version": "2.2.0",
4
+ "description": "Your go-to memory provider for all agents, for any AI model.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "node dist/index.js"
10
+ },
11
+ "keywords": [
12
+ "ai",
13
+ "agents",
14
+ "memory",
15
+ "hive",
16
+ "collective-intelligence"
17
+ ],
18
+ "license": "MIT"
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,95 @@
1
+ export class MarrowClient {
2
+ private decisionId: string | null = null;
3
+
4
+ constructor(private apiKey: string, private baseUrl = 'https://api.getmarrow.ai') {}
5
+
6
+ // PRIMARY METHOD — call before every agent action
7
+ async think(params: {
8
+ action: string;
9
+ type?: 'implementation' | 'security' | 'architecture' | 'process' | 'general';
10
+ context?: Record<string, unknown>;
11
+ // Previous session (auto-commits it):
12
+ previousSuccess?: boolean;
13
+ previousOutcome?: string;
14
+ previousCausedBy?: string;
15
+ }): Promise<{
16
+ decisionId: string;
17
+ intelligence: {
18
+ similar: Array<{ outcome: string; confidence: number }>;
19
+ patterns: Array<{ pattern: string; frequency: number }>;
20
+ templates: Array<{ steps: unknown[]; success_rate: number }>;
21
+ shared: Array<{ outcome: string }>;
22
+ causalChain: unknown | null;
23
+ successRate: number;
24
+ priorityScore: number;
25
+ };
26
+ streamUrl: string;
27
+ previousCommitted?: boolean;
28
+ }> {
29
+ const body: Record<string, unknown> = {
30
+ action: params.action,
31
+ type: params.type || 'general',
32
+ context: params.context,
33
+ };
34
+ if (this.decisionId) {
35
+ body.previous_decision_id = this.decisionId;
36
+ body.previous_success = params.previousSuccess ?? true;
37
+ body.previous_outcome = params.previousOutcome ?? '';
38
+ if (params.previousCausedBy) body.previous_caused_by = params.previousCausedBy;
39
+ }
40
+ const res = await this.request('POST', '/v1/agent/think', body);
41
+ this.decisionId = res.decision_id as string;
42
+ return {
43
+ decisionId: res.decision_id as string,
44
+ intelligence: {
45
+ similar: (res.intelligence as Record<string, unknown>)?.similar as Array<{ outcome: string; confidence: number }> || [],
46
+ patterns: (res.intelligence as Record<string, unknown>)?.patterns as Array<{ pattern: string; frequency: number }> || [],
47
+ templates: (res.intelligence as Record<string, unknown>)?.templates as Array<{ steps: unknown[]; success_rate: number }> || [],
48
+ shared: (res.intelligence as Record<string, unknown>)?.shared as Array<{ outcome: string }> || [],
49
+ causalChain: (res.intelligence as Record<string, unknown>)?.causal_chain || null,
50
+ successRate: (res.intelligence as Record<string, unknown>)?.success_rate as number || 0,
51
+ priorityScore: (res.intelligence as Record<string, unknown>)?.priority_score as number || 0,
52
+ },
53
+ streamUrl: res.stream_url as string,
54
+ previousCommitted: res.previous_committed as boolean | undefined,
55
+ };
56
+ }
57
+
58
+ // Explicit commit (optional — think() auto-commits on next call)
59
+ async commit(params: {
60
+ success: boolean;
61
+ outcome: string;
62
+ causedBy?: string;
63
+ }): Promise<{ committed: boolean; successRate: number; insight: string | null }> {
64
+ if (!this.decisionId) throw new Error('No active decision. Call think() first.');
65
+ const res = await this.request('POST', '/v1/agent/commit', {
66
+ decision_id: this.decisionId,
67
+ success: params.success,
68
+ outcome: params.outcome,
69
+ caused_by: params.causedBy,
70
+ });
71
+ this.decisionId = null;
72
+ return {
73
+ committed: res.committed as boolean,
74
+ successRate: res.success_rate as number,
75
+ insight: res.insight as string | null,
76
+ };
77
+ }
78
+
79
+ // Raw request helper
80
+ private async request(method: string, path: string, body?: unknown): Promise<Record<string, unknown>> {
81
+ const res = await fetch(`${this.baseUrl}${path}`, {
82
+ method,
83
+ headers: {
84
+ 'Authorization': `Bearer ${this.apiKey}`,
85
+ 'Content-Type': 'application/json',
86
+ },
87
+ body: body ? JSON.stringify(body) : undefined,
88
+ });
89
+ const json = await res.json() as { data: Record<string, unknown>; error?: string };
90
+ if (json.error) throw new Error(json.error);
91
+ return json.data;
92
+ }
93
+ }
94
+
95
+ export default MarrowClient;
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": ["src/**/*"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }