@mnemopay/sdk 0.7.3 → 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.
- package/README.md +295 -193
- package/dist/cli/setup.js +86 -6
- package/dist/cli/setup.js.map +1 -1
- package/package.json +16 -5
package/README.md
CHANGED
|
@@ -1,193 +1,295 @@
|
|
|
1
|
-
# @mnemopay/sdk
|
|
2
|
-
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm install
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
| `
|
|
74
|
-
| `
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import
|
|
119
|
-
import { MnemoPay } from "@mnemopay/sdk";
|
|
120
|
-
import {
|
|
121
|
-
|
|
122
|
-
const agent = MnemoPay.quick("
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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/dist/cli/setup.js
CHANGED
|
@@ -16,6 +16,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
const fs_1 = __importDefault(require("fs"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const os_1 = __importDefault(require("os"));
|
|
19
|
+
const AUTO_CAPTURE_HOOK_CONTENT = `#!/bin/bash
|
|
20
|
+
# MnemoPay auto-capture hook — PostToolUse
|
|
21
|
+
# Detects high-signal tool outcomes and instructs Claude to save them to memory.
|
|
22
|
+
INPUT=$(cat)
|
|
23
|
+
TOOL=$(echo "$INPUT" | grep -o '"tool_name":"[^"]*"' | grep -o '[^"]*"$' | tr -d '"' 2>/dev/null)
|
|
24
|
+
COMMAND=$(echo "$INPUT" | grep -o '"command":"[^"]*"' | head -1 | grep -o '"[^"]*"$' | tr -d '"' 2>/dev/null)
|
|
25
|
+
EXIT_CODE=$(echo "$INPUT" | grep -o '"exit_code":[0-9]*' | grep -o '[0-9]*' 2>/dev/null)
|
|
26
|
+
|
|
27
|
+
MSG=""
|
|
28
|
+
|
|
29
|
+
# git commit — always worth remembering
|
|
30
|
+
if echo "$COMMAND" | grep -q "git commit"; then
|
|
31
|
+
MSG="A git commit was just made. Call mcp__mnemopay__remember with what was committed and why. Importance: 0.7, tags: [commit, progress]."
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# git push — milestone
|
|
35
|
+
if echo "$COMMAND" | grep -q "git push"; then
|
|
36
|
+
MSG="Code was just pushed to remote. Call mcp__mnemopay__remember with what shipped. Importance: 0.75, tags: [shipped, milestone]."
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
# npm publish — release
|
|
40
|
+
if echo "$COMMAND" | grep -q "npm publish"; then
|
|
41
|
+
MSG="A package was just published to npm. Call mcp__mnemopay__remember with the version and what changed. Importance: 0.8, tags: [release, shipped]."
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# test run completed successfully
|
|
45
|
+
if [ "$TOOL" = "Bash" ] && echo "$COMMAND" | grep -qE "vitest|jest|pytest|npm test|npm run test"; then
|
|
46
|
+
if [ "$EXIT_CODE" = "0" ]; then
|
|
47
|
+
MSG="Tests just passed. Call mcp__mnemopay__remember with what was tested and that it passed. Importance: 0.6, tags: [tests, progress]."
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# File written — significant new file
|
|
52
|
+
if [ "$TOOL" = "Write" ]; then
|
|
53
|
+
FILE=$(echo "$INPUT" | grep -o '"file_path":"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"' 2>/dev/null)
|
|
54
|
+
if echo "$FILE" | grep -qvE "node_modules|dist|.git|tmp|temp"; then
|
|
55
|
+
MSG="A new file was just written: $FILE. If this is significant (new feature, config, doc), call mcp__mnemopay__remember with what it does. Importance: 0.55, tags: [file, progress]."
|
|
56
|
+
fi
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
if [ -n "$MSG" ]; then
|
|
60
|
+
printf '{"systemMessage":"%s"}\n' "$MSG"
|
|
61
|
+
else
|
|
62
|
+
printf '{}\n'
|
|
63
|
+
fi
|
|
64
|
+
`;
|
|
19
65
|
const STOP_HOOK_CONTENT = `#!/bin/bash
|
|
20
66
|
MARKER="$HOME/.claude/hooks/.mnemo-stop"
|
|
21
67
|
|
|
@@ -48,11 +94,17 @@ function settingsPath() {
|
|
|
48
94
|
function stopHookPath() {
|
|
49
95
|
return path_1.default.join(hooksDir(), "stop-hook.sh");
|
|
50
96
|
}
|
|
97
|
+
function autoCaptureHookPath() {
|
|
98
|
+
return path_1.default.join(hooksDir(), "auto-capture-hook.sh");
|
|
99
|
+
}
|
|
51
100
|
function stopHookCommand() {
|
|
52
|
-
// On Windows, bash is invoked via Git Bash or WSL — use forward-slash path
|
|
53
101
|
const p = stopHookPath().replace(/\\/g, "/");
|
|
54
102
|
return `bash ${p}`;
|
|
55
103
|
}
|
|
104
|
+
function autoCaptureHookCommand() {
|
|
105
|
+
const p = autoCaptureHookPath().replace(/\\/g, "/");
|
|
106
|
+
return `bash ${p}`;
|
|
107
|
+
}
|
|
56
108
|
function ensureDir(dir) {
|
|
57
109
|
if (!fs_1.default.existsSync(dir)) {
|
|
58
110
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
@@ -62,10 +114,15 @@ function ensureDir(dir) {
|
|
|
62
114
|
function writeStopHook() {
|
|
63
115
|
const p = stopHookPath();
|
|
64
116
|
fs_1.default.writeFileSync(p, STOP_HOOK_CONTENT, { encoding: "utf8" });
|
|
65
|
-
|
|
66
|
-
|
|
117
|
+
if (process.platform !== "win32")
|
|
118
|
+
fs_1.default.chmodSync(p, 0o755);
|
|
119
|
+
log(` wrote ${p}`);
|
|
120
|
+
}
|
|
121
|
+
function writeAutoCaptureHook() {
|
|
122
|
+
const p = autoCaptureHookPath();
|
|
123
|
+
fs_1.default.writeFileSync(p, AUTO_CAPTURE_HOOK_CONTENT, { encoding: "utf8" });
|
|
124
|
+
if (process.platform !== "win32")
|
|
67
125
|
fs_1.default.chmodSync(p, 0o755);
|
|
68
|
-
}
|
|
69
126
|
log(` wrote ${p}`);
|
|
70
127
|
}
|
|
71
128
|
function readSettings() {
|
|
@@ -134,6 +191,27 @@ function injectHooks(settings) {
|
|
|
134
191
|
else {
|
|
135
192
|
log(" UserPromptSubmit hook already present — skipped");
|
|
136
193
|
}
|
|
194
|
+
// PostToolUse auto-capture hook
|
|
195
|
+
if (!hasHook(settings.hooks.PostToolUse, "")) {
|
|
196
|
+
settings.hooks.PostToolUse = [
|
|
197
|
+
...(settings.hooks.PostToolUse ?? []),
|
|
198
|
+
{
|
|
199
|
+
matcher: "",
|
|
200
|
+
hooks: [
|
|
201
|
+
{
|
|
202
|
+
type: "command",
|
|
203
|
+
command: autoCaptureHookCommand(),
|
|
204
|
+
timeout: 5000,
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
];
|
|
209
|
+
changed = true;
|
|
210
|
+
log(" injected PostToolUse auto-capture hook");
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
log(" PostToolUse hook already present — skipped");
|
|
214
|
+
}
|
|
137
215
|
return { settings, changed };
|
|
138
216
|
}
|
|
139
217
|
function main() {
|
|
@@ -141,8 +219,9 @@ function main() {
|
|
|
141
219
|
// 1. Ensure directories
|
|
142
220
|
ensureDir(claudeDir());
|
|
143
221
|
ensureDir(hooksDir());
|
|
144
|
-
// 2. Write
|
|
222
|
+
// 2. Write hook scripts
|
|
145
223
|
writeStopHook();
|
|
224
|
+
writeAutoCaptureHook();
|
|
146
225
|
// 3. Read + patch settings.json
|
|
147
226
|
const raw = readSettings();
|
|
148
227
|
const { settings, changed } = injectHooks(raw);
|
|
@@ -153,7 +232,8 @@ function main() {
|
|
|
153
232
|
log("\nDone! Claude Code hooks are configured for MnemoPay.\n");
|
|
154
233
|
log("What happens now:");
|
|
155
234
|
log(" • On session end — Claude is prompted to save a session summary");
|
|
156
|
-
log(" • On each message — Claude is reminded to recall relevant memories
|
|
235
|
+
log(" • On each message — Claude is reminded to recall relevant memories");
|
|
236
|
+
log(" • After tool use — git commits, publishes, writes auto-trigger memory saves\n");
|
|
157
237
|
log("Make sure MnemoPay MCP is connected:");
|
|
158
238
|
log(" claude mcp add mnemopay -s user -- npx -y @mnemopay/sdk\n");
|
|
159
239
|
}
|
package/dist/cli/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/cli/setup.ts"],"names":[],"mappings":";;AACA;;;;;;;;GAQG;;;;;AAEH,4CAAoB;AACpB,gDAAwB;AACxB,4CAAoB;AAEpB,MAAM,iBAAiB,GAAG;;;;;;;;;;CAUzB,CAAC;AAEF,MAAM,wBAAwB,GAC5B,sFAAsF;IACtF,uGAAuG;IACvG,kFAAkF,CAAC,OAAO,EAAE,CAAC;AAE/F,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,GAAG,CAAC,GAAW;IACtB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,CA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C,6DAA6D,CAAC,CAAC;AACrE,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnemopay/sdk",
|
|
3
|
-
"version": "0.7.
|
|
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
|
-
"
|
|
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",
|