@paybox-sh/sdk 0.8.0 → 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/README.md +2 -1
- package/SKILL.md +73 -9
- package/dist/{chunk-7VW4QMV4.js → chunk-WRPYONXW.js} +41 -90
- package/dist/chunk-WRPYONXW.js.map +1 -0
- package/dist/cli.js +84 -25
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -142
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7VW4QMV4.js.map +0 -1
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, 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\";\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 valid pbxk1. 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 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 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\", \"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: 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(\"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: 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({ 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,WAAoB;AAC3B,SAAO,QAAQ,QAAQ,KAAK,EAAE,IAAI;AACpC;AAEA,SAAS,KAAK,MAAqB;AACjC,MAAI,SAAS,EAAG,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O,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":[]}
|
|
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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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,38 +135,25 @@ 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
158
|
typed_data: unknown;
|
|
191
159
|
binding: {
|
|
@@ -193,19 +161,17 @@ interface X402Plan {
|
|
|
193
161
|
key_id?: string | null;
|
|
194
162
|
derivation_path?: string | null;
|
|
195
163
|
};
|
|
196
|
-
x402: Record<string, unknown
|
|
164
|
+
x402: Record<string, unknown> & {
|
|
165
|
+
rail?: string;
|
|
166
|
+
};
|
|
167
|
+
solana?: {
|
|
168
|
+
transaction?: string;
|
|
169
|
+
};
|
|
197
170
|
}
|
|
198
|
-
/** `POST /agent/x402` | `/agent/use-service` response. The plan is present only
|
|
199
|
-
* while approval or signature is pending. On success, header mode puts the
|
|
200
|
-
* X-PAYMENT header in
|
|
201
|
-
* `response.output.value.x_payment`; gateway mode puts the resource's reply in
|
|
202
|
-
* `response.output.value.response`. */
|
|
203
171
|
interface X402Result {
|
|
204
172
|
response: AgentResponse;
|
|
205
173
|
plan: X402Plan | null;
|
|
206
174
|
}
|
|
207
|
-
/** One curated x402 service (the `discover_services` tool / `/agent/services`):
|
|
208
|
-
* where it lives, a human description, and its `accepts` PaymentRequirements. */
|
|
209
175
|
interface ServiceSummary {
|
|
210
176
|
resource: string;
|
|
211
177
|
description: string | null;
|
|
@@ -222,9 +188,6 @@ interface DiscoverServicesPage {
|
|
|
222
188
|
has_more: boolean;
|
|
223
189
|
next_cursor?: string;
|
|
224
190
|
}
|
|
225
|
-
/** `POST /agent/account-change` (the `request_account_change` tool): a pure
|
|
226
|
-
* launcher. Surface `manage_url` to the user — they edit this client's access
|
|
227
|
-
* in their own app session (passkey-gated); nothing is parked server-side. */
|
|
228
191
|
interface AccountChangeResult {
|
|
229
192
|
kind: "account_change";
|
|
230
193
|
client_id: string;
|
|
@@ -232,17 +195,11 @@ interface AccountChangeResult {
|
|
|
232
195
|
note?: string | null;
|
|
233
196
|
}
|
|
234
197
|
interface BuyLinkArgs {
|
|
235
|
-
/** A granted wallet credential to fund. */
|
|
236
198
|
credentialId: string;
|
|
237
|
-
/** Exact network. Defaults to Base for EVM or Solana mainnet for Solana. */
|
|
238
199
|
destinationChain?: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
239
|
-
/** Enabled MoonPay code matching the destination's exact network. */
|
|
240
200
|
currencyCode?: string;
|
|
241
|
-
/** Prefill amount in USD. */
|
|
242
201
|
amountUsd?: number;
|
|
243
202
|
}
|
|
244
|
-
/** `GET /agent/buy-link` (the `get_buy_link` tool): a signed MoonPay checkout
|
|
245
|
-
* URL funding the wallet. Generating the link charges nothing. */
|
|
246
203
|
interface BuyLinkResult {
|
|
247
204
|
url: string;
|
|
248
205
|
currency_code: string;
|
|
@@ -250,14 +207,11 @@ interface BuyLinkResult {
|
|
|
250
207
|
network: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
251
208
|
}
|
|
252
209
|
interface WorldMarketsArgs {
|
|
253
|
-
/** Return the events list (each event groups its markets) instead of markets. */
|
|
254
210
|
events?: boolean;
|
|
255
211
|
limit?: number;
|
|
256
|
-
/** Rows to skip; the response carries the next cursor. */
|
|
257
212
|
cursor?: number;
|
|
258
213
|
eventTicker?: string;
|
|
259
214
|
seriesTicker?: string;
|
|
260
|
-
/** One of active | initialized | determined | finalized. */
|
|
261
215
|
status?: string;
|
|
262
216
|
}
|
|
263
217
|
interface WorldPricesArgs {
|
|
@@ -273,20 +227,14 @@ declare class PayboxError extends Error {
|
|
|
273
227
|
constructor(status: number, body: string, context: string);
|
|
274
228
|
}
|
|
275
229
|
interface PayboxClientOptions {
|
|
276
|
-
/** API origin (the OAuth issuer). Default `https://api.paybox.sh`. */
|
|
277
230
|
baseUrl?: string;
|
|
278
|
-
/** A `pbx_live_*` personal API key. */
|
|
279
231
|
apiKey?: string;
|
|
280
|
-
/** A raw OAuth access token (skips the stored-token path). */
|
|
281
232
|
token?: string;
|
|
282
|
-
/** A `pbxk1.` signing key token; enables in-process wallet/swap signing. */
|
|
283
233
|
signingKey?: string;
|
|
284
234
|
fetchImpl?: typeof fetch;
|
|
285
235
|
}
|
|
286
236
|
interface SignOptions {
|
|
287
|
-
/** Sign in-process when the request clears to `pending_signature`. Default true. */
|
|
288
237
|
autoSign?: boolean;
|
|
289
|
-
/** Wait for passkey approval and then sign in-process. Default false. */
|
|
290
238
|
waitForApproval?: boolean | {
|
|
291
239
|
intervalMs?: number;
|
|
292
240
|
timeoutMs?: number;
|
|
@@ -299,118 +247,42 @@ declare class PayboxClient {
|
|
|
299
247
|
private oauth?;
|
|
300
248
|
private configBacked;
|
|
301
249
|
constructor(options?: PayboxClientOptions);
|
|
302
|
-
/** Build a client from `~/.config/paybox/config.json` + env, with overrides. */
|
|
303
250
|
static fromConfig(overrides?: PayboxClientOptions): PayboxClient;
|
|
304
251
|
private signingCreds;
|
|
305
|
-
/** Whether in-process signing is available (a parseable `pbxk1.` key is set). */
|
|
306
252
|
get canSign(): boolean;
|
|
307
253
|
private bearer;
|
|
308
254
|
private request;
|
|
309
255
|
private readonly poster;
|
|
310
|
-
/** List granted credentials plus the `ungranted` credentials (id, name, kind,
|
|
311
|
-
* safe metadata) the user owns but hasn't granted this connector. */
|
|
312
256
|
listCredentials(): Promise<ClientCredentialList>;
|
|
313
|
-
/** Token balances across chains (the `get_portfolio` tool). */
|
|
314
257
|
getPortfolio(args: PortfolioArgs): Promise<unknown>;
|
|
315
|
-
/** Verify one confirmed Solana transaction's exact wallet/mint effect, then
|
|
316
|
-
* read the current balance at or after its slot (`verify_solana_balance`). */
|
|
317
258
|
verifySolanaBalance(args: VerifySolanaBalanceArgs$1): Promise<VerifySolanaBalanceResult>;
|
|
318
|
-
/** Charge a card credential (the `request_payment` tool). */
|
|
319
259
|
requestPayment(args: PaymentArgs): Promise<AgentResponse>;
|
|
320
|
-
/** Reveal a secret credential (the `request_secret` tool). */
|
|
321
260
|
requestSecret(args: SecretArgs): Promise<AgentResponse>;
|
|
322
|
-
/** Sign with a wallet credential (the `request_wallet_sign` tool). Signs
|
|
323
|
-
* in-process and returns the completed request when a signing key is set and
|
|
324
|
-
* the request clears immediately; otherwise returns the pending response.
|
|
325
|
-
* Uses `/agent/wallet-sign`, which echoes the wallet binding only while
|
|
326
|
-
* approval or signature is pending so the signer need not resolve it
|
|
327
|
-
* separately. Terminal responses carry a null binding. */
|
|
328
261
|
requestWalletSign(args: WalletSignArgs, opts?: SignOptions): Promise<AgentResponse>;
|
|
329
|
-
/** Swap tokens from a wallet credential (the `request_swap` tool). Returns the
|
|
330
|
-
* parked response and its sign-ready plan while approval or signature is
|
|
331
|
-
* pending; terminal responses carry a null plan. Signs + submits in-process
|
|
332
|
-
* when a signing key is set and the swap cleared immediately. */
|
|
333
262
|
requestSwap(args: SwapArgs, opts?: SignOptions): Promise<SwapResult>;
|
|
334
|
-
/** Complete a swap request: optionally wait out a `pending_approval` dwell,
|
|
335
|
-
* then sign the plan in-process and submit envelopes. Signing first refreshes
|
|
336
|
-
* the parked request via `/agent/requests/{id}/refresh`, so a long approval
|
|
337
|
-
* dwell never signs stale bytes. */
|
|
338
263
|
private completeSwap;
|
|
339
|
-
/** Poll while the request sits in `pending_approval` (the user is approving
|
|
340
|
-
* with their passkey); returns the first non-approval state. */
|
|
341
264
|
private waitWhileApproval;
|
|
342
|
-
/** Run an operation and, if it terminates on a server-marked expiry
|
|
343
|
-
* (`retryable` on a terminal `error`/`denied`: the window elapsed and nothing
|
|
344
|
-
* was signed or spent), re-issue it exactly once (SPE-456). Never loops: the
|
|
345
|
-
* second attempt's result is returned as-is. */
|
|
346
265
|
private withExpiryRetry;
|
|
347
|
-
/** Sign a parked request; if the sign/submit call fails, reconcile against the
|
|
348
|
-
* authoritative state once (SPE-456). The server leaves a pre-broadcast
|
|
349
|
-
* completion failure recoverable — the claim is released and the row stays
|
|
350
|
-
* `pending_signature` — so re-sign a still-open request a single time; a
|
|
351
|
-
* terminal or already-broadcast row is left as-is for the caller to read (and
|
|
352
|
-
* for `withExpiryRetry` to re-issue if it is retryable). Bounded to one extra
|
|
353
|
-
* attempt: a second failure propagates. */
|
|
354
266
|
private signWithReconcile;
|
|
355
|
-
/** Discover x402 services with the original array-returning response. */
|
|
356
267
|
discoverServices(query?: string, opts?: DiscoverServicesOptions): Promise<ServiceSummary[]>;
|
|
357
|
-
/** Discover one bounded page of x402 services. Reuse the returned cursor with
|
|
358
|
-
* the same query and network while `has_more` is true. */
|
|
359
268
|
discoverServicesPage(query?: string, opts?: DiscoverServicesPageOptions): Promise<DiscoverServicesPage>;
|
|
360
|
-
/** Pay a paid x402 endpoint from a wallet credential (the `pay_x402` tool,
|
|
361
|
-
* header mode). Signs in-process when a signing key is set and the payment
|
|
362
|
-
* clears immediately — then the X-PAYMENT header is on the completed
|
|
363
|
-
* response's `output.value.x_payment` (replay it on the original request). */
|
|
364
269
|
payX402(args: X402Args, opts?: SignOptions): Promise<X402Result>;
|
|
365
|
-
/** Fetch a paid x402 resource and have paybox pay for it (the `use_service`
|
|
366
|
-
* tool, gateway mode): paybox probes the url, pays the 402, re-fetches with the
|
|
367
|
-
* payment, and returns the resource's reply on `output.value.response`. */
|
|
368
270
|
useService(args: UseServiceArgs, opts?: SignOptions): Promise<X402Result>;
|
|
369
|
-
/** Shared completion for the two x402 entry points: optionally wait out a
|
|
370
|
-
* `pending_approval` dwell, then sign the parked typed data in-process and
|
|
371
|
-
* return the finished request, exactly like the swap path. */
|
|
372
271
|
private completeX402;
|
|
373
|
-
/** Claim the usable card credentials of an approved payment (the
|
|
374
|
-
* `claim_payment_credentials` tool). One-time: the claim is consumed. */
|
|
375
272
|
claimPaymentCredentials(requestId: string): Promise<Record<string, unknown>>;
|
|
376
|
-
/** Open the account-change flow (the `request_account_change` tool): returns a
|
|
377
|
-
* `manage_url` deep link for the USER to open — they update this client's
|
|
378
|
-
* access (or add a credential) in their own passkey-gated app session.
|
|
379
|
-
* Nothing is parked or applied server-side. */
|
|
380
273
|
requestAccountChange(note?: string): Promise<AccountChangeResult>;
|
|
381
|
-
/** A signed MoonPay checkout URL funding a granted wallet (the `get_buy_link`
|
|
382
|
-
* tool). Share the URL with the user; generating it charges nothing. */
|
|
383
274
|
getBuyLink(args: BuyLinkArgs): Promise<BuyLinkResult>;
|
|
384
|
-
/** Browse World prediction markets (the `world_find_markets` tool). */
|
|
385
275
|
worldMarkets(args?: WorldMarketsArgs): Promise<unknown>;
|
|
386
|
-
/** One World event with its markets (the `world_get_market` tool). Nested
|
|
387
|
-
* markets default on, matching the tool — they carry the outcome mint ids
|
|
388
|
-
* the orderbook/trade calls need. */
|
|
389
276
|
worldMarket(eventTicker: string, withNestedMarkets?: boolean): Promise<unknown>;
|
|
390
|
-
/** A World market's orderbook (the `world_orderbook` tool). */
|
|
391
277
|
worldOrderbook(id: string, byMint?: boolean): Promise<unknown>;
|
|
392
|
-
/** A World market's price history (the `world_market_prices` tool). */
|
|
393
278
|
worldPrices(args: WorldPricesArgs): Promise<unknown>;
|
|
394
|
-
/** Filter addresses down to World outcome mints (the
|
|
395
|
-
* `world_filter_outcome_mints` tool). */
|
|
396
279
|
worldFilterOutcomeMints(addresses: string[]): Promise<unknown>;
|
|
397
|
-
/** A wallet's World prediction-market positions: classified `positions` /
|
|
398
|
-
* `settled` entries (each with a `position_result`) plus `settlement_cash`
|
|
399
|
-
* for a settled winner's CASH cash-out (swap CASH to USDC via request_swap).
|
|
400
|
-
* The `world_positions` tool. */
|
|
401
280
|
worldPositions(address: string): Promise<unknown>;
|
|
402
|
-
/** Hyperliquid spot markets (the `hyperliquid_markets` tool). */
|
|
403
281
|
hyperliquidMarkets(): Promise<unknown>;
|
|
404
|
-
/** Hyperliquid spot prices (the `hyperliquid_prices` tool). */
|
|
405
282
|
hyperliquidPrices(): Promise<unknown>;
|
|
406
|
-
/** Resolve one Hyperliquid token by name (the `hyperliquid_token` tool). */
|
|
407
283
|
hyperliquidToken(name: string): Promise<unknown>;
|
|
408
|
-
/** Poll a request's status (the `get_request` tool). */
|
|
409
284
|
getRequest(requestId: string): Promise<AgentResponse>;
|
|
410
|
-
/** After in-process sign, `--wait` polls through settlement/confirmation;
|
|
411
|
-
* without it, return the first snapshot (the historical no-wait contract). */
|
|
412
285
|
private requestAfterSign;
|
|
413
|
-
/** Poll until the request leaves a pending state (or the timeout elapses). */
|
|
414
286
|
waitForRequest(requestId: string, opts?: {
|
|
415
287
|
intervalMs?: number;
|
|
416
288
|
timeoutMs?: number;
|
|
@@ -421,15 +293,11 @@ interface OAuthTokens {
|
|
|
421
293
|
clientId: string;
|
|
422
294
|
accessToken: string;
|
|
423
295
|
refreshToken?: string;
|
|
424
|
-
/** Epoch millis the access token expires. */
|
|
425
296
|
expiresAt?: number;
|
|
426
|
-
/** The audience the token is bound to (`<baseUrl>/mcp`). */
|
|
427
297
|
resource: string;
|
|
428
298
|
}
|
|
429
299
|
interface StoredConfig {
|
|
430
300
|
baseUrl?: string;
|
|
431
|
-
/** Paybox app origin used for signing-key provisioning (derived from baseUrl
|
|
432
|
-
* when unset). */
|
|
433
301
|
appUrl?: string;
|
|
434
302
|
apiKey?: string;
|
|
435
303
|
oauth?: OAuthTokens;
|
|
@@ -439,20 +307,16 @@ declare function configFile(): string;
|
|
|
439
307
|
declare function loadConfig(): StoredConfig;
|
|
440
308
|
declare function saveConfig(config: StoredConfig): void;
|
|
441
309
|
|
|
442
|
-
/** The MCP resource the access token is audience-bound to. */
|
|
443
310
|
declare function mcpResource(baseUrl: string): string;
|
|
444
311
|
interface LoginOptions {
|
|
445
312
|
scope?: string;
|
|
446
313
|
clientName?: string;
|
|
447
|
-
/** Sink for the "open this URL" prompt; defaults to console.error. */
|
|
448
314
|
log?: (msg: string) => void;
|
|
449
|
-
/** Abort with an error if no approval arrives in this long. Default 5 min. */
|
|
450
315
|
timeoutMs?: number;
|
|
451
316
|
}
|
|
452
317
|
declare function loginLoopback(baseUrl: string, opts?: LoginOptions): Promise<OAuthTokens>;
|
|
453
318
|
declare function refreshTokens(baseUrl: string, current: OAuthTokens): Promise<OAuthTokens>;
|
|
454
319
|
|
|
455
|
-
/** Parse the one-string `pbxk1.` token into the agent keypair the core expects. */
|
|
456
320
|
declare function credsFromToken(token: string): Creds;
|
|
457
321
|
|
|
458
322
|
interface RequestPaymentArgs {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paybox-sh/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"type": "module",
|
|
5
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",
|