@paybox-sh/sdk 0.8.1 → 0.8.2
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/SKILL.md +67 -6
- package/dist/{chunk-OBZSVPP7.js → chunk-WRPYONXW.js} +6 -85
- package/dist/chunk-WRPYONXW.js.map +1 -0
- package/dist/cli.js +45 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +0 -144
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-OBZSVPP7.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -5,11 +5,12 @@ import {
|
|
|
5
5
|
appBaseFrom,
|
|
6
6
|
configDir,
|
|
7
7
|
configFile,
|
|
8
|
+
didNotHappen,
|
|
8
9
|
loadConfig,
|
|
9
10
|
loginDevice,
|
|
10
11
|
openBrowser,
|
|
11
12
|
saveConfig
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WRPYONXW.js";
|
|
13
14
|
|
|
14
15
|
// src/cli.ts
|
|
15
16
|
import { spawnSync } from "node:child_process";
|
|
@@ -28,6 +29,8 @@ function jsonMode() {
|
|
|
28
29
|
function emit(data) {
|
|
29
30
|
if (jsonMode()) console.log(JSON.stringify(data, null, 2));
|
|
30
31
|
else console.dir(data, { depth: null, colors: process.stdout.isTTY });
|
|
32
|
+
const d = data;
|
|
33
|
+
if (didNotHappen(d) || didNotHappen(d?.response)) process.exitCode = 1;
|
|
31
34
|
}
|
|
32
35
|
function client() {
|
|
33
36
|
return PayboxClient.fromConfig({ baseUrl: program.opts().baseUrl });
|
|
@@ -48,11 +51,23 @@ function optInt(flag, value) {
|
|
|
48
51
|
}
|
|
49
52
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
50
53
|
function credentialId(value) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
return uuid(
|
|
55
|
+
value,
|
|
56
|
+
"--credential expects a credential id, not a name",
|
|
57
|
+
"Run `paybox credentials` and use the `credential.id` of the one you want."
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function requestId(value) {
|
|
61
|
+
return uuid(
|
|
62
|
+
value,
|
|
63
|
+
"not a request id",
|
|
64
|
+
"Request ids come back from the command that created the request, and from `paybox requests`."
|
|
54
65
|
);
|
|
55
66
|
}
|
|
67
|
+
function uuid(value, what, hint) {
|
|
68
|
+
if (UUID.test(value)) return value;
|
|
69
|
+
throw new Error(`${what}: got ${JSON.stringify(value)}. ${hint}`);
|
|
70
|
+
}
|
|
56
71
|
function isNewer(a, b) {
|
|
57
72
|
const pa = a.split(".").map(Number);
|
|
58
73
|
const pb = b.split(".").map(Number);
|
|
@@ -76,7 +91,9 @@ async function run(fn) {
|
|
|
76
91
|
try {
|
|
77
92
|
await fn();
|
|
78
93
|
} catch (err) {
|
|
79
|
-
|
|
94
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
95
|
+
if (jsonMode()) console.log(JSON.stringify({ error: message }, null, 2));
|
|
96
|
+
else console.error(message);
|
|
80
97
|
process.exitCode = 1;
|
|
81
98
|
}
|
|
82
99
|
}
|
|
@@ -96,10 +113,11 @@ program.command("login").description("Authenticate via OAuth (browser + passkey)
|
|
|
96
113
|
const baseUrl = (program.opts().baseUrl ?? process.env.PAYBOX_API_URL ?? cfg.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
97
114
|
cfg.baseUrl = baseUrl;
|
|
98
115
|
if (opts.appUrl) cfg.appUrl = opts.appUrl;
|
|
116
|
+
const keepExistingLogin = Boolean(opts.signingKey) && Boolean(cfg.apiKey ?? cfg.oauth);
|
|
99
117
|
if (opts.key) {
|
|
100
118
|
cfg.apiKey = opts.key;
|
|
101
119
|
delete cfg.oauth;
|
|
102
|
-
} else {
|
|
120
|
+
} else if (!keepExistingLogin) {
|
|
103
121
|
cfg.oauth = await loginDevice(baseUrl);
|
|
104
122
|
delete cfg.apiKey;
|
|
105
123
|
}
|
|
@@ -265,7 +283,7 @@ program.command("verify-solana-balance").description("Verify a Solana transactio
|
|
|
265
283
|
)
|
|
266
284
|
)
|
|
267
285
|
);
|
|
268
|
-
program.command("claim <request-id>").description("Claim the usable card credentials of an approved payment (one-time)").action((id) => run(async () => emit(await client().claimPaymentCredentials(id))));
|
|
286
|
+
program.command("claim <request-id>").description("Claim the usable card credentials of an approved payment (one-time)").action((id) => run(async () => emit(await client().claimPaymentCredentials(requestId(id)))));
|
|
269
287
|
program.command("account-change").description("Get a manage_url for the USER to update this client's access in the app").option("--note <text>", "why the change is needed (shown to the user)").action((o) => run(async () => emit(await client().requestAccountChange(o.note))));
|
|
270
288
|
program.command("buy-link").description("Signed MoonPay checkout URL funding a granted wallet (charges nothing)").requiredOption("--credential <id>", "a granted wallet credential").option(
|
|
271
289
|
"--destination <chain>",
|
|
@@ -326,7 +344,8 @@ hyperliquid.command("token <name>").description("Resolve one token by name").act
|
|
|
326
344
|
program.command("request <id>").description("Poll a request's status").option("--wait", "block until it leaves the pending state").action(
|
|
327
345
|
(id, o) => run(async () => {
|
|
328
346
|
const c = client();
|
|
329
|
-
|
|
347
|
+
const rid = requestId(id);
|
|
348
|
+
emit(o.wait ? await c.waitForRequest(rid) : await c.getRequest(rid));
|
|
330
349
|
})
|
|
331
350
|
);
|
|
332
351
|
program.command("version").description("Show the installed CLI version (and whether an update is available)").action(
|
|
@@ -343,8 +362,6 @@ program.command("version").description("Show the installed CLI version (and whet
|
|
|
343
362
|
version: VERSION,
|
|
344
363
|
latest: latest ?? null,
|
|
345
364
|
updateAvailable,
|
|
346
|
-
// Another `paybox` earlier on PATH is a real way to be misled about
|
|
347
|
-
// what just ran, so name the one that did.
|
|
348
365
|
binary: process.argv[1] ?? null
|
|
349
366
|
});
|
|
350
367
|
return;
|
|
@@ -384,5 +401,23 @@ program.command("uninstall").description("Remove stored PayBox credentials/confi
|
|
|
384
401
|
);
|
|
385
402
|
})
|
|
386
403
|
);
|
|
404
|
+
function rejectUnknownCommand(argv) {
|
|
405
|
+
if (!argv.includes("--help") && !argv.includes("-h")) return;
|
|
406
|
+
let node = program;
|
|
407
|
+
for (let i = 2; i < argv.length; i++) {
|
|
408
|
+
const arg = argv[i];
|
|
409
|
+
if (node.options.some((o) => o.long === arg && o.required)) i++;
|
|
410
|
+
if (arg.startsWith("-")) continue;
|
|
411
|
+
const next = node.commands.find((c) => c.name() === arg || c.aliases().includes(arg));
|
|
412
|
+
if (next) {
|
|
413
|
+
node = next;
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (node.commands.length === 0) return;
|
|
417
|
+
if (node === program && arg === "help") return;
|
|
418
|
+
program.error(`error: unknown command '${arg}'`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
rejectUnknownCommand(process.argv);
|
|
387
422
|
program.parseAsync(process.argv);
|
|
388
423
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n// The `paybox` CLI — a thin wrapper over PayboxClient. Mirrors the MCP tools as\n// subcommands; `--json` on any command emits machine-readable output.\n\nimport { spawnSync } from \"node:child_process\";\nimport { readFileSync, rmSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { createInterface } from \"node:readline/promises\";\n\nimport { Command } from \"commander\";\n\nimport { agentClientId, appBaseFrom, loginDevice, openBrowser } from \"./auth.js\";\nimport { PayboxClient } from \"./client.js\";\nimport { configDir, configFile, loadConfig, saveConfig } from \"./config.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.paybox.sh\";\nconst PKG = \"@paybox-sh/sdk\";\n// Read from the manifest rather than a literal: a hardcoded copy silently goes\n// stale on release, and `update` compares against it to decide whether a newer\n// version exists. Resolves from `dist/` when bundled and from `src/` under tsx.\nconst VERSION = createRequire(import.meta.url)(\"../package.json\").version as string;\n\nconst program = new Command();\nprogram\n .name(\"paybox\")\n .description(\"PayBox agent CLI — vaulted cards, wallets, and secrets for agents\")\n .version(VERSION)\n .option(\"--base-url <url>\", \"API origin (default https://api.paybox.sh or stored)\")\n .option(\"--json\", \"machine-readable JSON output\");\n\nfunction jsonMode(): boolean {\n return Boolean(program.opts().json);\n}\n\nfunction emit(data: unknown): void {\n if (jsonMode()) console.log(JSON.stringify(data, null, 2));\n else console.dir(data, { depth: null, colors: process.stdout.isTTY });\n}\n\nfunction client(): PayboxClient {\n return PayboxClient.fromConfig({ baseUrl: program.opts().baseUrl });\n}\n\nfunction readIntent(value: string): unknown {\n const raw = value.startsWith(\"@\") ? readFileSync(value.slice(1), \"utf8\") : value;\n return JSON.parse(raw);\n}\n\nfunction int(flag: string, value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n)) {\n throw new Error(`--${flag} must be an integer, got ${JSON.stringify(value)}`);\n }\n return n;\n}\n\nfunction optInt(flag: string, value: string | undefined): number | undefined {\n return value === undefined ? undefined : int(flag, value);\n}\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\n/** `--credential` is the id from `paybox credentials`, never the wallet's name.\n * The API takes a UUID, so a name fails deserialization and comes back as a bare\n * 422 that reads like a server fault. */\nfunction credentialId(value: string): string {\n if (UUID.test(value)) return value;\n throw new Error(\n `--credential expects a credential id, not a name: got ${JSON.stringify(value)}. ` +\n \"Run `paybox credentials` and use the `credential.id` of the one you want.\",\n );\n}\n\n/** True when semver `a` is strictly greater than `b` (plain x.y.z). */\nfunction isNewer(a: string, b: string): boolean {\n const pa = a.split(\".\").map(Number);\n const pb = b.split(\".\").map(Number);\n for (let i = 0; i < 3; i++) {\n const x = pa[i] ?? 0;\n const y = pb[i] ?? 0;\n if (x !== y) return x > y;\n }\n return false;\n}\n\nasync function prompt(question: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\"; // non-interactive: skip\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n try {\n return (await rl.question(question)).trim();\n } finally {\n rl.close();\n }\n}\n\nasync function run(fn: () => Promise<void>): Promise<void> {\n try {\n await fn();\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\n/** A request parked at `pending_signature` can only complete in-process with a\n * `pbxk1.` key (there is no signing window on this surface). */\nfunction warnIfUnsignable(c: PayboxClient, status: string): void {\n if (status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"awaiting signatures but no valid pbxk1. signing key is set — \" +\n \"set PAYBOX_SIGNING_KEY and re-run `paybox login`, then poll `paybox request <id>`.\",\n );\n }\n}\n\nprogram\n .command(\"login\")\n .description(\"Authenticate via OAuth (browser + passkey), or store a pbx_live_ key\")\n .option(\"--key <key>\", \"store a pbx_live_ personal API key instead of OAuth\")\n .option(\n \"--signing-key <token>\",\n \"store a pbxk1. wallet signing key; prefer PAYBOX_SIGNING_KEY (an argument is visible in shell history)\",\n )\n .option(\"--app-url <url>\", \"PayBox app origin for key provisioning (default: derived from --base-url)\")\n .option(\"--no-provision\", \"skip the wallet signing-key provisioning step\")\n .action((opts) =>\n run(async () => {\n const cfg = loadConfig();\n const baseUrl = (\n program.opts().baseUrl ??\n process.env.PAYBOX_API_URL ??\n cfg.baseUrl ??\n DEFAULT_BASE_URL\n ).replace(/\\/+$/, \"\");\n cfg.baseUrl = baseUrl;\n if (opts.appUrl) cfg.appUrl = opts.appUrl;\n\n // Step 1 — authenticate.\n if (opts.key) {\n cfg.apiKey = opts.key;\n delete cfg.oauth;\n } else {\n cfg.oauth = await loginDevice(baseUrl);\n delete cfg.apiKey;\n }\n if (opts.signingKey) cfg.signingKey = opts.signingKey;\n saveConfig(cfg);\n console.error(`Saved credentials to ${configFile()}`);\n\n // Step 2 — provision a wallet signing key. Runs only after OAuth (the app\n // session is warm) and only when one wasn't supplied or disabled. The app\n // mints a key scoped to this agent and shows a `pbxk1.` token to paste back.\n if (!cfg.oauth || opts.signingKey || opts.provision === false) return;\n const cid = agentClientId(cfg.oauth.accessToken);\n const appBase = appBaseFrom(baseUrl, opts.appUrl ?? process.env.PAYBOX_APP_URL ?? cfg.appUrl);\n if (!cid || !appBase) {\n console.error(\n \"To enable wallet sign/swap, provision a signing key, then set\\n\" +\n \" PAYBOX_SIGNING_KEY=<pbxk1...> and re-run `paybox login`\" +\n (cid && !appBase ? \" (or pass --app-url <paybox app origin>)\" : \"\"),\n );\n return;\n }\n const url = `${appBase}/agent-key?client_id=${cid}`;\n console.error(\n `\\nNext, provision a wallet signing key for this agent (needed for sign/swap):\\n ${url}\\n`,\n );\n openBrowser(url);\n // Nobody sees the prompt without a TTY, so read the env var the client\n // already honours instead. Passing the key as an argument would put it in\n // shell history and in any process listing. At a terminal the prompt still\n // decides, so pressing Enter skips even when the env var is set.\n const key = process.stdin.isTTY\n ? await prompt(\"Paste the pbxk1. signing key when ready (or Enter to skip): \")\n : (process.env.PAYBOX_SIGNING_KEY ?? \"\").trim();\n if (key) {\n cfg.signingKey = key;\n saveConfig(cfg);\n console.error(\"Signing key saved — sign/swap enabled.\");\n } else if (process.stdin.isTTY) {\n console.error(\n \"Skipped — provision one later by setting PAYBOX_SIGNING_KEY and re-running `paybox login`.\",\n );\n } else {\n console.error(\n \"No signing key configured, so sign and swap will stop at pending_signature.\\n\" +\n \"Set PAYBOX_SIGNING_KEY to the `pbxk1.` token and re-run `paybox login`.\",\n );\n }\n }),\n );\n\nprogram\n .command(\"logout\")\n .description(\"Forget stored credentials\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n delete cfg.apiKey;\n delete cfg.oauth;\n delete cfg.signingKey;\n saveConfig(cfg);\n console.error(\"Logged out.\");\n }),\n );\n\nprogram\n .command(\"whoami\")\n .description(\"Show the configured endpoint, auth mode, and signing capability\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n const c = client();\n const mode = process.env.PAYBOX_ACCESS_TOKEN\n ? \"oauth (env token)\"\n : process.env.PAYBOX_API_KEY || cfg.apiKey\n ? \"api key\"\n : cfg.oauth\n ? \"oauth\"\n : \"none\";\n emit({ baseUrl: c.baseUrl, auth: mode, canSign: c.canSign, configFile: configFile() });\n }),\n );\n\nprogram\n .command(\"credentials\")\n .description(\"List the credentials this client may use\")\n .action(() => run(async () => emit(await client().listCredentials())));\n\nprogram\n .command(\"pay\")\n .description(\"Charge a card credential\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--merchant <name>\")\n .requiredOption(\"--url <url>\", \"real merchant URL the card is bound to\")\n .requiredOption(\"--amount <cents>\", \"amount in cents\")\n .option(\"--currency <code>\", \"ISO 4217 currency\", \"USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestPayment({\n credentialId: credentialId(o.credential),\n merchant: o.merchant,\n merchantUrl: o.url,\n amountCents: int(\"amount\", o.amount),\n currency: o.currency,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"secret\")\n .description(\"Reveal a secret credential (one-time token, or --raw value)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .option(\"--raw\", \"return the raw secret value (grant-gated)\")\n .option(\"--purpose <text>\", \"why the secret is requested (shown on approval)\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestSecret({\n credentialId: credentialId(o.credential),\n raw: Boolean(o.raw),\n purpose: o.purpose,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"sign\")\n .description(\"Sign with a wallet credential (intent JSON, or @file)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--intent <json>\", 'a SignIntent, e.g. \\'{\"op\":\"message\",\"message\":\"hi\"}\\' or @intent.json')\n .action((o) =>\n run(async () => {\n const c = client();\n const res = await c.requestWalletSign({\n credentialId: credentialId(o.credential),\n intent: readIntent(o.intent) as never,\n });\n warnIfUnsignable(c, res.status);\n emit(res);\n }),\n );\n\nprogram\n .command(\"swap\")\n .description(\"Swap tokens from a wallet credential\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--src-chain <caip2>\")\n .requiredOption(\"--src-token <addr>\", '\"native\" or a token address')\n .requiredOption(\"--dst-token <addr>\")\n .requiredOption(\"--amount <smallest-unit>\", \"source amount in smallest units\")\n .option(\"--dst-chain <caip2>\", \"defaults to --src-chain\")\n .option(\"--direction <dir>\", \"exact-amount-in | exact-amount-out\", \"exact-amount-in\")\n .option(\"--slippage <bps>\", \"slippage in bps\", \"150\")\n .option(\"--recipient <addr>\")\n .option(\"--value-cents <n>\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.requestSwap(\n {\n credentialId: credentialId(o.credential),\n srcChain: o.srcChain,\n dstChain: o.dstChain,\n srcToken: o.srcToken,\n dstToken: o.dstToken,\n amount: o.amount,\n swapDirection: o.direction,\n slippageBps: int(\"slippage\", o.slippage),\n recipient: o.recipient,\n valueCents: optInt(\"value-cents\", o.valueCents),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"discover [query]\")\n .description(\"Discover curated paid x402 services from Bazaar (optional search)\")\n .option(\"--raw\", \"return uncurated compact Bazaar service summaries (debug)\")\n .action((query, o) =>\n run(async () => emit(await client().discoverServices(query, { raw: Boolean(o.raw) }))),\n );\n\nprogram\n .command(\"pay-x402\")\n .description(\"Pay a paid x402 endpoint (header mode — returns the X-PAYMENT header to replay)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--accepts <json>\", \"the 402's accepts[] array (JSON or @file)\")\n .requiredOption(\"--url <url>\", \"the paywalled resource URL\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.payX402(\n {\n credentialId: credentialId(o.credential),\n accepts: readIntent(o.accepts) as unknown[],\n resourceUrl: o.url,\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"use-service\")\n .description(\"Fetch a paid x402 resource and have paybox pay for it (gateway mode)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--url <url>\", \"the paid x402 resource URL\")\n .option(\"--method <verb>\", \"HTTP method\", \"GET\")\n .option(\"--body <json>\", \"request body (JSON or @file)\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.useService(\n {\n credentialId: credentialId(o.credential),\n url: o.url,\n method: o.method,\n body: o.body === undefined ? undefined : readIntent(o.body),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"portfolio\")\n .description(\"List a wallet address's token balances across chains\")\n .requiredOption(\"--address <addr>\")\n .option(\"--networks <ids>\", 'comma-separated network IDs, e.g. \"1,8453\"')\n .action((o) =>\n run(async () =>\n emit(await client().getPortfolio({ address: o.address, networkIds: o.networks })),\n ),\n );\n\nprogram\n .command(\"verify-solana-balance\")\n .description(\"Verify a Solana transaction's wallet/token effect and current balance\")\n .requiredOption(\"--address <addr>\", \"canonical Solana wallet address\")\n .requiredOption(\"--mint <addr>\", \"canonical SPL or Token-2022 mint\")\n .requiredOption(\"--transaction <signature>\", \"confirmed Solana transaction signature\")\n .action((o) =>\n run(async () =>\n emit(\n await client().verifySolanaBalance({\n address: o.address,\n tokenMint: o.mint,\n transactionSignature: o.transaction,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"claim <request-id>\")\n .description(\"Claim the usable card credentials of an approved payment (one-time)\")\n .action((id) => run(async () => emit(await client().claimPaymentCredentials(id))));\n\nprogram\n .command(\"account-change\")\n .description(\"Get a manage_url for the USER to update this client's access in the app\")\n .option(\"--note <text>\", \"why the change is needed (shown to the user)\")\n .action((o) => run(async () => emit(await client().requestAccountChange(o.note))));\n\nprogram\n .command(\"buy-link\")\n .description(\"Signed MoonPay checkout URL funding a granted wallet (charges nothing)\")\n .requiredOption(\"--credential <id>\", \"a granted wallet credential\")\n .option(\n \"--destination <chain>\",\n \"exact network: eip155:8453 (default EVM), eip155:1, or solana:mainnet\",\n )\n .option(\"--currency <code>\", \"enabled MoonPay code matching the exact destination\")\n .option(\"--amount-usd <n>\", \"prefill amount in USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().getBuyLink({\n credentialId: credentialId(o.credential),\n destinationChain: o.destination,\n currencyCode: o.currency,\n amountUsd: o.amountUsd === undefined ? undefined : Number(o.amountUsd),\n }),\n ),\n ),\n );\n\n// ---- World discovery. Money tools require the geofenced MCP signing window. ----\nconst world = program\n .command(\"world\")\n .description(\"World prediction markets (requires the world plugin)\");\n\nworld\n .command(\"markets\")\n .description(\"Browse markets (or events with --events)\")\n .option(\"--events\", \"list events (each groups its markets)\")\n .option(\"--limit <n>\")\n .option(\"--cursor <n>\", \"rows to skip; the response carries the next cursor\")\n .option(\"--event-ticker <ticker>\")\n .option(\"--series-ticker <ticker>\")\n .option(\"--status <status>\", \"active | initialized | determined | finalized\")\n .action((o) =>\n run(async () =>\n emit(\n await client().worldMarkets({\n events: Boolean(o.events),\n limit: optInt(\"limit\", o.limit),\n cursor: optInt(\"cursor\", o.cursor),\n eventTicker: o.eventTicker,\n seriesTicker: o.seriesTicker,\n status: o.status,\n }),\n ),\n ),\n );\n\nworld\n .command(\"market <event-ticker>\")\n .description(\"One event with its nested markets (disable with --no-nested)\")\n .option(\"--no-nested\", \"exclude the event's markets\")\n .action((ticker, o) =>\n run(async () => emit(await client().worldMarket(ticker, Boolean(o.nested)))),\n );\n\nworld\n .command(\"orderbook <id>\")\n .description(\"A market's orderbook (id is a ticker, or a mint with --by-mint)\")\n .option(\"--by-mint\", \"look up by outcome mint instead of ticker\")\n .action((id, o) =>\n run(async () => emit(await client().worldOrderbook(id, Boolean(o.byMint)))),\n );\n\nworld\n .command(\"prices <ticker>\")\n .description(\"A market's price history\")\n .requiredOption(\"--start <unix-ts>\")\n .requiredOption(\"--end <unix-ts>\")\n .option(\"--resolution <n>\")\n .action((ticker, o) =>\n run(async () =>\n emit(\n await client().worldPrices({\n ticker,\n startTs: int(\"start\", o.start),\n endTs: int(\"end\", o.end),\n resolution: optInt(\"resolution\", o.resolution),\n }),\n ),\n ),\n );\n\nworld\n .command(\"filter-mints <addresses...>\")\n .description(\"Filter addresses down to World outcome mints\")\n .action((addresses) =>\n run(async () => emit(await client().worldFilterOutcomeMints(addresses))),\n );\n\nworld\n .command(\"positions <address>\")\n .description(\"Solana token positions for an address\")\n .action((address) => run(async () => emit(await client().worldPositions(address))));\n\n// ---- Hyperliquid plugin (read-only spot discovery). Requires the\n// `hyperliquid` plugin enabled in the paybox app. ----\nconst hyperliquid = program\n .command(\"hyperliquid\")\n .description(\"Hyperliquid spot discovery (requires the hyperliquid plugin)\");\n\nhyperliquid\n .command(\"markets\")\n .description(\"Spot markets\")\n .action(() => run(async () => emit(await client().hyperliquidMarkets())));\n\nhyperliquid\n .command(\"prices\")\n .description(\"Spot prices\")\n .action(() => run(async () => emit(await client().hyperliquidPrices())));\n\nhyperliquid\n .command(\"token <name>\")\n .description(\"Resolve one token by name\")\n .action((name) => run(async () => emit(await client().hyperliquidToken(name))));\n\nprogram\n .command(\"request <id>\")\n .description(\"Poll a request's status\")\n .option(\"--wait\", \"block until it leaves the pending state\")\n .action((id, o) =>\n run(async () => {\n const c = client();\n emit(o.wait ? await c.waitForRequest(id) : await c.getRequest(id));\n }),\n );\n\nprogram\n .command(\"version\")\n .description(\"Show the installed CLI version (and whether an update is available)\")\n .action(() =>\n run(async () => {\n let latest: string | undefined;\n try {\n const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`);\n if (res.ok) latest = ((await res.json()) as { version?: string }).version;\n } catch {\n /* offline — just report the installed version */\n }\n const updateAvailable = Boolean(latest && isNewer(latest, VERSION));\n if (jsonMode()) {\n emit({\n version: VERSION,\n latest: latest ?? null,\n updateAvailable,\n // Another `paybox` earlier on PATH is a real way to be misled about\n // what just ran, so name the one that did.\n binary: process.argv[1] ?? null,\n });\n return;\n }\n console.log(`${PKG} v${VERSION}`);\n if (updateAvailable) {\n console.log(`Update available: v${latest} — run \\`paybox update\\`.`);\n }\n }),\n );\n\nprogram\n .command(\"update\")\n .description(\"Update the globally-installed paybox CLI to the latest version\")\n .option(\"--print\", \"print the update command instead of running it\")\n .action((opts) =>\n run(async () => {\n const args = [\"install\", \"-g\", `${PKG}@latest`];\n if (opts.print) {\n console.log(`npm ${args.join(\" \")}`);\n return;\n }\n console.error(`Updating ${PKG} (npm ${args.join(\" \")})…`);\n const r = spawnSync(\"npm\", args, { stdio: \"inherit\" });\n if (r.status !== 0) {\n console.error(\n `\\nIf this isn't a global install: run \\`pnpm up ${PKG}\\` in your project, ` +\n `or use \\`npx ${PKG}@latest …\\` to always run the latest.`,\n );\n process.exitCode = r.status ?? 1;\n }\n }),\n );\n\nprogram\n .command(\"uninstall\")\n .description(\"Remove stored PayBox credentials/config (and show how to remove the CLI)\")\n .action(() =>\n run(async () => {\n const dir = configDir();\n rmSync(dir, { recursive: true, force: true });\n console.error(`Removed stored config at ${dir}.`);\n console.error(\n `The CLI binary is managed by npm — remove it with:\\n npm rm -g ${PKG}`,\n );\n }),\n );\n\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAS,iBAAiB;AAC1B,SAAS,cAAc,cAAc;AACrC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC,SAAS,eAAe;AAMxB,IAAM,mBAAmB;AACzB,IAAM,MAAM;AAIZ,IAAM,UAAU,cAAc,YAAY,GAAG,EAAE,iBAAiB,EAAE;AAElE,IAAM,UAAU,IAAI,QAAQ;AAC5B,QACG,KAAK,QAAQ,EACb,YAAY,wEAAmE,EAC/E,QAAQ,OAAO,EACf,OAAO,oBAAoB,sDAAsD,EACjF,OAAO,UAAU,8BAA8B;A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EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAC5C,YAAQ,MAAM,4BAA4B,GAAG,GAAG;AAChD,YAAQ;AAAA,MACN;AAAA,cAAmE,GAAG;AAAA,IACxE;AAAA,EACF,CAAC;AACH;AAEF,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { spawnSync } from \"node:child_process\";\nimport { readFileSync, rmSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { createInterface } from \"node:readline/promises\";\n\nimport { Command } from \"commander\";\n\nimport { agentClientId, appBaseFrom, loginDevice, openBrowser } from \"./auth.js\";\nimport { PayboxClient, didNotHappen } from \"./client.js\";\nimport { configDir, configFile, loadConfig, saveConfig } from \"./config.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.paybox.sh\";\nconst PKG = \"@paybox-sh/sdk\";\nconst VERSION = createRequire(import.meta.url)(\"../package.json\").version as string;\n\nconst program = new Command();\nprogram\n .name(\"paybox\")\n .description(\"PayBox agent CLI — vaulted cards, wallets, and secrets for agents\")\n .version(VERSION)\n .option(\"--base-url <url>\", \"API origin (default https://api.paybox.sh or stored)\")\n .option(\"--json\", \"machine-readable JSON output\");\n\nfunction jsonMode(): boolean {\n return Boolean(program.opts().json);\n}\n\nfunction emit(data: unknown): void {\n if (jsonMode()) console.log(JSON.stringify(data, null, 2));\n else console.dir(data, { depth: null, colors: process.stdout.isTTY });\n const d = data as { status?: unknown; response?: { status?: unknown } } | null;\n if (didNotHappen(d) || didNotHappen(d?.response)) process.exitCode = 1;\n}\n\nfunction client(): PayboxClient {\n return PayboxClient.fromConfig({ baseUrl: program.opts().baseUrl });\n}\n\nfunction readIntent(value: string): unknown {\n const raw = value.startsWith(\"@\") ? readFileSync(value.slice(1), \"utf8\") : value;\n return JSON.parse(raw);\n}\n\nfunction int(flag: string, value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n)) {\n throw new Error(`--${flag} must be an integer, got ${JSON.stringify(value)}`);\n }\n return n;\n}\n\nfunction optInt(flag: string, value: string | undefined): number | undefined {\n return value === undefined ? undefined : int(flag, value);\n}\n\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction credentialId(value: string): string {\n return uuid(\n value,\n \"--credential expects a credential id, not a name\",\n \"Run `paybox credentials` and use the `credential.id` of the one you want.\",\n );\n}\n\nfunction requestId(value: string): string {\n return uuid(\n value,\n \"not a request id\",\n \"Request ids come back from the command that created the request, and from `paybox requests`.\",\n );\n}\n\nfunction uuid(value: string, what: string, hint: string): string {\n if (UUID.test(value)) return value;\n throw new Error(`${what}: got ${JSON.stringify(value)}. ${hint}`);\n}\n\nfunction isNewer(a: string, b: string): boolean {\n const pa = a.split(\".\").map(Number);\n const pb = b.split(\".\").map(Number);\n for (let i = 0; i < 3; i++) {\n const x = pa[i] ?? 0;\n const y = pb[i] ?? 0;\n if (x !== y) return x > y;\n }\n return false;\n}\n\nasync function prompt(question: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\";\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n try {\n return (await rl.question(question)).trim();\n } finally {\n rl.close();\n }\n}\n\nasync function run(fn: () => Promise<void>): Promise<void> {\n try {\n await fn();\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (jsonMode()) console.log(JSON.stringify({ error: message }, null, 2));\n else console.error(message);\n process.exitCode = 1;\n }\n}\n\nfunction warnIfUnsignable(c: PayboxClient, status: string): void {\n if (status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"awaiting signatures but no valid pbxk1. signing key is set — \" +\n \"set PAYBOX_SIGNING_KEY and re-run `paybox login`, then poll `paybox request <id>`.\",\n );\n }\n}\n\nprogram\n .command(\"login\")\n .description(\"Authenticate via OAuth (browser + passkey), or store a pbx_live_ key\")\n .option(\"--key <key>\", \"store a pbx_live_ personal API key instead of OAuth\")\n .option(\n \"--signing-key <token>\",\n \"store a pbxk1. wallet signing key; prefer PAYBOX_SIGNING_KEY (an argument is visible in shell history)\",\n )\n .option(\"--app-url <url>\", \"PayBox app origin for key provisioning (default: derived from --base-url)\")\n .option(\"--no-provision\", \"skip the wallet signing-key provisioning step\")\n .action((opts) =>\n run(async () => {\n const cfg = loadConfig();\n const baseUrl = (\n program.opts().baseUrl ??\n process.env.PAYBOX_API_URL ??\n cfg.baseUrl ??\n DEFAULT_BASE_URL\n ).replace(/\\/+$/, \"\");\n cfg.baseUrl = baseUrl;\n if (opts.appUrl) cfg.appUrl = opts.appUrl;\n\n const keepExistingLogin = Boolean(opts.signingKey) && Boolean(cfg.apiKey ?? cfg.oauth);\n if (opts.key) {\n cfg.apiKey = opts.key;\n delete cfg.oauth;\n } else if (!keepExistingLogin) {\n cfg.oauth = await loginDevice(baseUrl);\n delete cfg.apiKey;\n }\n if (opts.signingKey) cfg.signingKey = opts.signingKey;\n saveConfig(cfg);\n console.error(`Saved credentials to ${configFile()}`);\n\n if (!cfg.oauth || opts.signingKey || opts.provision === false) return;\n const cid = agentClientId(cfg.oauth.accessToken);\n const appBase = appBaseFrom(baseUrl, opts.appUrl ?? process.env.PAYBOX_APP_URL ?? cfg.appUrl);\n if (!cid || !appBase) {\n console.error(\n \"To enable wallet sign/swap, provision a signing key, then set\\n\" +\n \" PAYBOX_SIGNING_KEY=<pbxk1...> and re-run `paybox login`\" +\n (cid && !appBase ? \" (or pass --app-url <paybox app origin>)\" : \"\"),\n );\n return;\n }\n const url = `${appBase}/agent-key?client_id=${cid}`;\n console.error(\n `\\nNext, provision a wallet signing key for this agent (needed for sign/swap):\\n ${url}\\n`,\n );\n openBrowser(url);\n const key = process.stdin.isTTY\n ? await prompt(\"Paste the pbxk1. signing key when ready (or Enter to skip): \")\n : (process.env.PAYBOX_SIGNING_KEY ?? \"\").trim();\n if (key) {\n cfg.signingKey = key;\n saveConfig(cfg);\n console.error(\"Signing key saved — sign/swap enabled.\");\n } else if (process.stdin.isTTY) {\n console.error(\n \"Skipped — provision one later by setting PAYBOX_SIGNING_KEY and re-running `paybox login`.\",\n );\n } else {\n console.error(\n \"No signing key configured, so sign and swap will stop at pending_signature.\\n\" +\n \"Set PAYBOX_SIGNING_KEY to the `pbxk1.` token and re-run `paybox login`.\",\n );\n }\n }),\n );\n\nprogram\n .command(\"logout\")\n .description(\"Forget stored credentials\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n delete cfg.apiKey;\n delete cfg.oauth;\n delete cfg.signingKey;\n saveConfig(cfg);\n console.error(\"Logged out.\");\n }),\n );\n\nprogram\n .command(\"whoami\")\n .description(\"Show the configured endpoint, auth mode, and signing capability\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n const c = client();\n const mode = process.env.PAYBOX_ACCESS_TOKEN\n ? \"oauth (env token)\"\n : process.env.PAYBOX_API_KEY || cfg.apiKey\n ? \"api key\"\n : cfg.oauth\n ? \"oauth\"\n : \"none\";\n emit({ baseUrl: c.baseUrl, auth: mode, canSign: c.canSign, configFile: configFile() });\n }),\n );\n\nprogram\n .command(\"credentials\")\n .description(\"List the credentials this client may use\")\n .action(() => run(async () => emit(await client().listCredentials())));\n\nprogram\n .command(\"pay\")\n .description(\"Charge a card credential\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--merchant <name>\")\n .requiredOption(\"--url <url>\", \"real merchant URL the card is bound to\")\n .requiredOption(\"--amount <cents>\", \"amount in cents\")\n .option(\"--currency <code>\", \"ISO 4217 currency\", \"USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestPayment({\n credentialId: credentialId(o.credential),\n merchant: o.merchant,\n merchantUrl: o.url,\n amountCents: int(\"amount\", o.amount),\n currency: o.currency,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"secret\")\n .description(\"Reveal a secret credential (one-time token, or --raw value)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .option(\"--raw\", \"return the raw secret value (grant-gated)\")\n .option(\"--purpose <text>\", \"why the secret is requested (shown on approval)\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestSecret({\n credentialId: credentialId(o.credential),\n raw: Boolean(o.raw),\n purpose: o.purpose,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"sign\")\n .description(\"Sign with a wallet credential (intent JSON, or @file)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--intent <json>\", 'a SignIntent, e.g. \\'{\"op\":\"message\",\"message\":\"hi\"}\\' or @intent.json')\n .action((o) =>\n run(async () => {\n const c = client();\n const res = await c.requestWalletSign({\n credentialId: credentialId(o.credential),\n intent: readIntent(o.intent) as never,\n });\n warnIfUnsignable(c, res.status);\n emit(res);\n }),\n );\n\nprogram\n .command(\"swap\")\n .description(\"Swap tokens from a wallet credential\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--src-chain <caip2>\")\n .requiredOption(\"--src-token <addr>\", '\"native\" or a token address')\n .requiredOption(\"--dst-token <addr>\")\n .requiredOption(\"--amount <smallest-unit>\", \"source amount in smallest units\")\n .option(\"--dst-chain <caip2>\", \"defaults to --src-chain\")\n .option(\"--direction <dir>\", \"exact-amount-in | exact-amount-out\", \"exact-amount-in\")\n .option(\"--slippage <bps>\", \"slippage in bps\", \"150\")\n .option(\"--recipient <addr>\")\n .option(\"--value-cents <n>\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.requestSwap(\n {\n credentialId: credentialId(o.credential),\n srcChain: o.srcChain,\n dstChain: o.dstChain,\n srcToken: o.srcToken,\n dstToken: o.dstToken,\n amount: o.amount,\n swapDirection: o.direction,\n slippageBps: int(\"slippage\", o.slippage),\n recipient: o.recipient,\n valueCents: optInt(\"value-cents\", o.valueCents),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"discover [query]\")\n .description(\"Discover curated paid x402 services from Bazaar (optional search)\")\n .option(\"--raw\", \"return uncurated compact Bazaar service summaries (debug)\")\n .action((query, o) =>\n run(async () => emit(await client().discoverServices(query, { raw: Boolean(o.raw) }))),\n );\n\nprogram\n .command(\"pay-x402\")\n .description(\"Pay a paid x402 endpoint (header mode — returns the X-PAYMENT header to replay)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--accepts <json>\", \"the 402's accepts[] array (JSON or @file)\")\n .requiredOption(\"--url <url>\", \"the paywalled resource URL\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.payX402(\n {\n credentialId: credentialId(o.credential),\n accepts: readIntent(o.accepts) as unknown[],\n resourceUrl: o.url,\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"use-service\")\n .description(\"Fetch a paid x402 resource and have paybox pay for it (gateway mode)\")\n .requiredOption(\"--credential <id>\", \"credential id from `paybox credentials`\")\n .requiredOption(\"--url <url>\", \"the paid x402 resource URL\")\n .option(\"--method <verb>\", \"HTTP method\", \"GET\")\n .option(\"--body <json>\", \"request body (JSON or @file)\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.useService(\n {\n credentialId: credentialId(o.credential),\n url: o.url,\n method: o.method,\n body: o.body === undefined ? undefined : readIntent(o.body),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"portfolio\")\n .description(\"List a wallet address's token balances across chains\")\n .requiredOption(\"--address <addr>\")\n .option(\"--networks <ids>\", 'comma-separated network IDs, e.g. \"1,8453\"')\n .action((o) =>\n run(async () =>\n emit(await client().getPortfolio({ address: o.address, networkIds: o.networks })),\n ),\n );\n\nprogram\n .command(\"verify-solana-balance\")\n .description(\"Verify a Solana transaction's wallet/token effect and current balance\")\n .requiredOption(\"--address <addr>\", \"canonical Solana wallet address\")\n .requiredOption(\"--mint <addr>\", \"canonical SPL or Token-2022 mint\")\n .requiredOption(\"--transaction <signature>\", \"confirmed Solana transaction signature\")\n .action((o) =>\n run(async () =>\n emit(\n await client().verifySolanaBalance({\n address: o.address,\n tokenMint: o.mint,\n transactionSignature: o.transaction,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"claim <request-id>\")\n .description(\"Claim the usable card credentials of an approved payment (one-time)\")\n .action((id) => run(async () => emit(await client().claimPaymentCredentials(requestId(id)))));\n\nprogram\n .command(\"account-change\")\n .description(\"Get a manage_url for the USER to update this client's access in the app\")\n .option(\"--note <text>\", \"why the change is needed (shown to the user)\")\n .action((o) => run(async () => emit(await client().requestAccountChange(o.note))));\n\nprogram\n .command(\"buy-link\")\n .description(\"Signed MoonPay checkout URL funding a granted wallet (charges nothing)\")\n .requiredOption(\"--credential <id>\", \"a granted wallet credential\")\n .option(\n \"--destination <chain>\",\n \"exact network: eip155:8453 (default EVM), eip155:1, or solana:mainnet\",\n )\n .option(\"--currency <code>\", \"enabled MoonPay code matching the exact destination\")\n .option(\"--amount-usd <n>\", \"prefill amount in USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().getBuyLink({\n credentialId: credentialId(o.credential),\n destinationChain: o.destination,\n currencyCode: o.currency,\n amountUsd: o.amountUsd === undefined ? undefined : Number(o.amountUsd),\n }),\n ),\n ),\n );\n\nconst world = program\n .command(\"world\")\n .description(\"World prediction markets (requires the world plugin)\");\n\nworld\n .command(\"markets\")\n .description(\"Browse markets (or events with --events)\")\n .option(\"--events\", \"list events (each groups its markets)\")\n .option(\"--limit <n>\")\n .option(\"--cursor <n>\", \"rows to skip; the response carries the next cursor\")\n .option(\"--event-ticker <ticker>\")\n .option(\"--series-ticker <ticker>\")\n .option(\"--status <status>\", \"active | initialized | determined | finalized\")\n .action((o) =>\n run(async () =>\n emit(\n await client().worldMarkets({\n events: Boolean(o.events),\n limit: optInt(\"limit\", o.limit),\n cursor: optInt(\"cursor\", o.cursor),\n eventTicker: o.eventTicker,\n seriesTicker: o.seriesTicker,\n status: o.status,\n }),\n ),\n ),\n );\n\nworld\n .command(\"market <event-ticker>\")\n .description(\"One event with its nested markets (disable with --no-nested)\")\n .option(\"--no-nested\", \"exclude the event's markets\")\n .action((ticker, o) =>\n run(async () => emit(await client().worldMarket(ticker, Boolean(o.nested)))),\n );\n\nworld\n .command(\"orderbook <id>\")\n .description(\"A market's orderbook (id is a ticker, or a mint with --by-mint)\")\n .option(\"--by-mint\", \"look up by outcome mint instead of ticker\")\n .action((id, o) =>\n run(async () => emit(await client().worldOrderbook(id, Boolean(o.byMint)))),\n );\n\nworld\n .command(\"prices <ticker>\")\n .description(\"A market's price history\")\n .requiredOption(\"--start <unix-ts>\")\n .requiredOption(\"--end <unix-ts>\")\n .option(\"--resolution <n>\")\n .action((ticker, o) =>\n run(async () =>\n emit(\n await client().worldPrices({\n ticker,\n startTs: int(\"start\", o.start),\n endTs: int(\"end\", o.end),\n resolution: optInt(\"resolution\", o.resolution),\n }),\n ),\n ),\n );\n\nworld\n .command(\"filter-mints <addresses...>\")\n .description(\"Filter addresses down to World outcome mints\")\n .action((addresses) =>\n run(async () => emit(await client().worldFilterOutcomeMints(addresses))),\n );\n\nworld\n .command(\"positions <address>\")\n .description(\"Solana token positions for an address\")\n .action((address) => run(async () => emit(await client().worldPositions(address))));\n\nconst hyperliquid = program\n .command(\"hyperliquid\")\n .description(\"Hyperliquid spot discovery (requires the hyperliquid plugin)\");\n\nhyperliquid\n .command(\"markets\")\n .description(\"Spot markets\")\n .action(() => run(async () => emit(await client().hyperliquidMarkets())));\n\nhyperliquid\n .command(\"prices\")\n .description(\"Spot prices\")\n .action(() => run(async () => emit(await client().hyperliquidPrices())));\n\nhyperliquid\n .command(\"token <name>\")\n .description(\"Resolve one token by name\")\n .action((name) => run(async () => emit(await client().hyperliquidToken(name))));\n\nprogram\n .command(\"request <id>\")\n .description(\"Poll a request's status\")\n .option(\"--wait\", \"block until it leaves the pending state\")\n .action((id, o) =>\n run(async () => {\n const c = client();\n const rid = requestId(id);\n emit(o.wait ? await c.waitForRequest(rid) : await c.getRequest(rid));\n }),\n );\n\nprogram\n .command(\"version\")\n .description(\"Show the installed CLI version (and whether an update is available)\")\n .action(() =>\n run(async () => {\n let latest: string | undefined;\n try {\n const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`);\n if (res.ok) latest = ((await res.json()) as { version?: string }).version;\n } catch {\n }\n const updateAvailable = Boolean(latest && isNewer(latest, VERSION));\n if (jsonMode()) {\n emit({\n version: VERSION,\n latest: latest ?? null,\n updateAvailable,\n binary: process.argv[1] ?? null,\n });\n return;\n }\n console.log(`${PKG} v${VERSION}`);\n if (updateAvailable) {\n console.log(`Update available: v${latest} — run \\`paybox update\\`.`);\n }\n }),\n );\n\nprogram\n .command(\"update\")\n .description(\"Update the globally-installed paybox CLI to the latest version\")\n .option(\"--print\", \"print the update command instead of running it\")\n .action((opts) =>\n run(async () => {\n const args = [\"install\", \"-g\", `${PKG}@latest`];\n if (opts.print) {\n console.log(`npm ${args.join(\" \")}`);\n return;\n }\n console.error(`Updating ${PKG} (npm ${args.join(\" \")})…`);\n const r = spawnSync(\"npm\", args, { stdio: \"inherit\" });\n if (r.status !== 0) {\n console.error(\n `\\nIf this isn't a global install: run \\`pnpm up ${PKG}\\` in your project, ` +\n `or use \\`npx ${PKG}@latest …\\` to always run the latest.`,\n );\n process.exitCode = r.status ?? 1;\n }\n }),\n );\n\nprogram\n .command(\"uninstall\")\n .description(\"Remove stored PayBox credentials/config (and show how to remove the CLI)\")\n .action(() =>\n run(async () => {\n const dir = configDir();\n rmSync(dir, { recursive: true, force: true });\n console.error(`Removed stored config at ${dir}.`);\n console.error(\n `The CLI binary is managed by npm — remove it with:\\n npm rm -g ${PKG}`,\n );\n }),\n );\n\nfunction rejectUnknownCommand(argv: string[]): void {\n if (!argv.includes(\"--help\") && !argv.includes(\"-h\")) return;\n let node: Command = program;\n for (let i = 2; i < argv.length; i++) {\n const arg = argv[i];\n if (node.options.some((o) => o.long === arg && o.required)) i++;\n if (arg.startsWith(\"-\")) continue;\n const next = node.commands.find((c) => c.name() === arg || c.aliases().includes(arg));\n if (next) {\n node = next;\n continue;\n }\n if (node.commands.length === 0) return;\n if (node === program && arg === \"help\") return;\n program.error(`error: unknown command '${arg}'`);\n }\n}\n\nrejectUnknownCommand(process.argv);\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;;;;;;;;;;AAEA,SAAS,iBAAiB;AAC1B,SAAS,cAAc,cAAc;AACrC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC,SAAS,eAAe;AAMxB,IAAM,mBAAmB;AACzB,IAAM,MAAM;AACZ,IAAM,UAAU,cAAc,YAAY,GAAG,EAAE,iBAAiB,EAAE;AAElE,IAAM,UAAU,IAAI,QAAQ;AAC5B,QACG,KAAK,QAAQ,EACb,YAAY,wEAAmE,EAC/E,QAAQ,OAAO,EACf,OAAO,oBAAoB,sDAAsD,EACjF,OAAO,UAAU,8BAA8B;AAElD,SAAS,WAAoB;AAC3B,SAAO,QAAQ,QAAQ,KAAK,EAAE,IAAI;AACpC;AAEA,SAAS,KAAK,MAAqB;AACjC,MAAI,SAAS,EAAG,SAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,MACpD,SAAQ,IAAI,MAAM,EAAE,OAAO,MAAM,QAAQ,QAAQ,OAAO,MAAM,CAAC;AACpE,QAAM,IAAI;AACV,MAAI,aAAa,CAAC,KAAK,aAAa,GAAG,QAAQ,EAAG,SAAQ,WAAW;AACvE;AAEA,SAAS,SAAuB;AAC9B,SAAO,aAAa,WAAW,EAAE,SAAS,QAAQ,KAAK,EAAE,QAAQ,CAAC;AACpE;AAEA,SAAS,WAAW,OAAwB;AAC1C,QAAM,MAAM,MAAM,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M,MAAM,UAAU;AACtB,WAAO,KAAK,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAC5C,YAAQ,MAAM,4BAA4B,GAAG,GAAG;AAChD,YAAQ;AAAA,MACN;AAAA,cAAmE,GAAG;AAAA,IACxE;AAAA,EACF,CAAC;AACH;AAEF,SAAS,qBAAqB,MAAsB;AAClD,MAAI,CAAC,KAAK,SAAS,QAAQ,KAAK,CAAC,KAAK,SAAS,IAAI,EAAG;AACtD,MAAI,OAAgB;AACpB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,QAAI,KAAK,QAAQ,KAAK,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,QAAQ,EAAG;AAC5D,QAAI,IAAI,WAAW,GAAG,EAAG;AACzB,UAAM,OAAO,KAAK,SAAS,KAAK,CAAC,MAAM,EAAE,KAAK,MAAM,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,CAAC;AACpF,QAAI,MAAM;AACR,aAAO;AACP;AAAA,IACF;AACA,QAAI,KAAK,SAAS,WAAW,EAAG;AAChC,QAAI,SAAS,WAAW,QAAQ,OAAQ;AACxC,YAAQ,MAAM,2BAA2B,GAAG,GAAG;AAAA,EACjD;AACF;AAEA,qBAAqB,QAAQ,IAAI;AACjC,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { Creds } from '@paybox/mcp-app/creds';
|
|
|
4
4
|
|
|
5
5
|
interface WalletSignArgs {
|
|
6
6
|
credentialId: string;
|
|
7
|
-
/** What to sign. The chain, destination, and value are read from the intent —
|
|
8
|
-
* there are no separate declared fields. */
|
|
9
7
|
intent: SignIntent;
|
|
10
8
|
}
|
|
11
9
|
interface PaymentArgs {
|
|
@@ -26,7 +24,6 @@ interface SwapArgs {
|
|
|
26
24
|
dstChain?: string;
|
|
27
25
|
srcToken: string;
|
|
28
26
|
dstToken: string;
|
|
29
|
-
/** Amount in the source token's smallest unit, as a decimal string. */
|
|
30
27
|
amount: string;
|
|
31
28
|
swapDirection?: "exact-amount-in" | "exact-amount-out";
|
|
32
29
|
slippageBps?: number;
|
|
@@ -35,7 +32,6 @@ interface SwapArgs {
|
|
|
35
32
|
}
|
|
36
33
|
interface PortfolioArgs {
|
|
37
34
|
address: string;
|
|
38
|
-
/** Comma-separated network IDs, e.g. "1,8453". Omit to auto-detect. */
|
|
39
35
|
networkIds?: string;
|
|
40
36
|
}
|
|
41
37
|
interface VerifySolanaBalanceArgs$1 {
|
|
@@ -65,15 +61,11 @@ interface VerifySolanaBalanceResult {
|
|
|
65
61
|
as_of: string;
|
|
66
62
|
}
|
|
67
63
|
interface DiscoverServicesOptions {
|
|
68
|
-
/** Catalogs to search. Defaults to both. */
|
|
69
64
|
network?: "all" | "base" | "solana";
|
|
70
|
-
/** @deprecated Accepted for compatibility but not advertised to agents. */
|
|
71
65
|
raw?: boolean;
|
|
72
66
|
}
|
|
73
67
|
interface DiscoverServicesPageOptions extends DiscoverServicesOptions {
|
|
74
|
-
/** Results per page. Defaults to 10; maximum 25. */
|
|
75
68
|
limit?: number;
|
|
76
|
-
/** Opaque continuation from a prior page. */
|
|
77
69
|
cursor?: string;
|
|
78
70
|
}
|
|
79
71
|
type RequestStatus = "pending_approval" | "pending_signature" | "pending_settlement" | "pending_confirmation" | "success" | "denied" | "error";
|
|
@@ -96,10 +88,6 @@ interface AgentResponse {
|
|
|
96
88
|
output: CredentialOutput | null;
|
|
97
89
|
approval_id: string | null;
|
|
98
90
|
error: string | null;
|
|
99
|
-
/** SPE-456: set on a terminal `error`/`denied` when the failure was an expiry
|
|
100
|
-
* (the signing/approval window elapsed and nothing was signed or spent), so
|
|
101
|
-
* re-issuing the same request is the correct recovery. `retry_hint` is plain
|
|
102
|
-
* guidance. Absent on non-expiry outcomes. */
|
|
103
91
|
retryable?: boolean;
|
|
104
92
|
retry_hint?: string | null;
|
|
105
93
|
}
|
|
@@ -122,10 +110,6 @@ interface ClientGrantSummary {
|
|
|
122
110
|
credential: CredentialSummary;
|
|
123
111
|
grant: Grant;
|
|
124
112
|
}
|
|
125
|
-
/** An active credential the user owns but has not granted this connector.
|
|
126
|
-
* Carries identity + safe display metadata (wallet chain family, card
|
|
127
|
-
* brand/last4) so the connector can request a specific credential by id; never
|
|
128
|
-
* card tokens or secret material. */
|
|
129
113
|
interface UngrantedCredential {
|
|
130
114
|
credential_id: string;
|
|
131
115
|
name: string;
|
|
@@ -136,9 +120,6 @@ interface ClientCredentialList {
|
|
|
136
120
|
credentials: ClientGrantSummary[];
|
|
137
121
|
ungranted: UngrantedCredential[];
|
|
138
122
|
}
|
|
139
|
-
/** The wallet binding the server echoes for a wallet-sign / resolve. Mirrors
|
|
140
|
-
* `WalletBinding` in server/src/agent.rs (key_id/derivation_path may be null
|
|
141
|
-
* for an unprovisioned wallet). */
|
|
142
123
|
interface BindingResponse {
|
|
143
124
|
wallet_id: string;
|
|
144
125
|
key_id: string | null;
|
|
@@ -154,41 +135,26 @@ interface SwapPlan {
|
|
|
154
135
|
quote: Record<string, unknown>;
|
|
155
136
|
txs: PlanTx[];
|
|
156
137
|
}
|
|
157
|
-
/** `POST /agent/swap` response. The sign-ready plan is present only while the
|
|
158
|
-
* request is awaiting approval or signature; terminal responses return null. */
|
|
159
138
|
interface SwapResult {
|
|
160
139
|
response: AgentResponse;
|
|
161
140
|
plan: SwapPlan | null;
|
|
162
141
|
}
|
|
163
|
-
/** `POST /agent/wallet-sign` response. The wallet binding is present only while
|
|
164
|
-
* approval or signature is pending, so the signer can sign without a separate
|
|
165
|
-
* resolve round-trip; terminal responses return null. */
|
|
166
142
|
interface WalletSignResult {
|
|
167
143
|
response: AgentResponse;
|
|
168
144
|
binding: BindingResponse | null;
|
|
169
145
|
}
|
|
170
146
|
interface X402Args {
|
|
171
147
|
credentialId: string;
|
|
172
|
-
/** The 402's `accepts` PaymentRequirements array, verbatim (from the resource's
|
|
173
|
-
* own 402 — discover_services gives you a curated catalog entry to start from). */
|
|
174
148
|
accepts: unknown[];
|
|
175
|
-
/** The paywalled resource URL. */
|
|
176
149
|
resourceUrl: string;
|
|
177
150
|
}
|
|
178
151
|
interface UseServiceArgs {
|
|
179
152
|
credentialId: string;
|
|
180
|
-
/** The paid x402 resource URL to fetch. */
|
|
181
153
|
url: string;
|
|
182
|
-
/** HTTP method (default GET). */
|
|
183
154
|
method?: string;
|
|
184
|
-
/** Optional JSON request body (for POST/PUT services). */
|
|
185
155
|
body?: unknown;
|
|
186
156
|
}
|
|
187
|
-
/** The x402 sign-ready plan (`POST /agent/x402` | `/agent/use-service`): the
|
|
188
|
-
* EIP-3009 typed data to sign + the wallet binding. */
|
|
189
157
|
interface X402Plan {
|
|
190
|
-
/** EVM rail only: the EIP-3009 typed data to sign. Null on the Solana rail,
|
|
191
|
-
* which parks a transaction under `solana` instead. */
|
|
192
158
|
typed_data: unknown;
|
|
193
159
|
binding: {
|
|
194
160
|
wallet_id: string;
|
|
@@ -198,22 +164,14 @@ interface X402Plan {
|
|
|
198
164
|
x402: Record<string, unknown> & {
|
|
199
165
|
rail?: string;
|
|
200
166
|
};
|
|
201
|
-
/** Solana rail only: the base64 payment transaction to sign. */
|
|
202
167
|
solana?: {
|
|
203
168
|
transaction?: string;
|
|
204
169
|
};
|
|
205
170
|
}
|
|
206
|
-
/** `POST /agent/x402` | `/agent/use-service` response. The plan is present only
|
|
207
|
-
* while approval or signature is pending. On success, header mode puts the
|
|
208
|
-
* X-PAYMENT header in
|
|
209
|
-
* `response.output.value.x_payment`; gateway mode puts the resource's reply in
|
|
210
|
-
* `response.output.value.response`. */
|
|
211
171
|
interface X402Result {
|
|
212
172
|
response: AgentResponse;
|
|
213
173
|
plan: X402Plan | null;
|
|
214
174
|
}
|
|
215
|
-
/** One curated x402 service (the `discover_services` tool / `/agent/services`):
|
|
216
|
-
* where it lives, a human description, and its `accepts` PaymentRequirements. */
|
|
217
175
|
interface ServiceSummary {
|
|
218
176
|
resource: string;
|
|
219
177
|
description: string | null;
|
|
@@ -230,9 +188,6 @@ interface DiscoverServicesPage {
|
|
|
230
188
|
has_more: boolean;
|
|
231
189
|
next_cursor?: string;
|
|
232
190
|
}
|
|
233
|
-
/** `POST /agent/account-change` (the `request_account_change` tool): a pure
|
|
234
|
-
* launcher. Surface `manage_url` to the user — they edit this client's access
|
|
235
|
-
* in their own app session (passkey-gated); nothing is parked server-side. */
|
|
236
191
|
interface AccountChangeResult {
|
|
237
192
|
kind: "account_change";
|
|
238
193
|
client_id: string;
|
|
@@ -240,17 +195,11 @@ interface AccountChangeResult {
|
|
|
240
195
|
note?: string | null;
|
|
241
196
|
}
|
|
242
197
|
interface BuyLinkArgs {
|
|
243
|
-
/** A granted wallet credential to fund. */
|
|
244
198
|
credentialId: string;
|
|
245
|
-
/** Exact network. Defaults to Base for EVM or Solana mainnet for Solana. */
|
|
246
199
|
destinationChain?: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
247
|
-
/** Enabled MoonPay code matching the destination's exact network. */
|
|
248
200
|
currencyCode?: string;
|
|
249
|
-
/** Prefill amount in USD. */
|
|
250
201
|
amountUsd?: number;
|
|
251
202
|
}
|
|
252
|
-
/** `GET /agent/buy-link` (the `get_buy_link` tool): a signed MoonPay checkout
|
|
253
|
-
* URL funding the wallet. Generating the link charges nothing. */
|
|
254
203
|
interface BuyLinkResult {
|
|
255
204
|
url: string;
|
|
256
205
|
currency_code: string;
|
|
@@ -258,14 +207,11 @@ interface BuyLinkResult {
|
|
|
258
207
|
network: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
259
208
|
}
|
|
260
209
|
interface WorldMarketsArgs {
|
|
261
|
-
/** Return the events list (each event groups its markets) instead of markets. */
|
|
262
210
|
events?: boolean;
|
|
263
211
|
limit?: number;
|
|
264
|
-
/** Rows to skip; the response carries the next cursor. */
|
|
265
212
|
cursor?: number;
|
|
266
213
|
eventTicker?: string;
|
|
267
214
|
seriesTicker?: string;
|
|
268
|
-
/** One of active | initialized | determined | finalized. */
|
|
269
215
|
status?: string;
|
|
270
216
|
}
|
|
271
217
|
interface WorldPricesArgs {
|
|
@@ -281,20 +227,14 @@ declare class PayboxError extends Error {
|
|
|
281
227
|
constructor(status: number, body: string, context: string);
|
|
282
228
|
}
|
|
283
229
|
interface PayboxClientOptions {
|
|
284
|
-
/** API origin (the OAuth issuer). Default `https://api.paybox.sh`. */
|
|
285
230
|
baseUrl?: string;
|
|
286
|
-
/** A `pbx_live_*` personal API key. */
|
|
287
231
|
apiKey?: string;
|
|
288
|
-
/** A raw OAuth access token (skips the stored-token path). */
|
|
289
232
|
token?: string;
|
|
290
|
-
/** A `pbxk1.` signing key token; enables in-process wallet/swap signing. */
|
|
291
233
|
signingKey?: string;
|
|
292
234
|
fetchImpl?: typeof fetch;
|
|
293
235
|
}
|
|
294
236
|
interface SignOptions {
|
|
295
|
-
/** Sign in-process when the request clears to `pending_signature`. Default true. */
|
|
296
237
|
autoSign?: boolean;
|
|
297
|
-
/** Wait for passkey approval and then sign in-process. Default false. */
|
|
298
238
|
waitForApproval?: boolean | {
|
|
299
239
|
intervalMs?: number;
|
|
300
240
|
timeoutMs?: number;
|
|
@@ -307,118 +247,42 @@ declare class PayboxClient {
|
|
|
307
247
|
private oauth?;
|
|
308
248
|
private configBacked;
|
|
309
249
|
constructor(options?: PayboxClientOptions);
|
|
310
|
-
/** Build a client from `~/.config/paybox/config.json` + env, with overrides. */
|
|
311
250
|
static fromConfig(overrides?: PayboxClientOptions): PayboxClient;
|
|
312
251
|
private signingCreds;
|
|
313
|
-
/** Whether in-process signing is available (a parseable `pbxk1.` key is set). */
|
|
314
252
|
get canSign(): boolean;
|
|
315
253
|
private bearer;
|
|
316
254
|
private request;
|
|
317
255
|
private readonly poster;
|
|
318
|
-
/** List granted credentials plus the `ungranted` credentials (id, name, kind,
|
|
319
|
-
* safe metadata) the user owns but hasn't granted this connector. */
|
|
320
256
|
listCredentials(): Promise<ClientCredentialList>;
|
|
321
|
-
/** Token balances across chains (the `get_portfolio` tool). */
|
|
322
257
|
getPortfolio(args: PortfolioArgs): Promise<unknown>;
|
|
323
|
-
/** Verify one confirmed Solana transaction's exact wallet/mint effect, then
|
|
324
|
-
* read the current balance at or after its slot (`verify_solana_balance`). */
|
|
325
258
|
verifySolanaBalance(args: VerifySolanaBalanceArgs$1): Promise<VerifySolanaBalanceResult>;
|
|
326
|
-
/** Charge a card credential (the `request_payment` tool). */
|
|
327
259
|
requestPayment(args: PaymentArgs): Promise<AgentResponse>;
|
|
328
|
-
/** Reveal a secret credential (the `request_secret` tool). */
|
|
329
260
|
requestSecret(args: SecretArgs): Promise<AgentResponse>;
|
|
330
|
-
/** Sign with a wallet credential (the `request_wallet_sign` tool). Signs
|
|
331
|
-
* in-process and returns the completed request when a signing key is set and
|
|
332
|
-
* the request clears immediately; otherwise returns the pending response.
|
|
333
|
-
* Uses `/agent/wallet-sign`, which echoes the wallet binding only while
|
|
334
|
-
* approval or signature is pending so the signer need not resolve it
|
|
335
|
-
* separately. Terminal responses carry a null binding. */
|
|
336
261
|
requestWalletSign(args: WalletSignArgs, opts?: SignOptions): Promise<AgentResponse>;
|
|
337
|
-
/** Swap tokens from a wallet credential (the `request_swap` tool). Returns the
|
|
338
|
-
* parked response and its sign-ready plan while approval or signature is
|
|
339
|
-
* pending; terminal responses carry a null plan. Signs + submits in-process
|
|
340
|
-
* when a signing key is set and the swap cleared immediately. */
|
|
341
262
|
requestSwap(args: SwapArgs, opts?: SignOptions): Promise<SwapResult>;
|
|
342
|
-
/** Complete a swap request: optionally wait out a `pending_approval` dwell,
|
|
343
|
-
* then sign the plan in-process and submit envelopes. Signing first refreshes
|
|
344
|
-
* the parked request via `/agent/requests/{id}/refresh`, so a long approval
|
|
345
|
-
* dwell never signs stale bytes. */
|
|
346
263
|
private completeSwap;
|
|
347
|
-
/** Poll while the request sits in `pending_approval` (the user is approving
|
|
348
|
-
* with their passkey); returns the first non-approval state. */
|
|
349
264
|
private waitWhileApproval;
|
|
350
|
-
/** Run an operation and, if it terminates on a server-marked expiry
|
|
351
|
-
* (`retryable` on a terminal `error`/`denied`: the window elapsed and nothing
|
|
352
|
-
* was signed or spent), re-issue it exactly once (SPE-456). Never loops: the
|
|
353
|
-
* second attempt's result is returned as-is. */
|
|
354
265
|
private withExpiryRetry;
|
|
355
|
-
/** Sign a parked request; if the sign/submit call fails, reconcile against the
|
|
356
|
-
* authoritative state once (SPE-456). The server leaves a pre-broadcast
|
|
357
|
-
* completion failure recoverable — the claim is released and the row stays
|
|
358
|
-
* `pending_signature` — so re-sign a still-open request a single time; a
|
|
359
|
-
* terminal or already-broadcast row is left as-is for the caller to read (and
|
|
360
|
-
* for `withExpiryRetry` to re-issue if it is retryable). Bounded to one extra
|
|
361
|
-
* attempt: a second failure propagates. */
|
|
362
266
|
private signWithReconcile;
|
|
363
|
-
/** Discover x402 services with the original array-returning response. */
|
|
364
267
|
discoverServices(query?: string, opts?: DiscoverServicesOptions): Promise<ServiceSummary[]>;
|
|
365
|
-
/** Discover one bounded page of x402 services. Reuse the returned cursor with
|
|
366
|
-
* the same query and network while `has_more` is true. */
|
|
367
268
|
discoverServicesPage(query?: string, opts?: DiscoverServicesPageOptions): Promise<DiscoverServicesPage>;
|
|
368
|
-
/** Pay a paid x402 endpoint from a wallet credential (the `pay_x402` tool,
|
|
369
|
-
* header mode). Signs in-process when a signing key is set and the payment
|
|
370
|
-
* clears immediately — then the X-PAYMENT header is on the completed
|
|
371
|
-
* response's `output.value.x_payment` (replay it on the original request). */
|
|
372
269
|
payX402(args: X402Args, opts?: SignOptions): Promise<X402Result>;
|
|
373
|
-
/** Fetch a paid x402 resource and have paybox pay for it (the `use_service`
|
|
374
|
-
* tool, gateway mode): paybox probes the url, pays the 402, re-fetches with the
|
|
375
|
-
* payment, and returns the resource's reply on `output.value.response`. */
|
|
376
270
|
useService(args: UseServiceArgs, opts?: SignOptions): Promise<X402Result>;
|
|
377
|
-
/** Shared completion for the two x402 entry points: optionally wait out a
|
|
378
|
-
* `pending_approval` dwell, then sign the parked typed data in-process and
|
|
379
|
-
* return the finished request, exactly like the swap path. */
|
|
380
271
|
private completeX402;
|
|
381
|
-
/** Claim the usable card credentials of an approved payment (the
|
|
382
|
-
* `claim_payment_credentials` tool). One-time: the claim is consumed. */
|
|
383
272
|
claimPaymentCredentials(requestId: string): Promise<Record<string, unknown>>;
|
|
384
|
-
/** Open the account-change flow (the `request_account_change` tool): returns a
|
|
385
|
-
* `manage_url` deep link for the USER to open — they update this client's
|
|
386
|
-
* access (or add a credential) in their own passkey-gated app session.
|
|
387
|
-
* Nothing is parked or applied server-side. */
|
|
388
273
|
requestAccountChange(note?: string): Promise<AccountChangeResult>;
|
|
389
|
-
/** A signed MoonPay checkout URL funding a granted wallet (the `get_buy_link`
|
|
390
|
-
* tool). Share the URL with the user; generating it charges nothing. */
|
|
391
274
|
getBuyLink(args: BuyLinkArgs): Promise<BuyLinkResult>;
|
|
392
|
-
/** Browse World prediction markets (the `world_find_markets` tool). */
|
|
393
275
|
worldMarkets(args?: WorldMarketsArgs): Promise<unknown>;
|
|
394
|
-
/** One World event with its markets (the `world_get_market` tool). Nested
|
|
395
|
-
* markets default on, matching the tool — they carry the outcome mint ids
|
|
396
|
-
* the orderbook/trade calls need. */
|
|
397
276
|
worldMarket(eventTicker: string, withNestedMarkets?: boolean): Promise<unknown>;
|
|
398
|
-
/** A World market's orderbook (the `world_orderbook` tool). */
|
|
399
277
|
worldOrderbook(id: string, byMint?: boolean): Promise<unknown>;
|
|
400
|
-
/** A World market's price history (the `world_market_prices` tool). */
|
|
401
278
|
worldPrices(args: WorldPricesArgs): Promise<unknown>;
|
|
402
|
-
/** Filter addresses down to World outcome mints (the
|
|
403
|
-
* `world_filter_outcome_mints` tool). */
|
|
404
279
|
worldFilterOutcomeMints(addresses: string[]): Promise<unknown>;
|
|
405
|
-
/** A wallet's World prediction-market positions: classified `positions` /
|
|
406
|
-
* `settled` entries (each with a `position_result`) plus `settlement_cash`
|
|
407
|
-
* for a settled winner's CASH cash-out (swap CASH to USDC via request_swap).
|
|
408
|
-
* The `world_positions` tool. */
|
|
409
280
|
worldPositions(address: string): Promise<unknown>;
|
|
410
|
-
/** Hyperliquid spot markets (the `hyperliquid_markets` tool). */
|
|
411
281
|
hyperliquidMarkets(): Promise<unknown>;
|
|
412
|
-
/** Hyperliquid spot prices (the `hyperliquid_prices` tool). */
|
|
413
282
|
hyperliquidPrices(): Promise<unknown>;
|
|
414
|
-
/** Resolve one Hyperliquid token by name (the `hyperliquid_token` tool). */
|
|
415
283
|
hyperliquidToken(name: string): Promise<unknown>;
|
|
416
|
-
/** Poll a request's status (the `get_request` tool). */
|
|
417
284
|
getRequest(requestId: string): Promise<AgentResponse>;
|
|
418
|
-
/** After in-process sign, `--wait` polls through settlement/confirmation;
|
|
419
|
-
* without it, return the first snapshot (the historical no-wait contract). */
|
|
420
285
|
private requestAfterSign;
|
|
421
|
-
/** Poll until the request leaves a pending state (or the timeout elapses). */
|
|
422
286
|
waitForRequest(requestId: string, opts?: {
|
|
423
287
|
intervalMs?: number;
|
|
424
288
|
timeoutMs?: number;
|
|
@@ -429,15 +293,11 @@ interface OAuthTokens {
|
|
|
429
293
|
clientId: string;
|
|
430
294
|
accessToken: string;
|
|
431
295
|
refreshToken?: string;
|
|
432
|
-
/** Epoch millis the access token expires. */
|
|
433
296
|
expiresAt?: number;
|
|
434
|
-
/** The audience the token is bound to (`<baseUrl>/mcp`). */
|
|
435
297
|
resource: string;
|
|
436
298
|
}
|
|
437
299
|
interface StoredConfig {
|
|
438
300
|
baseUrl?: string;
|
|
439
|
-
/** Paybox app origin used for signing-key provisioning (derived from baseUrl
|
|
440
|
-
* when unset). */
|
|
441
301
|
appUrl?: string;
|
|
442
302
|
apiKey?: string;
|
|
443
303
|
oauth?: OAuthTokens;
|
|
@@ -447,20 +307,16 @@ declare function configFile(): string;
|
|
|
447
307
|
declare function loadConfig(): StoredConfig;
|
|
448
308
|
declare function saveConfig(config: StoredConfig): void;
|
|
449
309
|
|
|
450
|
-
/** The MCP resource the access token is audience-bound to. */
|
|
451
310
|
declare function mcpResource(baseUrl: string): string;
|
|
452
311
|
interface LoginOptions {
|
|
453
312
|
scope?: string;
|
|
454
313
|
clientName?: string;
|
|
455
|
-
/** Sink for the "open this URL" prompt; defaults to console.error. */
|
|
456
314
|
log?: (msg: string) => void;
|
|
457
|
-
/** Abort with an error if no approval arrives in this long. Default 5 min. */
|
|
458
315
|
timeoutMs?: number;
|
|
459
316
|
}
|
|
460
317
|
declare function loginLoopback(baseUrl: string, opts?: LoginOptions): Promise<OAuthTokens>;
|
|
461
318
|
declare function refreshTokens(baseUrl: string, current: OAuthTokens): Promise<OAuthTokens>;
|
|
462
319
|
|
|
463
|
-
/** Parse the one-string `pbxk1.` token into the agent keypair the core expects. */
|
|
464
320
|
declare function credsFromToken(token: string): Creds;
|
|
465
321
|
|
|
466
322
|
interface RequestPaymentArgs {
|