@okx_ai/okx-trade-cli 1.3.6-beta.1 → 1.3.6-beta.3
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 +211 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13562,6 +13562,110 @@ async function handleAuthCommand(action, _rest, v) {
|
|
|
13562
13562
|
}
|
|
13563
13563
|
}
|
|
13564
13564
|
|
|
13565
|
+
// src/commands/outcomes.ts
|
|
13566
|
+
import { spawn as spawn4 } from "child_process";
|
|
13567
|
+
import { existsSync as existsSync9 } from "fs";
|
|
13568
|
+
import { delimiter, join as join13 } from "path";
|
|
13569
|
+
var OUTCOMES_BINARY_NAME = process.platform === "win32" ? "okx-outcomes.exe" : "okx-outcomes";
|
|
13570
|
+
function resolveOutcomesBinaryPath() {
|
|
13571
|
+
const override = process.env.OKX_OUTCOMES_BIN;
|
|
13572
|
+
if (override) {
|
|
13573
|
+
if (existsSync9(override)) return override;
|
|
13574
|
+
errorLine(
|
|
13575
|
+
`Warning: OKX_OUTCOMES_BIN is set to '${override}' but no file exists there; falling back to PATH search.`
|
|
13576
|
+
);
|
|
13577
|
+
}
|
|
13578
|
+
const paths = (process.env.PATH ?? "").split(delimiter);
|
|
13579
|
+
for (const dir of paths) {
|
|
13580
|
+
if (!dir) continue;
|
|
13581
|
+
const full = join13(dir, OUTCOMES_BINARY_NAME);
|
|
13582
|
+
if (existsSync9(full)) return full;
|
|
13583
|
+
}
|
|
13584
|
+
return null;
|
|
13585
|
+
}
|
|
13586
|
+
function printInstallHint() {
|
|
13587
|
+
errorLine("Error: okx-outcomes binary not found in PATH.");
|
|
13588
|
+
errorLine("");
|
|
13589
|
+
errorLine("Install (macOS / Linux):");
|
|
13590
|
+
errorLine(" curl -fsSL https://raw.githubusercontent.com/okx/outcomes/master/install.sh | sh");
|
|
13591
|
+
errorLine("");
|
|
13592
|
+
errorLine("Install (Windows): download okx-outcomes.exe from");
|
|
13593
|
+
errorLine(" https://github.com/okx/outcomes/releases");
|
|
13594
|
+
errorLine("and place it on your PATH.");
|
|
13595
|
+
errorLine("");
|
|
13596
|
+
errorLine("Or set OKX_OUTCOMES_BIN env var to a custom binary path.");
|
|
13597
|
+
}
|
|
13598
|
+
function runOkxOutcomes(args) {
|
|
13599
|
+
const binPath = resolveOutcomesBinaryPath();
|
|
13600
|
+
if (!binPath) {
|
|
13601
|
+
printInstallHint();
|
|
13602
|
+
return Promise.resolve(127);
|
|
13603
|
+
}
|
|
13604
|
+
return new Promise((resolve3, reject) => {
|
|
13605
|
+
const child = spawn4(binPath, args, { stdio: "inherit" });
|
|
13606
|
+
child.on(
|
|
13607
|
+
"error",
|
|
13608
|
+
(err) => reject(new Error(`Failed to spawn okx-outcomes: ${err.message}`))
|
|
13609
|
+
);
|
|
13610
|
+
child.on("close", (code) => resolve3(code ?? 1));
|
|
13611
|
+
});
|
|
13612
|
+
}
|
|
13613
|
+
function printOutcomesHelp() {
|
|
13614
|
+
const lines = [
|
|
13615
|
+
"Usage: okx outcomes <command> [args...]",
|
|
13616
|
+
"",
|
|
13617
|
+
"OKX Outcomes - YES/NO event contract trading via the okx-outcomes binary.",
|
|
13618
|
+
"",
|
|
13619
|
+
"Common commands:",
|
|
13620
|
+
" data events List outcome events",
|
|
13621
|
+
" data event <eventId> Get event detail",
|
|
13622
|
+
" data event-markets <eventId> Event + all its markets (returns asset ids)",
|
|
13623
|
+
" data market <marketId> Get single market detail",
|
|
13624
|
+
" data trending List trending events",
|
|
13625
|
+
" data ticker <assetId> 24h ticker for an outcome asset",
|
|
13626
|
+
" data candles <assetId> OHLCV candles for an outcome asset",
|
|
13627
|
+
" search <keyword> Search events/markets",
|
|
13628
|
+
" (Note: events/event/market etc. live UNDER the `data` namespace \u2014 calling them",
|
|
13629
|
+
" as top-level commands prints the binary's help instead of returning JSON.)",
|
|
13630
|
+
"",
|
|
13631
|
+
" clob price/prices/midpoint(s)/spread(s)/book(s) --asset <id>",
|
|
13632
|
+
" CLOB read-side market data",
|
|
13633
|
+
" clob create-order Place limit order (EIP-712 signed)",
|
|
13634
|
+
" clob market-order Cross book immediately (IOC/FOK)",
|
|
13635
|
+
" clob cancel-oid | cancel-all | heartbeat",
|
|
13636
|
+
"",
|
|
13637
|
+
" ctf split/merge/redeem Conditional token operations",
|
|
13638
|
+
"",
|
|
13639
|
+
" account balance/order/orders/positions/closed-positions/trades",
|
|
13640
|
+
" HMAC-auth account queries",
|
|
13641
|
+
"",
|
|
13642
|
+
" wallet show Show derived wallet address",
|
|
13643
|
+
" status Health check",
|
|
13644
|
+
" setup Interactive .env wizard",
|
|
13645
|
+
"",
|
|
13646
|
+
"Run 'okx outcomes <command> --help' for command-specific help.",
|
|
13647
|
+
"",
|
|
13648
|
+
"Note: place flags after the subcommand, e.g. 'okx outcomes events --json'",
|
|
13649
|
+
" (or before the module: 'okx --json outcomes events'). Writing",
|
|
13650
|
+
" 'okx outcomes --json events' is not supported.",
|
|
13651
|
+
"",
|
|
13652
|
+
"Requires: curl -fsSL https://raw.githubusercontent.com/okx/outcomes/master/install.sh | sh"
|
|
13653
|
+
];
|
|
13654
|
+
for (const line of lines) outputLine(line);
|
|
13655
|
+
}
|
|
13656
|
+
async function handleOutcomesCommand(action, rest, v) {
|
|
13657
|
+
if (!action || action === "--help" || action === "-h" || action === "help") {
|
|
13658
|
+
printOutcomesHelp();
|
|
13659
|
+
return;
|
|
13660
|
+
}
|
|
13661
|
+
const forwardArgs = [action, ...rest];
|
|
13662
|
+
if (v.json && !forwardArgs.includes("--json") && !forwardArgs.includes("-j")) {
|
|
13663
|
+
forwardArgs.push("--json");
|
|
13664
|
+
}
|
|
13665
|
+
const code = await runOkxOutcomes(forwardArgs);
|
|
13666
|
+
if (code !== 0) process.exitCode = code;
|
|
13667
|
+
}
|
|
13668
|
+
|
|
13565
13669
|
// src/commands/diagnose.ts
|
|
13566
13670
|
import dns from "dns/promises";
|
|
13567
13671
|
import net from "net";
|
|
@@ -13656,7 +13760,7 @@ function sanitize2(value) {
|
|
|
13656
13760
|
import fs5 from "fs";
|
|
13657
13761
|
import path4 from "path";
|
|
13658
13762
|
import os4 from "os";
|
|
13659
|
-
import { spawnSync, spawn as
|
|
13763
|
+
import { spawnSync, spawn as spawn5 } from "child_process";
|
|
13660
13764
|
import { createRequire as createRequire2 } from "module";
|
|
13661
13765
|
import { fileURLToPath } from "url";
|
|
13662
13766
|
var _require2 = createRequire2(import.meta.url);
|
|
@@ -13990,7 +14094,7 @@ async function checkStdioHandshake(entryPath, report) {
|
|
|
13990
14094
|
clearTimeout(timer);
|
|
13991
14095
|
resolve3(passed);
|
|
13992
14096
|
};
|
|
13993
|
-
const child =
|
|
14097
|
+
const child = spawn5(process.execPath, [entryPath], {
|
|
13994
14098
|
stdio: ["pipe", "pipe", "pipe"],
|
|
13995
14099
|
env: { ...process.env }
|
|
13996
14100
|
});
|
|
@@ -14109,7 +14213,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
14109
14213
|
|
|
14110
14214
|
// src/commands/diagnose.ts
|
|
14111
14215
|
var CLI_VERSION = readCliVersion();
|
|
14112
|
-
var GIT_HASH = true ? "
|
|
14216
|
+
var GIT_HASH = true ? "0614700e" : "dev";
|
|
14113
14217
|
function maskKey2(key) {
|
|
14114
14218
|
if (!key) return "(not set)";
|
|
14115
14219
|
if (key.length <= 8) return "****";
|
|
@@ -14471,12 +14575,12 @@ function suggestSubcommand(action, knownActions, knownPaths = []) {
|
|
|
14471
14575
|
// src/commands/upgrade.ts
|
|
14472
14576
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
14473
14577
|
import { readFileSync as readFileSync9, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11 } from "fs";
|
|
14474
|
-
import { dirname as dirname8, join as
|
|
14578
|
+
import { dirname as dirname8, join as join14 } from "path";
|
|
14475
14579
|
import { homedir as homedir11 } from "os";
|
|
14476
14580
|
var PACKAGES = ["@okx_ai/okx-trade-mcp", "@okx_ai/okx-trade-cli"];
|
|
14477
|
-
var CACHE_FILE2 =
|
|
14581
|
+
var CACHE_FILE2 = join14(homedir11(), ".okx", "last_check");
|
|
14478
14582
|
var THROTTLE_MS = 12 * 60 * 60 * 1e3;
|
|
14479
|
-
var NPM_BIN =
|
|
14583
|
+
var NPM_BIN = join14(dirname8(process.execPath), process.platform === "win32" ? "npm.cmd" : "npm");
|
|
14480
14584
|
function readLastCheck() {
|
|
14481
14585
|
try {
|
|
14482
14586
|
return parseInt(readFileSync9(CACHE_FILE2, "utf-8").trim(), 10) || 0;
|
|
@@ -14486,7 +14590,7 @@ function readLastCheck() {
|
|
|
14486
14590
|
}
|
|
14487
14591
|
function writeLastCheck() {
|
|
14488
14592
|
try {
|
|
14489
|
-
mkdirSync11(
|
|
14593
|
+
mkdirSync11(join14(homedir11(), ".okx"), { recursive: true });
|
|
14490
14594
|
writeFileSync8(CACHE_FILE2, String(Math.floor(Date.now() / 1e3)), "utf-8");
|
|
14491
14595
|
} catch {
|
|
14492
14596
|
}
|
|
@@ -15642,6 +15746,63 @@ var CLI_REGISTRY = {
|
|
|
15642
15746
|
description: "Upgrade okx CLI and MCP server to the latest stable version",
|
|
15643
15747
|
usage: "okx upgrade [--check] [--beta] [--force] [--json]"
|
|
15644
15748
|
},
|
|
15749
|
+
// ── outcomes ───────────────────────────────────────────────────────────────
|
|
15750
|
+
// External binary wrapper - forwards to the okx-outcomes binary (formerly okx-predict).
|
|
15751
|
+
// All toolName=null because outcomes commands are not exposed as MCP tools.
|
|
15752
|
+
outcomes: {
|
|
15753
|
+
description: "OKX Outcomes markets (YES/NO event contracts) via external okx-outcomes binary",
|
|
15754
|
+
commands: {
|
|
15755
|
+
// Note: events / event / event-markets / market / trending / ticker /
|
|
15756
|
+
// candles live UNDER the `data` namespace in the upstream binary.
|
|
15757
|
+
// Calling them as top-level commands prints the binary's help text
|
|
15758
|
+
// instead of returning JSON. Always invoke as `okx outcomes data <cmd>`.
|
|
15759
|
+
data: {
|
|
15760
|
+
toolName: null,
|
|
15761
|
+
usage: "okx outcomes data <events|event|event-markets|market|trending|ticker|candles> [args...]",
|
|
15762
|
+
description: "Public market data namespace: events, event(-markets), market, trending, ticker, candles"
|
|
15763
|
+
},
|
|
15764
|
+
search: {
|
|
15765
|
+
toolName: null,
|
|
15766
|
+
usage: "okx outcomes search <keyword> [--limit <n>] [--cursor <c>]",
|
|
15767
|
+
description: "Search events/markets by keyword"
|
|
15768
|
+
},
|
|
15769
|
+
account: {
|
|
15770
|
+
toolName: null,
|
|
15771
|
+
usage: "okx outcomes account <balance|order|orders|positions|closed-positions|trades>",
|
|
15772
|
+
description: "HMAC-auth account queries"
|
|
15773
|
+
},
|
|
15774
|
+
clob: {
|
|
15775
|
+
toolName: null,
|
|
15776
|
+
usage: "okx outcomes clob <price|prices|midpoint|midpoints|spread|spreads|book|books|order|orders|trades|create-order|market-order|cancel-oid|cancel-all|heartbeat>",
|
|
15777
|
+
description: "CLOB market data (--asset) + EIP-712 signed order operations"
|
|
15778
|
+
},
|
|
15779
|
+
ctf: {
|
|
15780
|
+
toolName: null,
|
|
15781
|
+
usage: "okx outcomes ctf <split|merge|redeem> --market <id> [--amount <xp>]",
|
|
15782
|
+
description: "Conditional Token Framework: split xp into YES/NO, merge, redeem"
|
|
15783
|
+
},
|
|
15784
|
+
wallet: {
|
|
15785
|
+
toolName: null,
|
|
15786
|
+
usage: "okx outcomes wallet show",
|
|
15787
|
+
description: "Show derived wallet address (from PREDICTIONS_AGENT_PRIVATE_KEY)"
|
|
15788
|
+
},
|
|
15789
|
+
status: {
|
|
15790
|
+
toolName: null,
|
|
15791
|
+
usage: "okx outcomes status [--json]",
|
|
15792
|
+
description: "Health check: API + balance reachability"
|
|
15793
|
+
},
|
|
15794
|
+
setup: {
|
|
15795
|
+
toolName: null,
|
|
15796
|
+
usage: "okx outcomes setup",
|
|
15797
|
+
description: "Interactive .env wizard for PREDICTIONS_* env vars"
|
|
15798
|
+
},
|
|
15799
|
+
shell: {
|
|
15800
|
+
toolName: null,
|
|
15801
|
+
usage: "okx outcomes shell",
|
|
15802
|
+
description: "Interactive REPL (do not invoke from agent context)"
|
|
15803
|
+
}
|
|
15804
|
+
}
|
|
15805
|
+
},
|
|
15645
15806
|
// ── list-tools ──────────────────────────────────────────────────────────────
|
|
15646
15807
|
"list-tools": {
|
|
15647
15808
|
description: "List all available tools and their parameters (use --json for machine-readable output)",
|
|
@@ -16514,6 +16675,30 @@ function parseCli(argv) {
|
|
|
16514
16675
|
}
|
|
16515
16676
|
return { values, positionals };
|
|
16516
16677
|
}
|
|
16678
|
+
function peekFirstPositional(argv) {
|
|
16679
|
+
const booleanFlags = /* @__PURE__ */ new Set();
|
|
16680
|
+
for (const [name, opt] of Object.entries(CLI_OPTIONS)) {
|
|
16681
|
+
const o = opt;
|
|
16682
|
+
if (o.type === "boolean") {
|
|
16683
|
+
booleanFlags.add(name);
|
|
16684
|
+
if (o.short) booleanFlags.add(o.short);
|
|
16685
|
+
}
|
|
16686
|
+
}
|
|
16687
|
+
for (let i = 0; i < argv.length; i++) {
|
|
16688
|
+
const tok = argv[i];
|
|
16689
|
+
if (tok === "--") {
|
|
16690
|
+
const next2 = argv[i + 1];
|
|
16691
|
+
return next2 === void 0 ? void 0 : { module: next2, idx: i + 1 };
|
|
16692
|
+
}
|
|
16693
|
+
if (!tok.startsWith("-")) return { module: tok, idx: i };
|
|
16694
|
+
if (tok.includes("=")) continue;
|
|
16695
|
+
const name = tok.replace(/^--?/, "");
|
|
16696
|
+
if (booleanFlags.has(name)) continue;
|
|
16697
|
+
const next = argv[i + 1];
|
|
16698
|
+
if (next !== void 0 && !next.startsWith("-")) i++;
|
|
16699
|
+
}
|
|
16700
|
+
return void 0;
|
|
16701
|
+
}
|
|
16517
16702
|
|
|
16518
16703
|
// src/commands/market.ts
|
|
16519
16704
|
function getData2(result) {
|
|
@@ -19916,13 +20101,13 @@ async function cmdDcdQuoteAndBuy(run, opts) {
|
|
|
19916
20101
|
|
|
19917
20102
|
// src/commands/skill.ts
|
|
19918
20103
|
import { tmpdir, homedir as homedir13 } from "os";
|
|
19919
|
-
import { join as
|
|
19920
|
-
import { mkdirSync as mkdirSync12, rmSync, existsSync as
|
|
20104
|
+
import { join as join16, dirname as dirname9 } from "path";
|
|
20105
|
+
import { mkdirSync as mkdirSync12, rmSync, existsSync as existsSync11, copyFileSync as copyFileSync2 } from "fs";
|
|
19921
20106
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
19922
20107
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
19923
20108
|
function resolveNpx() {
|
|
19924
|
-
const sibling =
|
|
19925
|
-
if (
|
|
20109
|
+
const sibling = join16(dirname9(process.execPath), "npx");
|
|
20110
|
+
if (existsSync11(sibling)) return sibling;
|
|
19926
20111
|
return "npx";
|
|
19927
20112
|
}
|
|
19928
20113
|
function npxEnv() {
|
|
@@ -19978,13 +20163,13 @@ async function cmdSkillCategories(run, json) {
|
|
|
19978
20163
|
outputLine("");
|
|
19979
20164
|
}
|
|
19980
20165
|
async function cmdSkillAdd(name, config, json, exec = execFileSync2) {
|
|
19981
|
-
const tmpBase =
|
|
20166
|
+
const tmpBase = join16(tmpdir(), `okx-skill-${randomUUID2()}`);
|
|
19982
20167
|
mkdirSync12(tmpBase, { recursive: true });
|
|
19983
20168
|
try {
|
|
19984
20169
|
outputLine(`Downloading ${name}...`);
|
|
19985
20170
|
const client = new OkxRestClient(config);
|
|
19986
20171
|
const zipPath = await downloadSkillZip(client, name, tmpBase);
|
|
19987
|
-
const contentDir = await extractSkillZip(zipPath,
|
|
20172
|
+
const contentDir = await extractSkillZip(zipPath, join16(tmpBase, "content"));
|
|
19988
20173
|
const meta = readMetaJson(contentDir);
|
|
19989
20174
|
validateSkillMdExists(contentDir);
|
|
19990
20175
|
outputLine("Installing to detected agents...");
|
|
@@ -19995,7 +20180,7 @@ async function cmdSkillAdd(name, config, json, exec = execFileSync2) {
|
|
|
19995
20180
|
env: npxEnv()
|
|
19996
20181
|
});
|
|
19997
20182
|
} catch (e) {
|
|
19998
|
-
const savedZip =
|
|
20183
|
+
const savedZip = join16(process.cwd(), `${name}.zip`);
|
|
19999
20184
|
try {
|
|
20000
20185
|
copyFileSync2(zipPath, savedZip);
|
|
20001
20186
|
} catch {
|
|
@@ -20035,7 +20220,7 @@ function cmdSkillRemove(name, json, exec = execFileSync2) {
|
|
|
20035
20220
|
env: npxEnv()
|
|
20036
20221
|
});
|
|
20037
20222
|
} catch {
|
|
20038
|
-
const agentsPath =
|
|
20223
|
+
const agentsPath = join16(homedir13(), ".agents", "skills", name);
|
|
20039
20224
|
try {
|
|
20040
20225
|
rmSync(agentsPath, { recursive: true, force: true });
|
|
20041
20226
|
} catch {
|
|
@@ -20719,7 +20904,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
20719
20904
|
// src/index.ts
|
|
20720
20905
|
var _require3 = createRequire3(import.meta.url);
|
|
20721
20906
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
20722
|
-
var GIT_HASH2 = true ? "
|
|
20907
|
+
var GIT_HASH2 = true ? "0614700e" : "dev";
|
|
20723
20908
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
20724
20909
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
20725
20910
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|
|
@@ -22187,7 +22372,16 @@ async function main() {
|
|
|
22187
22372
|
err: (m) => process.stderr.write(m)
|
|
22188
22373
|
});
|
|
22189
22374
|
checkForUpdates("@okx_ai/okx-trade-cli", CLI_VERSION2);
|
|
22190
|
-
const
|
|
22375
|
+
const rawArgv = process.argv.slice(2);
|
|
22376
|
+
const peek = peekFirstPositional(rawArgv);
|
|
22377
|
+
if (peek?.module === "outcomes") {
|
|
22378
|
+
const after = rawArgv.slice(peek.idx + 1);
|
|
22379
|
+
const action2 = after[0];
|
|
22380
|
+
const rest2 = after.slice(1);
|
|
22381
|
+
const json2 = rawArgv.includes("--json") || rawArgv.includes("-j");
|
|
22382
|
+
return handleOutcomesCommand(action2, rest2, { json: json2 });
|
|
22383
|
+
}
|
|
22384
|
+
const { values, positionals } = parseCli(rawArgv);
|
|
22191
22385
|
if (values.version) {
|
|
22192
22386
|
printVersion();
|
|
22193
22387
|
return;
|