@mnemopay/sdk 0.1.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/LICENSE +21 -0
- package/README.md +193 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +537 -0
- package/dist/index.js.map +1 -0
- package/dist/langgraph/tools.d.ts +84 -0
- package/dist/langgraph/tools.d.ts.map +1 -0
- package/dist/langgraph/tools.js +129 -0
- package/dist/langgraph/tools.js.map +1 -0
- package/dist/mcp/server.d.ts +21 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +431 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/middleware/anthropic.d.ts +28 -0
- package/dist/middleware/anthropic.d.ts.map +1 -0
- package/dist/middleware/anthropic.js +95 -0
- package/dist/middleware/anthropic.js.map +1 -0
- package/dist/middleware/openai.d.ts +31 -0
- package/dist/middleware/openai.d.ts.map +1 -0
- package/dist/middleware/openai.js +96 -0
- package/dist/middleware/openai.js.map +1 -0
- package/dist/recall/engine.d.ts +109 -0
- package/dist/recall/engine.d.ts.map +1 -0
- package/dist/recall/engine.js +253 -0
- package/dist/recall/engine.js.map +1 -0
- package/package.json +109 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @mnemopay/sdk — Give any AI agent memory and a wallet in 5 lines.
|
|
4
|
+
*
|
|
5
|
+
* MnemoPay unifies Mnemosyne (cognitive memory) and AgentPay (escrow economics)
|
|
6
|
+
* into a single SDK. The core innovation: payment outcomes reinforce the memories
|
|
7
|
+
* that led to successful decisions.
|
|
8
|
+
*
|
|
9
|
+
* Two modes, identical API:
|
|
10
|
+
* MnemoPay.quick("id") → zero infra, in-memory (dev/testing)
|
|
11
|
+
* MnemoPay.create({...}) → Postgres + Redis (production)
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.l2Normalize = exports.localEmbed = exports.cosineSimilarity = exports.RecallEngine = exports.MnemoPay = exports.MnemoPayLite = void 0;
|
|
15
|
+
exports.autoScore = autoScore;
|
|
16
|
+
exports.computeScore = computeScore;
|
|
17
|
+
const events_1 = require("events");
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
const engine_js_1 = require("./recall/engine.js");
|
|
20
|
+
// ─── Auto-scoring keywords ─────────────────────────────────────────────────
|
|
21
|
+
const IMPORTANCE_PATTERNS = [
|
|
22
|
+
{ pattern: /\b(error|fail|crash|critical|broken|bug)\b/i, boost: 0.20 },
|
|
23
|
+
{ pattern: /\b(success|complete|paid|delivered|resolved)\b/i, boost: 0.15 },
|
|
24
|
+
{ pattern: /\b(prefer|always|never|important|must|require)\b/i, boost: 0.15 },
|
|
25
|
+
];
|
|
26
|
+
const LONG_CONTENT_THRESHOLD = 200;
|
|
27
|
+
const LONG_CONTENT_BOOST = 0.10;
|
|
28
|
+
const BASE_IMPORTANCE = 0.50;
|
|
29
|
+
function autoScore(content) {
|
|
30
|
+
let score = BASE_IMPORTANCE;
|
|
31
|
+
if (content.length > LONG_CONTENT_THRESHOLD)
|
|
32
|
+
score += LONG_CONTENT_BOOST;
|
|
33
|
+
for (const { pattern, boost } of IMPORTANCE_PATTERNS) {
|
|
34
|
+
if (pattern.test(content))
|
|
35
|
+
score += boost;
|
|
36
|
+
}
|
|
37
|
+
return Math.min(score, 1.0);
|
|
38
|
+
}
|
|
39
|
+
// ─── Memory scoring ────────────────────────────────────────────────────────
|
|
40
|
+
function computeScore(importance, lastAccessed, accessCount, decay) {
|
|
41
|
+
const hoursSince = (Date.now() - lastAccessed.getTime()) / 3_600_000;
|
|
42
|
+
const recency = Math.exp(-decay * hoursSince);
|
|
43
|
+
const frequency = 1 + Math.log(1 + accessCount);
|
|
44
|
+
return importance * recency * frequency;
|
|
45
|
+
}
|
|
46
|
+
// ─── MnemoPayLite (in-memory, zero dependencies) ───────────────────────────
|
|
47
|
+
class MnemoPayLite extends events_1.EventEmitter {
|
|
48
|
+
agentId;
|
|
49
|
+
decay;
|
|
50
|
+
debugMode;
|
|
51
|
+
memories = new Map();
|
|
52
|
+
transactions = new Map();
|
|
53
|
+
auditLog = [];
|
|
54
|
+
_wallet = 0;
|
|
55
|
+
_reputation = 0.5;
|
|
56
|
+
recallEngine;
|
|
57
|
+
constructor(agentId, decay = 0.05, debug = false, recallConfig) {
|
|
58
|
+
super();
|
|
59
|
+
this.agentId = agentId;
|
|
60
|
+
this.decay = decay;
|
|
61
|
+
this.debugMode = debug;
|
|
62
|
+
this.recallEngine = new engine_js_1.RecallEngine(recallConfig);
|
|
63
|
+
this.log(`MnemoPayLite initialized (in-memory mode, recall: ${this.recallEngine.strategy})`);
|
|
64
|
+
setTimeout(() => this.emit("ready"), 0);
|
|
65
|
+
}
|
|
66
|
+
log(msg) {
|
|
67
|
+
if (this.debugMode)
|
|
68
|
+
console.log(`[mnemopay:${this.agentId}] ${msg}`);
|
|
69
|
+
}
|
|
70
|
+
audit(action, details) {
|
|
71
|
+
const entry = {
|
|
72
|
+
id: (0, crypto_1.randomUUID)(),
|
|
73
|
+
agentId: this.agentId,
|
|
74
|
+
action,
|
|
75
|
+
details,
|
|
76
|
+
createdAt: new Date(),
|
|
77
|
+
};
|
|
78
|
+
this.auditLog.push(entry);
|
|
79
|
+
}
|
|
80
|
+
// ── Memory Methods ──────────────────────────────────────────────────────
|
|
81
|
+
async remember(content, opts) {
|
|
82
|
+
const importance = opts?.importance ?? autoScore(content);
|
|
83
|
+
const now = new Date();
|
|
84
|
+
const mem = {
|
|
85
|
+
id: (0, crypto_1.randomUUID)(),
|
|
86
|
+
agentId: this.agentId,
|
|
87
|
+
content,
|
|
88
|
+
importance: Math.min(Math.max(importance, 0), 1),
|
|
89
|
+
score: importance,
|
|
90
|
+
createdAt: now,
|
|
91
|
+
lastAccessed: now,
|
|
92
|
+
accessCount: 0,
|
|
93
|
+
tags: opts?.tags ?? [],
|
|
94
|
+
};
|
|
95
|
+
this.memories.set(mem.id, mem);
|
|
96
|
+
// Generate embedding if using vector/hybrid recall
|
|
97
|
+
if (this.recallEngine.strategy !== "score") {
|
|
98
|
+
await this.recallEngine.embed(mem.id, content);
|
|
99
|
+
}
|
|
100
|
+
this.audit("memory:stored", { id: mem.id, content: content.slice(0, 100), importance: mem.importance });
|
|
101
|
+
this.emit("memory:stored", { id: mem.id, content, importance: mem.importance });
|
|
102
|
+
this.log(`Stored memory: "${content.slice(0, 60)}..." (importance: ${mem.importance.toFixed(2)})`);
|
|
103
|
+
return mem.id;
|
|
104
|
+
}
|
|
105
|
+
async recall(queryOrLimit, maybeLimit) {
|
|
106
|
+
// Parse overloaded args
|
|
107
|
+
const query = typeof queryOrLimit === "string" ? queryOrLimit : undefined;
|
|
108
|
+
const limit = typeof queryOrLimit === "number" ? queryOrLimit : (maybeLimit ?? 5);
|
|
109
|
+
// Compute decay scores for all memories
|
|
110
|
+
const all = Array.from(this.memories.values()).map((m) => {
|
|
111
|
+
m.score = computeScore(m.importance, m.lastAccessed, m.accessCount, this.decay);
|
|
112
|
+
return m;
|
|
113
|
+
});
|
|
114
|
+
let results;
|
|
115
|
+
if (this.recallEngine.strategy !== "score" && query) {
|
|
116
|
+
// Use vector/hybrid search with the query
|
|
117
|
+
const searchResults = await this.recallEngine.search(query, all, limit);
|
|
118
|
+
results = searchResults.map((r) => {
|
|
119
|
+
const mem = this.memories.get(r.id);
|
|
120
|
+
mem.score = r.combinedScore;
|
|
121
|
+
return mem;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Default: score-based ranking
|
|
126
|
+
all.sort((a, b) => b.score - a.score);
|
|
127
|
+
results = all.slice(0, limit);
|
|
128
|
+
}
|
|
129
|
+
const now = new Date();
|
|
130
|
+
for (const m of results) {
|
|
131
|
+
m.lastAccessed = now;
|
|
132
|
+
m.accessCount++;
|
|
133
|
+
}
|
|
134
|
+
this.emit("memory:recalled", { count: results.length });
|
|
135
|
+
this.log(`Recalled ${results.length} memories (strategy: ${this.recallEngine.strategy})`);
|
|
136
|
+
return results;
|
|
137
|
+
}
|
|
138
|
+
async forget(id) {
|
|
139
|
+
const existed = this.memories.delete(id);
|
|
140
|
+
if (existed) {
|
|
141
|
+
this.recallEngine.remove(id);
|
|
142
|
+
this.audit("memory:deleted", { id });
|
|
143
|
+
this.log(`Forgot memory: ${id}`);
|
|
144
|
+
}
|
|
145
|
+
return existed;
|
|
146
|
+
}
|
|
147
|
+
async reinforce(id, boost = 0.1) {
|
|
148
|
+
const mem = this.memories.get(id);
|
|
149
|
+
if (!mem)
|
|
150
|
+
throw new Error(`Memory ${id} not found`);
|
|
151
|
+
mem.importance = Math.min(mem.importance + boost, 1.0);
|
|
152
|
+
mem.lastAccessed = new Date();
|
|
153
|
+
this.audit("memory:reinforced", { id, boost, newImportance: mem.importance });
|
|
154
|
+
this.log(`Reinforced memory ${id} by +${boost} → ${mem.importance.toFixed(2)}`);
|
|
155
|
+
}
|
|
156
|
+
async consolidate() {
|
|
157
|
+
const threshold = 0.01;
|
|
158
|
+
let pruned = 0;
|
|
159
|
+
const prunedIds = [];
|
|
160
|
+
for (const [id, mem] of this.memories) {
|
|
161
|
+
const score = computeScore(mem.importance, mem.lastAccessed, mem.accessCount, this.decay);
|
|
162
|
+
if (score < threshold) {
|
|
163
|
+
this.memories.delete(id);
|
|
164
|
+
prunedIds.push(id);
|
|
165
|
+
pruned++;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Clean up embedding cache for pruned memories
|
|
169
|
+
this.recallEngine.removeBatch(prunedIds);
|
|
170
|
+
this.audit("memory:consolidated", { pruned });
|
|
171
|
+
this.log(`Consolidated: pruned ${pruned} stale memories`);
|
|
172
|
+
return pruned;
|
|
173
|
+
}
|
|
174
|
+
// ── Payment Methods ─────────────────────────────────────────────────────
|
|
175
|
+
async charge(amount, reason) {
|
|
176
|
+
if (amount <= 0)
|
|
177
|
+
throw new Error("Amount must be positive");
|
|
178
|
+
const maxCharge = 500 * this._reputation;
|
|
179
|
+
if (amount > maxCharge) {
|
|
180
|
+
throw new Error(`Amount $${amount.toFixed(2)} exceeds reputation ceiling $${maxCharge.toFixed(2)} ` +
|
|
181
|
+
`(reputation: ${this._reputation.toFixed(2)}, max: $${maxCharge.toFixed(2)})`);
|
|
182
|
+
}
|
|
183
|
+
const tx = {
|
|
184
|
+
id: (0, crypto_1.randomUUID)(),
|
|
185
|
+
agentId: this.agentId,
|
|
186
|
+
amount,
|
|
187
|
+
reason,
|
|
188
|
+
status: "pending",
|
|
189
|
+
createdAt: new Date(),
|
|
190
|
+
};
|
|
191
|
+
this.transactions.set(tx.id, tx);
|
|
192
|
+
this.audit("payment:pending", { id: tx.id, amount, reason });
|
|
193
|
+
this.emit("payment:pending", { id: tx.id, amount, reason });
|
|
194
|
+
this.log(`Charge created: $${amount.toFixed(2)} for "${reason}" (pending)`);
|
|
195
|
+
return { ...tx };
|
|
196
|
+
}
|
|
197
|
+
async settle(txId) {
|
|
198
|
+
const tx = this.transactions.get(txId);
|
|
199
|
+
if (!tx)
|
|
200
|
+
throw new Error(`Transaction ${txId} not found`);
|
|
201
|
+
if (tx.status !== "pending")
|
|
202
|
+
throw new Error(`Transaction ${txId} is ${tx.status}, not pending`);
|
|
203
|
+
// 1. Move funds to wallet
|
|
204
|
+
tx.status = "completed";
|
|
205
|
+
tx.completedAt = new Date();
|
|
206
|
+
this._wallet += tx.amount;
|
|
207
|
+
// 2. Boost reputation
|
|
208
|
+
this._reputation = Math.min(this._reputation + 0.01, 1.0);
|
|
209
|
+
// 3. Reinforce recently-accessed memories (feedback loop)
|
|
210
|
+
const oneHourAgo = Date.now() - 3_600_000;
|
|
211
|
+
let reinforced = 0;
|
|
212
|
+
for (const mem of this.memories.values()) {
|
|
213
|
+
if (mem.lastAccessed.getTime() > oneHourAgo) {
|
|
214
|
+
mem.importance = Math.min(mem.importance + 0.05, 1.0);
|
|
215
|
+
reinforced++;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
this.audit("payment:completed", { id: tx.id, amount: tx.amount, reinforcedMemories: reinforced });
|
|
219
|
+
this.emit("payment:completed", { id: tx.id, amount: tx.amount });
|
|
220
|
+
this.log(`Settled $${tx.amount.toFixed(2)} → wallet: $${this._wallet.toFixed(2)}, ` +
|
|
221
|
+
`reputation: ${this._reputation.toFixed(2)}, reinforced: ${reinforced} memories`);
|
|
222
|
+
return { ...tx };
|
|
223
|
+
}
|
|
224
|
+
async refund(txId) {
|
|
225
|
+
const tx = this.transactions.get(txId);
|
|
226
|
+
if (!tx)
|
|
227
|
+
throw new Error(`Transaction ${txId} not found`);
|
|
228
|
+
if (tx.status === "refunded")
|
|
229
|
+
throw new Error(`Transaction ${txId} already refunded`);
|
|
230
|
+
if (tx.status === "completed") {
|
|
231
|
+
this._wallet = Math.max(this._wallet - tx.amount, 0);
|
|
232
|
+
this._reputation = Math.max(this._reputation - 0.05, 0);
|
|
233
|
+
}
|
|
234
|
+
tx.status = "refunded";
|
|
235
|
+
this.audit("payment:refunded", { id: tx.id, amount: tx.amount });
|
|
236
|
+
this.emit("payment:refunded", { id: tx.id });
|
|
237
|
+
this.log(`Refunded $${tx.amount.toFixed(2)} → reputation: ${this._reputation.toFixed(2)}`);
|
|
238
|
+
return { ...tx };
|
|
239
|
+
}
|
|
240
|
+
async balance() {
|
|
241
|
+
return { wallet: this._wallet, reputation: this._reputation };
|
|
242
|
+
}
|
|
243
|
+
// ── Observability ───────────────────────────────────────────────────────
|
|
244
|
+
async profile() {
|
|
245
|
+
return {
|
|
246
|
+
id: this.agentId,
|
|
247
|
+
reputation: this._reputation,
|
|
248
|
+
wallet: this._wallet,
|
|
249
|
+
memoriesCount: this.memories.size,
|
|
250
|
+
transactionsCount: this.transactions.size,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async logs(limit = 50) {
|
|
254
|
+
return this.auditLog.slice(-limit);
|
|
255
|
+
}
|
|
256
|
+
async history(limit = 20) {
|
|
257
|
+
const all = Array.from(this.transactions.values());
|
|
258
|
+
// Reverse insertion order (Map preserves insertion order)
|
|
259
|
+
all.reverse();
|
|
260
|
+
return all.slice(0, limit).map((tx) => ({ ...tx }));
|
|
261
|
+
}
|
|
262
|
+
async disconnect() {
|
|
263
|
+
this.log("Disconnected (in-memory mode, data discarded)");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.MnemoPayLite = MnemoPayLite;
|
|
267
|
+
// ─── MnemoPay (production — talks to Mnemosyne + AgentPay backends) ────────
|
|
268
|
+
class MnemoPay extends events_1.EventEmitter {
|
|
269
|
+
agentId;
|
|
270
|
+
config;
|
|
271
|
+
headers;
|
|
272
|
+
constructor(config) {
|
|
273
|
+
super();
|
|
274
|
+
this.agentId = config.agentId;
|
|
275
|
+
this.config = {
|
|
276
|
+
mnemoUrl: config.mnemoUrl || "http://localhost:8100",
|
|
277
|
+
agentpayUrl: config.agentpayUrl || "http://localhost:3100",
|
|
278
|
+
decay: config.decay ?? 0.05,
|
|
279
|
+
debug: config.debug ?? false,
|
|
280
|
+
mnemoApiKey: config.mnemoApiKey,
|
|
281
|
+
agentpayApiKey: config.agentpayApiKey,
|
|
282
|
+
};
|
|
283
|
+
this.headers = {
|
|
284
|
+
"Content-Type": "application/json",
|
|
285
|
+
"X-Agent-ID": this.agentId,
|
|
286
|
+
};
|
|
287
|
+
this.log("MnemoPay initialized (production mode)");
|
|
288
|
+
this.init();
|
|
289
|
+
}
|
|
290
|
+
async init() {
|
|
291
|
+
try {
|
|
292
|
+
// Register agent with AgentPay if it doesn't exist
|
|
293
|
+
await this.agentpayFetch("/api/agents", {
|
|
294
|
+
method: "POST",
|
|
295
|
+
body: JSON.stringify({ agentId: this.agentId, name: this.agentId }),
|
|
296
|
+
}).catch(() => { });
|
|
297
|
+
this.emit("ready");
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
this.emit("ready");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
log(msg) {
|
|
304
|
+
if (this.config.debug)
|
|
305
|
+
console.log(`[mnemopay:${this.agentId}] ${msg}`);
|
|
306
|
+
}
|
|
307
|
+
async mnemoFetch(path, init) {
|
|
308
|
+
const headers = { ...this.headers };
|
|
309
|
+
if (this.config.mnemoApiKey)
|
|
310
|
+
headers["Authorization"] = `Bearer ${this.config.mnemoApiKey}`;
|
|
311
|
+
const res = await fetch(`${this.config.mnemoUrl}${path}`, { ...init, headers: { ...headers, ...init?.headers } });
|
|
312
|
+
if (!res.ok) {
|
|
313
|
+
const body = await res.text().catch(() => "");
|
|
314
|
+
throw new Error(`Mnemosyne ${res.status}: ${body}`);
|
|
315
|
+
}
|
|
316
|
+
const text = await res.text();
|
|
317
|
+
return text ? JSON.parse(text) : null;
|
|
318
|
+
}
|
|
319
|
+
async agentpayFetch(path, init) {
|
|
320
|
+
const headers = { ...this.headers };
|
|
321
|
+
if (this.config.agentpayApiKey)
|
|
322
|
+
headers["Authorization"] = `Bearer ${this.config.agentpayApiKey}`;
|
|
323
|
+
const res = await fetch(`${this.config.agentpayUrl}${path}`, { ...init, headers: { ...headers, ...init?.headers } });
|
|
324
|
+
if (!res.ok) {
|
|
325
|
+
const body = await res.text().catch(() => "");
|
|
326
|
+
throw new Error(`AgentPay ${res.status}: ${body}`);
|
|
327
|
+
}
|
|
328
|
+
const text = await res.text();
|
|
329
|
+
return text ? JSON.parse(text) : null;
|
|
330
|
+
}
|
|
331
|
+
// ── Memory Methods (→ Mnemosyne API) ───────────────────────────────────
|
|
332
|
+
async remember(content, opts) {
|
|
333
|
+
const importance = opts?.importance ?? autoScore(content);
|
|
334
|
+
const result = await this.mnemoFetch("/v1/memory", {
|
|
335
|
+
method: "POST",
|
|
336
|
+
body: JSON.stringify({
|
|
337
|
+
content,
|
|
338
|
+
tier: "long_term",
|
|
339
|
+
metadata: {
|
|
340
|
+
memory_type: "OBSERVATION",
|
|
341
|
+
tags: opts?.tags ?? [],
|
|
342
|
+
confidence: importance,
|
|
343
|
+
},
|
|
344
|
+
}),
|
|
345
|
+
});
|
|
346
|
+
this.emit("memory:stored", { id: result.id, content, importance });
|
|
347
|
+
this.log(`Stored memory: "${content.slice(0, 60)}..." (id: ${result.id})`);
|
|
348
|
+
return result.id;
|
|
349
|
+
}
|
|
350
|
+
async recall(queryOrLimit, maybeLimit) {
|
|
351
|
+
const query = typeof queryOrLimit === "string" ? queryOrLimit : "*";
|
|
352
|
+
const limit = typeof queryOrLimit === "number" ? queryOrLimit : (maybeLimit ?? 5);
|
|
353
|
+
const result = await this.mnemoFetch("/v1/memory/search", {
|
|
354
|
+
method: "POST",
|
|
355
|
+
body: JSON.stringify({
|
|
356
|
+
query,
|
|
357
|
+
top_k: limit,
|
|
358
|
+
min_retrievability: 0.01,
|
|
359
|
+
}),
|
|
360
|
+
});
|
|
361
|
+
const memories = (result.results || []).map((r) => ({
|
|
362
|
+
id: r.id,
|
|
363
|
+
agentId: this.agentId,
|
|
364
|
+
content: r.content,
|
|
365
|
+
importance: r.retrievability ?? 0.5,
|
|
366
|
+
score: r.score ?? 0,
|
|
367
|
+
createdAt: new Date(r.created_at || Date.now()),
|
|
368
|
+
lastAccessed: new Date(),
|
|
369
|
+
accessCount: r.access_count ?? 0,
|
|
370
|
+
tags: r.tags ?? [],
|
|
371
|
+
}));
|
|
372
|
+
this.emit("memory:recalled", { count: memories.length });
|
|
373
|
+
this.log(`Recalled ${memories.length} memories`);
|
|
374
|
+
return memories;
|
|
375
|
+
}
|
|
376
|
+
async forget(id) {
|
|
377
|
+
try {
|
|
378
|
+
await this.mnemoFetch(`/v1/memory/${id}`, { method: "DELETE" });
|
|
379
|
+
this.log(`Forgot memory: ${id}`);
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
catch {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
async reinforce(id, boost = 0.1) {
|
|
387
|
+
await this.mnemoFetch(`/v1/memory/${id}/review`, {
|
|
388
|
+
method: "POST",
|
|
389
|
+
body: JSON.stringify({ grade: boost >= 0.15 ? 4 : 3 }),
|
|
390
|
+
});
|
|
391
|
+
this.log(`Reinforced memory ${id}`);
|
|
392
|
+
}
|
|
393
|
+
async consolidate() {
|
|
394
|
+
const result = await this.mnemoFetch("/v1/consolidate", {
|
|
395
|
+
method: "POST",
|
|
396
|
+
body: JSON.stringify({ namespace: `agent:${this.agentId}`, scope: "incremental", dry_run: false }),
|
|
397
|
+
});
|
|
398
|
+
const pruned = result?.phases?.prune?.pruned ?? 0;
|
|
399
|
+
this.log(`Consolidated: pruned ${pruned} stale memories`);
|
|
400
|
+
return pruned;
|
|
401
|
+
}
|
|
402
|
+
// ── Payment Methods (→ AgentPay API) ───────────────────────────────────
|
|
403
|
+
async charge(amount, reason) {
|
|
404
|
+
if (amount <= 0)
|
|
405
|
+
throw new Error("Amount must be positive");
|
|
406
|
+
const result = await this.agentpayFetch("/api/escrow", {
|
|
407
|
+
method: "POST",
|
|
408
|
+
body: JSON.stringify({
|
|
409
|
+
agentId: this.agentId,
|
|
410
|
+
amount,
|
|
411
|
+
reason,
|
|
412
|
+
currency: "USD",
|
|
413
|
+
}),
|
|
414
|
+
});
|
|
415
|
+
const tx = {
|
|
416
|
+
id: result.id,
|
|
417
|
+
agentId: this.agentId,
|
|
418
|
+
amount,
|
|
419
|
+
reason,
|
|
420
|
+
status: "pending",
|
|
421
|
+
createdAt: new Date(result.createdAt || Date.now()),
|
|
422
|
+
};
|
|
423
|
+
this.emit("payment:pending", { id: tx.id, amount, reason });
|
|
424
|
+
this.log(`Charge created: $${amount.toFixed(2)} for "${reason}"`);
|
|
425
|
+
return tx;
|
|
426
|
+
}
|
|
427
|
+
async settle(txId) {
|
|
428
|
+
const result = await this.agentpayFetch(`/api/escrow/${txId}/release`, {
|
|
429
|
+
method: "POST",
|
|
430
|
+
});
|
|
431
|
+
this.emit("payment:completed", { id: txId, amount: result.amount });
|
|
432
|
+
this.log(`Settled: $${result.amount?.toFixed(2)}`);
|
|
433
|
+
return {
|
|
434
|
+
id: txId,
|
|
435
|
+
agentId: this.agentId,
|
|
436
|
+
amount: result.amount,
|
|
437
|
+
reason: result.reason || "",
|
|
438
|
+
status: "completed",
|
|
439
|
+
createdAt: new Date(result.createdAt || Date.now()),
|
|
440
|
+
completedAt: new Date(),
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
async refund(txId) {
|
|
444
|
+
const result = await this.agentpayFetch(`/api/escrow/${txId}/refund`, {
|
|
445
|
+
method: "POST",
|
|
446
|
+
});
|
|
447
|
+
this.emit("payment:refunded", { id: txId });
|
|
448
|
+
this.log(`Refunded: ${txId}`);
|
|
449
|
+
return {
|
|
450
|
+
id: txId,
|
|
451
|
+
agentId: this.agentId,
|
|
452
|
+
amount: result.amount,
|
|
453
|
+
reason: result.reason || "",
|
|
454
|
+
status: "refunded",
|
|
455
|
+
createdAt: new Date(result.createdAt || Date.now()),
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
async balance() {
|
|
459
|
+
const result = await this.agentpayFetch(`/api/agents/${this.agentId}/wallet`);
|
|
460
|
+
return {
|
|
461
|
+
wallet: result.balance ?? 0,
|
|
462
|
+
reputation: result.reputation ?? 0.5,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
// ── Observability ─────────────────────────────────────────────────────
|
|
466
|
+
async profile() {
|
|
467
|
+
const [agentInfo, bal] = await Promise.all([
|
|
468
|
+
this.agentpayFetch(`/api/agents/${this.agentId}`).catch(() => null),
|
|
469
|
+
this.balance(),
|
|
470
|
+
]);
|
|
471
|
+
return {
|
|
472
|
+
id: this.agentId,
|
|
473
|
+
reputation: bal.reputation,
|
|
474
|
+
wallet: bal.wallet,
|
|
475
|
+
memoriesCount: agentInfo?.memoriesCount ?? 0,
|
|
476
|
+
transactionsCount: agentInfo?.transactionsCount ?? 0,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
async logs(limit = 50) {
|
|
480
|
+
const result = await this.agentpayFetch(`/api/events/audit?limit=${limit}`);
|
|
481
|
+
return (result.entries || result || []).map((e) => ({
|
|
482
|
+
id: e.id,
|
|
483
|
+
agentId: e.agentId || this.agentId,
|
|
484
|
+
action: e.action || e.type,
|
|
485
|
+
details: e.details || e.data || {},
|
|
486
|
+
createdAt: new Date(e.createdAt || e.timestamp || Date.now()),
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
async history(limit = 20) {
|
|
490
|
+
const result = await this.agentpayFetch(`/api/agents/${this.agentId}/transactions?limit=${limit}`);
|
|
491
|
+
return (result.transactions || result || []).map((t) => ({
|
|
492
|
+
id: t.id,
|
|
493
|
+
agentId: t.agentId || this.agentId,
|
|
494
|
+
amount: t.amount,
|
|
495
|
+
reason: t.reason || t.description || "",
|
|
496
|
+
status: t.status,
|
|
497
|
+
createdAt: new Date(t.createdAt || Date.now()),
|
|
498
|
+
completedAt: t.completedAt ? new Date(t.completedAt) : undefined,
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
async disconnect() {
|
|
502
|
+
this.log("Disconnected");
|
|
503
|
+
}
|
|
504
|
+
// ── Static factory methods ────────────────────────────────────────────
|
|
505
|
+
/**
|
|
506
|
+
* Zero-infrastructure mode. In-memory, no database, no Redis.
|
|
507
|
+
* Perfect for development, testing, and demos.
|
|
508
|
+
*/
|
|
509
|
+
static quick(agentId, opts) {
|
|
510
|
+
const recallConfig = opts?.recall
|
|
511
|
+
? {
|
|
512
|
+
strategy: opts.recall,
|
|
513
|
+
embeddingProvider: opts.embeddings,
|
|
514
|
+
openaiApiKey: opts.openaiApiKey,
|
|
515
|
+
scoreWeight: opts.scoreWeight,
|
|
516
|
+
vectorWeight: opts.vectorWeight,
|
|
517
|
+
}
|
|
518
|
+
: undefined;
|
|
519
|
+
return new MnemoPayLite(agentId, opts?.decay ?? 0.05, opts?.debug ?? false, recallConfig);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Production mode. Connects to Mnemosyne + AgentPay backends.
|
|
523
|
+
* Requires running services (use docker-compose.yml).
|
|
524
|
+
*/
|
|
525
|
+
static create(config) {
|
|
526
|
+
return new MnemoPay(config);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
exports.MnemoPay = MnemoPay;
|
|
530
|
+
// ─── Re-exports ─────────────────────────────────────────────────────────────
|
|
531
|
+
exports.default = MnemoPay;
|
|
532
|
+
var engine_js_2 = require("./recall/engine.js");
|
|
533
|
+
Object.defineProperty(exports, "RecallEngine", { enumerable: true, get: function () { return engine_js_2.RecallEngine; } });
|
|
534
|
+
Object.defineProperty(exports, "cosineSimilarity", { enumerable: true, get: function () { return engine_js_2.cosineSimilarity; } });
|
|
535
|
+
Object.defineProperty(exports, "localEmbed", { enumerable: true, get: function () { return engine_js_2.localEmbed; } });
|
|
536
|
+
Object.defineProperty(exports, "l2Normalize", { enumerable: true, get: function () { return engine_js_2.l2Normalize; } });
|
|
537
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA8pBM,8BAAS;AAAE,oCAAY;AA5pBhC,mCAAsC;AACtC,mCAAoC;AACpC,kDAAwH;AAkFxH,8EAA8E;AAE9E,MAAM,mBAAmB,GAA8C;IACrE,EAAE,OAAO,EAAE,6CAA6C,EAAE,KAAK,EAAE,IAAI,EAAE;IACvE,EAAE,OAAO,EAAE,iDAAiD,EAAE,KAAK,EAAE,IAAI,EAAE;IAC3E,EAAE,OAAO,EAAE,mDAAmD,EAAE,KAAK,EAAE,IAAI,EAAE;CAC9E,CAAC;AAEF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,SAAS,SAAS,CAAC,OAAe;IAChC,IAAI,KAAK,GAAG,eAAe,CAAC;IAC5B,IAAI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AC;AAExB,gDAA6F;AAApF,yGAAA,YAAY,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,wGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangGraph Tools — drop-in tools for createReactAgent.
|
|
3
|
+
*
|
|
4
|
+
* import { mnemoTools, agentPayTools } from "@mnemopay/sdk/langgraph";
|
|
5
|
+
* const graph = createReactAgent({ llm, tools: [...mnemoTools(agent), ...agentPayTools(agent)] });
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import type { MnemoPayLite, MnemoPay } from "../index.js";
|
|
9
|
+
type Agent = MnemoPayLite | MnemoPay;
|
|
10
|
+
/**
|
|
11
|
+
* Memory tools: recall, store, reinforce
|
|
12
|
+
*/
|
|
13
|
+
export declare function mnemoTools(agent: Agent): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
14
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
limit: number;
|
|
17
|
+
}, {
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
limit: number;
|
|
21
|
+
}, {
|
|
22
|
+
limit?: number | undefined;
|
|
23
|
+
}, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
24
|
+
content: z.ZodString;
|
|
25
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
content: string;
|
|
28
|
+
importance?: number | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
content: string;
|
|
31
|
+
importance?: number | undefined;
|
|
32
|
+
}>, {
|
|
33
|
+
content: string;
|
|
34
|
+
importance?: number | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
content: string;
|
|
37
|
+
importance?: number | undefined;
|
|
38
|
+
}, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
boost: z.ZodDefault<z.ZodNumber>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
boost: number;
|
|
43
|
+
id: string;
|
|
44
|
+
}, {
|
|
45
|
+
id: string;
|
|
46
|
+
boost?: number | undefined;
|
|
47
|
+
}>, {
|
|
48
|
+
boost: number;
|
|
49
|
+
id: string;
|
|
50
|
+
}, {
|
|
51
|
+
id: string;
|
|
52
|
+
boost?: number | undefined;
|
|
53
|
+
}, string>)[];
|
|
54
|
+
/**
|
|
55
|
+
* Payment tools: charge, settle, check balance
|
|
56
|
+
*/
|
|
57
|
+
export declare function agentPayTools(agent: Agent): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
58
|
+
amount: z.ZodNumber;
|
|
59
|
+
reason: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
amount: number;
|
|
62
|
+
reason: string;
|
|
63
|
+
}, {
|
|
64
|
+
amount: number;
|
|
65
|
+
reason: string;
|
|
66
|
+
}>, {
|
|
67
|
+
amount: number;
|
|
68
|
+
reason: string;
|
|
69
|
+
}, {
|
|
70
|
+
amount: number;
|
|
71
|
+
reason: string;
|
|
72
|
+
}, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
73
|
+
txId: z.ZodString;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
txId: string;
|
|
76
|
+
}, {
|
|
77
|
+
txId: string;
|
|
78
|
+
}>, {
|
|
79
|
+
txId: string;
|
|
80
|
+
}, {
|
|
81
|
+
txId: string;
|
|
82
|
+
}, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {}, {}, string>)[];
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/langgraph/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC;AAErC;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsEtC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;sIAkEzC"}
|