@liquiditytech/rapidx-cli 1.0.32 → 1.0.34
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/commands/algo.js +1 -0
- package/dist/cli/commands/index.js +4 -0
- package/dist/cli/commands/order.js +3 -3
- package/dist/cli/commands/transaction.js +23 -0
- package/dist/cli/commands/update.js +3 -0
- package/dist/cli/help.js +2 -2
- package/dist/core/client/capability-executor.js +32 -4
- package/dist/core/contracts/capabilities.js +2 -2
- package/dist/core/contracts/compatibility.js +1 -1
- package/dist/core/contracts/input-schema.js +12 -6
- package/dist/core/safety/policy.js +1 -3
- package/dist/core/trading/preview-preflight.js +0 -1
- package/dist/core/trading/preview.js +2 -2
- package/dist/core/trading/trading-verification.js +2 -2
- package/dist/core/update/check-update.js +77 -10
- package/dist/core/version.js +1 -1
- package/dist/mcp/tool-registry.js +46 -1
- package/dist/mcp/tool-runner.js +6 -3
- package/package.json +1 -1
- package/packages/distribution/docs/cli.md +31 -0
- package/packages/distribution/docs/mcp.md +5 -3
- package/packages/distribution/docs/skills.md +1 -1
- package/packages/distribution/docs/tools.md +7 -4
- package/packages/distribution/docs/troubleshooting/index.md +74 -3
- package/packages/distribution/manifests/offline-manifest.json +3 -3
- package/packages/distribution/registry/rapidx.mcp.json +1 -1
|
@@ -11,6 +11,7 @@ import { runPositionCommand } from "./position.js";
|
|
|
11
11
|
import { runSchemaCommand } from "./schema.js";
|
|
12
12
|
import { runSelfCheckCommand, runTradingVerificationCommand } from "./self-check.js";
|
|
13
13
|
import { runTradeCommand } from "./trade.js";
|
|
14
|
+
import { runTransactionCommand } from "./transaction.js";
|
|
14
15
|
import { runUpdateCommand } from "./update.js";
|
|
15
16
|
export async function dispatchCli(parsed) {
|
|
16
17
|
const [domain, action, subAction] = parsed.commandParts;
|
|
@@ -63,6 +64,9 @@ export async function dispatchCli(parsed) {
|
|
|
63
64
|
if (domain === "trade") {
|
|
64
65
|
return runTradeCommand(action ?? "preview", parsed.input);
|
|
65
66
|
}
|
|
67
|
+
if (domain === "transaction") {
|
|
68
|
+
return runTransactionCommand(action ?? "executions", parsed.input);
|
|
69
|
+
}
|
|
66
70
|
if (domain === "position") {
|
|
67
71
|
return runPositionCommand(action ?? "query", parsed.input);
|
|
68
72
|
}
|
|
@@ -5,10 +5,10 @@ const safetyState = makeSafetyState();
|
|
|
5
5
|
export async function runOrderCommand(action, input) {
|
|
6
6
|
const previewStoreFile = resolvePreviewStoreFile();
|
|
7
7
|
const previewStore = loadPreviewStoreFromFile(previewStoreFile);
|
|
8
|
-
if (action === "
|
|
9
|
-
const capability = findCapabilityById("order.preview");
|
|
8
|
+
if (action === "place-preview") {
|
|
9
|
+
const capability = findCapabilityById("order.place-preview");
|
|
10
10
|
if (!capability) {
|
|
11
|
-
return fail("RCLI30001", "order.preview capability missing.");
|
|
11
|
+
return fail("RCLI30001", "order.place-preview capability missing.");
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
14
|
const preview = createTradePreview(capability, input, { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false }, safetyState, previewStore);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { executeRapidXCapability, findCapabilityById, normalizeUnknownError, publicErrorDetails } from "../../core/index.js";
|
|
2
|
+
import { fail, ok } from "../envelope.js";
|
|
3
|
+
const TRANSACTION_CAPABILITY_BY_ACTION = {
|
|
4
|
+
executions: "transaction.executions"
|
|
5
|
+
};
|
|
6
|
+
export async function runTransactionCommand(action, input) {
|
|
7
|
+
const capabilityId = TRANSACTION_CAPABILITY_BY_ACTION[action];
|
|
8
|
+
if (!capabilityId) {
|
|
9
|
+
return fail("RCLI12001", `Unknown transaction command: ${action}`, "FAIL", `rapidx transaction ${action}`);
|
|
10
|
+
}
|
|
11
|
+
const capability = findCapabilityById(capabilityId);
|
|
12
|
+
if (!capability) {
|
|
13
|
+
return fail("RCLI30002", `Missing capability: ${capabilityId}`, "FAIL", `rapidx transaction ${action}`);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const data = await executeRapidXCapability(capabilityId, input);
|
|
17
|
+
return ok(data, `rapidx transaction ${action}`, "PASS", "real_tool_call");
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const productError = normalizeUnknownError(error, "RCLI12001");
|
|
21
|
+
return fail(productError.code.replace(/^RCORE/, "RCLI"), productError.message, productError.status, `rapidx transaction ${action}`, publicErrorDetails(productError));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -13,6 +13,9 @@ export async function runUpdateCommand(action, input) {
|
|
|
13
13
|
if (typeof input.maxCacheAgeSeconds === "number") {
|
|
14
14
|
updateInput.maxCacheAgeSeconds = input.maxCacheAgeSeconds;
|
|
15
15
|
}
|
|
16
|
+
if (typeof input.installedSkillsVersion === "string") {
|
|
17
|
+
updateInput.installedSkillsVersion = input.installedSkillsVersion;
|
|
18
|
+
}
|
|
16
19
|
const result = await checkForUpdate(updateInput);
|
|
17
20
|
return ok(result, "rapidx update check --json", envelopeStatusForUpdate(result.status));
|
|
18
21
|
}
|
package/dist/cli/help.js
CHANGED
|
@@ -11,14 +11,14 @@ export function formatCliHelp() {
|
|
|
11
11
|
" rapidx self-check --input '{\"scope\":\"deep\"}' --json",
|
|
12
12
|
" rapidx market get-ticker --input '{\"symbol\":\"BINANCE_PERP_BTC_USDT\"}' --json",
|
|
13
13
|
" rapidx market get-ticker --symbol BINANCE_PERP_BTC_USDT --json",
|
|
14
|
-
" rapidx order preview --input '{\"symbol\":\"BINANCE_PERP_BTC_USDT\",\"side\":\"BUY\",\"orderType\":\"LIMIT\",\"price\":\"1\",\"quantity\":\"0.001\",\"maxNotional\":\"1\",\"clientOrderId\":\"example\"}' --json",
|
|
14
|
+
" rapidx order place-preview --input '{\"symbol\":\"BINANCE_PERP_BTC_USDT\",\"side\":\"BUY\",\"orderType\":\"LIMIT\",\"price\":\"1\",\"quantity\":\"0.001\",\"maxNotional\":\"1\",\"clientOrderId\":\"example\"}' --json",
|
|
15
15
|
" rapidx order cancel-preview --input '{\"orderId\":\"<order-id>\"}' --json",
|
|
16
16
|
" rapidx trade verify-live --input '{\"symbol\":\"BINANCE_PERP_BTC_USDT\",\"side\":\"BUY\",\"maxNotional\":\"10\",\"clientOrderId\":\"verify-001\",\"explicitUserConsent\":true,\"acceptedRiskText\":\"I authorize a real verification order for BINANCE_PERP_BTC_USDT BUY maxNotional 10 with cancel cleanup.\"}' --json",
|
|
17
17
|
" rapidx mcp serve",
|
|
18
18
|
"",
|
|
19
19
|
"Domains:",
|
|
20
20
|
" schema, doctor, auth, config, update, self-check, invocation",
|
|
21
|
-
" market, portfolio, order, trade, position, algo",
|
|
21
|
+
" market, portfolio, order, transaction, trade, position, algo",
|
|
22
22
|
"",
|
|
23
23
|
"Use --input for structured JSON. Named options such as --symbol and --depth are also accepted for simple inputs."
|
|
24
24
|
].join("\n");
|
|
@@ -47,8 +47,8 @@ export async function executeRapidXCapability(capabilityId, input = {}, options
|
|
|
47
47
|
case "order.open-orders":
|
|
48
48
|
return client.get("/api/v1/trading/orders", orderListParams(input, "1000"));
|
|
49
49
|
case "order.history":
|
|
50
|
-
return client.get("/api/v1/trading/history/orders",
|
|
51
|
-
case "
|
|
50
|
+
return client.get("/api/v1/trading/history/orders", orderHistoryParams(input));
|
|
51
|
+
case "transaction.executions":
|
|
52
52
|
return client.get("/api/v1/trading/executions", executionParams(input));
|
|
53
53
|
case "position.query":
|
|
54
54
|
return executePositionListCapability(client, input);
|
|
@@ -76,6 +76,8 @@ export async function executeRapidXCapability(capabilityId, input = {}, options
|
|
|
76
76
|
return client.delete("/api/v1/algo/order", optionalParams(input, ["algoOrderId", "clientOrderId"]));
|
|
77
77
|
case "algo.open-orders":
|
|
78
78
|
return client.get("/api/v1/algo/openOrders", algoListParams(input));
|
|
79
|
+
case "algo.history":
|
|
80
|
+
return client.get("/api/v1/algo/history/orders", algoHistoryParams(input));
|
|
79
81
|
case "algo.query":
|
|
80
82
|
return client.get("/api/v1/algo/order", optionalParams(input, ["algoOrderId", "clientOrderId", "attachedOrderId"]));
|
|
81
83
|
default:
|
|
@@ -321,14 +323,28 @@ function orderListParams(input, defaultPageSize) {
|
|
|
321
323
|
])
|
|
322
324
|
};
|
|
323
325
|
}
|
|
326
|
+
function orderHistoryParams(input) {
|
|
327
|
+
return {
|
|
328
|
+
pageSize: stringValue(input.pageSize, "1000"),
|
|
329
|
+
...mappedOptionalParams(input, [
|
|
330
|
+
["symbol", "sym"],
|
|
331
|
+
["exchange", "exchange"],
|
|
332
|
+
["businessType", "businessType"],
|
|
333
|
+
["begin", "begin"],
|
|
334
|
+
["end", "end"],
|
|
335
|
+
["page", "page"],
|
|
336
|
+
["filterExecuted", "filterExecuted"]
|
|
337
|
+
])
|
|
338
|
+
};
|
|
339
|
+
}
|
|
324
340
|
function executionParams(input) {
|
|
325
341
|
return mappedOptionalParams(input, [
|
|
326
342
|
["orderId", "orderId"],
|
|
327
343
|
["symbol", "sym"],
|
|
328
344
|
["exchange", "exchange"],
|
|
329
345
|
["businessType", "businessType"],
|
|
330
|
-
["
|
|
331
|
-
["
|
|
346
|
+
["begin", "begin"],
|
|
347
|
+
["end", "end"],
|
|
332
348
|
["limit", "limit"]
|
|
333
349
|
]);
|
|
334
350
|
}
|
|
@@ -404,6 +420,18 @@ function algoListParams(input) {
|
|
|
404
420
|
["pageSize", "pageSize"]
|
|
405
421
|
]);
|
|
406
422
|
}
|
|
423
|
+
function algoHistoryParams(input) {
|
|
424
|
+
return mappedOptionalParams(input, [
|
|
425
|
+
["symbol", "sym"],
|
|
426
|
+
["exchange", "exchange"],
|
|
427
|
+
["businessType", "businessType"],
|
|
428
|
+
["algoOrderType", "algoOrderType"],
|
|
429
|
+
["begin", "begin"],
|
|
430
|
+
["end", "end"],
|
|
431
|
+
["page", "page"],
|
|
432
|
+
["pageSize", "pageSize"]
|
|
433
|
+
]);
|
|
434
|
+
}
|
|
407
435
|
function positionHistoryParams(input) {
|
|
408
436
|
const params = mappedOptionalParams(input, [
|
|
409
437
|
["startTime", "begin"],
|
|
@@ -24,7 +24,6 @@ export const CAPABILITIES = [
|
|
|
24
24
|
{ capabilityId: "portfolio.position-bracket", cliCommand: "rapidx portfolio position-bracket", mcpTool: "rapidx/portfolio/position-bracket", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "PositionBracketInput", outputSchema: "PositionBracket", previewRequired: false },
|
|
25
25
|
{ capabilityId: "portfolio.set-position-mode", cliCommand: "rapidx portfolio set-position-mode", mcpTool: "rapidx/portfolio/set-position-mode", operationType: "TRADE_WRITE", riskLevel: "critical-trade-write", inputSchema: "SetPositionModeInput", outputSchema: "SetPositionModeResult", previewRequired: true },
|
|
26
26
|
{ capabilityId: "trade.preview", cliCommand: "rapidx trade preview", mcpTool: "rapidx/trade/preview", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "TradePreviewInput", outputSchema: "TradePreviewResult", previewRequired: false },
|
|
27
|
-
{ capabilityId: "order.preview", cliCommand: "rapidx order preview", mcpTool: "rapidx/order/preview", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "PreviewOrderInput", outputSchema: "PreviewOrderResult", previewRequired: false },
|
|
28
27
|
{ capabilityId: "order.place-preview", cliCommand: "rapidx order place-preview", mcpTool: "rapidx/order/place-preview", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "PreviewOrderInput", outputSchema: "PreviewOrderResult", previewRequired: false },
|
|
29
28
|
{ capabilityId: "order.replace-preview", cliCommand: "rapidx order replace-preview", mcpTool: "rapidx/order/replace-preview", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "ReplaceOrderPreviewInput", outputSchema: "TradePreviewResult", previewRequired: false },
|
|
30
29
|
{ capabilityId: "order.cancel-preview", cliCommand: "rapidx order cancel-preview", mcpTool: "rapidx/order/cancel-preview", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "CancelOrderPreviewInput", outputSchema: "TradePreviewResult", previewRequired: false },
|
|
@@ -35,7 +34,7 @@ export const CAPABILITIES = [
|
|
|
35
34
|
{ capabilityId: "order.query", cliCommand: "rapidx order query", mcpTool: "rapidx/order/query", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "OrderLookupInput", outputSchema: "OrderStatusResult", previewRequired: false },
|
|
36
35
|
{ capabilityId: "order.open-orders", cliCommand: "rapidx order open-orders", mcpTool: "rapidx/order/open-orders", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "OrderListInput", outputSchema: "OrderList", previewRequired: false },
|
|
37
36
|
{ capabilityId: "order.history", cliCommand: "rapidx order history", mcpTool: "rapidx/order/history", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "OrderHistoryInput", outputSchema: "OrderHistory", previewRequired: false },
|
|
38
|
-
{ capabilityId: "
|
|
37
|
+
{ capabilityId: "transaction.executions", cliCommand: "rapidx transaction executions", mcpTool: "rapidx/transaction/executions", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "ExecutionListInput", outputSchema: "ExecutionList", previewRequired: false },
|
|
39
38
|
{ capabilityId: "position.query", cliCommand: "rapidx position query", mcpTool: "rapidx/position/query", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "PositionListInput", outputSchema: "PositionList", previewRequired: false },
|
|
40
39
|
{ capabilityId: "position.history", cliCommand: "rapidx position history", mcpTool: "rapidx/position/history", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "PositionHistoryInput", outputSchema: "PositionHistory", previewRequired: false },
|
|
41
40
|
{ capabilityId: "position.get-leverage", cliCommand: "rapidx position get-leverage", mcpTool: "rapidx/position/get-leverage", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "SymbolInput", outputSchema: "PositionLeverage", previewRequired: false },
|
|
@@ -46,6 +45,7 @@ export const CAPABILITIES = [
|
|
|
46
45
|
{ capabilityId: "algo.replace", cliCommand: "rapidx algo replace", mcpTool: "rapidx/algo/replace", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "AlgoReplaceInput", outputSchema: "AlgoOrderStatus", previewRequired: true },
|
|
47
46
|
{ capabilityId: "algo.cancel", cliCommand: "rapidx algo cancel", mcpTool: "rapidx/algo/cancel", operationType: "TRADE_WRITE", riskLevel: "trade-write", inputSchema: "AlgoCancelInput", outputSchema: "AlgoOrderStatus", previewRequired: true },
|
|
48
47
|
{ capabilityId: "algo.open-orders", cliCommand: "rapidx algo open-orders", mcpTool: "rapidx/algo/open-orders", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "AlgoListInput", outputSchema: "AlgoList", previewRequired: false },
|
|
48
|
+
{ capabilityId: "algo.history", cliCommand: "rapidx algo history", mcpTool: "rapidx/algo/history", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "AlgoHistoryInput", outputSchema: "AlgoHistory", previewRequired: false },
|
|
49
49
|
{ capabilityId: "algo.query", cliCommand: "rapidx algo query", mcpTool: "rapidx/algo/query", operationType: "TRADE_READ", riskLevel: "trade-read", inputSchema: "AlgoLookupInput", outputSchema: "AlgoOrderStatus", previewRequired: false },
|
|
50
50
|
{ capabilityId: "trading.verify", cliCommand: "rapidx self-check trade-verify", mcpTool: "rapidx/trading-verification", operationType: "TRADE_WRITE", riskLevel: "critical-trade-write", inputSchema: "TradingVerificationInput", outputSchema: "TradingVerificationReport", previewRequired: false, containsRealOrder: true, requiresExplicitHumanConfirmation: true, confirmationMode: "internal-preview-and-parameter-bound-consent" },
|
|
51
51
|
{ capabilityId: "trading.verify-live", cliCommand: "rapidx trade verify-live", mcpTool: "rapidx/trade/verify-live", operationType: "TRADE_WRITE", riskLevel: "critical-trade-write", inputSchema: "TradingVerificationInput", outputSchema: "TradingVerificationReport", previewRequired: false, containsRealOrder: true, requiresExplicitHumanConfirmation: true, confirmationMode: "internal-preview-and-parameter-bound-consent" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SCHEMA_VERSION } from "./types.js";
|
|
2
2
|
import { RAPIDX_VERSION } from "../version.js";
|
|
3
3
|
export const RAPIDX_SKILLS_DISTRIBUTION = "github";
|
|
4
|
-
export const RAPIDX_SKILLS_VERSION = "1.0.
|
|
4
|
+
export const RAPIDX_SKILLS_VERSION = "1.0.9";
|
|
5
5
|
export const RAPIDX_SKILLS_SCHEMA_VERSION = "1.0.0";
|
|
6
6
|
export function buildCompatibilityReport(input = {}) {
|
|
7
7
|
const checks = [
|
|
@@ -92,11 +92,14 @@ const exchangeTypeSchema = { type: "string", description: "RapidX exchange type,
|
|
|
92
92
|
const businessTypeSchema = { type: "string", description: "RapidX business type, for example PERP." };
|
|
93
93
|
const pageSchema = { type: "number", description: "1-based page number." };
|
|
94
94
|
const pageSizeSchema = { type: "number", description: "Page size." };
|
|
95
|
-
const startTimeSchema = { type: "string", description: "
|
|
96
|
-
const endTimeSchema = { type: "string", description: "
|
|
95
|
+
const startTimeSchema = { type: "string", description: "Optional time range start timestamp accepted by the RapidX API. If omitted, the upstream server default range applies." };
|
|
96
|
+
const endTimeSchema = { type: "string", description: "Optional time range end timestamp accepted by the RapidX API. If omitted, the upstream server default range applies." };
|
|
97
|
+
const beginSchema = { type: "string", description: "Official RapidX begin timestamp in milliseconds for the query window. If omitted, RapidX defaults to up to 7 days ago." };
|
|
98
|
+
const endSchema = { type: "string", description: "Official RapidX end timestamp in milliseconds for the query window. If omitted, RapidX uses the current time." };
|
|
97
99
|
const coinSchema = { type: "string", description: "Asset coin, for example USDT." };
|
|
98
100
|
const statementTypeSchema = { type: "string", description: "RapidX statement type filter." };
|
|
99
101
|
const filterExecutedSchema = { type: "boolean", description: "Whether to filter executed order history where the endpoint supports it." };
|
|
102
|
+
const algoOrderTypeSchema = { type: "string", description: "RapidX algo order type filter." };
|
|
100
103
|
const closeAllPositionsSchema = { type: "boolean", description: "When true, requests RapidX to close all positions allowed by the provided filters." };
|
|
101
104
|
const symbolListSchema = { type: "string", description: "Comma-separated RapidX symbols for close-all position requests." };
|
|
102
105
|
const closeAllPositionSideSchema = {
|
|
@@ -135,15 +138,18 @@ export function inputSchemaForName(name) {
|
|
|
135
138
|
anyOf: [{ required: ["orderId"] }, { required: ["clientOrderId"] }]
|
|
136
139
|
};
|
|
137
140
|
case "OrderListInput":
|
|
138
|
-
case "OrderHistoryInput":
|
|
139
141
|
return objectSchema({ symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, page: pageSchema, pageSize: pageSizeSchema, startTime: startTimeSchema, endTime: endTimeSchema, filterExecuted: filterExecutedSchema });
|
|
142
|
+
case "OrderHistoryInput":
|
|
143
|
+
return objectSchema({ symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, page: pageSchema, pageSize: pageSizeSchema, begin: beginSchema, end: endSchema, filterExecuted: filterExecutedSchema });
|
|
140
144
|
case "ExecutionListInput":
|
|
141
|
-
return objectSchema({ orderId: orderIdSchema, symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, limit: numberSchema,
|
|
145
|
+
return objectSchema({ orderId: orderIdSchema, symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, limit: numberSchema, begin: beginSchema, end: endSchema });
|
|
142
146
|
case "StatementInput":
|
|
143
147
|
return objectSchema({ coin: coinSchema, symbol: symbolSchema, statementType: statementTypeSchema, exchange: stringSchema, page: pageSchema, pageSize: pageSizeSchema, startTime: startTimeSchema, endTime: endTimeSchema });
|
|
144
|
-
case "PositionListInput":
|
|
145
148
|
case "AlgoListInput":
|
|
149
|
+
case "PositionListInput":
|
|
146
150
|
return objectSchema({ symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, page: pageSchema, pageSize: pageSizeSchema, startTime: startTimeSchema, endTime: endTimeSchema });
|
|
151
|
+
case "AlgoHistoryInput":
|
|
152
|
+
return objectSchema({ symbol: symbolSchema, exchange: stringSchema, businessType: businessTypeSchema, algoOrderType: algoOrderTypeSchema, begin: beginSchema, end: endSchema, page: pageSchema, pageSize: pageSizeSchema });
|
|
147
153
|
case "PositionHistoryInput":
|
|
148
154
|
return objectSchema({ symbol: symbolSchema, pageSize: pageSizeSchema, startTime: startTimeSchema, endTime: endTimeSchema });
|
|
149
155
|
case "TradePreviewInput":
|
|
@@ -305,7 +311,7 @@ export function inputSchemaForName(name) {
|
|
|
305
311
|
case "InvocationCheckInput":
|
|
306
312
|
return objectSchema({ commandLine: stringSchema, preflightError: stringSchema });
|
|
307
313
|
case "UpdateCheckInput":
|
|
308
|
-
return objectSchema({ force: booleanSchema, manifestUrl: stringSchema, maxCacheAgeSeconds: numberSchema });
|
|
314
|
+
return objectSchema({ force: booleanSchema, manifestUrl: stringSchema, maxCacheAgeSeconds: numberSchema, installedSkillsVersion: stringSchema });
|
|
309
315
|
case "SchemaQuery":
|
|
310
316
|
return objectSchema({ consumer: stringSchema, consumerVersion: stringSchema, includeExamples: booleanSchema });
|
|
311
317
|
case "SelfCheckInput":
|
|
@@ -105,7 +105,6 @@ export function evaluateSafety(capability, input, policy, state = makeSafetyStat
|
|
|
105
105
|
function requiredTradeFields(capability, input) {
|
|
106
106
|
const missing = [];
|
|
107
107
|
switch (capability.capabilityId) {
|
|
108
|
-
case "order.preview":
|
|
109
108
|
case "order.place-preview":
|
|
110
109
|
case "order.place":
|
|
111
110
|
case "algo.place":
|
|
@@ -164,8 +163,7 @@ function requiredTradeFields(capability, input) {
|
|
|
164
163
|
return missing;
|
|
165
164
|
}
|
|
166
165
|
function requiresNotionalLimit(capability) {
|
|
167
|
-
return capability.capabilityId === "order.preview"
|
|
168
|
-
|| capability.capabilityId === "order.place-preview"
|
|
166
|
+
return capability.capabilityId === "order.place-preview"
|
|
169
167
|
|| capability.capabilityId === "order.place"
|
|
170
168
|
|| capability.capabilityId === "algo.place"
|
|
171
169
|
|| capability.capabilityId === "position.close";
|
|
@@ -4,7 +4,6 @@ import { parseRapidXSymbol } from "../client/symbol.js";
|
|
|
4
4
|
import { ProductError } from "../errors/product-error.js";
|
|
5
5
|
export async function runPreviewPreflight(capabilityId, input, options = {}) {
|
|
6
6
|
switch (capabilityId) {
|
|
7
|
-
case "order.preview":
|
|
8
7
|
case "order.place-preview":
|
|
9
8
|
case "order.place":
|
|
10
9
|
case "algo.place":
|
|
@@ -156,7 +156,7 @@ export function verifyPreview(store, previewId, capability, input, now = new Dat
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
const capabilityMatches = record.capabilityId === capability.capabilityId
|
|
159
|
-
|| (
|
|
159
|
+
|| (record.capabilityId === "order.place-preview" && capability.capabilityId === "order.place");
|
|
160
160
|
if (!capabilityMatches) {
|
|
161
161
|
throw new ProductError({
|
|
162
162
|
code: "RCORE20002",
|
|
@@ -203,7 +203,7 @@ function makePreviewDetails(capability, tradeParams, automation) {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
function makeRequestSummary(capabilityId, params) {
|
|
206
|
-
if (capabilityId === "order.
|
|
206
|
+
if (capabilityId === "order.place-preview" || capabilityId === "order.place") {
|
|
207
207
|
return compactRecord({
|
|
208
208
|
action: "place_order",
|
|
209
209
|
symbol: params.symbol,
|
|
@@ -62,9 +62,9 @@ export async function runTradingVerification(rawInput, probes = {}) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
steps.push({ name: "market", status: "PASS", toolOrCommandEvidence: `minNotional=${marketRules.minNotional};tickSize=${marketRules.tickSize}` });
|
|
65
|
-
const capability = findCapabilityById("order.preview");
|
|
65
|
+
const capability = findCapabilityById("order.place-preview");
|
|
66
66
|
if (!capability) {
|
|
67
|
-
throw new Error("Missing order.preview capability");
|
|
67
|
+
throw new Error("Missing order.place-preview capability");
|
|
68
68
|
}
|
|
69
69
|
const policy = { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false, maxNotional: input.maxNotional };
|
|
70
70
|
const price = marketRules.orderPrice ?? (input.side === "BUY" ? marketRules.bestBid : marketRules.bestAsk);
|
|
@@ -13,11 +13,14 @@ export async function checkForUpdate(input = {}, env = process.env, cwd = proces
|
|
|
13
13
|
const cacheFile = resolveUpdateCacheFile(env, cwd);
|
|
14
14
|
const cached = loadCachedUpdateState(cacheFile);
|
|
15
15
|
if (!input.force && cached && !isCacheExpired(cached, cacheTtlSeconds)) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const manifest = cached.manifest ?? manifestFromCachedResult(cached.result);
|
|
17
|
+
return buildUpdateCheckResult(manifest, {
|
|
18
|
+
checkedAt: cached.checkedAt,
|
|
19
|
+
cacheTtlSeconds,
|
|
20
|
+
manifestUrl,
|
|
18
21
|
manifestSource: "cache",
|
|
19
|
-
|
|
20
|
-
};
|
|
22
|
+
installedSkillsVersion: input.installedSkillsVersion
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
try {
|
|
23
26
|
const manifest = await fetchReleaseManifest(manifestUrl);
|
|
@@ -25,29 +28,35 @@ export async function checkForUpdate(input = {}, env = process.env, cwd = proces
|
|
|
25
28
|
checkedAt: new Date().toISOString(),
|
|
26
29
|
cacheTtlSeconds,
|
|
27
30
|
manifestUrl,
|
|
28
|
-
manifestSource: "remote"
|
|
31
|
+
manifestSource: "remote",
|
|
32
|
+
installedSkillsVersion: input.installedSkillsVersion
|
|
29
33
|
});
|
|
30
34
|
saveCachedUpdateState(cacheFile, {
|
|
31
35
|
checkedAt: result.checkedAt,
|
|
32
36
|
cacheTtlSeconds,
|
|
37
|
+
manifest,
|
|
33
38
|
result
|
|
34
39
|
});
|
|
35
40
|
return result;
|
|
36
41
|
}
|
|
37
42
|
catch (error) {
|
|
38
43
|
if (cached) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const manifest = cached.manifest ?? manifestFromCachedResult(cached.result);
|
|
45
|
+
return buildUpdateCheckResult(manifest, {
|
|
46
|
+
checkedAt: cached.checkedAt,
|
|
42
47
|
cacheTtlSeconds,
|
|
48
|
+
manifestUrl,
|
|
49
|
+
manifestSource: "cache",
|
|
50
|
+
installedSkillsVersion: input.installedSkillsVersion,
|
|
43
51
|
error: error instanceof Error ? error.message : String(error)
|
|
44
|
-
};
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
return buildUnknownUpdateCheckResult({
|
|
47
55
|
checkedAt: new Date().toISOString(),
|
|
48
56
|
cacheTtlSeconds,
|
|
49
57
|
manifestUrl,
|
|
50
58
|
manifestSource: "fallback",
|
|
59
|
+
installedSkillsVersion: input.installedSkillsVersion,
|
|
51
60
|
error: error instanceof Error ? error.message : String(error)
|
|
52
61
|
});
|
|
53
62
|
}
|
|
@@ -62,6 +71,11 @@ export function buildUpdateCheckResult(manifest, metadata) {
|
|
|
62
71
|
minimumWriteVersion
|
|
63
72
|
});
|
|
64
73
|
const writeAllowed = status !== "WRITE_BLOCKED";
|
|
74
|
+
const installedSkillsVersion = normalizeInstalledSkillsVersion(metadata.installedSkillsVersion);
|
|
75
|
+
const skillsInstallStatus = computeSkillsInstallStatus(installedSkillsVersion, manifest.skillsVersion);
|
|
76
|
+
const skillsUpdateRecommended = manifest.skillsUpdateRecommended
|
|
77
|
+
|| skillsInstallStatus === "UPDATE_AVAILABLE"
|
|
78
|
+
|| (skillsInstallStatus === "NOT_VERIFIED" && compareVersions(RAPIDX_SKILLS_VERSION, manifest.skillsVersion) < 0);
|
|
65
79
|
return {
|
|
66
80
|
currentVersion: RAPIDX_VERSION,
|
|
67
81
|
latestVersion: manifest.latestCliVersion,
|
|
@@ -71,6 +85,10 @@ export function buildUpdateCheckResult(manifest, metadata) {
|
|
|
71
85
|
currentMcpSchemaVersion: SCHEMA_VERSION,
|
|
72
86
|
skillsVersion: manifest.skillsVersion,
|
|
73
87
|
currentSkillsVersion: RAPIDX_SKILLS_VERSION,
|
|
88
|
+
latestSkillsVersion: manifest.skillsVersion,
|
|
89
|
+
bundledExpectedSkillsVersion: RAPIDX_SKILLS_VERSION,
|
|
90
|
+
installedSkillsVersion,
|
|
91
|
+
skillsInstallStatus,
|
|
74
92
|
skillsSchemaVersion: manifest.skillsSchemaVersion,
|
|
75
93
|
currentSkillsSchemaVersion: RAPIDX_SKILLS_SCHEMA_VERSION,
|
|
76
94
|
updateAvailable: compareVersions(RAPIDX_VERSION, manifest.latestCliVersion) < 0,
|
|
@@ -82,9 +100,12 @@ export function buildUpdateCheckResult(manifest, metadata) {
|
|
|
82
100
|
cacheTtlSeconds: metadata.cacheTtlSeconds,
|
|
83
101
|
manifestUrl: metadata.manifestUrl,
|
|
84
102
|
manifestSource: metadata.manifestSource,
|
|
103
|
+
updateFreshness: freshnessForSource(metadata.manifestSource),
|
|
104
|
+
refreshCommand: "rapidx update check --input '{\"force\":true}' --json",
|
|
85
105
|
releaseNotesUrl: manifest.releaseNotesUrl,
|
|
86
|
-
skillsUpdateRecommended
|
|
106
|
+
skillsUpdateRecommended,
|
|
87
107
|
upgrade: manifest.upgrade,
|
|
108
|
+
...(metadata.manifestSource === "cache" ? { cacheWarning: "Result came from local cache. Use force=true to refresh the remote release manifest." } : {}),
|
|
88
109
|
...(metadata.error ? { error: metadata.error } : {})
|
|
89
110
|
};
|
|
90
111
|
}
|
|
@@ -160,6 +181,8 @@ function fallbackManifest() {
|
|
|
160
181
|
}
|
|
161
182
|
function buildUnknownUpdateCheckResult(metadata) {
|
|
162
183
|
const manifest = fallbackManifest();
|
|
184
|
+
const installedSkillsVersion = normalizeInstalledSkillsVersion(metadata.installedSkillsVersion);
|
|
185
|
+
const skillsInstallStatus = computeSkillsInstallStatus(installedSkillsVersion, manifest.skillsVersion);
|
|
163
186
|
return {
|
|
164
187
|
currentVersion: RAPIDX_VERSION,
|
|
165
188
|
latestVersion: RAPIDX_VERSION,
|
|
@@ -169,6 +192,10 @@ function buildUnknownUpdateCheckResult(metadata) {
|
|
|
169
192
|
currentMcpSchemaVersion: SCHEMA_VERSION,
|
|
170
193
|
skillsVersion: manifest.skillsVersion,
|
|
171
194
|
currentSkillsVersion: RAPIDX_SKILLS_VERSION,
|
|
195
|
+
latestSkillsVersion: manifest.skillsVersion,
|
|
196
|
+
bundledExpectedSkillsVersion: RAPIDX_SKILLS_VERSION,
|
|
197
|
+
installedSkillsVersion,
|
|
198
|
+
skillsInstallStatus,
|
|
172
199
|
skillsSchemaVersion: manifest.skillsSchemaVersion,
|
|
173
200
|
currentSkillsSchemaVersion: RAPIDX_SKILLS_SCHEMA_VERSION,
|
|
174
201
|
updateAvailable: false,
|
|
@@ -180,6 +207,8 @@ function buildUnknownUpdateCheckResult(metadata) {
|
|
|
180
207
|
cacheTtlSeconds: metadata.cacheTtlSeconds,
|
|
181
208
|
manifestUrl: metadata.manifestUrl,
|
|
182
209
|
manifestSource: metadata.manifestSource,
|
|
210
|
+
updateFreshness: freshnessForSource(metadata.manifestSource),
|
|
211
|
+
refreshCommand: "rapidx update check --input '{\"force\":true}' --json",
|
|
183
212
|
releaseNotesUrl: "",
|
|
184
213
|
skillsUpdateRecommended: false,
|
|
185
214
|
upgrade: {},
|
|
@@ -198,6 +227,41 @@ function computeUpdateStatus(input) {
|
|
|
198
227
|
}
|
|
199
228
|
return "CURRENT";
|
|
200
229
|
}
|
|
230
|
+
function computeSkillsInstallStatus(installedSkillsVersion, latestSkillsVersion) {
|
|
231
|
+
if (installedSkillsVersion === "NOT_VERIFIED") {
|
|
232
|
+
return "NOT_VERIFIED";
|
|
233
|
+
}
|
|
234
|
+
return compareVersions(installedSkillsVersion, latestSkillsVersion) < 0 ? "UPDATE_AVAILABLE" : "CURRENT";
|
|
235
|
+
}
|
|
236
|
+
function normalizeInstalledSkillsVersion(value) {
|
|
237
|
+
return typeof value === "string" && isSemver(value) ? value : "NOT_VERIFIED";
|
|
238
|
+
}
|
|
239
|
+
function freshnessForSource(source) {
|
|
240
|
+
if (source === "remote") {
|
|
241
|
+
return "REMOTE";
|
|
242
|
+
}
|
|
243
|
+
if (source === "cache") {
|
|
244
|
+
return "CACHE";
|
|
245
|
+
}
|
|
246
|
+
return "FALLBACK";
|
|
247
|
+
}
|
|
248
|
+
function manifestFromCachedResult(result) {
|
|
249
|
+
return {
|
|
250
|
+
product: "rapidx",
|
|
251
|
+
channel: "stable",
|
|
252
|
+
latestCliVersion: result.latestVersion,
|
|
253
|
+
minimumSupportedVersion: result.minimumSupportedVersion,
|
|
254
|
+
minimumWriteVersion: result.minimumWriteVersion,
|
|
255
|
+
latestMcpSchemaVersion: result.latestMcpSchemaVersion,
|
|
256
|
+
skillsVersion: result.skillsVersion,
|
|
257
|
+
skillsSchemaVersion: result.skillsSchemaVersion,
|
|
258
|
+
skillsUpdateRecommended: result.skillsUpdateRecommended,
|
|
259
|
+
severity: result.severity,
|
|
260
|
+
breaking: result.breaking,
|
|
261
|
+
releaseNotesUrl: result.releaseNotesUrl,
|
|
262
|
+
upgrade: result.upgrade
|
|
263
|
+
};
|
|
264
|
+
}
|
|
201
265
|
function compareVersions(left, right) {
|
|
202
266
|
const a = parseVersion(left);
|
|
203
267
|
const b = parseVersion(right);
|
|
@@ -220,6 +284,9 @@ function parseVersion(version) {
|
|
|
220
284
|
}
|
|
221
285
|
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
222
286
|
}
|
|
287
|
+
function isSemver(version) {
|
|
288
|
+
return /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.test(version);
|
|
289
|
+
}
|
|
223
290
|
function assertSemver(version, field) {
|
|
224
291
|
try {
|
|
225
292
|
parseVersion(version);
|
package/dist/core/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const RAPIDX_VERSION = "1.0.
|
|
1
|
+
export const RAPIDX_VERSION = "1.0.34";
|
|
@@ -18,12 +18,57 @@ export function getMcpToolDefinitions() {
|
|
|
18
18
|
return tools.sort((a, b) => a.name.localeCompare(b.name));
|
|
19
19
|
}
|
|
20
20
|
function toolDescription(capability) {
|
|
21
|
-
const base =
|
|
21
|
+
const base = TOOL_DESCRIPTIONS[capability.capabilityId]
|
|
22
|
+
?? `RapidX ${capability.capabilityId}. Use the published input schema before calling this tool. Risk level: ${capability.riskLevel}. Schema version: ${SCHEMA_VERSION}.`;
|
|
22
23
|
if (!capability.containsRealOrder) {
|
|
23
24
|
return base;
|
|
24
25
|
}
|
|
25
26
|
return `${base}. This submits a real verification order and requires explicit human confirmation bound to symbol, side, maxNotional, and cancel cleanup behavior.`;
|
|
26
27
|
}
|
|
28
|
+
const TOOL_DESCRIPTIONS = {
|
|
29
|
+
"schema.discover": `Discover the RapidX MCP tool surface, capability metadata, and concrete JSON input schemas. Use this before constructing tool inputs. Schema version: ${SCHEMA_VERSION}.`,
|
|
30
|
+
"self-check.run": "Run a read-only RapidX integration self-check. Verifies tool discovery, schema, credential configuration, and optional live read probes without submitting trade writes.",
|
|
31
|
+
"update.check": "Check the RapidX release manifest for CLI, MCP schema, and skills versions. Use during setup, review, or session startup; do not run before every trade submit.",
|
|
32
|
+
"market.ticker": "Read the latest ticker for a RapidX symbol. Public market adapter may query Binance or OKX venue APIs and returns canonical RapidX symbol plus original venue symbol when they differ.",
|
|
33
|
+
"market.orderbook": "Read the order book for a RapidX symbol. Public market adapter may query Binance or OKX venue depth/books endpoints and returns canonical RapidX symbol plus venue data.",
|
|
34
|
+
"market.klines": "Read historical candlesticks for a RapidX symbol. Requires symbol and interval, with optional limit. Public market adapter currently supports Binance-style kline data.",
|
|
35
|
+
"market.funding-rate": "Read the current funding rate for a perpetual RapidX symbol through the RapidX market funding-rate endpoint.",
|
|
36
|
+
"market.mark-price": "Read the current mark price for a perpetual RapidX symbol through the RapidX market mark-price endpoint.",
|
|
37
|
+
"market.symbol-info": "Read RapidX symbol trading rules and metadata, including minNotional, minSize, lotSize, and tickSize when available. Use before order preview or sizing.",
|
|
38
|
+
"market.open-interest": "Read current open interest for a perpetual RapidX symbol. Public market adapter may query Binance or OKX and returns canonical RapidX symbol plus original venue symbol.",
|
|
39
|
+
"portfolio.overview": "Read the RapidX trading portfolio overview from GET /api/v1/trading/account. Requires configured RapidX credentials.",
|
|
40
|
+
"portfolio.assets": "Read RapidX portfolio asset and balance details from GET /api/v1/trading/portfolio/assets. Supports optional exchangeType, page, and pageSize filters.",
|
|
41
|
+
"portfolio.statement": "Read RapidX portfolio statements from GET /api/v1/trading/statement. Supports optional coin, symbol, statementType, exchange, page, pageSize, startTime, and endTime filters.",
|
|
42
|
+
"portfolio.user-fee-rate": "Read the user's RapidX trading fee rates from GET /api/v1/trading/userFeeRate. Use this for fee-aware order and execution analysis.",
|
|
43
|
+
"portfolio.position-bracket": "Read RapidX position tier/bracket information for a symbol from GET /api/v1/trading/positionBracket.",
|
|
44
|
+
"portfolio.set-position-mode": "Preview-required write: change RapidX account position mode through POST /api/v1/trading/account. Use only when the user explicitly asks to change account position mode.",
|
|
45
|
+
"trade.preview": "Create a generic preview token by targetCapabilityId for write operations without a dedicated order preview command, including portfolio writes, position writes, and algo writes before submitting the target tool.",
|
|
46
|
+
"order.place-preview": "Preview an order placement before submitting a real order. Validates input schema, local safety rules, symbol trading rules from GET /api/v1/trading/sym/info, maxNotional, and returns previewId plus confirmation.submitToken.",
|
|
47
|
+
"order.replace-preview": "Preview an order replacement before submitting a real replace. Performs order readback through GET /api/v1/trading/order to verify the order exists and is replaceable, then returns previewId plus confirmation.submitToken.",
|
|
48
|
+
"order.cancel-preview": "Preview an order cancellation before submitting a real cancel. Performs order readback through GET /api/v1/trading/order to verify the order exists and is cancelable, then returns previewId plus confirmation.submitToken.",
|
|
49
|
+
"order.place": "Preview-required write: submit a real order to POST /api/v1/trading/order. Must use unchanged business parameters from order.place-preview and continueConsentId=confirmation.submitToken.",
|
|
50
|
+
"order.replace": "Preview-required write: replace a real order through PUT /api/v1/trading/order. Must use unchanged business parameters from order.replace-preview or a matching trade preview.",
|
|
51
|
+
"order.cancel": "Preview-required write: cancel a real order through DELETE /api/v1/trading/order. Cancel can be asynchronous; inspect cancelAccepted, terminalStateConfirmed, and poll order.query when needed.",
|
|
52
|
+
"order.cancel-all": "Preview-required write: cancel multiple open orders through DELETE /api/v1/trading/cancelAll. Use filters carefully and verify final open-orders state after submission.",
|
|
53
|
+
"order.query": "Read a single RapidX order from GET /api/v1/trading/order using orderId or clientOrderId. orderId is locally validated as a 16-digit numeric id before upstream lookup.",
|
|
54
|
+
"order.open-orders": "Read current non-terminal RapidX open orders from GET /api/v1/trading/orders. open-orders means currently active orders, not placing a new order.",
|
|
55
|
+
"order.history": "Read RapidX order history from GET /api/v1/trading/history/orders. Supports optional sym, businessType, exchange, begin, end, filterExecuted, page, and pageSize. If begin is omitted, RapidX defaults to up to the last 7 days; if end is omitted, current time is used.",
|
|
56
|
+
"transaction.executions": "Read RapidX transaction executions from GET /api/v1/trading/executions. Supports optional orderId, sym, exchange, businessType, begin, end, and limit filters.",
|
|
57
|
+
"position.query": "Read current RapidX portfolio positions from GET /api/v1/trading/position. Supports optional symbol and other list filters; client may apply symbol filtering when upstream returns a list.",
|
|
58
|
+
"position.history": "Read RapidX historical positions from GET /api/v1/trading/history/position. Supports optional symbol, pageSize, startTime, and endTime filters.",
|
|
59
|
+
"position.get-leverage": "Read current leverage for a perpetual RapidX symbol from GET /api/v1/trading/perp/leverage.",
|
|
60
|
+
"position.close": "Preview-required write: close a RapidX position through DELETE /api/v1/trading/position. Do not pass side or quantity; NET mode omits positionSide, hedge mode uses LONG or SHORT.",
|
|
61
|
+
"position.close-all": "Preview-required write: close multiple RapidX positions through DELETE /api/v1/trading/positions. Use filters carefully and verify final positions after submission.",
|
|
62
|
+
"position.set-leverage": "Preview-required write: set leverage for a RapidX position through POST /api/v1/trading/position/leverage. Verify current leverage after submission.",
|
|
63
|
+
"algo.place": "Preview-required write: place a RapidX algo order through POST /api/v1/algo/order, including TPSL and conditional flows. Preview first with targetCapabilityId=algo.place.",
|
|
64
|
+
"algo.replace": "Preview-required write: replace a RapidX algo order through PUT /api/v1/algo/order. Preview first and keep business parameters unchanged between preview and submit.",
|
|
65
|
+
"algo.cancel": "Preview-required write: cancel a RapidX algo order through DELETE /api/v1/algo/order. Preview first and verify final algo order state after submission.",
|
|
66
|
+
"algo.open-orders": "Read current non-terminal RapidX algo orders from GET /api/v1/algo/openOrders. open-orders means active algo orders that have not ended.",
|
|
67
|
+
"algo.history": "Read RapidX algo order history from GET /api/v1/algo/history/orders. Supports optional sym, businessType, exchange, algoOrderType, begin, end, page, and pageSize. The endpoint retrieves finished orders from the past 7 days.",
|
|
68
|
+
"algo.query": "Read a RapidX algo order detail from GET /api/v1/algo/order using algoOrderId, clientOrderId, or attachedOrderId.",
|
|
69
|
+
"trading.verify": "Run the compatibility live trading verification flow. It performs read-only self-check, previews a small real order, submits it with explicit user consent, then cancels/cleans up and verifies state.",
|
|
70
|
+
"trading.verify-live": "Run the live trading verification flow. It performs read-only self-check, previews a small real order, submits it with explicit user consent, then cancels/cleans up and verifies state."
|
|
71
|
+
};
|
|
27
72
|
export function capabilityForTool(toolName) {
|
|
28
73
|
const overrideId = toolName === "rapidx/tools"
|
|
29
74
|
? "schema.discover"
|
package/dist/mcp/tool-runner.js
CHANGED
|
@@ -40,6 +40,9 @@ export async function runMcpTool(toolName, input = {}) {
|
|
|
40
40
|
if (typeof input.maxCacheAgeSeconds === "number") {
|
|
41
41
|
updateInput.maxCacheAgeSeconds = input.maxCacheAgeSeconds;
|
|
42
42
|
}
|
|
43
|
+
if (typeof input.installedSkillsVersion === "string") {
|
|
44
|
+
updateInput.installedSkillsVersion = input.installedSkillsVersion;
|
|
45
|
+
}
|
|
43
46
|
const update = await checkForUpdate(updateInput);
|
|
44
47
|
const status = envelopeStatusForUpdate(update.status);
|
|
45
48
|
const auditId = writeMcpAudit("update-check", status, { toolName, updateStatus: update.status });
|
|
@@ -51,10 +54,10 @@ export async function runMcpTool(toolName, input = {}) {
|
|
|
51
54
|
return tradingVerificationEnvelope(toolName, report, auditId);
|
|
52
55
|
}
|
|
53
56
|
const capability = capabilityForTool(toolName);
|
|
54
|
-
if (toolName === "rapidx/order/
|
|
55
|
-
const previewCapability = findCapabilityById("order.preview");
|
|
57
|
+
if (toolName === "rapidx/order/place-preview") {
|
|
58
|
+
const previewCapability = findCapabilityById("order.place-preview");
|
|
56
59
|
if (!previewCapability) {
|
|
57
|
-
throw new Error("order.preview capability missing");
|
|
60
|
+
throw new Error("order.place-preview capability missing");
|
|
58
61
|
}
|
|
59
62
|
const preview = createTradePreview(previewCapability, input, { ...defaultSafetyPolicy(), tradingEnabled: true, readOnly: false }, safetyState, previewStore);
|
|
60
63
|
try {
|
package/package.json
CHANGED
|
@@ -39,11 +39,37 @@ rapidx order replace-preview --input @/absolute/path/order-replace-preview.json
|
|
|
39
39
|
rapidx order cancel-preview --input @/absolute/path/order-cancel-preview.json --json
|
|
40
40
|
rapidx trade preview --input @/absolute/path/trade-preview.json --json
|
|
41
41
|
rapidx position history --input @/absolute/path/position-history.json --json
|
|
42
|
+
rapidx algo history --input @/absolute/path/algo-history.json --json
|
|
42
43
|
rapidx portfolio set-position-mode --input @/absolute/path/set-position-mode.json --json
|
|
43
44
|
```
|
|
44
45
|
|
|
45
46
|
`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.
|
|
46
47
|
|
|
48
|
+
When checking an existing installation, read the installed RapidX skill `version` from the loaded `SKILL.md` frontmatter and pass it to update check:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
rapidx update check --input '{"installedSkillsVersion":"1.0.9"}' --json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For upgrade reviews, force a remote manifest refresh:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
rapidx update check --input '{"installedSkillsVersion":"1.0.9","force":true}' --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Update output fields:
|
|
61
|
+
|
|
62
|
+
- `latestVersion`: latest CLI version from the release manifest.
|
|
63
|
+
- `currentVersion`: running CLI version.
|
|
64
|
+
- `latestSkillsVersion` / `skillsVersion`: latest RapidX skills version from the release manifest.
|
|
65
|
+
- `bundledExpectedSkillsVersion` / `currentSkillsVersion`: skills version expected by this CLI build, not proof of locally installed skills.
|
|
66
|
+
- `installedSkillsVersion`: local skill version supplied by the caller, or `NOT_VERIFIED`.
|
|
67
|
+
- `skillsInstallStatus`: `CURRENT`, `UPDATE_AVAILABLE`, or `NOT_VERIFIED`.
|
|
68
|
+
- `manifestSource`: `remote`, `cache`, or `fallback`.
|
|
69
|
+
- `updateFreshness`: `REMOTE`, `CACHE`, or `FALLBACK`.
|
|
70
|
+
- `cacheWarning`: present when the result came from local cache.
|
|
71
|
+
- `refreshCommand`: command for forcing a remote manifest refresh.
|
|
72
|
+
|
|
47
73
|
`rapidx schema --json` returns `capabilities` plus `inputSchemas`. Agents should read the concrete input schema before constructing write inputs.
|
|
48
74
|
|
|
49
75
|
`rapidx portfolio assets` reads `/api/v1/trading/portfolio/assets`. It is the canonical CLI command for portfolio asset balances.
|
|
@@ -54,6 +80,11 @@ rapidx portfolio set-position-mode --input @/absolute/path/set-position-mode.jso
|
|
|
54
80
|
|
|
55
81
|
When using `orderId`, pass the RapidX 16-digit numeric order id. Invalid `orderId` format is rejected locally as `INVALID_INPUT`. `clientOrderId` can be used instead and does not need to satisfy the `orderId` format. Preview commands for replace/cancel perform a RapidX readback after local format validation; valid-but-missing orders return `NOT_FOUND` or a blocked non-open state.
|
|
56
82
|
|
|
83
|
+
`rapidx order history` and `rapidx algo history` accept optional `begin` and `end` time range fields in milliseconds. If omitted, RapidX applies the upstream server default range.
|
|
84
|
+
|
|
85
|
+
`rapidx transaction executions` reads transaction executions from `GET /api/v1/trading/executions`.
|
|
86
|
+
|
|
57
87
|
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.
|
|
88
|
+
Valid automation preview returns an `automation` object with `confirmationMode="automation-preview"`; generic or missing automation consent text is blocked before submission.
|
|
58
89
|
|
|
59
90
|
`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 query --json`, and do not rely only on `order query` to interpret the close intent.
|
|
@@ -27,13 +27,15 @@ Key trading tools:
|
|
|
27
27
|
- `rapidx/tools` returns the MCP tool list plus `inputSchemas`. Agents should read the concrete input schema before constructing write inputs.
|
|
28
28
|
- `rapidx/update/check` reads the RapidX release manifest and returns current/latest CLI version, minimum write version, skills update advice, and upgrade commands.
|
|
29
29
|
- `rapidx/self-check` can include update state when called with `{"checkUpdates": true}`.
|
|
30
|
-
- `rapidx/order/preview`
|
|
31
|
-
- `rapidx/
|
|
32
|
-
- `rapidx/trade/preview` creates preview tokens for non-place trade writes by `targetCapabilityId`, including position, portfolio, and algo writes.
|
|
30
|
+
- `rapidx/order/place-preview`, `rapidx/order/replace-preview`, and `rapidx/order/cancel-preview` are concrete order preview tools. Preview responses include `confirmation.submitToken`; pass it as `continueConsentId` when submitting the matching write tool.
|
|
31
|
+
- `rapidx/trade/preview` creates generic preview tokens by `targetCapabilityId` for write operations without a dedicated order preview command, including position, portfolio, and algo writes.
|
|
33
32
|
- 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
33
|
- `rapidx/order/cancel` returns cancel acceptance plus terminal-state guidance. Poll `rapidx/order/query` when `terminalStateConfirmed=false`.
|
|
35
34
|
- 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.
|
|
35
|
+
- Valid automation preview returns an `automation` object with `confirmationMode="automation-preview"`; generic or missing automation consent text is blocked before submission.
|
|
36
36
|
- `rapidx/position/history` reads historical positions.
|
|
37
|
+
- `rapidx/order/history` and `rapidx/algo/history` accept optional `begin` and `end` time range fields in milliseconds. If omitted, RapidX applies the upstream server default range.
|
|
38
|
+
- `rapidx/transaction/executions` reads transaction executions from `GET /api/v1/trading/executions`.
|
|
37
39
|
- 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
40
|
- `rapidx/portfolio/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
41
|
- `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.
|
|
@@ -137,4 +137,4 @@ The config skill guides the agent to install `@liquiditytech/rapidx-cli`, config
|
|
|
137
137
|
|
|
138
138
|
The trading skill guides read flow, preview-first write flow, state confirmation, and small real-trade verification.
|
|
139
139
|
|
|
140
|
-
For existing installations, run `rapidx update check --json` or call `rapidx/update/check` through MCP before an integration review. Reinstall the GitHub-distributed skills when
|
|
140
|
+
For existing installations, read the installed skill `version` from each loaded `SKILL.md` frontmatter, then run `rapidx update check --input '{"installedSkillsVersion":"<local-skill-version>","force":true}' --json` or call `rapidx/update/check` through MCP with the same input before an integration review. Reinstall the GitHub-distributed skills when `skillsInstallStatus=UPDATE_AVAILABLE`, `installedSkillsVersion=NOT_VERIFIED`, or `skillsUpdateRecommended=true`.
|
|
@@ -10,22 +10,24 @@ The canonical source is `rapidx schema --json` or `rapidx/tools`.
|
|
|
10
10
|
|
|
11
11
|
## Preview Tools
|
|
12
12
|
|
|
13
|
-
- `rapidx/order/preview`: preview for `order.place`.
|
|
14
13
|
- `rapidx/order/place-preview`: explicit alias for `order.place` preview. It returns `previewId` plus `confirmation.submitToken`.
|
|
15
14
|
- `rapidx/order/replace-preview`: explicit alias for `order.replace` preview. Submit `rapidx/order/replace` with unchanged parameters, `previewId`, and `continueConsentId=confirmation.submitToken`.
|
|
16
15
|
- `rapidx/order/cancel-preview`: explicit alias for `order.cancel` preview. Submit `rapidx/order/cancel` with unchanged parameters, `previewId`, and `continueConsentId=confirmation.submitToken`.
|
|
17
|
-
- `rapidx/trade/preview`: generic preview for
|
|
16
|
+
- `rapidx/trade/preview`: generic preview for write operations without a dedicated order preview command, including position writes, portfolio writes, and algo writes. Pass `targetCapabilityId`, then submit the target tool with unchanged parameters, `previewId`, and `continueConsentId`.
|
|
18
17
|
|
|
19
18
|
## Read Tools
|
|
20
19
|
|
|
21
20
|
- Market reads: ticker, orderbook, klines, funding rate, mark price, symbol info, and open interest.
|
|
22
21
|
- Portfolio reads: overview, assets, statement, user fee rate, and position bracket.
|
|
23
|
-
- Order reads: query, open-orders,
|
|
22
|
+
- Order reads: query, open-orders, and history.
|
|
23
|
+
- Transaction reads: `rapidx/transaction/executions`, backed by `GET /api/v1/trading/executions` under the LTP Transactions category.
|
|
24
24
|
- Position reads: query, position history, and get-leverage.
|
|
25
|
-
- Algo reads: open-orders and
|
|
25
|
+
- Algo reads: `rapidx/algo/open-orders`, `rapidx/algo/query`, and `rapidx/algo/history`.
|
|
26
26
|
|
|
27
27
|
`open-orders` means current non-terminal orders, not "open an order". These orders may still be fillable, replaceable, or cancelable. `algo/open-orders` means current non-terminal algo orders such as conditional or TPSL orders that have not triggered, been canceled, or otherwise ended.
|
|
28
28
|
|
|
29
|
+
`rapidx/order/history` and `rapidx/algo/history` accept official RapidX `begin` and `end` time range fields in milliseconds. If they are omitted, RapidX applies the upstream server default range.
|
|
30
|
+
|
|
29
31
|
## Symbol Format
|
|
30
32
|
|
|
31
33
|
Use RapidX symbols in tool inputs:
|
|
@@ -58,6 +60,7 @@ Preview ids are runtime-local. A preview created by MCP must be submitted throug
|
|
|
58
60
|
Order identifiers use two validation layers. If `orderId` is provided, RapidX validates it locally as a 16-digit numeric id and returns `INVALID_INPUT` before any upstream call when the format is wrong. If `clientOrderId` is provided instead, do not apply `orderId` validation. For `order.query`, `order.replace-preview`, and `order.cancel-preview`, a syntactically valid `orderId` or `clientOrderId` is checked through RapidX readback; missing or non-open orders return `NOT_FOUND` or `BLOCKED` depending on the observed state.
|
|
59
61
|
|
|
60
62
|
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.
|
|
63
|
+
Automation support is verified at the preview layer: valid automation input returns an `automation` object with `confirmationMode="automation-preview"`, while missing or generic `automationConsentText` is blocked before submission.
|
|
61
64
|
|
|
62
65
|
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/open-orders`.
|
|
63
66
|
|
|
@@ -1,23 +1,94 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Version and installation
|
|
4
|
+
|
|
5
|
+
Check the npm package and the binary resolved by the shell:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm view @liquiditytech/rapidx-cli version
|
|
9
|
+
which rapidx
|
|
10
|
+
rapidx --version
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If npm shows a newer version but `rapidx --version` is old, the shell or agent host is resolving another binary. Update `PATH`, reinstall globally, or configure the MCP host with the absolute `rapidx` path.
|
|
14
|
+
|
|
15
|
+
## RCLI errors
|
|
4
16
|
|
|
5
17
|
`RCLI13001` means the CLI rejected a complex invocation. Use the `rapidx` bin directly.
|
|
6
18
|
|
|
7
19
|
`RCLI25001` means the agent host preflight blocked execution before RapidX ran. Remove shell chaining or use MCP tools.
|
|
8
20
|
|
|
9
|
-
|
|
21
|
+
`RCLI20002` means preview or continuation consent is missing. Run the matching preview first, then submit with the returned `previewId` and `continueConsentId`.
|
|
22
|
+
|
|
23
|
+
`RCLI22001` means RapidX upstream returned a business error. Read the upstream message and adjust the request.
|
|
24
|
+
|
|
25
|
+
## RMCP errors
|
|
10
26
|
|
|
11
27
|
`RMCP20001` means trade consent is missing.
|
|
12
28
|
|
|
13
29
|
`RMCP20002` means preview is missing, expired, or mismatched.
|
|
14
30
|
|
|
15
|
-
|
|
31
|
+
If MCP tools are missing or stale, confirm that the MCP config starts the server with:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"command": "rapidx",
|
|
36
|
+
"args": ["mcp", "serve"]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Reload the agent host after changing MCP config. If old tools such as `rapidx/order/preview` still appear, upgrade the CLI and reload the MCP host.
|
|
41
|
+
|
|
42
|
+
## RCORE errors
|
|
16
43
|
|
|
17
44
|
`RCORE01001` means Portfolio credentials are missing.
|
|
18
45
|
|
|
46
|
+
`RCORE01003` means `LTP_API_HOST` is missing.
|
|
47
|
+
|
|
48
|
+
`RCORE00002` means `orderId` format is invalid. Use a 16-digit RapidX order id, or use `clientOrderId` where supported.
|
|
49
|
+
|
|
50
|
+
`RCORE22004` means the requested upstream resource was not found.
|
|
51
|
+
|
|
52
|
+
`RCORE23002` means upstream network or timeout failure.
|
|
53
|
+
|
|
54
|
+
`RCORE23003` means RapidX upstream rate limit was reached. Retry later and avoid tight polling loops.
|
|
55
|
+
|
|
19
56
|
`RCORE90002` means output or audit may contain secret material and must fail closed.
|
|
20
57
|
|
|
58
|
+
## INVALID_INPUT
|
|
59
|
+
|
|
60
|
+
Compare the request with the live schema:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
rapidx schema --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Common causes are missing required fields, old time fields such as `startTime` / `endTime` instead of `begin` / `end`, invalid `orderId` format, or unsupported symbol format.
|
|
67
|
+
|
|
68
|
+
## BLOCKED writes
|
|
69
|
+
|
|
70
|
+
For write tools, check:
|
|
71
|
+
|
|
72
|
+
- The matching preview ran first.
|
|
73
|
+
- `previewId` is present.
|
|
74
|
+
- `continueConsentId` equals the preview response's `confirmation.submitToken`.
|
|
75
|
+
- The submit request keeps the same business parameters as the preview.
|
|
76
|
+
- The input matches `rapidx schema --json` or `rapidx/tools`.
|
|
77
|
+
|
|
78
|
+
## Order and algo history
|
|
79
|
+
|
|
80
|
+
Use official RapidX time fields:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{ "begin": 1717200000000, "end": 1717804800000 }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If `begin` and `end` are omitted, RapidX applies the upstream default range.
|
|
87
|
+
|
|
88
|
+
## Asynchronous cancel
|
|
89
|
+
|
|
90
|
+
A successful cancel response means the cancel request was accepted. If `terminalStateConfirmed=false`, poll `rapidx order query` until the order reaches a terminal state.
|
|
91
|
+
|
|
21
92
|
## RSKILL
|
|
22
93
|
|
|
23
94
|
`RSKILL12001` means the skill did not require evidence.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.34",
|
|
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:
|
|
8
|
+
"checksum": "sha256:0a21dd7e9627c0996ed56d7409f28f0ca0d30de9d13c6b10650a7ef3fb67505b",
|
|
9
9
|
"status": "ready"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"name": "rapidx-tools-doc",
|
|
20
20
|
"path": "packages/distribution/docs/tools.md",
|
|
21
21
|
"channel": "offline",
|
|
22
|
-
"checksum": "sha256:
|
|
22
|
+
"checksum": "sha256:59246ef27a9b826bfdc8a20c1ccd8ec6556a95a00b7e5f71fb82d01eb1585b22",
|
|
23
23
|
"status": "ready"
|
|
24
24
|
}
|
|
25
25
|
]
|