@mnemopay/sdk 0.7.5 → 0.8.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 CHANGED
@@ -1,230 +1,171 @@
1
- # @mnemopay/sdk
1
+ # MnemoPay
2
2
 
3
- **Session memory for Claude on AWS Bedrock, Google Vertex AI, Anthropic API, and Foundry.**
3
+ **Give your AI agents real superpowers.** Memory + Payments + Identity in one SDK.
4
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:
5
+ Your agent remembers every interaction, handles real money, builds reputation, and trades with other agents — all with a balanced double-entry ledger that never drifts by a penny.
33
6
 
34
7
  ```bash
35
8
  npm install @mnemopay/sdk
36
9
  ```
37
10
 
38
- ```typescript
39
- import { MnemoPay } from "@mnemopay/sdk";
11
+ ```ts
12
+ import MnemoPay from "@mnemopay/sdk";
40
13
 
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");
14
+ const agent = MnemoPay.quick("my-agent");
15
+
16
+ await agent.remember("User prefers monthly billing");
17
+ const tx = await agent.charge(25, "Monthly API access");
46
18
  await agent.settle(tx.id);
19
+ // Agent now has memory, money, and reputation. Ledger balanced.
47
20
  ```
48
21
 
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.
22
+ 330+ tests. Production-hardened. MIT licensed.
66
23
 
67
24
  ---
68
25
 
69
- ## Two Modes, One API
26
+ ## Why MnemoPay
70
27
 
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 |
28
+ AI agents can think. They can't remember or pay. MnemoPay fixes both.
75
29
 
76
- Switch by changing one line. No code rewrites.
30
+ | Problem | Without MnemoPay | With MnemoPay |
31
+ |---|---|---|
32
+ | Memory | Every session starts cold | Agent remembers everything — decays naturally, strengthens on use |
33
+ | Payments | Manual API calls, no escrow | Charge → escrow → settle → refund. Real money, real rails |
34
+ | Identity | No agent verification | KYA (Know Your Agent) with capability tokens and permissions |
35
+ | Trust | No reputation system | Agent FICO score that grows with successful transactions |
36
+ | Accounting | Hope the numbers are right | Double-entry ledger. Every debit has a credit. Always balances to zero |
37
+ | Fraud | Build your own | Velocity checks, anomaly detection, geo-enhanced risk scoring |
38
+ | Multi-agent | Not possible | `net.transact("buyer", "seller", 25, "API access")` — both agents remember |
77
39
 
78
40
  ---
79
41
 
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. |
42
+ ## Features
43
+
44
+ ### Memory (Neuroscience-backed)
45
+ - **Ebbinghaus forgetting curve** — memories decay over time, just like the brain
46
+ - **Hebbian reinforcement** successful transactions strengthen associated memories
47
+ - **Consolidation** — auto-prunes weak memories, keeps what matters
48
+ - **Semantic recall** find memories by relevance, not just recency
49
+ - **100KB per memory** store rich context, not just strings
50
+
51
+ ### Payments (Bank-grade math)
52
+ - **Double-entry bookkeeping** Luca Pacioli's 1494 system, 330+ tests proving it works
53
+ - **Escrow flow** — charge → hold → settle → refund (same as Stripe/Square)
54
+ - **Platform fee** — 1.9% on settlement (configurable, volume-tiered: 1.9% → 1.5% → 1.0%)
55
+ - **3 payment rails** — Paystack (Africa), Stripe (global), Lightning (BTC)
56
+ - **Penny-precise** stress-tested with 1,000 random transactions, fee + net = gross every time
57
+
58
+ ### Identity (KYA Compliance)
59
+ - **Agent identity** cryptographic keypairs, owner verification
60
+ - **Capability tokens** scoped permissions (charge, settle, refund, remember)
61
+ - **Spend limits** max per transaction, max total spend, counterparty whitelists
62
+ - **Kill switch** — revoke all tokens instantly
63
+
64
+ ### Fraud Detection (Geo-enhanced)
65
+ - **Velocity checks** per-minute, per-hour, per-day limits
66
+ - **Anomaly detection** — z-score + optional ML (Isolation Forest)
67
+ - **Geo-enhanced** country tracking, rapid-hop detection, currency mismatch, timezone anomalies
68
+ - **Geo trust** consistent location builds trust, dampens false positives
69
+ - **OFAC sanctions** hard blocks for sanctioned countries (KP, IR, SY, CU, RU)
70
+ - **Behavioral fingerprinting** — detects drift from agent's normal patterns
71
+
72
+ ### Multi-Agent Commerce
73
+ - **MnemoPayNetwork** — register agents, execute deals, shared memory context
74
+ - **One method** — `net.transact(buyer, seller, amount, reason)` handles everything
75
+ - **Both remember** — buyer and seller each store the deal in their memory
76
+ - **Supply chains** — 10-step agent chains, 100-agent marketplaces, all tested
108
77
 
109
78
  ---
110
79
 
111
- ## Provider Middlewares
80
+ ## Payment Rails
81
+
82
+ MnemoPay supports real money movement through pluggable payment rails:
112
83
 
113
- ### Anthropic (invisible memory)
84
+ ```ts
85
+ import { PaystackRail, StripeRail, LightningRail } from "@mnemopay/sdk";
114
86
 
115
- Drop-in wrapper for `@anthropic-ai/sdk`. Works with Bedrock and Vertex clients too — anything that uses the same interface.
87
+ // Africa (NGN, GHS, ZAR, KES)
88
+ const paystack = new PaystackRail(process.env.PAYSTACK_SECRET_KEY!);
116
89
 
117
- ```typescript
118
- import Anthropic from "@anthropic-ai/sdk";
119
- import { MnemoPay } from "@mnemopay/sdk";
120
- import { AnthropicMiddleware } from "@mnemopay/sdk/middleware/anthropic";
90
+ // Global (USD, EUR, GBP — cards)
91
+ const stripe = new StripeRail(process.env.STRIPE_SECRET_KEY!);
121
92
 
122
- const agent = MnemoPay.quick("claude-agent");
123
- const ai = AnthropicMiddleware.wrap(new Anthropic(), agent);
93
+ // Crypto (BTC via Lightning Network)
94
+ const lightning = new LightningRail(LND_URL, MACAROON);
124
95
 
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
- });
96
+ // Plug into any agent
97
+ const agent = MnemoPay.quick("my-agent", { paymentRail: paystack });
131
98
  ```
132
99
 
133
- ### OpenAI (invisible memory)
100
+ ### Paystack Rail (Built for Africa)
101
+ - Initialize → checkout → verify flow
102
+ - Charge saved cards (authorization codes)
103
+ - Bank transfers / payouts
104
+ - Webhook HMAC-SHA512 verification
105
+ - Bank account resolution
106
+ - 23 Nigerian banks pre-mapped
134
107
 
135
- ```typescript
136
- import OpenAI from "openai";
137
- import { MnemoPay } from "@mnemopay/sdk";
138
- import { MnemoPayMiddleware } from "@mnemopay/sdk/middleware/openai";
108
+ ### Fee Structure
139
109
 
140
- const agent = MnemoPay.quick("assistant");
141
- const ai = MnemoPayMiddleware.wrap(new OpenAI(), agent);
110
+ | Tier | Monthly Volume | Platform Fee |
111
+ |---|---|---|
112
+ | Standard | < $10,000 | 1.9% |
113
+ | Growth | $10,000 - $100,000 | 1.5% |
114
+ | Scale | $100,000+ | 1.0% |
142
115
 
143
- const res = await ai.chat.completions.create({
144
- model: "gpt-4o",
145
- messages: [{ role: "user", content: "What do you remember?" }],
146
- });
147
- ```
116
+ Fees are automatically tiered based on cumulative settled volume per agent.
148
117
 
149
118
  ---
150
119
 
151
- ## LangGraph Tools
120
+ ## MCP Server
152
121
 
153
- ```typescript
154
- import { createReactAgent } from "@langchain/langgraph/prebuilt";
155
- import { MnemoPay } from "@mnemopay/sdk";
156
- import { mnemoTools, agentPayTools } from "@mnemopay/sdk/langgraph";
122
+ MnemoPay runs as an MCP server, giving Claude and other AI assistants direct access:
157
123
 
158
- const agent = MnemoPay.quick("langgraph-agent");
159
- const graph = createReactAgent({
160
- llm,
161
- tools: [...mnemoTools(agent), ...agentPayTools(agent)],
162
- });
124
+ ```bash
125
+ npx @mnemopay/sdk init
126
+ # or
127
+ claude mcp add mnemopay -s user -- npx -y @mnemopay/sdk
163
128
  ```
164
129
 
165
- 6 tools with full Zod schemas: `recall_memories`, `store_memory`, `reinforce_memory`, `charge_user`, `settle_payment`, `check_balance`.
130
+ Available tools: `charge`, `settle`, `refund`, `remember`, `recall`, `balance`, `history`, `profile`, `reputation`, `fraud_stats`, `dispute`, `reinforce`, `consolidate`, `forget`, `logs`.
166
131
 
167
132
  ---
168
133
 
169
- ## The Memory-Payment Feedback Loop
134
+ ## Middleware
170
135
 
171
- The payment rails are optional, but they unlock a core differentiator: payment outcomes reinforce the memories that led to successful decisions.
136
+ Drop MnemoPay into your existing AI stack:
172
137
 
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
- ```
138
+ ```ts
139
+ // OpenAI
140
+ import { mnemoPayMiddleware } from "@mnemopay/sdk/middleware/openai";
182
141
 
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.
142
+ // Anthropic
143
+ import { mnemoPayMiddleware } from "@mnemopay/sdk/middleware/anthropic";
184
144
 
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
145
+ // LangGraph
146
+ import { mnemoPayTools } from "@mnemopay/sdk/langgraph";
198
147
  ```
199
148
 
200
149
  ---
201
150
 
202
- ## Production Setup
151
+ ## Multi-Agent Example
203
152
 
204
- ```bash
205
- docker compose up -d # Starts Mnemosyne + AgentPay + Postgres + Redis
206
- ```
153
+ ```ts
154
+ import { MnemoPayNetwork } from "@mnemopay/sdk";
207
155
 
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
- ```
156
+ const net = new MnemoPayNetwork({ fraud: { platformFeeRate: 0.019 } });
221
157
 
222
- Optional peer dependencies — install only what you use:
158
+ // Register agents
159
+ net.register("buyer-bot", "owner-1", "dev@company.com");
160
+ net.register("seller-bot", "owner-2", "dev@company.com");
223
161
 
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
162
+ // Execute a deal — both agents remember, seller gets paid, ledger balances
163
+ const deal = await net.transact("buyer-bot", "seller-bot", 25, "API access for 1 month");
164
+
165
+ console.log(deal.netAmount); // 24.52 (after 1.9% fee)
166
+ console.log(deal.platformFee); // 0.48
167
+ console.log(deal.buyerMemoryId); // buyer remembers the purchase
168
+ console.log(deal.sellerMemoryId);// seller remembers the sale
228
169
  ```
229
170
 
230
171
  ---
@@ -232,64 +173,94 @@ npm install @langchain/langgraph @langchain/core @langchain/openai # For LangGr
232
173
  ## Architecture
233
174
 
234
175
  ```
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
176
+ ┌─────────────────────────────────────────────────┐
177
+ │ MnemoPay SDK │
178
+ ├──────────┬──────────┬───────────┬───────────────┤
179
+ │ Memory │ Payments │ Identity │ Fraud Guard │
180
+ │ │ │ │ │
181
+ remember │ charge │ KYA │ velocity
182
+ │ recall │ settle │ tokens │ anomaly │
183
+ reinforce│ refund │ perms │ geo-enhanced │
184
+ │ forget │ dispute │ killswitch│ ML (optional) │
185
+ ├──────────┴──────────┴───────────┴───────────────┤
186
+ │ Double-Entry Ledger │
187
+ │ debit + credit = always zero │
188
+ ├─────────────────────────────────────────────────┤
189
+ │ Payment Rails │
190
+ │ Paystack │ Stripe │ Lightning │
191
+ └─────────────────────────────────────────────────┘
243
192
  ```
244
193
 
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
194
  ---
249
195
 
250
- ## Integration Support
196
+ ## Persistence
251
197
 
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 |
198
+ ```ts
199
+ // File-based (default)
200
+ const agent = MnemoPay.quick("my-agent", { persistDir: "./data" });
263
201
 
264
- ---
202
+ // SQLite (production)
203
+ import { SQLiteStorage } from "@mnemopay/sdk/storage";
204
+ const storage = new SQLiteStorage("./mnemopay.db");
265
205
 
266
- ## Pricing
206
+ // Everything persists: memories, transactions, identity, fraud state, geo profiles
207
+ ```
267
208
 
268
- MnemoPay SDK is free and MIT-licensed. Self-hosting is always free.
209
+ ---
269
210
 
270
- For teams that want managed hosting, SLA support, or enterprise onboarding:
211
+ ## API Reference
271
212
 
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 |
213
+ ### Core Methods
214
+
215
+ | Method | Description |
216
+ |---|---|
217
+ | `agent.remember(content, opts?)` | Store a memory with importance scoring |
218
+ | `agent.recall(limit?, query?)` | Retrieve memories by relevance |
219
+ | `agent.charge(amount, reason)` | Create an escrow hold |
220
+ | `agent.settle(txId, counterpartyId?)` | Release escrow, apply fee, complete payment |
221
+ | `agent.refund(txId)` | Reverse a completed or pending transaction |
222
+ | `agent.dispute(txId, reason)` | File a dispute against a settled transaction |
223
+ | `agent.balance()` | Get wallet balance and reputation |
224
+ | `agent.verifyLedger()` | Confirm double-entry ledger balances to zero |
225
+ | `agent.history(limit?)` | Get transaction history |
226
+ | `agent.consolidate()` | Prune stale memories |
227
+
228
+ ### Network Methods
278
229
 
279
- Contact: [github.com/mnemopay](https://github.com/mnemopay)
230
+ | Method | Description |
231
+ |---|---|
232
+ | `net.register(agentId, ownerId, email)` | Register an agent on the network |
233
+ | `net.transact(buyer, seller, amount, reason)` | Full deal: charge → settle → memory → identity |
234
+ | `net.refundDeal(dealId)` | Reverse a deal, both agents remember the refund |
235
+ | `net.stats()` | Network-wide statistics |
236
+ | `net.dealsBetween(agentA, agentB)` | Get deal history between two agents |
280
237
 
281
238
  ---
282
239
 
283
- ## Tests
240
+ ## Testing
284
241
 
285
242
  ```bash
286
- npm test # 143 tests covering memory, payments, feedback loop, security, concurrency
243
+ npm test # Run all 330+ tests
244
+ npm run lint # Type check
287
245
  ```
288
246
 
247
+ Test coverage:
248
+ - `core.test.ts` — 67 tests (memory, payments, lifecycle)
249
+ - `fraud.test.ts` — 43 tests (velocity, anomaly, fees, disputes)
250
+ - `geo-fraud.test.ts` — 20 tests (geo signals, trust, sanctions)
251
+ - `identity.test.ts` — 44 tests (KYA, tokens, permissions)
252
+ - `ledger.test.ts` — 21 tests (double-entry, reconciliation)
253
+ - `network.test.ts` — 22 tests (multi-agent, deals, supply chains)
254
+ - `paystack.test.ts` — 46 tests (rail, webhooks, transfers)
255
+ - `stress.test.ts` — 32 tests (1000-cycle precision, parallel ops)
256
+ - `recall.test.ts` — 35 tests (semantic search, decay, reinforcement)
257
+
289
258
  ---
290
259
 
291
260
  ## License
292
261
 
293
- **MIT** — use it in commercial products, enterprise deployments, forks, anything. No AGPL restrictions.
262
+ MIT
263
+
264
+ ---
294
265
 
295
- Built by [J&B Enterprise LLC](https://github.com/mnemopay)
266
+ Built by [Jerry Omiagbo](https://github.com/mnemopay)
package/dist/fraud.d.ts CHANGED
@@ -7,9 +7,17 @@
7
7
  */
8
8
  import { IsolationForest, TransactionGraph, BehaviorProfile } from "./fraud-ml.js";
9
9
  import type { CollusionSignal, BehaviorSnapshot } from "./fraud-ml.js";
10
+ export interface FeeTier {
11
+ /** Minimum cumulative settled volume (USD) to qualify */
12
+ minVolume: number;
13
+ /** Fee rate for this tier */
14
+ rate: number;
15
+ }
10
16
  export interface FraudConfig {
11
- /** Platform fee rate on settle (0.03 = 3%). Default 0.03 */
17
+ /** Platform fee rate on settle (0.019 = 1.9%). Default 0.019. Used when no tiers match. */
12
18
  platformFeeRate: number;
19
+ /** Volume-based fee tiers (sorted by minVolume ascending). Overrides platformFeeRate when agent qualifies. */
20
+ feeTiers: FeeTier[];
13
21
  /** Max charges per minute per agent. Default 5 */
14
22
  maxChargesPerMinute: number;
15
23
  /** Max charges per hour per agent. Default 30 */
@@ -38,6 +46,8 @@ export interface FraudConfig {
38
46
  blockedCountries: string[];
39
47
  /** Enable ML fraud detection (Isolation Forest, graph analysis, behavioral fingerprinting). Default false */
40
48
  ml: boolean;
49
+ /** Geo-enhanced fraud detection config */
50
+ geo: GeoFraudConfig;
41
51
  }
42
52
  export declare const DEFAULT_FRAUD_CONFIG: FraudConfig;
43
53
  export interface FraudSignal {
@@ -86,6 +96,40 @@ export interface RequestContext {
86
96
  country?: string;
87
97
  userAgent?: string;
88
98
  sessionId?: string;
99
+ /** UTC offset in hours (e.g., +1 for WAT, -5 for CDT) */
100
+ utcOffset?: number;
101
+ /** Currency code associated with this request's region */
102
+ currency?: string;
103
+ }
104
+ /** Per-agent geographic behavior profile */
105
+ export interface GeoProfile {
106
+ /** First country seen — established as "home" after 5+ transactions */
107
+ homeCountry?: string;
108
+ /** All countries seen, with transaction counts */
109
+ countryCounts: Record<string, number>;
110
+ /** Country of last transaction */
111
+ lastCountry?: string;
112
+ /** Timestamps of country changes (for rapid-hop detection) */
113
+ countryChanges: number[];
114
+ /** Total transactions tracked for this profile */
115
+ totalTxCount: number;
116
+ /** Geo trust score 0-1 (higher = more consistent location = less suspicious) */
117
+ trustScore: number;
118
+ }
119
+ /** Geo-specific fraud config. All thresholds designed to FLAG, not BLOCK. */
120
+ export interface GeoFraudConfig {
121
+ /** Enable geo-enhanced fraud signals. Default: true */
122
+ enabled: boolean;
123
+ /** Min transactions before establishing home country. Default: 5 */
124
+ homeCountryThreshold: number;
125
+ /** Country changes in 24h to trigger rapid-hop signal. Default: 3 */
126
+ rapidHopThreshold: number;
127
+ /** High-risk country corridors (pairs). Default: common AML corridors */
128
+ highRiskCorridors: [string, string][];
129
+ /** OFAC/sanctions blocked countries. These BLOCK, not just flag. */
130
+ sanctionedCountries: string[];
131
+ /** Currency-to-country region map for mismatch detection */
132
+ currencyRegions: Record<string, string[]>;
89
133
  }
90
134
  export declare class FraudGuard {
91
135
  readonly config: FraudConfig;
@@ -99,12 +143,16 @@ export declare class FraudGuard {
99
143
  private feeLedger;
100
144
  /** Total platform fees collected */
101
145
  private _platformFeesCollected;
146
+ /** Cumulative settled volume per agent (for tiered pricing) */
147
+ private agentSettledVolume;
102
148
  /** Known IPs per agent for consistency checks */
103
149
  private agentIps;
104
150
  /** Flagged agents (soft block — allowed but monitored) */
105
151
  private flaggedAgents;
106
152
  /** Hard-blocked agents */
107
153
  private blockedAgents;
154
+ /** Per-agent geo behavior profiles */
155
+ private geoProfiles;
108
156
  /** ML anomaly detection — only loaded when ml: true */
109
157
  readonly isolationForest: IsolationForest | null;
110
158
  /** Transaction graph — only loaded when ml: true */
@@ -130,8 +178,18 @@ export declare class FraudGuard {
130
178
  detectCollusion(): CollusionSignal[];
131
179
  /** Get an agent's behavioral baseline (requires ml: true) */
132
180
  getAgentBaseline(agentId: string): BehaviorSnapshot | undefined;
181
+ /**
182
+ * Get the effective fee rate for an agent based on cumulative settled volume.
183
+ * Higher volume = lower fees (loyalty reward for active agents).
184
+ */
185
+ getEffectiveFeeRate(agentId: string): number;
186
+ /**
187
+ * Get an agent's cumulative settled volume.
188
+ */
189
+ getAgentVolume(agentId: string): number;
133
190
  /**
134
191
  * Calculate and record platform fee for a settlement.
192
+ * Uses volume-based tiered pricing when configured.
135
193
  * Returns { grossAmount, feeAmount, netAmount }.
136
194
  */
137
195
  applyPlatformFee(txId: string, agentId: string, grossAmount: number): PlatformFeeRecord;
@@ -176,6 +234,22 @@ export declare class FraudGuard {
176
234
  openDisputes: number;
177
235
  platformFeesCollected: number;
178
236
  };
237
+ /**
238
+ * Assess geo-related risk signals for a transaction.
239
+ * Design: all signals are LOW weight (0.1-0.35) so they NEVER block alone.
240
+ * Only sanctioned countries use critical weight (0.9).
241
+ * Agents build geo trust over time, dampening signals further.
242
+ */
243
+ private assessGeo;
244
+ /**
245
+ * Update geo profile after a successful charge.
246
+ * Builds geo trust over time — consistent location = higher trust.
247
+ */
248
+ updateGeoProfile(agentId: string, ctx?: RequestContext): void;
249
+ /** Get or create a geo profile for an agent */
250
+ private getOrCreateGeoProfile;
251
+ /** Get an agent's geo profile (for diagnostics/display) */
252
+ getGeoProfile(agentId: string): GeoProfile | undefined;
179
253
  serialize(): string;
180
254
  static deserialize(json: string, config?: Partial<FraudConfig>): FraudGuard;
181
255
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fraud.d.ts","sourceRoot":"","sources":["../src/fraud.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAIpF,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iDAAiD;IACjD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,8EAA8E;IAC9E,qBAAqB,EAAE,MAAM,CAAC;IAC9B,qFAAqF;IACrF,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sEAAsE;IACtE,cAAc,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,aAAa,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,+DAA+D;IAC/D,sBAAsB,EAAE,MAAM,CAAC;IAC/B,6DAA6D;IAC7D,cAAc,EAAE,OAAO,CAAC;IACxB,+CAA+C;IAC/C,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,6GAA6G;IAC7G,EAAE,EAAE,OAAO,CAAC;CACb;AAED,eAAO,MAAM,oBAAoB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