@paybox-sh/sdk 0.5.0 → 0.7.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/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  loginLoopback,
10
10
  openBrowser,
11
11
  saveConfig
12
- } from "./chunk-DIMOTJ2E.js";
12
+ } from "./chunk-EBB4HNOB.js";
13
13
 
14
14
  // src/cli.ts
15
15
  import { spawnSync } from "node:child_process";
@@ -18,7 +18,7 @@ import { createInterface } from "node:readline/promises";
18
18
  import { Command } from "commander";
19
19
  var DEFAULT_BASE_URL = "https://api.paybox.sh";
20
20
  var PKG = "@paybox-sh/sdk";
21
- var VERSION = "0.5.0";
21
+ var VERSION = "0.7.0";
22
22
  var program = new Command();
23
23
  program.name("paybox").description("Paybox agent CLI \u2014 vaulted cards, wallets, and secrets for agents").version(VERSION).option("--base-url <url>", "API origin (default https://api.paybox.sh or stored)").option("--json", "machine-readable JSON output");
24
24
  function jsonMode() {
@@ -72,6 +72,13 @@ async function run(fn) {
72
72
  process.exitCode = 1;
73
73
  }
74
74
  }
75
+ function warnIfUnsignable(c, status) {
76
+ if (status === "pending_signature" && !c.canSign) {
77
+ console.error(
78
+ "awaiting signatures but no signing key is set \u2014 run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`."
79
+ );
80
+ }
81
+ }
75
82
  program.command("login").description("Authenticate via OAuth (browser + passkey), or store a pbx_live_ key").option("--key <key>", "store a pbx_live_ personal API key instead of OAuth").option("--signing-key <token>", "store a pbxk1. wallet signing key (skips the prompt)").option("--app-url <url>", "Paybox app origin for key provisioning (default: derived from --base-url)").option("--no-provision", "skip the wallet signing-key provisioning step").action(
76
83
  (opts) => run(async () => {
77
84
  const cfg = loadConfig();
@@ -165,68 +172,63 @@ program.command("sign").description("Sign with a wallet credential (intent JSON,
165
172
  credentialId: o.credential,
166
173
  intent: readIntent(o.intent)
167
174
  });
168
- if (res.status === "pending_signature" && !c.canSign) {
169
- console.error(
170
- "request is awaiting a signature but no signing key is set \u2014 run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`."
171
- );
172
- }
175
+ warnIfUnsignable(c, res.status);
173
176
  emit(res);
174
177
  })
175
178
  );
176
- program.command("swap").description("Swap tokens from a wallet credential").requiredOption("--credential <id>").requiredOption("--src-chain <caip2>").requiredOption("--src-token <addr>", '"native" or a token address').requiredOption("--dst-token <addr>").requiredOption("--amount <smallest-unit>", "source amount in smallest units").option("--dst-chain <caip2>", "defaults to --src-chain").option("--direction <dir>", "exact-amount-in | exact-amount-out", "exact-amount-in").option("--slippage <bps>", "slippage in bps", "50").option("--recipient <addr>").option("--value-cents <n>").action(
179
+ program.command("swap").description("Swap tokens from a wallet credential").requiredOption("--credential <id>").requiredOption("--src-chain <caip2>").requiredOption("--src-token <addr>", '"native" or a token address').requiredOption("--dst-token <addr>").requiredOption("--amount <smallest-unit>", "source amount in smallest units").option("--dst-chain <caip2>", "defaults to --src-chain").option("--direction <dir>", "exact-amount-in | exact-amount-out", "exact-amount-in").option("--slippage <bps>", "slippage in bps", "50").option("--recipient <addr>").option("--value-cents <n>").option("--wait", "if approval is required, wait for it and then sign in-process").action(
177
180
  (o) => run(async () => {
178
181
  const c = client();
179
- const result = await c.requestSwap({
180
- credentialId: o.credential,
181
- srcChain: o.srcChain,
182
- dstChain: o.dstChain,
183
- srcToken: o.srcToken,
184
- dstToken: o.dstToken,
185
- amount: o.amount,
186
- swapDirection: o.direction,
187
- slippageBps: int("slippage", o.slippage),
188
- recipient: o.recipient,
189
- valueCents: optInt("value-cents", o.valueCents)
190
- });
191
- if (result.response.status === "pending_signature" && !c.canSign) {
192
- console.error(
193
- "swap is awaiting signatures but no signing key is set \u2014 run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`."
194
- );
195
- }
182
+ const result = await c.requestSwap(
183
+ {
184
+ credentialId: o.credential,
185
+ srcChain: o.srcChain,
186
+ dstChain: o.dstChain,
187
+ srcToken: o.srcToken,
188
+ dstToken: o.dstToken,
189
+ amount: o.amount,
190
+ swapDirection: o.direction,
191
+ slippageBps: int("slippage", o.slippage),
192
+ recipient: o.recipient,
193
+ valueCents: optInt("value-cents", o.valueCents)
194
+ },
195
+ { waitForApproval: Boolean(o.wait) }
196
+ );
197
+ warnIfUnsignable(c, result.response.status);
196
198
  emit(result);
197
199
  })
198
200
  );
199
- program.command("discover [query]").description("Discover paid x402 services from the Bazaar catalog (optional ranked search)").action((query) => run(async () => emit(await client().discoverServices(query))));
200
- program.command("pay-x402").description("Pay a paid x402 endpoint (header mode \u2014 returns the X-PAYMENT header to replay)").requiredOption("--credential <id>").requiredOption("--accepts <json>", "the 402's accepts[] array (JSON or @file)").requiredOption("--url <url>", "the paywalled resource URL").action(
201
+ program.command("discover [query]").description("Discover curated paid x402 services from Bazaar (optional search)").option("--raw", "return uncurated compact Bazaar service summaries (debug)").action(
202
+ (query, o) => run(async () => emit(await client().discoverServices(query, { raw: Boolean(o.raw) })))
203
+ );
204
+ program.command("pay-x402").description("Pay a paid x402 endpoint (header mode \u2014 returns the X-PAYMENT header to replay)").requiredOption("--credential <id>").requiredOption("--accepts <json>", "the 402's accepts[] array (JSON or @file)").requiredOption("--url <url>", "the paywalled resource URL").option("--wait", "if approval is required, wait for it and then sign in-process").action(
201
205
  (o) => run(async () => {
202
206
  const c = client();
203
- const result = await c.payX402({
204
- credentialId: o.credential,
205
- accepts: readIntent(o.accepts),
206
- resourceUrl: o.url
207
- });
208
- if (result.response.status === "pending_signature" && !c.canSign) {
209
- console.error(
210
- "payment is awaiting a signature but no signing key is set \u2014 run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`."
211
- );
212
- }
207
+ const result = await c.payX402(
208
+ {
209
+ credentialId: o.credential,
210
+ accepts: readIntent(o.accepts),
211
+ resourceUrl: o.url
212
+ },
213
+ { waitForApproval: Boolean(o.wait) }
214
+ );
215
+ warnIfUnsignable(c, result.response.status);
213
216
  emit(result);
214
217
  })
215
218
  );
216
- program.command("use-service").description("Fetch a paid x402 resource and have paybox pay for it (gateway mode)").requiredOption("--credential <id>").requiredOption("--url <url>", "the paid x402 resource URL").option("--method <verb>", "HTTP method", "GET").option("--body <json>", "request body (JSON or @file)").action(
219
+ program.command("use-service").description("Fetch a paid x402 resource and have paybox pay for it (gateway mode)").requiredOption("--credential <id>").requiredOption("--url <url>", "the paid x402 resource URL").option("--method <verb>", "HTTP method", "GET").option("--body <json>", "request body (JSON or @file)").option("--wait", "if approval is required, wait for it and then sign in-process").action(
217
220
  (o) => run(async () => {
218
221
  const c = client();
219
- const result = await c.useService({
220
- credentialId: o.credential,
221
- url: o.url,
222
- method: o.method,
223
- body: o.body === void 0 ? void 0 : readIntent(o.body)
224
- });
225
- if (result.response.status === "pending_signature" && !c.canSign) {
226
- console.error(
227
- "payment is awaiting a signature but no signing key is set \u2014 run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`."
228
- );
229
- }
222
+ const result = await c.useService(
223
+ {
224
+ credentialId: o.credential,
225
+ url: o.url,
226
+ method: o.method,
227
+ body: o.body === void 0 ? void 0 : readIntent(o.body)
228
+ },
229
+ { waitForApproval: Boolean(o.wait) }
230
+ );
231
+ warnIfUnsignable(c, result.response.status);
230
232
  emit(result);
231
233
  })
232
234
  );
@@ -235,6 +237,85 @@ program.command("portfolio").description("List a wallet address's token balances
235
237
  async () => emit(await client().getPortfolio({ address: o.address, networkIds: o.networks }))
236
238
  )
237
239
  );
240
+ program.command("claim <request-id>").description("Claim the usable card credentials of an approved payment (one-time)").action((id) => run(async () => emit(await client().claimPaymentCredentials(id))));
241
+ program.command("account-change").description("Get a manage_url for the USER to update this client's access in the app").option("--note <text>", "why the change is needed (shown to the user)").action((o) => run(async () => emit(await client().requestAccountChange(o.note))));
242
+ program.command("buy-link").description("Signed MoonPay checkout URL funding a granted wallet (charges nothing)").requiredOption("--credential <id>", "a granted wallet credential").option("--currency <code>", "MoonPay currency code (default USDC on the wallet's chain)").option("--amount-usd <n>", "prefill amount in USD").action(
243
+ (o) => run(
244
+ async () => emit(
245
+ await client().getBuyLink({
246
+ credentialId: o.credential,
247
+ currencyCode: o.currency,
248
+ amountUsd: o.amountUsd === void 0 ? void 0 : Number(o.amountUsd)
249
+ })
250
+ )
251
+ )
252
+ );
253
+ var world = program.command("world").description("World prediction markets (requires the world plugin)");
254
+ world.command("markets").description("Browse markets (or events with --events)").option("--events", "list events (each groups its markets)").option("--limit <n>").option("--cursor <n>", "rows to skip; the response carries the next cursor").option("--event-ticker <ticker>").option("--series-ticker <ticker>").option("--status <status>", "active | initialized | determined | finalized").action(
255
+ (o) => run(
256
+ async () => emit(
257
+ await client().worldMarkets({
258
+ events: Boolean(o.events),
259
+ limit: optInt("limit", o.limit),
260
+ cursor: optInt("cursor", o.cursor),
261
+ eventTicker: o.eventTicker,
262
+ seriesTicker: o.seriesTicker,
263
+ status: o.status
264
+ })
265
+ )
266
+ )
267
+ );
268
+ world.command("market <event-ticker>").description("One event with its nested markets (disable with --no-nested)").option("--no-nested", "exclude the event's markets").action(
269
+ (ticker, o) => run(async () => emit(await client().worldMarket(ticker, Boolean(o.nested))))
270
+ );
271
+ world.command("orderbook <id>").description("A market's orderbook (id is a ticker, or a mint with --by-mint)").option("--by-mint", "look up by outcome mint instead of ticker").action(
272
+ (id, o) => run(async () => emit(await client().worldOrderbook(id, Boolean(o.byMint))))
273
+ );
274
+ world.command("prices <ticker>").description("A market's price history").requiredOption("--start <unix-ts>").requiredOption("--end <unix-ts>").option("--resolution <n>").action(
275
+ (ticker, o) => run(
276
+ async () => emit(
277
+ await client().worldPrices({
278
+ ticker,
279
+ startTs: int("start", o.start),
280
+ endTs: int("end", o.end),
281
+ resolution: optInt("resolution", o.resolution)
282
+ })
283
+ )
284
+ )
285
+ );
286
+ world.command("filter-mints <addresses...>").description("Filter addresses down to World outcome mints").action(
287
+ (addresses) => run(async () => emit(await client().worldFilterOutcomeMints(addresses)))
288
+ );
289
+ world.command("positions <address>").description("Solana token positions for an address").action((address) => run(async () => emit(await client().worldPositions(address))));
290
+ function worldTradeCommand(name, side, desc) {
291
+ const cmd = world.command(name).description(desc).requiredOption("--credential <id>", "a granted wallet credential (Solana)").requiredOption("--mint <addr>", "the outcome mint").requiredOption("--size <n>").option("--value-cents <n>").option("--wait", "wait for the user's approval, then sign in-process");
292
+ if (side !== "redeem") cmd.option("--slippage <bps>", "slippage in bps", "50");
293
+ cmd.action(
294
+ (o) => run(async () => {
295
+ const c = client();
296
+ const result = await c.worldTrade(
297
+ {
298
+ credentialId: o.credential,
299
+ marketMint: o.mint,
300
+ side,
301
+ size: o.size,
302
+ slippageBps: optInt("slippage", o.slippage),
303
+ valueCents: optInt("value-cents", o.valueCents)
304
+ },
305
+ { waitForApproval: Boolean(o.wait) }
306
+ );
307
+ warnIfUnsignable(c, result.response.status);
308
+ emit(result);
309
+ })
310
+ );
311
+ }
312
+ worldTradeCommand("buy", "buy", "Buy an outcome (force-approved; approve in the app)");
313
+ worldTradeCommand("sell", "sell", "Sell an outcome position (force-approved)");
314
+ worldTradeCommand("redeem", "redeem", "Redeem a settled position (force-approved)");
315
+ var hyperliquid = program.command("hyperliquid").description("Hyperliquid spot discovery (requires the hyperliquid plugin)");
316
+ hyperliquid.command("markets").description("Spot markets").action(() => run(async () => emit(await client().hyperliquidMarkets())));
317
+ hyperliquid.command("prices").description("Spot prices").action(() => run(async () => emit(await client().hyperliquidPrices())));
318
+ hyperliquid.command("token <name>").description("Resolve one token by name").action((name) => run(async () => emit(await client().hyperliquidToken(name))));
238
319
  program.command("request <id>").description("Poll a request's status").option("--wait", "block until it leaves the pending state").action(
239
320
  (id, o) => run(async () => {
240
321
  const c = client();
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,SAAS,SAAuB;AAC9B,SAAO,aAAa,WAAW,EAAE,SAAS,QAAQ,KAAK,EAAE,QAAQ,CAAC;AACpE;AAEA,SAAS,WAAW,OAAwB;AAC1C,QAAM,MAAM,MAAM,WAAW,GAAG,IAAI,aAAa,MAAM,MAAM,CAAC,GAAG,MAAM,IAAI;AAC3E,SAAO,KAAK,MAAM,GAAG;AACvB;AAEA,SAAS,IAAI,MAAc,OAAuB;AAChD,QAAM,IAAI,OAAO,KAAK;AACtB,MAAI,CAAC,OAAO,UAAU,CAAC,GAAG;AACxB,UAAM,IAAI,MAAM,KAAK,IAAI,4BAA4B,KAAK,UAAU,KAAK,CAAC,EAAE;AAAA,EAC9E;AACA,SAAO;AACT;AAEA,SAAS,OAAO,MAAc,OAA+C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AE,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, loginLoopback, openBrowser } from \"./auth.js\";\nimport { PayboxClient } from \"./client.js\";\nimport { configDir, configFile, loadConfig, saveConfig } from \"./config.js\";\n\nconst DEFAULT_BASE_URL = \"https://api.paybox.sh\";\nconst PKG = \"@paybox-sh/sdk\";\nconst VERSION = \"0.7.0\";\n\nconst program = new Command();\nprogram\n .name(\"paybox\")\n .description(\"Paybox agent CLI — vaulted cards, wallets, and secrets for agents\")\n .version(VERSION)\n .option(\"--base-url <url>\", \"API origin (default https://api.paybox.sh or stored)\")\n .option(\"--json\", \"machine-readable JSON output\");\n\nfunction jsonMode(): boolean {\n return Boolean(program.opts().json);\n}\n\nfunction emit(data: unknown): void {\n if (jsonMode()) console.log(JSON.stringify(data, null, 2));\n else console.dir(data, { depth: null, colors: process.stdout.isTTY });\n}\n\nfunction client(): PayboxClient {\n return PayboxClient.fromConfig({ baseUrl: program.opts().baseUrl });\n}\n\nfunction readIntent(value: string): unknown {\n const raw = value.startsWith(\"@\") ? readFileSync(value.slice(1), \"utf8\") : value;\n return JSON.parse(raw);\n}\n\nfunction int(flag: string, value: string): number {\n const n = Number(value);\n if (!Number.isInteger(n)) {\n throw new Error(`--${flag} must be an integer, got ${JSON.stringify(value)}`);\n }\n return n;\n}\n\nfunction optInt(flag: string, value: string | undefined): number | undefined {\n return value === undefined ? undefined : int(flag, value);\n}\n\n/** True when semver `a` is strictly greater than `b` (plain x.y.z). */\nfunction isNewer(a: string, b: string): boolean {\n const pa = a.split(\".\").map(Number);\n const pb = b.split(\".\").map(Number);\n for (let i = 0; i < 3; i++) {\n const x = pa[i] ?? 0;\n const y = pb[i] ?? 0;\n if (x !== y) return x > y;\n }\n return false;\n}\n\nasync function prompt(question: string): Promise<string> {\n if (!process.stdin.isTTY) return \"\"; // non-interactive: skip\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n try {\n return (await rl.question(question)).trim();\n } finally {\n rl.close();\n }\n}\n\nasync function run(fn: () => Promise<void>): Promise<void> {\n try {\n await fn();\n } catch (err) {\n console.error(err instanceof Error ? err.message : String(err));\n process.exitCode = 1;\n }\n}\n\n/** A request parked at `pending_signature` can only complete in-process with a\n * `pbxk1.` key (there is no signing window on this surface). */\nfunction warnIfUnsignable(c: PayboxClient, status: string): void {\n if (status === \"pending_signature\" && !c.canSign) {\n console.error(\n \"awaiting signatures but no signing key is set — \" +\n \"run `paybox login --signing-key <pbxk1...>` or set PAYBOX_SIGNING_KEY, then poll `paybox request <id>`.\",\n );\n }\n}\n\nprogram\n .command(\"login\")\n .description(\"Authenticate via OAuth (browser + passkey), or store a pbx_live_ key\")\n .option(\"--key <key>\", \"store a pbx_live_ personal API key instead of OAuth\")\n .option(\"--signing-key <token>\", \"store a pbxk1. wallet signing key (skips the prompt)\")\n .option(\"--app-url <url>\", \"Paybox app origin for key provisioning (default: derived from --base-url)\")\n .option(\"--no-provision\", \"skip the wallet signing-key provisioning step\")\n .action((opts) =>\n run(async () => {\n const cfg = loadConfig();\n const baseUrl = (\n program.opts().baseUrl ??\n process.env.PAYBOX_API_URL ??\n cfg.baseUrl ??\n DEFAULT_BASE_URL\n ).replace(/\\/+$/, \"\");\n cfg.baseUrl = baseUrl;\n if (opts.appUrl) cfg.appUrl = opts.appUrl;\n\n // Step 1 — authenticate.\n if (opts.key) {\n cfg.apiKey = opts.key;\n delete cfg.oauth;\n } else {\n cfg.oauth = await loginLoopback(baseUrl);\n delete cfg.apiKey;\n }\n if (opts.signingKey) cfg.signingKey = opts.signingKey;\n saveConfig(cfg);\n console.error(`Saved credentials to ${configFile()}`);\n\n // Step 2 — provision a wallet signing key. Runs only after OAuth (the app\n // session is warm) and only when one wasn't supplied or disabled. The app\n // mints a key scoped to this agent and shows a `pbxk1.` token to paste back.\n if (!cfg.oauth || opts.signingKey || opts.provision === false) return;\n const cid = agentClientId(cfg.oauth.accessToken);\n const appBase = appBaseFrom(baseUrl, opts.appUrl ?? process.env.PAYBOX_APP_URL ?? cfg.appUrl);\n if (!cid || !appBase) {\n console.error(\n \"To enable wallet sign/swap, provision a signing key and run\\n\" +\n \" paybox login --signing-key <pbxk1...>\" +\n (cid && !appBase ? \" (or pass --app-url <paybox app origin>)\" : \"\"),\n );\n return;\n }\n const url = `${appBase}/agent-key?client_id=${cid}`;\n console.error(\n `\\nNext, provision a wallet signing key for this agent (needed for sign/swap):\\n ${url}\\n`,\n );\n openBrowser(url);\n const key = await prompt(\"Paste the pbxk1. signing key when ready (or Enter to skip): \");\n if (key) {\n cfg.signingKey = key;\n saveConfig(cfg);\n console.error(\"Signing key saved — sign/swap enabled.\");\n } else {\n console.error(\"Skipped — add it later with `paybox login --signing-key <pbxk1...>`.\");\n }\n }),\n );\n\nprogram\n .command(\"logout\")\n .description(\"Forget stored credentials\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n delete cfg.apiKey;\n delete cfg.oauth;\n delete cfg.signingKey;\n saveConfig(cfg);\n console.error(\"Logged out.\");\n }),\n );\n\nprogram\n .command(\"whoami\")\n .description(\"Show the configured endpoint, auth mode, and signing capability\")\n .action(() =>\n run(async () => {\n const cfg = loadConfig();\n const c = client();\n const mode = process.env.PAYBOX_ACCESS_TOKEN\n ? \"oauth (env token)\"\n : process.env.PAYBOX_API_KEY || cfg.apiKey\n ? \"api key\"\n : cfg.oauth\n ? \"oauth\"\n : \"none\";\n emit({ baseUrl: c.baseUrl, auth: mode, canSign: c.canSign, configFile: configFile() });\n }),\n );\n\nprogram\n .command(\"credentials\")\n .description(\"List the credentials this client may use\")\n .action(() => run(async () => emit(await client().listCredentials())));\n\nprogram\n .command(\"pay\")\n .description(\"Charge a card credential\")\n .requiredOption(\"--credential <id>\")\n .requiredOption(\"--merchant <name>\")\n .requiredOption(\"--url <url>\", \"real merchant URL the card is bound to\")\n .requiredOption(\"--amount <cents>\", \"amount in cents\")\n .option(\"--currency <code>\", \"ISO 4217 currency\", \"USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestPayment({\n credentialId: o.credential,\n merchant: o.merchant,\n merchantUrl: o.url,\n amountCents: int(\"amount\", o.amount),\n currency: o.currency,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"secret\")\n .description(\"Reveal a secret credential (one-time token, or --raw value)\")\n .requiredOption(\"--credential <id>\")\n .option(\"--raw\", \"return the raw secret value (grant-gated)\")\n .option(\"--purpose <text>\", \"why the secret is requested (shown on approval)\")\n .action((o) =>\n run(async () =>\n emit(\n await client().requestSecret({\n credentialId: o.credential,\n raw: Boolean(o.raw),\n purpose: o.purpose,\n }),\n ),\n ),\n );\n\nprogram\n .command(\"sign\")\n .description(\"Sign with a wallet credential (intent JSON, or @file)\")\n .requiredOption(\"--credential <id>\")\n .requiredOption(\"--intent <json>\", 'a SignIntent, e.g. \\'{\"op\":\"message\",\"message\":\"hi\"}\\' or @intent.json')\n .action((o) =>\n run(async () => {\n const c = client();\n const res = await c.requestWalletSign({\n credentialId: o.credential,\n intent: readIntent(o.intent) as never,\n });\n warnIfUnsignable(c, res.status);\n emit(res);\n }),\n );\n\nprogram\n .command(\"swap\")\n .description(\"Swap tokens from a wallet credential\")\n .requiredOption(\"--credential <id>\")\n .requiredOption(\"--src-chain <caip2>\")\n .requiredOption(\"--src-token <addr>\", '\"native\" or a token address')\n .requiredOption(\"--dst-token <addr>\")\n .requiredOption(\"--amount <smallest-unit>\", \"source amount in smallest units\")\n .option(\"--dst-chain <caip2>\", \"defaults to --src-chain\")\n .option(\"--direction <dir>\", \"exact-amount-in | exact-amount-out\", \"exact-amount-in\")\n .option(\"--slippage <bps>\", \"slippage in bps\", \"50\")\n .option(\"--recipient <addr>\")\n .option(\"--value-cents <n>\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.requestSwap(\n {\n credentialId: o.credential,\n srcChain: o.srcChain,\n dstChain: o.dstChain,\n srcToken: o.srcToken,\n dstToken: o.dstToken,\n amount: o.amount,\n swapDirection: o.direction,\n slippageBps: int(\"slippage\", o.slippage),\n recipient: o.recipient,\n valueCents: optInt(\"value-cents\", o.valueCents),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"discover [query]\")\n .description(\"Discover curated paid x402 services from Bazaar (optional search)\")\n .option(\"--raw\", \"return uncurated compact Bazaar service summaries (debug)\")\n .action((query, o) =>\n run(async () => emit(await client().discoverServices(query, { raw: Boolean(o.raw) }))),\n );\n\nprogram\n .command(\"pay-x402\")\n .description(\"Pay a paid x402 endpoint (header mode — returns the X-PAYMENT header to replay)\")\n .requiredOption(\"--credential <id>\")\n .requiredOption(\"--accepts <json>\", \"the 402's accepts[] array (JSON or @file)\")\n .requiredOption(\"--url <url>\", \"the paywalled resource URL\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.payX402(\n {\n credentialId: o.credential,\n accepts: readIntent(o.accepts) as unknown[],\n resourceUrl: o.url,\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"use-service\")\n .description(\"Fetch a paid x402 resource and have paybox pay for it (gateway mode)\")\n .requiredOption(\"--credential <id>\")\n .requiredOption(\"--url <url>\", \"the paid x402 resource URL\")\n .option(\"--method <verb>\", \"HTTP method\", \"GET\")\n .option(\"--body <json>\", \"request body (JSON or @file)\")\n .option(\"--wait\", \"if approval is required, wait for it and then sign in-process\")\n .action((o) =>\n run(async () => {\n const c = client();\n const result = await c.useService(\n {\n credentialId: o.credential,\n url: o.url,\n method: o.method,\n body: o.body === undefined ? undefined : readIntent(o.body),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n\nprogram\n .command(\"portfolio\")\n .description(\"List a wallet address's token balances across chains\")\n .requiredOption(\"--address <addr>\")\n .option(\"--networks <ids>\", 'comma-separated network IDs, e.g. \"1,8453\"')\n .action((o) =>\n run(async () =>\n emit(await client().getPortfolio({ address: o.address, networkIds: o.networks })),\n ),\n );\n\nprogram\n .command(\"claim <request-id>\")\n .description(\"Claim the usable card credentials of an approved payment (one-time)\")\n .action((id) => run(async () => emit(await client().claimPaymentCredentials(id))));\n\nprogram\n .command(\"account-change\")\n .description(\"Get a manage_url for the USER to update this client's access in the app\")\n .option(\"--note <text>\", \"why the change is needed (shown to the user)\")\n .action((o) => run(async () => emit(await client().requestAccountChange(o.note))));\n\nprogram\n .command(\"buy-link\")\n .description(\"Signed MoonPay checkout URL funding a granted wallet (charges nothing)\")\n .requiredOption(\"--credential <id>\", \"a granted wallet credential\")\n .option(\"--currency <code>\", \"MoonPay currency code (default USDC on the wallet's chain)\")\n .option(\"--amount-usd <n>\", \"prefill amount in USD\")\n .action((o) =>\n run(async () =>\n emit(\n await client().getBuyLink({\n credentialId: o.credential,\n currencyCode: o.currency,\n amountUsd: o.amountUsd === undefined ? undefined : Number(o.amountUsd),\n }),\n ),\n ),\n );\n\n// ---- World plugin (prediction markets). Requires the `world` plugin enabled in\n// the paybox app. Trades are force-approved; --wait waits for the approval and\n// then signs in-process (no signing window on this surface). ----\nconst world = program\n .command(\"world\")\n .description(\"World prediction markets (requires the world plugin)\");\n\nworld\n .command(\"markets\")\n .description(\"Browse markets (or events with --events)\")\n .option(\"--events\", \"list events (each groups its markets)\")\n .option(\"--limit <n>\")\n .option(\"--cursor <n>\", \"rows to skip; the response carries the next cursor\")\n .option(\"--event-ticker <ticker>\")\n .option(\"--series-ticker <ticker>\")\n .option(\"--status <status>\", \"active | initialized | determined | finalized\")\n .action((o) =>\n run(async () =>\n emit(\n await client().worldMarkets({\n events: Boolean(o.events),\n limit: optInt(\"limit\", o.limit),\n cursor: optInt(\"cursor\", o.cursor),\n eventTicker: o.eventTicker,\n seriesTicker: o.seriesTicker,\n status: o.status,\n }),\n ),\n ),\n );\n\nworld\n .command(\"market <event-ticker>\")\n .description(\"One event with its nested markets (disable with --no-nested)\")\n .option(\"--no-nested\", \"exclude the event's markets\")\n .action((ticker, o) =>\n run(async () => emit(await client().worldMarket(ticker, Boolean(o.nested)))),\n );\n\nworld\n .command(\"orderbook <id>\")\n .description(\"A market's orderbook (id is a ticker, or a mint with --by-mint)\")\n .option(\"--by-mint\", \"look up by outcome mint instead of ticker\")\n .action((id, o) =>\n run(async () => emit(await client().worldOrderbook(id, Boolean(o.byMint)))),\n );\n\nworld\n .command(\"prices <ticker>\")\n .description(\"A market's price history\")\n .requiredOption(\"--start <unix-ts>\")\n .requiredOption(\"--end <unix-ts>\")\n .option(\"--resolution <n>\")\n .action((ticker, o) =>\n run(async () =>\n emit(\n await client().worldPrices({\n ticker,\n startTs: int(\"start\", o.start),\n endTs: int(\"end\", o.end),\n resolution: optInt(\"resolution\", o.resolution),\n }),\n ),\n ),\n );\n\nworld\n .command(\"filter-mints <addresses...>\")\n .description(\"Filter addresses down to World outcome mints\")\n .action((addresses) =>\n run(async () => emit(await client().worldFilterOutcomeMints(addresses))),\n );\n\nworld\n .command(\"positions <address>\")\n .description(\"Solana token positions for an address\")\n .action((address) => run(async () => emit(await client().worldPositions(address))));\n\nfunction worldTradeCommand(name: string, side: \"buy\" | \"sell\" | \"redeem\", desc: string) {\n const cmd = world\n .command(name)\n .description(desc)\n .requiredOption(\"--credential <id>\", \"a granted wallet credential (Solana)\")\n .requiredOption(\"--mint <addr>\", \"the outcome mint\")\n .requiredOption(\"--size <n>\")\n .option(\"--value-cents <n>\")\n .option(\"--wait\", \"wait for the user's approval, then sign in-process\");\n if (side !== \"redeem\") cmd.option(\"--slippage <bps>\", \"slippage in bps\", \"50\");\n cmd.action((o) =>\n run(async () => {\n const c = client();\n const result = await c.worldTrade(\n {\n credentialId: o.credential,\n marketMint: o.mint,\n side,\n size: o.size,\n slippageBps: optInt(\"slippage\", o.slippage),\n valueCents: optInt(\"value-cents\", o.valueCents),\n },\n { waitForApproval: Boolean(o.wait) },\n );\n warnIfUnsignable(c, result.response.status);\n emit(result);\n }),\n );\n}\nworldTradeCommand(\"buy\", \"buy\", \"Buy an outcome (force-approved; approve in the app)\");\nworldTradeCommand(\"sell\", \"sell\", \"Sell an outcome position (force-approved)\");\nworldTradeCommand(\"redeem\", \"redeem\", \"Redeem a settled position (force-approved)\");\n\n// ---- Hyperliquid plugin (read-only spot discovery). Requires the\n// `hyperliquid` plugin enabled in the paybox app. ----\nconst hyperliquid = program\n .command(\"hyperliquid\")\n .description(\"Hyperliquid spot discovery (requires the hyperliquid plugin)\");\n\nhyperliquid\n .command(\"markets\")\n .description(\"Spot markets\")\n .action(() => run(async () => emit(await client().hyperliquidMarkets())));\n\nhyperliquid\n .command(\"prices\")\n .description(\"Spot prices\")\n .action(() => run(async () => emit(await client().hyperliquidPrices())));\n\nhyperliquid\n .command(\"token <name>\")\n .description(\"Resolve one token by name\")\n .action((name) => run(async () => emit(await client().hyperliquidToken(name))));\n\nprogram\n .command(\"request <id>\")\n .description(\"Poll a request's status\")\n .option(\"--wait\", \"block until it leaves the pending state\")\n .action((id, o) =>\n run(async () => {\n const c = client();\n emit(o.wait ? await c.waitForRequest(id) : await c.getRequest(id));\n }),\n );\n\nprogram\n .command(\"version\")\n .description(\"Show the installed CLI version (and whether an update is available)\")\n .action(() =>\n run(async () => {\n let latest: string | undefined;\n try {\n const res = await fetch(`https://registry.npmjs.org/${PKG}/latest`);\n if (res.ok) latest = ((await res.json()) as { version?: string }).version;\n } catch {\n /* offline — just report the installed version */\n }\n const updateAvailable = Boolean(latest && isNewer(latest, VERSION));\n if (jsonMode()) {\n emit({ version: VERSION, latest: latest ?? null, updateAvailable });\n return;\n }\n console.log(`${PKG} v${VERSION}`);\n if (updateAvailable) {\n console.log(`Update available: v${latest} — run \\`paybox update\\`.`);\n }\n }),\n );\n\nprogram\n .command(\"update\")\n .description(\"Update the globally-installed paybox CLI to the latest version\")\n .option(\"--print\", \"print the update command instead of running it\")\n .action((opts) =>\n run(async () => {\n const args = [\"install\", \"-g\", `${PKG}@latest`];\n if (opts.print) {\n console.log(`npm ${args.join(\" \")}`);\n return;\n }\n console.error(`Updating ${PKG} (npm ${args.join(\" \")})…`);\n const r = spawnSync(\"npm\", args, { stdio: \"inherit\" });\n if (r.status !== 0) {\n console.error(\n `\\nIf this isn't a global install: run \\`pnpm up ${PKG}\\` in your project, ` +\n `or use \\`npx ${PKG}@latest …\\` to always run the latest.`,\n );\n process.exitCode = r.status ?? 1;\n }\n }),\n );\n\nprogram\n .command(\"uninstall\")\n .description(\"Remove stored Paybox credentials/config (and show how to remove the CLI)\")\n .action(() =>\n run(async () => {\n const dir = configDir();\n rmSync(dir, { recursive: true, force: true });\n console.error(`Removed stored config at ${dir}.`);\n console.error(\n `The CLI binary is managed by npm — remove it with:\\n npm rm -g ${PKG}`,\n );\n }),\n );\n\nprogram.parseAsync(process.argv);\n"],"mappings":";;;;;;;;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G,oCACpC,GAAG;AAAA,MACvB;AACA,cAAQ,WAAW,EAAE,UAAU;AAAA,IACjC;AAAA,EACF,CAAC;AACH;AAEF,QACG,QAAQ,WAAW,EACnB,YAAY,0EAA0E,EACtF;AAAA,EAAO,MACN,IAAI,YAAY;AACd,UAAM,MAAM,UAAU;AACtB,WAAO,KAAK,EAAE,WAAW,MAAM,OAAO,KAAK,CAAC;AAC5C,YAAQ,MAAM,4BAA4B,GAAG,GAAG;AAChD,YAAQ;AAAA,MACN;AAAA,cAAmE,GAAG;AAAA,IACxE;AAAA,EACF,CAAC;AACH;AAEF,QAAQ,WAAW,QAAQ,IAAI;","names":[]}
package/dist/index.d.ts CHANGED
@@ -38,7 +38,11 @@ interface PortfolioArgs {
38
38
  /** Comma-separated network IDs, e.g. "1,8453". Omit to auto-detect. */
39
39
  networkIds?: string;
40
40
  }
41
- type RequestStatus = "pending_approval" | "pending_signature" | "success" | "denied" | "error";
41
+ interface DiscoverServicesOptions {
42
+ /** Debug escape hatch: return uncurated compact Bazaar service summaries. */
43
+ raw?: boolean;
44
+ }
45
+ type RequestStatus = "pending_approval" | "pending_signature" | "pending_settlement" | "pending_confirmation" | "success" | "denied" | "error";
42
46
  type OutputType = "payment_token" | "signature" | "tx_hash" | "secret_token" | "raw_secret";
43
47
  interface CredentialOutput {
44
48
  output_id: string;
@@ -110,7 +114,7 @@ interface WalletSignResult {
110
114
  interface X402Args {
111
115
  credentialId: string;
112
116
  /** The 402's `accepts` PaymentRequirements array, verbatim (from the resource's
113
- * own 402 — discover_services gives you the catalog entry to start from). */
117
+ * own 402 — discover_services gives you a curated catalog entry to start from). */
114
118
  accepts: unknown[];
115
119
  /** The paywalled resource URL. */
116
120
  resourceUrl: string;
@@ -143,13 +147,66 @@ interface X402Result {
143
147
  response: AgentResponse;
144
148
  plan: X402Plan;
145
149
  }
146
- /** One discovered x402 service (the `discover_services` tool / `/agent/services`):
150
+ /** One curated x402 service (the `discover_services` tool / `/agent/services`):
147
151
  * where it lives, a human description, and its `accepts` PaymentRequirements. */
148
152
  interface ServiceSummary {
149
153
  resource: string;
150
154
  description: string | null;
151
155
  accepts: unknown;
152
156
  }
157
+ /** `POST /agent/account-change` (the `request_account_change` tool): a pure
158
+ * launcher. Surface `manage_url` to the user — they edit this client's access
159
+ * in their own app session (passkey-gated); nothing is parked server-side. */
160
+ interface AccountChangeResult {
161
+ kind: "account_change";
162
+ client_id: string;
163
+ manage_url: string;
164
+ note?: string | null;
165
+ }
166
+ interface BuyLinkArgs {
167
+ /** A granted wallet credential to fund. */
168
+ credentialId: string;
169
+ /** MoonPay currency code (defaults to USDC on the wallet's chain). */
170
+ currencyCode?: string;
171
+ /** Prefill amount in USD. */
172
+ amountUsd?: number;
173
+ }
174
+ /** `GET /agent/buy-link` (the `get_buy_link` tool): a signed MoonPay checkout
175
+ * URL funding the wallet. Generating the link charges nothing. */
176
+ interface BuyLinkResult {
177
+ url: string;
178
+ currency_code: string;
179
+ wallet_address: string;
180
+ }
181
+ interface WorldMarketsArgs {
182
+ /** Return the events list (each event groups its markets) instead of markets. */
183
+ events?: boolean;
184
+ limit?: number;
185
+ /** Rows to skip; the response carries the next cursor. */
186
+ cursor?: number;
187
+ eventTicker?: string;
188
+ seriesTicker?: string;
189
+ /** One of active | initialized | determined | finalized. */
190
+ status?: string;
191
+ }
192
+ interface WorldPricesArgs {
193
+ ticker: string;
194
+ startTs: number;
195
+ endTs: number;
196
+ resolution?: number;
197
+ }
198
+ interface WorldTradeArgs {
199
+ /** A granted wallet credential (Solana). */
200
+ credentialId: string;
201
+ /** The outcome mint to trade. */
202
+ marketMint: string;
203
+ /** "buy" | "sell" trade at market; "redeem" pays out a settled position. */
204
+ side: "buy" | "sell" | "redeem";
205
+ size: string;
206
+ /** Ignored for redeem (no price slippage at settlement). Default 50. */
207
+ slippageBps?: number;
208
+ valueCents?: number;
209
+ }
153
210
 
154
211
  declare class PayboxError extends Error {
155
212
  readonly status: number;
@@ -170,6 +227,14 @@ interface PayboxClientOptions {
170
227
  interface SignOptions {
171
228
  /** Sign in-process when the request clears to `pending_signature`. Default true. */
172
229
  autoSign?: boolean;
230
+ /** When the request parks as `pending_approval` (approval-mode grant, or a
231
+ * force-approved op like a World trade), wait for the user's passkey approval
232
+ * and then sign in-process — the SDK's headless equivalent of the signing
233
+ * window's post-approval sign. Default false (return the pending response). */
234
+ waitForApproval?: boolean | {
235
+ intervalMs?: number;
236
+ timeoutMs?: number;
237
+ };
173
238
  }
174
239
  declare class PayboxClient {
175
240
  readonly baseUrl: string;
@@ -203,9 +268,20 @@ declare class PayboxClient {
203
268
  * parked response + sign-ready plan; signs + submits in-process when a signing
204
269
  * key is set and the swap cleared immediately. */
205
270
  requestSwap(args: SwapArgs, opts?: SignOptions): Promise<SwapResult>;
206
- /** Discover paid x402 services from the Bazaar catalog (the `discover_services`
207
- * tool). Pass a query for a ranked search; omit it for the catalog listing. */
208
- discoverServices(query?: string): Promise<ServiceSummary[]>;
271
+ /** Shared completion for swap-shaped requests (`request_swap` and the World
272
+ * trade): optionally wait out a `pending_approval` dwell, then sign the plan
273
+ * in-process and submit envelopes. Signing re-pins a Solana plan's blockhash
274
+ * (and re-quotes a stale World order) via `/agent/requests/{id}/refresh`
275
+ * first, so a long approval dwell never signs stale bytes. */
276
+ private completeSwap;
277
+ /** Poll while the request sits in `pending_approval` (the user is approving
278
+ * with their passkey); returns the first non-approval state. */
279
+ private waitWhileApproval;
280
+ /** Discover curated paid x402 services from the Bazaar catalog (the
281
+ * `discover_services` tool). Pass a query to search the curated set; omit it
282
+ * for the curated listing. Set `raw` only to inspect uncurated compact
283
+ * Bazaar service summaries. */
284
+ discoverServices(query?: string, opts?: DiscoverServicesOptions): Promise<ServiceSummary[]>;
209
285
  /** Pay a paid x402 endpoint from a wallet credential (the `pay_x402` tool,
210
286
  * header mode). Signs in-process when a signing key is set and the payment
211
287
  * clears immediately — then the X-PAYMENT header is on the completed
@@ -215,10 +291,48 @@ declare class PayboxClient {
215
291
  * tool, gateway mode): paybox probes the url, pays the 402, re-fetches with the
216
292
  * payment, and returns the resource's reply on `output.value.response`. */
217
293
  useService(args: UseServiceArgs, opts?: SignOptions): Promise<X402Result>;
218
- /** Shared completion for the two x402 entry points: sign the parked typed data
219
- * in-process (when a key is set + the request cleared) and return the finished
220
- * request, exactly like the swap path. */
294
+ /** Shared completion for the two x402 entry points: optionally wait out a
295
+ * `pending_approval` dwell, then sign the parked typed data in-process and
296
+ * return the finished request, exactly like the swap path. */
221
297
  private completeX402;
298
+ /** Claim the usable card credentials of an approved payment (the
299
+ * `claim_payment_credentials` tool). One-time: the claim is consumed. */
300
+ claimPaymentCredentials(requestId: string): Promise<Record<string, unknown>>;
301
+ /** Open the account-change flow (the `request_account_change` tool): returns a
302
+ * `manage_url` deep link for the USER to open — they update this client's
303
+ * access (or add a credential) in their own passkey-gated app session.
304
+ * Nothing is parked or applied server-side. */
305
+ requestAccountChange(note?: string): Promise<AccountChangeResult>;
306
+ /** A signed MoonPay checkout URL funding a granted wallet (the `get_buy_link`
307
+ * tool). Share the URL with the user; generating it charges nothing. */
308
+ getBuyLink(args: BuyLinkArgs): Promise<BuyLinkResult>;
309
+ /** Browse World prediction markets (the `world_find_markets` tool). */
310
+ worldMarkets(args?: WorldMarketsArgs): Promise<unknown>;
311
+ /** One World event with its markets (the `world_get_market` tool). Nested
312
+ * markets default on, matching the tool — they carry the outcome mint ids
313
+ * the orderbook/trade calls need. */
314
+ worldMarket(eventTicker: string, withNestedMarkets?: boolean): Promise<unknown>;
315
+ /** A World market's orderbook (the `world_orderbook` tool). */
316
+ worldOrderbook(id: string, byMint?: boolean): Promise<unknown>;
317
+ /** A World market's price history (the `world_market_prices` tool). */
318
+ worldPrices(args: WorldPricesArgs): Promise<unknown>;
319
+ /** Filter addresses down to World outcome mints (the
320
+ * `world_filter_outcome_mints` tool). */
321
+ worldFilterOutcomeMints(addresses: string[]): Promise<unknown>;
322
+ /** Solana token positions for an address (the `world_positions` tool). */
323
+ worldPositions(address: string): Promise<unknown>;
324
+ /** Trade a World prediction market (the `world_buy_outcome` /
325
+ * `world_change_position` / `world_redeem` tools). Always parks as
326
+ * `pending_approval` (trades are force-approved); pass
327
+ * `{ waitForApproval: true }` to wait for the user's passkey approval and
328
+ * sign in-process. */
329
+ worldTrade(args: WorldTradeArgs, opts?: SignOptions): Promise<SwapResult>;
330
+ /** Hyperliquid spot markets (the `hyperliquid_markets` tool). */
331
+ hyperliquidMarkets(): Promise<unknown>;
332
+ /** Hyperliquid spot prices (the `hyperliquid_prices` tool). */
333
+ hyperliquidPrices(): Promise<unknown>;
334
+ /** Resolve one Hyperliquid token by name (the `hyperliquid_token` tool). */
335
+ hyperliquidToken(name: string): Promise<unknown>;
222
336
  /** Poll a request's status (the `get_request` tool). */
223
337
  getRequest(requestId: string): Promise<AgentResponse>;
224
338
  /** Poll until the request leaves a pending state (or the timeout elapses). */
@@ -299,4 +413,4 @@ interface GetPortfolioArgs {
299
413
  network_ids?: string | null;
300
414
  }
301
415
 
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 };
416
+ export { type AccountChangeResult, type AgentResponse, type BindingResponse, type BuyLinkArgs, type BuyLinkResult, type ClientGrantSummary, type CredentialOutput, type CredentialSummary, type DiscoverServicesOptions, type GetPortfolioArgs, type Grant, type LoginOptions, type OAuthTokens, type OutputType, PayboxClient, type PayboxClientOptions, PayboxError, type PaymentArgs, type PortfolioArgs, type RequestPaymentArgs, type RequestSecretArgs, type RequestStatus, type RequestSwapArgs, type RequestWalletSignArgs, type SecretArgs, type ServiceSummary, type SignOptions, type StoredConfig, type SwapArgs, type SwapPlan, type SwapResult, type UseServiceArgs, type WalletSignArgs, type WalletSignResult, type WorldMarketsArgs, type WorldPricesArgs, type WorldTradeArgs, type X402Args, type X402Plan, type X402Result, configFile, credsFromToken, loadConfig, loginLoopback, mcpResource, refreshTokens, saveConfig };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  mcpResource,
9
9
  refreshTokens,
10
10
  saveConfig
11
- } from "./chunk-DIMOTJ2E.js";
11
+ } from "./chunk-EBB4HNOB.js";
12
12
  export {
13
13
  PayboxClient,
14
14
  PayboxError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybox-sh/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
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, get_request) over REST, with in-process non-custodial wallet signing.",
6
6
  "license": "Apache-2.0",