@paybox-sh/sdk 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 { createInterface } from \"node:readline/promises\";\n\nimport { Command } from \"commander\";\n\nimport { agentClientId, appBaseFrom, loginLoopback, 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\";\nconst VERSION = \"0.7.0\";\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\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 signing key is set — \" +\n \"run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, 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(\"--signing-key <token>\", \"store a pbxk1. wallet signing key (skips the prompt)\")\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 loginLoopback(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 and run\\n\" +\n \" paybox login --signing-key <pbxk1...>\" +\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 = await prompt(\"Paste the pbxk1. signing key when ready (or Enter to skip): \");\n if (key) {\n cfg.signingKey = key;\n saveConfig(cfg);\n console.error(\"Signing key saved — sign/swap enabled.\");\n } else {\n console.error(\"Skipped — add it later with `paybox login --signing-key <pbxk1...>`.\");\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>\")\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: 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>\")\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: 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>\")\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: 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>\")\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\", \"50\")\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: 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>\")\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: 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>\")\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: 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(\"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(\"--currency <code>\", \"MoonPay currency code (default USDC on the wallet's chain)\")\n .option(\"--amount-usd <n>\", \"prefill amount in USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().getBuyLink({\n credentialId: o.credential,\n currencyCode: o.currency,\n amountUsd: o.amountUsd === undefined ? undefined : Number(o.amountUsd),\n }),\n ),\n ),\n );\n\n// ---- World plugin (prediction markets). Requires the `world` plugin enabled in\n// the paybox app. Trades are force-approved; --wait waits for the approval and\n// then signs in-process (no signing window on this surface). ----\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\nfunction worldTradeCommand(name: string, side: \"buy\" | \"sell\" | \"redeem\", desc: string) {\n const cmd = world\n .command(name)\n .description(desc)\n .requiredOption(\"--credential <id>\", \"a granted wallet credential (Solana)\")\n .requiredOption(\"--mint <addr>\", \"the outcome mint\")\n .requiredOption(\"--size <n>\")\n .option(\"--value-cents <n>\")\n .option(\"--wait\", \"wait for the user's approval, then sign in-process\");\n if (side !== \"redeem\") cmd.option(\"--slippage <bps>\", \"slippage in bps\", \"50\");\n cmd.action((o) =>\n run(async () => {\n const c = client();\n const result = await c.worldTrade(\n {\n credentialId: o.credential,\n marketMint: o.mint,\n side,\n size: o.size,\n slippageBps: optInt(\"slippage\", o.slippage),\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}\nworldTradeCommand(\"buy\", \"buy\", \"Buy an outcome (force-approved; approve in the app)\");\nworldTradeCommand(\"sell\", \"sell\", \"Sell an outcome position (force-approved)\");\nworldTradeCommand(\"redeem\", \"redeem\", \"Redeem a settled position (force-approved)\");\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({ version: VERSION, latest: latest ?? null, updateAvailable });\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,uBAAuB;AAEhC,SAAS,eAAe;AAMxB,IAAM,mBAAmB;AACzB,IAAM,MAAM;AACZ,IAAM,UAAU;AAEhB,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,WA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A,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// 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;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;AACtE;AAEA,SAAS,SAAuB;AAC9B,SAAO,aAAa,WAAW,EAAE,SAAS,QAAQ,KAAK,EAAE,QAAQ,CAAC;AACpE;AAEA,SAAS,WAAW,OAAwB;AAC1C,QAAM,MAAM,MAAM,WAAW,GAAG,IAAI,aAAa,MAAM,MAAM,CAAC,GAAG,MAAM,IAAI;AAC3E,SAAO,KAAK,MAAM,GAAG;AACvB;AAEA,SAAS,IAAI,MAAc,OAAuB;AAChD,QAAM,IAA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,CAAC;AACH;AAEF,QACG,QAAQ,QAAQ,EAChB,YAAY,gEAAgE,EAC5E,OAAO,WAAW,gDAAgD,EAClE;AAAA,EAAO,CAAC,SACP,IAAI,YAAY;AACd,UAAM,OAAO,CAAC,WAAW,MAAM,GAAG,GAAG,SAAS;AAC9C,QAAI,KAAK,OAAO;AACd,cAAQ,IAAI,OAAO,KAAK,KAAK,GAAG,CAAC,EAAE;AACnC;AAAA,IACF;AACA,YAAQ,MAAM,YAAY,GAAG,SAAS,KAAK,KAAK,GAAG,CAAC,SAAI;AACxD,UAAM,IAAI,UAAU,OAAO,MAAM,EAAE,OAAO,UAAU,CAAC;AACrD,QAAI,EAAE,WAAW,GAAG;AAClB,cAAQ;AAAA,QACN;AAAA,gDAAmD,GAAG,oCACpC,GAAG;AAAA,MACvB;AACA,cAAQ,WAAW,EAAE,UAAU;AAAA,IACjC;AAAA,EACF,CAAC;AACH;AAEF,QACG,QAAQ,WAAW,EACnB,YAAY,0EAA0E,EACtF;AAAA,EAAO,MACN,IAAI,YAAY;AACd,UAAM,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,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
package/dist/index.d.ts CHANGED
@@ -38,10 +38,44 @@ interface PortfolioArgs {
38
38
  /** Comma-separated network IDs, e.g. "1,8453". Omit to auto-detect. */
39
39
  networkIds?: string;
40
40
  }
41
+ interface VerifySolanaBalanceArgs$1 {
42
+ address: string;
43
+ tokenMint: string;
44
+ transactionSignature: string;
45
+ }
46
+ interface VerifySolanaBalanceResult {
47
+ address: string;
48
+ token_mint: string;
49
+ transaction_signature: string;
50
+ source: "alchemy_rpc";
51
+ network: "solana-mainnet";
52
+ transaction: {
53
+ slot: number;
54
+ pre_balance: string;
55
+ post_balance: string;
56
+ delta: string;
57
+ };
58
+ balance: {
59
+ amount: string;
60
+ decimals: number;
61
+ ui_amount_string: string;
62
+ };
63
+ observed_slot: number;
64
+ read_covers_transaction: true;
65
+ as_of: string;
66
+ }
41
67
  interface DiscoverServicesOptions {
42
- /** Debug escape hatch: return uncurated compact Bazaar service summaries. */
68
+ /** Catalogs to search. Defaults to both. */
69
+ network?: "all" | "base" | "solana";
70
+ /** @deprecated Accepted for compatibility but not advertised to agents. */
43
71
  raw?: boolean;
44
72
  }
73
+ interface DiscoverServicesPageOptions extends DiscoverServicesOptions {
74
+ /** Results per page. Defaults to 10; maximum 25. */
75
+ limit?: number;
76
+ /** Opaque continuation from a prior page. */
77
+ cursor?: string;
78
+ }
45
79
  type RequestStatus = "pending_approval" | "pending_signature" | "pending_settlement" | "pending_confirmation" | "success" | "denied" | "error";
46
80
  type OutputType = "payment_token" | "signature" | "tx_hash" | "secret_token" | "raw_secret";
47
81
  interface CredentialOutput {
@@ -62,6 +96,12 @@ interface AgentResponse {
62
96
  output: CredentialOutput | null;
63
97
  approval_id: string | null;
64
98
  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
+ retryable?: boolean;
104
+ retry_hint?: string | null;
65
105
  }
66
106
  interface CredentialSummary {
67
107
  id: string;
@@ -75,13 +115,27 @@ interface CredentialSummary {
75
115
  }
76
116
  interface Grant {
77
117
  credential_id: string;
78
- approval_mode: "always_approve" | "autonomous";
118
+ approval_mode: "always_approve" | "iframe" | "autonomous";
79
119
  [key: string]: unknown;
80
120
  }
81
121
  interface ClientGrantSummary {
82
122
  credential: CredentialSummary;
83
123
  grant: Grant;
84
124
  }
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
+ interface UngrantedCredential {
130
+ credential_id: string;
131
+ name: string;
132
+ kind: "card" | "wallet" | "secret";
133
+ metadata: Record<string, unknown>;
134
+ }
135
+ interface ClientCredentialList {
136
+ credentials: ClientGrantSummary[];
137
+ ungranted: UngrantedCredential[];
138
+ }
85
139
  /** The wallet binding the server echoes for a wallet-sign / resolve. Mirrors
86
140
  * `WalletBinding` in server/src/agent.rs (key_id/derivation_path may be null
87
141
  * for an unprovisioned wallet). */
@@ -100,13 +154,15 @@ interface SwapPlan {
100
154
  quote: Record<string, unknown>;
101
155
  txs: PlanTx[];
102
156
  }
103
- /** `POST /agent/swap` response: the parked request plus the sign-ready plan. */
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. */
104
159
  interface SwapResult {
105
160
  response: AgentResponse;
106
- plan: SwapPlan;
161
+ plan: SwapPlan | null;
107
162
  }
108
- /** `POST /agent/wallet-sign` response: the parked request plus the wallet
109
- * binding, so the signer can sign without a separate resolve round-trip. */
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. */
110
166
  interface WalletSignResult {
111
167
  response: AgentResponse;
112
168
  binding: BindingResponse | null;
@@ -131,28 +187,48 @@ interface UseServiceArgs {
131
187
  /** The x402 sign-ready plan (`POST /agent/x402` | `/agent/use-service`): the
132
188
  * EIP-3009 typed data to sign + the wallet binding. */
133
189
  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. */
134
192
  typed_data: unknown;
135
193
  binding: {
136
194
  wallet_id: string;
137
195
  key_id?: string | null;
138
196
  derivation_path?: string | null;
139
197
  };
140
- x402: Record<string, unknown>;
198
+ x402: Record<string, unknown> & {
199
+ rail?: string;
200
+ };
201
+ /** Solana rail only: the base64 payment transaction to sign. */
202
+ solana?: {
203
+ transaction?: string;
204
+ };
141
205
  }
142
- /** `POST /agent/x402` | `/agent/use-service` response: parked request + plan. On
143
- * success, header mode puts the X-PAYMENT header in
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
144
209
  * `response.output.value.x_payment`; gateway mode puts the resource's reply in
145
210
  * `response.output.value.response`. */
146
211
  interface X402Result {
147
212
  response: AgentResponse;
148
- plan: X402Plan;
213
+ plan: X402Plan | null;
149
214
  }
150
215
  /** One curated x402 service (the `discover_services` tool / `/agent/services`):
151
216
  * where it lives, a human description, and its `accepts` PaymentRequirements. */
152
217
  interface ServiceSummary {
153
218
  resource: string;
154
219
  description: string | null;
155
- accepts: unknown;
220
+ accepts: Array<{
221
+ scheme: string;
222
+ network: string;
223
+ asset: string;
224
+ amount: string;
225
+ }>;
226
+ contract_uri?: string;
227
+ }
228
+ interface DiscoverServicesPage {
229
+ services: ServiceSummary[];
230
+ has_more: boolean;
231
+ next_cursor?: string;
156
232
  }
157
233
  /** `POST /agent/account-change` (the `request_account_change` tool): a pure
158
234
  * launcher. Surface `manage_url` to the user — they edit this client's access
@@ -166,7 +242,9 @@ interface AccountChangeResult {
166
242
  interface BuyLinkArgs {
167
243
  /** A granted wallet credential to fund. */
168
244
  credentialId: string;
169
- /** MoonPay currency code (defaults to USDC on the wallet's chain). */
245
+ /** Exact network. Defaults to Base for EVM or Solana mainnet for Solana. */
246
+ destinationChain?: "eip155:8453" | "eip155:1" | "solana:mainnet";
247
+ /** Enabled MoonPay code matching the destination's exact network. */
170
248
  currencyCode?: string;
171
249
  /** Prefill amount in USD. */
172
250
  amountUsd?: number;
@@ -177,6 +255,7 @@ interface BuyLinkResult {
177
255
  url: string;
178
256
  currency_code: string;
179
257
  wallet_address: string;
258
+ network: "eip155:8453" | "eip155:1" | "solana:mainnet";
180
259
  }
181
260
  interface WorldMarketsArgs {
182
261
  /** Return the events list (each event groups its markets) instead of markets. */
@@ -195,18 +274,6 @@ interface WorldPricesArgs {
195
274
  endTs: number;
196
275
  resolution?: number;
197
276
  }
198
- interface WorldTradeArgs {
199
- /** A granted wallet credential (Solana). */
200
- credentialId: string;
201
- /** The outcome mint to trade. */
202
- marketMint: string;
203
- /** "buy" | "sell" trade at market; "redeem" pays out a settled position. */
204
- side: "buy" | "sell" | "redeem";
205
- size: string;
206
- /** Ignored for redeem (no price slippage at settlement). Default 50. */
207
- slippageBps?: number;
208
- valueCents?: number;
209
- }
210
277
 
211
278
  declare class PayboxError extends Error {
212
279
  readonly status: number;
@@ -227,10 +294,7 @@ interface PayboxClientOptions {
227
294
  interface SignOptions {
228
295
  /** Sign in-process when the request clears to `pending_signature`. Default true. */
229
296
  autoSign?: boolean;
230
- /** When the request parks as `pending_approval` (approval-mode grant, or a
231
- * force-approved op like a World trade), wait for the user's passkey approval
232
- * and then sign in-process — the SDK's headless equivalent of the signing
233
- * window's post-approval sign. Default false (return the pending response). */
297
+ /** Wait for passkey approval and then sign in-process. Default false. */
234
298
  waitForApproval?: boolean | {
235
299
  intervalMs?: number;
236
300
  timeoutMs?: number;
@@ -245,15 +309,20 @@ declare class PayboxClient {
245
309
  constructor(options?: PayboxClientOptions);
246
310
  /** Build a client from `~/.config/paybox/config.json` + env, with overrides. */
247
311
  static fromConfig(overrides?: PayboxClientOptions): PayboxClient;
248
- /** Whether in-process signing is available (a `pbxk1.` key is configured). */
312
+ private signingCreds;
313
+ /** Whether in-process signing is available (a parseable `pbxk1.` key is set). */
249
314
  get canSign(): boolean;
250
315
  private bearer;
251
316
  private request;
252
317
  private readonly poster;
253
- /** List the credentials this client may use (the `list_credentials` tool). */
254
- listCredentials(): Promise<ClientGrantSummary[]>;
318
+ /** List granted credentials plus the `ungranted` credentials (id, name, kind,
319
+ * safe metadata) the user owns but hasn't granted this connector. */
320
+ listCredentials(): Promise<ClientCredentialList>;
255
321
  /** Token balances across chains (the `get_portfolio` tool). */
256
322
  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
+ verifySolanaBalance(args: VerifySolanaBalanceArgs$1): Promise<VerifySolanaBalanceResult>;
257
326
  /** Charge a card credential (the `request_payment` tool). */
258
327
  requestPayment(args: PaymentArgs): Promise<AgentResponse>;
259
328
  /** Reveal a secret credential (the `request_secret` tool). */
@@ -261,27 +330,41 @@ declare class PayboxClient {
261
330
  /** Sign with a wallet credential (the `request_wallet_sign` tool). Signs
262
331
  * in-process and returns the completed request when a signing key is set and
263
332
  * the request clears immediately; otherwise returns the pending response.
264
- * Uses `/agent/wallet-sign`, which echoes the wallet binding so the signer
265
- * need not resolve it separately. */
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. */
266
336
  requestWalletSign(args: WalletSignArgs, opts?: SignOptions): Promise<AgentResponse>;
267
337
  /** Swap tokens from a wallet credential (the `request_swap` tool). Returns the
268
- * parked response + sign-ready plan; signs + submits in-process when a signing
269
- * key is set and the swap cleared immediately. */
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. */
270
341
  requestSwap(args: SwapArgs, opts?: SignOptions): Promise<SwapResult>;
271
- /** Shared completion for swap-shaped requests (`request_swap` and the World
272
- * trade): optionally wait out a `pending_approval` dwell, then sign the plan
273
- * in-process and submit envelopes. Signing re-pins a Solana plan's blockhash
274
- * (and re-quotes a stale World order) via `/agent/requests/{id}/refresh`
275
- * first, so a long approval dwell never signs stale bytes. */
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. */
276
346
  private completeSwap;
277
347
  /** Poll while the request sits in `pending_approval` (the user is approving
278
348
  * with their passkey); returns the first non-approval state. */
279
349
  private waitWhileApproval;
280
- /** Discover curated paid x402 services from the Bazaar catalog (the
281
- * `discover_services` tool). Pass a query to search the curated set; omit it
282
- * for the curated listing. Set `raw` only to inspect uncurated compact
283
- * Bazaar service summaries. */
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
+ 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
+ private signWithReconcile;
363
+ /** Discover x402 services with the original array-returning response. */
284
364
  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
+ discoverServicesPage(query?: string, opts?: DiscoverServicesPageOptions): Promise<DiscoverServicesPage>;
285
368
  /** Pay a paid x402 endpoint from a wallet credential (the `pay_x402` tool,
286
369
  * header mode). Signs in-process when a signing key is set and the payment
287
370
  * clears immediately — then the X-PAYMENT header is on the completed
@@ -319,14 +402,11 @@ declare class PayboxClient {
319
402
  /** Filter addresses down to World outcome mints (the
320
403
  * `world_filter_outcome_mints` tool). */
321
404
  worldFilterOutcomeMints(addresses: string[]): Promise<unknown>;
322
- /** Solana token positions for an address (the `world_positions` tool). */
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. */
323
409
  worldPositions(address: string): Promise<unknown>;
324
- /** Trade a World prediction market (the `world_buy_outcome` /
325
- * `world_change_position` / `world_redeem` tools). Always parks as
326
- * `pending_approval` (trades are force-approved); pass
327
- * `{ waitForApproval: true }` to wait for the user's passkey approval and
328
- * sign in-process. */
329
- worldTrade(args: WorldTradeArgs, opts?: SignOptions): Promise<SwapResult>;
330
410
  /** Hyperliquid spot markets (the `hyperliquid_markets` tool). */
331
411
  hyperliquidMarkets(): Promise<unknown>;
332
412
  /** Hyperliquid spot prices (the `hyperliquid_prices` tool). */
@@ -335,6 +415,9 @@ declare class PayboxClient {
335
415
  hyperliquidToken(name: string): Promise<unknown>;
336
416
  /** Poll a request's status (the `get_request` tool). */
337
417
  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
+ private requestAfterSign;
338
421
  /** Poll until the request leaves a pending state (or the timeout elapses). */
339
422
  waitForRequest(requestId: string, opts?: {
340
423
  intervalMs?: number;
@@ -412,5 +495,10 @@ interface GetPortfolioArgs {
412
495
  address: string;
413
496
  network_ids?: string | null;
414
497
  }
498
+ interface VerifySolanaBalanceArgs {
499
+ address: string;
500
+ token_mint: string;
501
+ transaction_signature: string;
502
+ }
415
503
 
416
- export { type AccountChangeResult, type AgentResponse, type BindingResponse, type BuyLinkArgs, type BuyLinkResult, type ClientGrantSummary, type CredentialOutput, type CredentialSummary, type DiscoverServicesOptions, type GetPortfolioArgs, type Grant, type LoginOptions, type OAuthTokens, type OutputType, PayboxClient, type PayboxClientOptions, PayboxError, type PaymentArgs, type PortfolioArgs, type RequestPaymentArgs, type RequestSecretArgs, type RequestStatus, type RequestSwapArgs, type RequestWalletSignArgs, type SecretArgs, type ServiceSummary, type SignOptions, type StoredConfig, type SwapArgs, type SwapPlan, type SwapResult, type UseServiceArgs, type WalletSignArgs, type WalletSignResult, type WorldMarketsArgs, type WorldPricesArgs, type WorldTradeArgs, type X402Args, type X402Plan, type X402Result, configFile, credsFromToken, loadConfig, loginLoopback, mcpResource, refreshTokens, saveConfig };
504
+ export { type AccountChangeResult, type AgentResponse, type BindingResponse, type BuyLinkArgs, type BuyLinkResult, type ClientCredentialList, type ClientGrantSummary, type CredentialOutput, type CredentialSummary, type DiscoverServicesOptions, type GetPortfolioArgs, type Grant, type LoginOptions, type OAuthTokens, type OutputType, PayboxClient, type PayboxClientOptions, PayboxError, type PaymentArgs, type PortfolioArgs, type RequestPaymentArgs, type RequestSecretArgs, type RequestStatus, type RequestSwapArgs, type RequestWalletSignArgs, type SecretArgs, type ServiceSummary, type SignOptions, type StoredConfig, type SwapArgs, type SwapPlan, type SwapResult, type UngrantedCredential, type UseServiceArgs, type VerifySolanaBalanceArgs$1 as VerifySolanaBalanceArgs, type VerifySolanaBalanceResult, type VerifySolanaBalanceArgs as VerifySolanaBalanceWireArgs, type WalletSignArgs, type WalletSignResult, type WorldMarketsArgs, type WorldPricesArgs, type X402Args, type X402Plan, type X402Result, configFile, credsFromToken, loadConfig, loginLoopback, mcpResource, refreshTokens, saveConfig };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  mcpResource,
9
9
  refreshTokens,
10
10
  saveConfig
11
- } from "./chunk-EBB4HNOB.js";
11
+ } from "./chunk-OBZSVPP7.js";
12
12
  export {
13
13
  PayboxClient,
14
14
  PayboxError,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@paybox-sh/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "type": "module",
5
- "description": "Typed Node SDK + `paybox` CLI for the Paybox agent API. Mirrors the MCP tool surface (list_credentials, request_payment, request_wallet_sign, request_secret, request_swap, get_portfolio, get_request) over REST, with in-process non-custodial wallet signing.",
5
+ "description": "Typed Node SDK + `paybox` CLI for the PayBox agent API. Mirrors the MCP tool surface (list_credentials, request_payment, request_wallet_sign, request_secret, request_swap, get_portfolio, verify_solana_balance, get_request) over REST, with in-process non-custodial wallet signing.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -37,7 +37,8 @@
37
37
  }
38
38
  },
39
39
  "files": [
40
- "dist"
40
+ "dist",
41
+ "SKILL.md"
41
42
  ],
42
43
  "engines": {
43
44
  "node": ">=18"
@@ -45,12 +46,13 @@
45
46
  "scripts": {
46
47
  "build": "tsup",
47
48
  "dev": "tsup --watch",
49
+ "test": "tsx --test test/*.test.ts",
48
50
  "typecheck": "tsc --noEmit",
49
51
  "gen": "tsx scripts/generate.ts",
50
52
  "prepublishOnly": "pnpm build"
51
53
  },
52
54
  "dependencies": {
53
- "@moon-x/core": "0.10.0",
55
+ "@moon-x/core": "0.17.0",
54
56
  "@moon-x/evm-adapter": "0.3.0",
55
57
  "@moon-x/solana-adapter": "0.3.0",
56
58
  "@solana/web3.js": "1.98.4",
@@ -68,5 +70,11 @@
68
70
  "tsup": "8.3.5",
69
71
  "tsx": "4.19.2",
70
72
  "typescript": "5.9.3"
73
+ },
74
+ "pnpm": {
75
+ "comment:overrides": "ASEC-8563 (GHSA-67mh-4wv8-2f99): force tsup's transitive esbuild off 0.24.2 so no flagged version remains in this lockfile. Targets 0.24.2 only; tsx's 0.23.1 is unaffected.",
76
+ "overrides": {
77
+ "esbuild@0.24.2": "0.25.0"
78
+ }
71
79
  }
72
80
  }