x402-proxy 0.11.4 → 0.11.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/dist/bin/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import { C as run, S as buildRouteMap, _ as base58, a as getDebugLogPath, b as b
|
|
|
4
4
|
import { C as warn, S as success, _ as decodePaymentResponseHeader, b as info, c as resolveWallet, d as displayNetwork, f as formatAmount, g as wrapFetchWithPayment, h as readHistory, l as appendHistory, m as formatUsdcValue, n as fetchAllBalances, o as walletInfoCommand, p as formatTxLine, s as buildX402Client, u as calcSpend, v as dim, x as isTTY, y as error } from "../wallet-CUCoLEqs.js";
|
|
5
5
|
import { i as deserializeSessionReceipt, n as tempo, o as parseUnits, r as parseEvent, t as create } from "../client-DqtxTnu6.js";
|
|
6
6
|
import { t as privateKeyToAccount } from "../accounts-D9KsVVpJ.js";
|
|
7
|
-
import { a as Nt, c as Wt, i as Jt, l as Ct, n as setupCommand, o as R, r as Gt, s as Rt, t as runSetup } from "../setup-
|
|
7
|
+
import { a as Nt, c as Wt, i as Jt, l as Ct, n as setupCommand, o as R, r as Gt, s as Rt, t as runSetup } from "../setup-q91MbrZT.js";
|
|
8
8
|
import { n as statusCommand } from "../status-DjZdIeES.js";
|
|
9
9
|
import { dirname, join, normalize, resolve } from "node:path";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
@@ -13,6 +13,7 @@ import http from "node:http";
|
|
|
13
13
|
import { randomUUID } from "node:crypto";
|
|
14
14
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
16
17
|
//#region packages/x402-proxy/src/openclaw/defaults.ts
|
|
17
18
|
const DEFAULT_SURF_PROVIDER_ID = "surf";
|
|
18
19
|
const DEFAULT_SURF_BASE_URL = "/x402-proxy/v1";
|
|
@@ -1308,7 +1309,7 @@ async function resolveWalletForServe(flags) {
|
|
|
1308
1309
|
solanaKey: flags.solanaKey
|
|
1309
1310
|
});
|
|
1310
1311
|
if (wallet.source !== "none") return wallet;
|
|
1311
|
-
const { runSetup } = await import("../setup-
|
|
1312
|
+
const { runSetup } = await import("../setup-DPuLACk7.js");
|
|
1312
1313
|
if (isTTY()) {
|
|
1313
1314
|
dim(" No wallet found. Let's set one up first.\n");
|
|
1314
1315
|
await runSetup();
|
|
@@ -1949,7 +1950,7 @@ Examples:
|
|
|
1949
1950
|
process.exit(1);
|
|
1950
1951
|
}
|
|
1951
1952
|
dim(" No wallet found. Let's set one up first.\n");
|
|
1952
|
-
const { runSetup } = await import("../setup-
|
|
1953
|
+
const { runSetup } = await import("../setup-DPuLACk7.js");
|
|
1953
1954
|
await runSetup();
|
|
1954
1955
|
console.log();
|
|
1955
1956
|
wallet = resolveWallet();
|
|
@@ -2382,7 +2383,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2382
2383
|
});
|
|
2383
2384
|
if (wallet.source === "none") {
|
|
2384
2385
|
dim("No wallet found. Auto-generating...");
|
|
2385
|
-
const { runSetup } = await import("../setup-
|
|
2386
|
+
const { runSetup } = await import("../setup-DPuLACk7.js");
|
|
2386
2387
|
await runSetup({ nonInteractive: true });
|
|
2387
2388
|
const fresh = resolveWallet({
|
|
2388
2389
|
evmKey: flags.evmKey,
|
|
@@ -2403,7 +2404,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2403
2404
|
const { SSEClientTransport } = await import("../sse-kba68iqF.js");
|
|
2404
2405
|
const { StreamableHTTPClientTransport } = await import("../streamableHttp-DRntYTFN.js");
|
|
2405
2406
|
const { Server } = await import("../server-Dbsk9dql.js");
|
|
2406
|
-
const { StdioServerTransport } = await import("../stdio-
|
|
2407
|
+
const { StdioServerTransport } = await import("../stdio-BCoJJXun.js");
|
|
2407
2408
|
const { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ToolListChangedNotificationSchema, ResourceListChangedNotificationSchema } = await import("../types-DH9rDVeP.js");
|
|
2408
2409
|
async function connectTransport(target) {
|
|
2409
2410
|
try {
|
|
@@ -2445,7 +2446,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2445
2446
|
}
|
|
2446
2447
|
const remoteClient = new Client({
|
|
2447
2448
|
name: "x402-proxy",
|
|
2448
|
-
version: "0.11.
|
|
2449
|
+
version: "0.11.5"
|
|
2449
2450
|
});
|
|
2450
2451
|
await connectTransport(remoteClient);
|
|
2451
2452
|
function recordX402Payment(ctx) {
|
|
@@ -2476,7 +2477,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2476
2477
|
}
|
|
2477
2478
|
const localServer = new Server({
|
|
2478
2479
|
name: "x402-proxy",
|
|
2479
|
-
version: "0.11.
|
|
2480
|
+
version: "0.11.5"
|
|
2480
2481
|
}, { capabilities: {
|
|
2481
2482
|
tools: tools.length > 0 ? {} : void 0,
|
|
2482
2483
|
resources: remoteResources.length > 0 ? {} : void 0
|
|
@@ -2535,7 +2536,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2535
2536
|
const { privateKeyToAccount } = await import("../accounts-D5u2KBgr.js");
|
|
2536
2537
|
const account = privateKeyToAccount(wallet.evmKey);
|
|
2537
2538
|
const maxDeposit = config?.mppSessionBudget ?? "1";
|
|
2538
|
-
|
|
2539
|
+
const challengeAmountStore = new AsyncLocalStorage();
|
|
2539
2540
|
const wrappedMethods = tempo({
|
|
2540
2541
|
account,
|
|
2541
2542
|
maxDeposit
|
|
@@ -2543,13 +2544,14 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2543
2544
|
...m,
|
|
2544
2545
|
createCredential: async (params) => {
|
|
2545
2546
|
const req = params.challenge.request;
|
|
2546
|
-
|
|
2547
|
+
const store = challengeAmountStore.getStore();
|
|
2548
|
+
if (req.amount && store) store.amount = Number(req.amount) / 10 ** (req.decimals ?? 6);
|
|
2547
2549
|
return m.createCredential(params);
|
|
2548
2550
|
}
|
|
2549
2551
|
}));
|
|
2550
2552
|
const remoteClient = new Client({
|
|
2551
2553
|
name: "x402-proxy",
|
|
2552
|
-
version: "0.11.
|
|
2554
|
+
version: "0.11.5"
|
|
2553
2555
|
});
|
|
2554
2556
|
await connectTransport(remoteClient);
|
|
2555
2557
|
const mppClient = McpClient.wrap(remoteClient, { methods: wrappedMethods });
|
|
@@ -2564,7 +2566,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2564
2566
|
}
|
|
2565
2567
|
const localServer = new Server({
|
|
2566
2568
|
name: "x402-proxy",
|
|
2567
|
-
version: "0.11.
|
|
2569
|
+
version: "0.11.5"
|
|
2568
2570
|
}, { capabilities: {
|
|
2569
2571
|
tools: tools.length > 0 ? {} : void 0,
|
|
2570
2572
|
resources: remoteResources.length > 0 ? {} : void 0
|
|
@@ -2572,28 +2574,30 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
2572
2574
|
localServer.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools.map((t) => cloneTool(t)) }));
|
|
2573
2575
|
localServer.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
2574
2576
|
const { name, arguments: args } = request.params;
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2577
|
-
|
|
2577
|
+
const store = { amount: void 0 };
|
|
2578
|
+
return challengeAmountStore.run(store, async () => {
|
|
2579
|
+
const result = await mppClient.callTool({
|
|
2580
|
+
name,
|
|
2581
|
+
arguments: args ?? {}
|
|
2582
|
+
});
|
|
2583
|
+
if (result.receipt) {
|
|
2584
|
+
const record = {
|
|
2585
|
+
t: Date.now(),
|
|
2586
|
+
ok: true,
|
|
2587
|
+
kind: "mpp_payment",
|
|
2588
|
+
net: TEMPO_NETWORK,
|
|
2589
|
+
from: wallet.evmAddress ?? "unknown",
|
|
2590
|
+
tx: result.receipt.reference,
|
|
2591
|
+
amount: store.amount,
|
|
2592
|
+
token: "USDC",
|
|
2593
|
+
label: `mcp:${name}`
|
|
2594
|
+
};
|
|
2595
|
+
appendHistory(getHistoryPath(), record);
|
|
2596
|
+
const amountStr = store.amount !== void 0 ? formatAmount(store.amount, "USDC") : "";
|
|
2597
|
+
warn(` MPP payment for tool "${name}" (Tempo)${amountStr ? ` \u00b7 ${amountStr}` : ""}`);
|
|
2598
|
+
}
|
|
2599
|
+
return normalizeCallToolResult(result);
|
|
2578
2600
|
});
|
|
2579
|
-
if (result.receipt) {
|
|
2580
|
-
const record = {
|
|
2581
|
-
t: Date.now(),
|
|
2582
|
-
ok: true,
|
|
2583
|
-
kind: "mpp_payment",
|
|
2584
|
-
net: TEMPO_NETWORK,
|
|
2585
|
-
from: wallet.evmAddress ?? "unknown",
|
|
2586
|
-
tx: result.receipt.reference,
|
|
2587
|
-
amount: lastChallengeAmount,
|
|
2588
|
-
token: "USDC",
|
|
2589
|
-
label: `mcp:${name}`
|
|
2590
|
-
};
|
|
2591
|
-
appendHistory(getHistoryPath(), record);
|
|
2592
|
-
const amountStr = lastChallengeAmount !== void 0 ? formatAmount(lastChallengeAmount, "USDC") : "";
|
|
2593
|
-
warn(` MPP payment for tool "${name}" (Tempo)${amountStr ? ` \u00b7 ${amountStr}` : ""}`);
|
|
2594
|
-
lastChallengeAmount = void 0;
|
|
2595
|
-
}
|
|
2596
|
-
return normalizeCallToolResult(result);
|
|
2597
2601
|
});
|
|
2598
2602
|
if (remoteResources.length > 0) {
|
|
2599
2603
|
localServer.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources: remoteResources.map((r) => cloneResource(r)) }));
|
|
@@ -2950,7 +2954,7 @@ const app = buildApplication(buildRouteMap({
|
|
|
2950
2954
|
docs: { brief: "curl for x402 paid APIs" }
|
|
2951
2955
|
}), {
|
|
2952
2956
|
name: "x402-proxy",
|
|
2953
|
-
versionInfo: { currentVersion: "0.11.
|
|
2957
|
+
versionInfo: { currentVersion: "0.11.5" },
|
|
2954
2958
|
scanner: { caseStyle: "allow-kebab-for-camel" }
|
|
2955
2959
|
});
|
|
2956
2960
|
//#endregion
|
|
@@ -4,7 +4,7 @@ import { c as isConfigured, d as saveConfig, g as generateMnemonic, i as getConf
|
|
|
4
4
|
import "node:path";
|
|
5
5
|
import "node:fs";
|
|
6
6
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
7
|
-
import
|
|
7
|
+
import N, { stdin, stdout } from "node:process";
|
|
8
8
|
import "node:readline";
|
|
9
9
|
import ot from "node:readline";
|
|
10
10
|
import "node:tty";
|
|
@@ -493,7 +493,7 @@ var $t = class extends B {
|
|
|
493
493
|
//#endregion
|
|
494
494
|
//#region node_modules/.pnpm/@clack+prompts@1.1.0/node_modules/@clack/prompts/dist/index.mjs
|
|
495
495
|
function pt() {
|
|
496
|
-
return
|
|
496
|
+
return N.platform !== "win32" ? N.env.TERM !== "linux" : !!N.env.CI || !!N.env.WT_SESSION || !!N.env.TERMINUS_SUBLIME || N.env.ConEmuTask === "{cmd::Cmder}" || N.env.TERM_PROGRAM === "Terminus-Sublime" || N.env.TERM_PROGRAM === "vscode" || N.env.TERM === "xterm-256color" || N.env.TERM === "alacritty" || N.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
497
497
|
}
|
|
498
498
|
const ee = pt(), I = (e, r) => ee ? e : r, Re = I("◆", "*"), $e = I("■", "x"), de = I("▲", "x"), V = I("◇", "o"), he = I("┌", "T"), h = I("│", "|"), x = I("└", "—");
|
|
499
499
|
I("┐", "T");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Z as JSONRPCMessageSchema } from "./types-BQ17ZF7g.js";
|
|
3
|
-
import
|
|
3
|
+
import N from "node:process";
|
|
4
4
|
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
5
5
|
/**
|
|
6
6
|
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
@@ -35,7 +35,7 @@ function serializeMessage(message) {
|
|
|
35
35
|
* This transport is only available in Node.js environments.
|
|
36
36
|
*/
|
|
37
37
|
var StdioServerTransport = class {
|
|
38
|
-
constructor(_stdin =
|
|
38
|
+
constructor(_stdin = N.stdin, _stdout = N.stdout) {
|
|
39
39
|
this._stdin = _stdin;
|
|
40
40
|
this._stdout = _stdout;
|
|
41
41
|
this._readBuffer = new ReadBuffer();
|
package/package.json
CHANGED
package/dist/setup-BdSfEdx4.js
DELETED