@cmdoss/suipay-mcp 0.2.1 → 0.2.2-dev.1
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 +61 -8
- package/dist/bin/suipay.js +2 -3
- package/dist/chunk-K6WM4Z7H.js +46 -0
- package/dist/{chunk-XZQOOY66.js → chunk-NVTYOOMY.js} +3743 -1623
- package/dist/http-B4YTVw0k.d.ts +392 -0
- package/dist/http.d.ts +7 -2
- package/dist/http.js +1 -2
- package/dist/index.d.ts +109 -35
- package/dist/index.js +14 -3
- package/package.json +9 -7
- package/dist/chunk-A3JIIDYT.js +0 -161
- package/dist/chunk-TPW6S2K4.js +0 -39
- package/dist/http-BnIjiwcR.d.ts +0 -1149
- package/dist/personal-message-5PF4KVLF.js +0 -284
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmdoss/suipay-mcp",
|
|
3
|
-
"version": "0.2.1",
|
|
3
|
+
"version": "0.2.2-dev.1",
|
|
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,8 +19,7 @@
|
|
|
19
19
|
"README.md"
|
|
20
20
|
],
|
|
21
21
|
"publishConfig": {
|
|
22
|
-
"access": "public"
|
|
23
|
-
"provenance": true
|
|
22
|
+
"access": "public"
|
|
24
23
|
},
|
|
25
24
|
"engines": {
|
|
26
25
|
"node": ">=20"
|
|
@@ -34,12 +33,15 @@
|
|
|
34
33
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
35
34
|
"@mysten/sui": "2.24.0",
|
|
36
35
|
"@noble/ed25519": "^2.1.0",
|
|
37
|
-
"@noble/hashes": "^
|
|
36
|
+
"@noble/hashes": "^2.3.0",
|
|
38
37
|
"open": "^11.0.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
40
|
+
"@cmdoss/suipay-core": "workspace:*",
|
|
41
|
+
"@cmdoss/suipay-sdk": "workspace:*",
|
|
42
|
+
"@types/node": "catalog:",
|
|
43
|
+
"tsup": "catalog:",
|
|
44
|
+
"typescript": "catalog:",
|
|
45
|
+
"vitest": "catalog:"
|
|
44
46
|
}
|
|
45
47
|
}
|
package/dist/chunk-A3JIIDYT.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// ../../src/protocol/rail.ts
|
|
2
|
-
var SETTLEMENT_RAILS = [
|
|
3
|
-
"direct",
|
|
4
|
-
"allowance",
|
|
5
|
-
"shared_pool",
|
|
6
|
-
"spend_account",
|
|
7
|
-
"auth_capture",
|
|
8
|
-
"subscription"
|
|
9
|
-
];
|
|
10
|
-
function isSpendAccountRail(rail) {
|
|
11
|
-
return rail === "shared_pool" || rail === "spend_account";
|
|
12
|
-
}
|
|
13
|
-
var DIALECT_ORDER = ["mpp", "x402"];
|
|
14
|
-
function isSettlementRail(value) {
|
|
15
|
-
return typeof value === "string" && SETTLEMENT_RAILS.includes(value);
|
|
16
|
-
}
|
|
17
|
-
function assertSettlementRail(value) {
|
|
18
|
-
if (!isSettlementRail(value)) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`invalid settlement rail: ${String(value)} (expected ${SETTLEMENT_RAILS.join(" | ")})`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
function isDialect(value) {
|
|
26
|
-
return value === "mpp" || value === "x402";
|
|
27
|
-
}
|
|
28
|
-
function isDialectMode(value) {
|
|
29
|
-
return value === "transaction" || value === "finalized-proof";
|
|
30
|
-
}
|
|
31
|
-
function dialectsFromModes(modes) {
|
|
32
|
-
return DIALECT_ORDER.filter((d) => modes[d] != null);
|
|
33
|
-
}
|
|
34
|
-
function dialectMode(authority, dialect) {
|
|
35
|
-
const mode = authority.dialectModes[dialect];
|
|
36
|
-
if (!mode) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
`${authority.rail} has no dialectMode for ${dialect} (ceiling: ${authority.supportedDialects.join(",")})`
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return mode;
|
|
42
|
-
}
|
|
43
|
-
function createSettlementRailAuthority(input) {
|
|
44
|
-
assertSettlementRail(input.rail);
|
|
45
|
-
if (typeof input.packageId !== "string" || !input.packageId.trim()) {
|
|
46
|
-
throw new Error("packageId is required");
|
|
47
|
-
}
|
|
48
|
-
if (typeof input.module !== "string" || !input.module.trim()) {
|
|
49
|
-
throw new Error("module is required");
|
|
50
|
-
}
|
|
51
|
-
if (typeof input.payFunction !== "string" || !input.payFunction.trim()) {
|
|
52
|
-
throw new Error("payFunction is required");
|
|
53
|
-
}
|
|
54
|
-
const keys = Object.keys(input.dialectModes ?? {});
|
|
55
|
-
if (!keys.length) {
|
|
56
|
-
throw new Error("dialectModes must be non-empty");
|
|
57
|
-
}
|
|
58
|
-
for (const d of keys) {
|
|
59
|
-
if (!isDialect(d)) {
|
|
60
|
-
throw new Error(`unknown dialect in dialectModes: ${String(d)}`);
|
|
61
|
-
}
|
|
62
|
-
const mode = input.dialectModes[d];
|
|
63
|
-
if (!isDialectMode(mode)) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`invalid dialectMode for ${d}: ${String(mode)}`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const dialectModes = Object.freeze({ ...input.dialectModes });
|
|
70
|
-
const supportedDialects = Object.freeze(
|
|
71
|
-
dialectsFromModes(dialectModes)
|
|
72
|
-
);
|
|
73
|
-
const proofMode = dialectModes.mpp ?? dialectModes.x402 ?? "transaction";
|
|
74
|
-
return Object.freeze({
|
|
75
|
-
rail: input.rail,
|
|
76
|
-
packageId: input.packageId.trim(),
|
|
77
|
-
module: input.module.trim(),
|
|
78
|
-
payFunction: input.payFunction.trim(),
|
|
79
|
-
dialectModes,
|
|
80
|
-
supportedDialects,
|
|
81
|
-
proofMode
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
var SPEND_ACCOUNT_DEBIT_FUNCTIONS = [
|
|
85
|
-
"settle_policy_payment",
|
|
86
|
-
"settle_policy_payment_to_refund_vault",
|
|
87
|
-
"settle_open_recipient_payment",
|
|
88
|
-
"settle_open_recipient_payment_to_refund_vault"
|
|
89
|
-
];
|
|
90
|
-
function spendAccountDebitFunction(input) {
|
|
91
|
-
const open = input?.accessMode === "open";
|
|
92
|
-
const refundable = input?.refundable === true;
|
|
93
|
-
if (open && refundable) return "settle_open_recipient_payment_to_refund_vault";
|
|
94
|
-
if (open) return "settle_open_recipient_payment";
|
|
95
|
-
if (refundable) return "settle_policy_payment_to_refund_vault";
|
|
96
|
-
return "settle_policy_payment";
|
|
97
|
-
}
|
|
98
|
-
function defaultAuthorityForRail(rail, packageId, opts) {
|
|
99
|
-
switch (rail) {
|
|
100
|
-
case "spend_account":
|
|
101
|
-
case "shared_pool": {
|
|
102
|
-
const dual = opts?.x402DialectEnabled === true;
|
|
103
|
-
return createSettlementRailAuthority({
|
|
104
|
-
rail,
|
|
105
|
-
packageId,
|
|
106
|
-
module: "spend_account",
|
|
107
|
-
payFunction: spendAccountDebitFunction(),
|
|
108
|
-
dialectModes: dual ? { mpp: "finalized-proof", x402: "transaction" } : { mpp: "finalized-proof" }
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
case "allowance":
|
|
112
|
-
throw new Error(
|
|
113
|
-
"settlement rail 'allowance' is retired (ADR-0010); it is decodable but has no settlement authority"
|
|
114
|
-
);
|
|
115
|
-
case "subscription":
|
|
116
|
-
return createSettlementRailAuthority({
|
|
117
|
-
rail: "subscription",
|
|
118
|
-
packageId,
|
|
119
|
-
module: "subscription",
|
|
120
|
-
payFunction: "charge",
|
|
121
|
-
dialectModes: {
|
|
122
|
-
mpp: "transaction",
|
|
123
|
-
x402: "transaction"
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
case "direct":
|
|
127
|
-
return createSettlementRailAuthority({
|
|
128
|
-
rail: "direct",
|
|
129
|
-
packageId,
|
|
130
|
-
module: "payment",
|
|
131
|
-
payFunction: "pay",
|
|
132
|
-
dialectModes: {
|
|
133
|
-
mpp: "transaction",
|
|
134
|
-
x402: "transaction"
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
case "auth_capture":
|
|
138
|
-
return createSettlementRailAuthority({
|
|
139
|
-
rail: "auth_capture",
|
|
140
|
-
packageId,
|
|
141
|
-
module: "auth_capture",
|
|
142
|
-
payFunction: "authorize",
|
|
143
|
-
dialectModes: {
|
|
144
|
-
x402: "transaction"
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
default: {
|
|
148
|
-
const _exhaustive = rail;
|
|
149
|
-
throw new Error(`unhandled rail: ${String(_exhaustive)}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export {
|
|
155
|
-
isSpendAccountRail,
|
|
156
|
-
isSettlementRail,
|
|
157
|
-
dialectMode,
|
|
158
|
-
SPEND_ACCOUNT_DEBIT_FUNCTIONS,
|
|
159
|
-
spendAccountDebitFunction,
|
|
160
|
-
defaultAuthorityForRail
|
|
161
|
-
};
|
package/dist/chunk-TPW6S2K4.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createServer,
|
|
3
|
-
loadMcpConfig,
|
|
4
|
-
loadPaymentProfile
|
|
5
|
-
} from "./chunk-XZQOOY66.js";
|
|
6
|
-
|
|
7
|
-
// src/index.ts
|
|
8
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
-
function loadBootProfile(load = loadPaymentProfile) {
|
|
10
|
-
try {
|
|
11
|
-
return { profile: load(), unreadable: false };
|
|
12
|
-
} catch {
|
|
13
|
-
return { profile: null, unreadable: true };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
async function main() {
|
|
17
|
-
const cfg = loadMcpConfig();
|
|
18
|
-
const { profile: bootProfile, unreadable: bootProfileUnreadable } = loadBootProfile();
|
|
19
|
-
const server = createServer(cfg);
|
|
20
|
-
await server.connect(new StdioServerTransport());
|
|
21
|
-
if (bootProfileUnreadable) {
|
|
22
|
-
console.error(
|
|
23
|
-
"[suipay-mcp] credentials unreadable: run suipay_login or suipay_logout force=true \xB7 stdio ready"
|
|
24
|
-
);
|
|
25
|
-
} else if (bootProfile) {
|
|
26
|
-
console.error(
|
|
27
|
-
`[suipay-mcp] delegate ${bootProfile.creds.delegateAddress} (${bootProfile.source}) \xB7 stdio ready`
|
|
28
|
-
);
|
|
29
|
-
} else {
|
|
30
|
-
console.error(
|
|
31
|
-
"[suipay-mcp] not connected \xB7 run suipay_login \xB7 stdio ready"
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
loadBootProfile,
|
|
38
|
-
main
|
|
39
|
-
};
|