@okx_ai/okx-trade-cli 1.3.2-beta.1 → 1.3.2-beta.2

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/index.js CHANGED
@@ -892,19 +892,19 @@ import { get as httpsGet } from "https";
892
892
  import { get as httpGet } from "http";
893
893
  var EXEC_TIMEOUT_MS = 3e4;
894
894
  var ALLOWED_DOMAIN_RE = /^[\w.-]+\.okx\.com$/;
895
- var DOH_BIN_DIR = join(homedir(), ".okx", "bin");
896
- function getDohBinaryPath() {
897
- if (process.env.OKX_DOH_BINARY_PATH) {
898
- return process.env.OKX_DOH_BINARY_PATH;
895
+ var PILOT_BIN_DIR = join(homedir(), ".okx", "bin");
896
+ function getPilotBinaryPath() {
897
+ if (process.env.OKX_PILOT_BINARY_PATH) {
898
+ return process.env.OKX_PILOT_BINARY_PATH;
899
899
  }
900
900
  const ext = process.platform === "win32" ? ".exe" : "";
901
- return join(DOH_BIN_DIR, `okx-pilot${ext}`);
901
+ return join(PILOT_BIN_DIR, `okx-pilot${ext}`);
902
902
  }
903
- function execDohBinary(domain, exclude = [], userAgent) {
903
+ function execPilotBinary(domain, exclude = [], userAgent) {
904
904
  if (!ALLOWED_DOMAIN_RE.test(domain)) {
905
905
  return Promise.resolve(null);
906
906
  }
907
- const binPath = getDohBinaryPath();
907
+ const binPath = getPilotBinaryPath();
908
908
  const args = ["--domain", domain];
909
909
  if (exclude.length > 0) {
910
910
  args.push("--exclude", exclude.join(","));
@@ -937,7 +937,7 @@ function execDohBinary(domain, exclude = [], userAgent) {
937
937
  });
938
938
  }
939
939
  function getDefaultCachePath() {
940
- return process.env.OKX_DOH_CACHE_PATH || join2(homedir2(), ".okx", "doh-cache.json");
940
+ return process.env.OKX_PILOT_CACHE_PATH || join2(homedir2(), ".okx", "pilot-cache.json");
941
941
  }
942
942
  function readCache(hostname, cachePath = getDefaultCachePath()) {
943
943
  try {
@@ -991,7 +991,7 @@ function getActiveFailedNodes(nodes) {
991
991
  const now = Date.now();
992
992
  return nodes.filter((n) => now - n.failedAt < FAILED_NODE_TTL_MS);
993
993
  }
994
- function resolveDoh(hostname, cachePath) {
994
+ function resolvePilot(hostname, cachePath) {
995
995
  const entry = readCache(hostname, cachePath);
996
996
  if (entry) {
997
997
  if (entry.mode === "direct") {
@@ -1003,53 +1003,53 @@ function resolveDoh(hostname, cachePath) {
1003
1003
  }
1004
1004
  return { mode: null, node: null };
1005
1005
  }
1006
- async function reResolveDoh(hostname, failedIp, userAgent, cachePath) {
1006
+ async function reResolvePilot(hostname, failedIp, userAgent, cachePath) {
1007
1007
  const entry = readCache(hostname, cachePath);
1008
1008
  const active = getActiveFailedNodes(entry?.failedNodes);
1009
1009
  const now = Date.now();
1010
1010
  const alreadyFailed = failedIp && active.some((n) => n.ip === failedIp);
1011
1011
  const failedNodes = failedIp && !alreadyFailed ? [...active, { ip: failedIp, failedAt: now }] : active;
1012
1012
  const excludeIps = failedNodes.map((n) => n.ip);
1013
- const node = await execDohBinary(hostname, excludeIps, userAgent);
1013
+ const node = await execPilotBinary(hostname, excludeIps, userAgent);
1014
1014
  return classifyAndCache(node, hostname, failedNodes, cachePath);
1015
1015
  }
1016
1016
  function vlog(message) {
1017
1017
  process.stderr.write(`[verbose] ${message}
1018
1018
  `);
1019
1019
  }
1020
- var DohManager = class {
1020
+ var PilotManager = class {
1021
1021
  opts;
1022
- // DoH proxy state (lazy-resolved on first request)
1023
- dohResolved = false;
1024
- dohRetried = false;
1022
+ // Pilot proxy state (lazy-resolved on first request)
1023
+ pilotResolved = false;
1024
+ pilotRetried = false;
1025
1025
  directUnverified = false;
1026
1026
  // The first direct connection has not yet been verified
1027
- dohNode = null;
1028
- dohAgent = null;
1029
- dohBaseUrl = null;
1027
+ pilotNode = null;
1028
+ pilotAgent = null;
1029
+ pilotBaseUrl = null;
1030
1030
  constructor(opts) {
1031
1031
  this.opts = opts;
1032
1032
  }
1033
1033
  /**
1034
- * Lazily resolve the DoH proxy node on the first request.
1034
+ * Lazily resolve the Pilot proxy node on the first request.
1035
1035
  * Uses cache-first strategy via the resolver.
1036
1036
  */
1037
- prepareDoh() {
1038
- if (this.dohResolved || this.opts.hasCustomProxy) return;
1039
- this.dohResolved = true;
1037
+ preparePilot() {
1038
+ if (this.pilotResolved || this.opts.hasCustomProxy) return;
1039
+ this.pilotResolved = true;
1040
1040
  try {
1041
1041
  const { hostname, protocol } = new URL(this.opts.baseUrl);
1042
- const result = resolveDoh(hostname);
1042
+ const result = resolvePilot(hostname);
1043
1043
  if (!result.mode) {
1044
1044
  this.directUnverified = true;
1045
1045
  if (this.opts.verbose) {
1046
- vlog("DoH: no cache, trying direct connection first");
1046
+ vlog("Pilot: no cache, trying direct connection first");
1047
1047
  }
1048
1048
  return;
1049
1049
  }
1050
1050
  if (result.mode === "direct") {
1051
1051
  if (this.opts.verbose) {
1052
- vlog("DoH: mode=direct (overseas or cached), using direct connection");
1052
+ vlog("Pilot: mode=direct (overseas or cached), using direct connection");
1053
1053
  }
1054
1054
  return;
1055
1055
  }
@@ -1059,57 +1059,57 @@ var DohManager = class {
1059
1059
  } catch (err) {
1060
1060
  if (this.opts.verbose) {
1061
1061
  const cause = err instanceof Error ? err.message : String(err);
1062
- vlog(`DoH resolution failed, falling back to direct: ${cause}`);
1062
+ vlog(`Pilot resolution failed, falling back to direct: ${cause}`);
1063
1063
  }
1064
1064
  }
1065
1065
  }
1066
1066
  /** Get connection parameters for the current request. */
1067
1067
  getConnectionParams() {
1068
- const baseUrl = this.dohNode ? this.dohBaseUrl : this.opts.baseUrl;
1068
+ const baseUrl = this.pilotNode ? this.pilotBaseUrl : this.opts.baseUrl;
1069
1069
  const result = { baseUrl };
1070
- if (this.dohAgent) {
1071
- result.dispatcher = this.dohAgent;
1070
+ if (this.pilotAgent) {
1071
+ result.dispatcher = this.pilotAgent;
1072
1072
  }
1073
- if (this.dohNode) {
1074
- result.userAgent = this.dohUserAgent;
1073
+ if (this.pilotNode) {
1074
+ result.userAgent = this.pilotUserAgent;
1075
1075
  }
1076
1076
  return result;
1077
1077
  }
1078
- /** Whether a DoH proxy node is currently active. */
1078
+ /** Whether a Pilot proxy node is currently active. */
1079
1079
  get isProxyActive() {
1080
- return this.dohNode !== null;
1080
+ return this.pilotNode !== null;
1081
1081
  }
1082
1082
  /** Whether we have already retried after network failure. */
1083
1083
  get hasRetried() {
1084
- return this.dohRetried;
1084
+ return this.pilotRetried;
1085
1085
  }
1086
1086
  /**
1087
1087
  * Handle network failure: re-resolve with --exclude and retry once.
1088
1088
  * Returns true if retry should proceed, false if already retried.
1089
1089
  */
1090
1090
  async handleNetworkFailure() {
1091
- if (this.dohRetried) return false;
1092
- this.dohRetried = true;
1093
- const failedIp = this.dohNode?.ip ?? "";
1091
+ if (this.pilotRetried) return false;
1092
+ this.pilotRetried = true;
1093
+ const failedIp = this.pilotNode?.ip ?? "";
1094
1094
  const { hostname, protocol } = new URL(this.opts.baseUrl);
1095
- this.dohNode = null;
1096
- this.dohAgent = null;
1097
- this.dohBaseUrl = null;
1095
+ this.pilotNode = null;
1096
+ this.pilotAgent = null;
1097
+ this.pilotBaseUrl = null;
1098
1098
  if (!failedIp) this.directUnverified = false;
1099
1099
  if (this.opts.verbose) {
1100
- vlog(failedIp ? `DoH: proxy node ${failedIp} failed, re-resolving with --exclude` : "DoH: direct connection failed, calling binary for DoH resolution");
1100
+ vlog(failedIp ? `Pilot: proxy node ${failedIp} failed, re-resolving with --exclude` : "Pilot: direct connection failed, calling binary for Pilot resolution");
1101
1101
  }
1102
1102
  try {
1103
- const result = await reResolveDoh(hostname, failedIp, this.dohUserAgent);
1103
+ const result = await reResolvePilot(hostname, failedIp, this.pilotUserAgent);
1104
1104
  if (result.mode === "proxy" && result.node) {
1105
1105
  this.applyNode(result.node, protocol);
1106
- this.dohRetried = false;
1106
+ this.pilotRetried = false;
1107
1107
  return true;
1108
1108
  }
1109
1109
  } catch {
1110
1110
  }
1111
1111
  if (this.opts.verbose) {
1112
- vlog("DoH: re-resolution failed or switched to direct, retrying with direct connection");
1112
+ vlog("Pilot: re-resolution failed or switched to direct, retrying with direct connection");
1113
1113
  }
1114
1114
  return true;
1115
1115
  }
@@ -1118,7 +1118,7 @@ var DohManager = class {
1118
1118
  * (Even if the business response is an error, the network path is valid.)
1119
1119
  */
1120
1120
  cacheDirectIfNeeded() {
1121
- if (!this.directUnverified || this.dohNode) return;
1121
+ if (!this.directUnverified || this.pilotNode) return;
1122
1122
  this.directUnverified = false;
1123
1123
  const { hostname } = new URL(this.opts.baseUrl);
1124
1124
  writeCache(hostname, {
@@ -1128,25 +1128,25 @@ var DohManager = class {
1128
1128
  updatedAt: Date.now()
1129
1129
  });
1130
1130
  if (this.opts.verbose) {
1131
- vlog("DoH: direct connection succeeded, cached mode=direct");
1131
+ vlog("Pilot: direct connection succeeded, cached mode=direct");
1132
1132
  }
1133
1133
  }
1134
- /** User-Agent for DoH proxy requests: OKX/@okx_ai/{packageName}/{version} */
1135
- get dohUserAgent() {
1134
+ /** User-Agent for Pilot proxy requests: OKX/@okx_ai/{packageName}/{version} */
1135
+ get pilotUserAgent() {
1136
1136
  return `OKX/@okx_ai/${this.opts.packageUserAgent ?? "unknown"}`;
1137
1137
  }
1138
1138
  /**
1139
- * Apply a DoH node: set up the custom Agent + base URL.
1139
+ * Apply a Pilot node: set up the custom Agent + base URL.
1140
1140
  *
1141
1141
  * node.ip may be a real IP or a domain (CNAME like *.aliyunddos1021.com).
1142
1142
  * - Real IP → use directly in lookup callback
1143
1143
  * - Domain → dns.lookup on every connection to get a fresh IP
1144
1144
  */
1145
1145
  applyNode(node, protocol) {
1146
- this.dohNode = node;
1147
- this.dohBaseUrl = `${protocol}//${node.host}`;
1146
+ this.pilotNode = node;
1147
+ this.pilotBaseUrl = `${protocol}//${node.host}`;
1148
1148
  const nodeIpIsRealIp = !!isIP(node.ip);
1149
- this.dohAgent = new Agent({
1149
+ this.pilotAgent = new Agent({
1150
1150
  connect: {
1151
1151
  lookup: (_hostname, options, callback) => {
1152
1152
  if (nodeIpIsRealIp) {
@@ -1170,7 +1170,7 @@ var DohManager = class {
1170
1170
  }
1171
1171
  });
1172
1172
  if (this.opts.verbose) {
1173
- vlog(`DoH proxy active: \u2192 ${node.host} (${node.ip}), ttl=${node.ttl}s`);
1173
+ vlog(`Pilot proxy active: \u2192 ${node.host} (${node.ip}), ttl=${node.ttl}s`);
1174
1174
  }
1175
1175
  }
1176
1176
  };
@@ -1392,14 +1392,14 @@ var OkxRestClient = class _OkxRestClient {
1392
1392
  config;
1393
1393
  rateLimiter;
1394
1394
  dispatcher;
1395
- doh;
1395
+ pilot;
1396
1396
  constructor(config) {
1397
1397
  this.config = config;
1398
1398
  this.rateLimiter = new RateLimiter(3e4, config.verbose);
1399
1399
  if (config.proxyUrl) {
1400
1400
  this.dispatcher = new ProxyAgent(config.proxyUrl);
1401
1401
  }
1402
- this.doh = new DohManager({
1402
+ this.pilot = new PilotManager({
1403
1403
  baseUrl: config.baseUrl,
1404
1404
  packageUserAgent: config.userAgent,
1405
1405
  verbose: config.verbose,
@@ -1582,12 +1582,12 @@ var OkxRestClient = class _OkxRestClient {
1582
1582
  * Security: validates Content-Type and enforces maxBytes limit.
1583
1583
  */
1584
1584
  async privatePostBinary(path42, body, opts) {
1585
- this.doh.prepareDoh();
1585
+ this.pilot.preparePilot();
1586
1586
  const maxBytes = opts?.maxBytes ?? _OkxRestClient.DEFAULT_MAX_BYTES;
1587
1587
  const expectedCT = opts?.expectedContentType ?? "application/octet-stream";
1588
1588
  const bodyJson = body ? JSON.stringify(body) : "";
1589
1589
  const endpoint = `POST ${path42}`;
1590
- const conn = this.doh.getConnectionParams();
1590
+ const conn = this.pilot.getConnectionParams();
1591
1591
  this.logRequest("POST", `${conn.baseUrl}${path42}`, "private");
1592
1592
  const reqConfig = { method: "POST", path: path42, auth: "private" };
1593
1593
  const headers = this.buildHeaders(reqConfig, path42, bodyJson, getNow());
@@ -1599,13 +1599,15 @@ var OkxRestClient = class _OkxRestClient {
1599
1599
  try {
1600
1600
  response = await this.fetchBinary(path42, endpoint, headers, bodyJson, t0);
1601
1601
  } catch (error) {
1602
- this.doh.handleNetworkFailure().catch(() => {
1603
- });
1602
+ try {
1603
+ await this.pilot.handleNetworkFailure();
1604
+ } catch {
1605
+ }
1604
1606
  throw error;
1605
1607
  }
1606
1608
  const elapsed = Date.now() - t0;
1607
1609
  const traceId = extractTraceId(response.headers);
1608
- this.doh.cacheDirectIfNeeded();
1610
+ this.pilot.cacheDirectIfNeeded();
1609
1611
  if (!response.ok) {
1610
1612
  const text = await response.text();
1611
1613
  this.logResponse(response.status, text.length, elapsed, traceId, String(response.status));
@@ -1631,15 +1633,15 @@ var OkxRestClient = class _OkxRestClient {
1631
1633
  /**
1632
1634
  * Send an unauthenticated GET request and return the raw binary response.
1633
1635
  * Used for pre-signed download URLs where auth is embedded in the token.
1634
- * Inherits proxy, timeout, DoH, and verbose capabilities from the client.
1636
+ * Inherits proxy, timeout, Pilot, and verbose capabilities from the client.
1635
1637
  */
1636
1638
  async publicGetBinary(path42, query, opts) {
1637
- this.doh.prepareDoh();
1639
+ this.pilot.preparePilot();
1638
1640
  const maxBytes = opts?.maxBytes ?? _OkxRestClient.DEFAULT_MAX_BYTES;
1639
1641
  const expectedCT = opts?.expectedContentType ?? "application/octet-stream";
1640
1642
  const queryString = buildQueryString(query);
1641
1643
  const requestPath = queryString ? `${path42}?${queryString}` : path42;
1642
- const conn = this.doh.getConnectionParams();
1644
+ const conn = this.pilot.getConnectionParams();
1643
1645
  const url = `${conn.baseUrl}${requestPath}`;
1644
1646
  this.logRequest("GET", url, "public");
1645
1647
  const headers = new Headers({ Accept: "application/octet-stream" });
@@ -1655,13 +1657,15 @@ var OkxRestClient = class _OkxRestClient {
1655
1657
  dispatcher: this.dispatcher ?? conn.dispatcher
1656
1658
  });
1657
1659
  } catch (error) {
1658
- this.doh.handleNetworkFailure().catch(() => {
1659
- });
1660
+ try {
1661
+ await this.pilot.handleNetworkFailure();
1662
+ } catch {
1663
+ }
1660
1664
  throw new NetworkError(`Failed to call OKX endpoint GET ${path42}.`, `GET ${path42}`, error);
1661
1665
  }
1662
1666
  const elapsed = Date.now() - t0;
1663
1667
  const traceId = extractTraceId(response.headers);
1664
- this.doh.cacheDirectIfNeeded();
1668
+ this.pilot.cacheDirectIfNeeded();
1665
1669
  if (!response.ok) {
1666
1670
  const text = await response.text();
1667
1671
  this.logResponse(response.status, text.length, elapsed, traceId, String(response.status));
@@ -1686,7 +1690,7 @@ var OkxRestClient = class _OkxRestClient {
1686
1690
  }
1687
1691
  /** Execute fetch for binary endpoint, wrapping network errors. */
1688
1692
  async fetchBinary(path42, endpoint, headers, bodyJson, t0) {
1689
- const conn = this.doh.getConnectionParams();
1693
+ const conn = this.pilot.getConnectionParams();
1690
1694
  try {
1691
1695
  const fetchOptions = {
1692
1696
  method: "POST",
@@ -1733,16 +1737,16 @@ var OkxRestClient = class _OkxRestClient {
1733
1737
  // JSON request
1734
1738
  // ---------------------------------------------------------------------------
1735
1739
  /**
1736
- * Handle network error during a JSON request: refresh DoH and maybe retry.
1740
+ * Handle network error during a JSON request: refresh Pilot and maybe retry.
1737
1741
  * Always either returns a retry result or throws NetworkError.
1738
1742
  */
1739
1743
  async handleRequestNetworkError(error, reqConfig, requestPath, t0) {
1740
- if (!this.doh.hasRetried) {
1744
+ if (!this.pilot.hasRetried) {
1741
1745
  if (this.config.verbose) {
1742
1746
  const cause = error instanceof Error ? error.message : String(error);
1743
- vlog2(`Network failure, refreshing DoH: ${cause}`);
1747
+ vlog2(`Network failure, refreshing Pilot: ${cause}`);
1744
1748
  }
1745
- const shouldRetry = await this.doh.handleNetworkFailure();
1749
+ const shouldRetry = await this.pilot.handleNetworkFailure();
1746
1750
  if (shouldRetry && (reqConfig.method === "GET" || reqConfig.retryOnNetworkError)) {
1747
1751
  return this.request(reqConfig);
1748
1752
  }
@@ -1759,10 +1763,10 @@ var OkxRestClient = class _OkxRestClient {
1759
1763
  );
1760
1764
  }
1761
1765
  async request(reqConfig) {
1762
- this.doh.prepareDoh();
1766
+ this.pilot.preparePilot();
1763
1767
  const queryString = buildQueryString(reqConfig.query);
1764
1768
  const requestPath = queryString.length > 0 ? `${reqConfig.path}?${queryString}` : reqConfig.path;
1765
- const conn = this.doh.getConnectionParams();
1769
+ const conn = this.pilot.getConnectionParams();
1766
1770
  const url = `${conn.baseUrl}${requestPath}`;
1767
1771
  const bodyJson = reqConfig.body ? JSON.stringify(reqConfig.body) : "";
1768
1772
  const timestamp = getNow();
@@ -1791,7 +1795,7 @@ var OkxRestClient = class _OkxRestClient {
1791
1795
  const rawText = await response.text();
1792
1796
  const elapsed = Date.now() - t0;
1793
1797
  const traceId = extractTraceId(response.headers);
1794
- this.doh.cacheDirectIfNeeded();
1798
+ this.pilot.cacheDirectIfNeeded();
1795
1799
  return this.processResponse(rawText, response, elapsed, traceId, reqConfig, requestPath);
1796
1800
  }
1797
1801
  };
@@ -2248,7 +2252,7 @@ var MODULE_DESCRIPTIONS = {
2248
2252
  bot: "Trading bot strategies (grid, dca)",
2249
2253
  config: "Manage CLI configuration profiles",
2250
2254
  setup: "Set up client integrations (Cursor, Windsurf, Claude, etc.)",
2251
- doh: "Manage DoH (DNS-over-HTTPS) resolver binary",
2255
+ pilot: "Manage Pilot proxy resolver binary",
2252
2256
  diagnose: "Run network / MCP server diagnostics",
2253
2257
  upgrade: "Upgrade okx CLI and MCP server to the latest stable version",
2254
2258
  skill: SKILLS_MARKETPLACE_DESC
@@ -2398,6 +2402,10 @@ function registerAccountTools() {
2398
2402
  showValuation: {
2399
2403
  type: "boolean",
2400
2404
  description: "Include total asset valuation breakdown by account type (trading/funding/earn). Default false."
2405
+ },
2406
+ valuationCcy: {
2407
+ type: "string",
2408
+ description: "Currency used to denominate the total asset valuation (e.g. USDT, BTC). Default USDT. Only applies when showValuation=true."
2401
2409
  }
2402
2410
  }
2403
2411
  },
@@ -2405,6 +2413,7 @@ function registerAccountTools() {
2405
2413
  const args = asRecord(rawArgs);
2406
2414
  const ccy = readString(args, "ccy");
2407
2415
  const showValuation = readBoolean(args, "showValuation");
2416
+ const valuationCcy = readString(args, "valuationCcy") ?? "USDT";
2408
2417
  if (showValuation) {
2409
2418
  const balanceResp2 = await context.client.privateGet(
2410
2419
  "/api/v5/asset/balances",
@@ -2412,16 +2421,26 @@ function registerAccountTools() {
2412
2421
  privateRateLimit("account_get_asset_balance", 6)
2413
2422
  );
2414
2423
  let valuationData = null;
2424
+ let valuationError;
2415
2425
  try {
2416
2426
  const valuationResp = await context.client.privateGet(
2417
2427
  "/api/v5/asset/asset-valuation",
2418
- {},
2428
+ { ccy: valuationCcy },
2419
2429
  privateRateLimit("account_get_asset_valuation", 1)
2420
2430
  );
2421
2431
  valuationData = valuationResp.data;
2422
- } catch {
2432
+ } catch (err) {
2433
+ valuationError = err instanceof Error ? err.message : String(err);
2434
+ }
2435
+ const valuationResult = {
2436
+ ...normalizeResponse(balanceResp2),
2437
+ valuation: valuationData,
2438
+ valuationCcy
2439
+ };
2440
+ if (valuationError !== void 0) {
2441
+ valuationResult["valuationError"] = valuationError;
2423
2442
  }
2424
- return { ...normalizeResponse(balanceResp2), valuation: valuationData };
2443
+ return valuationResult;
2425
2444
  }
2426
2445
  const balanceResp = await context.client.privateGet(
2427
2446
  "/api/v5/asset/balances",
@@ -6557,9 +6576,9 @@ function registerEventContractTools() {
6557
6576
  var PATH_LEADERBOARD = "/api/v5/orbit/public/leaderboard";
6558
6577
  var PATH_POSITION_CURRENT = "/api/v5/orbit/public/position-current";
6559
6578
  var PATH_TRADE_RECORDS = "/api/v5/orbit/public/trade-records";
6560
- var PATH_OVERVIEW = "/api/v5/journal/public/smartmoney/overview";
6561
- var PATH_SIGNAL = "/api/v5/journal/public/smartmoney/signal";
6562
- var PATH_SIGNAL_HISTORY = "/api/v5/journal/public/smartmoney/signal-history";
6579
+ var PATH_OVERVIEW = "/api/v5/journal/smartmoney/overview";
6580
+ var PATH_SIGNAL = "/api/v5/journal/smartmoney/signal";
6581
+ var PATH_SIGNAL_HISTORY = "/api/v5/journal/smartmoney/signal-history";
6563
6582
  var SIGNAL_POOL_FILTER_PROPS = {
6564
6583
  sortType: {
6565
6584
  type: "string",
@@ -6629,23 +6648,6 @@ function extractLeaderboardData(data) {
6629
6648
  }
6630
6649
  return [];
6631
6650
  }
6632
- var SMARTMONEY_DEMO_MESSAGE = "Smart Money features are not available in demo/simulated trading mode.";
6633
- var SMARTMONEY_DEMO_SUGGESTION = "Switch to a live profile to use Smart Money features.";
6634
- function withSmartmoneyDemoGuard(tool) {
6635
- const originalHandler = tool.handler;
6636
- return {
6637
- ...tool,
6638
- handler: async (args, context) => {
6639
- if (context.config.demo) {
6640
- throw new ConfigError(
6641
- SMARTMONEY_DEMO_MESSAGE,
6642
- SMARTMONEY_DEMO_SUGGESTION
6643
- );
6644
- }
6645
- return originalHandler(args, context);
6646
- }
6647
- };
6648
- }
6649
6651
  function registerSmartmoneyTools() {
6650
6652
  const tools = [
6651
6653
  /* ---------- 1. Overview ---------- */
@@ -6716,18 +6718,18 @@ function registerSmartmoneyTools() {
6716
6718
  {
6717
6719
  name: "smartmoney_get_signal",
6718
6720
  module: "smartmoney",
6719
- description: "Single-currency consensus signal: long/short ratio, entry prices, trend, capital flow. Requires instId or instCcy. Pass ts=Date.now() for latest data, or dataVersion from a prior call. For multi-currency overview, use smartmoney_get_overview. For timeline, use smartmoney_get_signal_history.",
6721
+ description: "Single-currency consensus signal: long/short ratio, entry prices, trend, capital flow. Prefer instId (e.g. BTC-USDT-SWAP); instCcy is accepted but may return empty \u2014 use instId for reliable results. Pass ts=Date.now() for latest data, or dataVersion from a prior call. For multi-currency overview, use smartmoney_get_overview. For timeline, use smartmoney_get_signal_history.",
6720
6722
  isWrite: false,
6721
6723
  inputSchema: {
6722
6724
  type: "object",
6723
6725
  properties: {
6724
6726
  instId: {
6725
6727
  type: "string",
6726
- description: "e.g. BTC-USDT-SWAP (or use instCcy)"
6728
+ description: "Recommended. e.g. BTC-USDT-SWAP"
6727
6729
  },
6728
6730
  instCcy: {
6729
6731
  type: "string",
6730
- description: "e.g. BTC, SPOT/SWAP only (or use instId)"
6732
+ description: "e.g. BTC, SPOT/SWAP only. May return empty \u2014 prefer instId."
6731
6733
  },
6732
6734
  dataVersion: {
6733
6735
  type: "string",
@@ -6799,11 +6801,11 @@ function registerSmartmoneyTools() {
6799
6801
  },
6800
6802
  granularity: {
6801
6803
  type: "string",
6802
- description: "1h or 1d"
6804
+ description: "1h or 1d (default 1h)"
6803
6805
  },
6804
6806
  limit: {
6805
6807
  type: "string",
6806
- description: "Data points 1-500"
6808
+ description: "Data points 1-500 (default 24)"
6807
6809
  },
6808
6810
  ...SIGNAL_POOL_FILTER_PROPS
6809
6811
  },
@@ -6947,7 +6949,7 @@ function registerSmartmoneyTools() {
6947
6949
  }
6948
6950
  }
6949
6951
  ];
6950
- return tools.map(withSmartmoneyDemoGuard);
6952
+ return tools;
6951
6953
  }
6952
6954
  function buildContractTradeTools(cfg) {
6953
6955
  const { prefix, module, label, instTypes, instIdExample } = cfg;
@@ -10745,18 +10747,20 @@ var CDN_SOURCES = [
10745
10747
  { host: "static.okx.com", protocol: "https" },
10746
10748
  { host: "static.coinall.ltd", protocol: "https" }
10747
10749
  ];
10748
- var CDN_PATH_PREFIX = "/upgradeapp/doh";
10750
+ var CDN_PATH_PREFIX = "/upgradeapp/tools/pilot";
10749
10751
  var DOWNLOAD_TIMEOUT_MS = 3e4;
10752
+ var PLATFORM_MAP = {
10753
+ "darwin-arm64": "darwin-arm64",
10754
+ "darwin-x64": "darwin-x64",
10755
+ "linux-arm64": "linux-arm64",
10756
+ "linux-x64": "linux-x64",
10757
+ "win32-arm64": "win32-arm64",
10758
+ "win32-x64": "win32-x64"
10759
+ };
10750
10760
  function getPlatformDir() {
10751
10761
  const p = platform();
10752
10762
  const a = arch();
10753
- const map = {
10754
- "darwin-arm64": "darwin-arm64",
10755
- "darwin-x64": "darwin-x64",
10756
- "linux-x64": "linux-x64",
10757
- "win32-x64": "win32-x64"
10758
- };
10759
- return map[`${p}-${a}`] ?? null;
10763
+ return PLATFORM_MAP[`${p}-${a}`] ?? null;
10760
10764
  }
10761
10765
  function getBinaryName() {
10762
10766
  return platform() === "win32" ? "okx-pilot.exe" : "okx-pilot";
@@ -10768,8 +10772,8 @@ function hashFile(filePath) {
10768
10772
  sha256: createHash("sha256").update(buf).digest("hex")
10769
10773
  };
10770
10774
  }
10771
- function getDohStatus(binaryPath, opts) {
10772
- const resolvedPath = binaryPath ?? getDohBinaryPath();
10775
+ function getPilotStatus(binaryPath, opts) {
10776
+ const resolvedPath = binaryPath ?? getPilotBinaryPath();
10773
10777
  const platformDir = getPlatformDir();
10774
10778
  if (!existsSync6(resolvedPath)) {
10775
10779
  return {
@@ -10861,7 +10865,7 @@ function atomicReplace(tmpPath, resolvedDest) {
10861
10865
  }
10862
10866
  }
10863
10867
  function installPreChecks(destPath, sources) {
10864
- if (!destPath && process.env.OKX_DOH_BINARY_PATH) {
10868
+ if (!destPath && process.env.OKX_PILOT_BINARY_PATH) {
10865
10869
  return { status: "up-to-date", source: "(env override)" };
10866
10870
  }
10867
10871
  if (!getPlatformDir()) {
@@ -10875,7 +10879,7 @@ function installPreChecks(destPath, sources) {
10875
10879
  function isLocalUpToDate(localHash, checksum) {
10876
10880
  return localHash !== null && localHash.size === checksum.size && localHash.sha256 === checksum.sha256;
10877
10881
  }
10878
- async function installDohBinary(destPath, sources = CDN_SOURCES, onProgress) {
10882
+ async function installPilotBinary(destPath, sources = CDN_SOURCES, onProgress) {
10879
10883
  const earlyResult = installPreChecks(destPath, sources);
10880
10884
  if (earlyResult) return earlyResult;
10881
10885
  const platformDir = getPlatformDir();
@@ -10918,8 +10922,8 @@ async function installDohBinary(destPath, sources = CDN_SOURCES, onProgress) {
10918
10922
  return { status: "failed", error: `All CDN sources failed:
10919
10923
  ${errors.join("\n")}` };
10920
10924
  }
10921
- function removeDohBinary(binaryPath) {
10922
- const resolvedPath = binaryPath ?? getDohBinaryPath();
10925
+ function removePilotBinary(binaryPath) {
10926
+ const resolvedPath = binaryPath ?? getPilotBinaryPath();
10923
10927
  try {
10924
10928
  unlinkSync3(resolvedPath);
10925
10929
  return { status: "removed" };
@@ -11642,7 +11646,7 @@ async function cmdDiagnoseMcp(options = {}) {
11642
11646
 
11643
11647
  // src/commands/diagnose.ts
11644
11648
  var CLI_VERSION = readCliVersion();
11645
- var GIT_HASH = true ? "d5c8ab1" : "dev";
11649
+ var GIT_HASH = true ? "e0ee5a96" : "dev";
11646
11650
  function maskKey2(key) {
11647
11651
  if (!key) return "(not set)";
11648
11652
  if (key.length <= 8) return "****";
@@ -11884,42 +11888,42 @@ async function cmdDiagnose(config, profile, options = {}) {
11884
11888
  }
11885
11889
  return runCliChecks(config, profile, options.output);
11886
11890
  }
11887
- async function checkDoh(report) {
11888
- section("DoH Resolver");
11889
- const local = getDohStatus();
11891
+ async function checkPilot(report) {
11892
+ section("Pilot");
11893
+ const local = getPilotStatus();
11890
11894
  if (!local.exists) {
11891
- fail("DoH binary", "not installed", [
11892
- "Run: okx doh install",
11895
+ fail("Pilot binary", "not installed", [
11896
+ "Run: okx pilot install",
11893
11897
  "Or wait for the next npm install to auto-download"
11894
11898
  ]);
11895
- report.add("doh_binary", "not installed");
11899
+ report.add("pilot_binary", "not installed");
11896
11900
  return;
11897
11901
  }
11898
- ok("DoH binary", local.binaryPath);
11899
- report.add("doh_binary", `installed (${local.platform ?? "unknown"})`);
11902
+ ok("Pilot binary", local.binaryPath);
11903
+ report.add("pilot_binary", `installed (${local.platform ?? "unknown"})`);
11900
11904
  const cdnChecksum = await fetchCdnChecksum(void 0, 5e3);
11901
11905
  if (!cdnChecksum) {
11902
- warn("DoH checksum", "CDN unreachable \u2014 cannot verify");
11903
- report.add("doh_checksum", "CDN unreachable");
11906
+ warn("Pilot checksum", "CDN unreachable \u2014 cannot verify");
11907
+ report.add("pilot_checksum", "CDN unreachable");
11904
11908
  } else if (cdnChecksum.sha256 === local.sha256) {
11905
- ok("DoH checksum", `match (${cdnChecksum.source})`);
11906
- report.add("doh_checksum", `match (${cdnChecksum.source})`);
11909
+ ok("Pilot checksum", `match (${cdnChecksum.source})`);
11910
+ report.add("pilot_checksum", `match (${cdnChecksum.source})`);
11907
11911
  } else {
11908
- warn("DoH checksum", "mismatch \u2014 update available", ["Run: okx doh install"]);
11909
- report.add("doh_checksum", "mismatch");
11912
+ warn("Pilot checksum", "mismatch \u2014 update available", ["Run: okx pilot install"]);
11913
+ report.add("pilot_checksum", "mismatch");
11910
11914
  }
11911
11915
  try {
11912
11916
  const cacheEntry = readCache("www.okx.com");
11913
11917
  if (cacheEntry) {
11914
- ok("DoH mode", cacheEntry.mode);
11915
- report.add("doh_mode", cacheEntry.mode);
11918
+ ok("Pilot mode", cacheEntry.mode);
11919
+ report.add("pilot_mode", cacheEntry.mode);
11916
11920
  } else {
11917
- ok("DoH mode", "no cache (will auto-detect on next request)");
11918
- report.add("doh_mode", "no cache");
11921
+ ok("Pilot mode", "no cache (will auto-detect on next request)");
11922
+ report.add("pilot_mode", "no cache");
11919
11923
  }
11920
11924
  } catch {
11921
- ok("DoH mode", "no cache");
11922
- report.add("doh_mode", "no cache");
11925
+ ok("Pilot mode", "no cache");
11926
+ report.add("pilot_mode", "no cache");
11923
11927
  }
11924
11928
  }
11925
11929
  function checkConfigFile(report) {
@@ -11950,7 +11954,7 @@ async function runCliChecks(config, profile, outputPath) {
11950
11954
  report.add("ts", (/* @__PURE__ */ new Date()).toISOString());
11951
11955
  const configFilePassed = checkConfigFile(report);
11952
11956
  const envPassed = checkEnvironment(report);
11953
- await checkDoh(report);
11957
+ await checkPilot(report);
11954
11958
  if (!config) {
11955
11959
  fail("Config", "Could not load config (see Config File check above)", []);
11956
11960
  report.add("result", "FAIL");
@@ -11976,6 +11980,31 @@ async function runCliChecks(config, profile, outputPath) {
11976
11980
  writeReportIfRequested(report, outputPath);
11977
11981
  }
11978
11982
 
11983
+ // src/unknown-command.ts
11984
+ function unknownSubcommand(module, action, knownActions) {
11985
+ const actionStr = action ?? "(missing)";
11986
+ errorLine(`Unknown command: okx ${module} ${actionStr}`);
11987
+ const hint = suggestSubcommand(action, knownActions);
11988
+ if (hint) {
11989
+ errorLine(` Did you mean: okx ${module} ${hint} ?`);
11990
+ }
11991
+ if (knownActions.length > 0) {
11992
+ errorLine(` Available subcommands: ${knownActions.join(", ")}`);
11993
+ }
11994
+ errorLine(` Run 'okx ${module} --help' for full usage.`);
11995
+ process.exitCode = 1;
11996
+ }
11997
+ function suggestSubcommand(action, knownActions) {
11998
+ if (!action || !action.includes("-")) return void 0;
11999
+ const parts = action.split("-");
12000
+ if (parts.length !== 2) return void 0;
12001
+ const [a, b] = parts;
12002
+ if (knownActions.includes(b)) {
12003
+ return `${b} ${a}`;
12004
+ }
12005
+ return void 0;
12006
+ }
12007
+
11979
12008
  // src/commands/upgrade.ts
11980
12009
  import { spawnSync as spawnSync2 } from "child_process";
11981
12010
  import { readFileSync as readFileSync8, writeFileSync as writeFileSync7, mkdirSync as mkdirSync9 } from "fs";
@@ -12931,7 +12960,7 @@ var CLI_REGISTRY = {
12931
12960
  signal: {
12932
12961
  toolName: "smartmoney_get_signal",
12933
12962
  usage: "okx smartmoney signal [--instId <id>] [--instCcy <ccy>] [--dataVersion <ver>] [--ts <ms>] [--sortType <pnl|pnlRatio>] [--period <3|7|30|90>] [--pnl <tier>] [--winRatio <tier>] [--maxRetreat <tier>] [--asset <tier>] [--lmtNum <n>] [--authorIds <ids>] [--json]",
12934
- description: "Single-currency aggregated consensus signal"
12963
+ description: "Single-currency aggregated consensus signal (prefer --instId; --instCcy may return empty)"
12935
12964
  },
12936
12965
  "signal-history": {
12937
12966
  toolName: "smartmoney_get_signal_history",
@@ -12981,24 +13010,24 @@ var CLI_REGISTRY = {
12981
13010
  description: "Set up client integrations (Cursor, Windsurf, Claude, etc.)",
12982
13011
  usage: `okx setup --client <${SUPPORTED_CLIENTS.join("|")}> [--profile <name>] [--modules <list>]`
12983
13012
  },
12984
- // ── doh ────────────────────────────────────────────────────────────────────
12985
- doh: {
12986
- description: "Manage DoH (DNS-over-HTTPS) resolver binary",
13013
+ // ── pilot ──────────────────────────────────────────────────────────────────
13014
+ pilot: {
13015
+ description: "Manage Pilot proxy resolver binary",
12987
13016
  commands: {
12988
13017
  status: {
12989
13018
  toolName: null,
12990
- usage: "okx doh status [--json]",
12991
- description: "Show DoH binary info, checksum, and CDN match status"
13019
+ usage: "okx pilot status [--json]",
13020
+ description: "Show Pilot binary info, checksum, and CDN match status"
12992
13021
  },
12993
13022
  install: {
12994
13023
  toolName: null,
12995
- usage: "okx doh install [--json]",
12996
- description: "Download or update the DoH resolver binary"
13024
+ usage: "okx pilot install [--json]",
13025
+ description: "Download or update the Pilot binary"
12997
13026
  },
12998
13027
  remove: {
12999
13028
  toolName: null,
13000
- usage: "okx doh remove [--force] [--json]",
13001
- description: "Remove the DoH resolver binary (prompts for confirmation without --force)"
13029
+ usage: "okx pilot remove [--force] [--json]",
13030
+ description: "Remove the Pilot binary (prompts for confirmation without --force)"
13002
13031
  }
13003
13032
  }
13004
13033
  },
@@ -13685,6 +13714,7 @@ var CLI_OPTIONS = {
13685
13714
  // account extras
13686
13715
  archive: { type: "boolean", default: false },
13687
13716
  valuation: { type: "boolean", default: false },
13717
+ valuationCcy: { type: "string" },
13688
13718
  posMode: { type: "string" },
13689
13719
  ccy: { type: "string" },
13690
13720
  from: { type: "string" },
@@ -14288,13 +14318,14 @@ async function cmdAccountBalance(run, ccy, json) {
14288
14318
  }
14289
14319
  printTable(rows);
14290
14320
  }
14291
- async function cmdAccountAssetBalance(run, ccy, json, showValuation) {
14321
+ async function cmdAccountAssetBalance(run, ccy, json, showValuation, valuationCcy) {
14292
14322
  const result = await run("account_get_asset_balance", {
14293
14323
  ccy,
14294
- ...showValuation ? { showValuation: true } : {}
14324
+ ...showValuation ? { showValuation: true } : {},
14325
+ ...valuationCcy !== void 0 ? { valuationCcy } : {}
14295
14326
  });
14296
14327
  const data = result.data ?? [];
14297
- if (json) return printJson(showValuation ? { data, valuation: result.valuation } : data);
14328
+ if (json) return printJson(showValuation ? { data, valuation: result.valuation, valuationCcy: result.valuationCcy } : data);
14298
14329
  const assetRows = data.filter((r) => Number(r["bal"]) > 0).map((r) => ({
14299
14330
  ccy: r["ccy"],
14300
14331
  bal: r["bal"],
@@ -14309,7 +14340,7 @@ async function cmdAccountAssetBalance(run, ccy, json, showValuation) {
14309
14340
  if (showValuation && result.valuation) {
14310
14341
  const valuationData = result.valuation ?? [];
14311
14342
  outputLine("");
14312
- outputLine("Asset Valuation by Account Type:");
14343
+ outputLine(`Asset Valuation by Account Type (${String(result.valuationCcy ?? "USDT")}):`);
14313
14344
  printTable(
14314
14345
  valuationData.map((v) => {
14315
14346
  const details = v["details"] ?? {};
@@ -17205,7 +17236,7 @@ function printSkillInstallResult(meta, json) {
17205
17236
  }
17206
17237
  }
17207
17238
 
17208
- // src/commands/doh.ts
17239
+ // src/commands/pilot.ts
17209
17240
  import readline from "readline";
17210
17241
  function resolveChecksumMatch(local, cdnChecksum, cdnError) {
17211
17242
  if (!local.exists) return "not-installed";
@@ -17220,7 +17251,7 @@ function checksumMatchLabel(match) {
17220
17251
  }
17221
17252
  function formatStatusText(local, checksumMatch, cdnChecksum, runtimeMode) {
17222
17253
  outputLine("");
17223
- outputLine(" DoH Resolver Status");
17254
+ outputLine(" Pilot Status");
17224
17255
  outputLine(" " + "\u2500".repeat(40));
17225
17256
  outputLine(` Binary path : ${local.binaryPath}`);
17226
17257
  outputLine(` Installed : ${local.exists ? "yes" : "no"}`);
@@ -17236,8 +17267,8 @@ function formatStatusText(local, checksumMatch, cdnChecksum, runtimeMode) {
17236
17267
  outputLine(` Runtime mode: ${runtimeMode}`);
17237
17268
  outputLine("");
17238
17269
  }
17239
- async function cmdDohStatus(json, binaryPath) {
17240
- const local = getDohStatus(binaryPath);
17270
+ async function cmdPilotStatus(json, binaryPath) {
17271
+ const local = getPilotStatus(binaryPath);
17241
17272
  let runtimeMode = "no cache";
17242
17273
  try {
17243
17274
  const cacheEntry = readCache("www.okx.com");
@@ -17274,7 +17305,7 @@ async function cmdDohStatus(json, binaryPath) {
17274
17305
  }
17275
17306
  formatStatusText(local, checksumMatch, cdnChecksum, runtimeMode);
17276
17307
  }
17277
- async function cmdDohInstall(json, binaryPath) {
17308
+ async function cmdPilotInstall(json, binaryPath) {
17278
17309
  const messages2 = [];
17279
17310
  const onProgress = (msg) => {
17280
17311
  if (!json) {
@@ -17284,9 +17315,9 @@ async function cmdDohInstall(json, binaryPath) {
17284
17315
  };
17285
17316
  if (!json) {
17286
17317
  outputLine("");
17287
- outputLine(" Installing DoH resolver...");
17318
+ outputLine(" Installing Pilot...");
17288
17319
  }
17289
- const result = await installDohBinary(binaryPath, void 0, onProgress);
17320
+ const result = await installPilotBinary(binaryPath, void 0, onProgress);
17290
17321
  if (json) {
17291
17322
  outputLine(JSON.stringify({ status: result.status, source: result.source ?? null, error: result.error ?? null, messages: messages2 }));
17292
17323
  if (result.status === "failed") {
@@ -17295,9 +17326,9 @@ async function cmdDohInstall(json, binaryPath) {
17295
17326
  return;
17296
17327
  }
17297
17328
  if (result.status === "installed") {
17298
- outputLine(` \u2713 DoH resolver installed successfully (${result.source ?? ""})`);
17329
+ outputLine(` \u2713 Pilot installed successfully (${result.source ?? ""})`);
17299
17330
  } else if (result.status === "up-to-date") {
17300
- outputLine(" \u2713 DoH resolver is already up to date");
17331
+ outputLine(" \u2713 Pilot is already up to date");
17301
17332
  } else {
17302
17333
  errorLine(` \u2717 Installation failed: ${result.error ?? "unknown error"}`);
17303
17334
  errorLine(" Hint: check network connectivity or try again later");
@@ -17305,13 +17336,13 @@ async function cmdDohInstall(json, binaryPath) {
17305
17336
  }
17306
17337
  outputLine("");
17307
17338
  }
17308
- async function cmdDohRemove(force, json, binaryPath) {
17309
- const local = getDohStatus(binaryPath);
17339
+ async function cmdPilotRemove(force, json, binaryPath) {
17340
+ const local = getPilotStatus(binaryPath);
17310
17341
  if (!local.exists) {
17311
17342
  if (json) {
17312
17343
  outputLine(JSON.stringify({ status: "not-installed" }));
17313
17344
  } else {
17314
- outputLine(" DoH resolver is not installed.");
17345
+ outputLine(" Pilot is not installed.");
17315
17346
  }
17316
17347
  return;
17317
17348
  }
@@ -17322,14 +17353,14 @@ async function cmdDohRemove(force, json, binaryPath) {
17322
17353
  return;
17323
17354
  }
17324
17355
  const confirmed = await askConfirmation(
17325
- ` Remove DoH resolver at ${local.binaryPath}? [y/N] `
17356
+ ` Remove Pilot at ${local.binaryPath}? [y/N] `
17326
17357
  );
17327
17358
  if (!confirmed) {
17328
17359
  outputLine(" Cancelled.");
17329
17360
  return;
17330
17361
  }
17331
17362
  }
17332
- const result = removeDohBinary(binaryPath);
17363
+ const result = removePilotBinary(binaryPath);
17333
17364
  if (json) {
17334
17365
  outputLine(JSON.stringify({ status: result.status, path: local.binaryPath }));
17335
17366
  return;
@@ -17337,7 +17368,7 @@ async function cmdDohRemove(force, json, binaryPath) {
17337
17368
  if (result.status === "removed") {
17338
17369
  outputLine(` \u2713 Removed: ${local.binaryPath}`);
17339
17370
  } else {
17340
- outputLine(" DoH resolver is not installed.");
17371
+ outputLine(" Pilot is not installed.");
17341
17372
  }
17342
17373
  }
17343
17374
  function formatBytes(bytes) {
@@ -17804,13 +17835,13 @@ async function cmdEventCancel(run, opts) {
17804
17835
  // src/index.ts
17805
17836
  var _require3 = createRequire3(import.meta.url);
17806
17837
  var CLI_VERSION2 = _require3("../package.json").version;
17807
- var GIT_HASH2 = true ? "d5c8ab1" : "dev";
17808
- function handleDohCommand(action, json, force, binaryPath) {
17809
- if (action === "status") return cmdDohStatus(json, binaryPath);
17810
- if (action === "install") return cmdDohInstall(json, binaryPath);
17811
- if (action === "remove") return cmdDohRemove(force, json, binaryPath);
17812
- errorLine(`Unknown doh command: ${action}`);
17813
- errorLine("Usage: okx doh <status|install|remove>");
17838
+ var GIT_HASH2 = true ? "e0ee5a96" : "dev";
17839
+ function handlePilotCommand(action, json, force, binaryPath) {
17840
+ if (action === "status") return cmdPilotStatus(json, binaryPath);
17841
+ if (action === "install") return cmdPilotInstall(json, binaryPath);
17842
+ if (action === "remove") return cmdPilotRemove(force, json, binaryPath);
17843
+ errorLine(`Unknown pilot command: ${action}`);
17844
+ errorLine("Usage: okx pilot <status|install|remove>");
17814
17845
  process.exitCode = 1;
17815
17846
  }
17816
17847
  function handleConfigCommand(action, rest, json, lang, force) {
@@ -17909,9 +17940,6 @@ function handleMarketFilterCommand(run, action, rest, v, json) {
17909
17940
  limit,
17910
17941
  json
17911
17942
  });
17912
- errorLine(`Unknown market command: ${action}`);
17913
- errorLine("Valid: ticker, tickers, orderbook, candles, trades, instruments, mark-price, funding-rate, open-interest, index-ticker, price-limit, stock-tokens, instruments-by-category, indicator, filter, oi-history, oi-change");
17914
- process.exitCode = 1;
17915
17943
  }
17916
17944
  function handleIndicatorAction(run, rest, v, json) {
17917
17945
  if (rest[0] === "list") return cmdMarketIndicatorList(json);
@@ -17940,7 +17968,28 @@ function handleMarketDataCommand(run, action, rest, v, json) {
17940
17968
  return cmdMarketIndexCandles(run, rest[0], { bar: v.bar, limit, history: v.history ?? false, json, demo: v.demo });
17941
17969
  }
17942
17970
  function handleMarketCommand(run, action, rest, v, json) {
17943
- return handleMarketPublicCommand(run, action, rest, v, json) ?? handleMarketDataCommand(run, action, rest, v, json);
17971
+ const result = handleMarketPublicCommand(run, action, rest, v, json) ?? handleMarketDataCommand(run, action, rest, v, json);
17972
+ if (result !== void 0) return result;
17973
+ unknownSubcommand("market", action, [
17974
+ "ticker",
17975
+ "tickers",
17976
+ "orderbook",
17977
+ "candles",
17978
+ "trades",
17979
+ "instruments",
17980
+ "mark-price",
17981
+ "funding-rate",
17982
+ "open-interest",
17983
+ "index-ticker",
17984
+ "price-limit",
17985
+ "stock-tokens",
17986
+ "instruments-by-category",
17987
+ "indicator",
17988
+ "filter",
17989
+ "oi-history",
17990
+ "oi-change",
17991
+ "index-candles"
17992
+ ]);
17944
17993
  }
17945
17994
  function handleAccountWriteCommand(run, action, v, json) {
17946
17995
  if (action === "set-position-mode")
@@ -17960,13 +18009,28 @@ function handleAccountWriteCommand(run, action, v, json) {
17960
18009
  subAcct: v.subAcct,
17961
18010
  json
17962
18011
  });
18012
+ unknownSubcommand("account", action, [
18013
+ "audit",
18014
+ "balance",
18015
+ "asset-balance",
18016
+ "positions",
18017
+ "positions-history",
18018
+ "bills",
18019
+ "fees",
18020
+ "config",
18021
+ "set-position-mode",
18022
+ "max-size",
18023
+ "max-avail-size",
18024
+ "max-withdrawal",
18025
+ "transfer"
18026
+ ]);
17963
18027
  }
17964
18028
  function handleAccountCommand(run, action, rest, v, json) {
17965
18029
  if (action === "audit")
17966
18030
  return cmdAccountAudit({ limit: v.limit, tool: v.tool, since: v.since, json });
17967
18031
  const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
17968
18032
  if (action === "balance") return cmdAccountBalance(run, rest[0], json);
17969
- if (action === "asset-balance") return cmdAccountAssetBalance(run, v.ccy, json, v.valuation);
18033
+ if (action === "asset-balance") return cmdAccountAssetBalance(run, v.ccy, json, v.valuation, v.valuationCcy);
17970
18034
  if (action === "positions")
17971
18035
  return cmdAccountPositions(run, { instType: v.instType, instId: v.instId, json });
17972
18036
  if (action === "positions-history")
@@ -18039,6 +18103,7 @@ function handleSpotAlgoCommand(run, subAction, v, json) {
18039
18103
  ordType: v.ordType,
18040
18104
  json
18041
18105
  });
18106
+ unknownSubcommand("spot algo", subAction, ["trail", "place", "amend", "cancel", "orders"]);
18042
18107
  }
18043
18108
  function handleSpotCommand(run, action, rest, v, json) {
18044
18109
  if (action === "orders")
@@ -18090,6 +18155,17 @@ function handleSpotCommand(run, action, rest, v, json) {
18090
18155
  mgnMode: v.mgnMode,
18091
18156
  json
18092
18157
  });
18158
+ unknownSubcommand("spot", action, [
18159
+ "orders",
18160
+ "get",
18161
+ "fills",
18162
+ "place",
18163
+ "cancel",
18164
+ "amend",
18165
+ "algo",
18166
+ "batch",
18167
+ "leverage"
18168
+ ]);
18093
18169
  }
18094
18170
  function handleSwapAlgoCommand(run, subAction, v, json) {
18095
18171
  if (subAction === "trail")
@@ -18145,6 +18221,7 @@ function handleSwapAlgoCommand(run, subAction, v, json) {
18145
18221
  ordType: v.ordType,
18146
18222
  json
18147
18223
  });
18224
+ unknownSubcommand("swap algo", subAction, ["trail", "place", "amend", "cancel", "orders"]);
18148
18225
  }
18149
18226
  function handleSwapQuery(run, action, rest, v, json) {
18150
18227
  if (action === "positions")
@@ -18220,6 +18297,20 @@ function handleSwapCommand(run, action, rest, v, json) {
18220
18297
  return handleSwapAlgoCommand(run, rest[0], v, json);
18221
18298
  if (action === "batch")
18222
18299
  return cmdSwapBatch(run, { action: v.action, orders: v.orders, json });
18300
+ unknownSubcommand("swap", action, [
18301
+ "positions",
18302
+ "orders",
18303
+ "get",
18304
+ "fills",
18305
+ "get-leverage",
18306
+ "place",
18307
+ "cancel",
18308
+ "amend",
18309
+ "close",
18310
+ "leverage",
18311
+ "algo",
18312
+ "batch"
18313
+ ]);
18223
18314
  }
18224
18315
  function handleOptionAlgoCommand(run, subAction, v, json) {
18225
18316
  if (subAction === "place")
@@ -18258,6 +18349,7 @@ function handleOptionAlgoCommand(run, subAction, v, json) {
18258
18349
  ordType: v.ordType,
18259
18350
  json
18260
18351
  });
18352
+ unknownSubcommand("option algo", subAction, ["place", "amend", "cancel", "orders"]);
18261
18353
  }
18262
18354
  function handleOptionCommand(run, action, rest, v, json) {
18263
18355
  if (action === "orders") {
@@ -18308,6 +18400,19 @@ function handleOptionCommand(run, action, rest, v, json) {
18308
18400
  return cmdOptionBatchCancel(run, { orders: v.orders, json });
18309
18401
  if (action === "algo")
18310
18402
  return handleOptionAlgoCommand(run, rest[0], v, json);
18403
+ unknownSubcommand("option", action, [
18404
+ "orders",
18405
+ "get",
18406
+ "positions",
18407
+ "fills",
18408
+ "instruments",
18409
+ "greeks",
18410
+ "place",
18411
+ "cancel",
18412
+ "amend",
18413
+ "batch-cancel",
18414
+ "algo"
18415
+ ]);
18311
18416
  }
18312
18417
  function handleFuturesAlgoCommand(run, subAction, v, json) {
18313
18418
  if (subAction === "trail")
@@ -18363,6 +18468,7 @@ function handleFuturesAlgoCommand(run, subAction, v, json) {
18363
18468
  ordType: v.ordType,
18364
18469
  json
18365
18470
  });
18471
+ unknownSubcommand("futures algo", subAction, ["trail", "place", "amend", "cancel", "orders"]);
18366
18472
  }
18367
18473
  function resolveFuturesOrdersStatus(v) {
18368
18474
  if (v.archive) return "archive";
@@ -18438,6 +18544,20 @@ function handleFuturesCommand(run, action, rest, v, json) {
18438
18544
  return cmdFuturesBatch(run, { action: v.action, orders: v.orders, json });
18439
18545
  if (action === "algo")
18440
18546
  return handleFuturesAlgoCommand(run, rest[0], v, json);
18547
+ unknownSubcommand("futures", action, [
18548
+ "orders",
18549
+ "positions",
18550
+ "fills",
18551
+ "get",
18552
+ "get-leverage",
18553
+ "place",
18554
+ "cancel",
18555
+ "amend",
18556
+ "close",
18557
+ "leverage",
18558
+ "batch",
18559
+ "algo"
18560
+ ]);
18441
18561
  }
18442
18562
  function handleBotGridCommand(run, v, rest, json) {
18443
18563
  const subAction = rest[0];
@@ -18505,6 +18625,7 @@ function handleBotGridCommand(run, v, rest, json) {
18505
18625
  stopType: v.stopType,
18506
18626
  json
18507
18627
  });
18628
+ unknownSubcommand("bot grid", subAction, ["orders", "details", "sub-orders", "create", "amend", "stop"]);
18508
18629
  }
18509
18630
  function handleBotDcaCommand(run, subAction, v, json) {
18510
18631
  const algoOrdType = v.algoOrdType ?? "contract_dca";
@@ -18543,10 +18664,12 @@ function handleBotDcaCommand(run, subAction, v, json) {
18543
18664
  });
18544
18665
  if (subAction === "stop")
18545
18666
  return cmdDcaStop(run, { algoId: v.algoId, algoOrdType, stopType: v.stopType, json });
18667
+ unknownSubcommand("bot dca", subAction, ["orders", "details", "sub-orders", "create", "stop"]);
18546
18668
  }
18547
18669
  function handleBotCommand(run, action, rest, v, json) {
18548
18670
  if (action === "grid") return handleBotGridCommand(run, v, rest, json);
18549
18671
  if (action === "dca") return handleBotDcaCommand(run, rest[0], v, json);
18672
+ unknownSubcommand("bot", action, ["grid", "dca"]);
18550
18673
  }
18551
18674
  function handleEarnCommand(run, submodule, rest, v, json) {
18552
18675
  const action = rest[0];
@@ -18888,11 +19011,11 @@ async function runDiagnose(v) {
18888
19011
  }
18889
19012
  function printVersion() {
18890
19013
  outputLine(`${CLI_VERSION2} (${GIT_HASH2})`);
18891
- const dohStatus = getDohStatus(void 0, { skipHash: true });
18892
- if (dohStatus.exists) {
18893
- outputLine(`DoH resolver: installed (${dohStatus.platform ?? "unknown"})`);
19014
+ const pilotStatus = getPilotStatus(void 0, { skipHash: true });
19015
+ if (pilotStatus.exists) {
19016
+ outputLine(`Pilot: installed (${pilotStatus.platform ?? "unknown"})`);
18894
19017
  } else {
18895
- outputLine("DoH resolver: not installed");
19018
+ outputLine("Pilot: not installed");
18896
19019
  }
18897
19020
  }
18898
19021
  function routeManagementCommand(module, action, rest, json, v) {
@@ -18905,8 +19028,8 @@ function routeManagementCommand(module, action, rest, json, v) {
18905
19028
  return true;
18906
19029
  }
18907
19030
  if (module === "upgrade") return cmdUpgrade(CLI_VERSION2, { beta: v.beta, check: v.check, force: v.force }, json);
18908
- if (module === "doh") {
18909
- const r = handleDohCommand(action, json, v.force ?? false);
19031
+ if (module === "pilot") {
19032
+ const r = handlePilotCommand(action, json, v.force ?? false);
18910
19033
  return r ?? true;
18911
19034
  }
18912
19035
  if (module === "diagnose") return runDiagnose(v);
@@ -18976,7 +19099,6 @@ export {
18976
19099
  handleBotDcaCommand,
18977
19100
  handleBotGridCommand,
18978
19101
  handleConfigCommand,
18979
- handleDohCommand,
18980
19102
  handleEarnCommand,
18981
19103
  handleEventCommand,
18982
19104
  handleFuturesAlgoCommand,
@@ -18987,6 +19109,7 @@ export {
18987
19109
  handleNewsCommand,
18988
19110
  handleOptionAlgoCommand,
18989
19111
  handleOptionCommand,
19112
+ handlePilotCommand,
18990
19113
  handleSetupCommand,
18991
19114
  handleSkillCommand,
18992
19115
  handleSmartmoneyCommand,