@okx_ai/okx-trade-cli 1.3.8-beta.5 → 1.3.8-beta.6
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 +222 -18
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/LICENSE +0 -21
- package/scripts/postinstall-download.js +0 -152
package/dist/index.js
CHANGED
|
@@ -14193,6 +14193,115 @@ async function handleAuthCommand(action, _rest, v) {
|
|
|
14193
14193
|
}
|
|
14194
14194
|
}
|
|
14195
14195
|
|
|
14196
|
+
// src/commands/outcomes.ts
|
|
14197
|
+
import { spawn as spawn4 } from "child_process";
|
|
14198
|
+
import { existsSync as existsSync9 } from "fs";
|
|
14199
|
+
import { delimiter, join as join15 } from "path";
|
|
14200
|
+
var OUTCOMES_BINARY_NAME = process.platform === "win32" ? "okx-outcomes.exe" : "okx-outcomes";
|
|
14201
|
+
function resolveOutcomesBinaryPath() {
|
|
14202
|
+
const override = process.env.OKX_OUTCOMES_BIN;
|
|
14203
|
+
if (override) {
|
|
14204
|
+
if (existsSync9(override)) return override;
|
|
14205
|
+
errorLine(
|
|
14206
|
+
`Warning: OKX_OUTCOMES_BIN is set to '${override}' but no file exists there; falling back to PATH search.`
|
|
14207
|
+
);
|
|
14208
|
+
}
|
|
14209
|
+
const paths = (process.env.PATH ?? "").split(delimiter);
|
|
14210
|
+
for (const dir of paths) {
|
|
14211
|
+
if (!dir) continue;
|
|
14212
|
+
const full = join15(dir, OUTCOMES_BINARY_NAME);
|
|
14213
|
+
if (existsSync9(full)) return full;
|
|
14214
|
+
}
|
|
14215
|
+
return null;
|
|
14216
|
+
}
|
|
14217
|
+
function printInstallHint() {
|
|
14218
|
+
errorLine("Error: okx-outcomes binary not found in PATH.");
|
|
14219
|
+
errorLine("");
|
|
14220
|
+
errorLine("Install (macOS / Linux):");
|
|
14221
|
+
errorLine(" curl -fsSL https://raw.githubusercontent.com/okx/outcomes-cli/main/install.sh | sh");
|
|
14222
|
+
errorLine("");
|
|
14223
|
+
errorLine("Install (Windows): download okx-outcomes.exe from");
|
|
14224
|
+
errorLine(" https://github.com/okx/outcomes-cli/releases");
|
|
14225
|
+
errorLine("and place it on your PATH.");
|
|
14226
|
+
errorLine("");
|
|
14227
|
+
errorLine("Or set OKX_OUTCOMES_BIN env var to a custom binary path.");
|
|
14228
|
+
}
|
|
14229
|
+
function runOkxOutcomes(args) {
|
|
14230
|
+
const binPath = resolveOutcomesBinaryPath();
|
|
14231
|
+
if (!binPath) {
|
|
14232
|
+
printInstallHint();
|
|
14233
|
+
return Promise.resolve(127);
|
|
14234
|
+
}
|
|
14235
|
+
return new Promise((resolve4, reject) => {
|
|
14236
|
+
const child = spawn4(binPath, args, { stdio: "inherit" });
|
|
14237
|
+
child.on(
|
|
14238
|
+
"error",
|
|
14239
|
+
(err) => reject(new Error(`Failed to spawn okx-outcomes: ${err.message}`))
|
|
14240
|
+
);
|
|
14241
|
+
child.on("close", (code) => resolve4(code ?? 1));
|
|
14242
|
+
});
|
|
14243
|
+
}
|
|
14244
|
+
function printOutcomesHelp() {
|
|
14245
|
+
const lines = [
|
|
14246
|
+
"Usage: okx outcomes <command> [args...]",
|
|
14247
|
+
"",
|
|
14248
|
+
"OKX Outcomes - YES/NO event contract trading via the okx-outcomes binary.",
|
|
14249
|
+
"",
|
|
14250
|
+
"Common commands:",
|
|
14251
|
+
" data events List outcome events",
|
|
14252
|
+
" data event <eventId> Get event detail",
|
|
14253
|
+
" data event-markets <eventId> Event + all its markets (returns asset ids)",
|
|
14254
|
+
" data market <marketId> Get single market detail",
|
|
14255
|
+
" data trending List trending events",
|
|
14256
|
+
" data ticker <assetId> 24h ticker for an outcome asset",
|
|
14257
|
+
" data candles <assetId> OHLCV candles for an outcome asset",
|
|
14258
|
+
" search <keyword> Search events/markets",
|
|
14259
|
+
" (Note: events/event/market etc. live UNDER the `data` namespace \u2014 calling them",
|
|
14260
|
+
" as top-level commands prints the binary's help instead of returning JSON.)",
|
|
14261
|
+
"",
|
|
14262
|
+
" clob price/prices/midpoint(s)/spread(s)/book(s) --asset <id>",
|
|
14263
|
+
" CLOB read-side market data",
|
|
14264
|
+
" clob create-order Place limit order (EIP-712 signed)",
|
|
14265
|
+
" clob market-order Cross book immediately (IOC/FOK)",
|
|
14266
|
+
" clob cancel-oid | cancel-all | heartbeat",
|
|
14267
|
+
"",
|
|
14268
|
+
" ctf split/merge/redeem Conditional token operations",
|
|
14269
|
+
"",
|
|
14270
|
+
" account balance/order/orders/positions/trades",
|
|
14271
|
+
" Account queries (OAuth sign-in; closed = positions --status closed)",
|
|
14272
|
+
"",
|
|
14273
|
+
" auth login --manual [--json] OAuth device-code sign-in (prints URL+code; agent-friendly)",
|
|
14274
|
+
" auth login [--site global|us] OAuth sign-in, browser-foreground (user at a terminal)",
|
|
14275
|
+
" auth refresh | auth status Verify/refresh session; show sign-in state",
|
|
14276
|
+
" setup status|region|bind Step-by-step onboarding (all non-interactive; agent-runnable)",
|
|
14277
|
+
"",
|
|
14278
|
+
" wallet show Show derived wallet address",
|
|
14279
|
+
" status Health check",
|
|
14280
|
+
" setup Interactive setup wizard (region -> OAuth -> wallet bind)",
|
|
14281
|
+
"",
|
|
14282
|
+
"Run 'okx outcomes <command> --help' for command-specific help.",
|
|
14283
|
+
"",
|
|
14284
|
+
"Note: place flags after the subcommand, e.g. 'okx outcomes events --json'",
|
|
14285
|
+
" (or before the module: 'okx --json outcomes events'). Writing",
|
|
14286
|
+
" 'okx outcomes --json events' is not supported.",
|
|
14287
|
+
"",
|
|
14288
|
+
"Requires: curl -fsSL https://raw.githubusercontent.com/okx/outcomes-cli/main/install.sh | sh"
|
|
14289
|
+
];
|
|
14290
|
+
for (const line of lines) outputLine(line);
|
|
14291
|
+
}
|
|
14292
|
+
async function handleOutcomesCommand(action, rest, v) {
|
|
14293
|
+
if (!action || action === "--help" || action === "-h" || action === "help") {
|
|
14294
|
+
printOutcomesHelp();
|
|
14295
|
+
return;
|
|
14296
|
+
}
|
|
14297
|
+
const forwardArgs = [action, ...rest];
|
|
14298
|
+
if (v.json && !forwardArgs.includes("--json") && !forwardArgs.includes("-j")) {
|
|
14299
|
+
forwardArgs.push("--json");
|
|
14300
|
+
}
|
|
14301
|
+
const code = await runOkxOutcomes(forwardArgs);
|
|
14302
|
+
if (code !== 0) process.exitCode = code;
|
|
14303
|
+
}
|
|
14304
|
+
|
|
14196
14305
|
// src/commands/diagnose.ts
|
|
14197
14306
|
import dns from "dns/promises";
|
|
14198
14307
|
import net from "net";
|
|
@@ -14287,7 +14396,7 @@ function sanitize2(value) {
|
|
|
14287
14396
|
import fs5 from "fs";
|
|
14288
14397
|
import path4 from "path";
|
|
14289
14398
|
import os4 from "os";
|
|
14290
|
-
import { spawnSync, spawn as
|
|
14399
|
+
import { spawnSync, spawn as spawn5 } from "child_process";
|
|
14291
14400
|
import { createRequire as createRequire2 } from "module";
|
|
14292
14401
|
import { fileURLToPath } from "url";
|
|
14293
14402
|
var _require2 = createRequire2(import.meta.url);
|
|
@@ -14621,7 +14730,7 @@ async function checkStdioHandshake(entryPath, report) {
|
|
|
14621
14730
|
clearTimeout(timer);
|
|
14622
14731
|
resolve4(passed);
|
|
14623
14732
|
};
|
|
14624
|
-
const child =
|
|
14733
|
+
const child = spawn5(process.execPath, [entryPath], {
|
|
14625
14734
|
stdio: ["pipe", "pipe", "pipe"],
|
|
14626
14735
|
env: { ...process.env }
|
|
14627
14736
|
});
|
|
@@ -14740,7 +14849,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
14740
14849
|
|
|
14741
14850
|
// src/commands/diagnose.ts
|
|
14742
14851
|
var CLI_VERSION = readCliVersion();
|
|
14743
|
-
var GIT_HASH = true ? "
|
|
14852
|
+
var GIT_HASH = true ? "e2de3b7e" : "dev";
|
|
14744
14853
|
function maskKey2(key) {
|
|
14745
14854
|
if (!key) return "(not set)";
|
|
14746
14855
|
if (key.length <= 8) return "****";
|
|
@@ -15102,12 +15211,12 @@ function suggestSubcommand(action, knownActions, knownPaths = []) {
|
|
|
15102
15211
|
// src/commands/upgrade.ts
|
|
15103
15212
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
15104
15213
|
import { readFileSync as readFileSync11, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11 } from "fs";
|
|
15105
|
-
import { dirname as dirname8, join as
|
|
15214
|
+
import { dirname as dirname8, join as join16 } from "path";
|
|
15106
15215
|
import { homedir as homedir11 } from "os";
|
|
15107
15216
|
var PACKAGES = ["@okx_ai/okx-trade-mcp", "@okx_ai/okx-trade-cli"];
|
|
15108
|
-
var CACHE_FILE2 =
|
|
15217
|
+
var CACHE_FILE2 = join16(homedir11(), ".okx", "last_check");
|
|
15109
15218
|
var THROTTLE_MS = 12 * 60 * 60 * 1e3;
|
|
15110
|
-
var NPM_BIN =
|
|
15219
|
+
var NPM_BIN = join16(dirname8(process.execPath), process.platform === "win32" ? "npm.cmd" : "npm");
|
|
15111
15220
|
function readLastCheck() {
|
|
15112
15221
|
try {
|
|
15113
15222
|
return parseInt(readFileSync11(CACHE_FILE2, "utf-8").trim(), 10) || 0;
|
|
@@ -15117,7 +15226,7 @@ function readLastCheck() {
|
|
|
15117
15226
|
}
|
|
15118
15227
|
function writeLastCheck() {
|
|
15119
15228
|
try {
|
|
15120
|
-
mkdirSync11(
|
|
15229
|
+
mkdirSync11(join16(homedir11(), ".okx"), { recursive: true });
|
|
15121
15230
|
writeFileSync8(CACHE_FILE2, String(Math.floor(Date.now() / 1e3)), "utf-8");
|
|
15122
15231
|
} catch {
|
|
15123
15232
|
}
|
|
@@ -16278,6 +16387,68 @@ var CLI_REGISTRY = {
|
|
|
16278
16387
|
description: "Upgrade okx CLI and MCP server to the latest stable version",
|
|
16279
16388
|
usage: "okx upgrade [--check] [--beta] [--force] [--json]"
|
|
16280
16389
|
},
|
|
16390
|
+
// ── outcomes ───────────────────────────────────────────────────────────────
|
|
16391
|
+
// External binary wrapper - forwards to the okx-outcomes binary (formerly okx-predict).
|
|
16392
|
+
// All toolName=null because outcomes commands are not exposed as MCP tools.
|
|
16393
|
+
outcomes: {
|
|
16394
|
+
description: "OKX Outcomes markets (YES/NO event contracts) via external okx-outcomes binary",
|
|
16395
|
+
commands: {
|
|
16396
|
+
// Note: events / event / event-markets / market / trending / ticker /
|
|
16397
|
+
// candles live UNDER the `data` namespace in the upstream binary.
|
|
16398
|
+
// Calling them as top-level commands prints the binary's help text
|
|
16399
|
+
// instead of returning JSON. Always invoke as `okx outcomes data <cmd>`.
|
|
16400
|
+
data: {
|
|
16401
|
+
toolName: null,
|
|
16402
|
+
usage: "okx outcomes data <events|event|event-markets|market|trending|ticker|candles> [args...]",
|
|
16403
|
+
description: "Public market data namespace: events, event(-markets), market, trending, ticker, candles"
|
|
16404
|
+
},
|
|
16405
|
+
search: {
|
|
16406
|
+
toolName: null,
|
|
16407
|
+
usage: "okx outcomes search <keyword> [--limit <n>] [--cursor <c>]",
|
|
16408
|
+
description: "Search events/markets by keyword (OAuth)"
|
|
16409
|
+
},
|
|
16410
|
+
account: {
|
|
16411
|
+
toolName: null,
|
|
16412
|
+
usage: "okx outcomes account <balance|order|orders|positions|trades> (closed = positions --status closed)",
|
|
16413
|
+
description: "Account queries (OAuth)"
|
|
16414
|
+
},
|
|
16415
|
+
auth: {
|
|
16416
|
+
toolName: null,
|
|
16417
|
+
usage: "okx outcomes auth <login|refresh|status> [--manual] [--site global|us] [--json]",
|
|
16418
|
+
description: "OAuth sign-in / token refresh / session status (login --manual = agent-friendly device-code flow)"
|
|
16419
|
+
},
|
|
16420
|
+
clob: {
|
|
16421
|
+
toolName: null,
|
|
16422
|
+
usage: "okx outcomes clob <price|prices|midpoint|midpoints|spread|spreads|book|books|order|orders|trades|create-order|market-order|cancel-oid|cancel-all|heartbeat>",
|
|
16423
|
+
description: "CLOB market data (--asset) + EIP-712 signed order operations"
|
|
16424
|
+
},
|
|
16425
|
+
ctf: {
|
|
16426
|
+
toolName: null,
|
|
16427
|
+
usage: "okx outcomes ctf <split|merge|redeem> --market <id> [--amount <xp>]",
|
|
16428
|
+
description: "Conditional Token Framework: split xp into YES/NO, merge, redeem"
|
|
16429
|
+
},
|
|
16430
|
+
wallet: {
|
|
16431
|
+
toolName: null,
|
|
16432
|
+
usage: "okx outcomes wallet show",
|
|
16433
|
+
description: "Show derived wallet address (from the signing key)"
|
|
16434
|
+
},
|
|
16435
|
+
status: {
|
|
16436
|
+
toolName: null,
|
|
16437
|
+
usage: "okx outcomes status [--json]",
|
|
16438
|
+
description: "Health check: API + balance reachability"
|
|
16439
|
+
},
|
|
16440
|
+
setup: {
|
|
16441
|
+
toolName: null,
|
|
16442
|
+
usage: "okx outcomes setup [status|region|bind]",
|
|
16443
|
+
description: "Setup wizard (region -> OAuth sign-in -> wallet bind); subcommands: status/region/bind"
|
|
16444
|
+
},
|
|
16445
|
+
shell: {
|
|
16446
|
+
toolName: null,
|
|
16447
|
+
usage: "okx outcomes shell",
|
|
16448
|
+
description: "Interactive REPL (do not invoke from agent context)"
|
|
16449
|
+
}
|
|
16450
|
+
}
|
|
16451
|
+
},
|
|
16281
16452
|
// ── list-tools ──────────────────────────────────────────────────────────────
|
|
16282
16453
|
"list-tools": {
|
|
16283
16454
|
description: "List all available tools and their parameters (use --json for machine-readable output)",
|
|
@@ -17152,6 +17323,30 @@ function parseCli(argv) {
|
|
|
17152
17323
|
}
|
|
17153
17324
|
return { values, positionals };
|
|
17154
17325
|
}
|
|
17326
|
+
function peekFirstPositional(argv) {
|
|
17327
|
+
const booleanFlags = /* @__PURE__ */ new Set();
|
|
17328
|
+
for (const [name, opt] of Object.entries(CLI_OPTIONS)) {
|
|
17329
|
+
const o = opt;
|
|
17330
|
+
if (o.type === "boolean") {
|
|
17331
|
+
booleanFlags.add(name);
|
|
17332
|
+
if (o.short) booleanFlags.add(o.short);
|
|
17333
|
+
}
|
|
17334
|
+
}
|
|
17335
|
+
for (let i = 0; i < argv.length; i++) {
|
|
17336
|
+
const tok = argv[i];
|
|
17337
|
+
if (tok === "--") {
|
|
17338
|
+
const next2 = argv[i + 1];
|
|
17339
|
+
return next2 === void 0 ? void 0 : { module: next2, idx: i + 1 };
|
|
17340
|
+
}
|
|
17341
|
+
if (!tok.startsWith("-")) return { module: tok, idx: i };
|
|
17342
|
+
if (tok.includes("=")) continue;
|
|
17343
|
+
const name = tok.replace(/^--?/, "");
|
|
17344
|
+
if (booleanFlags.has(name)) continue;
|
|
17345
|
+
const next = argv[i + 1];
|
|
17346
|
+
if (next !== void 0 && !next.startsWith("-")) i++;
|
|
17347
|
+
}
|
|
17348
|
+
return void 0;
|
|
17349
|
+
}
|
|
17155
17350
|
|
|
17156
17351
|
// src/commands/market.ts
|
|
17157
17352
|
var NO_INDICATOR_VALUES_HINT = "No indicator values returned. This indicator may require a period \u2014 try --params (e.g. --params 14).";
|
|
@@ -20643,20 +20838,20 @@ async function cmdDcdQuoteAndBuy(run, opts) {
|
|
|
20643
20838
|
|
|
20644
20839
|
// src/commands/skill.ts
|
|
20645
20840
|
import { tmpdir, homedir as homedir13 } from "os";
|
|
20646
|
-
import { join as
|
|
20647
|
-
import { mkdirSync as mkdirSync12, rmSync, existsSync as
|
|
20841
|
+
import { join as join18, dirname as dirname9 } from "path";
|
|
20842
|
+
import { mkdirSync as mkdirSync12, rmSync, existsSync as existsSync11, copyFileSync as copyFileSync2 } from "fs";
|
|
20648
20843
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
20649
20844
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
20650
20845
|
function resolveNpx() {
|
|
20651
|
-
const sibling =
|
|
20652
|
-
if (
|
|
20846
|
+
const sibling = join18(dirname9(process.execPath), "npx");
|
|
20847
|
+
if (existsSync11(sibling)) return sibling;
|
|
20653
20848
|
return "npx";
|
|
20654
20849
|
}
|
|
20655
20850
|
function npxEnv() {
|
|
20656
20851
|
return { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" };
|
|
20657
20852
|
}
|
|
20658
20853
|
function getSkillContentDir(name) {
|
|
20659
|
-
return
|
|
20854
|
+
return join18(homedir13(), ".agents", "skills", name);
|
|
20660
20855
|
}
|
|
20661
20856
|
var THIRD_PARTY_INSTALL_NOTICE = "Note: This skill was created by a third-party developer, not by OKX. Review SKILL.md before use.";
|
|
20662
20857
|
async function cmdSkillSearch(run, opts) {
|
|
@@ -20722,13 +20917,13 @@ async function wrapVerify(fn) {
|
|
|
20722
20917
|
async function cmdSkillAdd(name, config, json, force = false, exec = execFileSync2, _deps) {
|
|
20723
20918
|
const _download = _deps?.download ?? downloadSkillZip;
|
|
20724
20919
|
const _extract = _deps?.extract ?? extractSkillZip;
|
|
20725
|
-
const tmpBase =
|
|
20920
|
+
const tmpBase = join18(tmpdir(), `okx-skill-${randomUUID2()}`);
|
|
20726
20921
|
mkdirSync12(tmpBase, { recursive: true });
|
|
20727
20922
|
try {
|
|
20728
20923
|
outputLine(`Downloading ${name}...`);
|
|
20729
20924
|
const client = new OkxRestClient(config);
|
|
20730
20925
|
const zipPath = await _download(client, name, tmpBase);
|
|
20731
|
-
const contentDir = await _extract(zipPath,
|
|
20926
|
+
const contentDir = await _extract(zipPath, join18(tmpBase, "content"));
|
|
20732
20927
|
const meta = readMetaJson(contentDir);
|
|
20733
20928
|
validateSkillMdExists(contentDir);
|
|
20734
20929
|
outputLine("Verifying signature...");
|
|
@@ -20765,7 +20960,7 @@ async function cmdSkillAdd(name, config, json, force = false, exec = execFileSyn
|
|
|
20765
20960
|
env: npxEnv()
|
|
20766
20961
|
});
|
|
20767
20962
|
} catch (e) {
|
|
20768
|
-
const savedZip =
|
|
20963
|
+
const savedZip = join18(process.cwd(), `${name}.zip`);
|
|
20769
20964
|
try {
|
|
20770
20965
|
copyFileSync2(zipPath, savedZip);
|
|
20771
20966
|
} catch {
|
|
@@ -20878,7 +21073,7 @@ async function cmdSkillVerify(name, config, json) {
|
|
|
20878
21073
|
return;
|
|
20879
21074
|
}
|
|
20880
21075
|
const contentDir = getSkillContentDir(name);
|
|
20881
|
-
if (!
|
|
21076
|
+
if (!existsSync11(contentDir)) {
|
|
20882
21077
|
errorLine(`Skill content directory not found: ${contentDir}`);
|
|
20883
21078
|
errorLine(`Try reinstalling with: okx skill add ${name}`);
|
|
20884
21079
|
process.exitCode = 1;
|
|
@@ -21543,7 +21738,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
21543
21738
|
// src/index.ts
|
|
21544
21739
|
var _require3 = createRequire3(import.meta.url);
|
|
21545
21740
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
21546
|
-
var GIT_HASH2 = true ? "
|
|
21741
|
+
var GIT_HASH2 = true ? "e2de3b7e" : "dev";
|
|
21547
21742
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
21548
21743
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
21549
21744
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|
|
@@ -23025,7 +23220,16 @@ async function main() {
|
|
|
23025
23220
|
err: (m) => process.stderr.write(m)
|
|
23026
23221
|
});
|
|
23027
23222
|
checkForUpdates("@okx_ai/okx-trade-cli", CLI_VERSION2);
|
|
23028
|
-
const
|
|
23223
|
+
const rawArgv = process.argv.slice(2);
|
|
23224
|
+
const peek = peekFirstPositional(rawArgv);
|
|
23225
|
+
if (peek?.module === "outcomes") {
|
|
23226
|
+
const after = rawArgv.slice(peek.idx + 1);
|
|
23227
|
+
const action2 = after[0];
|
|
23228
|
+
const rest2 = after.slice(1);
|
|
23229
|
+
const json2 = rawArgv.includes("--json") || rawArgv.includes("-j");
|
|
23230
|
+
return handleOutcomesCommand(action2, rest2, { json: json2 });
|
|
23231
|
+
}
|
|
23232
|
+
const { values, positionals } = parseCli(rawArgv);
|
|
23029
23233
|
if (values.version) {
|
|
23030
23234
|
printVersion();
|
|
23031
23235
|
return;
|