@paybox-sh/sdk 0.5.0 → 0.8.0
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 +46 -15
- package/SKILL.md +118 -0
- package/dist/{chunk-DIMOTJ2E.js → chunk-7VW4QMV4.js} +445 -105
- package/dist/chunk-7VW4QMV4.js.map +1 -0
- package/dist/cli.js +125 -54
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +220 -26
- package/dist/index.js +1 -1
- package/package.json +12 -4
- package/dist/chunk-DIMOTJ2E.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, 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.5.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\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 if (res.status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"request is awaiting a signature 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 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 .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.requestSwap({\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 if (result.response.status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"swap is 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 emit(result);\n }),\n );\n\nprogram\n .command(\"discover [query]\")\n .description(\"Discover paid x402 services from the Bazaar catalog (optional ranked search)\")\n .action((query) => run(async () => emit(await client().discoverServices(query))));\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 .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.payX402({\n credentialId: o.credential,\n accepts: readIntent(o.accepts) as unknown[],\n resourceUrl: o.url,\n });\n if (result.response.status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"payment is awaiting a signature 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 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 .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.useService({\n credentialId: o.credential,\n url: o.url,\n method: o.method,\n body: o.body === undefined ? undefined : readIntent(o.body),\n });\n if (result.response.status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"payment is awaiting a signature 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 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(\"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,SAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,MACpD,SAAQ,IAAI,MAAM,EAAE,OAAO,MAAM,QAAQ,QAAQ,OAAO,MAAM,CAAC;AACtE;AAEA,SAA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Q,IAAI,sBAAsB,MAAM,gCAA2B;AAAA,IACrE;AAAA,EACF,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":[]}
|
|
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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E,GAAG;AAAA,IACxE;AAAA,EACF,CAAC;AACH;AAEF,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,45 @@ interface PortfolioArgs {
|
|
|
38
38
|
/** Comma-separated network IDs, e.g. "1,8453". Omit to auto-detect. */
|
|
39
39
|
networkIds?: string;
|
|
40
40
|
}
|
|
41
|
-
|
|
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
|
+
}
|
|
67
|
+
interface DiscoverServicesOptions {
|
|
68
|
+
/** Catalogs to search. Defaults to both. */
|
|
69
|
+
network?: "all" | "base" | "solana";
|
|
70
|
+
/** @deprecated Accepted for compatibility but not advertised to agents. */
|
|
71
|
+
raw?: boolean;
|
|
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
|
+
}
|
|
79
|
+
type RequestStatus = "pending_approval" | "pending_signature" | "pending_settlement" | "pending_confirmation" | "success" | "denied" | "error";
|
|
42
80
|
type OutputType = "payment_token" | "signature" | "tx_hash" | "secret_token" | "raw_secret";
|
|
43
81
|
interface CredentialOutput {
|
|
44
82
|
output_id: string;
|
|
@@ -58,6 +96,12 @@ interface AgentResponse {
|
|
|
58
96
|
output: CredentialOutput | null;
|
|
59
97
|
approval_id: string | null;
|
|
60
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;
|
|
61
105
|
}
|
|
62
106
|
interface CredentialSummary {
|
|
63
107
|
id: string;
|
|
@@ -71,13 +115,27 @@ interface CredentialSummary {
|
|
|
71
115
|
}
|
|
72
116
|
interface Grant {
|
|
73
117
|
credential_id: string;
|
|
74
|
-
approval_mode: "always_approve" | "autonomous";
|
|
118
|
+
approval_mode: "always_approve" | "iframe" | "autonomous";
|
|
75
119
|
[key: string]: unknown;
|
|
76
120
|
}
|
|
77
121
|
interface ClientGrantSummary {
|
|
78
122
|
credential: CredentialSummary;
|
|
79
123
|
grant: Grant;
|
|
80
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
|
+
}
|
|
81
139
|
/** The wallet binding the server echoes for a wallet-sign / resolve. Mirrors
|
|
82
140
|
* `WalletBinding` in server/src/agent.rs (key_id/derivation_path may be null
|
|
83
141
|
* for an unprovisioned wallet). */
|
|
@@ -96,13 +154,15 @@ interface SwapPlan {
|
|
|
96
154
|
quote: Record<string, unknown>;
|
|
97
155
|
txs: PlanTx[];
|
|
98
156
|
}
|
|
99
|
-
/** `POST /agent/swap` response
|
|
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. */
|
|
100
159
|
interface SwapResult {
|
|
101
160
|
response: AgentResponse;
|
|
102
|
-
plan: SwapPlan;
|
|
161
|
+
plan: SwapPlan | null;
|
|
103
162
|
}
|
|
104
|
-
/** `POST /agent/wallet-sign` response
|
|
105
|
-
*
|
|
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. */
|
|
106
166
|
interface WalletSignResult {
|
|
107
167
|
response: AgentResponse;
|
|
108
168
|
binding: BindingResponse | null;
|
|
@@ -110,7 +170,7 @@ interface WalletSignResult {
|
|
|
110
170
|
interface X402Args {
|
|
111
171
|
credentialId: string;
|
|
112
172
|
/** The 402's `accepts` PaymentRequirements array, verbatim (from the resource's
|
|
113
|
-
* own 402 — discover_services gives you
|
|
173
|
+
* own 402 — discover_services gives you a curated catalog entry to start from). */
|
|
114
174
|
accepts: unknown[];
|
|
115
175
|
/** The paywalled resource URL. */
|
|
116
176
|
resourceUrl: string;
|
|
@@ -135,20 +195,76 @@ interface X402Plan {
|
|
|
135
195
|
};
|
|
136
196
|
x402: Record<string, unknown>;
|
|
137
197
|
}
|
|
138
|
-
/** `POST /agent/x402` | `/agent/use-service` response
|
|
139
|
-
* success, header mode puts the
|
|
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
|
|
140
201
|
* `response.output.value.x_payment`; gateway mode puts the resource's reply in
|
|
141
202
|
* `response.output.value.response`. */
|
|
142
203
|
interface X402Result {
|
|
143
204
|
response: AgentResponse;
|
|
144
|
-
plan: X402Plan;
|
|
205
|
+
plan: X402Plan | null;
|
|
145
206
|
}
|
|
146
|
-
/** One
|
|
207
|
+
/** One curated x402 service (the `discover_services` tool / `/agent/services`):
|
|
147
208
|
* where it lives, a human description, and its `accepts` PaymentRequirements. */
|
|
148
209
|
interface ServiceSummary {
|
|
149
210
|
resource: string;
|
|
150
211
|
description: string | null;
|
|
151
|
-
accepts:
|
|
212
|
+
accepts: Array<{
|
|
213
|
+
scheme: string;
|
|
214
|
+
network: string;
|
|
215
|
+
asset: string;
|
|
216
|
+
amount: string;
|
|
217
|
+
}>;
|
|
218
|
+
contract_uri?: string;
|
|
219
|
+
}
|
|
220
|
+
interface DiscoverServicesPage {
|
|
221
|
+
services: ServiceSummary[];
|
|
222
|
+
has_more: boolean;
|
|
223
|
+
next_cursor?: string;
|
|
224
|
+
}
|
|
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
|
+
interface AccountChangeResult {
|
|
229
|
+
kind: "account_change";
|
|
230
|
+
client_id: string;
|
|
231
|
+
manage_url: string;
|
|
232
|
+
note?: string | null;
|
|
233
|
+
}
|
|
234
|
+
interface BuyLinkArgs {
|
|
235
|
+
/** A granted wallet credential to fund. */
|
|
236
|
+
credentialId: string;
|
|
237
|
+
/** Exact network. Defaults to Base for EVM or Solana mainnet for Solana. */
|
|
238
|
+
destinationChain?: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
239
|
+
/** Enabled MoonPay code matching the destination's exact network. */
|
|
240
|
+
currencyCode?: string;
|
|
241
|
+
/** Prefill amount in USD. */
|
|
242
|
+
amountUsd?: number;
|
|
243
|
+
}
|
|
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
|
+
interface BuyLinkResult {
|
|
247
|
+
url: string;
|
|
248
|
+
currency_code: string;
|
|
249
|
+
wallet_address: string;
|
|
250
|
+
network: "eip155:8453" | "eip155:1" | "solana:mainnet";
|
|
251
|
+
}
|
|
252
|
+
interface WorldMarketsArgs {
|
|
253
|
+
/** Return the events list (each event groups its markets) instead of markets. */
|
|
254
|
+
events?: boolean;
|
|
255
|
+
limit?: number;
|
|
256
|
+
/** Rows to skip; the response carries the next cursor. */
|
|
257
|
+
cursor?: number;
|
|
258
|
+
eventTicker?: string;
|
|
259
|
+
seriesTicker?: string;
|
|
260
|
+
/** One of active | initialized | determined | finalized. */
|
|
261
|
+
status?: string;
|
|
262
|
+
}
|
|
263
|
+
interface WorldPricesArgs {
|
|
264
|
+
ticker: string;
|
|
265
|
+
startTs: number;
|
|
266
|
+
endTs: number;
|
|
267
|
+
resolution?: number;
|
|
152
268
|
}
|
|
153
269
|
|
|
154
270
|
declare class PayboxError extends Error {
|
|
@@ -170,6 +286,11 @@ interface PayboxClientOptions {
|
|
|
170
286
|
interface SignOptions {
|
|
171
287
|
/** Sign in-process when the request clears to `pending_signature`. Default true. */
|
|
172
288
|
autoSign?: boolean;
|
|
289
|
+
/** Wait for passkey approval and then sign in-process. Default false. */
|
|
290
|
+
waitForApproval?: boolean | {
|
|
291
|
+
intervalMs?: number;
|
|
292
|
+
timeoutMs?: number;
|
|
293
|
+
};
|
|
173
294
|
}
|
|
174
295
|
declare class PayboxClient {
|
|
175
296
|
readonly baseUrl: string;
|
|
@@ -180,15 +301,20 @@ declare class PayboxClient {
|
|
|
180
301
|
constructor(options?: PayboxClientOptions);
|
|
181
302
|
/** Build a client from `~/.config/paybox/config.json` + env, with overrides. */
|
|
182
303
|
static fromConfig(overrides?: PayboxClientOptions): PayboxClient;
|
|
183
|
-
|
|
304
|
+
private signingCreds;
|
|
305
|
+
/** Whether in-process signing is available (a parseable `pbxk1.` key is set). */
|
|
184
306
|
get canSign(): boolean;
|
|
185
307
|
private bearer;
|
|
186
308
|
private request;
|
|
187
309
|
private readonly poster;
|
|
188
|
-
/** List
|
|
189
|
-
|
|
310
|
+
/** List granted credentials plus the `ungranted` credentials (id, name, kind,
|
|
311
|
+
* safe metadata) the user owns but hasn't granted this connector. */
|
|
312
|
+
listCredentials(): Promise<ClientCredentialList>;
|
|
190
313
|
/** Token balances across chains (the `get_portfolio` tool). */
|
|
191
314
|
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
|
+
verifySolanaBalance(args: VerifySolanaBalanceArgs$1): Promise<VerifySolanaBalanceResult>;
|
|
192
318
|
/** Charge a card credential (the `request_payment` tool). */
|
|
193
319
|
requestPayment(args: PaymentArgs): Promise<AgentResponse>;
|
|
194
320
|
/** Reveal a secret credential (the `request_secret` tool). */
|
|
@@ -196,16 +322,41 @@ declare class PayboxClient {
|
|
|
196
322
|
/** Sign with a wallet credential (the `request_wallet_sign` tool). Signs
|
|
197
323
|
* in-process and returns the completed request when a signing key is set and
|
|
198
324
|
* the request clears immediately; otherwise returns the pending response.
|
|
199
|
-
* Uses `/agent/wallet-sign`, which echoes the wallet binding
|
|
200
|
-
* need not resolve it
|
|
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. */
|
|
201
328
|
requestWalletSign(args: WalletSignArgs, opts?: SignOptions): Promise<AgentResponse>;
|
|
202
329
|
/** Swap tokens from a wallet credential (the `request_swap` tool). Returns the
|
|
203
|
-
* parked response
|
|
204
|
-
*
|
|
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. */
|
|
205
333
|
requestSwap(args: SwapArgs, opts?: SignOptions): Promise<SwapResult>;
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
|
|
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
|
+
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
|
+
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
|
+
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
|
+
private signWithReconcile;
|
|
355
|
+
/** Discover x402 services with the original array-returning response. */
|
|
356
|
+
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
|
+
discoverServicesPage(query?: string, opts?: DiscoverServicesPageOptions): Promise<DiscoverServicesPage>;
|
|
209
360
|
/** Pay a paid x402 endpoint from a wallet credential (the `pay_x402` tool,
|
|
210
361
|
* header mode). Signs in-process when a signing key is set and the payment
|
|
211
362
|
* clears immediately — then the X-PAYMENT header is on the completed
|
|
@@ -215,12 +366,50 @@ declare class PayboxClient {
|
|
|
215
366
|
* tool, gateway mode): paybox probes the url, pays the 402, re-fetches with the
|
|
216
367
|
* payment, and returns the resource's reply on `output.value.response`. */
|
|
217
368
|
useService(args: UseServiceArgs, opts?: SignOptions): Promise<X402Result>;
|
|
218
|
-
/** Shared completion for the two x402 entry points:
|
|
219
|
-
*
|
|
220
|
-
* request, exactly like the swap path. */
|
|
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. */
|
|
221
372
|
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
|
+
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
|
+
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
|
+
getBuyLink(args: BuyLinkArgs): Promise<BuyLinkResult>;
|
|
384
|
+
/** Browse World prediction markets (the `world_find_markets` tool). */
|
|
385
|
+
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
|
+
worldMarket(eventTicker: string, withNestedMarkets?: boolean): Promise<unknown>;
|
|
390
|
+
/** A World market's orderbook (the `world_orderbook` tool). */
|
|
391
|
+
worldOrderbook(id: string, byMint?: boolean): Promise<unknown>;
|
|
392
|
+
/** A World market's price history (the `world_market_prices` tool). */
|
|
393
|
+
worldPrices(args: WorldPricesArgs): Promise<unknown>;
|
|
394
|
+
/** Filter addresses down to World outcome mints (the
|
|
395
|
+
* `world_filter_outcome_mints` tool). */
|
|
396
|
+
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
|
+
worldPositions(address: string): Promise<unknown>;
|
|
402
|
+
/** Hyperliquid spot markets (the `hyperliquid_markets` tool). */
|
|
403
|
+
hyperliquidMarkets(): Promise<unknown>;
|
|
404
|
+
/** Hyperliquid spot prices (the `hyperliquid_prices` tool). */
|
|
405
|
+
hyperliquidPrices(): Promise<unknown>;
|
|
406
|
+
/** Resolve one Hyperliquid token by name (the `hyperliquid_token` tool). */
|
|
407
|
+
hyperliquidToken(name: string): Promise<unknown>;
|
|
222
408
|
/** Poll a request's status (the `get_request` tool). */
|
|
223
409
|
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
|
+
private requestAfterSign;
|
|
224
413
|
/** Poll until the request leaves a pending state (or the timeout elapses). */
|
|
225
414
|
waitForRequest(requestId: string, opts?: {
|
|
226
415
|
intervalMs?: number;
|
|
@@ -298,5 +487,10 @@ interface GetPortfolioArgs {
|
|
|
298
487
|
address: string;
|
|
299
488
|
network_ids?: string | null;
|
|
300
489
|
}
|
|
490
|
+
interface VerifySolanaBalanceArgs {
|
|
491
|
+
address: string;
|
|
492
|
+
token_mint: string;
|
|
493
|
+
transaction_signature: string;
|
|
494
|
+
}
|
|
301
495
|
|
|
302
|
-
export { type AgentResponse, type BindingResponse, type ClientGrantSummary, type CredentialOutput, type CredentialSummary, 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 SignOptions, type StoredConfig, type SwapArgs, type SwapPlan, type SwapResult, type WalletSignArgs, type WalletSignResult, configFile, credsFromToken, loadConfig, loginLoopback, mcpResource, refreshTokens, saveConfig };
|
|
496
|
+
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
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paybox-sh/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Typed Node SDK + `paybox` CLI for the
|
|
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.
|
|
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
|
}
|