@okx_ai/okx-trade-cli 1.3.8-beta.7 → 1.3.9-beta.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 +2 -2
- package/package.json +1 -1
- package/scripts/postinstall-download.js +0 -152
package/dist/index.js
CHANGED
|
@@ -14918,7 +14918,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
14918
14918
|
|
|
14919
14919
|
// src/commands/diagnose.ts
|
|
14920
14920
|
var CLI_VERSION = readCliVersion();
|
|
14921
|
-
var GIT_HASH = true ? "
|
|
14921
|
+
var GIT_HASH = true ? "deb85df8" : "dev";
|
|
14922
14922
|
function maskKey2(key) {
|
|
14923
14923
|
if (!key) return "(not set)";
|
|
14924
14924
|
if (key.length <= 8) return "****";
|
|
@@ -21807,7 +21807,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
21807
21807
|
// src/index.ts
|
|
21808
21808
|
var _require3 = createRequire3(import.meta.url);
|
|
21809
21809
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
21810
|
-
var GIT_HASH2 = true ? "
|
|
21810
|
+
var GIT_HASH2 = true ? "deb85df8" : "dev";
|
|
21811
21811
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
21812
21812
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
21813
21813
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|
package/package.json
CHANGED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* postinstall-download.js
|
|
4
|
-
*
|
|
5
|
-
* Downloads the platform-specific okx-doh-resolver binary from OKX CDN
|
|
6
|
-
* to ~/.okx/bin/. Two-layer CDN fallback:
|
|
7
|
-
* 1. static.okx.com (HTTPS, overseas)
|
|
8
|
-
* 2. pcdoh.qcxex.com (HTTP, domestic)
|
|
9
|
-
*
|
|
10
|
-
* This script MUST NOT block npm install — all errors are silently swallowed.
|
|
11
|
-
* If the binary cannot be downloaded the SDK falls back to direct connection.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { createWriteStream, mkdirSync, chmodSync, existsSync, unlinkSync } from 'node:fs';
|
|
15
|
-
import { homedir, platform, arch } from 'node:os';
|
|
16
|
-
import { join } from 'node:path';
|
|
17
|
-
import { get as httpsGet } from 'node:https';
|
|
18
|
-
import { get as httpGet } from 'node:http';
|
|
19
|
-
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
// Config
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
const CDN_SOURCES = [
|
|
25
|
-
{ host: 'static.okx.com', protocol: 'https' },
|
|
26
|
-
{ host: 'pcdoh.qcxex.com', protocol: 'http' },
|
|
27
|
-
];
|
|
28
|
-
const CDN_PATH_PREFIX = '/upgradeapp/doh/prepub';
|
|
29
|
-
const DOWNLOAD_TIMEOUT_MS = 30_000;
|
|
30
|
-
const BIN_DIR = join(homedir(), '.okx', 'bin');
|
|
31
|
-
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
// Platform detection
|
|
34
|
-
// ---------------------------------------------------------------------------
|
|
35
|
-
|
|
36
|
-
function getPlatformDir() {
|
|
37
|
-
const p = platform();
|
|
38
|
-
const a = arch();
|
|
39
|
-
|
|
40
|
-
const map = {
|
|
41
|
-
'darwin-arm64': 'darwin-arm64',
|
|
42
|
-
'darwin-x64': 'darwin-x64',
|
|
43
|
-
'linux-x64': 'linux-x64',
|
|
44
|
-
'win32-x64': 'win32-x64',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const key = `${p}-${a}`;
|
|
48
|
-
return map[key] ?? null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getBinaryName() {
|
|
52
|
-
return platform() === 'win32' ? 'okx-doh-resolver.exe' : 'okx-doh-resolver';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
// Download helper (follows up to 5 redirects)
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
function download(url, destPath, timeoutMs) {
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
let redirects = 0;
|
|
62
|
-
const maxRedirects = 5;
|
|
63
|
-
const getter = url.startsWith('https') ? httpsGet : httpGet;
|
|
64
|
-
|
|
65
|
-
function doRequest(requestUrl) {
|
|
66
|
-
const reqFn = requestUrl.startsWith('https') ? httpsGet : getter;
|
|
67
|
-
const req = reqFn(requestUrl, { timeout: timeoutMs }, (res) => {
|
|
68
|
-
// Follow redirects
|
|
69
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
70
|
-
redirects++;
|
|
71
|
-
if (redirects > maxRedirects) {
|
|
72
|
-
reject(new Error(`Too many redirects (${maxRedirects})`));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
doRequest(res.headers.location);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (res.statusCode !== 200) {
|
|
80
|
-
reject(new Error(`HTTP ${res.statusCode}`));
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const file = createWriteStream(destPath);
|
|
85
|
-
res.pipe(file);
|
|
86
|
-
file.on('finish', () => file.close(resolve));
|
|
87
|
-
file.on('error', (err) => {
|
|
88
|
-
try { unlinkSync(destPath); } catch { /* ignore */ }
|
|
89
|
-
reject(err);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
req.on('error', reject);
|
|
94
|
-
req.on('timeout', () => {
|
|
95
|
-
req.destroy();
|
|
96
|
-
reject(new Error('Download timed out'));
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
doRequest(url);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
|
-
// Main
|
|
106
|
-
// ---------------------------------------------------------------------------
|
|
107
|
-
|
|
108
|
-
async function main() {
|
|
109
|
-
// Skip if OKX_DOH_BINARY_PATH is set (user manages their own binary)
|
|
110
|
-
if (process.env.OKX_DOH_BINARY_PATH) return;
|
|
111
|
-
|
|
112
|
-
const platformDir = getPlatformDir();
|
|
113
|
-
if (!platformDir) {
|
|
114
|
-
// Unsupported platform — silently skip
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const binaryName = getBinaryName();
|
|
119
|
-
const destPath = join(BIN_DIR, binaryName);
|
|
120
|
-
|
|
121
|
-
// Skip if binary already exists
|
|
122
|
-
if (existsSync(destPath)) return;
|
|
123
|
-
|
|
124
|
-
// Ensure target directory exists
|
|
125
|
-
mkdirSync(BIN_DIR, { recursive: true });
|
|
126
|
-
|
|
127
|
-
const urlPath = `${CDN_PATH_PREFIX}/${platformDir}/${binaryName}`;
|
|
128
|
-
|
|
129
|
-
for (const { host, protocol } of CDN_SOURCES) {
|
|
130
|
-
const url = `${protocol}://${host}${urlPath}`;
|
|
131
|
-
try {
|
|
132
|
-
await download(url, destPath, DOWNLOAD_TIMEOUT_MS);
|
|
133
|
-
// Make executable on Unix
|
|
134
|
-
if (platform() !== 'win32') {
|
|
135
|
-
chmodSync(destPath, 0o755);
|
|
136
|
-
}
|
|
137
|
-
process.stderr.write(` ✓ DoH resolver downloaded from ${host}\n`);
|
|
138
|
-
return;
|
|
139
|
-
} catch {
|
|
140
|
-
// Remove partial download
|
|
141
|
-
try { unlinkSync(destPath); } catch { /* ignore */ }
|
|
142
|
-
// Try next CDN source
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// All CDN hosts failed — silently degrade
|
|
147
|
-
process.stderr.write(' ⓘ DoH resolver not available (download failed), using direct connection.\n');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
main().catch(() => {
|
|
151
|
-
// Never block npm install
|
|
152
|
-
});
|