@m2msentinel/sdk 1.2.2 → 1.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 M2M Sentinel
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 CHANGED
@@ -1,146 +1,152 @@
1
- # M2M Sentinel SDKs
1
+ # M2M Sentinel SDK & MCP Server
2
2
 
3
- Production API Base URL: `https://api.m2msentinel.com` (with fallback `https://m2msentinel.com`).
3
+ Official multi-language client library, **Model Context Protocol (MCP) server**, and **Coinbase AgentKit ActionProvider** for M2M Sentinel — deterministic EVM bytecode capability observations and common-proxy resolution for autonomous applications operating on Base. Callers own transaction policy.
4
4
 
5
- Deterministic EVM bytecode and proxy capability intelligence on Base. Factual static capability observation — not a formal reachability audit, safety guarantee, or transaction advice. Live latency depends on RPC availability and deployment geography; transaction middleware requires a caller-defined policy and has no built-in decision threshold.
5
+ [![npm version](https://img.shields.io/npm/v/m2m-sentinel-sdk.svg)](https://www.npmjs.com/package/m2m-sentinel-sdk)
6
+ [![PyPI version](https://img.shields.io/pypi/v/m2m-sentinel.svg)](https://pypi.org/project/m2m-sentinel/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+ [![Smithery](https://smithery.ai/badge/m2m-sentinel-sdk)](https://smithery.ai/server/m2m-sentinel-sdk)
6
9
 
7
10
  ---
8
11
 
9
- ## 🏗️ Recommended Defense-in-Depth Pipeline for Agents
10
-
11
- Autonomous agents handling value must never rely on a single oracle or heuristic. M2M Sentinel can supply static observations as Layer 1 of a caller-owned pipeline:
12
-
13
- ```text
14
- [Agent Intent]
15
-
16
-
17
- [Transaction Builder]
18
-
19
-
20
- [Stage 1: M2M Sentinel Observation] ── (Bytecode hash, proxy target, selected opcode/selector evidence)
21
-
22
-
23
- [Stage 2: Local Policy Engine] ── (Caller-defined rules: Check spending bounds, reject DELEGATECALL, verify allowlist)
24
-
25
-
26
- [Stage 3: Execution Simulation] ── (eth_call / Tenderly / Trace state simulation)
27
-
28
-
29
- [Stage 4: Sub-Wallet Signing] ── (Scoped ephemeral wallet signs & broadcasts on Base)
30
- ```
31
-
32
- ---
33
-
34
- ## Installation
12
+ ## 1. Model Context Protocol (MCP) Server
35
13
 
36
- ### JavaScript / TypeScript (npm)
14
+ Connect M2M Sentinel directly to **Claude Desktop**, **Cursor**, **Windsurf**, or any MCP-compliant LLM agent.
37
15
 
16
+ ### Option A: 1-Click via Smithery
38
17
  ```bash
39
- # Scoped package (recommended)
40
- npm install @m2msentinel/sdk
18
+ npx -y @smithery/cli mcp add M2M-Sentinel/m2m-sentinel-sdk --client claude
19
+ ```
41
20
 
42
- # Or unscoped package
43
- npm install m2m-sentinel-sdk@1.2.2
21
+ ### Option B: Local Stdio (`claude_desktop_config.json`)
22
+ ```json
23
+ {
24
+ "mcpServers": {
25
+ "m2m-sentinel": {
26
+ "command": "npx",
27
+ "args": ["-y", "m2m-sentinel-sdk"],
28
+ "env": {
29
+ "M2M_SENTINEL_API_KEY": ""
30
+ }
31
+ }
32
+ }
33
+ }
44
34
  ```
45
35
 
46
- ### Python (PyPI)
36
+ ### Option C: Remote Streamable HTTP
37
+ * **Current MCP endpoint**: `https://api.m2msentinel.com/mcp`
38
+ * **Legacy HTTP+SSE compatibility**: `https://api.m2msentinel.com/sse` with messages at `https://api.m2msentinel.com/messages`
47
39
 
48
- ```bash
49
- pip install m2m-sentinel==1.2.2
50
- ```
40
+ ---
51
41
 
52
- ### MCP Server (Model Context Protocol)
42
+ ## 🤖 2. Coinbase AgentKit Integration
53
43
 
54
- ```bash
55
- npx -y @m2msentinel/sdk
56
- # or
57
- npx -y m2m-sentinel-sdk
44
+ ```typescript
45
+ import { AgentKit } from "@coinbase/agentkit";
46
+ import { m2mSentinelActionProvider } from "m2m-sentinel-sdk";
47
+
48
+ const agentKit = await AgentKit.from({
49
+ walletProvider,
50
+ actionProviders: [
51
+ m2mSentinelActionProvider({
52
+ apiKey: process.env.M2M_SENTINEL_API_KEY
53
+ })
54
+ ]
55
+ });
58
56
  ```
59
57
 
60
58
  ---
61
59
 
62
- ## Quickstart: JavaScript / TypeScript
60
+ ## 📦 3. JavaScript / TypeScript Client
61
+
62
+ ```bash
63
+ npm install m2m-sentinel-sdk
64
+ ```
63
65
 
64
66
  ```javascript
65
- const { M2MSentinelClient, X402SignerClient } = require('@m2msentinel/sdk');
67
+ const { M2MSentinelClient } = require('m2m-sentinel-sdk');
66
68
 
67
- // 1. Standard API Client (Header Authentication)
68
- const client = new M2MSentinelClient({
69
- apiKey: process.env.M2M_SENTINEL_API_KEY,
70
- baseUrl: 'https://api.m2msentinel.com'
71
- });
69
+ const client = new M2MSentinelClient();
72
70
 
73
- // Inspect contract capabilities before transaction
74
- const audit = await client.auditContract('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913');
75
- console.log('Contract capabilities:', audit.audit.verdict.executableCapabilities);
76
- console.log('Capability evidence:', audit.audit.dissection.capabilities);
77
- console.log('Proxy Target:', audit.audit.proxyResolution.targetAddress);
78
- console.log('Reachability:', audit.audit.reachability || 'NOT_ESTABLISHED');
79
-
80
- // 2. Autonomous Headless x402 Micropayments (EIP-3009 Local Signing)
81
- const x402Client = new X402SignerClient({
82
- walletSigner: myAgentWallet, // ethers / viem signer
83
- baseUrl: 'https://api.m2msentinel.com',
84
- maxPriceUsd: 0.01 // Optional: strict spending limit (default $0.05)
85
- });
71
+ async function main() {
72
+ const audit = await client.auditContract('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913');
73
+ console.log('Proxy Detected:', audit.audit.proxyResolution.isProxy);
74
+ console.log('Proxy Target:', audit.audit.proxyResolution.targetAddress);
75
+ console.log('Capabilities:', audit.audit.verdict.executableCapabilities);
76
+ console.log('Evidence:', audit.audit.dissection.capabilities);
77
+ }
86
78
 
87
- const res = await x402Client.fetchWithAutoPayment('/v1/audit/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913');
88
- console.log('Paid analysis result:', res.json);
79
+ main().catch(console.error);
89
80
  ```
90
81
 
91
82
  ---
92
83
 
93
- ## 🛡️ Autonomous Wallet Policy & Security Boundaries
84
+ ## 🛡️ Base Account `wallet_sendCalls` Guard
94
85
 
95
- To prevent autonomous AI agents from blindly signing arbitrary or spoofed HTTP 402 challenges from untrusted sources, `X402SignerClient` enforces **4 strict client-side invariants** locally before generating any cryptographic signature:
86
+ The public SDK includes `guardWalletSendCalls`, a customer-side execution-identity
87
+ boundary for Base Account / EIP-5792 batches. It preflights the anchor call and
88
+ evaluates its caller policy before scheduling any remaining call, then pins
89
+ remaining calls to the first trusted block identity in waves of at most four.
90
+ Each settled wave is validated and policy-checked in ascending request-index
91
+ order before a later wave starts; a failure or rejection stops later scheduling.
92
+ The original detached request is forwarded only after all checks pass. It does
93
+ not sign, broadcast, custody funds, infer inner UserOperation semantics, or
94
+ make a safety claim. See `examples/base_account_paymaster_guard.js` for a no-network fixture.
96
95
 
97
- | Client Invariant | Enforced Value | Security Protection |
98
- | :--- | :--- | :--- |
99
- | **Chain ID** | `8453` (Base Mainnet) | Rejects signing on any unapproved EVM chain. |
100
- | **Asset Contract** | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` | Rejects signing for unapproved tokens (Base USDC only). |
101
- | **Payout Recipient** | `0x6d6c398390cfb88f1cd42715b84906a0bd6652aa` | Rejects signing payments to unexpected recipient addresses. |
102
- | **Price Ceiling** | `maxPriceUsd` (Default: `$0.05`) | Throws if remote challenge requests funds exceeding caller's authorized ceiling. |
96
+ ---
103
97
 
104
- ```javascript
105
- import { X402SignerClient } from '@m2msentinel/sdk';
98
+ ## 🐍 4. Python Client
106
99
 
107
- // Fully policy-constrained autonomous signer with immutable recipient & domain constants
108
- const signer = new X402SignerClient({
109
- wallet: agentWallet,
110
- maxPriceUsd: 0.005 // Strict spending limit: 0.5 cents max per decision (default $0.05)
111
- });
100
+ ```bash
101
+ pip install m2m-sentinel
102
+ ```
103
+
104
+ ```python
105
+ from m2m_sentinel import M2MSentinelClient
106
+
107
+ client = M2MSentinelClient()
108
+ audit = client.audit_contract("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913")
109
+ print("Proxy detected:", audit["audit"]["proxyResolution"]["isProxy"])
110
+ print("Proxy target:", audit["audit"]["proxyResolution"].get("targetAddress"))
111
+ print("Capabilities:", audit["audit"]["verdict"]["executableCapabilities"])
112
+ print("Evidence:", audit["audit"]["dissection"]["capabilities"])
112
113
  ```
113
114
 
114
115
  ---
115
116
 
116
- ## Authentication and x402
117
+ ## Transaction-specific preflight example
117
118
 
118
- Send API keys only in `x-api-key` (or `Authorization: Bearer`). Query-string credentials are rejected with HTTP 401. Payable routes also support x402 v2 on Base USDC. An unpaid call returns a base64 `PAYMENT-REQUIRED` challenge; a successful settlement returns `PAYMENT-RESPONSE`.
119
+ The public repository includes a standalone, mock-only transaction boundary
120
+ example at [`examples/transaction_preflight.js`](examples/transaction_preflight.js).
121
+ From this repository root, run:
119
122
 
120
- ---
123
+ ```bash
124
+ node examples/transaction_preflight.js
125
+ ```
121
126
 
122
- ## Public Routes
127
+ It observes one caller-supplied Base transaction, passes the observation to a
128
+ caller-owned policy, and reaches only a mock signing/send callback. It refuses
129
+ to continue on unverified evidence, unresolved execution, an observation
130
+ mismatch, or a missing Diamond selector mapping. It never signs or sends a
131
+ transaction; optional live mode uses only a caller-supplied API-key header and
132
+ remains the caller's responsibility.
123
133
 
124
- - `GET /v1/status`
125
- - `GET /v1/stats` (public privacy envelope; exact aggregate commercial counters are operator-only)
126
- - `GET /v1/plans`
127
- - `GET /v1/demo/audit/:address` for the published sample allowlist
128
- - `GET /v1/audit/:address` (requires API key or x402 payment)
134
+ ---
129
135
 
130
- The JavaScript, TypeScript, and Python clients expose multi-period purchase/renewal and wallet recovery without requiring callers to hand-build requests:
136
+ ## 💳 5. Autonomous x402 Micropayments (Headless M2M)
131
137
 
132
- ```javascript
133
- await client.createSubscriptionIntent('GROWTH', wallet, {
134
- durationDays: 90,
135
- renewExistingKey: true,
136
- apiKey: existingPaidKey
138
+ ```typescript
139
+ import { x402SignerClient } from "m2m-sentinel-sdk";
140
+
141
+ const client = new x402SignerClient({
142
+ walletSigner: myAgentWallet,
143
+ baseUrl: "https://api.m2msentinel.com"
137
144
  });
138
- const challenge = await client.createRecoveryChallenge(wallet, { txHash });
139
- await client.claimRecoveredKey(challenge.intent.id, walletSignature);
145
+
146
+ const result = await client.request("/v1/audit/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
140
147
  ```
141
148
 
142
149
  ---
143
150
 
144
- ## Disclaimer & Limitations
145
-
146
- Deterministic EVM bytecode and proxy capability intelligence on Base. Factual static capability observation — not a formal reachability audit, safety guarantee, or transaction advice. Live latency depends on RPC availability and deployment geography.
151
+ ## 📜 License
152
+ MIT License. Copyright (c) 2026 M2M Sentinel.
package/agent_adapter.js CHANGED
@@ -67,7 +67,7 @@ class M2MSentinelActionProvider {
67
67
 
68
68
  const headers = {
69
69
  Accept: 'application/json',
70
- 'User-Agent': 'M2MSentinel-AgentKit/1.2.2',
70
+ 'User-Agent': 'M2MSentinel-AgentKit/1.2.5',
71
71
  ...options.headers
72
72
  };
73
73
  if (this.apiKey && !headers['x-api-key']) {