kontext-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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kontext / Legaci Labs Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @kontext/sdk
2
+
3
+ Trust and compliance layer for agentic crypto workflows.
4
+
5
+ Kontext provides structured action logging, tamper-evident audit trails, trust scoring, anomaly detection, and compliance tooling for AI agents operating in crypto and stablecoin ecosystems.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @kontext/sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { Kontext } from '@kontext/sdk';
17
+
18
+ // Initialize in local mode (no API key needed)
19
+ const kontext = Kontext.init({
20
+ projectId: 'my-project',
21
+ environment: 'development',
22
+ });
23
+
24
+ // Log an agent action
25
+ await kontext.log({
26
+ type: 'transfer',
27
+ description: 'Agent initiated USDC transfer',
28
+ agentId: 'payment-agent-1',
29
+ });
30
+
31
+ // Log a transaction with full chain details
32
+ await kontext.logTransaction({
33
+ txHash: '0xabc...',
34
+ chain: 'base',
35
+ amount: '100',
36
+ token: 'USDC',
37
+ from: '0xSender...',
38
+ to: '0xReceiver...',
39
+ agentId: 'payment-agent-1',
40
+ });
41
+
42
+ // Get trust score for an agent
43
+ const score = await kontext.getTrustScore('payment-agent-1');
44
+ console.log(`Trust: ${score.score}/100 (${score.level})`);
45
+
46
+ // Export audit data
47
+ const audit = await kontext.export({ format: 'json' });
48
+
49
+ // Verify digest chain integrity
50
+ const verification = kontext.verifyDigestChain();
51
+ console.log(`Chain valid: ${verification.valid}`);
52
+ ```
53
+
54
+ ## Features
55
+
56
+ - **Action Logging** -- Structured logging for all agent actions with timestamps, correlation IDs, and metadata.
57
+ - **Transaction Tracking** -- Full chain details for crypto transactions across Base, Ethereum, Polygon, Arbitrum, and Optimism.
58
+ - **Tamper-Evident Digest Chain** -- Rolling SHA-256 digest chain that detects any modification to the audit trail.
59
+ - **Trust Scoring** -- Rule-based trust scores for agents based on history, task completion, anomaly rate, and consistency.
60
+ - **Anomaly Detection** -- Configurable rules for unusual amounts, frequency spikes, new destinations, off-hours activity, rapid succession, and round amounts.
61
+ - **Task Confirmation** -- Evidence-based task tracking with required proof for completion.
62
+ - **USDC Compliance** -- Pre-built compliance checks aligned with stablecoin regulatory requirements across all supported chains.
63
+ - **CCTP Integration** -- Cross-chain transfer tracking for Circle's Cross-Chain Transfer Protocol with full lifecycle management.
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.
67
+
68
+ ## Supported Chains
69
+
70
+ | Chain | USDC Contract | CCTP Domain |
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 |
77
+
78
+ ## Operating Modes
79
+
80
+ - **Local mode** (no API key): All data stored in-memory and optionally written to local JSON files. Suitable for development and open-source usage.
81
+ - **Cloud mode** (with API key): Data synced to Kontext API for persistent storage and advanced features.
82
+
83
+ ```typescript
84
+ // Cloud mode
85
+ const kontext = Kontext.init({
86
+ apiKey: 'sk_live_...',
87
+ projectId: 'my-project',
88
+ environment: 'production',
89
+ });
90
+ ```
91
+
92
+ ## Documentation
93
+
94
+ For full documentation, visit [getkontext.com](https://getkontext.com).
95
+
96
+ ## License
97
+
98
+ MIT -- see [LICENSE](./LICENSE) for details.