@cmdoss/suipay-mcp 0.2.2-dev.4 → 0.2.2-dev.40

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/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import { Wallet } from '@cmdoss/suipay-core/chain/types';
2
- import { M as McpConfig, a as McpAuthContext, b as McpTraceHooks } from './http-C8xW9F1c.js';
3
- export { A as AgentHeldResolver, c as AgentHeldSettlement, d as McpEnvelope, e as McpEnvelopeEntry, f as McpServerOptions, g as McpTraceContext, h as McpTraceRuntime, P as PACKAGE_NAME, T as TOOLS, i as canonicalMcpRequestId, j as createServer, k as handleSuipayMcpHttpRequest, l as inspectMcpEnvelope, m as loadMcpConfig, r as resetAgentHeldProcessLedger, n as resolveAgentHeldSettlement, t as traceMcpHttpRequest } from './http-C8xW9F1c.js';
4
- import { GrantSnapshot } from '@cmdoss/suipay-core/policy/grant-target';
5
- export { resolveGrantTarget } from '@cmdoss/suipay-core/policy/grant-target';
6
- import { PaidHttpRequest } from '@cmdoss/suipay-sdk/protocol/paid-http-request';
7
- import { TraceSink } from '@cmdoss/suipay-core/trace/types';
8
- import { Dialect } from '@cmdoss/suipay-sdk/protocol/types';
9
- import { GetObjectJson } from '@cmdoss/suipay-sdk/agent-sdk/reads';
2
+ import { S as SpendAccountSigningRequest, M as McpConfig, a as McpAuthContext, b as McpTraceHooks, c as SpendAccountPayDeps } from './http-DvnvTrb3.js';
3
+ export { A as AgentHeldResolver, d as AgentHeldSettlement, e as MCP_TARGET_PRESETS, f as McpEnvelope, g as McpEnvelopeEntry, h as McpServerOptions, i as McpTarget, j as McpTraceContext, k as McpTraceRuntime, P as PACKAGE_NAME, l as PreparedPayment, m as SpendAccountPrepareResult, n as SpendAccountPrepareSession, T as TOOLS, o as buildSpendAccountPayKind, p as canonicalMcpRequestId, q as createServer, r as handleSuipayMcpHttpRequest, s as inspectMcpEnvelope, t as loadMcpConfig, u as parseMcpTargetFlag, v as prepareSpendAccountPayment, w as resetAgentHeldProcessLedger, x as resolveAgentHeldSettlement, y as resolveMcpTarget, z as sameMcpGateway, B as traceMcpHttpRequest, C as verifySpendAccountPayReconstructs } from './http-DvnvTrb3.js';
4
+ import { GetObjectJson, createReader } from '@cmdoss/suipay-sdk/agent-sdk/reads';
10
5
  import { DelegatedKeySigner, DelegatedPayerSession, DelegatedPayerConfig, DelegatedPayerDeps, SpendIntent, DelegatedPayResult } from '@cmdoss/suipay-sdk/delegated-signer/payer';
6
+ import { PaidHttpRequest } from '@cmdoss/suipay-sdk/protocol/paid-http-request';
7
+ import { createPayer } from '@cmdoss/suipay-sdk/agent-sdk/delegate-agent';
11
8
  import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
9
+ export { resolveGrantTarget } from '@cmdoss/suipay-core/policy/grant-target';
12
10
  import '@cmdoss/suipay-sdk/mcp/access-context';
13
11
  import '@cmdoss/suipay-sdk/buyer/settlement-dto';
14
12
  import '@modelcontextprotocol/sdk/server/index.js';
13
+ import '@cmdoss/suipay-core/trace/types';
14
+ import '@cmdoss/suipay-sdk/protocol/types';
15
+ import '@cmdoss/suipay-sdk/pay-operation';
16
+ import '@cmdoss/suipay-core/errors';
15
17
 
16
18
  interface SuiPayCredentials {
17
19
  /** 64-hex Ed25519 seed. NEVER logged. */
@@ -48,11 +50,6 @@ interface PaymentProfile {
48
50
  * and point operators at delegate OAuth / delegated-signer flows.
49
51
  */
50
52
  declare function loadPaymentProfile(): PaymentProfile | null;
51
- /**
52
- * First authorization generates a local keypair and persists it at 0600.
53
- * Re-authorization reuses the stored key so a second key cannot orphan the grant.
54
- * Returns only the public identity.
55
- */
56
53
  declare function ensureLocalSigningKey(opts?: {
57
54
  label?: string;
58
55
  }): Promise<LocalSigningKeyIdentity>;
@@ -72,208 +69,6 @@ declare function loadLocalSigner(): {
72
69
  signPersonalMessage: (message: Uint8Array) => Promise<string>;
73
70
  } | null;
74
71
 
75
- /**
76
- * Shared pay-request helpers.
77
- *
78
- * The V1 allowance sponsored payer (ADR-0010) is retired; only the
79
- * rail-neutral request surface the SpendAccount payer depends on survives here:
80
- * the `PayResult` shape every payer returns. `paidRequestInit` is the SDK helper
81
- * that builds the one RequestInit replayed byte for byte on both calls.
82
- */
83
-
84
- type PayResult = {
85
- status: 'ok' | 'failed' | 'ambiguous';
86
- /**
87
- * `true` — settlement confirmed. `false` — money did not leave the
88
- * account. `'unknown'` — execute/finality did not resolve; a retry can
89
- * pay twice.
90
- */
91
- paid: boolean | 'unknown';
92
- body?: unknown;
93
- receipt?: unknown;
94
- code?: string;
95
- detail?: string;
96
- txDigest?: string;
97
- };
98
-
99
- /**
100
- * SpendAccount PREPARE-only client (non-custodial MCP).
101
- *
102
- * The remote MCP `pay` tool runs inside the gateway, which holds NO key that can
103
- * spend. So this module does not sign or submit: it PREPARES a payment and hands
104
- * back an unsigned `spend_account::settle_policy_payment` transaction plus everything the client
105
- * needs. The client — which holds the delegate key — sponsors, signs locally,
106
- * and submits through the same personal-message challenge → local-sign → submit flow the
107
- * REST/SDK delegate path uses. Only signatures ever reach the gateway; the
108
- * private key is never placed in an HTTP body, a bearer, or any header.
109
- *
110
- * Flow: 402 Offer → request-binding → package/network SSOT →
111
- * resolveGrantTarget(snapshot, offer.targetHash) (pause/revoke gate) → cap/coin
112
- * checks → assertLive (fresh authority) → build unsigned kind bytes → return the
113
- * signing request. There is deliberately no sponsor call, no decrypt, no
114
- * signature, and no forwarded bearer here.
115
- *
116
- * See docs/design/mcp-non-custodial-signing.md and ADR-0013 §3.
117
- */
118
-
119
- /**
120
- * Read/prepare-only session for the non-custodial MCP pay tool. It carries the
121
- * immutable grant snapshot and an optional prepare-time live gate — and no key,
122
- * by construction. There is no `decryptDelegateSeed` and no `sponsorAuthorization`.
123
- */
124
- interface SpendAccountPrepareSession {
125
- snapshot: GrantSnapshot;
126
- /** SpendAccount package id (V2). */
127
- packageId: string;
128
- /**
129
- * Re-assert the grant is still live (not paused/revoked/expired) against fresh
130
- * canonical state, invoked immediately before a signing request is handed back.
131
- * Throw to abort. Optional; when absent, only the request-time snapshot gates
132
- * the prepare (on-chain `spend_account::settle_policy_payment` remains the final backstop for any
133
- * spend the client later submits).
134
- */
135
- assertLive?: () => Promise<void>;
136
- }
137
- interface SpendAccountPayDeps {
138
- fetchImpl?: typeof fetch;
139
- /** Build only-transaction-kind bytes for spend_account::settle_policy_payment. */
140
- buildPayKind?: (input: {
141
- delegate: string;
142
- coinType: string;
143
- poolObjectId: string;
144
- grantObjectId: string;
145
- policyId: number | string;
146
- targetHash: string;
147
- amount: string;
148
- paymentIdHash: Uint8Array;
149
- termsHash: Uint8Array;
150
- recipient?: string;
151
- accessMode?: 'scoped' | 'open';
152
- }) => Promise<{
153
- kindBytes: string;
154
- }>;
155
- /**
156
- * Live trace for this prepare. Purely observational: emission records what the
157
- * canonical read decisions already returned — an event is written after a check
158
- * passes and can never be the thing that lets the next step run.
159
- */
160
- trace?: SpendAccountPayTrace;
161
- }
162
- interface SpendAccountPayTrace {
163
- sink: TraceSink;
164
- traceId: string;
165
- requestId: string | null;
166
- buyerAccountId: string;
167
- connectionId: string;
168
- /** HMAC secret for signed cross-request context. Absent disables signing. */
169
- secret?: string | null;
170
- /** Injected clock, for tests. */
171
- now?: () => number;
172
- }
173
- /** The unsigned payment the client signs locally and submits. */
174
- interface SpendAccountSigningRequest {
175
- /**
176
- * Unsigned `spend_account::settle_policy_payment` transaction-kind bytes (base64), sender set to
177
- * `delegateAddress`. The client sponsors these for gas, signs with the delegate
178
- * key, and submits — the gateway never receives the key.
179
- */
180
- unsignedKindBytes: string;
181
- delegateAddress: string;
182
- packageId: string;
183
- poolObjectId: string;
184
- grantObjectId: string;
185
- /** On-chain policy id the pay is bound to. */
186
- policyId: number | string;
187
- coinType: string;
188
- targetHash: string;
189
- amount: string;
190
- /** Hex (no 0x) of the payment-id hash bound into the transaction. */
191
- paymentIdHashHex: string;
192
- /** Hex (no 0x) of the terms hash bound into the transaction. */
193
- termsHashHex: string;
194
- challengeId: string;
195
- /** The exact paid request to replay after the client submits. */
196
- resource: {
197
- url: string;
198
- method: string;
199
- };
200
- dialect: Dialect;
201
- /** Recipient the agent requested (offer.payTo). */
202
- recipient: string;
203
- /** Where the client (holding the key) sponsors and submits. */
204
- submit: {
205
- sponsorUrl: string;
206
- executeUrl: string;
207
- moveCallTarget: string;
208
- };
209
- /**
210
- * ISO-8601 timestamp when this prepared operation expires. After this time the
211
- * unsigned bytes are no longer valid and the client must re-call pay() for a
212
- * fresh prepare. Derived from the offer TTL.
213
- */
214
- expiresAt: string;
215
- /** Restated hard rule for the agent host. */
216
- note: string;
217
- }
218
- interface PreparedPayment {
219
- status: 'prepared';
220
- paid: false;
221
- signingRequest: SpendAccountSigningRequest;
222
- }
223
- /** Prepared signing request, or a canonical failure (never a spend). */
224
- type SpendAccountPrepareResult = PreparedPayment | PayResult;
225
- /** Default kind builder (no chain client — pure PTB). */
226
- declare function buildSpendAccountPayKind(input: {
227
- packageId: string;
228
- delegate: string;
229
- coinType: string;
230
- poolObjectId: string;
231
- grantObjectId: string;
232
- policyId: number | string;
233
- targetHash: string;
234
- amount: string;
235
- paymentIdHash: Uint8Array;
236
- termsHash: Uint8Array;
237
- }): Promise<{
238
- kindBytes: string;
239
- }>;
240
- /**
241
- * Refuse blind signing: a client validating a sponsored transaction must be able
242
- * to prove the sponsored bytes reconstruct the intended spend_account::settle_policy_payment. Kept
243
- * here (and exported) so both the client signer and its tests share one check.
244
- */
245
- declare function verifySpendAccountPayReconstructs(bytes: string, expected: {
246
- kindBytes: string;
247
- packageId: string;
248
- delegate: string;
249
- poolObjectId: string;
250
- grantObjectId: string;
251
- amount: string;
252
- }): void;
253
- /**
254
- * Prepare a delegate payment WITHOUT signing. Reads the 402 offer, binds it,
255
- * gates on the immutable grant snapshot + a fresh authority check, builds the
256
- * unsigned transaction, and returns a signing request. The client holding the
257
- * delegate key signs locally and submits. This function never decrypts, signs,
258
- * sponsors, or submits.
259
- *
260
- * Uses `resolvePayment` from the SDK pay-operation module (SAIP-170) for the
261
- * shared offer-acquisition + authority-resolution pipeline (steps 1–5 + assertLive
262
- * + hash derivation + buildPayKind). This module wraps that with MCP-specific
263
- * concerns: trace events, dialect-mode ceiling check, and signing-request
264
- * construction.
265
- */
266
- declare function prepareSpendAccountPayment(args: {
267
- url: string;
268
- /** The one normalized paid request, replayed byte for byte after signing. */
269
- request?: PaidHttpRequest;
270
- session: SpendAccountPrepareSession;
271
- cfg: McpConfig;
272
- deps?: SpendAccountPayDeps;
273
- /** Preferred dialect when the 402 advertises both (default mpp). */
274
- preferredDialect?: Dialect;
275
- }): Promise<SpendAccountPrepareResult>;
276
-
277
72
  /**
278
73
  * Client-side completion of an MCP prepared payment.
279
74
  *
@@ -319,12 +114,40 @@ declare function settlePreparedMcpPayment(args: {
319
114
  intent?: SpendIntent;
320
115
  }): Promise<DelegatedPayResult>;
321
116
 
117
+ interface StdioLoginOptions {
118
+ consoleUrl: string;
119
+ gatewayUrl: string;
120
+ identity: {
121
+ delegateAddress: string;
122
+ publicKeyHex: string;
123
+ };
124
+ label?: string;
125
+ timeoutMs?: number;
126
+ openBrowser?: boolean;
127
+ onUrl?: (connectUrl: string) => void;
128
+ }
129
+ interface StartedStdioLogin {
130
+ connectUrl: string;
131
+ port: number;
132
+ connectState: string;
133
+ done: Promise<void>;
134
+ close: () => void;
135
+ }
136
+ /**
137
+ * Bind the loopback listener and return the console URL immediately.
138
+ * The wallet callback is awaited on `done`, not on the MCP tool call.
139
+ */
140
+ declare function startStdioLogin(opts: StdioLoginOptions): Promise<StartedStdioLogin>;
141
+
322
142
  type ToolResult = CallToolResult;
143
+
323
144
  interface ToolDeps {
324
145
  fetchImpl?: typeof fetch;
325
146
  profileLoader?: () => PaymentProfile | null;
326
147
  /** Remote HTTP auth (grant + scope + optional shared-pool pay session). */
327
148
  auth?: McpAuthContext;
149
+ /** Wire transport. Hosted HTTP never reads a buyer path. */
150
+ transport?: 'stdio' | 'http';
328
151
  /**
329
152
  * Proxy-resolved live trace for this MCP request. Observation only: it never
330
153
  * changes which rail runs, what is paid, or whether a payment is allowed.
@@ -342,22 +165,29 @@ interface ToolDeps {
342
165
  };
343
166
  /** Override the prepare-time kind builder (tests / offline). */
344
167
  buildPayKind?: SpendAccountPayDeps['buildPayKind'];
168
+ /** Override the exclusion-registry resolver (tests / offline). */
169
+ resolveExclusionRegistry?: SpendAccountPayDeps['resolveExclusionRegistry'];
345
170
  /**
346
171
  * Stdio login surfaces the console URL (MCP progress notification). The URL
347
172
  * carries the delegate address only — never the seed.
348
173
  */
349
174
  onUrl?: (url: string) => void;
175
+ createPayer?: typeof createPayer;
176
+ createReader?: typeof createReader;
177
+ startStdioLogin?: typeof startStdioLogin;
350
178
  }
351
179
  declare function pay(args: {
352
180
  url: string;
353
181
  method?: unknown;
354
182
  json?: unknown;
183
+ file?: unknown;
184
+ fileField?: unknown;
355
185
  recipient?: unknown;
356
186
  maxAmount?: unknown;
357
187
  }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
358
188
  declare function receipts(args: {
359
189
  challengeId?: string;
360
- }, _cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
190
+ }, cfg: McpConfig, deps?: ToolDeps): Promise<ToolResult>;
361
191
 
362
192
  declare function loadBootProfile(load?: typeof loadPaymentProfile): {
363
193
  profile: ReturnType<typeof loadPaymentProfile>;
@@ -365,4 +195,4 @@ declare function loadBootProfile(load?: typeof loadPaymentProfile): {
365
195
  };
366
196
  declare function main(): Promise<void>;
367
197
 
368
- export { McpAuthContext, McpConfig, McpTraceHooks, type PreparedPayment, type SpendAccountPrepareResult, type SpendAccountPrepareSession, type SpendAccountSigningRequest, buildSpendAccountPayKind, ensureLocalSigningKey, loadBootProfile, loadLocalSigner, main, pay, prepareSpendAccountPayment, receipts, settlePreparedMcpPayment, verifySpendAccountPayReconstructs };
198
+ export { McpAuthContext, McpConfig, McpTraceHooks, SpendAccountSigningRequest, ensureLocalSigningKey, loadBootProfile, loadLocalSigner, main, pay, receipts, settlePreparedMcpPayment };
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  loadBootProfile,
3
3
  main
4
- } from "./chunk-XAM2YQC6.js";
4
+ } from "./chunk-IH6HQD2V.js";
5
5
  import {
6
+ MCP_TARGET_PRESETS,
6
7
  PACKAGE_NAME,
7
8
  TOOLS,
8
9
  buildSpendAccountPayKind,
@@ -13,17 +14,21 @@ import {
13
14
  inspectMcpEnvelope,
14
15
  loadLocalSigner,
15
16
  loadMcpConfig,
17
+ parseMcpTargetFlag,
16
18
  pay,
17
19
  prepareSpendAccountPayment,
18
20
  receipts,
19
21
  resetAgentHeldProcessLedger,
20
22
  resolveAgentHeldSettlement,
21
23
  resolveGrantTarget,
24
+ resolveMcpTarget,
25
+ sameMcpGateway,
22
26
  settlePreparedMcpPayment,
23
27
  traceMcpHttpRequest,
24
28
  verifySpendAccountPayReconstructs
25
- } from "./chunk-KDOGSB5I.js";
29
+ } from "./chunk-YMOMYFKL.js";
26
30
  export {
31
+ MCP_TARGET_PRESETS,
27
32
  PACKAGE_NAME,
28
33
  TOOLS,
29
34
  buildSpendAccountPayKind,
@@ -36,12 +41,15 @@ export {
36
41
  loadLocalSigner,
37
42
  loadMcpConfig,
38
43
  main,
44
+ parseMcpTargetFlag,
39
45
  pay,
40
46
  prepareSpendAccountPayment,
41
47
  receipts,
42
48
  resetAgentHeldProcessLedger,
43
49
  resolveAgentHeldSettlement,
44
50
  resolveGrantTarget,
51
+ resolveMcpTarget,
52
+ sameMcpGateway,
45
53
  settlePreparedMcpPayment,
46
54
  traceMcpHttpRequest,
47
55
  verifySpendAccountPayReconstructs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdoss/suipay-mcp",
3
- "version": "0.2.2-dev.4",
3
+ "version": "0.2.2-dev.40",
4
4
  "type": "module",
5
5
  "description": "SuiPay MCP — pay MPP-gated APIs from a spend-account grant with an agent-held delegate key.",
6
6
  "main": "./dist/index.js",
@@ -19,16 +19,12 @@
19
19
  "README.md"
20
20
  ],
21
21
  "publishConfig": {
22
- "access": "public"
22
+ "access": "public",
23
+ "provenance": false
23
24
  },
24
25
  "engines": {
25
26
  "node": ">=20"
26
27
  },
27
- "scripts": {
28
- "build": "tsup",
29
- "test": "vitest run",
30
- "typecheck": "tsc -p tsconfig.json --noEmit"
31
- },
32
28
  "dependencies": {
33
29
  "@modelcontextprotocol/sdk": "^1.29.0",
34
30
  "@mysten/sui": "2.24.0",
@@ -37,11 +33,16 @@
37
33
  "open": "^11.0.0"
38
34
  },
39
35
  "devDependencies": {
40
- "@cmdoss/suipay-core": "workspace:*",
41
- "@cmdoss/suipay-sdk": "workspace:*",
42
- "@types/node": "catalog:",
43
- "tsup": "catalog:",
44
- "typescript": "catalog:",
45
- "vitest": "catalog:"
36
+ "@types/node": "^26",
37
+ "tsup": "^8.0.0",
38
+ "typescript": "^6.0.3",
39
+ "vitest": "^4.1.10",
40
+ "@cmdoss/suipay-core": "0.1.0",
41
+ "@cmdoss/suipay-sdk": "0.1.0"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "test": "vitest run",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit"
46
47
  }
47
- }
48
+ }