@paybox-sh/sdk 0.8.2 → 1.0.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 CHANGED
@@ -4,10 +4,9 @@ Typed Node SDK and `paybox` CLI for the PayBox agent API. It mirrors the MCP too
4
4
  surface — `list_credentials`, `request_payment`, `claim_payment_credentials`,
5
5
  `request_wallet_sign`, `request_secret`, `request_swap`, `discover_services`,
6
6
  `pay_x402`, `use_service`, `get_portfolio`, `get_buy_link`,
7
- `request_account_change`, `get_request`, and read-only plugin tools (`world_*`,
8
- `hyperliquid_*`) — but talks to the REST API directly, with no MCP host and no
9
- signing iframe.
10
- Geofenced World money tools are MCP-only.
7
+ `request_account_change`, `get_request`, and the generic plugin discovery,
8
+ contract, and invocation flow. Core operations use the REST API; plugins use
9
+ the same MCP tools as connector hosts, with no hardcoded per-plugin paths.
11
10
 
12
11
  Wallet signing is **non-custodial and runs in-process**: the SDK reuses the exact
13
12
  signing core from the wallet-sign iframe (`@paybox/mcp-app`), builds the chain
@@ -24,7 +23,8 @@ npx @paybox-sh/sdk login # or use the CLI directly
24
23
  Driving this CLI from an agent? [`SKILL.md`](SKILL.md) ships in the package and
25
24
  describes the install and login flow as an agent skill: what the human has to do
26
25
  (approve wallets, paste one signing key), and what the agent should not do
27
- around it.
26
+ around it. Use the CLI on **Muse**, **Grok Bot**, **Grok Computer**, and any agent on a
27
+ computer with no connector screen — not the grok.com MCP connector path.
28
28
 
29
29
  ## CLI
30
30
 
@@ -59,8 +59,9 @@ paybox account-change --note "need a wallet grant" # manage_url for the user to
59
59
  paybox request <request_id> --wait # poll a pending request
60
60
 
61
61
  # Plugins (enable them in the paybox app first)
62
- paybox world markets --status active # browse prediction markets
63
- paybox hyperliquid markets # spot discovery
62
+ paybox plugins list --status enabled
63
+ paybox plugins contract paybox://plugins/world
64
+ paybox plugins use world world_get_events --input '{"status":"active"}'
64
65
 
65
66
  paybox version # installed version (+ update check)
66
67
  paybox update # update the global install to latest
@@ -76,7 +77,7 @@ its own binary). For project installs use `pnpm up`/`pnpm rm`, or `npx
76
77
  @paybox-sh/sdk@latest` to always run the latest without installing.
77
78
 
78
79
  `sign`, `swap`, `pay-x402`, and `use-service` can complete in-process with a
79
- configured `pbxk1.` key. World buy/sell/redeem are MCP-only.
80
+ configured `pbxk1.` key. Plugin calls return the raw MCP tool result.
80
81
 
81
82
  For a Solana `swap` the SDK re-pins a fresh recent blockhash immediately before
82
83
  signing (parity with the signing window — the quote-time blockhash expires
@@ -84,7 +85,7 @@ within ~60–90s, often before signing), so a swap that dwells for approval no
84
85
  longer broadcasts as `BlockhashNotFound`. EVM swaps are unaffected.
85
86
 
86
87
  `pay-x402` is header mode — on success `output.value.x_payment` is the `X-PAYMENT`
87
- header to replay on the original request. `use-service` is gateway mode — paybox
88
+ header to replay on the original request. `use-service` is gateway mode — PayBox
88
89
  makes the paid call for you and returns the resource's reply on
89
90
  `output.value.response`. Pass `--accepts` from the resource's own 402 (start from
90
91
  the curated Bazaar set with `paybox discover`).
@@ -121,6 +122,15 @@ const services = await paybox.discoverServices("weather api");
121
122
  const rawServices = await paybox.discoverServices("weather api", { raw: true }); // debug only
122
123
  const paid = await paybox.useService({ credentialId: walletId, url: services[0].resource });
123
124
  // paid.response.output.value.response holds the resource's reply
125
+
126
+ const plugins = await paybox.discoverPlugins({ status: "enabled" });
127
+ const selected = plugins.plugins.find((plugin) => plugin.id === "aave");
128
+ const contract = await paybox.getPluginContract(selected!.contract_uri!);
129
+ const result = await paybox.usePlugin({
130
+ pluginId: contract.contract.id,
131
+ toolId: contract.contract.tools[0].id,
132
+ input: {},
133
+ });
124
134
  ```
125
135
 
126
136
  ## Configuration
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: PayBox CLI setup
3
- version: 0.8.3
3
+ version: 0.8.13
4
4
  description: >-
5
5
  Install and log in to the PayBox CLI (@paybox-sh/sdk) so an agent can pay,
6
6
  sign, and hold wallet, card, and secret credentials on the user's behalf. Use
@@ -12,12 +12,77 @@ description: >-
12
12
 
13
13
  The human and agent guide is `https://docs.paybox.sh` (start at
14
14
  getting-started and connect/mcp). This file is only the CLI film. Grok
15
- (grok.com) and Grok Bots are different hosts; do not treat one as the other.
15
+ (grok.com), Grok Bots, and Muse are different hosts; do not treat one as another.
16
+
17
+ ## Which host
18
+
19
+ - **Muse, Grok Bot, Grok Computer, or any agent on a computer or VM with no connector
20
+ screen:** this skill is the path. Install and run `paybox login` on that
21
+ machine. Do not send the user to grok.com/connectors and do not paste the MCP
22
+ URL as setup.
23
+ - **Grok at grok.com (chat in the browser):** the user adds the MCP connector at
24
+ grok.com/connectors. Do not run this CLI install flow unless they explicitly
25
+ want the CLI on a separate machine.
26
+
27
+ When the user says "install PayBox" and you are Muse, Grok Bot, or running on a
28
+ computer, start here immediately.
16
29
 
17
30
  The user asks to install PayBox. Two things need them: they approve wallet
18
31
  access with a passkey, and they paste one signing key. Everything else is yours,
19
32
  and they should not see it happen.
20
33
 
34
+ ## Muse
35
+
36
+ On Muse this section wins over Grok Bot phone-app and masked-field rules below.
37
+ Prod is `https://api.paybox.sh` / `https://app.paybox.sh`. Stay quiet until they
38
+ say install PayBox / install paybox / Install Paybox. English. Few words. No
39
+ secret dumps. No invented click paths.
40
+
41
+ Do not send them to Settings → Connectors → Add custom, or to paste an MCP URL.
42
+ Muse **Manage Connectors** (OpenAI, Anthropic, and the rest) is not where
43
+ PayBox is added. Do not run passkey inside Muse. Muse is a chat host, not a
44
+ Grok Bot computer VM. Do not ask for done, listo, or a screenshot. Do not
45
+ fake ready.
46
+ Never wipe `~/.config/paybox`.
47
+
48
+ Two chat controls, then Welcome. Muse does **not** open those links the way
49
+ Grok Bot does. Every link you send must tell them to tap it. A bare
50
+ markdown pill with no "tap this" line is a failed take.
51
+
52
+ 1. Run device-code login (`paybox login`, or the PayBox capability Authorize
53
+ flow if this host already has it). The moment you have
54
+ `verification_uri_complete` and `user_code`, send **one** message:
55
+ **Tap [Authorize wallets](verification_uri_complete) on your phone
56
+ browser.** plus `Code: XXXX-XXXX`. One short extra line only if the
57
+ PayBox **Capability** screen shows **Authorize**: "Or tap Authorize on
58
+ Paybox under Capabilities." Never mention Add custom. Phone browser
59
+ (Safari or Chrome), not the native PayBox app and not inside Muse.
60
+ You do not open the URL. Poll until OAuth is live. Do not end the
61
+ turn while polling.
62
+ 2. When OAuth is live and the signing key is missing, send **Tap
63
+ [Provision agent key](https://app.paybox.sh/agent-key?client_id=<cid>)
64
+ on your phone browser.** Then this exact line: **Muse does not have a
65
+ secure field for the signing key yet; the team is working on it. For
66
+ now paste the pbxk1 here and rotate it after.** `cid` is the
67
+ access-token UUID, never `oauth.clientId`. Muse has no masked field.
68
+ Write `signingKey` into an isolated config. Never `login --signing-key`
69
+ on argv. Never echo the key.
70
+
71
+ Ready only when OAuth or an API key is live **and** `canSign` is true. Then
72
+ Welcome to PayBox with two buttons: **Swap 20 USDC to SOL**, **Pay a Solana
73
+ briefing**. Do the one they tap. Stop when that job is done.
74
+
75
+ If token exchange fails (`refresh_rejected` / egress): one stop line, "Host
76
+ blocks PayBox token exchange. Install NOT complete." Do not offer Settings →
77
+ Add custom as a workaround. If a PayBox capability with **Authorize** is
78
+ visible, point only there. If MCP is already Connected under Manage your MCP
79
+ servers, use that grant — still no Add custom story.
80
+
81
+ Install the CLI only when this host still needs device-code:
82
+ `npm install -g @paybox-sh/sdk@latest`, then `paybox --json version` (0.8.5+).
83
+ Fresh `PAYBOX_CONFIG_DIR`. Unset `PAYBOX_API_URL` `PAYBOX_API_KEY`
84
+ `PAYBOX_SIGNING_KEY` `PAYBOX_ACCESS_TOKEN`.
85
+
21
86
  ## Install
22
87
 
23
88
  ```bash
@@ -60,8 +125,9 @@ reads as a setup that failed.
60
125
 
61
126
  The command drives the whole flow itself. Do not reimplement any of it: it
62
127
  registers a client, starts device authorization, prints a verification URL and a
63
- short user code, tries to open that URL locally, polls until the user approves,
64
- then opens the signing-key page and prompts for the key.
128
+ short user code, tries to open that URL locally, and polls until the user
129
+ approves. After this poll writes `oauth`, it may print an `/agent-key?client_id=`
130
+ URL. Do not wait for that print if this run already saved `oauth`.
65
131
 
66
132
  Login writes progress to stderr as plain prose, not JSON. Watch for the
67
133
  verification URL and the `Code:` line.
@@ -76,27 +142,55 @@ Send that link even though the CLI also tries to open a browser. When the CLI
76
142
  is not on the user's machine, that local open is useless or invisible, and your
77
143
  message is the only way they reach the page.
78
144
 
79
- The user approves in the browser. If the link opens the PayBox mobile app and
80
- errors instead, have them open it in a browser.
145
+ On Grok Bot, Authorize wallets should open the PayBox app. That is the
146
+ correct path there. After they tap Connect CLI, the app opens Generate a
147
+ signing key by itself. Do not tell them to come back to chat first. On Muse
148
+ use the Muse section: phone browser, not the native app, not inside Muse.
81
149
 
82
150
  Then wait. The poll is the continue signal. Do not ask the user to type `done`,
83
151
  confirm, or send a screenshot, and do not end your turn while login is running.
84
152
  If the code expires before they approve, run `paybox login` again for a fresh
85
153
  one rather than reusing the old link.
86
154
 
155
+ A `clientId` already on disk when this `paybox login` starts is the previous
156
+ client. Ignore it. `login` registers a new client and only writes `oauth` after
157
+ the poll succeeds. If you restart login for a fresh code, drop any signing-key
158
+ link you already sent.
159
+
160
+ After **this** login writes `oauth` (or prints `/agent-key?client_id=`), send
161
+ the signing-key controls. Prefer that printed URL. If stderr never printed it
162
+ but this run did save `oauth`, build
163
+ `https://app.paybox.sh/agent-key?client_id=<cid>` from the `cid` claim on the
164
+ access token this login just wrote. Never use `oauth.clientId`, a `pbx-oauth-`
165
+ id, or a `clientId` that was already in `config.json` when the command started.
166
+ Those are the OAuth registration, not the vault agent. `/agent-key` will say
167
+ the agent was not found. Do not wait for a dropped Windows executor to
168
+ reconnect before they see the box. Merge the key when the machine is back;
169
+ showing the box does not need that machine.
170
+
87
171
  ### Step 2 — Paste the signing key
88
172
 
89
- After approval, login opens the signing-key page and prompts for the key.
90
- Present a **masked input** for the `pbxk1.` value and write what the user gives
91
- you to that prompt's stdin.
173
+ The moment **this** login has an agent-key URL (stderr, or `cid` from the oauth
174
+ it just saved), put **Generate Signing Key** in chat as that link plus a
175
+ **masked input** for the `pbxk1.` value, in the same turn. Seconds after they
176
+ finish Authorize wallets, not minutes. That chat link must use the JWT `cid`.
177
+ On Grok Bot it must open the PayBox app on the first tap, the same way
178
+ Authorize wallets does. On Muse tell them to tap the link, then say Muse does
179
+ not have a secure field for the signing key yet; the team is working
180
+ on it. For now paste the pbxk1 here and rotate it after. There is no
181
+ masked field. The link opens in the phone browser. Do not `Start-Process`, `open`, `rundll32`, or `xdg-open` the authorize,
182
+ connect, or agent-key URL yourself. Write what they give you to login's
183
+ prompt stdin when that prompt is alive. If login is wedged after this oauth
184
+ write, keep the box on screen and merge `signingKey` when the host can write
185
+ files again.
92
186
 
93
187
  Pass it through the prompt, or set `PAYBOX_SIGNING_KEY` before running `login`
94
188
  when nothing is attached to stdin. Never pass it as `login --signing-key <value>`
95
189
  on the command line: an argument lands in shell history and is visible to anyone
96
190
  who can list processes.
97
191
 
98
- Do not ask the user to click the signing-key link, it is already open. Do not
99
- show the key field before that page has opened, and do not open it twice.
192
+ Do not ask the user to click a signing-key URL that never arrived. Do not open
193
+ the page twice. Do not hold the box until login narrates success.
100
194
 
101
195
  Wallet signing is non-custodial: the key stays on the user's machine and PayBox
102
196
  never holds it. Never print, log, or echo it.
@@ -115,8 +209,15 @@ rather than continuing, because signing and swaps will fail without it.
115
209
  From the install request until `canSign` is `true`, exactly two messages, in
116
210
  this order:
117
211
 
118
- 1. The **Authorize wallets** link plus the code.
119
- 2. The masked `pbxk1.` field, after the signing-key page has opened.
212
+ 1. The **Authorize wallets** link plus the code. On Muse, the line says
213
+ to tap that link on the phone browser. Grok Bot can omit that; it
214
+ opens the link itself.
215
+ 2. **Generate Signing Key** plus the signing-key control, as soon as
216
+ **this** login prints `/agent-key?client_id=` or writes a new `oauth`.
217
+ Grok Bot: masked `pbxk1.` field. Muse: tell them to tap Provision
218
+ agent key on the phone browser, then: Muse does not have a secure
219
+ field for the signing key yet; the team is working on it. For now
220
+ paste the pbxk1 here and rotate it after.
120
221
 
121
222
  Nothing else. No "Installing…", "Opening…", "Got it", no CLI version, package
122
223
  manager, config path, or request id, and no narration of a retry or fallback. If
@@ -132,16 +233,60 @@ The silence rules above are about setup, and end here.
132
233
  Show them what they now have: `paybox --json credentials` for the granted
133
234
  wallets, then `paybox --json portfolio --address <wallet>` for balances. Every
134
235
  `--credential` takes the `credential.id` from that list; a wallet's name is not
135
- an id and the command will refuse it. Render a compact table, never addresses or
136
- raw JSON. The CLI cannot create wallets; it uses what the user granted during
137
- authorization.
138
-
139
- When you run several operations at once, report each one where the user is
140
- watching, as it lands, with its request id. Each spends real money on its own,
141
- and one combined summary at the end leaves nobody able to tell which transaction
142
- came from which request.
143
-
144
- After that table, do two things with plugins. Do not treat Welcome as a
236
+ an id and the command will refuse it. Render a compact Token / Amount / USD
237
+ table, never addresses or raw JSON. The CLI cannot create wallets; it uses what
238
+ the user granted during authorization.
239
+
240
+ A wave is done only when every named task has a content recap in the main
241
+ chat, a confirmed second failure, or an Auto-review block that you marked
242
+ stopped. One specialist finishing is not the wave. Print the table **twice only**: once after the signing key is saved
243
+ (then Welcome), and once when the wave is done. Do not reprint it after each
244
+ recap or swap. Recaps can name a token, amount, and Solscan link without
245
+ the book.
246
+
247
+ Spawn work only for tasks they named. Do not start `paybox buy-link` or a
248
+ buy-dollars / card-checkout specialist unless they asked to buy dollars or
249
+ fund. Swap, BONK, a briefing, or an xStock is not that ask. "MoonPay on
250
+ glim.sh" as a named task is a paid search payload, not a MoonPay checkout. A
251
+ default film five is not a license to add checkout.
252
+
253
+ Window count is 1 main chat plus **one specialist per named job**. If they
254
+ state a count ("all five", "both", "the three"), that number is the specialist
255
+ count. Do not add a window for discovery, picking a URL or service, setup, a
256
+ retry, or a sub-step. Those stay inside the job that owns them.
257
+
258
+ The human never sees `Approval needed`, Allow once, Always allow, or Deny for
259
+ any command you or a specialist run: login, swap, use-service, discover, pay,
260
+ portfolio, whoami, uninstall, anything else. Never set
261
+ `request_smart_mode_approval` or retry an Auto-review block. If Auto-review
262
+ blocks, that command is done: mark that named job stopped on the checklist,
263
+ do not retry it, and do not nudge the specialist. One short main-chat line
264
+ that the job stopped is the recap. If they say stop, abort immediately. Do
265
+ not wait for Allow and do not raise a new card. A blocked command is not a
266
+ prompt for them to authorize the CLI.
267
+
268
+ When you run several operations at once, keep a checklist of the tasks they
269
+ named. Recaps in the main chat are the bought content (amounts, tweets,
270
+ briefing bullets). If a specialist is silent, open its transcript. If the
271
+ last command was Auto-review blocked, mark that job stopped and do not
272
+ nudge. Otherwise nudge it. Do not go idle waiting for a wake. Looking frozen
273
+ is a failed take.
274
+ Do not call the wave done, and do not print the summary or second table,
275
+ until the wave-done rule above is true.
276
+
277
+ Report each recap where the user is watching as it lands, without a new table.
278
+ Each spends real money on its own. If a command fails and you will retry,
279
+ retry once without telling them it failed. If the retry works, they only see
280
+ success, or a single working beat. If it fails twice, then say so. A
281
+ specialist may log the first fail in its own audit chat; the main recap stays
282
+ clean. That retry still must not raise an approval card.
283
+
284
+ Never tell them they had no money unless `paybox --json portfolio` shows they
285
+ cannot cover that exact amount. A pre-broadcast reject, a dropped signature,
286
+ or a token-refresh race is not insufficient funds. When the wave is done, one
287
+ short summary of what they bought, then the second table.
288
+
289
+ After the first table, do two things with plugins. Do not treat Welcome as a
145
290
  catalog index. There may be tens or thousands.
146
291
 
147
292
  1. Send them to enable plugins on the web: a markdown link labeled
@@ -149,24 +294,30 @@ catalog index. There may be tens or thousands.
149
294
  app, not a host Settings → Plugins screen. Ask them to turn on what
150
295
  they want to use, then say when they are back.
151
296
 
152
- 2. Then call `discover_plugins` with `status` `enabled`, no `query`, and
153
- a small `limit`. That page is what they have on, not the store. From
297
+ 2. Then run `paybox --json plugins list --status enabled --limit 10`. That page
298
+ is what they have on, not the store. From
154
299
  those plugins plus the portfolio, suggest a few concrete next moves
155
300
  (about six, not one row per plugin). Use each result's `name` and
156
301
  contract. Be specific: amounts, which wallet UUID, which market or
157
302
  vault from the contract. Mix two enabled plugins in one suggestion
158
303
  when that serves the same goal (for example fund or swap, then put
159
- the result to work). If nothing is enabled, skip the suggestion list
160
- and stay on the Plugins link.
161
-
162
- When they name a plugin or a job, search: `discover_plugins` with `query`
163
- set to what they asked, `status` `enabled` if they already turned it on,
164
- then page with `next_cursor` only while the current page has no match.
165
- Official plugin money uses MCP: `get_contract` with `contract_uri`
166
- unchanged → `use_plugin` with that contract's `plugin_id`, `tool_id`,
167
- and `input`. Do not invent a `paybox <plugin>` command; only use CLI
168
- groups that `paybox --help` already lists. Enabled plugin tools may also
169
- appear on `tools/list`. Plugin money always pauses for passkey.
304
+ the result to work). On Muse, Welcome is those two buttons first:
305
+ **Swap 20 USDC to SOL** on the granted Solana wallet, then **Pay a
306
+ Solana briefing**. Do not offer 0.001 SOL to USDC. If nothing is
307
+ enabled, skip the extra plugin list and stay on the Plugins link.
308
+
309
+ When they name a plugin or a job, search with `paybox --json plugins list
310
+ <query> --status enabled`, then page with `--cursor <next_cursor>` only while
311
+ the current page has no match. For an official plugin, run `paybox --json
312
+ plugins contract <contract_uri>` with the URI unchanged, then `paybox --json
313
+ plugins use <plugin_id> <tool_id> --input <json>` with input matching that
314
+ contract. Unofficial discovery results already contain their tool schemas;
315
+ reuse `--invocation-id` only to retrieve the exact same ambiguous call. Plugin
316
+ money always pauses for passkey.
317
+
318
+ There are no per-plugin commands. `paybox world …` and `paybox hyperliquid …`
319
+ were removed in 1.0.0; reach World and Hyperliquid through `paybox plugins`
320
+ like every other plugin.
170
321
 
171
322
  If prod MCP (`https://api.paybox.sh/mcp`) is `unreachable` or `needsAuth` while
172
323
  `paybox --json whoami` still works, say that. Do not send the human to Settings.
@@ -175,8 +326,23 @@ Do not switch to staging. Do not report the dollar as sent.
175
326
  ## A setup that went wrong
176
327
 
177
328
  - The user had to prompt you after approving wallet access.
178
- - The key field appeared before the signing-key page opened.
179
- - You asked the user to click the signing-key link, or to type `done`.
329
+ - The key field waited minutes after they finished Authorize wallets.
330
+ - The signing-key URL used `oauth.clientId`, a `pbx-oauth-` id, or a
331
+ `clientId` that was already on disk before this `paybox login` started.
332
+ - The first Generate Signing Key tap said the agent was not in the vault.
333
+ - You asked the user to type `done`.
180
334
  - You opened either page twice.
335
+ - You launched authorize, connect, or agent-key with `Start-Process` or an
336
+ equivalent local open.
337
+ - The human saw Allow once, Always allow, or Deny for a CLI command.
338
+ - You nudged a specialist after Auto-review blocked its last command.
339
+ - You spawned more specialists than named jobs (discovery or a sub-step
340
+ got its own window).
181
341
  - Setup chat contained anything besides those two messages.
182
342
  - A token, API key, or `pbxk1.` value reached the transcript.
343
+ - On Muse you sent Settings → Connectors → Add custom, or Manage Connectors.
344
+ - On Muse you opened passkey inside Muse.
345
+ - On Muse Authorize wallets opened in the PayBox app or inside Muse.
346
+ - On Muse you sent a link without telling them to tap it.
347
+ - On Muse you faked ready before `canSign` was true.
348
+ - On Muse token exchange failed and you invented an MCP Add custom path.