@okx_ai/okx-trade-mcp 1.3.6-beta.1 → 1.3.7
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/LICENSE +21 -0
- package/dist/index.js +49 -36
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/scripts/postinstall-download.js +152 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OKX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -36,10 +36,10 @@ import { writeFileSync as writeFileSync2, renameSync as renameSync2, unlinkSync
|
|
|
36
36
|
import { join as join4, resolve, basename, sep } from "path";
|
|
37
37
|
import { randomUUID } from "crypto";
|
|
38
38
|
import yauzl from "yauzl";
|
|
39
|
-
import { join as
|
|
39
|
+
import { join as join8, dirname as dirname3 } from "path";
|
|
40
40
|
import { homedir as homedir4 } from "os";
|
|
41
|
-
import { readFileSync as
|
|
42
|
-
import { join as
|
|
41
|
+
import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, existsSync as existsSync3 } from "fs";
|
|
42
|
+
import { join as join9, dirname as dirname4 } from "path";
|
|
43
43
|
import { homedir as homedir5 } from "os";
|
|
44
44
|
|
|
45
45
|
// ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/error.js
|
|
@@ -728,8 +728,8 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
// ../core/dist/index.js
|
|
731
|
-
import { readFileSync as
|
|
732
|
-
import { join as
|
|
731
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, mkdirSync as mkdirSync6, existsSync as existsSync4 } from "fs";
|
|
732
|
+
import { join as join10 } from "path";
|
|
733
733
|
import { homedir as homedir6 } from "os";
|
|
734
734
|
import fs2 from "fs";
|
|
735
735
|
import path2 from "path";
|
|
@@ -738,9 +738,21 @@ import * as fs3 from "fs";
|
|
|
738
738
|
import * as path3 from "path";
|
|
739
739
|
import * as os3 from "os";
|
|
740
740
|
import { execFileSync } from "child_process";
|
|
741
|
-
import { join as
|
|
741
|
+
import { join as join14 } from "path";
|
|
742
742
|
import { homedir as homedir10 } from "os";
|
|
743
|
-
|
|
743
|
+
function hasProxyEnv(env = process.env) {
|
|
744
|
+
return Boolean(
|
|
745
|
+
env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
function installEnvProxyDispatcher(deps = {}) {
|
|
749
|
+
const env = deps.env ?? process.env;
|
|
750
|
+
if (!hasProxyEnv(env)) return false;
|
|
751
|
+
const register = deps.register ?? (() => setGlobalDispatcher(new EnvHttpProxyAgent()));
|
|
752
|
+
register();
|
|
753
|
+
return true;
|
|
754
|
+
}
|
|
755
|
+
installEnvProxyDispatcher();
|
|
744
756
|
var EXEC_TIMEOUT_MS = 3e4;
|
|
745
757
|
var ALLOWED_DOMAIN_RE = /^[\w.-]+\.okx\.com$/;
|
|
746
758
|
var PILOT_BIN_DIR = join(homedir(), ".okx", "bin");
|
|
@@ -763,25 +775,25 @@ function execPilotBinary(domain, exclude = [], userAgent) {
|
|
|
763
775
|
if (userAgent) {
|
|
764
776
|
args.push("--user-agent", userAgent);
|
|
765
777
|
}
|
|
766
|
-
return new Promise((
|
|
778
|
+
return new Promise((resolve4) => {
|
|
767
779
|
execFile(
|
|
768
780
|
binPath,
|
|
769
781
|
args,
|
|
770
782
|
{ timeout: EXEC_TIMEOUT_MS, encoding: "utf-8" },
|
|
771
783
|
(error, stdout) => {
|
|
772
784
|
if (error) {
|
|
773
|
-
|
|
785
|
+
resolve4(null);
|
|
774
786
|
return;
|
|
775
787
|
}
|
|
776
788
|
try {
|
|
777
789
|
const result = JSON.parse(stdout);
|
|
778
790
|
if (result.code === 0 && result.data) {
|
|
779
|
-
|
|
791
|
+
resolve4(result.data);
|
|
780
792
|
} else {
|
|
781
|
-
|
|
793
|
+
resolve4(null);
|
|
782
794
|
}
|
|
783
795
|
} catch {
|
|
784
|
-
|
|
796
|
+
resolve4(null);
|
|
785
797
|
}
|
|
786
798
|
}
|
|
787
799
|
);
|
|
@@ -1115,7 +1127,7 @@ var EXIT_CODES = {
|
|
|
1115
1127
|
NOT_LOGGED_IN: 2,
|
|
1116
1128
|
REFRESH_FAILED: 3
|
|
1117
1129
|
};
|
|
1118
|
-
function finalizeToken(code, token,
|
|
1130
|
+
function finalizeToken(code, token, resolve4, reject) {
|
|
1119
1131
|
if (code === EXIT_CODES.SUCCESS) {
|
|
1120
1132
|
if (!token) {
|
|
1121
1133
|
reject(new AuthenticationError(
|
|
@@ -1124,7 +1136,7 @@ function finalizeToken(code, token, resolve3, reject) {
|
|
|
1124
1136
|
));
|
|
1125
1137
|
return;
|
|
1126
1138
|
}
|
|
1127
|
-
|
|
1139
|
+
resolve4(token);
|
|
1128
1140
|
return;
|
|
1129
1141
|
}
|
|
1130
1142
|
if (code === EXIT_CODES.NOT_LOGGED_IN) {
|
|
@@ -1161,7 +1173,7 @@ function defaultWindowsPipeName() {
|
|
|
1161
1173
|
return WIN_PIPE_PREFIX + randomBytes(32).toString("hex");
|
|
1162
1174
|
}
|
|
1163
1175
|
function execAuthTokenWindows(binPath, makePipeName = defaultWindowsPipeName) {
|
|
1164
|
-
return new Promise((
|
|
1176
|
+
return new Promise((resolve4, reject) => {
|
|
1165
1177
|
const pipeName = makePipeName();
|
|
1166
1178
|
const server = createServer();
|
|
1167
1179
|
const chunks = [];
|
|
@@ -1181,7 +1193,7 @@ function execAuthTokenWindows(binPath, makePipeName = defaultWindowsPipeName) {
|
|
|
1181
1193
|
const tryFinalize = () => {
|
|
1182
1194
|
if (!pipeClosed || exitCode === void 0) return;
|
|
1183
1195
|
const token = Buffer.concat(chunks).toString("utf-8").trim();
|
|
1184
|
-
settle(() => finalizeToken(exitCode, token,
|
|
1196
|
+
settle(() => finalizeToken(exitCode, token, resolve4, reject));
|
|
1185
1197
|
};
|
|
1186
1198
|
server.on("connection", (socket) => {
|
|
1187
1199
|
connectionMade = true;
|
|
@@ -1228,7 +1240,7 @@ function execAuthToken() {
|
|
|
1228
1240
|
return process.platform === "win32" ? execAuthTokenWindows(binPath) : execAuthTokenUnix(binPath);
|
|
1229
1241
|
}
|
|
1230
1242
|
function execAuthTokenUnix(binPath) {
|
|
1231
|
-
return new Promise((
|
|
1243
|
+
return new Promise((resolve4, reject) => {
|
|
1232
1244
|
const child = spawn2(binPath, ["token"], {
|
|
1233
1245
|
stdio: ["ignore", "ignore", "inherit", "pipe"]
|
|
1234
1246
|
// stdin stdout stderr fd3 (pipe)
|
|
@@ -1241,35 +1253,35 @@ function execAuthTokenUnix(binPath) {
|
|
|
1241
1253
|
});
|
|
1242
1254
|
child.on("close", (code) => {
|
|
1243
1255
|
const token = Buffer.concat(chunks).toString("utf-8").trim();
|
|
1244
|
-
finalizeToken(code, token,
|
|
1256
|
+
finalizeToken(code, token, resolve4, reject);
|
|
1245
1257
|
});
|
|
1246
1258
|
});
|
|
1247
1259
|
}
|
|
1248
1260
|
function execAuthStatus() {
|
|
1249
1261
|
const binPath = getAuthBinaryPath();
|
|
1250
|
-
return new Promise((
|
|
1262
|
+
return new Promise((resolve4) => {
|
|
1251
1263
|
execFile2(
|
|
1252
1264
|
binPath,
|
|
1253
1265
|
["status", "--json"],
|
|
1254
1266
|
{ timeout: EXEC_TIMEOUT_MS2, encoding: "utf-8" },
|
|
1255
1267
|
(error, stdout) => {
|
|
1256
1268
|
if (error) {
|
|
1257
|
-
|
|
1269
|
+
resolve4(null);
|
|
1258
1270
|
return;
|
|
1259
1271
|
}
|
|
1260
1272
|
try {
|
|
1261
1273
|
const result = JSON.parse(stdout);
|
|
1262
|
-
|
|
1274
|
+
resolve4(result);
|
|
1263
1275
|
} catch {
|
|
1264
|
-
|
|
1276
|
+
resolve4(null);
|
|
1265
1277
|
}
|
|
1266
1278
|
}
|
|
1267
1279
|
);
|
|
1268
1280
|
});
|
|
1269
1281
|
}
|
|
1270
1282
|
function sleep(ms) {
|
|
1271
|
-
return new Promise((
|
|
1272
|
-
setTimeout(
|
|
1283
|
+
return new Promise((resolve4) => {
|
|
1284
|
+
setTimeout(resolve4, ms);
|
|
1273
1285
|
});
|
|
1274
1286
|
}
|
|
1275
1287
|
var RateLimiter = class {
|
|
@@ -4059,8 +4071,9 @@ async function downloadSkillZip(client, name, targetDir, format = "zip") {
|
|
|
4059
4071
|
const filePath = safeWriteFile(targetDir, fileName, result.data);
|
|
4060
4072
|
return filePath;
|
|
4061
4073
|
}
|
|
4074
|
+
var ED25519_SPKI_HEADER = Buffer.from("302a300506032b6570032100", "hex");
|
|
4062
4075
|
var DEFAULT_MAX_TOTAL_BYTES = 100 * 1024 * 1024;
|
|
4063
|
-
var DEFAULT_REGISTRY_PATH =
|
|
4076
|
+
var DEFAULT_REGISTRY_PATH = join8(homedir4(), ".okx", "skills", "registry.json");
|
|
4064
4077
|
function registerSkillsTools() {
|
|
4065
4078
|
return [
|
|
4066
4079
|
{
|
|
@@ -11857,12 +11870,12 @@ function toMcpTool(tool) {
|
|
|
11857
11870
|
};
|
|
11858
11871
|
}
|
|
11859
11872
|
function configFilePath() {
|
|
11860
|
-
return
|
|
11873
|
+
return join9(homedir5(), ".okx", "config.toml");
|
|
11861
11874
|
}
|
|
11862
11875
|
function readFullConfig() {
|
|
11863
11876
|
const path4 = configFilePath();
|
|
11864
11877
|
if (!existsSync3(path4)) return { profiles: {} };
|
|
11865
|
-
const raw =
|
|
11878
|
+
const raw = readFileSync6(path4, "utf-8");
|
|
11866
11879
|
try {
|
|
11867
11880
|
return parse(raw);
|
|
11868
11881
|
} catch (err) {
|
|
@@ -11997,7 +12010,7 @@ async function loadConfig(cli) {
|
|
|
11997
12010
|
verbose: cli.verbose ?? false
|
|
11998
12011
|
};
|
|
11999
12012
|
}
|
|
12000
|
-
var CACHE_FILE =
|
|
12013
|
+
var CACHE_FILE = join10(homedir6(), ".okx", "update-check.json");
|
|
12001
12014
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
12002
12015
|
var NEGATIVE_CHECK_INTERVAL_MS = 60 * 60 * 1e3;
|
|
12003
12016
|
var DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
@@ -12005,7 +12018,7 @@ var FETCH_TIMEOUT_MS = 3e3;
|
|
|
12005
12018
|
function readCache2() {
|
|
12006
12019
|
try {
|
|
12007
12020
|
if (existsSync4(CACHE_FILE)) {
|
|
12008
|
-
return JSON.parse(
|
|
12021
|
+
return JSON.parse(readFileSync7(CACHE_FILE, "utf-8"));
|
|
12009
12022
|
}
|
|
12010
12023
|
} catch {
|
|
12011
12024
|
}
|
|
@@ -12013,7 +12026,7 @@ function readCache2() {
|
|
|
12013
12026
|
}
|
|
12014
12027
|
function writeCache2(cache) {
|
|
12015
12028
|
try {
|
|
12016
|
-
mkdirSync6(
|
|
12029
|
+
mkdirSync6(join10(homedir6(), ".okx"), { recursive: true });
|
|
12017
12030
|
writeFileSync5(CACHE_FILE, JSON.stringify(cache, null, 2), "utf-8");
|
|
12018
12031
|
} catch {
|
|
12019
12032
|
}
|
|
@@ -12043,13 +12056,13 @@ function buildNpmrcCandidates() {
|
|
|
12043
12056
|
let dir = process.cwd();
|
|
12044
12057
|
const root = dir.startsWith("/") ? "/" : dir.slice(0, 3);
|
|
12045
12058
|
while (true) {
|
|
12046
|
-
add(
|
|
12059
|
+
add(join10(dir, ".npmrc"));
|
|
12047
12060
|
if (dir === root) break;
|
|
12048
|
-
const parent =
|
|
12061
|
+
const parent = join10(dir, "..");
|
|
12049
12062
|
if (parent === dir) break;
|
|
12050
12063
|
dir = parent;
|
|
12051
12064
|
}
|
|
12052
|
-
add(
|
|
12065
|
+
add(join10(homedir6(), ".npmrc"));
|
|
12053
12066
|
if (process.platform !== "win32") {
|
|
12054
12067
|
add("/etc/npmrc");
|
|
12055
12068
|
}
|
|
@@ -12058,7 +12071,7 @@ function buildNpmrcCandidates() {
|
|
|
12058
12071
|
function readNpmrcRegistry(filePath) {
|
|
12059
12072
|
try {
|
|
12060
12073
|
if (!existsSync4(filePath)) return null;
|
|
12061
|
-
const lines =
|
|
12074
|
+
const lines = readFileSync7(filePath, "utf-8").split(/\r?\n/);
|
|
12062
12075
|
for (const line of lines) {
|
|
12063
12076
|
const trimmed = line.trim();
|
|
12064
12077
|
if (trimmed.startsWith("#") || !trimmed.includes("=")) continue;
|
|
@@ -12375,7 +12388,7 @@ function runSetup(options) {
|
|
|
12375
12388
|
`);
|
|
12376
12389
|
}
|
|
12377
12390
|
}
|
|
12378
|
-
var CACHE_PATH =
|
|
12391
|
+
var CACHE_PATH = join14(homedir10(), ".okx", "auth-binary-check.json");
|
|
12379
12392
|
var CHECK_INTERVAL_MS2 = 2 * 60 * 60 * 1e3;
|
|
12380
12393
|
|
|
12381
12394
|
// src/constants.ts
|
|
@@ -12384,7 +12397,7 @@ var _require = createRequire(import.meta.url);
|
|
|
12384
12397
|
var pkg = _require("../package.json");
|
|
12385
12398
|
var SERVER_NAME = "okx-trade-mcp";
|
|
12386
12399
|
var SERVER_VERSION = pkg.version;
|
|
12387
|
-
var GIT_HASH = true ? "
|
|
12400
|
+
var GIT_HASH = true ? "2c1da5c1" : "dev";
|
|
12388
12401
|
|
|
12389
12402
|
// src/server.ts
|
|
12390
12403
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|