@okx_ai/okx-trade-cli 1.3.1-beta.9 → 1.3.1

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
@@ -969,7 +969,7 @@ function classifyAndCache(node, hostname, failedNodes, cachePath) {
969
969
  if (!node) {
970
970
  return { mode: null, node: null };
971
971
  }
972
- if (node.ip === hostname || node.host === hostname) {
972
+ if (node.ip === hostname && node.host === hostname) {
973
973
  writeCache(hostname, {
974
974
  mode: "direct",
975
975
  node: null,
@@ -7843,32 +7843,34 @@ function langHeader(lang) {
7843
7843
  return { "Accept-Language": "en-US" };
7844
7844
  }
7845
7845
  var NEWS_DETAIL_LVL = ["brief", "summary", "full"];
7846
- var NEWS_IMPORTANCE = ["high", "medium", "low"];
7846
+ var NEWS_IMPORTANCE = ["high", "low"];
7847
7847
  var NEWS_SENTIMENT = ["bullish", "bearish", "neutral"];
7848
7848
  var NEWS_SORT = ["latest", "relevant"];
7849
7849
  var SENTIMENT_PERIOD = ["1h", "4h", "24h"];
7850
7850
  var D_COINS_NEWS = 'Comma-separated uppercase ticker symbols (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
7851
7851
  var D_COINS_SENTIMENT = 'Comma-separated uppercase ticker symbols, max 20 (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
7852
7852
  var D_LANGUAGE = "Content language: zh-CN or en-US. Infer from user's message. No server default.";
7853
- var D_BEGIN = "Start time, Unix epoch milliseconds. Parse relative time if given (e.g. 'yesterday', 'last 7 days').";
7853
+ var D_BEGIN = "Start time, Unix epoch milliseconds. API defaults to 72 hours ago when omitted. Pass explicitly for older topics (e.g. 'last 30 days'). Max range: 180 days. Parse relative time if given.";
7854
7854
  var D_END = "End time, Unix epoch milliseconds. Parse relative time if given. Omit for no upper bound.";
7855
- var D_IMPORTANCE = "Importance filter: high (server default), medium, low. Omit unless user wants broader coverage.";
7855
+ var D_IMPORTANCE = "Importance filter: high (server default) or low. Omit unless user wants broader coverage.";
7856
+ var D_PLATFORM = "Filter by news source. Use values from news_get_domains (e.g. blockbeats, odaily_flash). Omit for all sources.";
7856
7857
  var D_LIMIT = "Number of results (default 10, max 50).";
7857
7858
  function registerNewsTools() {
7858
- return [
7859
+ const tools = [
7859
7860
  // -----------------------------------------------------------------------
7860
7861
  // News browsing tools
7861
7862
  // -----------------------------------------------------------------------
7862
7863
  {
7863
7864
  name: "news_get_latest",
7864
7865
  module: "news",
7865
- description: "Get crypto news sorted by time. Omitting importance still returns only high-importance news (server default). Pass importance='medium' or 'low' explicitly to broaden results. Use when user asks 'what happened recently', 'latest news', 'any big news today', or wants to browse without a keyword. For coin-specific news, use news_get_by_coin instead.",
7866
+ description: "Get crypto news sorted by time. Omitting importance still returns only high-importance news (server default). Pass importance='low' explicitly to broaden results. Use when user asks 'what happened recently', 'latest news', 'any big news today', or wants to browse without a keyword. For coin-specific news, use news_get_by_coin instead.",
7866
7867
  isWrite: false,
7867
7868
  inputSchema: {
7868
7869
  type: "object",
7869
7870
  properties: {
7870
7871
  coins: { type: "string", description: D_COINS_NEWS + " Optional." },
7871
7872
  importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
7873
+ platform: { type: "string", description: D_PLATFORM },
7872
7874
  begin: { type: "number", description: D_BEGIN },
7873
7875
  end: { type: "number", description: D_END },
7874
7876
  language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
@@ -7889,6 +7891,7 @@ function registerNewsTools() {
7889
7891
  compactObject({
7890
7892
  sortBy: "latest",
7891
7893
  importance: readString(args, "importance"),
7894
+ platform: readString(args, "platform"),
7892
7895
  ccyList: readString(args, "coins"),
7893
7896
  begin: readNumber(args, "begin"),
7894
7897
  end: readNumber(args, "end"),
@@ -7912,6 +7915,7 @@ function registerNewsTools() {
7912
7915
  properties: {
7913
7916
  coins: { type: "string", description: D_COINS_NEWS + " Required." },
7914
7917
  importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
7918
+ platform: { type: "string", description: D_PLATFORM },
7915
7919
  begin: { type: "number", description: D_BEGIN },
7916
7920
  end: { type: "number", description: D_END },
7917
7921
  language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
@@ -7932,6 +7936,7 @@ function registerNewsTools() {
7932
7936
  sortBy: "latest",
7933
7937
  ccyList: coins,
7934
7938
  importance: readString(args, "importance"),
7939
+ platform: readString(args, "platform"),
7935
7940
  begin: readNumber(args, "begin"),
7936
7941
  end: readNumber(args, "end"),
7937
7942
  detailLvl: readString(args, "detailLvl"),
@@ -7957,6 +7962,7 @@ function registerNewsTools() {
7957
7962
  },
7958
7963
  coins: { type: "string", description: D_COINS_NEWS + " Optional." },
7959
7964
  importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
7965
+ platform: { type: "string", description: D_PLATFORM },
7960
7966
  sentiment: {
7961
7967
  type: "string",
7962
7968
  enum: [...NEWS_SENTIMENT],
@@ -7984,6 +7990,7 @@ function registerNewsTools() {
7984
7990
  keyword: readString(args, "keyword") || void 0,
7985
7991
  sortBy: readString(args, "sortBy") ?? "relevant",
7986
7992
  importance: readString(args, "importance"),
7993
+ platform: readString(args, "platform"),
7987
7994
  ccyList: readString(args, "coins"),
7988
7995
  sentiment: readString(args, "sentiment"),
7989
7996
  begin: readNumber(args, "begin"),
@@ -8129,6 +8136,24 @@ function registerNewsTools() {
8129
8136
  }
8130
8137
  }
8131
8138
  ];
8139
+ const domainsIdx = tools.findIndex((t) => t.name === "news_get_domains");
8140
+ if (domainsIdx === -1) throw new Error("news_get_domains not found in tools list");
8141
+ const [domainsTool] = tools.splice(domainsIdx, 1);
8142
+ return [...tools.map(withNewsDemoGuard), domainsTool];
8143
+ }
8144
+ var NEWS_DEMO_MESSAGE = "News features are not available in demo/simulated trading mode.";
8145
+ var NEWS_DEMO_SUGGESTION = "Switch to a live profile to use News features.";
8146
+ function withNewsDemoGuard(tool) {
8147
+ const originalHandler = tool.handler;
8148
+ return {
8149
+ ...tool,
8150
+ handler: async (args, context) => {
8151
+ if (context.config.demo) {
8152
+ throw new ConfigError(NEWS_DEMO_MESSAGE, NEWS_DEMO_SUGGESTION);
8153
+ }
8154
+ return originalHandler(args, context);
8155
+ }
8156
+ };
8132
8157
  }
8133
8158
  function registerOptionAlgoTools() {
8134
8159
  return [
@@ -10990,7 +11015,7 @@ async function cmdDiagnoseMcp(options = {}) {
10990
11015
 
10991
11016
  // src/commands/diagnose.ts
10992
11017
  var CLI_VERSION = readCliVersion();
10993
- var GIT_HASH = true ? "e0312e6" : "dev";
11018
+ var GIT_HASH = true ? "e9764c9" : "dev";
10994
11019
  function maskKey2(key) {
10995
11020
  if (!key) return "(not set)";
10996
11021
  if (key.length <= 8) return "****";
@@ -12314,7 +12339,7 @@ var CLI_REGISTRY = {
12314
12339
  commands: {
12315
12340
  latest: {
12316
12341
  toolName: "news_get_latest",
12317
- usage: "okx news latest [--coins BTC,ETH] [--lang zh-CN] [--limit 20]"
12342
+ usage: "okx news latest [--coins BTC,ETH] [--platform blockbeats] [--lang zh-CN] [--limit 20]"
12318
12343
  },
12319
12344
  important: {
12320
12345
  toolName: "news_get_latest",
@@ -12323,20 +12348,20 @@ var CLI_REGISTRY = {
12323
12348
  },
12324
12349
  "by-coin": {
12325
12350
  toolName: "news_get_by_coin",
12326
- usage: "okx news by-coin --coins BTC [--importance high] [--lang zh-CN]"
12351
+ usage: "okx news by-coin --coins BTC [--importance high] [--platform blockbeats] [--lang zh-CN]"
12327
12352
  },
12328
12353
  search: {
12329
12354
  toolName: "news_search",
12330
- usage: "okx news search --keyword <term> [--coins BTC] [--sentiment bullish] [--lang zh-CN]"
12355
+ usage: "okx news search --keyword <term> [--coins BTC] [--sentiment bullish] [--platform blockbeats] [--lang zh-CN]"
12331
12356
  },
12332
12357
  detail: {
12333
12358
  toolName: "news_get_detail",
12334
12359
  usage: "okx news detail <id> [--lang zh-CN]"
12335
12360
  },
12336
- domains: {
12361
+ platforms: {
12337
12362
  toolName: "news_get_domains",
12338
- usage: "okx news domains",
12339
- description: "List available news source domains"
12363
+ usage: "okx news platforms",
12364
+ description: "List available news platforms"
12340
12365
  },
12341
12366
  "coin-sentiment": {
12342
12367
  toolName: "news_get_coin_sentiment",
@@ -12349,7 +12374,7 @@ var CLI_REGISTRY = {
12349
12374
  },
12350
12375
  "by-sentiment": {
12351
12376
  toolName: "news_search",
12352
- usage: "okx news by-sentiment --sentiment bullish [--coins BTC] [--sort-by latest]",
12377
+ usage: "okx news by-sentiment --sentiment bullish [--coins BTC] [--importance high] [--platform <source>] [--sort-by latest] [--begin <ms>] [--end <ms>]",
12353
12378
  description: "Browse news filtered by sentiment direction"
12354
12379
  },
12355
12380
  "sentiment-rank": {
@@ -12557,6 +12582,7 @@ async function cmdNewsLatest(run, opts) {
12557
12582
  const result = await run("news_get_latest", {
12558
12583
  coins: opts.coins,
12559
12584
  importance: opts.importance,
12585
+ platform: opts.platform,
12560
12586
  begin: opts.begin,
12561
12587
  end: opts.end,
12562
12588
  language: opts.language,
@@ -12583,6 +12609,7 @@ async function cmdNewsImportant(run, opts) {
12583
12609
  const result = await run("news_get_latest", {
12584
12610
  coins: opts.coins,
12585
12611
  importance: "high",
12612
+ platform: opts.platform,
12586
12613
  begin: opts.begin,
12587
12614
  end: opts.end,
12588
12615
  language: opts.language,
@@ -12607,6 +12634,7 @@ async function cmdNewsByCoin(run, coins, opts) {
12607
12634
  const result = await run("news_get_by_coin", {
12608
12635
  coins,
12609
12636
  importance: opts.importance,
12637
+ platform: opts.platform,
12610
12638
  begin: opts.begin,
12611
12639
  end: opts.end,
12612
12640
  language: opts.language,
@@ -12632,6 +12660,7 @@ async function cmdNewsSearch(run, keyword, opts) {
12632
12660
  keyword: keyword || void 0,
12633
12661
  coins: opts.coins,
12634
12662
  importance: opts.importance,
12663
+ platform: opts.platform,
12635
12664
  sentiment: opts.sentiment,
12636
12665
  sortBy: opts.sortBy,
12637
12666
  begin: opts.begin,
@@ -12684,12 +12713,12 @@ async function cmdNewsDetail(run, id, opts) {
12684
12713
  content
12685
12714
  });
12686
12715
  }
12687
- async function cmdNewsDomains(run, opts) {
12716
+ async function cmdNewsPlatforms(run, opts) {
12688
12717
  const result = await run("news_get_domains", {});
12689
12718
  const raw = getData(result);
12690
12719
  const items = raw?.[0]?.["platform"] ?? [];
12691
12720
  if (opts.json) return printJson(items);
12692
- outputLine("Available news source domains:");
12721
+ outputLine("Available news platforms:");
12693
12722
  items.forEach((d) => outputLine(` ${d}`));
12694
12723
  }
12695
12724
  async function cmdNewsCoinSentiment(run, coins, opts) {
@@ -13071,6 +13100,7 @@ var CLI_OPTIONS = {
13071
13100
  coins: { type: "string" },
13072
13101
  sentiment: { type: "string" },
13073
13102
  importance: { type: "string" },
13103
+ platform: { type: "string" },
13074
13104
  keyword: { type: "string" },
13075
13105
  "detail-lvl": { type: "string" },
13076
13106
  period: { type: "string" },
@@ -16882,7 +16912,7 @@ async function cmdEventCancel(run, opts) {
16882
16912
  // src/index.ts
16883
16913
  var _require3 = createRequire3(import.meta.url);
16884
16914
  var CLI_VERSION2 = _require3("../package.json").version;
16885
- var GIT_HASH2 = true ? "e0312e6" : "dev";
16915
+ var GIT_HASH2 = true ? "e9764c9" : "dev";
16886
16916
  function handleDohCommand(action, json, force, binaryPath) {
16887
16917
  if (action === "status") return cmdDohStatus(json, binaryPath);
16888
16918
  if (action === "install") return cmdDohInstall(json, binaryPath);
@@ -17732,15 +17762,16 @@ function handleNewsCommand(run, action, rest, v, json) {
17732
17762
  const period = v.period;
17733
17763
  const points = v.points !== void 0 ? Number(v.points) : 24;
17734
17764
  const sortBy = v["sort-by"];
17735
- const searchOpts = { coins: v.coins, importance: v.importance, sentiment: v.sentiment, sortBy, begin, end, language, detailLvl, limit, after, json };
17736
- const listOpts = { coins: v.coins, importance: v.importance, begin, end, language, detailLvl, limit, after, json };
17765
+ const platform2 = v.platform;
17766
+ const searchOpts = { coins: v.coins, importance: v.importance, platform: platform2, sentiment: v.sentiment, sortBy, begin, end, language, detailLvl, limit, after, json };
17767
+ const listOpts = { coins: v.coins, importance: v.importance, platform: platform2, begin, end, language, detailLvl, limit, after, json };
17737
17768
  const dispatch = {
17738
17769
  latest: () => cmdNewsLatest(run, listOpts),
17739
- important: () => cmdNewsImportant(run, { coins: v.coins, begin, end, language, detailLvl, limit, json }),
17740
- "by-coin": () => cmdNewsByCoin(run, v.coins ?? rest[0], { importance: v.importance, begin, end, language, detailLvl, limit, json }),
17770
+ important: () => cmdNewsImportant(run, { coins: v.coins, platform: platform2, begin, end, language, detailLvl, limit, json }),
17771
+ "by-coin": () => cmdNewsByCoin(run, v.coins ?? rest[0], { importance: v.importance, platform: platform2, begin, end, language, detailLvl, limit, json }),
17741
17772
  search: () => cmdNewsSearch(run, v.keyword ?? rest[0], searchOpts),
17742
17773
  detail: () => cmdNewsDetail(run, rest[0], { language, json }),
17743
- domains: () => cmdNewsDomains(run, { json }),
17774
+ platforms: () => cmdNewsPlatforms(run, { json }),
17744
17775
  "coin-sentiment": () => cmdNewsCoinSentiment(run, v.coins ?? rest[0], { period, json }),
17745
17776
  "coin-trend": () => cmdNewsCoinTrend(run, v.coins ?? rest[0], { period, points, json }),
17746
17777
  // by-sentiment is a convenience wrapper over news_search (no keyword, sentiment filter only)