@coinbase/coinbase-cli 0.0.7 → 0.0.9

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/version.txt CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/coinbase-cli",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Coinbase for agents — CLI and MCP server for trading, wallets, payments, and onchain across the Coinbase platform",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,8 +8,10 @@
8
8
  },
9
9
  "scripts": {
10
10
  "build": "BUILD=external node scripts/embed-spec.mjs",
11
- "gen:types": "BUNDLE_SKIP=1 BUILD=external node scripts/embed-spec.mjs && node scripts/gen-types.mjs specs/cli/coinbase-cli.yaml '' > generated/cli/types.ts && node scripts/gen-types.mjs dist/spec.json '' RetailBrokerageApi_ > generated/brokerage/types.ts && node scripts/gen-client.mjs > generated/brokerage/client.ts && node scripts/gen-surface.mjs specs/cli/coinbase-cli.yaml > generated/cli/surface.ts",
11
+ "gen:spec": "BUILD=external node scripts/resolve-agent-spec.mjs",
12
+ "gen:types": "pnpm run gen:spec && BUNDLE_SKIP=1 BUILD=external node scripts/embed-spec.mjs && node scripts/gen-types.mjs dist/agent-api.yaml '' > generated/cli/types.ts && node scripts/gen-types.mjs dist/spec.json '' RetailBrokerageApi_ > generated/brokerage/types.ts && node scripts/gen-client.mjs > generated/brokerage/client.ts && node scripts/gen-surface.mjs dist/agent-api.yaml > generated/cli/surface.ts",
12
13
  "gen:test": "node scripts/gen-mapping-tests.mjs",
14
+ "gen:check": "pnpm run gen:spec && node scripts/check-contract.mjs",
13
15
  "typecheck": "tsc --noEmit",
14
16
  "test": "node --experimental-strip-types --no-warnings --test 'src/**/*.test.ts'",
15
17
  "test:keyring": "node --experimental-strip-types --no-warnings --test src/lib/keyring/keyring.integration-test.ts",
@@ -63,17 +63,57 @@ coinbase orders create product_id=BTC-USD side=SELL type=stop_limit \
63
63
 
64
64
  Prefer native order types — they are durable and server-side. Only use a `--until` watcher (see `coinbase-watch`) when the trigger is something a single resting order cannot express (cross-product price, spread/volume, fill sequencing).
65
65
 
66
+ ## Advanced orders (bracket, TWAP, scaled, attached exits)
67
+
68
+ Bracket, TWAP, scaled orders, and attached exits require the default Agent API
69
+ transport.
70
+ Attached exits require eligible market/limit parents: spot BUY or futures
71
+ BUY/SELL, not equities. Stops do not guarantee a fill or cap losses.
72
+
73
+ ```sh
74
+ # Attach take-profit/stop-loss exits to a limit order
75
+ coinbase orders create product_id=BTC-USD side=BUY type=limit base_size=0.01 \
76
+ limit_price=50000 attached_take_profit_price=55000 attached_stop_loss_price=48000
77
+
78
+ # Spot bracket: SELL exit (see orders create --help for futures eligibility)
79
+ coinbase orders create product_id=BTC-USD side=SELL type=bracket \
80
+ base_size=0.01 limit_price=55000 stop_price=48000
81
+
82
+ # TWAP: choose future start/end times for the requested execution window
83
+ coinbase orders create product_id=BTC-USD side=BUY type=twap base_size=0.01 \
84
+ limit_price=55000 time_in_force=GTD start_time='<start-RFC3339>' end_time='<end-RFC3339>'
85
+
86
+ # Scaled: 5 limit child orders spread between min_price and max_price
87
+ coinbase orders create product_id=BTC-USD side=BUY type=scaled base_size=0.01 \
88
+ num_orders=5 min_price=48000 max_price=52000
89
+
90
+ # Change or remove attached exits on an eligible unfilled limit order
91
+ coinbase orders edit <order_id> attached_take_profit_price=56000 attached_stop_loss_price=47000
92
+ coinbase orders edit <order_id> cancel_attached_order=true
93
+ ```
94
+
95
+ Preview first for anything non-trivial — `orders preview` returns the TWAP
96
+ slice schedule or scaled child-order plan before you place the order.
97
+ Read `orders get` before changing attached exits: an attached update replaces
98
+ both legs, so send both prices to retain both. Omit attached fields to keep
99
+ existing exits unchanged.
100
+
66
101
  ## Manage orders
67
102
 
68
103
  ```sh
69
104
  coinbase orders list status==OPEN
70
105
  coinbase orders get <order_id>
106
+ coinbase orders edit-preview order_id=<order_id> limit_price=50000
71
107
  coinbase orders cancel order_ids:='["id-1","id-2"]'
72
108
  coinbase orders edit <order_id> limit_price=50000
73
109
  coinbase orders fills order_id==<order_id>
74
- coinbase orders close_position product_id=BTC-USD
110
+ coinbase orders close-position product_id=BTC-USD
75
111
  ```
76
112
 
113
+ `orders edit-preview` reprices an open order without editing it — distinct from
114
+ `orders preview`, which prices an order you have not placed yet. Supply at least
115
+ one of `base_size` or `limit_price`.
116
+
77
117
  ## Portfolio scope
78
118
 
79
119
  CDP API keys derive portfolio scope from the key itself — no `retail_portfolio_id` needed in the body. To trade in a different portfolio, switch envs (`-e live-trading`); see `coinbase-portfolios`.
@@ -57,6 +57,29 @@ The header names are not interchangeable. Never send `X-PAYMENT` to a v2 resourc
57
57
 
58
58
  If the resource rejects the header, first verify that the challenge's `x402Version`, the `x402_version` passed to `pay`, and the HTTP header name agree. Do not create another payment merely to try the other header name.
59
59
 
60
+ ## Sign-In With X (SIWX)
61
+
62
+ When a v2 challenge includes `extensions["sign-in-with-x"]`, a wallet that has already paid for the resource may use SIWX instead of creating another payment. SIWX is a separate HTTP authentication flow: never add it to `x402 pay`.
63
+
64
+ `coinbase` cannot sign SIWX messages and `x402 fetch` cannot attach custom headers. Use the manual `x402 pay` flow only when the caller has a compatible external wallet signer and can make the resource request itself. Otherwise, omit `SIGN-IN-WITH-X` and pay normally.
65
+
66
+ Do not manually serialize or sign the extension JSON. Select a `supportedChains` entry compatible with the wallet, then use an x402 SIWX client implementation to:
67
+
68
+ 1. Merge `extension.info` with the selected `chainId` and `type`.
69
+ 2. Build the required CAIP-122 message, including the signing wallet address.
70
+ 3. Sign that message with the matching wallet.
71
+ 4. Emit a proof containing the copied `info` fields, `chainId`, `type`, `address`, and `signature`.
72
+ 5. Base64-encode the proof JSON for `SIGN-IN-WITH-X`.
73
+
74
+ Use a CAIP-122-compatible SIWX client or wallet SDK to construct and sign the proof.
75
+
76
+ Reject redirects that leave the original catalog URL's origin. Only sign when `extension.info.domain` matches the final URL hostname and `extension.info.uri` exactly matches the final response URL. Preserve every challenge field unchanged. Send the SIWX header on the resource request, with the version-matched x402 payment header when payment is still required:
77
+
78
+ ```http
79
+ PAYMENT-SIGNATURE: <payment_header>
80
+ SIGN-IN-WITH-X: <base64-encoded SIWX proof>
81
+ ```
82
+
60
83
  ## Retry safety
61
84
 
62
85
  Use the smallest `amount` and `max_amount` that satisfy the requirement. Reuse the returned `idempotency_key` only when retrying the same logical payment after an outcome-unknown failure. Starting a retry without it can create another hold.