x402-proxy 0.11.4 → 0.11.6

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-C10O8N36.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-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,10 +13,11 @@ 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";
19
- const DEFAULT_SURF_UPSTREAM_URL = "https://surf.cascade.fyi/api/v1/inference";
20
+ const DEFAULT_SURF_UPSTREAM_URL = "https://surf.cascade.fyi/api/v1/inference/v1";
20
21
  /** Known model metadata for cost/capability enrichment. */
21
22
  const MODEL_METADATA = {
22
23
  "anthropic/claude-opus-4.6": {
@@ -162,6 +163,71 @@ const MODEL_METADATA = {
162
163
  },
163
164
  contextWindow: 128e3
164
165
  },
166
+ "z-ai/glm-5.1": {
167
+ name: "GLM-5.1",
168
+ maxTokens: 202e3,
169
+ reasoning: true,
170
+ input: ["text"],
171
+ cost: {
172
+ input: .002,
173
+ output: .006,
174
+ cacheRead: 0,
175
+ cacheWrite: 0
176
+ },
177
+ contextWindow: 202e3
178
+ },
179
+ "x-ai/grok-4.20-multi-agent-beta": {
180
+ name: "Grok 4.20 Multi-Agent Beta",
181
+ maxTokens: 131072,
182
+ reasoning: true,
183
+ input: ["text"],
184
+ cost: {
185
+ input: .003,
186
+ output: .015,
187
+ cacheRead: 0,
188
+ cacheWrite: 0
189
+ },
190
+ contextWindow: 131072
191
+ },
192
+ "x-ai/grok-4.1-fast:online": {
193
+ name: "Grok 4.1 Fast (Online)",
194
+ maxTokens: 131072,
195
+ reasoning: false,
196
+ input: ["text"],
197
+ cost: {
198
+ input: .001,
199
+ output: .005,
200
+ cacheRead: 0,
201
+ cacheWrite: 0
202
+ },
203
+ contextWindow: 131072
204
+ },
205
+ "x-ai/grok-4.20-beta:online": {
206
+ name: "Grok 4.20 Beta (Online)",
207
+ maxTokens: 131072,
208
+ reasoning: true,
209
+ input: ["text"],
210
+ cost: {
211
+ input: .004,
212
+ output: .015,
213
+ cacheRead: 0,
214
+ cacheWrite: 0
215
+ },
216
+ contextWindow: 131072
217
+ },
218
+ "x-ai/grok-4.20-multi-agent-beta:online": {
219
+ name: "Grok 4.20 Multi-Agent Beta (Online)",
220
+ maxTokens: 131072,
221
+ reasoning: true,
222
+ input: ["text"],
223
+ cost: {
224
+ input: .004,
225
+ output: .015,
226
+ cacheRead: 0,
227
+ cacheWrite: 0
228
+ },
229
+ contextWindow: 131072
230
+ },
165
231
  "qwen/qwen-2.5-7b-instruct": {
166
232
  name: "Qwen 2.5 7B Instruct",
167
233
  maxTokens: 32768,
@@ -234,7 +300,7 @@ function resolveProviders(config) {
234
300
  const entries = Object.entries(raw).length > 0 ? Object.entries(raw).map(([id, provider]) => ({
235
301
  id,
236
302
  baseUrl: provider.baseUrl || "/x402-proxy/v1",
237
- upstreamUrl: provider.upstreamUrl || "https://surf.cascade.fyi/api/v1/inference",
303
+ upstreamUrl: provider.upstreamUrl || "https://surf.cascade.fyi/api/v1/inference/v1",
238
304
  protocol: resolveProtocol(provider.protocol, defaultProtocol),
239
305
  mppSessionBudget: resolveMppSessionBudget(provider.mppSessionBudget, defaultMppSessionBudget),
240
306
  models: provider.models && provider.models.length > 0 ? provider.models : DEFAULT_SURF_MODELS
@@ -1308,7 +1374,7 @@ async function resolveWalletForServe(flags) {
1308
1374
  solanaKey: flags.solanaKey
1309
1375
  });
1310
1376
  if (wallet.source !== "none") return wallet;
1311
- const { runSetup } = await import("../setup-BdSfEdx4.js");
1377
+ const { runSetup } = await import("../setup-DPuLACk7.js");
1312
1378
  if (isTTY()) {
1313
1379
  dim(" No wallet found. Let's set one up first.\n");
1314
1380
  await runSetup();
@@ -1363,7 +1429,7 @@ async function startServeServer(options = {}) {
1363
1429
  const resolvedProtocol = resolveProtocol(options.protocol ?? config?.preferredProtocol);
1364
1430
  const configuredMppBudget = resolveMppSessionBudget(config?.mppSessionBudget);
1365
1431
  const preferredNetwork = config?.defaultNetwork ?? await detectPreferredNetwork(wallet);
1366
- const upstreamUrl = options.upstreamUrl ?? "https://surf.cascade.fyi/api/v1/inference";
1432
+ const upstreamUrl = options.upstreamUrl ?? "https://surf.cascade.fyi/api/v1/inference/v1";
1367
1433
  const x402Proxy = createX402ProxyHandler({ client: await buildX402Client(wallet, {
1368
1434
  preferredNetwork: preferredNetwork || void 0,
1369
1435
  network: options.network,
@@ -1598,7 +1664,7 @@ not listed above.`
1598
1664
  async func(flags, ...rawClaudeArgs) {
1599
1665
  const debug = process.env.X402_PROXY_DEBUG === "1";
1600
1666
  const started = await startServeServer({
1601
- upstreamUrl: flags.upstream ?? "https://surf.cascade.fyi/api/v1/inference",
1667
+ upstreamUrl: flags.upstream ?? "https://surf.cascade.fyi/api/v1/inference/v1",
1602
1668
  port: Number(flags.port),
1603
1669
  protocol: flags.protocol ?? "mpp",
1604
1670
  network: flags.network,
@@ -1949,7 +2015,7 @@ Examples:
1949
2015
  process.exit(1);
1950
2016
  }
1951
2017
  dim(" No wallet found. Let's set one up first.\n");
1952
- const { runSetup } = await import("../setup-BdSfEdx4.js");
2018
+ const { runSetup } = await import("../setup-DPuLACk7.js");
1953
2019
  await runSetup();
1954
2020
  console.log();
1955
2021
  wallet = resolveWallet();
@@ -2382,7 +2448,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2382
2448
  });
2383
2449
  if (wallet.source === "none") {
2384
2450
  dim("No wallet found. Auto-generating...");
2385
- const { runSetup } = await import("../setup-BdSfEdx4.js");
2451
+ const { runSetup } = await import("../setup-DPuLACk7.js");
2386
2452
  await runSetup({ nonInteractive: true });
2387
2453
  const fresh = resolveWallet({
2388
2454
  evmKey: flags.evmKey,
@@ -2403,7 +2469,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2403
2469
  const { SSEClientTransport } = await import("../sse-kba68iqF.js");
2404
2470
  const { StreamableHTTPClientTransport } = await import("../streamableHttp-DRntYTFN.js");
2405
2471
  const { Server } = await import("../server-Dbsk9dql.js");
2406
- const { StdioServerTransport } = await import("../stdio-CdmkLt8r.js");
2472
+ const { StdioServerTransport } = await import("../stdio-BCoJJXun.js");
2407
2473
  const { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ToolListChangedNotificationSchema, ResourceListChangedNotificationSchema } = await import("../types-DH9rDVeP.js");
2408
2474
  async function connectTransport(target) {
2409
2475
  try {
@@ -2445,7 +2511,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2445
2511
  }
2446
2512
  const remoteClient = new Client({
2447
2513
  name: "x402-proxy",
2448
- version: "0.11.4"
2514
+ version: "0.11.6"
2449
2515
  });
2450
2516
  await connectTransport(remoteClient);
2451
2517
  function recordX402Payment(ctx) {
@@ -2476,7 +2542,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2476
2542
  }
2477
2543
  const localServer = new Server({
2478
2544
  name: "x402-proxy",
2479
- version: "0.11.4"
2545
+ version: "0.11.6"
2480
2546
  }, { capabilities: {
2481
2547
  tools: tools.length > 0 ? {} : void 0,
2482
2548
  resources: remoteResources.length > 0 ? {} : void 0
@@ -2535,7 +2601,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2535
2601
  const { privateKeyToAccount } = await import("../accounts-D5u2KBgr.js");
2536
2602
  const account = privateKeyToAccount(wallet.evmKey);
2537
2603
  const maxDeposit = config?.mppSessionBudget ?? "1";
2538
- let lastChallengeAmount;
2604
+ const challengeAmountStore = new AsyncLocalStorage();
2539
2605
  const wrappedMethods = tempo({
2540
2606
  account,
2541
2607
  maxDeposit
@@ -2543,13 +2609,14 @@ Wallet is auto-generated on first run. No env vars needed.`
2543
2609
  ...m,
2544
2610
  createCredential: async (params) => {
2545
2611
  const req = params.challenge.request;
2546
- if (req.amount) lastChallengeAmount = Number(req.amount) / 10 ** (req.decimals ?? 6);
2612
+ const store = challengeAmountStore.getStore();
2613
+ if (req.amount && store) store.amount = Number(req.amount) / 10 ** (req.decimals ?? 6);
2547
2614
  return m.createCredential(params);
2548
2615
  }
2549
2616
  }));
2550
2617
  const remoteClient = new Client({
2551
2618
  name: "x402-proxy",
2552
- version: "0.11.4"
2619
+ version: "0.11.6"
2553
2620
  });
2554
2621
  await connectTransport(remoteClient);
2555
2622
  const mppClient = McpClient.wrap(remoteClient, { methods: wrappedMethods });
@@ -2564,7 +2631,7 @@ Wallet is auto-generated on first run. No env vars needed.`
2564
2631
  }
2565
2632
  const localServer = new Server({
2566
2633
  name: "x402-proxy",
2567
- version: "0.11.4"
2634
+ version: "0.11.6"
2568
2635
  }, { capabilities: {
2569
2636
  tools: tools.length > 0 ? {} : void 0,
2570
2637
  resources: remoteResources.length > 0 ? {} : void 0
@@ -2572,28 +2639,30 @@ Wallet is auto-generated on first run. No env vars needed.`
2572
2639
  localServer.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: tools.map((t) => cloneTool(t)) }));
2573
2640
  localServer.setRequestHandler(CallToolRequestSchema, async (request) => {
2574
2641
  const { name, arguments: args } = request.params;
2575
- const result = await mppClient.callTool({
2576
- name,
2577
- arguments: args ?? {}
2642
+ const store = { amount: void 0 };
2643
+ return challengeAmountStore.run(store, async () => {
2644
+ const result = await mppClient.callTool({
2645
+ name,
2646
+ arguments: args ?? {}
2647
+ });
2648
+ if (result.receipt) {
2649
+ const record = {
2650
+ t: Date.now(),
2651
+ ok: true,
2652
+ kind: "mpp_payment",
2653
+ net: TEMPO_NETWORK,
2654
+ from: wallet.evmAddress ?? "unknown",
2655
+ tx: result.receipt.reference,
2656
+ amount: store.amount,
2657
+ token: "USDC",
2658
+ label: `mcp:${name}`
2659
+ };
2660
+ appendHistory(getHistoryPath(), record);
2661
+ const amountStr = store.amount !== void 0 ? formatAmount(store.amount, "USDC") : "";
2662
+ warn(` MPP payment for tool "${name}" (Tempo)${amountStr ? ` \u00b7 ${amountStr}` : ""}`);
2663
+ }
2664
+ return normalizeCallToolResult(result);
2578
2665
  });
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
2666
  });
2598
2667
  if (remoteResources.length > 0) {
2599
2668
  localServer.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources: remoteResources.map((r) => cloneResource(r)) }));
@@ -2950,7 +3019,7 @@ const app = buildApplication(buildRouteMap({
2950
3019
  docs: { brief: "curl for x402 paid APIs" }
2951
3020
  }), {
2952
3021
  name: "x402-proxy",
2953
- versionInfo: { currentVersion: "0.11.4" },
3022
+ versionInfo: { currentVersion: "0.11.6" },
2954
3023
  scanner: { caseStyle: "allow-kebab-for-camel" }
2955
3024
  });
2956
3025
  //#endregion
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { t as runSetup } from "./setup-q91MbrZT.js";
3
+ export { runSetup };
@@ -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 process$1, { stdin, stdout } from "node:process";
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 process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
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 process from "node:process";
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 = process.stdin, _stdout = process.stdout) {
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x402-proxy",
3
3
  "description": "curl for x402 paid APIs. Auto-pays any endpoint on Base, Solana, and Tempo.",
4
- "version": "0.11.4",
4
+ "version": "0.11.6",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "license": "Apache-2.0",
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { t as runSetup } from "./setup-C10O8N36.js";
3
- export { runSetup };