@paybox-sh/sdk 2.0.0 → 2.2.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 +83 -9
- package/SKILL.md +269 -228
- package/dist/{chunk-66FQ2R7G.js → chunk-DWDC6W5P.js} +427 -56
- package/dist/chunk-DWDC6W5P.js.map +1 -0
- package/dist/cli.js +33 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +61 -18
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-66FQ2R7G.js.map +0 -1
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ npx @paybox-sh/sdk login # or use the CLI directly
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Driving this CLI from an agent? [`SKILL.md`](SKILL.md) ships in the package and
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
routes wallet tasks through existing access or the required setup steps. It
|
|
25
|
+
preserves an explicit wallet choice and resumes the requested task after setup.
|
|
26
|
+
Use the CLI on **Muse**, **Grok Bot**, **Grok Computer**, and any agent on a
|
|
27
27
|
computer with no connector screen — not the grok.com MCP connector path.
|
|
28
28
|
|
|
29
29
|
## CLI
|
|
@@ -33,7 +33,8 @@ computer with no connector screen — not the grok.com MCP connector path.
|
|
|
33
33
|
# Pairing prints eight emoji and a link; you open the link and pick that same
|
|
34
34
|
# code in PayBox. The key is generated locally and never leaves this machine,
|
|
35
35
|
# so there is nothing to copy. Neither command needs a browser on the machine
|
|
36
|
-
# running the CLI — approve both from a phone if you like.
|
|
36
|
+
# running the CLI — approve both from a phone if you like. Add --no-open to
|
|
37
|
+
# either command to print the link without launching a browser.
|
|
37
38
|
paybox login # device-code OAuth (browser + passkey)
|
|
38
39
|
paybox login --key pbx_live_… # personal API key instead (no OAuth)
|
|
39
40
|
paybox connect # pair a signing key
|
|
@@ -57,6 +58,7 @@ paybox buy-link --credential <id> --amount-usd 50 # defaults EVM funding to Ba
|
|
|
57
58
|
paybox buy-link --credential <id> --destination eip155:1 --currency eth
|
|
58
59
|
paybox account-change --note "need a wallet grant" # manage_url for the user to open
|
|
59
60
|
paybox request <request_id> --wait # poll a pending request
|
|
61
|
+
paybox request <request_id> --complete-signature # sign that parked wallet-sign request locally
|
|
60
62
|
|
|
61
63
|
# Plugins (enable them in the paybox app first)
|
|
62
64
|
paybox plugins list --status enabled
|
|
@@ -79,6 +81,17 @@ its own binary). For project installs use `pnpm up`/`pnpm rm`, or `npx
|
|
|
79
81
|
`sign`, `swap`, `pay-x402`, and `use-service` can complete in-process with a
|
|
80
82
|
configured `pbxk1.` key. Plugin calls return the raw MCP tool result.
|
|
81
83
|
|
|
84
|
+
An MCP host can declare its signing surface on each HTTP request with
|
|
85
|
+
`X-Paybox-Signing-Surface: in-process`, `browser`, or `none`. Omit the header to
|
|
86
|
+
keep the existing MCP Apps behavior. The value selects one advisory
|
|
87
|
+
`next_action`; it does not grant signing access. A host must use `in-process`
|
|
88
|
+
only when it has an eligible local callback for that operation. For a parked
|
|
89
|
+
wallet-sign request, call `paybox.completeWalletSignRequest(requestId)` from
|
|
90
|
+
that callback. The SDK reads the stored intent from PayBox and signs the same
|
|
91
|
+
request. It does not create another request. Do not put the signing key in an
|
|
92
|
+
MCP tool argument or model context. `pending_approval` still needs a person;
|
|
93
|
+
`denied` and `error` remain terminal request states.
|
|
94
|
+
|
|
82
95
|
For a Solana `swap` the SDK re-pins a fresh recent blockhash immediately before
|
|
83
96
|
signing (parity with the signing window — the quote-time blockhash expires
|
|
84
97
|
within ~60–90s, often before signing), so a swap that dwells for approval no
|
|
@@ -133,6 +146,64 @@ const result = await paybox.usePlugin({
|
|
|
133
146
|
});
|
|
134
147
|
```
|
|
135
148
|
|
|
149
|
+
## Run and resume a plugin request
|
|
150
|
+
|
|
151
|
+
`runPlugin` invokes a plugin once and drives its stored request. `resumeRequest`
|
|
152
|
+
reads an existing request and does not invoke the plugin again. Signing follows
|
|
153
|
+
validated Solana/EVM transaction capabilities and server-owned `refresh_before_sign`,
|
|
154
|
+
not plugin names. `resumeRequest` also consumes stored `wallet_sign` transaction
|
|
155
|
+
intents through the existing signer. Unknown formats, versioned plans and gasless
|
|
156
|
+
prepared plans stop with `outcome: "unsupported"`. Public plugins also use
|
|
157
|
+
`use_plugin`, with their installation ID as `plugin_id`; request completion does
|
|
158
|
+
not by itself prove a purchase or broadcast. Use the plugin contract to select an
|
|
159
|
+
enabled tool and construct its input.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import type { UsePluginArgs } from "@paybox-sh/sdk";
|
|
163
|
+
|
|
164
|
+
async function runApprovedOperation(operation: UsePluginArgs) {
|
|
165
|
+
const execution = await paybox.runPlugin(operation, { timeoutMs: 60_000 });
|
|
166
|
+
if (execution.requestId) {
|
|
167
|
+
await saveRequestId(execution.requestId);
|
|
168
|
+
}
|
|
169
|
+
return execution;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const execution = await paybox.resumeRequest(savedRequestId, {
|
|
173
|
+
waitForApproval: true,
|
|
174
|
+
timeoutMs: 60_000,
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The example assumes application-owned storage through `saveRequestId` and
|
|
179
|
+
`savedRequestId`. Keep the request ID so another process can resume after a pause.
|
|
180
|
+
A paired signing key enables automatic signing. Set `autoSign: false` to stop
|
|
181
|
+
before signing. The server still enforces wallet grants and approval requirements.
|
|
182
|
+
|
|
183
|
+
| Outcome | Meaning |
|
|
184
|
+
| --- | --- |
|
|
185
|
+
| `terminal` | Check `response.status`: `success`, `denied`, or `error`. A signature alone is not success. |
|
|
186
|
+
| `approval_required` | The user must approve through Paybox. Approval waiting is disabled by default. |
|
|
187
|
+
| `signing_required` | Automatic signing is disabled or a signing key is unavailable. |
|
|
188
|
+
| `unsupported` | The result or signing plan is outside the supported contract. |
|
|
189
|
+
| `reconcile_required` | The client cannot confirm completion. Query the same request before further action. |
|
|
190
|
+
| `deadline_exceeded` / `cancelled` | The client stopped. The server operation can still finish. |
|
|
191
|
+
|
|
192
|
+
The default deadline is 300 seconds and includes network calls. Polling starts at
|
|
193
|
+
2 seconds, doubles when the status is unchanged, and stops increasing at 30 seconds.
|
|
194
|
+
A status change resets the interval. `intervalMs` sets the starting interval from
|
|
195
|
+
1 to 30,000 milliseconds. `signal` accepts an `AbortSignal` for cancellation.
|
|
196
|
+
|
|
197
|
+
Do not start concurrent drivers for the same request. After an uncertain result,
|
|
198
|
+
use `getRequest` before an explicit resume. The driver does not automatically retry
|
|
199
|
+
a signature submission or create a replacement request. If invocation stops before
|
|
200
|
+
a request ID arrives, reconcile outside this driver before invoking the plugin again.
|
|
201
|
+
|
|
202
|
+
`usePlugin` still returns the raw MCP result, including metadata. Use it for data
|
|
203
|
+
tools and unsupported flows. The new methods do not change existing CLI commands.
|
|
204
|
+
Funding requests stop with `outcome: "unsupported"`, `reason: "funding_required"`,
|
|
205
|
+
and a non-signing `pending_funding` response. They never reopen or submit a plan.
|
|
206
|
+
|
|
136
207
|
## Configuration
|
|
137
208
|
|
|
138
209
|
Resolution order: explicit constructor options → environment → stored config.
|
|
@@ -192,10 +263,13 @@ pnpm install
|
|
|
192
263
|
pnpm typecheck
|
|
193
264
|
pnpm build # tsup → dist/ (ESM + types + paybox bin)
|
|
194
265
|
|
|
195
|
-
# Refresh the generated tool types from
|
|
196
|
-
|
|
266
|
+
# Refresh the generated tool types from the MCP tool contract:
|
|
267
|
+
pnpm gen
|
|
197
268
|
```
|
|
198
269
|
|
|
199
|
-
The argument
|
|
200
|
-
|
|
201
|
-
|
|
270
|
+
The argument types in `src/types.generated.ts` come from
|
|
271
|
+
`artifacts/contracts/mcp-tools-v1.json`, the committed list of core MCP tools and
|
|
272
|
+
their input schemas. CI fails when the tools change and the file does not, or
|
|
273
|
+
when this file is not regenerated from it. Refresh it with
|
|
274
|
+
`PAYBOX_UPDATE_CONTRACTS=1 cargo test --lib mcp_tool_contract_matches_core_tools`
|
|
275
|
+
in `server/`. Response types in `src/types.ts` track `server/src/models.rs`.
|