@liquiditytech/rapidx-cli 1.0.28 → 1.0.29

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.
@@ -1,4 +1,4 @@
1
- import { consumePreview, createTargetedTradePreview, createTradePreview, defaultSafetyPolicy, executeRapidXCapability, findCapabilityById, getSchemaResult, makeEvidence, makePreviewStore, makeSafetyState, normalizeUnknownError, runSelfCheck, runTradingVerification, verifyPreview, buildLiveReadOnlySelfCheck, buildLiveTradingVerificationProbes, checkForUpdate, } from "../core/index.js";
1
+ import { consumePreview, createTargetedTradePreview, createTradePreview, defaultSafetyPolicy, executeRapidXCapability, findCapabilityById, getSchemaResult, makeEvidence, makePreviewStore, makeSafetyState, normalizeUnknownError, runSelfCheck, runPreviewPreflight, runTradingVerification, verifyPreview, buildLiveReadOnlySelfCheck, buildLiveTradingVerificationProbes, checkForUpdate, } from "../core/index.js";
2
2
  import { capabilityForTool, getMcpToolDefinitions } from "./tool-registry.js";
3
3
  import { writeMcpAudit } from "./audit.js";
4
4
  const previewStore = makePreviewStore();
@@ -6,8 +6,10 @@ const safetyState = makeSafetyState();
6
6
  export async function runMcpTool(toolName, input = {}) {
7
7
  try {
8
8
  if (toolName === "rapidx/tools") {
9
+ const schema = getSchemaResult();
9
10
  const data = {
10
- schemaVersion: getSchemaResult().schemaVersion,
11
+ schemaVersion: schema.schemaVersion,
12
+ inputSchemas: schema.inputSchemas,
11
13
  tools: getMcpToolDefinitions().map((tool) => ({
12
14
  name: tool.name,
13
15
  riskLevel: tool.capability.riskLevel,
@@ -55,6 +57,13 @@ export async function runMcpTool(toolName, input = {}) {
55
57
  throw new Error("order.preview capability missing");
56
58
  }
57
59
  const preview = createTradePreview(previewCapability, input, { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false }, safetyState, previewStore);
60
+ try {
61
+ Object.assign(preview, await runPreviewPreflight("order.place", input));
62
+ }
63
+ catch (error) {
64
+ previewStore.records.delete(preview.previewId);
65
+ throw error;
66
+ }
58
67
  const auditId = writeMcpAudit("trade-preview", "PASS", { toolName, capabilityId: capability.capabilityId, previewId: preview.previewId });
59
68
  return { ok: true, status: "PASS", data: preview, auditId, evidence: [makeEvidence(toolName)] };
60
69
  }
@@ -65,6 +74,13 @@ export async function runMcpTool(toolName, input = {}) {
65
74
  throw new Error(`${concretePreviewTarget} capability missing`);
66
75
  }
67
76
  const preview = createTargetedTradePreview(targetCapability, input, { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false }, safetyState, previewStore);
77
+ try {
78
+ Object.assign(preview, await runPreviewPreflight(concretePreviewTarget, input));
79
+ }
80
+ catch (error) {
81
+ previewStore.records.delete(preview.previewId);
82
+ throw error;
83
+ }
68
84
  const auditId = writeMcpAudit("trade-preview", "PASS", { toolName, capabilityId: targetCapability.capabilityId, previewId: preview.previewId });
69
85
  return { ok: true, status: "PASS", data: preview, auditId, evidence: [makeEvidence(toolName)] };
70
86
  }
@@ -78,6 +94,13 @@ export async function runMcpTool(toolName, input = {}) {
78
94
  throw new Error("trade preview target must be a non-preview trade write capability.");
79
95
  }
80
96
  const preview = createTargetedTradePreview(targetCapability, input, { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false }, safetyState, previewStore);
97
+ try {
98
+ Object.assign(preview, await runPreviewPreflight(targetCapability.capabilityId, input));
99
+ }
100
+ catch (error) {
101
+ previewStore.records.delete(preview.previewId);
102
+ throw error;
103
+ }
81
104
  const auditId = writeMcpAudit("trade-preview", "PASS", { toolName, capabilityId: targetCapability.capabilityId, previewId: preview.previewId });
82
105
  return { ok: true, status: "PASS", data: preview, auditId, evidence: [makeEvidence(toolName)] };
83
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liquiditytech/rapidx-cli",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "RapidX CLI, MCP server mode, registry, and release assets.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -21,7 +21,9 @@ Supported conventions:
21
21
  - Use `rapidx order cancel-preview` for `order.cancel`.
22
22
  - Use `rapidx trade preview` with `targetCapabilityId` for non-order trade writes, including position, account, and algo writes.
23
23
  - `rapidx trade preview` input is flat JSON; do not wrap target parameters under `params`.
24
+ - CLI preview ids are stored in the local CLI preview store. Do not submit MCP-created preview ids through CLI.
24
25
  - Treat `maxNotional` as a safety upper bound, not as the target order amount. Check symbol `minNotional` before increasing a requested amount.
26
+ - Use `positionSide="LONG"` or `positionSide="SHORT"` for hedge-mode order placement or verification. Do not switch account position mode just to place a hedge-side order.
25
27
 
26
28
  Examples:
27
29
 
@@ -42,8 +44,14 @@ rapidx account set-position-mode --input @/absolute/path/set-position-mode.json
42
44
 
43
45
  `rapidx update check --json` reads the RapidX release manifest and caches the result locally. Use it during setup, review, or session startup. Trade submit paths should not perform a fresh network update check.
44
46
 
47
+ `rapidx schema --json` returns `capabilities` plus `inputSchemas`. Agents should read the concrete input schema before constructing write inputs.
48
+
45
49
  `rapidx account balance` defaults to `mode=portfolio` and reads `/api/v1/trading/portfolio/assets`. `mode=account` reads `/api/v1/account/balance` and requires credentials with account-level permission.
46
50
 
47
- `rapidx account set-position-mode` is a trade write. It requires a matching preview token and a `continueConsentId` before execution.
51
+ `rapidx account set-position-mode` is a trade write. Use it only when the user explicitly asks to change account position mode. It requires a matching preview token and a `continueConsentId` before execution.
52
+
53
+ `rapidx order cancel` is asynchronous. A successful response can mean cancel accepted but not terminal. Poll `rapidx order get --json` when `terminalStateConfirmed=false`.
54
+
55
+ Automation mode still uses preview. Pass `automationMode=true` and the user's exact `automationConsentText` to preview only when the user has enabled automation in chat for the current scope.
48
56
 
49
57
  `rapidx position close` is a close-position action. Do not pass `side` or `quantity`; RapidX determines BUY or SELL from the current position and closes the target symbol/positionSide. Use a reduce-only order flow for partial closes. Verify the final exposure with `rapidx position list --json`, and do not rely only on `order get` to interpret the close intent.
@@ -24,13 +24,18 @@ Public tool names use the `rapidx/` prefix.
24
24
 
25
25
  Key trading tools:
26
26
 
27
+ - `rapidx/tools` returns the MCP tool list plus `inputSchemas`. Agents should read the concrete input schema before constructing write inputs.
27
28
  - `rapidx/update/check` reads the RapidX release manifest and returns current/latest CLI version, minimum write version, skills update advice, and upgrade commands.
28
29
  - `rapidx/self-check` can include update state when called with `{"checkUpdates": true}`.
29
30
  - `rapidx/order/preview` creates preview tokens for `order.place`.
30
31
  - `rapidx/order/place-preview`, `rapidx/order/amend-preview`, and `rapidx/order/cancel-preview` are concrete order preview aliases. Preview responses include `confirmation.submitToken`; pass it as `continueConsentId` when submitting the matching write tool.
31
32
  - `rapidx/trade/preview` creates preview tokens for non-place trade writes by `targetCapabilityId`, including position, account, and algo writes.
33
+ - Preview ids are local to the running MCP server. Do not submit a CLI-created preview id through MCP, and do not submit an MCP-created preview id through CLI.
34
+ - `rapidx/order/cancel` returns cancel acceptance plus terminal-state guidance. Poll `rapidx/order/get` when `terminalStateConfirmed=false`.
35
+ - Automation mode still uses preview. Set `automationMode=true` and pass the user's exact `automationConsentText` only when the user has enabled automation in chat for the current scope.
32
36
  - `rapidx/position/history` reads historical positions.
33
- - `rapidx/account/set-position-mode` changes account position mode and requires preview plus explicit continuation consent.
34
- - `rapidx/trade/verify-live` runs the optional small real-trade verification flow with `explicitUserConsent` and parameter-bound `acceptedRiskText`; it creates its own internal preview and does not accept an external `previewId`. `rapidx/trading-verification` remains supported as a compatibility alias.
37
+ - Hedge-mode order placement and verification use `positionSide="LONG"` or `positionSide="SHORT"` in the order or verify-live input. Do not use account mode switching as a substitute for order-level `positionSide`.
38
+ - `rapidx/account/set-position-mode` changes account position mode and requires preview plus explicit continuation consent. Use it only when the user explicitly asks to change account position mode.
39
+ - `rapidx/trade/verify-live` runs the optional small real-trade verification flow with `explicitUserConsent` and parameter-bound `acceptedRiskText`; it creates its own internal preview and does not accept an external `previewId`. If `positionSide` is provided, `acceptedRiskText` must include that position side. `rapidx/trading-verification` remains supported as a compatibility alias.
35
40
 
36
41
  Agents must discover the full tool list through `rapidx/tools` and must not invent tool names.
@@ -113,6 +113,8 @@ rapidx schema --json
113
113
 
114
114
  For trade writes, create a preview before submit. Use `rapidx order place-preview` for `order.place`, `rapidx order amend-preview` for `order.amend`, and `rapidx order cancel-preview` for `order.cancel`. Use flat JSON with `rapidx trade preview` and `targetCapabilityId` for non-order writes such as `position.set-leverage`, `position.close`, or `account.set-position-mode`.
115
115
 
116
+ `rapidx schema --json` and `rapidx/tools` return concrete `inputSchemas`. For hedge-mode orders, use `positionSide="LONG"` or `positionSide="SHORT"` in the order or verify-live input. Use `account.set-position-mode` only when the user explicitly asks to change account mode.
117
+
116
118
  For clearer order flows, prefer the explicit aliases:
117
119
 
118
120
  ```bash
@@ -124,6 +126,12 @@ rapidx trade preview --input '{"targetCapabilityId":"position.set-leverage","sym
124
126
 
125
127
  When submitting the actual write, pass the returned `previewId` and use `confirmation.submitToken` as `continueConsentId`.
126
128
 
129
+ Preview ids are runtime-local. Submit MCP previews through the same MCP server runtime, and submit CLI previews through the same CLI preview store.
130
+
131
+ `order.cancel` is asynchronous. If the cancel result says `terminalStateConfirmed=false`, poll `order get` until a terminal state before claiming that the order is cancelled.
132
+
133
+ For automation, keep the preview-first flow. Use `automationMode=true` and the user's exact `automationConsentText` only after the user has enabled RapidX automation mode in chat for the current scope.
134
+
127
135
  `maxNotional` is a safety upper bound, not the target order amount. If a requested amount is below the symbol `minNotional`, ask the user to confirm the larger amount before submitting. For `position.close`, do not pass `side` or `quantity`; RapidX determines the close side from the current position and closes the target symbol/positionSide. Use a reduce-only order flow for partial closes, then check final exposure with `position list`.
128
136
 
129
- Use `rapidx trade verify-live --json` only when the user explicitly authorizes a small real-trade verification. Include `acceptedRiskText` that names the exact symbol, side, maxNotional, real-order risk, and cancel cleanup behavior. The older `rapidx self-check trade-verify --json` command remains supported for compatibility.
137
+ Use `rapidx trade verify-live --json` only when the user explicitly authorizes a small real-trade verification. Include `acceptedRiskText` that names the exact symbol, side, positionSide when provided, maxNotional, real-order risk, and cancel cleanup behavior. The older `rapidx self-check trade-verify --json` command remains supported for compatibility.
@@ -4,7 +4,7 @@ The canonical source is `rapidx schema --json` or `rapidx/tools`.
4
4
 
5
5
  ## Discovery And Update
6
6
 
7
- - `rapidx/tools`: returns the MCP tool surface and schema metadata.
7
+ - `rapidx/tools`: returns the MCP tool surface and concrete `inputSchemas`.
8
8
  - `rapidx/self-check`: verifies discovery, schema, credentials, and optional read-only probes. Pass `checkUpdates=true` to include release manifest status.
9
9
  - `rapidx/update/check`: reads the RapidX release manifest, returns version status, minimum write version, skills update advice, and upgrade commands.
10
10
 
@@ -24,12 +24,46 @@ The canonical source is `rapidx schema --json` or `rapidx/tools`.
24
24
  - Position reads: list and position history.
25
25
  - Algo reads: list.
26
26
 
27
+ ## Symbol Format
28
+
29
+ Use RapidX symbols in tool inputs:
30
+
31
+ ```text
32
+ BINANCE_PERP_<BASE>_<QUOTE>
33
+ ```
34
+
35
+ `OKX_PERP_<BASE>_<QUOTE>` is also supported for OKX perpetual instruments. `OKX_SWAP_<BASE>_<QUOTE>` is accepted as an input alias and is normalized to `OKX_PERP_<BASE>_<QUOTE>` in preview matching and outputs.
36
+
37
+ Public market adapters may call venue APIs with official venue symbols such as `BTCUSDT` or `BTC-USDT-SWAP`. When the venue response uses a different symbol, RapidX returns canonical `symbol` plus `originalSymbol`.
38
+
27
39
  ## Write Tools
28
40
 
29
41
  - Order writes: place, amend, and cancel.
30
42
  - Position writes: close and set leverage.
31
43
  - Account writes: set position mode.
32
44
  - Algo writes: place, amend, and cancel.
33
- - Live verification: `rapidx/trade/verify-live` is the clearer alias for the small real-trade verification flow. It submits a real verification order and requires `acceptedRiskText` bound to the exact symbol, side, maxNotional, real-order risk, and cancel cleanup behavior. `rapidx/trading-verification` remains supported for compatibility.
45
+ - Live verification: `rapidx/trade/verify-live` is the clearer alias for the small real-trade verification flow. It submits a real verification order and requires `acceptedRiskText` bound to the exact symbol, side, maxNotional, real-order risk, and cancel cleanup behavior. If `positionSide` is provided, `acceptedRiskText` must include it. `rapidx/trading-verification` remains supported for compatibility.
34
46
 
35
47
  All write tools require preview where the schema marks `previewRequired: true`.
48
+ MARKET order writes are allowed after preview and consent. Preview includes immediate-execution and slippage risk notes; do not replace MARKET with a synthetic limit strategy unless the user explicitly asks for that order style.
49
+
50
+ For hedge-mode order placement, pass `positionSide="LONG"` or `positionSide="SHORT"` on the order or verify-live input. Use `account.set-position-mode` only when the user explicitly asks to change the account position mode.
51
+
52
+ Preview ids are runtime-local. A preview created by MCP must be submitted through the same MCP server runtime. A preview created by CLI must be submitted through the same CLI preview store. Do not mix MCP preview ids with CLI submit commands, or the reverse.
53
+
54
+ `order.cancel` is asynchronous. A successful cancel response means the cancel request was accepted; it may not prove a terminal order state yet. The response includes `cancelAccepted`, `terminalStateConfirmed`, `lastObservedOrderState`, and `recommendedAction`. Poll `order.get` until `CANCELED`, `REJECTED`, `EXPIRED`, or timeout when `terminalStateConfirmed=false`.
55
+
56
+ For automation, keep preview-first execution. Set `automationMode=true` and pass the user's exact `automationConsentText` only when the user has explicitly enabled RapidX automation mode in chat. The preview response still returns `confirmation.submitToken`; automation mode only means the agent may use that submit token without asking for another per-order chat confirmation within the authorized scope.
57
+
58
+ For TPSL or conditional algo orders, use `rapidx/trade/preview` with `targetCapabilityId="algo.place"`, then submit `rapidx/algo/place`. `conditionType="ENTIRE_CLOSE_POSITION"` may use `orderType="MARKET"` without `quantity` or `amount`; provide at least one take-profit or stop-loss trigger and verify with `rapidx/algo/list`.
59
+
60
+ ## Result Statuses
61
+
62
+ - `PASS`: the tool or command completed successfully.
63
+ - `INVALID_INPUT`: local schema or parameter validation failed. Fix the input before retrying.
64
+ - `BLOCKED`: local preview, safety, compatibility, or policy checks rejected the action before submission.
65
+ - `NOT_FOUND`: the requested order, position, or upstream resource was not found.
66
+ - `PERMISSION_SCOPE_ERROR`: credentials are valid but do not cover the requested scope, such as account-level balance with portfolio-scoped credentials.
67
+ - `BUSINESS_ERROR`: RapidX or venue business rules rejected the request.
68
+ - `NOT_VERIFIED`: the tool could not prove the requested state.
69
+ - `FAIL`: startup, auth, network, malformed response, or unexpected execution failure.
@@ -1,25 +1,25 @@
1
1
  {
2
- "version": "1.0.28",
2
+ "version": "1.0.29",
3
3
  "artifacts": [
4
4
  {
5
5
  "name": "rapidx-mcp-registry",
6
6
  "path": "packages/distribution/registry/rapidx.mcp.json",
7
7
  "channel": "offline",
8
- "checksum": "sha256:0e4bbf784d784442bd296e4ca6d490733ccd40e50f7b299b211b5fdb4dcb465d",
8
+ "checksum": "sha256:8a462f111ce2e1496b670978113277deeb49fc8ebcc9bfb2f9af3a91e5c8f9eb",
9
9
  "status": "ready"
10
10
  },
11
11
  {
12
12
  "name": "rapidx-quickstart-doc",
13
13
  "path": "packages/distribution/docs/quickstart.md",
14
14
  "channel": "offline",
15
- "checksum": "sha256:0f78bb814c60ec3f5ac1053cac49c1c1e768ff529b70b32e44a31f96ad8a1e95",
15
+ "checksum": "sha256:f1771cbc6e3da39b47afac839ca89fc063bede11ac9d8078b215145953c0145c",
16
16
  "status": "ready"
17
17
  },
18
18
  {
19
19
  "name": "rapidx-tools-doc",
20
20
  "path": "packages/distribution/docs/tools.md",
21
21
  "channel": "offline",
22
- "checksum": "sha256:ab953a5e40024e9171ad7510bd37fef20e6aa9c6d89bfc219160cb33bb465712",
22
+ "checksum": "sha256:e6ba0a1cbafa47fef2d6a2de6baffeb0a786d1d38886961c1347b9ffbd870e54",
23
23
  "status": "ready"
24
24
  }
25
25
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rapidx",
3
3
  "packageName": "@liquiditytech/rapidx-cli",
4
- "version": "1.0.28",
4
+ "version": "1.0.29",
5
5
  "command": "rapidx",
6
6
  "args": ["mcp", "serve"],
7
7
  "launchCommand": "rapidx",