m2m-sentinel-sdk 1.2.3 → 1.2.7
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 +106 -112
- package/agent_adapter.js +11 -23
- package/base_account_paymaster_guard.js +921 -0
- package/eliza_plugin.js +1 -1
- package/index.d.ts +244 -1
- package/index.js +3 -1
- package/langchain_tool.js +93 -0
- package/mcp_server.js +176 -84
- package/package.json +19 -3
- package/smithery.yaml +2 -2
- package/typescript/base_account_paymaster_guard.ts +284 -0
- package/typescript/index.ts +2 -0
- package/typescript/package-lock.json +50 -0
- package/typescript/package.json +6 -2
- package/typescript/tsconfig.json +13 -0
- package/typescript/x402.ts +1 -1
- package/x402_signer.js +1 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { M2MSentinelClient, TransactionPreflightRequest } from './index';
|
|
2
|
+
|
|
3
|
+
export interface WalletSendCallsCall {
|
|
4
|
+
to: string;
|
|
5
|
+
data: string;
|
|
6
|
+
/** Base Account uses canonical 0x quantities for call value. */
|
|
7
|
+
value?: string;
|
|
8
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
9
|
+
flowControl?: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface WalletSendCallsParams {
|
|
13
|
+
version: '1.0';
|
|
14
|
+
id?: string;
|
|
15
|
+
from: string;
|
|
16
|
+
/** Deliberately restricted to Base's canonical wallet_sendCalls value. */
|
|
17
|
+
chainId: '0x2105';
|
|
18
|
+
atomicRequired?: boolean;
|
|
19
|
+
calls: WalletSendCallsCall[];
|
|
20
|
+
capabilities?: Record<string, Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface WalletSendCallsRequest {
|
|
24
|
+
method: 'wallet_sendCalls';
|
|
25
|
+
params: [WalletSendCallsParams];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Eip1193Provider {
|
|
29
|
+
request(request: WalletSendCallsRequest): Promise<unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type BaseTrustLevel = 'HIGH_TRUST_PRIMARY' | 'QUORUM_PUBLIC';
|
|
33
|
+
|
|
34
|
+
export interface BaseObservationBlock {
|
|
35
|
+
status: 'PINNED';
|
|
36
|
+
chainId: number | string;
|
|
37
|
+
network: 'eip155:8453';
|
|
38
|
+
blockNumber: number | string;
|
|
39
|
+
blockHash: string;
|
|
40
|
+
blockTag: string;
|
|
41
|
+
trustLevel: BaseTrustLevel;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface BaseSimulationObservation {
|
|
46
|
+
attempted: true;
|
|
47
|
+
trusted: true;
|
|
48
|
+
outcome: 'NOT_ATTEMPTED' | 'SUCCEEDED' | 'REVERTED' | 'UNAVAILABLE' | 'MALFORMED';
|
|
49
|
+
blockTag: string;
|
|
50
|
+
evidenceOnly: true;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface BaseRpcObservation {
|
|
55
|
+
pinnedBlockTag: string;
|
|
56
|
+
stateBearingCallCount: number;
|
|
57
|
+
failedReadCount: 0;
|
|
58
|
+
failures: unknown[];
|
|
59
|
+
calls: BaseRpcObservationCall[];
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface BaseRpcObservationCall {
|
|
64
|
+
method?: string;
|
|
65
|
+
params?: unknown[];
|
|
66
|
+
blockTag?: string | null;
|
|
67
|
+
status?: 'OK' | 'UNSUPPORTED_OPTIONAL_METHOD' | 'EXECUTION_ERROR' | string;
|
|
68
|
+
trustLevel?: BaseTrustLevel | 'DEGRADED_LOW_TRUST';
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BaseCapabilityEvidence {
|
|
73
|
+
sourceAddress: string;
|
|
74
|
+
executionRole: 'RESOLVED_EXECUTING_CODE' | 'SELECTED_DIAMOND_FACET';
|
|
75
|
+
transactionSelector: string | null;
|
|
76
|
+
dissection: BaseDissection;
|
|
77
|
+
notASafetyGuarantee: true;
|
|
78
|
+
reachability: 'NOT_ESTABLISHED';
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface BaseDissectionCapability {
|
|
83
|
+
type: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface BaseDissection {
|
|
88
|
+
isValidContract: true;
|
|
89
|
+
bytecodeSizeBytes: number;
|
|
90
|
+
targetBytecodeHash: string;
|
|
91
|
+
capabilities: BaseDissectionCapability[];
|
|
92
|
+
detectedCapabilities: string[];
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface BaseBytecodeHashes {
|
|
97
|
+
runtimeBytecodeHash: string | null;
|
|
98
|
+
finalTargetBytecodeHash: string;
|
|
99
|
+
facetBytecodeHash: string | null;
|
|
100
|
+
facetBytecodeHashes: unknown[];
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface BaseAccountPreflightObservation {
|
|
105
|
+
status: 'SUCCESS';
|
|
106
|
+
operation: 'TRANSACTION_PREFLIGHT_OBSERVATION';
|
|
107
|
+
request: TransactionPreflightRequest;
|
|
108
|
+
selectorHex: string | null;
|
|
109
|
+
surfaceTarget: string;
|
|
110
|
+
resolvedExecutionTarget: string;
|
|
111
|
+
resolution: Record<string, unknown> & { status: 'COMPLETE'; resolutionComplete: true };
|
|
112
|
+
evidenceGrade: true;
|
|
113
|
+
evidenceStatus: 'VERIFIED';
|
|
114
|
+
effectiveTrust: BaseTrustLevel;
|
|
115
|
+
observationBlock: BaseObservationBlock;
|
|
116
|
+
simulationObservation: BaseSimulationObservation;
|
|
117
|
+
rpcObservation: BaseRpcObservation;
|
|
118
|
+
capabilityEvidence: BaseCapabilityEvidence;
|
|
119
|
+
bytecodeHashes: BaseBytecodeHashes;
|
|
120
|
+
notASafetyGuarantee: true;
|
|
121
|
+
reachability: 'NOT_ESTABLISHED';
|
|
122
|
+
limitations: string[];
|
|
123
|
+
conclusion: null;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface BaseAccountGuardContext {
|
|
128
|
+
callIndex: number;
|
|
129
|
+
index: number;
|
|
130
|
+
call: WalletSendCallsCall;
|
|
131
|
+
transaction: TransactionPreflightRequest;
|
|
132
|
+
request: WalletSendCallsRequest;
|
|
133
|
+
params: WalletSendCallsParams;
|
|
134
|
+
[key: string]: unknown;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type BaseAccountCallerPolicyResult =
|
|
138
|
+
| true
|
|
139
|
+
| false
|
|
140
|
+
| null
|
|
141
|
+
| undefined
|
|
142
|
+
| { allow: true; reason?: string }
|
|
143
|
+
| { allow: false; reason?: string };
|
|
144
|
+
|
|
145
|
+
export type BaseAccountCallerPolicy = (
|
|
146
|
+
observation: BaseAccountPreflightObservation,
|
|
147
|
+
context: BaseAccountGuardContext
|
|
148
|
+
) => BaseAccountCallerPolicyResult | Promise<BaseAccountCallerPolicyResult>;
|
|
149
|
+
|
|
150
|
+
export interface GuardWalletSendCallsOptions {
|
|
151
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
152
|
+
provider: Eip1193Provider;
|
|
153
|
+
request: WalletSendCallsRequest;
|
|
154
|
+
policy: BaseAccountCallerPolicy;
|
|
155
|
+
context?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface BaseAccountPaymasterGuardOptions {
|
|
159
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
160
|
+
policy: BaseAccountCallerPolicy;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface BaseAccountGuardCallOptions {
|
|
164
|
+
policy?: BaseAccountCallerPolicy;
|
|
165
|
+
context?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface BaseAccountObservationIdentity {
|
|
169
|
+
blockNumber: bigint;
|
|
170
|
+
blockTag: string;
|
|
171
|
+
blockHash: string;
|
|
172
|
+
effectiveTrust: BaseTrustLevel;
|
|
173
|
+
blockTrustLevel: BaseTrustLevel;
|
|
174
|
+
finalTargetBytecodeHash: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
interface WalletSendCallsInputErrorInstance extends TypeError {
|
|
178
|
+
readonly code: 'INVALID_WALLET_SEND_CALLS_INPUT';
|
|
179
|
+
readonly field: string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface ExecutionIdentityBlockedErrorInstance extends Error {
|
|
183
|
+
readonly code: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface BaseAccountPaymasterGuardInstance {
|
|
187
|
+
request(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
188
|
+
sendCalls(provider: Eip1193Provider, request: WalletSendCallsRequest, options?: BaseAccountGuardCallOptions): Promise<unknown>;
|
|
189
|
+
preflightTransaction(transaction: TransactionPreflightRequest, options?: { policy?: BaseAccountCallerPolicy; signAndSend: (tx: any, obs: any) => Promise<unknown>; context?: Record<string, unknown> }): Promise<unknown>;
|
|
190
|
+
guardTransaction(transaction: TransactionPreflightRequest, options?: { policy?: BaseAccountCallerPolicy; signAndSend: (tx: any, obs: any) => Promise<unknown>; context?: Record<string, unknown> }): Promise<unknown>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface PreflightBeforeSigningOptions {
|
|
194
|
+
client: Pick<M2MSentinelClient, 'preflightTransaction'>;
|
|
195
|
+
transaction: TransactionPreflightRequest;
|
|
196
|
+
policy: (
|
|
197
|
+
observation: BaseAccountPreflightObservation,
|
|
198
|
+
context: { transaction: TransactionPreflightRequest; [key: string]: unknown }
|
|
199
|
+
) => BaseAccountCallerPolicyResult | Promise<BaseAccountCallerPolicyResult>;
|
|
200
|
+
signAndSend: (transaction: TransactionPreflightRequest, observation: BaseAccountPreflightObservation) => Promise<unknown>;
|
|
201
|
+
context?: Record<string, unknown>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// This source-distributed TypeScript entrypoint targets Node.js/CommonJS
|
|
205
|
+
// (Node >=18). It intentionally loads the public runtime adapter through
|
|
206
|
+
// Node's require and is not a browser-targeted bundle.
|
|
207
|
+
function runtime(): any {
|
|
208
|
+
return require('../base_account_paymaster_guard.js');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export const BASE_CHAIN_ID: 8453 = runtime().BASE_CHAIN_ID;
|
|
212
|
+
export const BASE_CHAIN_HEX: '0x2105' = runtime().BASE_CHAIN_HEX;
|
|
213
|
+
export const BASE_NETWORK: 'eip155:8453' = runtime().BASE_NETWORK;
|
|
214
|
+
export const MAX_CALLS: number = runtime().MAX_CALLS;
|
|
215
|
+
export const MAX_PREFLIGHT_CONCURRENCY: number = runtime().MAX_PREFLIGHT_CONCURRENCY;
|
|
216
|
+
export const MAX_RPC_OBSERVATION_CALLS: number = runtime().MAX_RPC_OBSERVATION_CALLS;
|
|
217
|
+
export const MAX_DATA_BYTES: number = runtime().MAX_DATA_BYTES;
|
|
218
|
+
|
|
219
|
+
export const WalletSendCallsInputError: {
|
|
220
|
+
new (field: string, message: string): WalletSendCallsInputErrorInstance;
|
|
221
|
+
} = runtime().WalletSendCallsInputError;
|
|
222
|
+
export const ExecutionIdentityBlockedError: {
|
|
223
|
+
new (code: string, message: string): ExecutionIdentityBlockedErrorInstance;
|
|
224
|
+
} = runtime().ExecutionIdentityBlockedError;
|
|
225
|
+
export const PreflightInputError = WalletSendCallsInputError;
|
|
226
|
+
export const PreflightBlockedError = ExecutionIdentityBlockedError;
|
|
227
|
+
|
|
228
|
+
export function isAffirmativePolicyResult(value: unknown): value is true | { allow: true; reason?: string } {
|
|
229
|
+
return runtime().isAffirmativePolicyResult(value);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function validateWalletSendCallsRequest(request: unknown): WalletSendCallsRequest {
|
|
233
|
+
return runtime().validateWalletSendCallsRequest(request);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export const normalizeWalletSendCallsRequest = validateWalletSendCallsRequest;
|
|
237
|
+
|
|
238
|
+
export function transactionFromCall(params: WalletSendCallsParams, call: WalletSendCallsCall, index = 0): TransactionPreflightRequest {
|
|
239
|
+
return runtime().transactionFromCall(params, call, index);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export const toPreflightTransaction = transactionFromCall;
|
|
243
|
+
|
|
244
|
+
export function assertObservationReady(
|
|
245
|
+
observation: unknown,
|
|
246
|
+
transaction: TransactionPreflightRequest
|
|
247
|
+
): BaseAccountObservationIdentity {
|
|
248
|
+
return runtime().assertObservationReady(observation, transaction);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function guardWalletSendCalls(options: GuardWalletSendCallsOptions): Promise<unknown> {
|
|
252
|
+
return runtime().guardWalletSendCalls(options);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const preflightWalletSendCalls = guardWalletSendCalls;
|
|
256
|
+
export const sendCallsWithPreflight = guardWalletSendCalls;
|
|
257
|
+
export const executeWalletSendCalls = guardWalletSendCalls;
|
|
258
|
+
|
|
259
|
+
export function preflightBeforeSigning(options: PreflightBeforeSigningOptions): Promise<unknown> {
|
|
260
|
+
return runtime().preflightBeforeSigning(options);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export const guardTransaction = preflightBeforeSigning;
|
|
264
|
+
export const preflightTransactionBeforeSigning = preflightBeforeSigning;
|
|
265
|
+
|
|
266
|
+
export const BaseAccountPaymasterGuard: {
|
|
267
|
+
new (options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuardInstance;
|
|
268
|
+
} = runtime().BaseAccountPaymasterGuard;
|
|
269
|
+
export const BaseAccountExecutionGuard = BaseAccountPaymasterGuard;
|
|
270
|
+
|
|
271
|
+
export function createBaseAccountPaymasterGuard(options: BaseAccountPaymasterGuardOptions): BaseAccountPaymasterGuardInstance {
|
|
272
|
+
return new BaseAccountPaymasterGuard(options);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export const createExecutionIdentityGuard = createBaseAccountPaymasterGuard;
|
|
276
|
+
|
|
277
|
+
export function createPublicClient(options: {
|
|
278
|
+
apiKey: string;
|
|
279
|
+
baseUrl?: string;
|
|
280
|
+
timeoutMs?: number;
|
|
281
|
+
sdk?: { M2MSentinelClient: typeof M2MSentinelClient };
|
|
282
|
+
}): M2MSentinelClient {
|
|
283
|
+
return runtime().createPublicClient(options);
|
|
284
|
+
}
|
package/typescript/index.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "m2m-sentinel-sdk",
|
|
3
|
+
"version": "1.2.7",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "m2m-sentinel-sdk",
|
|
9
|
+
"version": "1.2.7",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^22.7.5",
|
|
12
|
+
"typescript": "^5.0.0"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"node_modules/@types/node": {
|
|
19
|
+
"version": "22.20.1",
|
|
20
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",
|
|
21
|
+
"integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==",
|
|
22
|
+
"dev": true,
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"undici-types": "~6.21.0"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"node_modules/typescript": {
|
|
29
|
+
"version": "5.9.3",
|
|
30
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
|
31
|
+
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
|
32
|
+
"dev": true,
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"bin": {
|
|
35
|
+
"tsc": "bin/tsc",
|
|
36
|
+
"tsserver": "bin/tsserver"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=14.17"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/undici-types": {
|
|
43
|
+
"version": "6.21.0",
|
|
44
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
45
|
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
46
|
+
"dev": true,
|
|
47
|
+
"license": "MIT"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/typescript/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "m2m-sentinel-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Source-distributed TypeScript client for M2M Sentinel Base capability intelligence API",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"types": "index.ts",
|
|
7
7
|
"private": true,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
|
-
"build": "tsc"
|
|
12
|
+
"build": "tsc --noEmit"
|
|
10
13
|
},
|
|
11
14
|
"devDependencies": {
|
|
15
|
+
"@types/node": "^22.7.5",
|
|
12
16
|
"typescript": "^5.0.0"
|
|
13
17
|
}
|
|
14
18
|
}
|
package/typescript/x402.ts
CHANGED
|
@@ -318,7 +318,7 @@ export class X402SignerClient {
|
|
|
318
318
|
|
|
319
319
|
async fetchWithAutoPayment(path: string, options: any = {}): Promise<any> {
|
|
320
320
|
const url = path.startsWith('http') ? path : `${this.baseUrl}/${path.replace(/^\/+/, '')}`;
|
|
321
|
-
const headers = { 'Accept': 'application/json', 'User-Agent': '@m2msentinel/sdk-ts/1.2.
|
|
321
|
+
const headers = { 'Accept': 'application/json', 'User-Agent': '@m2msentinel/sdk-ts/1.2.7', ...(options.headers || {}) };
|
|
322
322
|
|
|
323
323
|
let res = await fetch(url, { method: options.method || 'GET', headers, body: options.body });
|
|
324
324
|
if (res.status !== 402) {
|
package/x402_signer.js
CHANGED
|
@@ -271,7 +271,7 @@ class X402SignerClient {
|
|
|
271
271
|
path: url.pathname + url.search,
|
|
272
272
|
method: options.method || 'GET',
|
|
273
273
|
headers: {
|
|
274
|
-
'User-Agent': 'M2M-Sentinel-X402Signer/1.2.
|
|
274
|
+
'User-Agent': 'M2M-Sentinel-X402Signer/1.2.7',
|
|
275
275
|
'Accept': 'application/json',
|
|
276
276
|
...(options.headers || {})
|
|
277
277
|
},
|