@subly_fi/pay 0.6.1 → 0.7.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 +21 -0
- package/README.md +98 -61
- package/dist/budget.js +2267 -0
- package/dist/cli.js +37 -20
- package/dist/deposit.js +1031 -183
- package/dist/doctor.js +188 -0
- package/dist/mcp-server.js +3404 -2415
- package/dist/pay.js +2764 -1873
- package/dist/setup-link.js +950 -104
- package/dist/vaults.js +129 -0
- package/dist/withdraw.js +950 -104
- package/package.json +25 -6
package/dist/cli.js
CHANGED
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// resolves cleanly. Subcommands map to the bundled entry points; argv is
|
|
4
|
-
// reshaped so each entry sees its own positional args at the usual index.
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
5
3
|
import { dirname, join } from "node:path";
|
|
6
4
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
5
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
6
|
const TARGETS = {
|
|
9
|
-
mcp: "mcp-server.js",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
withdraw: "withdraw.js",
|
|
13
|
-
"setup-link": "setup-link.js",
|
|
14
|
-
"setup-status": "setup-status.js"
|
|
7
|
+
mcp: "mcp-server.js", fetch: "pay.js", deposit: "deposit.js", withdraw: "withdraw.js",
|
|
8
|
+
"setup-link": "setup-link.js", "setup-status": "setup-status.js",
|
|
9
|
+
doctor: "doctor.js", budget: "budget.js", vaults: "vaults.js"
|
|
15
10
|
};
|
|
11
|
+
const HELP = `Subly — x402 payments from Kamino USDC vault yield
|
|
12
|
+
|
|
13
|
+
Usage: pay <command> [arguments]
|
|
14
|
+
doctor Check configuration, relayer and mainnet RPC (no signing)
|
|
15
|
+
vaults Print the locally trusted vault catalogue (offline)
|
|
16
|
+
setup-link [options] Create a human owner approval link
|
|
17
|
+
setup-status <sessionId|URL> Read setup completion
|
|
18
|
+
deposit <rawUSDC> [approvalId] Deposit into the selected vault (real funds)
|
|
19
|
+
budget Refresh and read the selected vault's yield budget
|
|
20
|
+
withdraw <rawUSDC> [approvalId] Withdraw to the agent wallet (real funds)
|
|
21
|
+
fetch <URL> Pay a compatible x402 API within the configured cap
|
|
22
|
+
mcp Start the stdio MCP server
|
|
23
|
+
--version Print package version
|
|
16
24
|
|
|
25
|
+
Amounts: 1000000 raw USDC = 1 USDC. Requires Node.js 24+.
|
|
26
|
+
Set SUBLY_RELAYER_URL, SOLANA_RPC_URL and a wallet signer before use.
|
|
27
|
+
Local signer: SUBLY_DEMO_AGENT_KEYPAIR_PATH=/absolute/path/agent.json
|
|
28
|
+
Payment cap: SUBLY_MCP_MAX_AMOUNT_RAW_USDC (default 10000 = 0.01 USDC).
|
|
29
|
+
Run pay setup-link --help for policy options.
|
|
30
|
+
Guide: https://github.com/SublyFi/subly-payment-protocol/tree/main/packages/pay
|
|
31
|
+
`;
|
|
17
32
|
const [sub, ...rest] = process.argv.slice(2);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
|
|
33
|
+
if (sub === "--version" || sub === "-v") {
|
|
34
|
+
console.log(JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8")).version);
|
|
35
|
+
} else if (!sub || sub === "--help" || sub === "-h" || sub === "help" || rest.includes("--help") || rest.includes("-h")) {
|
|
36
|
+
console.log(HELP);
|
|
37
|
+
if (sub === "setup-link") console.log("Policy options: --initial-deposit <rawUSDC> --approval-threshold <rawUSDC> --per-payment-cap <rawUSDC> --daily-api-cap <rawUSDC> --daily-deposit-cap <rawUSDC> --ttl-days <days>");
|
|
38
|
+
} else if (!Object.hasOwn(TARGETS, sub)) {
|
|
39
|
+
console.error(`Unknown command: ${sub}\nRun pay --help.`);
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
} else {
|
|
42
|
+
process.argv = [process.argv[0], join(here, TARGETS[sub]), ...rest];
|
|
43
|
+
try { await import(`./${TARGETS[sub]}`); }
|
|
44
|
+
catch (error) { console.error(error instanceof Error ? error.message : "Command failed"); process.exitCode = 1; }
|
|
24
45
|
}
|
|
25
|
-
|
|
26
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
27
|
-
process.argv = [process.argv[0], join(here, target), ...rest];
|
|
28
|
-
await import(`./${target}`);
|