@mnemopay/sdk 0.7.4 → 0.7.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 +295 -193
  2. package/package.json +16 -5
package/README.md CHANGED
@@ -1,193 +1,295 @@
1
- # @mnemopay/sdk
2
-
3
- **Give any AI agent memory and a wallet in 5 lines.**
4
-
5
- MnemoPay unifies [Mnemosyne](https://github.com/mnemopay/mnemosyne-engine) (cognitive memory) and [AgentPay](https://github.com/mnemopay/agentpay-roa) (escrow economics) into a single SDK. The core innovation: **payment outcomes reinforce the memories that led to successful decisions**.
6
-
7
- ```typescript
8
- import { MnemoPay } from "@mnemopay/sdk";
9
-
10
- const agent = MnemoPay.quick("agent-001");
11
- await agent.remember("User prefers TypeScript");
12
- const memories = await agent.recall();
13
- const tx = await agent.charge(5.00, "Built analytics dashboard");
14
- await agent.settle(tx.id);
15
- ```
16
-
17
- ## Two Modes, One API
18
-
19
- | Mode | Constructor | Dependencies | Persistence | Use Case |
20
- |------|------------|-------------|-------------|----------|
21
- | **Prototype** | `MnemoPay.quick("id")` | None | In-memory | Development, testing, demos |
22
- | **Production** | `MnemoPay.create({...})` | Postgres + Redis | Durable | Deployed agents |
23
-
24
- Switch by changing one line. No code rewrites.
25
-
26
- ## Install
27
-
28
- ```bash
29
- npm install @mnemopay/sdk
30
- ```
31
-
32
- Optional peer dependencies (install only what you use):
33
-
34
- ```bash
35
- npm install openai # For OpenAI middleware
36
- npm install @anthropic-ai/sdk # For Anthropic middleware
37
- npm install @langchain/langgraph @langchain/core @langchain/openai # For LangGraph tools
38
- ```
39
-
40
- ## The Feedback Loop
41
-
42
- This is the core differentiator — payment outcomes reinforce memories:
43
-
44
- ```
45
- Agent recalls memories Makes decision Delivers value → Charges user
46
-
47
- Payment settles
48
-
49
- Memories accessed in the last hour get +0.05 importance
50
-
51
- Agent makes better decisions next time
52
- ```
53
-
54
- Over time, memories that lead to successful transactions become dominant in recall, while memories associated with refunds decay faster.
55
-
56
- ## API Reference
57
-
58
- ### Memory Methods
59
-
60
- | Method | Description |
61
- |--------|-------------|
62
- | `agent.remember(content, opts?)` | Store a memory. Auto-scored by importance if not specified. |
63
- | `agent.recall(limit?)` | Recall top memories ranked by importance x recency x frequency. |
64
- | `agent.forget(id)` | Delete a memory. |
65
- | `agent.reinforce(id, boost?)` | Boost a memory's importance. |
66
- | `agent.consolidate()` | Prune stale memories below score threshold. |
67
-
68
- ### Payment Methods
69
-
70
- | Method | Description |
71
- |--------|-------------|
72
- | `agent.charge(amount, reason)` | Create an escrow transaction. Reputation-gated. |
73
- | `agent.settle(txId)` | Finalize escrow. Moves funds, boosts reputation, reinforces memories. |
74
- | `agent.refund(txId)` | Refund a transaction. Docks reputation by -0.05. |
75
- | `agent.balance()` | Get wallet balance and reputation score. |
76
-
77
- ### Observability
78
-
79
- | Method | Description |
80
- |--------|-------------|
81
- | `agent.profile()` | Full agent stats (reputation, wallet, memory count, tx count). |
82
- | `agent.logs(limit?)` | Immutable audit trail of all actions. |
83
- | `agent.history(limit?)` | Transaction history, most recent first. |
84
-
85
- ## Provider Middlewares
86
-
87
- ### OpenAI (invisible memory)
88
-
89
- ```typescript
90
- import OpenAI from "openai";
91
- import { MnemoPay } from "@mnemopay/sdk";
92
- import { MnemoPayMiddleware } from "@mnemopay/sdk/middleware/openai";
93
-
94
- const agent = MnemoPay.quick("assistant");
95
- const ai = MnemoPayMiddleware.wrap(new OpenAI(), agent);
96
-
97
- // Memory is now invisible auto-injected and auto-stored
98
- const res = await ai.chat.completions.create({
99
- model: "gpt-4o",
100
- messages: [{ role: "user", content: "What do you remember?" }],
101
- });
102
- ```
103
-
104
- ### Anthropic (invisible memory)
105
-
106
- ```typescript
107
- import Anthropic from "@anthropic-ai/sdk";
108
- import { MnemoPay } from "@mnemopay/sdk";
109
- import { AnthropicMiddleware } from "@mnemopay/sdk/middleware/anthropic";
110
-
111
- const agent = MnemoPay.quick("claude-agent");
112
- const ai = AnthropicMiddleware.wrap(new Anthropic(), agent);
113
- ```
114
-
115
- ## LangGraph Tools
116
-
117
- ```typescript
118
- import { createReactAgent } from "@langchain/langgraph/prebuilt";
119
- import { MnemoPay } from "@mnemopay/sdk";
120
- import { mnemoTools, agentPayTools } from "@mnemopay/sdk/langgraph";
121
-
122
- const agent = MnemoPay.quick("langgraph-agent");
123
- const graph = createReactAgent({
124
- llm,
125
- tools: [...mnemoTools(agent), ...agentPayTools(agent)],
126
- });
127
- ```
128
-
129
- 6 tools with full Zod schemas: `recall_memories`, `store_memory`, `reinforce_memory`, `charge_user`, `settle_payment`, `check_balance`.
130
-
131
- ## Agents Hiring Agents
132
-
133
- ```typescript
134
- const manager = MnemoPay.quick("manager");
135
- const coder = MnemoPay.quick("coder");
136
-
137
- await manager.remember("coder delivered fast but had 2 bugs last time");
138
- const memories = await manager.recall(); // Use memory to decide
139
-
140
- const job = await manager.charge(5.00, "Code sorting algorithm");
141
- await manager.settle(job.id);
142
- await manager.remember("coder delivered clean code this time");
143
- // Next round: manager makes better hiring decisions
144
- ```
145
-
146
- ## Production Mode
147
-
148
- ```bash
149
- docker compose up -d # Starts Mnemosyne + AgentPay + Postgres + Redis
150
- ```
151
-
152
- ```typescript
153
- const agent = MnemoPay.create({
154
- agentId: "prod-agent",
155
- mnemoUrl: "http://localhost:8100",
156
- agentpayUrl: "http://localhost:3100",
157
- debug: true,
158
- });
159
-
160
- // Same API — now backed by Hopfield networks, Bayesian trust, AIS fraud detection
161
- await agent.remember("Production memory");
162
- const tx = await agent.charge(10.00, "Premium service");
163
- await agent.settle(tx.id);
164
- ```
165
-
166
- ## Architecture
167
-
168
- ```
169
- Your code
170
-
171
- @mnemopay/sdk ←── Single import, 12 methods
172
- ↓ ↓
173
- Mnemosyne API AgentPay API ←── Separate services (unchanged)
174
- (12 models) (14 models)
175
-
176
- Redis Streams Bridge ←── Payment outcomes reinforce memories
177
- ```
178
-
179
- The SDK is the developer-facing layer. The backends do the heavy lifting:
180
- - **Mnemosyne**: Hopfield associative recall, FSRS spaced repetition, Merkle integrity, Dream consolidation
181
- - **AgentPay**: Bayesian trust (Beta distributions), AIS fraud detection, behavioral economics, escrow
182
-
183
- ## Tests
184
-
185
- ```bash
186
- npm test # 67 tests covering memory, payments, feedback loop, security, concurrency
187
- ```
188
-
189
- ## License
190
-
191
- MIT
192
-
193
- Built by [J&B Enterprise LLC](https://github.com/mnemopay)
1
+ # @mnemopay/sdk
2
+
3
+ **Session memory for Claude on AWS Bedrock, Google Vertex AI, Anthropic API, and Foundry.**
4
+
5
+ MIT-licensed. Self-hostable. Works in 30 seconds via `npx`.
6
+
7
+ ---
8
+
9
+ ## The Problem
10
+
11
+ Anthropic's built-in Session Memory and Auto Dream features are **Pro/Max subscription only**. If your team accesses Claude through:
12
+
13
+ - AWS Bedrock
14
+ - Google Vertex AI
15
+ - Anthropic API directly
16
+ - Foundry or any third-party host
17
+
18
+ ...you get **zero native memory**. Every session starts cold. Context has to be rebuilt by hand, crammed into prompts, or managed with brittle custom code.
19
+
20
+ MnemoPay is the only MIT-licensed, self-hostable MCP server that gives those deployments persistent session memory — plus an optional micropayment wallet for agent-to-agent transactions.
21
+
22
+ ---
23
+
24
+ ## Quickstart
25
+
26
+ ```bash
27
+ npx @mnemopay/sdk init
28
+ ```
29
+
30
+ That registers MnemoPay as an MCP server. Works with Claude Code, Cursor, Windsurf, or any MCP-compatible client. No Claude Pro required.
31
+
32
+ Or install as a package dependency:
33
+
34
+ ```bash
35
+ npm install @mnemopay/sdk
36
+ ```
37
+
38
+ ```typescript
39
+ import { MnemoPay } from "@mnemopay/sdk";
40
+
41
+ const agent = MnemoPay.quick("agent-001");
42
+ await agent.remember("User prefers TypeScript over Python");
43
+ const memories = await agent.recall();
44
+ // Optional: payment rails
45
+ const tx = await agent.charge(5.00, "Built analytics dashboard");
46
+ await agent.settle(tx.id);
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Why Not the Alternatives?
52
+
53
+ | | MnemoPay | claude-mem | claude-brain | Anthropic built-in | Minolith |
54
+ |---|---|---|---|---|---|
55
+ | **License** | MIT | AGPL-3.0 | MIT | Proprietary | Paid/closed |
56
+ | **Enterprise-safe** | Yes | **No** (AGPL) | Yes | N/A | Vendor lock-in |
57
+ | **Works on Bedrock/Vertex/API** | Yes | No | No | **No (Pro/Max only)** | Unknown |
58
+ | **MCP — any client** | Yes | Claude Code only | Claude Code only | Claude Code only | No |
59
+ | **Semantic search** | Yes | No | No | Yes | Unknown |
60
+ | **Importance decay** | Yes | No | No | Unknown | Unknown |
61
+ | **Self-hostable** | Yes | Yes | Yes | No | No |
62
+ | **Payment rails** | Yes | No | No | No | No |
63
+ | **Runaway API spend risk** | No | Yes (worker daemon) | Unknown | N/A | Unknown |
64
+
65
+ **The short version:** claude-mem is AGPL, which means enterprise legal teams will reject it on sight. The Anthropic built-in solution is excellent — but it only works if your team pays for Pro or Max subscriptions. MnemoPay fills the gap for everyone else.
66
+
67
+ ---
68
+
69
+ ## Two Modes, One API
70
+
71
+ | Mode | Constructor | Dependencies | Persistence | Use Case |
72
+ |------|------------|-------------|-------------|----------|
73
+ | **Prototype** | `MnemoPay.quick("id")` | None | In-memory | Development, testing, demos |
74
+ | **Production** | `MnemoPay.create({...})` | Postgres + Redis | Durable | Deployed agents |
75
+
76
+ Switch by changing one line. No code rewrites.
77
+
78
+ ---
79
+
80
+ ## API Reference
81
+
82
+ ### Memory Methods
83
+
84
+ | Method | Description |
85
+ |--------|-------------|
86
+ | `agent.remember(content, opts?)` | Store a memory. Auto-scored by importance if not specified. |
87
+ | `agent.recall(limit?)` | Recall top memories ranked by importance × recency × frequency. |
88
+ | `agent.forget(id)` | Delete a memory. |
89
+ | `agent.reinforce(id, boost?)` | Boost a memory's importance score. |
90
+ | `agent.consolidate()` | Prune stale memories below score threshold. |
91
+
92
+ ### Payment Methods (Optional)
93
+
94
+ | Method | Description |
95
+ |--------|-------------|
96
+ | `agent.charge(amount, reason)` | Create an escrow transaction. Reputation-gated. |
97
+ | `agent.settle(txId)` | Finalize escrow. Moves funds, boosts reputation, reinforces memories. |
98
+ | `agent.refund(txId)` | Refund a transaction. Docks reputation by -0.05. |
99
+ | `agent.balance()` | Get wallet balance and reputation score. |
100
+
101
+ ### Observability
102
+
103
+ | Method | Description |
104
+ |--------|-------------|
105
+ | `agent.profile()` | Full agent stats (reputation, wallet, memory count, tx count). |
106
+ | `agent.logs(limit?)` | Immutable audit trail of all actions. |
107
+ | `agent.history(limit?)` | Transaction history, most recent first. |
108
+
109
+ ---
110
+
111
+ ## Provider Middlewares
112
+
113
+ ### Anthropic (invisible memory)
114
+
115
+ Drop-in wrapper for `@anthropic-ai/sdk`. Works with Bedrock and Vertex clients too — anything that uses the same interface.
116
+
117
+ ```typescript
118
+ import Anthropic from "@anthropic-ai/sdk";
119
+ import { MnemoPay } from "@mnemopay/sdk";
120
+ import { AnthropicMiddleware } from "@mnemopay/sdk/middleware/anthropic";
121
+
122
+ const agent = MnemoPay.quick("claude-agent");
123
+ const ai = AnthropicMiddleware.wrap(new Anthropic(), agent);
124
+
125
+ // Memory is auto-injected into context and auto-stored after each response
126
+ const res = await ai.messages.create({
127
+ model: "claude-opus-4-5",
128
+ max_tokens: 1024,
129
+ messages: [{ role: "user", content: "What do you remember?" }],
130
+ });
131
+ ```
132
+
133
+ ### OpenAI (invisible memory)
134
+
135
+ ```typescript
136
+ import OpenAI from "openai";
137
+ import { MnemoPay } from "@mnemopay/sdk";
138
+ import { MnemoPayMiddleware } from "@mnemopay/sdk/middleware/openai";
139
+
140
+ const agent = MnemoPay.quick("assistant");
141
+ const ai = MnemoPayMiddleware.wrap(new OpenAI(), agent);
142
+
143
+ const res = await ai.chat.completions.create({
144
+ model: "gpt-4o",
145
+ messages: [{ role: "user", content: "What do you remember?" }],
146
+ });
147
+ ```
148
+
149
+ ---
150
+
151
+ ## LangGraph Tools
152
+
153
+ ```typescript
154
+ import { createReactAgent } from "@langchain/langgraph/prebuilt";
155
+ import { MnemoPay } from "@mnemopay/sdk";
156
+ import { mnemoTools, agentPayTools } from "@mnemopay/sdk/langgraph";
157
+
158
+ const agent = MnemoPay.quick("langgraph-agent");
159
+ const graph = createReactAgent({
160
+ llm,
161
+ tools: [...mnemoTools(agent), ...agentPayTools(agent)],
162
+ });
163
+ ```
164
+
165
+ 6 tools with full Zod schemas: `recall_memories`, `store_memory`, `reinforce_memory`, `charge_user`, `settle_payment`, `check_balance`.
166
+
167
+ ---
168
+
169
+ ## The Memory-Payment Feedback Loop
170
+
171
+ The payment rails are optional, but they unlock a core differentiator: payment outcomes reinforce the memories that led to successful decisions.
172
+
173
+ ```
174
+ Agent recalls memories → Makes decision → Delivers value → Charges user
175
+
176
+ Payment settles
177
+
178
+ Memories accessed in the last hour get +0.05 importance
179
+
180
+ Agent makes better decisions next time
181
+ ```
182
+
183
+ Memories associated with successful transactions rise in recall priority. Memories associated with refunds decay faster. Over time, the agent's judgment improves without any fine-tuning.
184
+
185
+ ### Agents Hiring Agents
186
+
187
+ ```typescript
188
+ const manager = MnemoPay.quick("manager");
189
+ const coder = MnemoPay.quick("coder");
190
+
191
+ await manager.remember("coder delivered fast but had 2 bugs last time");
192
+ const memories = await manager.recall(); // Informs hiring decision
193
+
194
+ const job = await manager.charge(5.00, "Code sorting algorithm");
195
+ await manager.settle(job.id);
196
+ await manager.remember("coder delivered clean code this time");
197
+ // Next round: manager's recall reflects the updated track record
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Production Setup
203
+
204
+ ```bash
205
+ docker compose up -d # Starts Mnemosyne + AgentPay + Postgres + Redis
206
+ ```
207
+
208
+ ```typescript
209
+ const agent = MnemoPay.create({
210
+ agentId: "prod-agent",
211
+ mnemoUrl: "http://localhost:8100",
212
+ agentpayUrl: "http://localhost:3100",
213
+ debug: true,
214
+ });
215
+
216
+ // Same API — backed by Hopfield networks, Bayesian trust, AIS fraud detection
217
+ await agent.remember("Production memory");
218
+ const tx = await agent.charge(10.00, "Premium service");
219
+ await agent.settle(tx.id);
220
+ ```
221
+
222
+ Optional peer dependencies — install only what you use:
223
+
224
+ ```bash
225
+ npm install openai # For OpenAI middleware
226
+ npm install @anthropic-ai/sdk # For Anthropic middleware
227
+ npm install @langchain/langgraph @langchain/core @langchain/openai # For LangGraph tools
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Architecture
233
+
234
+ ```
235
+ Your code
236
+
237
+ @mnemopay/sdk ←── Single import, 12 methods
238
+ ↓ ↓
239
+ Mnemosyne API AgentPay API ←── Separate services (unchanged)
240
+ (12 models) (14 models)
241
+ ↓ ↓
242
+ Redis Streams Bridge ←── Payment outcomes reinforce memories
243
+ ```
244
+
245
+ - **Mnemosyne**: Hopfield associative recall, FSRS spaced repetition, Merkle integrity, Dream consolidation
246
+ - **AgentPay**: Bayesian trust (Beta distributions), AIS fraud detection, behavioral economics, escrow
247
+
248
+ ---
249
+
250
+ ## Integration Support
251
+
252
+ | Platform | Status | Notes |
253
+ |---|---|---|
254
+ | Claude Code | Stable | MCP server via `npx @mnemopay/sdk init` |
255
+ | Cursor | Stable | Same MCP config |
256
+ | Windsurf | Stable | Same MCP config |
257
+ | AWS Bedrock | Stable | Use `AnthropicMiddleware` with Bedrock client |
258
+ | Google Vertex AI | Stable | Use `AnthropicMiddleware` with Vertex client |
259
+ | Anthropic API | Stable | Drop-in with `AnthropicMiddleware` |
260
+ | LangGraph | Stable | 6 native tools with Zod schemas |
261
+ | OpenAI-compatible | Stable | `MnemoPayMiddleware` wrapper |
262
+ | Mastra | In progress | Native MCP — no plugin needed |
263
+
264
+ ---
265
+
266
+ ## Pricing
267
+
268
+ MnemoPay SDK is free and MIT-licensed. Self-hosting is always free.
269
+
270
+ For teams that want managed hosting, SLA support, or enterprise onboarding:
271
+
272
+ | Tier | Price | Includes |
273
+ |---|---|---|
274
+ | **Self-hosted** | Free | Full SDK, unlimited agents, you manage infra |
275
+ | **Team** | $99/month | Managed hosting, up to 10 agents, email support |
276
+ | **Business** | $299/month | Managed hosting, up to 50 agents, priority support, SSO |
277
+ | **Enterprise** | $499+/month | Unlimited agents, SLA, dedicated support, custom deployment |
278
+
279
+ Contact: [github.com/mnemopay](https://github.com/mnemopay)
280
+
281
+ ---
282
+
283
+ ## Tests
284
+
285
+ ```bash
286
+ npm test # 143 tests covering memory, payments, feedback loop, security, concurrency
287
+ ```
288
+
289
+ ---
290
+
291
+ ## License
292
+
293
+ **MIT** — use it in commercial products, enterprise deployments, forks, anything. No AGPL restrictions.
294
+
295
+ Built by [J&B Enterprise LLC](https://github.com/mnemopay)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnemopay/sdk",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Give any AI agent memory and a wallet in 5 lines. Unified SDK for Mnemosyne (cognitive memory) + AgentPay (escrow economics).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -55,20 +55,31 @@
55
55
  "prepublishOnly": "npm run build"
56
56
  },
57
57
  "keywords": [
58
- "ai",
59
- "agent",
58
+ "ai-agent",
59
+ "agent-memory",
60
60
  "memory",
61
+ "agent-wallet",
61
62
  "payment",
62
63
  "escrow",
63
64
  "llm",
64
65
  "openai",
65
66
  "anthropic",
67
+ "claude",
68
+ "aws-bedrock",
69
+ "google-vertex",
66
70
  "langchain",
67
71
  "langgraph",
68
72
  "mcp",
69
- "cognitive",
73
+ "model-context-protocol",
74
+ "cognitive-memory",
70
75
  "wallet",
71
- "reputation"
76
+ "reputation",
77
+ "agent-sdk",
78
+ "multi-agent",
79
+ "ai-memory",
80
+ "session-memory",
81
+ "fraud-detection",
82
+ "micropayments"
72
83
  ],
73
84
  "author": "Jerry Omiagbo <jeremiah@getbizsuite.com>",
74
85
  "license": "MIT",