kontext-sdk 0.5.0 → 0.5.2
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 +169 -60
- package/dist/cli.js +5452 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +5428 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.mts +55 -159
- package/dist/index.d.ts +55 -159
- package/dist/index.js +317 -454
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +314 -452
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -11
package/README.md
CHANGED
|
@@ -1,98 +1,207 @@
|
|
|
1
1
|
# kontext-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Compliance audit trail CLI and SDK for AI agents making stablecoin payments on Base.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**USDC** · **USDT** · **DAI** · **EURC** · **USDP** · **USDG** · **x402** · **Circle Programmable Wallets**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 30-Second Demo
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx kontext-sdk check 0xAgentWallet 0xMerchant --amount 5000 --token USDC
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
OFAC Sanctions: CLEAR
|
|
17
|
+
Travel Rule: TRIGGERED ($5,000 >= $3,000 EDD threshold)
|
|
18
|
+
CTR Threshold: CLEAR ($5,000 < $10,000)
|
|
19
|
+
Large TX Alert: CLEAR ($5,000 < $50,000)
|
|
20
|
+
Risk Level: medium
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
No install. No config. No API key. One command.
|
|
6
24
|
|
|
7
25
|
## Install
|
|
8
26
|
|
|
9
27
|
```bash
|
|
10
|
-
npm install kontext-sdk
|
|
28
|
+
npm install -g kontext-sdk
|
|
11
29
|
```
|
|
12
30
|
|
|
13
|
-
|
|
31
|
+
Then run `kontext` from anywhere. Or use `npx kontext-sdk` for one-off checks.
|
|
14
32
|
|
|
15
|
-
|
|
16
|
-
import { Kontext } from 'kontext-sdk';
|
|
33
|
+
## Claude Code / Cursor / Windsurf
|
|
17
34
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"kontext": {
|
|
39
|
+
"command": "npx",
|
|
40
|
+
"args": ["-y", "kontext-sdk", "mcp"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then ask: *"verify this USDC transaction for compliance"*
|
|
47
|
+
|
|
48
|
+
## CLI Commands
|
|
49
|
+
|
|
50
|
+
### `kontext check <from> <to>` — stateless compliance check
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx kontext-sdk check 0xSender 0xReceiver --amount 5000 --token USDC
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Instant OFAC screening + threshold checks. No state, no persistence.
|
|
57
|
+
|
|
58
|
+
### `kontext verify` — log + check + digest proof
|
|
23
59
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
60
|
+
```bash
|
|
61
|
+
npx kontext-sdk verify --tx 0xabc123 --amount 5000 --token USDC \
|
|
62
|
+
--from 0xAgent --to 0xMerchant --agent my-bot
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Runs compliance checks, logs the transaction, appends to the tamper-evident digest chain. Persists to `.kontext/` in the current directory.
|
|
66
|
+
|
|
67
|
+
### `kontext reason` — log agent reasoning
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx kontext-sdk reason "API returned data I need. Price within budget." \
|
|
71
|
+
--agent my-bot --session sess_abc --step 1
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### `kontext cert` — export compliance certificate
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx kontext-sdk cert --agent my-bot --output cert.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `kontext audit` — verify digest chain integrity
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx kontext-sdk audit --verify
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `kontext mcp` — MCP server mode
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npx kontext-sdk mcp
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Starts an MCP server on stdio for Claude Code, Cursor, and Windsurf.
|
|
93
|
+
|
|
94
|
+
### Flags
|
|
95
|
+
|
|
96
|
+
- `--json` on any command outputs structured JSON
|
|
97
|
+
- `--amount <number>` transaction amount in token units
|
|
98
|
+
- `--token <symbol>` one of USDC, USDT, DAI, EURC, USDP, USDG
|
|
99
|
+
|
|
100
|
+
## SDK — Programmatic Usage
|
|
101
|
+
|
|
102
|
+
For tighter integration, use the SDK directly:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { Kontext, FileStorage } from 'kontext-sdk';
|
|
106
|
+
|
|
107
|
+
const ctx = Kontext.init({
|
|
108
|
+
projectId: 'my-agent',
|
|
109
|
+
environment: 'production',
|
|
110
|
+
storage: new FileStorage('.kontext'),
|
|
29
111
|
});
|
|
30
112
|
|
|
31
|
-
//
|
|
32
|
-
await
|
|
113
|
+
// One-call: compliance check + transaction log + digest proof
|
|
114
|
+
const result = await ctx.verify({
|
|
33
115
|
txHash: '0xabc...',
|
|
34
116
|
chain: 'base',
|
|
35
|
-
amount: '
|
|
117
|
+
amount: '5000',
|
|
36
118
|
token: 'USDC',
|
|
37
|
-
from: '
|
|
38
|
-
to: '
|
|
39
|
-
agentId: 'payment-agent
|
|
119
|
+
from: '0xAgent...',
|
|
120
|
+
to: '0xMerchant...',
|
|
121
|
+
agentId: 'payment-agent',
|
|
40
122
|
});
|
|
41
123
|
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
124
|
+
// result.compliant = true/false
|
|
125
|
+
// result.checks = [{ name: 'OFAC Sanctions', passed: true }, ...]
|
|
126
|
+
// result.riskLevel = 'low' | 'medium' | 'high' | 'critical'
|
|
127
|
+
// result.digestProof = 'sha256:a1b2c3...'
|
|
128
|
+
```
|
|
45
129
|
|
|
46
|
-
|
|
47
|
-
const audit = await kontext.export({ format: 'json' });
|
|
130
|
+
### Log Reasoning
|
|
48
131
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
132
|
+
```typescript
|
|
133
|
+
await ctx.logReasoning({
|
|
134
|
+
agentId: 'payment-agent',
|
|
135
|
+
action: 'approve-transfer',
|
|
136
|
+
reasoning: 'Price within budget. Merchant verified.',
|
|
137
|
+
confidence: 0.95,
|
|
138
|
+
});
|
|
52
139
|
```
|
|
53
140
|
|
|
54
|
-
|
|
141
|
+
### Compliance Certificate
|
|
55
142
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- **Webhook Notifications** -- Event-driven webhooks for anomalies, task updates, and trust score changes with retry logic.
|
|
65
|
-
- **Audit Export** -- JSON and CSV export with date range and entity filtering.
|
|
66
|
-
- **SAR/CTR Templates** -- Structured report templates for suspicious activity and currency transaction reporting.
|
|
143
|
+
```typescript
|
|
144
|
+
const cert = await ctx.generateComplianceCertificate({
|
|
145
|
+
agentId: 'payment-agent',
|
|
146
|
+
includeReasoning: true,
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Trust Score
|
|
67
151
|
|
|
68
|
-
|
|
152
|
+
```typescript
|
|
153
|
+
const score = await ctx.getTrustScore('payment-agent');
|
|
154
|
+
// score.score = 87, score.level = 'high'
|
|
155
|
+
```
|
|
69
156
|
|
|
70
|
-
|
|
71
|
-
|----------|---------------|-------------|
|
|
72
|
-
| Ethereum | 0xA0b8...eB48 | 0 |
|
|
73
|
-
| Base | 0x8335...2913 | 6 |
|
|
74
|
-
| Polygon | 0x3c49...3359 | 7 |
|
|
75
|
-
| Arbitrum | 0xaf88...5831 | 3 |
|
|
76
|
-
| Optimism | 0x0b2C...Ff85 | 2 |
|
|
157
|
+
### Verify Digest Chain
|
|
77
158
|
|
|
78
|
-
|
|
159
|
+
```typescript
|
|
160
|
+
const chain = ctx.verifyDigestChain();
|
|
161
|
+
console.log(chain.valid); // true — no tampering
|
|
162
|
+
```
|
|
79
163
|
|
|
80
|
-
|
|
81
|
-
- **Cloud mode** (with API key): Data synced to Kontext API for persistent storage and advanced features.
|
|
164
|
+
### Persist Across Restarts
|
|
82
165
|
|
|
83
166
|
```typescript
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
projectId: 'my-
|
|
167
|
+
import { FileStorage } from 'kontext-sdk';
|
|
168
|
+
|
|
169
|
+
const ctx = Kontext.init({
|
|
170
|
+
projectId: 'my-agent',
|
|
88
171
|
environment: 'production',
|
|
172
|
+
storage: new FileStorage('.kontext'),
|
|
89
173
|
});
|
|
174
|
+
|
|
175
|
+
// Data persists to .kontext/ directory
|
|
176
|
+
// Call ctx.flush() to write, ctx.restore() to reload
|
|
90
177
|
```
|
|
91
178
|
|
|
92
|
-
##
|
|
179
|
+
## Compliance Thresholds
|
|
180
|
+
|
|
181
|
+
| Threshold | Amount | Trigger |
|
|
182
|
+
|-----------|--------|---------|
|
|
183
|
+
| **EDD / Travel Rule** | $3,000 | Enhanced Due Diligence required |
|
|
184
|
+
| **CTR** | $10,000 | Currency Transaction Report |
|
|
185
|
+
| **Large TX Alert** | $50,000 | Large Transaction Alert |
|
|
186
|
+
|
|
187
|
+
OFAC sanctions screening uses the built-in SDN list. No API key required.
|
|
93
188
|
|
|
94
|
-
|
|
189
|
+
## What's Included
|
|
190
|
+
|
|
191
|
+
- Tamper-evident audit trail (patented digest chain)
|
|
192
|
+
- OFAC sanctions screening (SDN list, no API key)
|
|
193
|
+
- Compliance certificates with SHA-256 proof
|
|
194
|
+
- Agent reasoning logs
|
|
195
|
+
- Trust scoring and anomaly detection
|
|
196
|
+
- MCP server mode for AI coding tools
|
|
197
|
+
- Zero runtime dependencies
|
|
95
198
|
|
|
96
199
|
## License
|
|
97
200
|
|
|
98
|
-
MIT
|
|
201
|
+
MIT
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
Kontext provides compliance logging tools. Regulatory responsibility remains with the operator. This software does not constitute legal advice and does not guarantee regulatory compliance. Consult qualified legal counsel for your specific obligations.
|
|
206
|
+
|
|
207
|
+
Built by [Legaci Labs](https://www.getkontext.com)
|