@zltquant/zlt-mcp 0.11.2 → 0.11.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/README.md +4 -2
- package/package.json +1 -1
- package/zlt-mcp-proxy.bundle.cjs +1097 -572
package/zlt-mcp-proxy.bundle.cjs
CHANGED
|
@@ -1206,8 +1206,8 @@ var require_command = __commonJS({
|
|
|
1206
1206
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
1207
1207
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1208
1208
|
var childProcess = require("node:child_process");
|
|
1209
|
-
var
|
|
1210
|
-
var
|
|
1209
|
+
var path64 = require("node:path");
|
|
1210
|
+
var fs61 = require("node:fs");
|
|
1211
1211
|
var process4 = require("node:process");
|
|
1212
1212
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1213
1213
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -2188,7 +2188,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2188
2188
|
* @param {string} subcommandName
|
|
2189
2189
|
*/
|
|
2190
2190
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
2191
|
-
if (
|
|
2191
|
+
if (fs61.existsSync(executableFile)) return;
|
|
2192
2192
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
2193
2193
|
const executableMissing = `'${executableFile}' does not exist
|
|
2194
2194
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -2206,11 +2206,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2206
2206
|
let launchWithNode = false;
|
|
2207
2207
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2208
2208
|
function findFile(baseDir, baseName) {
|
|
2209
|
-
const localBin =
|
|
2210
|
-
if (
|
|
2211
|
-
if (sourceExt.includes(
|
|
2209
|
+
const localBin = path64.resolve(baseDir, baseName);
|
|
2210
|
+
if (fs61.existsSync(localBin)) return localBin;
|
|
2211
|
+
if (sourceExt.includes(path64.extname(baseName))) return void 0;
|
|
2212
2212
|
const foundExt = sourceExt.find(
|
|
2213
|
-
(ext) =>
|
|
2213
|
+
(ext) => fs61.existsSync(`${localBin}${ext}`)
|
|
2214
2214
|
);
|
|
2215
2215
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
2216
2216
|
return void 0;
|
|
@@ -2222,21 +2222,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2222
2222
|
if (this._scriptPath) {
|
|
2223
2223
|
let resolvedScriptPath;
|
|
2224
2224
|
try {
|
|
2225
|
-
resolvedScriptPath =
|
|
2225
|
+
resolvedScriptPath = fs61.realpathSync(this._scriptPath);
|
|
2226
2226
|
} catch {
|
|
2227
2227
|
resolvedScriptPath = this._scriptPath;
|
|
2228
2228
|
}
|
|
2229
|
-
executableDir =
|
|
2230
|
-
|
|
2229
|
+
executableDir = path64.resolve(
|
|
2230
|
+
path64.dirname(resolvedScriptPath),
|
|
2231
2231
|
executableDir
|
|
2232
2232
|
);
|
|
2233
2233
|
}
|
|
2234
2234
|
if (executableDir) {
|
|
2235
2235
|
let localFile = findFile(executableDir, executableFile);
|
|
2236
2236
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2237
|
-
const legacyName =
|
|
2237
|
+
const legacyName = path64.basename(
|
|
2238
2238
|
this._scriptPath,
|
|
2239
|
-
|
|
2239
|
+
path64.extname(this._scriptPath)
|
|
2240
2240
|
);
|
|
2241
2241
|
if (legacyName !== this._name) {
|
|
2242
2242
|
localFile = findFile(
|
|
@@ -2247,7 +2247,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2247
2247
|
}
|
|
2248
2248
|
executableFile = localFile || executableFile;
|
|
2249
2249
|
}
|
|
2250
|
-
launchWithNode = sourceExt.includes(
|
|
2250
|
+
launchWithNode = sourceExt.includes(path64.extname(executableFile));
|
|
2251
2251
|
let proc;
|
|
2252
2252
|
if (process4.platform !== "win32") {
|
|
2253
2253
|
if (launchWithNode) {
|
|
@@ -3094,7 +3094,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3094
3094
|
* @return {Command}
|
|
3095
3095
|
*/
|
|
3096
3096
|
nameFromFilename(filename) {
|
|
3097
|
-
this._name =
|
|
3097
|
+
this._name = path64.basename(filename, path64.extname(filename));
|
|
3098
3098
|
return this;
|
|
3099
3099
|
}
|
|
3100
3100
|
/**
|
|
@@ -3108,9 +3108,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3108
3108
|
* @param {string} [path]
|
|
3109
3109
|
* @return {(string|null|Command)}
|
|
3110
3110
|
*/
|
|
3111
|
-
executableDir(
|
|
3112
|
-
if (
|
|
3113
|
-
this._executableDir =
|
|
3111
|
+
executableDir(path65) {
|
|
3112
|
+
if (path65 === void 0) return this._executableDir;
|
|
3113
|
+
this._executableDir = path65;
|
|
3114
3114
|
return this;
|
|
3115
3115
|
}
|
|
3116
3116
|
/**
|
|
@@ -6009,6 +6009,16 @@ async function finishRuntimeUpdate(handle, deps = runtimeLifecycleDepsForWorkRoo
|
|
|
6009
6009
|
fs11.unlinkSync(path11.join(stateDir, "update.json"));
|
|
6010
6010
|
});
|
|
6011
6011
|
}
|
|
6012
|
+
async function withIdleRuntime(root2, action) {
|
|
6013
|
+
const deps = runtimeLifecycleDepsForWorkRoot(root2);
|
|
6014
|
+
return withLifecycleLock(root2, deps, async (stateDir) => {
|
|
6015
|
+
assertRuntimeUpdateAccess(root2);
|
|
6016
|
+
const state2 = readAndPruneStore(stateDir, deps);
|
|
6017
|
+
if (state2.owner || state2.ownerMismatch || state2.leases.length)
|
|
6018
|
+
throw new Error("Stop the selected runtime and active tasks before preparing data");
|
|
6019
|
+
return action();
|
|
6020
|
+
});
|
|
6021
|
+
}
|
|
6012
6022
|
async function acquireRuntimeLease(workRoot, role, options = {}) {
|
|
6013
6023
|
assertRuntimeUpdateAccess(workRoot, options.updateToken);
|
|
6014
6024
|
const deps = options.deps ?? runtimeLifecycleDepsForWorkRoot(workRoot);
|
|
@@ -7449,17 +7459,17 @@ function rejectUnreachableProcess(executable) {
|
|
|
7449
7459
|
}
|
|
7450
7460
|
}
|
|
7451
7461
|
}
|
|
7452
|
-
async function launch3(root2, config2, host, owned) {
|
|
7462
|
+
async function launch3(root2, config2, host, owned, isolatedHost) {
|
|
7453
7463
|
const executable = path14.join(root2, host ? HOST2 : AF2);
|
|
7454
7464
|
rejectUnreachableProcess(executable);
|
|
7455
|
-
const log2 = path14.join(root2, "Temporary", host ? "cli-zlthost.log" : "cli-zltaf.log");
|
|
7465
|
+
const log2 = isolatedHost?.log ?? path14.join(root2, "Temporary", host ? "cli-zlthost.log" : "cli-zltaf.log");
|
|
7456
7466
|
const env = { ...process.env, PYTHONDONTWRITEBYTECODE: "1" };
|
|
7457
7467
|
for (const key2 of ["LD_LIBRARY_PATH", "LD_PRELOAD", "LD_AUDIT", "PYTHONPATH", "PYTHONHOME"])
|
|
7458
7468
|
delete env[key2];
|
|
7459
7469
|
const fd = fs14.openSync(log2, fs14.constants.O_WRONLY | fs14.constants.O_APPEND | fs14.constants.O_CREAT | fs14.constants.O_NOFOLLOW, 384);
|
|
7460
7470
|
const child = (() => {
|
|
7461
7471
|
try {
|
|
7462
|
-
return (0, import_node_child_process5.spawn)(host ? path14.join(root2, LAUNCHER) : executable, host ? [] : [`-Dconfig.path=${path14.join(root2, PROPERTIES)}`], {
|
|
7472
|
+
return (0, import_node_child_process5.spawn)(host ? path14.join(root2, LAUNCHER) : executable, host ? isolatedHost ? [`--config=${isolatedHost.configPath}`] : [] : [`-Dconfig.path=${path14.join(root2, PROPERTIES)}`], {
|
|
7463
7473
|
cwd: host ? path14.dirname(executable) : root2,
|
|
7464
7474
|
env,
|
|
7465
7475
|
detached: true,
|
|
@@ -7486,7 +7496,7 @@ async function launch3(root2, config2, host, owned) {
|
|
|
7486
7496
|
owned.push(identity2);
|
|
7487
7497
|
}
|
|
7488
7498
|
}
|
|
7489
|
-
if (identity2 && await reachable3(root2, host))
|
|
7499
|
+
if (identity2 && (isolatedHost ? isOwnedLinuxClientLiteSocket(isolatedHost.socket) : await reachable3(root2, host)))
|
|
7490
7500
|
return;
|
|
7491
7501
|
if (child.exitCode !== null || child.signalCode !== null)
|
|
7492
7502
|
break;
|
|
@@ -7494,6 +7504,93 @@ async function launch3(root2, config2, host, owned) {
|
|
|
7494
7504
|
}
|
|
7495
7505
|
throw new Error(`Linux ClientLite ${host ? "Host" : "ZLTAF"} did not become ready; see ${log2}${!identity2 && child.pid ? ` (PID ${child.pid} was not verified)` : ""}`);
|
|
7496
7506
|
}
|
|
7507
|
+
function dataHostIdentity(root2, configPath) {
|
|
7508
|
+
for (const entry of fs14.readdirSync("/proc")) {
|
|
7509
|
+
if (!/^\d+$/.test(entry))
|
|
7510
|
+
continue;
|
|
7511
|
+
const proc = "/proc/" + entry;
|
|
7512
|
+
try {
|
|
7513
|
+
if (fs14.statSync(proc).uid !== process.getuid?.())
|
|
7514
|
+
continue;
|
|
7515
|
+
const args = fs14.readFileSync(proc + "/cmdline", "utf8").split("\0");
|
|
7516
|
+
if (!args.includes("--config=" + configPath))
|
|
7517
|
+
continue;
|
|
7518
|
+
const identity2 = inspectRuntimeProcess(Number(entry));
|
|
7519
|
+
if (!identity2)
|
|
7520
|
+
continue;
|
|
7521
|
+
if (identity2.executablePath === path14.join(root2, HOST2))
|
|
7522
|
+
return identity2;
|
|
7523
|
+
if (args.includes(path14.join(root2, LAUNCHER)) || args.includes(path14.join(root2, HOST2))) {
|
|
7524
|
+
throw new Error("Previous data preparation Host is still starting; retry after it has started");
|
|
7525
|
+
}
|
|
7526
|
+
} catch (error2) {
|
|
7527
|
+
if (!["ENOENT", "ESRCH", "EACCES", "EPERM"].includes(error2.code ?? ""))
|
|
7528
|
+
throw error2;
|
|
7529
|
+
}
|
|
7530
|
+
}
|
|
7531
|
+
}
|
|
7532
|
+
async function withLinuxClientLiteDataHost(root2, config2, temporaryHostConfig, directory, action) {
|
|
7533
|
+
return withIdleRuntime(root2, async () => {
|
|
7534
|
+
const valid = validateLinuxClientLite(root2, config2);
|
|
7535
|
+
if (!valid.complete)
|
|
7536
|
+
throw new Error(valid.reason);
|
|
7537
|
+
if (await reachable3(root2, true) || await reachable3(root2, false))
|
|
7538
|
+
throw new Error("Stop the existing ClientLite runtime before preparing data");
|
|
7539
|
+
const suffix = readZltPipeSuffix(root2);
|
|
7540
|
+
const name = temporaryHostConfig.pipName;
|
|
7541
|
+
if (typeof name !== "string" || !/^ZLTDcm[A-Fa-f0-9]{16}$/.test(name) || !suffix)
|
|
7542
|
+
throw new Error("Invalid data preparation socket identity");
|
|
7543
|
+
const socket = `/tmp/${name}_${suffix}`;
|
|
7544
|
+
const configPath = path14.join(directory, "host.json");
|
|
7545
|
+
const state2 = path14.dirname(directory);
|
|
7546
|
+
const active2 = path14.join(state2, "active-host.json");
|
|
7547
|
+
const previous = fs14.lstatSync(active2, { throwIfNoEntry: false });
|
|
7548
|
+
if (previous) {
|
|
7549
|
+
if (!previous.isFile() || previous.uid !== process.getuid?.() || previous.mode & 63 || previous.size > 512) {
|
|
7550
|
+
throw new Error("Unsafe data preparation Host record");
|
|
7551
|
+
}
|
|
7552
|
+
const record7 = JSON.parse(fs14.readFileSync(active2, "utf8"));
|
|
7553
|
+
if (typeof record7.directory !== "string" || !/^host-[A-Za-z0-9]{6}$/.test(record7.directory) || typeof record7.name !== "string" || !/^ZLTDcm[a-f0-9]{16}$/.test(record7.name)) {
|
|
7554
|
+
throw new Error("Invalid data preparation Host record");
|
|
7555
|
+
}
|
|
7556
|
+
const identity2 = dataHostIdentity(root2, path14.join(state2, record7.directory, "host.json"));
|
|
7557
|
+
if (identity2)
|
|
7558
|
+
await terminateRuntimeProcess(identity2);
|
|
7559
|
+
const previousSocket = `/tmp/${record7.name}_${suffix}`;
|
|
7560
|
+
if (isOwnedLinuxClientLiteSocket(previousSocket))
|
|
7561
|
+
fs14.unlinkSync(previousSocket);
|
|
7562
|
+
fs14.unlinkSync(active2);
|
|
7563
|
+
}
|
|
7564
|
+
if (fs14.existsSync(socket))
|
|
7565
|
+
throw new Error("Data preparation socket already exists");
|
|
7566
|
+
fs14.writeFileSync(configPath, JSON.stringify(temporaryHostConfig), { flag: "wx", mode: 384 });
|
|
7567
|
+
const next = path14.join(directory, "active-host.json");
|
|
7568
|
+
fs14.writeFileSync(next, JSON.stringify({ directory: path14.basename(directory), name }), { flag: "wx", mode: 384 });
|
|
7569
|
+
fs14.renameSync(next, active2);
|
|
7570
|
+
const owned = [];
|
|
7571
|
+
const interrupted2 = new AbortController();
|
|
7572
|
+
const onInterrupt = () => interrupted2.abort(new Error("Data preparation interrupted; rerun the same command to continue"));
|
|
7573
|
+
process.on("SIGINT", onInterrupt);
|
|
7574
|
+
process.on("SIGTERM", onInterrupt);
|
|
7575
|
+
try {
|
|
7576
|
+
await launch3(root2, config2, true, owned, { configPath, socket, log: path14.join(directory, "host.log") });
|
|
7577
|
+
interrupted2.signal.throwIfAborted();
|
|
7578
|
+
return await action(socket, interrupted2.signal);
|
|
7579
|
+
} finally {
|
|
7580
|
+
try {
|
|
7581
|
+
const identity2 = owned[0] ?? dataHostIdentity(root2, configPath);
|
|
7582
|
+
if (identity2)
|
|
7583
|
+
await terminateRuntimeProcess(identity2);
|
|
7584
|
+
if (isOwnedLinuxClientLiteSocket(socket))
|
|
7585
|
+
fs14.unlinkSync(socket);
|
|
7586
|
+
fs14.unlinkSync(active2);
|
|
7587
|
+
} finally {
|
|
7588
|
+
process.off("SIGINT", onInterrupt);
|
|
7589
|
+
process.off("SIGTERM", onInterrupt);
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
});
|
|
7593
|
+
}
|
|
7497
7594
|
async function acquireLinuxClientLite(root2, config2, options = {}) {
|
|
7498
7595
|
root2 = fs14.realpathSync(root2);
|
|
7499
7596
|
const valid = validateLinuxClientLite(root2, config2, options.allowIncompleteQualification);
|
|
@@ -7640,18 +7737,18 @@ async function waitForPipe(workRoot, pipePrefix, timeout) {
|
|
|
7640
7737
|
throw new Error(`\u7B49\u5F85 ${pipePrefix} \u7BA1\u9053\u8D85\u65F6`);
|
|
7641
7738
|
}
|
|
7642
7739
|
async function readZltContent(workRoot, temporaryZltFile) {
|
|
7643
|
-
const
|
|
7644
|
-
const
|
|
7645
|
-
const zltFile =
|
|
7646
|
-
return
|
|
7740
|
+
const fs61 = await import("fs");
|
|
7741
|
+
const path64 = await import("path");
|
|
7742
|
+
const zltFile = path64.join(workRoot, temporaryZltFile || "Temporary/zlt");
|
|
7743
|
+
return fs61.existsSync(zltFile) ? fs61.readFileSync(zltFile, "utf-8").trim() : "";
|
|
7647
7744
|
}
|
|
7648
7745
|
async function pipeExists2(pipeName) {
|
|
7649
|
-
const
|
|
7746
|
+
const fs61 = await import("fs");
|
|
7650
7747
|
try {
|
|
7651
7748
|
if (process.platform === "win32") {
|
|
7652
|
-
return
|
|
7749
|
+
return fs61.readdirSync("\\\\.\\pipe\\").includes(pipeName);
|
|
7653
7750
|
}
|
|
7654
|
-
return
|
|
7751
|
+
return fs61.existsSync(`/tmp/${pipeName}`);
|
|
7655
7752
|
} catch {
|
|
7656
7753
|
return false;
|
|
7657
7754
|
}
|
|
@@ -11038,7 +11135,7 @@ function persistDeviceAuthorization(grant, env) {
|
|
|
11038
11135
|
throw new DeviceAuthorizationError("credentials_conflict", "Persisted device credential is not effective");
|
|
11039
11136
|
return { status: "success", authStatus: authStatus2 };
|
|
11040
11137
|
}
|
|
11041
|
-
async function requestJson(options, base,
|
|
11138
|
+
async function requestJson(options, base, path64, payload2, allowPoll400 = false) {
|
|
11042
11139
|
const controller = new AbortController();
|
|
11043
11140
|
const externalAbort = () => controller.abort();
|
|
11044
11141
|
if (options.signal?.aborted)
|
|
@@ -11047,7 +11144,7 @@ async function requestJson(options, base, path63, payload2, allowPoll400 = false
|
|
|
11047
11144
|
options.signal?.addEventListener("abort", externalAbort, { once: true });
|
|
11048
11145
|
const timeout = setTimeout(() => controller.abort(), options.requestTimeoutMs ?? 15e3);
|
|
11049
11146
|
try {
|
|
11050
|
-
const response = await (options.fetch ?? globalThis.fetch)(new URL(
|
|
11147
|
+
const response = await (options.fetch ?? globalThis.fetch)(new URL(path64, base), {
|
|
11051
11148
|
method: "POST",
|
|
11052
11149
|
redirect: "error",
|
|
11053
11150
|
headers: { "content-type": "application/json" },
|
|
@@ -12823,7 +12920,7 @@ var require_buffer_list = __commonJS({
|
|
|
12823
12920
|
}
|
|
12824
12921
|
}, {
|
|
12825
12922
|
key: "join",
|
|
12826
|
-
value: function
|
|
12923
|
+
value: function join58(s2) {
|
|
12827
12924
|
if (this.length === 0) return "";
|
|
12828
12925
|
var p = this.head;
|
|
12829
12926
|
var ret = "" + p.data;
|
|
@@ -18308,19 +18405,26 @@ var init_clientlite_macos_release_install = __esm({
|
|
|
18308
18405
|
// ../zlt-runtime-core/dist/linux-clientlite-research-trust.js
|
|
18309
18406
|
function uid() {
|
|
18310
18407
|
if (process.platform !== "linux" || !process.getuid)
|
|
18311
|
-
throw new
|
|
18408
|
+
throw new ResearchRuntimeTrustError("unsupported-platform");
|
|
18312
18409
|
return process.getuid();
|
|
18313
18410
|
}
|
|
18314
18411
|
function ownDirectory(dir2, owner, privateMode = false) {
|
|
18315
18412
|
const info2 = fs32.lstatSync(dir2);
|
|
18316
|
-
if (!info2.isDirectory() || info2.
|
|
18317
|
-
throw new
|
|
18413
|
+
if (!info2.isDirectory() || info2.mode & (privateMode ? 63 : 18)) {
|
|
18414
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18415
|
+
}
|
|
18416
|
+
if (info2.uid !== owner)
|
|
18417
|
+
throw new ResearchRuntimeTrustError("ownership-mismatch");
|
|
18318
18418
|
}
|
|
18319
18419
|
function requireTrustedParents(dir2, owner) {
|
|
18320
18420
|
for (; ; ) {
|
|
18321
18421
|
const info2 = fs32.lstatSync(dir2);
|
|
18322
|
-
if (!info2.isDirectory()
|
|
18323
|
-
throw new
|
|
18422
|
+
if (!info2.isDirectory())
|
|
18423
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18424
|
+
if (info2.uid !== owner && info2.uid !== 0)
|
|
18425
|
+
throw new ResearchRuntimeTrustError("ownership-mismatch");
|
|
18426
|
+
if ((info2.mode & 18) !== 0 && (info2.uid !== 0 || !(info2.mode & 512))) {
|
|
18427
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18324
18428
|
}
|
|
18325
18429
|
const parent = path32.dirname(dir2);
|
|
18326
18430
|
if (parent === dir2)
|
|
@@ -18343,13 +18447,13 @@ function sealDirectory(create, allowMissing = false) {
|
|
|
18343
18447
|
ownDirectory(store, owner, true);
|
|
18344
18448
|
return store;
|
|
18345
18449
|
}
|
|
18346
|
-
function
|
|
18347
|
-
return
|
|
18450
|
+
function sealFilename(root2) {
|
|
18451
|
+
return (0, import_node_crypto15.createHash)("sha256").update(root2).digest("hex") + ".json";
|
|
18348
18452
|
}
|
|
18349
18453
|
function checkLinuxClientLiteResearchInstallLocation(root2) {
|
|
18350
18454
|
try {
|
|
18351
18455
|
if (!path32.isAbsolute(root2) || path32.normalize(root2) !== root2)
|
|
18352
|
-
throw new
|
|
18456
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18353
18457
|
const parent = path32.dirname(root2);
|
|
18354
18458
|
let existing2 = parent;
|
|
18355
18459
|
let info2 = fs32.lstatSync(existing2, { throwIfNoEntry: false });
|
|
@@ -18358,7 +18462,7 @@ function checkLinuxClientLiteResearchInstallLocation(root2) {
|
|
|
18358
18462
|
info2 = fs32.lstatSync(existing2, { throwIfNoEntry: false });
|
|
18359
18463
|
}
|
|
18360
18464
|
if (!info2 || existing2 === parent && info2.mode & 18)
|
|
18361
|
-
throw new
|
|
18465
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18362
18466
|
requireTrustedParents(existing2, uid());
|
|
18363
18467
|
sealDirectory(false, true);
|
|
18364
18468
|
} catch (cause) {
|
|
@@ -18377,7 +18481,7 @@ function trustedSystemAlias(relative13, resolved) {
|
|
|
18377
18481
|
function softwareDigest(root2) {
|
|
18378
18482
|
const owner = uid();
|
|
18379
18483
|
if (fs32.realpathSync(root2) !== root2)
|
|
18380
|
-
throw new
|
|
18484
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18381
18485
|
requireTrustedParents(path32.dirname(root2), owner);
|
|
18382
18486
|
ownDirectory(root2, owner, true);
|
|
18383
18487
|
const hash = (0, import_node_crypto15.createHash)("sha256");
|
|
@@ -18385,24 +18489,24 @@ function softwareDigest(root2) {
|
|
|
18385
18489
|
const file2 = path32.join(root2, relative13);
|
|
18386
18490
|
const info2 = fs32.lstatSync(file2);
|
|
18387
18491
|
if (info2.uid !== owner)
|
|
18388
|
-
throw new
|
|
18492
|
+
throw new ResearchRuntimeTrustError("ownership-mismatch");
|
|
18389
18493
|
const record7 = (kind, value = "") => hash.update(JSON.stringify([relative13, kind, info2.mode & 511, value]) + "\n");
|
|
18390
18494
|
if (info2.isSymbolicLink()) {
|
|
18391
18495
|
const resolved = fs32.realpathSync(file2);
|
|
18392
18496
|
const internal = SOFTWARE.some((name) => withinClientLitePrefix(path32.join(root2, name), resolved));
|
|
18393
18497
|
if (!internal && !trustedSystemAlias(relative13, resolved))
|
|
18394
|
-
throw new
|
|
18498
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18395
18499
|
record7("link", fs32.readlinkSync(file2));
|
|
18396
18500
|
} else if (info2.isDirectory()) {
|
|
18397
18501
|
if (info2.mode & 18)
|
|
18398
|
-
throw new
|
|
18502
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18399
18503
|
record7("directory");
|
|
18400
18504
|
for (const name of fs32.readdirSync(file2).sort())
|
|
18401
18505
|
visit(path32.join(relative13, name));
|
|
18402
18506
|
} else if (info2.isFile() && info2.nlink === 1 && !(info2.mode & 18)) {
|
|
18403
18507
|
record7("file", clientLiteFileHash(file2));
|
|
18404
18508
|
} else
|
|
18405
|
-
throw new
|
|
18509
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18406
18510
|
};
|
|
18407
18511
|
ownDirectory(path32.join(root2, "runtime"), owner);
|
|
18408
18512
|
for (const name of SOFTWARE) {
|
|
@@ -18412,24 +18516,41 @@ function softwareDigest(root2) {
|
|
|
18412
18516
|
return hash.digest("hex");
|
|
18413
18517
|
}
|
|
18414
18518
|
function sealLinuxClientLiteResearchRuntime(root2, releaseIdentity) {
|
|
18415
|
-
const file2 =
|
|
18519
|
+
const file2 = path32.join(sealDirectory(true), sealFilename(root2));
|
|
18416
18520
|
const digest2 = softwareDigest(root2);
|
|
18417
18521
|
fs32.writeFileSync(file2, JSON.stringify({ schemaVersion: 1, root: root2, releaseIdentity, digest: digest2 }) + "\n", { flag: "wx", mode: 384 });
|
|
18418
18522
|
}
|
|
18419
18523
|
function assertLinuxClientLiteResearchRuntime(root2, releaseIdentity) {
|
|
18420
18524
|
try {
|
|
18421
|
-
const
|
|
18422
|
-
const
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
if (
|
|
18427
|
-
throw new
|
|
18428
|
-
|
|
18429
|
-
|
|
18525
|
+
const store = sealDirectory(false, true);
|
|
18526
|
+
const file2 = path32.join(store, sealFilename(root2));
|
|
18527
|
+
const info2 = fs32.lstatSync(file2, { throwIfNoEntry: false });
|
|
18528
|
+
if (!info2)
|
|
18529
|
+
throw new ResearchRuntimeTrustError("seal-missing");
|
|
18530
|
+
if (!info2.isFile() || info2.nlink !== 1 || info2.mode & 63 || info2.size > 8192) {
|
|
18531
|
+
throw new ResearchRuntimeTrustError("unsafe-filesystem");
|
|
18532
|
+
}
|
|
18533
|
+
if (info2.uid !== uid())
|
|
18534
|
+
throw new ResearchRuntimeTrustError("ownership-mismatch");
|
|
18535
|
+
const bytes = fs32.readFileSync(file2, "utf8");
|
|
18536
|
+
let seal;
|
|
18537
|
+
try {
|
|
18538
|
+
seal = JSON.parse(bytes);
|
|
18539
|
+
} catch {
|
|
18540
|
+
throw new ResearchRuntimeTrustError("seal-invalid");
|
|
18541
|
+
}
|
|
18542
|
+
if (seal?.schemaVersion !== 1 || seal.root !== root2 || seal.releaseIdentity !== releaseIdentity || typeof seal.digest !== "string" || !/^[a-f0-9]{64}$/.test(seal.digest)) {
|
|
18543
|
+
throw new ResearchRuntimeTrustError("seal-invalid");
|
|
18544
|
+
}
|
|
18545
|
+
if (seal.digest !== softwareDigest(root2))
|
|
18546
|
+
throw new ResearchRuntimeTrustError("software-changed");
|
|
18547
|
+
} catch (error2) {
|
|
18548
|
+
if (error2 instanceof ResearchRuntimeTrustError)
|
|
18549
|
+
throw error2;
|
|
18550
|
+
throw new ResearchRuntimeTrustError("filesystem-unavailable");
|
|
18430
18551
|
}
|
|
18431
18552
|
}
|
|
18432
|
-
var fs32, os10, path32, import_node_crypto15, SOFTWARE, SYSTEM_LIBRARIES,
|
|
18553
|
+
var fs32, os10, path32, import_node_crypto15, SOFTWARE, SYSTEM_LIBRARIES, TRUST_MESSAGES, ResearchRuntimeTrustError;
|
|
18433
18554
|
var init_linux_clientlite_research_trust = __esm({
|
|
18434
18555
|
"../zlt-runtime-core/dist/linux-clientlite-research-trust.js"() {
|
|
18435
18556
|
"use strict";
|
|
@@ -18445,7 +18566,23 @@ var init_linux_clientlite_research_trust = __esm({
|
|
|
18445
18566
|
init_shared_workspaces();
|
|
18446
18567
|
SOFTWARE = ["python", "runtime/lib", "bin"];
|
|
18447
18568
|
SYSTEM_LIBRARIES = /* @__PURE__ */ new Set(["libsqlite3.so.0", "libz.so.1"]);
|
|
18448
|
-
|
|
18569
|
+
TRUST_MESSAGES = {
|
|
18570
|
+
"unsupported-platform": "The runtime integrity check requires Linux.",
|
|
18571
|
+
"ownership-mismatch": "The process cannot verify file ownership in its current environment.",
|
|
18572
|
+
"unsafe-filesystem": "The runtime or private state has an unsafe path, file type, or permissions.",
|
|
18573
|
+
"seal-missing": "No private installation record was found in this environment. Check the selected installation and account home.",
|
|
18574
|
+
"seal-invalid": "The private installation record is invalid or belongs to a different release.",
|
|
18575
|
+
"software-changed": "The installed runtime software differs from its installation record.",
|
|
18576
|
+
"filesystem-unavailable": "The process could not read the required runtime files or private state."
|
|
18577
|
+
};
|
|
18578
|
+
ResearchRuntimeTrustError = class extends Error {
|
|
18579
|
+
reason;
|
|
18580
|
+
constructor(reason) {
|
|
18581
|
+
super(`Research requires a ClientLite installed by this CLI with its original software intact. ${TRUST_MESSAGES[reason]}`);
|
|
18582
|
+
this.reason = reason;
|
|
18583
|
+
this.name = "ResearchRuntimeTrustError";
|
|
18584
|
+
}
|
|
18585
|
+
};
|
|
18449
18586
|
}
|
|
18450
18587
|
});
|
|
18451
18588
|
|
|
@@ -19479,6 +19616,321 @@ var init_clientlite_uninstall = __esm({
|
|
|
19479
19616
|
}
|
|
19480
19617
|
});
|
|
19481
19618
|
|
|
19619
|
+
// ../zlt-runtime-core/dist/linux-clientlite-data.js
|
|
19620
|
+
function linuxDailyDataRequest(market, start, end) {
|
|
19621
|
+
const date4 = (s2) => {
|
|
19622
|
+
const stamp = /^\d{4}-\d{2}-\d{2}$/.test(s2) ? Date.parse(s2 + "T00:00:00Z") : NaN;
|
|
19623
|
+
if (!Number.isFinite(stamp) || new Date(stamp).toISOString().slice(0, 10) !== s2)
|
|
19624
|
+
throw new Error("Use a valid YYYY-MM-DD date");
|
|
19625
|
+
return stamp;
|
|
19626
|
+
};
|
|
19627
|
+
if (market !== "sh" && market !== "sz")
|
|
19628
|
+
throw new Error("Select sh or sz for daily stock data");
|
|
19629
|
+
const days = (date4(end) - date4(start)) / 864e5;
|
|
19630
|
+
if (days < 0 || days > 30)
|
|
19631
|
+
throw new Error("Choose a data window of at most 31 calendar days");
|
|
19632
|
+
return {
|
|
19633
|
+
params: [{ exchange_id: market, data_type: "dk1" }],
|
|
19634
|
+
start: start.replaceAll("-", "") + "000000",
|
|
19635
|
+
end: end.replaceAll("-", "") + "235959"
|
|
19636
|
+
};
|
|
19637
|
+
}
|
|
19638
|
+
function dcmResponse(status, header, content) {
|
|
19639
|
+
if (status !== 0 && status !== 200 || !/(?:^|,)code=0(?:,|$)/.test(header ?? "")) {
|
|
19640
|
+
throw new Error("ClientLite DCM rejected the operation; check the data preparation host log");
|
|
19641
|
+
}
|
|
19642
|
+
return JSON.parse(content);
|
|
19643
|
+
}
|
|
19644
|
+
function dcmReadIsInitializing(status, header) {
|
|
19645
|
+
return (status === 3 || status === 200) && /^(?:type=\d+,)?msg=storage initializing; capability=cache\.read,code=3,?$/.test(header ?? "");
|
|
19646
|
+
}
|
|
19647
|
+
function marketFile(root2, relative13) {
|
|
19648
|
+
const file2 = path36.join(root2, relative13);
|
|
19649
|
+
try {
|
|
19650
|
+
const stat2 = fs36.lstatSync(file2);
|
|
19651
|
+
if (!stat2.isFile() || stat2.size === 0 || fs36.realpathSync(file2) !== file2)
|
|
19652
|
+
throw new Error("Unsafe or empty market data file: " + relative13);
|
|
19653
|
+
return true;
|
|
19654
|
+
} catch (error2) {
|
|
19655
|
+
if (error2.code === "ENOENT")
|
|
19656
|
+
return false;
|
|
19657
|
+
throw error2;
|
|
19658
|
+
}
|
|
19659
|
+
}
|
|
19660
|
+
function linuxDataJournalName(task, request3) {
|
|
19661
|
+
return task === "market-foundation" ? "market-foundation.json" : "daily-" + (0, import_node_crypto19.createHash)("sha256").update(JSON.stringify(request3)).digest("hex") + ".json";
|
|
19662
|
+
}
|
|
19663
|
+
async function prepareDailyData(rpc, root2, journal, save2, pause = delay3) {
|
|
19664
|
+
const disk = await rpc("diskspace", {});
|
|
19665
|
+
if (disk.download_home !== root2)
|
|
19666
|
+
throw new Error("DCM data root differs from the selected SDK data root");
|
|
19667
|
+
const market = journal.request.params[0].exchange_id;
|
|
19668
|
+
const foundationReady = () => requiredMarketFiles.every((file2) => marketFile(root2, file2));
|
|
19669
|
+
const dailyReady = async () => {
|
|
19670
|
+
const directories = [`hqdata/his/${market}/dk1`, `hqdata/rel/${market}/dk1`];
|
|
19671
|
+
if (!directories.some((dir2) => {
|
|
19672
|
+
try {
|
|
19673
|
+
return fs36.readdirSync(path36.join(root2, dir2)).some((file2) => file2.endsWith(".dk1") && marketFile(root2, dir2 + "/" + file2));
|
|
19674
|
+
} catch (error2) {
|
|
19675
|
+
if (error2.code === "ENOENT")
|
|
19676
|
+
return false;
|
|
19677
|
+
throw error2;
|
|
19678
|
+
}
|
|
19679
|
+
}))
|
|
19680
|
+
return false;
|
|
19681
|
+
const coverage = await rpc("datarange", journal.request);
|
|
19682
|
+
return Array.isArray(coverage.results) && coverage.results.some((row) => row.exchange_id === market && row.data_type === "dk1" && Array.isArray(row.times) && row.times.some((item) => /^\d{14}$/.test(item.begin) && /^\d{14}$/.test(item.end) && item.begin <= journal.request.start && item.end >= journal.request.end));
|
|
19683
|
+
};
|
|
19684
|
+
for (const [name, request3, maxBytes] of [
|
|
19685
|
+
["market-foundation", { params: [{ data_type: "mr" }] }, 192 * 1024 ** 2],
|
|
19686
|
+
["daily-bars", journal.request, 160 * 1024 ** 2]
|
|
19687
|
+
]) {
|
|
19688
|
+
let task = journal.tasks.find((x2) => x2.name === name);
|
|
19689
|
+
let canResume = task?.state === "submitted";
|
|
19690
|
+
const ready = name === "market-foundation" ? foundationReady : dailyReady;
|
|
19691
|
+
const needsCheck = !task || task.state === "completed" || task.state === "failed";
|
|
19692
|
+
if (needsCheck && await ready())
|
|
19693
|
+
continue;
|
|
19694
|
+
if (needsCheck) {
|
|
19695
|
+
const inventory2 = await rpc("cloudlist", { ...request3, limit: 100 });
|
|
19696
|
+
const rows = inventory2.objects;
|
|
19697
|
+
const allowed = name === "market-foundation" ? /^quant\/libmr_data\// : new RegExp(`^hqdata/(?:his|rel)/${market}/dk1/`);
|
|
19698
|
+
if (inventory2.truncated || !Array.isArray(rows) || !rows.length || rows.length > 100 || rows.some((x2) => typeof x2.cloud_path !== "string" || !allowed.test(x2.cloud_path) || !Number.isSafeInteger(Number(x2.cloud_size)) || Number(x2.cloud_size) <= 0) || rows.reduce((sum2, x2) => sum2 + Number(x2.cloud_size), 0) > maxBytes) {
|
|
19699
|
+
throw new Error("Empty, unexpected or oversized official DCM inventory: " + name);
|
|
19700
|
+
}
|
|
19701
|
+
if (task)
|
|
19702
|
+
Object.assign(task, { state: "dispatching", id: void 0 });
|
|
19703
|
+
else {
|
|
19704
|
+
task = { name, state: "dispatching" };
|
|
19705
|
+
journal.tasks.push(task);
|
|
19706
|
+
}
|
|
19707
|
+
save2(task);
|
|
19708
|
+
const reply = await rpc("download", request3);
|
|
19709
|
+
if (typeof reply.uuid !== "string" || !/^[A-Za-z0-9-]{1,80}$/.test(reply.uuid)) {
|
|
19710
|
+
throw new Error("DCM did not return a valid task ID; inspect the original submission");
|
|
19711
|
+
}
|
|
19712
|
+
task.id = reply.uuid;
|
|
19713
|
+
task.state = "submitted";
|
|
19714
|
+
save2(task);
|
|
19715
|
+
}
|
|
19716
|
+
if (!task?.id || task.state !== "submitted")
|
|
19717
|
+
throw new Error("A prior download submission has unknown status; inspect the DCM journal before retrying");
|
|
19718
|
+
const deadline = Date.now() + 18e4;
|
|
19719
|
+
for (; ; ) {
|
|
19720
|
+
const q = await rpc("progress", { uuid: task.id });
|
|
19721
|
+
if (q.uuid !== task.id)
|
|
19722
|
+
throw new Error("DCM returned a different task identity");
|
|
19723
|
+
const terminal = q.terminal === true || q.terminal === 1;
|
|
19724
|
+
if (!terminal && [2, "TASK_STATUS_PAUSED"].includes(q.status)) {
|
|
19725
|
+
if (!canResume || Date.now() >= deadline)
|
|
19726
|
+
throw new Error("DCM task paused; rerun the same command to resume: " + task.id);
|
|
19727
|
+
canResume = false;
|
|
19728
|
+
const resumed = await rpc("taskcontrol", { uuid: task.id, action: "TASK_CONTROL_ACTION_RESUME" });
|
|
19729
|
+
if (resumed.task?.uuid !== task.id)
|
|
19730
|
+
throw new Error("DCM did not confirm the original resumed task: " + task.id);
|
|
19731
|
+
await pause(1e3);
|
|
19732
|
+
continue;
|
|
19733
|
+
}
|
|
19734
|
+
if (q.status === "TASK_STATUS_DONE" || q.status === 4) {
|
|
19735
|
+
if (Number(q.err_no ?? 0) !== 0 || q.terminal !== void 0 && !terminal)
|
|
19736
|
+
throw new Error("DCM returned an inconsistent completion result");
|
|
19737
|
+
task.state = "completed";
|
|
19738
|
+
save2(task);
|
|
19739
|
+
if (!await ready())
|
|
19740
|
+
throw new Error("DCM completed without the required files or cache coverage; confirm again to repair: " + name);
|
|
19741
|
+
break;
|
|
19742
|
+
}
|
|
19743
|
+
if (terminal || [3, 7, "TASK_STATUS_STOPPED", "TASK_STATUS_AUTH_ERROR"].includes(q.status)) {
|
|
19744
|
+
task.state = "failed";
|
|
19745
|
+
save2(task);
|
|
19746
|
+
throw new Error("DCM task ended unsuccessfully; see the Host log before confirming again: " + task.id);
|
|
19747
|
+
}
|
|
19748
|
+
if (![0, 1, "TASK_STATUS_PENDING", "TASK_STATUS_RUNNING"].includes(q.status)) {
|
|
19749
|
+
throw new Error("DCM task did not succeed; original ID retained: " + task.id);
|
|
19750
|
+
}
|
|
19751
|
+
if (Date.now() >= deadline)
|
|
19752
|
+
throw new Error("DCM task still running; rerun the same command to resume: " + task.id);
|
|
19753
|
+
await pause(1e3);
|
|
19754
|
+
}
|
|
19755
|
+
}
|
|
19756
|
+
}
|
|
19757
|
+
async function runLinuxClientLiteData(binding, config2, request3) {
|
|
19758
|
+
if (process.platform !== "linux" || process.arch !== "x64")
|
|
19759
|
+
throw new Error("Market data preparation requires Linux x64");
|
|
19760
|
+
const { root: root2, release } = binding.installation;
|
|
19761
|
+
if (binding.installation.kind !== "clientlite" || !release)
|
|
19762
|
+
throw new Error("Select a managed ClientLite workspace first");
|
|
19763
|
+
const receiptPath = path36.join(root2, "clientlite-npm-receipt.json");
|
|
19764
|
+
const receiptInfo = fs36.lstatSync(receiptPath);
|
|
19765
|
+
if (!receiptInfo.isFile() || receiptInfo.uid !== process.getuid?.() || receiptInfo.mode & 18 || receiptInfo.size > 65536) {
|
|
19766
|
+
throw new Error("Unsafe ClientLite installation receipt");
|
|
19767
|
+
}
|
|
19768
|
+
const receipt = JSON.parse(fs36.readFileSync(receiptPath, "utf8"));
|
|
19769
|
+
if (receipt.release?.distribution !== "public-npm" || receipt.release?.nativeBuildId !== "25956" || receipt.nativeIpcQualified !== true || receipt.releaseIdentity !== binding.installation.release) {
|
|
19770
|
+
throw new Error("Data preparation requires the managed official ClientLite 25956 release");
|
|
19771
|
+
}
|
|
19772
|
+
assertLinuxClientLiteResearchRuntime(root2, release);
|
|
19773
|
+
for (const relative13 of ["zlthost", "zlthost/moudles"]) {
|
|
19774
|
+
const file2 = path36.join(root2, relative13);
|
|
19775
|
+
const info2 = fs36.lstatSync(file2);
|
|
19776
|
+
if (!info2.isDirectory() || info2.uid !== process.getuid?.() || info2.mode & 18 || fs36.realpathSync(file2) !== file2) {
|
|
19777
|
+
throw new Error("Unsafe managed ClientLite data Host path: " + relative13);
|
|
19778
|
+
}
|
|
19779
|
+
}
|
|
19780
|
+
for (const [relative13, sha2562] of Object.entries(dataHostFiles)) {
|
|
19781
|
+
const file2 = path36.join(root2, relative13);
|
|
19782
|
+
const info2 = fs36.lstatSync(file2);
|
|
19783
|
+
if (!info2.isFile() || info2.uid !== process.getuid?.() || info2.mode & 18 || fs36.realpathSync(file2) !== file2 || clientLiteFileHash(file2) !== sha2562)
|
|
19784
|
+
throw new Error("Managed ClientLite data Host file differs from the official release: " + relative13);
|
|
19785
|
+
}
|
|
19786
|
+
const data = path36.join(root2, "Public/quantdata1");
|
|
19787
|
+
if (binding.workspace.dataPaths?.quantDataRoot !== data || fs36.realpathSync(data) !== data) {
|
|
19788
|
+
throw new Error("Data preparation requires the selected ClientLite data root");
|
|
19789
|
+
}
|
|
19790
|
+
const ca = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs/ca-bundle.crt"].find((file2) => fs36.statSync(file2, { throwIfNoEntry: false })?.isFile());
|
|
19791
|
+
if (!ca)
|
|
19792
|
+
throw new Error("Install your distribution's system CA certificates before preparing data");
|
|
19793
|
+
const state2 = path36.join(root2, "Temporary", "zlt-mcp-data");
|
|
19794
|
+
if (fs36.realpathSync(path36.dirname(state2)) !== path36.dirname(state2))
|
|
19795
|
+
throw new Error("Data preparation state parent is redirected");
|
|
19796
|
+
fs36.mkdirSync(state2, { mode: 448, recursive: true });
|
|
19797
|
+
const stateInfo = fs36.lstatSync(state2);
|
|
19798
|
+
if (!stateInfo.isDirectory() || stateInfo.uid !== process.getuid?.() || stateInfo.mode & 63 || fs36.realpathSync(state2) !== state2)
|
|
19799
|
+
throw new Error("Data preparation state directory is unsafe");
|
|
19800
|
+
const directory = fs36.mkdtempSync(path36.join(state2, "host-"));
|
|
19801
|
+
const dcm = path36.join(directory, "dcm.json");
|
|
19802
|
+
fs36.writeFileSync(dcm, JSON.stringify({
|
|
19803
|
+
download_home: data,
|
|
19804
|
+
local_db: "dcm.db3",
|
|
19805
|
+
cloud_base_url: officialMr,
|
|
19806
|
+
ssl_verify_peer: true,
|
|
19807
|
+
ssl_trusted_certificate: ca,
|
|
19808
|
+
task: { option: false, cron: "0 0 * * 1-7", data_categories: ["mr"] },
|
|
19809
|
+
background_scan_interval_ms: 0,
|
|
19810
|
+
retry_count: 3,
|
|
19811
|
+
data_categories: [
|
|
19812
|
+
{ name: "mr", type: "market_rule", cloud_prefix: "quant/libmr_data/", cloud_base_url: officialMr, local_folder: "libmr_data/", data_types: ["mr"] },
|
|
19813
|
+
{
|
|
19814
|
+
name: "hq",
|
|
19815
|
+
type: "market_series",
|
|
19816
|
+
cloud_prefix: "hqdata/",
|
|
19817
|
+
cloud_base_url: officialHq,
|
|
19818
|
+
local_folder: "hqdata/",
|
|
19819
|
+
data_types: ["dk", "mk", "tk"],
|
|
19820
|
+
static_data_types: ["sd"]
|
|
19821
|
+
}
|
|
19822
|
+
]
|
|
19823
|
+
}), { flag: "wx", mode: 384 });
|
|
19824
|
+
const host = {
|
|
19825
|
+
pipPath: "/tmp/",
|
|
19826
|
+
pipName: "ZLTDcm" + (0, import_node_crypto19.randomBytes)(8).toString("hex"),
|
|
19827
|
+
gRpcport: "",
|
|
19828
|
+
workThreadNum: 2,
|
|
19829
|
+
logLevel: 1,
|
|
19830
|
+
runServer: "zltdcm",
|
|
19831
|
+
residentMode: 1,
|
|
19832
|
+
serviceMoudles: [{ name: "zltdcm", moudle: "dcm.so", mpcmoudle: true, params: "", paramsPath: dcm }]
|
|
19833
|
+
};
|
|
19834
|
+
return withLinuxClientLiteDataHost(root2, config2, host, directory, async (socket, signal) => {
|
|
19835
|
+
const store = new SharedWorkspaceStore();
|
|
19836
|
+
store.assertGeneration(binding);
|
|
19837
|
+
const journal = { schemaVersion: 1, request: request3, release: receipt.releaseIdentity, tasks: [] };
|
|
19838
|
+
for (const name of ["market-foundation", "daily-bars"]) {
|
|
19839
|
+
const file2 = path36.join(state2, linuxDataJournalName(name, request3));
|
|
19840
|
+
const info2 = fs36.lstatSync(file2, { throwIfNoEntry: false });
|
|
19841
|
+
if (!info2)
|
|
19842
|
+
continue;
|
|
19843
|
+
if (!info2.isFile() || info2.uid !== process.getuid?.() || info2.mode & 63 || info2.size > 2048)
|
|
19844
|
+
throw new Error("Unsafe DCM journal");
|
|
19845
|
+
const entry = JSON.parse(fs36.readFileSync(file2, "utf8"));
|
|
19846
|
+
const expected = name === "daily-bars" ? request3 : null;
|
|
19847
|
+
if (entry.schemaVersion !== 1 || entry.release !== journal.release || JSON.stringify(entry.request) !== JSON.stringify(expected) || entry.task?.name !== name || !["dispatching", "submitted", "completed", "failed"].includes(entry.task.state) || entry.task.state !== "dispatching" && !/^[A-Za-z0-9-]{1,80}$/.test(entry.task.id ?? "")) {
|
|
19848
|
+
throw new Error("Invalid DCM journal");
|
|
19849
|
+
}
|
|
19850
|
+
journal.tasks.push(entry.task);
|
|
19851
|
+
}
|
|
19852
|
+
const save2 = (task) => {
|
|
19853
|
+
const file2 = path36.join(state2, linuxDataJournalName(task.name, request3));
|
|
19854
|
+
const next = path36.join(directory, "journal-next");
|
|
19855
|
+
const fd = fs36.openSync(next, "wx", 384);
|
|
19856
|
+
try {
|
|
19857
|
+
fs36.writeFileSync(fd, JSON.stringify({
|
|
19858
|
+
schemaVersion: 1,
|
|
19859
|
+
release: journal.release,
|
|
19860
|
+
request: task.name === "daily-bars" ? request3 : null,
|
|
19861
|
+
task
|
|
19862
|
+
}));
|
|
19863
|
+
fs36.fsyncSync(fd);
|
|
19864
|
+
} finally {
|
|
19865
|
+
fs36.closeSync(fd);
|
|
19866
|
+
}
|
|
19867
|
+
fs36.renameSync(next, file2);
|
|
19868
|
+
const parent = fs36.openSync(state2, "r");
|
|
19869
|
+
try {
|
|
19870
|
+
fs36.fsyncSync(parent);
|
|
19871
|
+
} finally {
|
|
19872
|
+
fs36.closeSync(parent);
|
|
19873
|
+
}
|
|
19874
|
+
};
|
|
19875
|
+
const client2 = new ZltafIpcClient();
|
|
19876
|
+
try {
|
|
19877
|
+
await client2.connect(socket, 5e3, { reuseMainSocket: true });
|
|
19878
|
+
await prepareDailyData(async (method, args) => {
|
|
19879
|
+
const deadline = Date.now() + 3e4;
|
|
19880
|
+
for (; ; ) {
|
|
19881
|
+
signal.throwIfAborted();
|
|
19882
|
+
const packet = await client2.invoke("/zltdcm/" + method, {}, JSON.stringify(args), 15e3);
|
|
19883
|
+
const header = packet.headers.get("X-Err");
|
|
19884
|
+
if (method !== "diskspace" || !dcmReadIsInitializing(packet.statusCode, header)) {
|
|
19885
|
+
return dcmResponse(packet.statusCode, header, packet.content);
|
|
19886
|
+
}
|
|
19887
|
+
if (Date.now() >= deadline)
|
|
19888
|
+
throw new Error("ClientLite DCM storage is still initializing");
|
|
19889
|
+
await delay3(1e3);
|
|
19890
|
+
}
|
|
19891
|
+
}, data, journal, save2);
|
|
19892
|
+
signal.throwIfAborted();
|
|
19893
|
+
store.assertGeneration(binding);
|
|
19894
|
+
return {
|
|
19895
|
+
status: "prepared",
|
|
19896
|
+
workspaceId: binding.workspace.workspaceId,
|
|
19897
|
+
installationId: binding.installation.installationId,
|
|
19898
|
+
request: request3,
|
|
19899
|
+
tasks: journal.tasks
|
|
19900
|
+
};
|
|
19901
|
+
} finally {
|
|
19902
|
+
await client2.disconnect();
|
|
19903
|
+
}
|
|
19904
|
+
});
|
|
19905
|
+
}
|
|
19906
|
+
var fs36, path36, import_node_crypto19, requiredMarketFiles, officialMr, officialHq, dataHostFiles, delay3;
|
|
19907
|
+
var init_linux_clientlite_data = __esm({
|
|
19908
|
+
"../zlt-runtime-core/dist/linux-clientlite-data.js"() {
|
|
19909
|
+
"use strict";
|
|
19910
|
+
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
19911
|
+
init_define_CLIENTLITE_NPM_RELEASE();
|
|
19912
|
+
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
19913
|
+
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
19914
|
+
fs36 = __toESM(require("node:fs"), 1);
|
|
19915
|
+
path36 = __toESM(require("node:path"), 1);
|
|
19916
|
+
import_node_crypto19 = require("node:crypto");
|
|
19917
|
+
init_clientlite_macos_archive();
|
|
19918
|
+
init_shared_workspaces();
|
|
19919
|
+
init_linux_clientlite_research_trust();
|
|
19920
|
+
init_linux_clientlite_runtime();
|
|
19921
|
+
init_zltaf_ipc();
|
|
19922
|
+
requiredMarketFiles = ["libmr_data/xml/SysMarkets.xml", "libmr_data/db/fin_base.db3", "libmr_data/db/status_hist.db"];
|
|
19923
|
+
officialMr = "https://zlt-data-house.oss-cn-wuhan-lr.aliyuncs.com";
|
|
19924
|
+
officialHq = "https://zlt-data-center.oss-cn-wuhan-lr.aliyuncs.com";
|
|
19925
|
+
dataHostFiles = {
|
|
19926
|
+
"zlthost/client-lite-linux-host.sh": "9428006c3b50e81f242b844a8c1aba1c4a5744eb403e01f47f1230a78efd6d96",
|
|
19927
|
+
"zlthost/ZLTHost": "c894e348b3c2d1f58d2661af209576873c1eeceb158062b1a6e20929dc9f0413",
|
|
19928
|
+
"zlthost/moudles/libdcm.so": "8989d8b05858c306e7e156ab7fc74a555ca0504d0b4b2676aeca40f5d6614d56"
|
|
19929
|
+
};
|
|
19930
|
+
delay3 = (ms) => new Promise((resolve29) => setTimeout(resolve29, ms));
|
|
19931
|
+
}
|
|
19932
|
+
});
|
|
19933
|
+
|
|
19482
19934
|
// ../zlt-runtime-core/dist/index.js
|
|
19483
19935
|
var init_dist = __esm({
|
|
19484
19936
|
"../zlt-runtime-core/dist/index.js"() {
|
|
@@ -19519,6 +19971,7 @@ var init_dist = __esm({
|
|
|
19519
19971
|
init_clientlite_uninstall();
|
|
19520
19972
|
init_macos_process_inspection();
|
|
19521
19973
|
init_linux_clientlite_runtime();
|
|
19974
|
+
init_linux_clientlite_data();
|
|
19522
19975
|
init_linux_clientlite_research_trust();
|
|
19523
19976
|
}
|
|
19524
19977
|
});
|
|
@@ -22804,8 +23257,8 @@ var require_utils = __commonJS({
|
|
|
22804
23257
|
}
|
|
22805
23258
|
return ind;
|
|
22806
23259
|
}
|
|
22807
|
-
function removeDotSegments(
|
|
22808
|
-
let input2 =
|
|
23260
|
+
function removeDotSegments(path64) {
|
|
23261
|
+
let input2 = path64;
|
|
22809
23262
|
const output = [];
|
|
22810
23263
|
let nextSlash = -1;
|
|
22811
23264
|
let len = 0;
|
|
@@ -23008,8 +23461,8 @@ var require_schemes = __commonJS({
|
|
|
23008
23461
|
wsComponent.secure = void 0;
|
|
23009
23462
|
}
|
|
23010
23463
|
if (wsComponent.resourceName) {
|
|
23011
|
-
const [
|
|
23012
|
-
wsComponent.path =
|
|
23464
|
+
const [path64, query2] = wsComponent.resourceName.split("?");
|
|
23465
|
+
wsComponent.path = path64 && path64 !== "/" ? path64 : void 0;
|
|
23013
23466
|
wsComponent.query = query2;
|
|
23014
23467
|
wsComponent.resourceName = void 0;
|
|
23015
23468
|
}
|
|
@@ -26555,12 +27008,12 @@ var require_dist = __commonJS({
|
|
|
26555
27008
|
throw new Error(`Unknown format "${name}"`);
|
|
26556
27009
|
return f;
|
|
26557
27010
|
};
|
|
26558
|
-
function addFormats(ajv, list,
|
|
27011
|
+
function addFormats(ajv, list, fs61, exportName) {
|
|
26559
27012
|
var _a;
|
|
26560
27013
|
var _b;
|
|
26561
27014
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
26562
27015
|
for (const f of list)
|
|
26563
|
-
ajv.addFormat(f,
|
|
27016
|
+
ajv.addFormat(f, fs61[f]);
|
|
26564
27017
|
}
|
|
26565
27018
|
module2.exports = exports2 = formatsPlugin;
|
|
26566
27019
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -26577,8 +27030,8 @@ var require_windows = __commonJS({
|
|
|
26577
27030
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26578
27031
|
module2.exports = isexe;
|
|
26579
27032
|
isexe.sync = sync;
|
|
26580
|
-
var
|
|
26581
|
-
function checkPathExt(
|
|
27033
|
+
var fs61 = require("fs");
|
|
27034
|
+
function checkPathExt(path64, options) {
|
|
26582
27035
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
26583
27036
|
if (!pathext) {
|
|
26584
27037
|
return true;
|
|
@@ -26589,25 +27042,25 @@ var require_windows = __commonJS({
|
|
|
26589
27042
|
}
|
|
26590
27043
|
for (var i2 = 0; i2 < pathext.length; i2++) {
|
|
26591
27044
|
var p = pathext[i2].toLowerCase();
|
|
26592
|
-
if (p &&
|
|
27045
|
+
if (p && path64.substr(-p.length).toLowerCase() === p) {
|
|
26593
27046
|
return true;
|
|
26594
27047
|
}
|
|
26595
27048
|
}
|
|
26596
27049
|
return false;
|
|
26597
27050
|
}
|
|
26598
|
-
function checkStat(stat2,
|
|
27051
|
+
function checkStat(stat2, path64, options) {
|
|
26599
27052
|
if (!stat2.isSymbolicLink() && !stat2.isFile()) {
|
|
26600
27053
|
return false;
|
|
26601
27054
|
}
|
|
26602
|
-
return checkPathExt(
|
|
27055
|
+
return checkPathExt(path64, options);
|
|
26603
27056
|
}
|
|
26604
|
-
function isexe(
|
|
26605
|
-
|
|
26606
|
-
cb(er, er ? false : checkStat(stat2,
|
|
27057
|
+
function isexe(path64, options, cb) {
|
|
27058
|
+
fs61.stat(path64, function(er, stat2) {
|
|
27059
|
+
cb(er, er ? false : checkStat(stat2, path64, options));
|
|
26607
27060
|
});
|
|
26608
27061
|
}
|
|
26609
|
-
function sync(
|
|
26610
|
-
return checkStat(
|
|
27062
|
+
function sync(path64, options) {
|
|
27063
|
+
return checkStat(fs61.statSync(path64), path64, options);
|
|
26611
27064
|
}
|
|
26612
27065
|
}
|
|
26613
27066
|
});
|
|
@@ -26621,14 +27074,14 @@ var require_mode = __commonJS({
|
|
|
26621
27074
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26622
27075
|
module2.exports = isexe;
|
|
26623
27076
|
isexe.sync = sync;
|
|
26624
|
-
var
|
|
26625
|
-
function isexe(
|
|
26626
|
-
|
|
27077
|
+
var fs61 = require("fs");
|
|
27078
|
+
function isexe(path64, options, cb) {
|
|
27079
|
+
fs61.stat(path64, function(er, stat2) {
|
|
26627
27080
|
cb(er, er ? false : checkStat(stat2, options));
|
|
26628
27081
|
});
|
|
26629
27082
|
}
|
|
26630
|
-
function sync(
|
|
26631
|
-
return checkStat(
|
|
27083
|
+
function sync(path64, options) {
|
|
27084
|
+
return checkStat(fs61.statSync(path64), options);
|
|
26632
27085
|
}
|
|
26633
27086
|
function checkStat(stat2, options) {
|
|
26634
27087
|
return stat2.isFile() && checkMode(stat2, options);
|
|
@@ -26656,7 +27109,7 @@ var require_isexe = __commonJS({
|
|
|
26656
27109
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
26657
27110
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
26658
27111
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26659
|
-
var
|
|
27112
|
+
var fs61 = require("fs");
|
|
26660
27113
|
var core;
|
|
26661
27114
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
26662
27115
|
core = require_windows();
|
|
@@ -26665,7 +27118,7 @@ var require_isexe = __commonJS({
|
|
|
26665
27118
|
}
|
|
26666
27119
|
module2.exports = isexe;
|
|
26667
27120
|
isexe.sync = sync;
|
|
26668
|
-
function isexe(
|
|
27121
|
+
function isexe(path64, options, cb) {
|
|
26669
27122
|
if (typeof options === "function") {
|
|
26670
27123
|
cb = options;
|
|
26671
27124
|
options = {};
|
|
@@ -26675,7 +27128,7 @@ var require_isexe = __commonJS({
|
|
|
26675
27128
|
throw new TypeError("callback not provided");
|
|
26676
27129
|
}
|
|
26677
27130
|
return new Promise(function(resolve29, reject) {
|
|
26678
|
-
isexe(
|
|
27131
|
+
isexe(path64, options || {}, function(er, is) {
|
|
26679
27132
|
if (er) {
|
|
26680
27133
|
reject(er);
|
|
26681
27134
|
} else {
|
|
@@ -26684,7 +27137,7 @@ var require_isexe = __commonJS({
|
|
|
26684
27137
|
});
|
|
26685
27138
|
});
|
|
26686
27139
|
}
|
|
26687
|
-
core(
|
|
27140
|
+
core(path64, options || {}, function(er, is) {
|
|
26688
27141
|
if (er) {
|
|
26689
27142
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
26690
27143
|
er = null;
|
|
@@ -26694,9 +27147,9 @@ var require_isexe = __commonJS({
|
|
|
26694
27147
|
cb(er, is);
|
|
26695
27148
|
});
|
|
26696
27149
|
}
|
|
26697
|
-
function sync(
|
|
27150
|
+
function sync(path64, options) {
|
|
26698
27151
|
try {
|
|
26699
|
-
return core.sync(
|
|
27152
|
+
return core.sync(path64, options || {});
|
|
26700
27153
|
} catch (er) {
|
|
26701
27154
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
26702
27155
|
return false;
|
|
@@ -26716,7 +27169,7 @@ var require_which = __commonJS({
|
|
|
26716
27169
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
26717
27170
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26718
27171
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
26719
|
-
var
|
|
27172
|
+
var path64 = require("path");
|
|
26720
27173
|
var COLON = isWindows ? ";" : ":";
|
|
26721
27174
|
var isexe = require_isexe();
|
|
26722
27175
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -26754,7 +27207,7 @@ var require_which = __commonJS({
|
|
|
26754
27207
|
return opt.all && found.length ? resolve29(found) : reject(getNotFoundError(cmd));
|
|
26755
27208
|
const ppRaw = pathEnv[i2];
|
|
26756
27209
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
26757
|
-
const pCmd =
|
|
27210
|
+
const pCmd = path64.join(pathPart, cmd);
|
|
26758
27211
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
26759
27212
|
resolve29(subStep(p, i2, 0));
|
|
26760
27213
|
});
|
|
@@ -26781,7 +27234,7 @@ var require_which = __commonJS({
|
|
|
26781
27234
|
for (let i2 = 0; i2 < pathEnv.length; i2++) {
|
|
26782
27235
|
const ppRaw = pathEnv[i2];
|
|
26783
27236
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
26784
|
-
const pCmd =
|
|
27237
|
+
const pCmd = path64.join(pathPart, cmd);
|
|
26785
27238
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
26786
27239
|
for (let j = 0; j < pathExt.length; j++) {
|
|
26787
27240
|
const cur = p + pathExt[j];
|
|
@@ -26837,7 +27290,7 @@ var require_resolveCommand = __commonJS({
|
|
|
26837
27290
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
26838
27291
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
26839
27292
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26840
|
-
var
|
|
27293
|
+
var path64 = require("path");
|
|
26841
27294
|
var which = require_which();
|
|
26842
27295
|
var getPathKey = require_path_key();
|
|
26843
27296
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -26855,7 +27308,7 @@ var require_resolveCommand = __commonJS({
|
|
|
26855
27308
|
try {
|
|
26856
27309
|
resolved = which.sync(parsed.command, {
|
|
26857
27310
|
path: env[getPathKey({ env })],
|
|
26858
|
-
pathExt: withoutPathExt ?
|
|
27311
|
+
pathExt: withoutPathExt ? path64.delimiter : void 0
|
|
26859
27312
|
});
|
|
26860
27313
|
} catch (e) {
|
|
26861
27314
|
} finally {
|
|
@@ -26864,7 +27317,7 @@ var require_resolveCommand = __commonJS({
|
|
|
26864
27317
|
}
|
|
26865
27318
|
}
|
|
26866
27319
|
if (resolved) {
|
|
26867
|
-
resolved =
|
|
27320
|
+
resolved = path64.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
26868
27321
|
}
|
|
26869
27322
|
return resolved;
|
|
26870
27323
|
}
|
|
@@ -26930,8 +27383,8 @@ var require_shebang_command = __commonJS({
|
|
|
26930
27383
|
if (!match) {
|
|
26931
27384
|
return null;
|
|
26932
27385
|
}
|
|
26933
|
-
const [
|
|
26934
|
-
const binary =
|
|
27386
|
+
const [path64, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
27387
|
+
const binary = path64.split("/").pop();
|
|
26935
27388
|
if (binary === "env") {
|
|
26936
27389
|
return argument;
|
|
26937
27390
|
}
|
|
@@ -26948,16 +27401,16 @@ var require_readShebang = __commonJS({
|
|
|
26948
27401
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
26949
27402
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
26950
27403
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26951
|
-
var
|
|
27404
|
+
var fs61 = require("fs");
|
|
26952
27405
|
var shebangCommand = require_shebang_command();
|
|
26953
27406
|
function readShebang(command) {
|
|
26954
27407
|
const size = 150;
|
|
26955
27408
|
const buffer = Buffer.alloc(size);
|
|
26956
27409
|
let fd;
|
|
26957
27410
|
try {
|
|
26958
|
-
fd =
|
|
26959
|
-
|
|
26960
|
-
|
|
27411
|
+
fd = fs61.openSync(command, "r");
|
|
27412
|
+
fs61.readSync(fd, buffer, 0, size, 0);
|
|
27413
|
+
fs61.closeSync(fd);
|
|
26961
27414
|
} catch (e) {
|
|
26962
27415
|
}
|
|
26963
27416
|
return shebangCommand(buffer.toString());
|
|
@@ -26974,7 +27427,7 @@ var require_parse = __commonJS({
|
|
|
26974
27427
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
26975
27428
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
26976
27429
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
26977
|
-
var
|
|
27430
|
+
var path64 = require("path");
|
|
26978
27431
|
var resolveCommand = require_resolveCommand();
|
|
26979
27432
|
var escape2 = require_escape();
|
|
26980
27433
|
var readShebang = require_readShebang();
|
|
@@ -26999,7 +27452,7 @@ var require_parse = __commonJS({
|
|
|
26999
27452
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
27000
27453
|
if (parsed.options.forceShell || needsShell) {
|
|
27001
27454
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
27002
|
-
parsed.command =
|
|
27455
|
+
parsed.command = path64.normalize(parsed.command);
|
|
27003
27456
|
parsed.command = escape2.command(parsed.command);
|
|
27004
27457
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
27005
27458
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -27124,20 +27577,20 @@ __export(auth_login_exports, {
|
|
|
27124
27577
|
waitWechatLogin: () => waitWechatLogin
|
|
27125
27578
|
});
|
|
27126
27579
|
function dir() {
|
|
27127
|
-
const d2 =
|
|
27128
|
-
|
|
27129
|
-
const info2 =
|
|
27580
|
+
const d2 = path56.join(resolveZltQuantHome(), "auth-sessions");
|
|
27581
|
+
fs54.mkdirSync(d2, { recursive: true, mode: 448 });
|
|
27582
|
+
const info2 = fs54.lstatSync(d2);
|
|
27130
27583
|
if (!info2.isDirectory() || info2.isSymbolicLink())
|
|
27131
27584
|
throw new Error("Invalid login session directory");
|
|
27132
27585
|
try {
|
|
27133
|
-
|
|
27586
|
+
fs54.chmodSync(d2, 448);
|
|
27134
27587
|
} catch {
|
|
27135
27588
|
}
|
|
27136
27589
|
return d2;
|
|
27137
27590
|
}
|
|
27138
27591
|
function file(id) {
|
|
27139
27592
|
if (!/^[a-f0-9]{32}$/.test(id)) throw new Error("Unknown login session");
|
|
27140
|
-
return
|
|
27593
|
+
return path56.join(dir(), `${id}.json`);
|
|
27141
27594
|
}
|
|
27142
27595
|
function safeMessage() {
|
|
27143
27596
|
return "\u5FAE\u4FE1\u767B\u5F55\u6682\u672A\u5B8C\u6210\uFF0C\u8BF7\u626B\u63CF\u4E8C\u7EF4\u7801\u5E76\u91CD\u8BD5";
|
|
@@ -27154,9 +27607,9 @@ function hasExplicitCredentials() {
|
|
|
27154
27607
|
function readSession(id) {
|
|
27155
27608
|
try {
|
|
27156
27609
|
const sessionFile = file(id);
|
|
27157
|
-
if (!
|
|
27610
|
+
if (!fs54.lstatSync(sessionFile).isFile() || fs54.lstatSync(sessionFile).isSymbolicLink())
|
|
27158
27611
|
throw new Error("invalid");
|
|
27159
|
-
const s2 = JSON.parse(
|
|
27612
|
+
const s2 = JSON.parse(fs54.readFileSync(sessionFile, "utf8"));
|
|
27160
27613
|
if (!s2.scene || !s2.qrUrl || s2.id !== id || !Number.isFinite(Date.parse(s2.expiresAt)))
|
|
27161
27614
|
throw new Error("expired");
|
|
27162
27615
|
return s2;
|
|
@@ -27166,17 +27619,17 @@ function readSession(id) {
|
|
|
27166
27619
|
}
|
|
27167
27620
|
function writeSession(s2) {
|
|
27168
27621
|
const p = file(s2.id), t = `${p}.${process.pid}.${Date.now()}.tmp`;
|
|
27169
|
-
|
|
27622
|
+
fs54.writeFileSync(t, JSON.stringify(s2), { mode: 384 });
|
|
27170
27623
|
try {
|
|
27171
|
-
|
|
27624
|
+
fs54.chmodSync(t, 384);
|
|
27172
27625
|
} catch {
|
|
27173
27626
|
}
|
|
27174
|
-
|
|
27627
|
+
fs54.renameSync(t, p);
|
|
27175
27628
|
}
|
|
27176
27629
|
function lock2(id) {
|
|
27177
27630
|
const p = `${file(id)}.lock`;
|
|
27178
27631
|
try {
|
|
27179
|
-
|
|
27632
|
+
fs54.mkdirSync(p, { mode: 448 });
|
|
27180
27633
|
} catch {
|
|
27181
27634
|
throw new Error("Login is already being completed");
|
|
27182
27635
|
}
|
|
@@ -27184,7 +27637,7 @@ function lock2(id) {
|
|
|
27184
27637
|
}
|
|
27185
27638
|
function unlock(p) {
|
|
27186
27639
|
try {
|
|
27187
|
-
|
|
27640
|
+
fs54.rmSync(p, { recursive: true, force: true });
|
|
27188
27641
|
} catch {
|
|
27189
27642
|
}
|
|
27190
27643
|
}
|
|
@@ -27313,7 +27766,7 @@ async function waitWechatLogin(sessionId, options = {}) {
|
|
|
27313
27766
|
}
|
|
27314
27767
|
if (Date.now() >= Date.parse(s2.expiresAt)) {
|
|
27315
27768
|
try {
|
|
27316
|
-
|
|
27769
|
+
fs54.unlinkSync(file(sessionId));
|
|
27317
27770
|
} catch {
|
|
27318
27771
|
}
|
|
27319
27772
|
unlock(lockPath);
|
|
@@ -27420,14 +27873,14 @@ async function waitWechatLogin(sessionId, options = {}) {
|
|
|
27420
27873
|
});
|
|
27421
27874
|
if (terminal) {
|
|
27422
27875
|
try {
|
|
27423
|
-
|
|
27876
|
+
fs54.rmSync(file(sessionId), { force: true });
|
|
27424
27877
|
} catch {
|
|
27425
27878
|
}
|
|
27426
27879
|
}
|
|
27427
27880
|
unlock(lockPath);
|
|
27428
27881
|
}
|
|
27429
27882
|
}
|
|
27430
|
-
var
|
|
27883
|
+
var fs54, path56, crypto2, AUTH_BASE, GATEWAY_BASE, SESSION_TTL, WAIT_MS;
|
|
27431
27884
|
var init_auth_login = __esm({
|
|
27432
27885
|
"src/auth-login.ts"() {
|
|
27433
27886
|
"use strict";
|
|
@@ -27435,8 +27888,8 @@ var init_auth_login = __esm({
|
|
|
27435
27888
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
27436
27889
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
27437
27890
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
27438
|
-
|
|
27439
|
-
|
|
27891
|
+
fs54 = __toESM(require("node:fs"), 1);
|
|
27892
|
+
path56 = __toESM(require("node:path"), 1);
|
|
27440
27893
|
crypto2 = __toESM(require("node:crypto"), 1);
|
|
27441
27894
|
init_dist();
|
|
27442
27895
|
AUTH_BASE = "https://auth.zltquant.com/zltAccCenter/api";
|
|
@@ -28472,8 +28925,8 @@ init_define_CLIENTLITE_NPM_RELEASE();
|
|
|
28472
28925
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
28473
28926
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
28474
28927
|
var makeIssue = (params) => {
|
|
28475
|
-
const { data, path:
|
|
28476
|
-
const fullPath = [...
|
|
28928
|
+
const { data, path: path64, errorMaps, issueData } = params;
|
|
28929
|
+
const fullPath = [...path64, ...issueData.path || []];
|
|
28477
28930
|
const fullIssue = {
|
|
28478
28931
|
...issueData,
|
|
28479
28932
|
path: fullPath
|
|
@@ -28599,11 +29052,11 @@ var errorUtil;
|
|
|
28599
29052
|
|
|
28600
29053
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
28601
29054
|
var ParseInputLazyPath = class {
|
|
28602
|
-
constructor(parent, value,
|
|
29055
|
+
constructor(parent, value, path64, key2) {
|
|
28603
29056
|
this._cachedPath = [];
|
|
28604
29057
|
this.parent = parent;
|
|
28605
29058
|
this.data = value;
|
|
28606
|
-
this._path =
|
|
29059
|
+
this._path = path64;
|
|
28607
29060
|
this._key = key2;
|
|
28608
29061
|
}
|
|
28609
29062
|
get path() {
|
|
@@ -32231,28 +32684,28 @@ var UNSUPPORTED_SCHEMA_KEYWORDS = [
|
|
|
32231
32684
|
"propertyNames",
|
|
32232
32685
|
"unevaluatedProperties"
|
|
32233
32686
|
];
|
|
32234
|
-
function unsupportedSchemaConstraint(schemaValue,
|
|
32687
|
+
function unsupportedSchemaConstraint(schemaValue, path64 = "inputSchema") {
|
|
32235
32688
|
const schema2 = record2(schemaValue);
|
|
32236
|
-
if (!schema2) return
|
|
32689
|
+
if (!schema2) return path64;
|
|
32237
32690
|
for (const keyword of UNSUPPORTED_SCHEMA_KEYWORDS) {
|
|
32238
|
-
if (Object.prototype.hasOwnProperty.call(schema2, keyword)) return `${
|
|
32691
|
+
if (Object.prototype.hasOwnProperty.call(schema2, keyword)) return `${path64}.${keyword}`;
|
|
32239
32692
|
}
|
|
32240
32693
|
const properties2 = record2(schema2.properties);
|
|
32241
32694
|
if (properties2) {
|
|
32242
32695
|
for (const [name, property2] of Object.entries(properties2)) {
|
|
32243
|
-
const unsupported = unsupportedSchemaConstraint(property2, `${
|
|
32696
|
+
const unsupported = unsupportedSchemaConstraint(property2, `${path64}.properties.${name}`);
|
|
32244
32697
|
if (unsupported) return unsupported;
|
|
32245
32698
|
}
|
|
32246
32699
|
}
|
|
32247
32700
|
if (schema2.items !== void 0) {
|
|
32248
|
-
const unsupported = unsupportedSchemaConstraint(schema2.items, `${
|
|
32701
|
+
const unsupported = unsupportedSchemaConstraint(schema2.items, `${path64}.items`);
|
|
32249
32702
|
if (unsupported) return unsupported;
|
|
32250
32703
|
}
|
|
32251
32704
|
return void 0;
|
|
32252
32705
|
}
|
|
32253
|
-
function explicitValue(schemaValue,
|
|
32706
|
+
function explicitValue(schemaValue, path64) {
|
|
32254
32707
|
const schema2 = record2(schemaValue);
|
|
32255
|
-
if (!schema2) return { available: false, missing: [
|
|
32708
|
+
if (!schema2) return { available: false, missing: [path64] };
|
|
32256
32709
|
if (Object.prototype.hasOwnProperty.call(schema2, "example")) {
|
|
32257
32710
|
return { available: true, value: cloneValue(schema2.example), missing: [] };
|
|
32258
32711
|
}
|
|
@@ -32274,13 +32727,13 @@ function explicitValue(schemaValue, path63) {
|
|
|
32274
32727
|
const value = {};
|
|
32275
32728
|
const missing2 = [];
|
|
32276
32729
|
for (const name of required2) {
|
|
32277
|
-
const child = explicitValue(properties2[name],
|
|
32730
|
+
const child = explicitValue(properties2[name], path64 ? `${path64}.${name}` : name);
|
|
32278
32731
|
if (child.available) value[name] = child.value;
|
|
32279
32732
|
missing2.push(...child.missing);
|
|
32280
32733
|
}
|
|
32281
32734
|
return { available: missing2.length === 0, value, missing: missing2 };
|
|
32282
32735
|
}
|
|
32283
|
-
return { available: false, missing: [
|
|
32736
|
+
return { available: false, missing: [path64] };
|
|
32284
32737
|
}
|
|
32285
32738
|
function buildArgumentExample(tool) {
|
|
32286
32739
|
const schema2 = record2(tool.inputSchema);
|
|
@@ -32723,7 +33176,7 @@ init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
|
32723
33176
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
32724
33177
|
var import_node_child_process16 = require("node:child_process");
|
|
32725
33178
|
var import_node_fs3 = require("node:fs");
|
|
32726
|
-
var
|
|
33179
|
+
var path37 = __toESM(require("node:path"), 1);
|
|
32727
33180
|
init_dist();
|
|
32728
33181
|
var OUTPUT_PREFIX = "ZLT_RESEARCH_PRICES:";
|
|
32729
33182
|
var MAX_SYMBOLS = 20;
|
|
@@ -32827,6 +33280,37 @@ function readResearchPricesOutput(stdout, request3) {
|
|
|
32827
33280
|
}
|
|
32828
33281
|
return rows.sort((a2, b2) => a2.symbol.localeCompare(b2.symbol) || a2.date.localeCompare(b2.date));
|
|
32829
33282
|
}
|
|
33283
|
+
async function resolveResearchRuntime(config2) {
|
|
33284
|
+
const { workRoot } = await resolveRuntimeRoot(config2);
|
|
33285
|
+
if (!workRoot) throw new Error("Select an installed ClientLite research workspace first.");
|
|
33286
|
+
const root2 = (0, import_node_fs3.realpathSync)(workRoot);
|
|
33287
|
+
if (!inspectLinuxClientLiteBacktest(root2).complete) throw new Error(NOTICE);
|
|
33288
|
+
const store = new SharedWorkspaceStore({ validateRoot: (candidate) => (0, import_node_fs3.realpathSync)(candidate) === root2 });
|
|
33289
|
+
const binding = store.resolve({ root: root2 });
|
|
33290
|
+
if (!binding || binding.installation.kind !== "clientlite") {
|
|
33291
|
+
throw new Error("Select a registered ClientLite research workspace first.");
|
|
33292
|
+
}
|
|
33293
|
+
assertLinuxClientLiteResearchRuntime(root2, binding.installation.release);
|
|
33294
|
+
return { root: root2, store, binding };
|
|
33295
|
+
}
|
|
33296
|
+
async function checkResearchRuntime(config2) {
|
|
33297
|
+
if (!isLinuxClientLiteCandidate()) {
|
|
33298
|
+
return { status: "blocked", reason: "unsupported-platform", message: "This research command requires Linux x64 ClientLite." };
|
|
33299
|
+
}
|
|
33300
|
+
try {
|
|
33301
|
+
await resolveResearchRuntime(config2);
|
|
33302
|
+
return { status: "passed" };
|
|
33303
|
+
} catch (error2) {
|
|
33304
|
+
if (error2 instanceof ResearchRuntimeTrustError) {
|
|
33305
|
+
return { status: "blocked", reason: error2.reason, message: error2.message };
|
|
33306
|
+
}
|
|
33307
|
+
return {
|
|
33308
|
+
status: "blocked",
|
|
33309
|
+
reason: "workspace-not-ready",
|
|
33310
|
+
message: "Check that a qualified ClientLite installation is selected and visible in this environment."
|
|
33311
|
+
};
|
|
33312
|
+
}
|
|
33313
|
+
}
|
|
32830
33314
|
async function runResearchPrices(options, config2) {
|
|
32831
33315
|
const request3 = parseResearchPriceRequest(options);
|
|
32832
33316
|
if (!isLinuxClientLiteCandidate()) throw new Error("This research command requires Linux x64 ClientLite.");
|
|
@@ -32840,19 +33324,10 @@ async function runResearchPrices(options, config2) {
|
|
|
32840
33324
|
if (credentials.apiBase.replace(/\/+$/, "") !== DEFAULT_ZLTQUANT_API_BASE) {
|
|
32841
33325
|
throw new Error("This research command requires a CLI login for the official ZLT Quant service.");
|
|
32842
33326
|
}
|
|
32843
|
-
const {
|
|
32844
|
-
|
|
32845
|
-
const root2 = (0, import_node_fs3.realpathSync)(workRoot);
|
|
32846
|
-
if (!inspectLinuxClientLiteBacktest(root2).complete) throw new Error(NOTICE);
|
|
32847
|
-
const store = new SharedWorkspaceStore({ validateRoot: (candidate) => (0, import_node_fs3.realpathSync)(candidate) === root2 });
|
|
32848
|
-
const binding = store.resolve({ root: root2 });
|
|
32849
|
-
if (!binding || binding.installation.kind !== "clientlite") {
|
|
32850
|
-
throw new Error("Select a registered ClientLite research workspace first.");
|
|
32851
|
-
}
|
|
32852
|
-
assertLinuxClientLiteResearchRuntime(root2, binding.installation.release);
|
|
32853
|
-
const executable = path36.join(root2, "python/bin/zlt-sdk-python");
|
|
33327
|
+
const { root: root2, store, binding } = await resolveResearchRuntime(config2);
|
|
33328
|
+
const executable = path37.join(root2, "python/bin/zlt-sdk-python");
|
|
32854
33329
|
const child = (0, import_node_child_process16.spawnSync)(executable, ["-I", "-B", "-X", "utf8", "-c", READ_DAILY_PRICES], {
|
|
32855
|
-
cwd:
|
|
33330
|
+
cwd: path37.join(root2, "python"),
|
|
32856
33331
|
env: { PATH: "/usr/bin:/bin", HOME: process.env.HOME, LANG: "C.UTF-8", LC_ALL: "C.UTF-8" },
|
|
32857
33332
|
input: JSON.stringify({ ...request3, root: root2, apiKey: credentials.apiKey, apiBase: DEFAULT_ZLTQUANT_API_BASE }),
|
|
32858
33333
|
encoding: "utf8",
|
|
@@ -33102,9 +33577,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
33102
33577
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
33103
33578
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
33104
33579
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
33105
|
-
var
|
|
33106
|
-
var
|
|
33107
|
-
var
|
|
33580
|
+
var fs37 = __toESM(require("node:fs"), 1);
|
|
33581
|
+
var path38 = __toESM(require("node:path"), 1);
|
|
33582
|
+
var import_node_crypto20 = require("node:crypto");
|
|
33108
33583
|
|
|
33109
33584
|
// src/market-panel-renderer.mjs
|
|
33110
33585
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
@@ -35394,22 +35869,22 @@ var CliMarketPanelOutput = class {
|
|
|
35394
35869
|
constructor(file2, tool) {
|
|
35395
35870
|
this.tool = tool;
|
|
35396
35871
|
if (!isMarketPanelTool(tool)) throw new Error("--panel-output supports only stock, market, leader and market observation tools");
|
|
35397
|
-
this.file =
|
|
35398
|
-
if (
|
|
35399
|
-
let ancestor =
|
|
35872
|
+
this.file = path38.resolve(file2);
|
|
35873
|
+
if (path38.extname(this.file).toLowerCase() !== ".html") throw new Error("--panel-output requires a new .html file");
|
|
35874
|
+
let ancestor = path38.dirname(this.file);
|
|
35400
35875
|
while (true) {
|
|
35401
35876
|
try {
|
|
35402
|
-
if (
|
|
35877
|
+
if (fs37.lstatSync(ancestor).isSymbolicLink()) throw new Error("Panel output parent is redirected");
|
|
35403
35878
|
} catch (error2) {
|
|
35404
35879
|
if (error2.code !== "ENOENT") throw error2;
|
|
35405
35880
|
}
|
|
35406
|
-
const parent =
|
|
35881
|
+
const parent = path38.dirname(ancestor);
|
|
35407
35882
|
if (parent === ancestor) break;
|
|
35408
35883
|
ancestor = parent;
|
|
35409
35884
|
}
|
|
35410
|
-
|
|
35411
|
-
this.fd =
|
|
35412
|
-
this.identity =
|
|
35885
|
+
fs37.mkdirSync(path38.dirname(this.file), { recursive: true });
|
|
35886
|
+
this.fd = fs37.openSync(this.file, "wx", 384);
|
|
35887
|
+
this.identity = fs37.fstatSync(this.fd);
|
|
35413
35888
|
}
|
|
35414
35889
|
tool;
|
|
35415
35890
|
file;
|
|
@@ -35418,7 +35893,7 @@ var CliMarketPanelOutput = class {
|
|
|
35418
35893
|
written = false;
|
|
35419
35894
|
owned() {
|
|
35420
35895
|
try {
|
|
35421
|
-
const current =
|
|
35896
|
+
const current = fs37.lstatSync(this.file);
|
|
35422
35897
|
return current.isFile() && !current.isSymbolicLink() && current.dev === this.identity.dev && current.ino === this.identity.ino;
|
|
35423
35898
|
} catch {
|
|
35424
35899
|
return false;
|
|
@@ -35477,7 +35952,7 @@ var CliMarketPanelOutput = class {
|
|
|
35477
35952
|
const dataAsOf = typeof asof === "string" ? asof : null;
|
|
35478
35953
|
const canonical2 = Z({
|
|
35479
35954
|
kind,
|
|
35480
|
-
id: (0,
|
|
35955
|
+
id: (0, import_node_crypto20.randomUUID)(),
|
|
35481
35956
|
schema_version: 1,
|
|
35482
35957
|
renderer_version: "1",
|
|
35483
35958
|
created_at: createdAt,
|
|
@@ -35520,8 +35995,8 @@ var CliMarketPanelOutput = class {
|
|
|
35520
35995
|
}
|
|
35521
35996
|
writeHtml(html, dataAsOf, createdAt) {
|
|
35522
35997
|
if (!this.owned() || this.fd === void 0) throw new Error("Panel output file was replaced; refusing to write");
|
|
35523
|
-
|
|
35524
|
-
|
|
35998
|
+
fs37.writeFileSync(this.fd, html, "utf8");
|
|
35999
|
+
fs37.fsyncSync(this.fd);
|
|
35525
36000
|
if (!this.owned()) throw new Error("Panel output file was replaced during write");
|
|
35526
36001
|
this.written = true;
|
|
35527
36002
|
return {
|
|
@@ -35536,24 +36011,24 @@ var CliMarketPanelOutput = class {
|
|
|
35536
36011
|
}
|
|
35537
36012
|
close() {
|
|
35538
36013
|
if (this.fd !== void 0) {
|
|
35539
|
-
|
|
36014
|
+
fs37.closeSync(this.fd);
|
|
35540
36015
|
this.fd = void 0;
|
|
35541
36016
|
}
|
|
35542
|
-
if (!this.written && this.owned())
|
|
36017
|
+
if (!this.written && this.owned()) fs37.unlinkSync(this.file);
|
|
35543
36018
|
}
|
|
35544
36019
|
};
|
|
35545
36020
|
|
|
35546
36021
|
// src/index.ts
|
|
35547
|
-
var
|
|
35548
|
-
var
|
|
36022
|
+
var fs60 = __toESM(require("node:fs"), 1);
|
|
36023
|
+
var path63 = __toESM(require("node:path"), 1);
|
|
35549
36024
|
|
|
35550
36025
|
// src/cli.ts
|
|
35551
36026
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
35552
36027
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
35553
36028
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
35554
36029
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
35555
|
-
var
|
|
35556
|
-
var
|
|
36030
|
+
var fs44 = __toESM(require("fs"), 1);
|
|
36031
|
+
var path45 = __toESM(require("path"), 1);
|
|
35557
36032
|
|
|
35558
36033
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
|
|
35559
36034
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
@@ -35794,10 +36269,10 @@ function assignProp(target, prop, value) {
|
|
|
35794
36269
|
configurable: true
|
|
35795
36270
|
});
|
|
35796
36271
|
}
|
|
35797
|
-
function getElementAtPath(obj,
|
|
35798
|
-
if (!
|
|
36272
|
+
function getElementAtPath(obj, path64) {
|
|
36273
|
+
if (!path64)
|
|
35799
36274
|
return obj;
|
|
35800
|
-
return
|
|
36275
|
+
return path64.reduce((acc, key2) => acc?.[key2], obj);
|
|
35801
36276
|
}
|
|
35802
36277
|
function promiseAllObject(promisesObj) {
|
|
35803
36278
|
const keys = Object.keys(promisesObj);
|
|
@@ -36117,11 +36592,11 @@ function aborted(x2, startIndex = 0) {
|
|
|
36117
36592
|
}
|
|
36118
36593
|
return false;
|
|
36119
36594
|
}
|
|
36120
|
-
function prefixIssues(
|
|
36595
|
+
function prefixIssues(path64, issues) {
|
|
36121
36596
|
return issues.map((iss) => {
|
|
36122
36597
|
var _a;
|
|
36123
36598
|
(_a = iss).path ?? (_a.path = []);
|
|
36124
|
-
iss.path.unshift(
|
|
36599
|
+
iss.path.unshift(path64);
|
|
36125
36600
|
return iss;
|
|
36126
36601
|
});
|
|
36127
36602
|
}
|
|
@@ -43413,35 +43888,35 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
43413
43888
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
43414
43889
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
43415
43890
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
43416
|
-
var
|
|
43417
|
-
var
|
|
43891
|
+
var fs38 = __toESM(require("fs"), 1);
|
|
43892
|
+
var path39 = __toESM(require("path"), 1);
|
|
43418
43893
|
init_dist();
|
|
43419
43894
|
init_dist();
|
|
43420
43895
|
function loadConfig(configPath) {
|
|
43421
|
-
const raw =
|
|
43896
|
+
const raw = fs38.readFileSync(configPath, "utf-8");
|
|
43422
43897
|
return JSON.parse(raw);
|
|
43423
43898
|
}
|
|
43424
43899
|
function resolveDefaultConfigPath() {
|
|
43425
43900
|
if (process.env.ZLT_MCP_CONFIG) return process.env.ZLT_MCP_CONFIG;
|
|
43426
|
-
const cwdCandidate =
|
|
43901
|
+
const cwdCandidate = path39.resolve(process.cwd(), "config.json");
|
|
43427
43902
|
const candidates = [
|
|
43428
|
-
|
|
43429
|
-
|
|
43903
|
+
path39.resolve(path39.dirname(resolveCliEntrypoint() || ""), "..", "config.json"),
|
|
43904
|
+
path39.resolve(path39.dirname(resolveCliEntrypoint() || ""), "config.json"),
|
|
43430
43905
|
cwdCandidate
|
|
43431
43906
|
];
|
|
43432
43907
|
for (const candidate of candidates) {
|
|
43433
|
-
if (
|
|
43908
|
+
if (fs38.existsSync(candidate)) return candidate;
|
|
43434
43909
|
}
|
|
43435
43910
|
return cwdCandidate;
|
|
43436
43911
|
}
|
|
43437
43912
|
function resolveDefaultRuntimeConfigPath() {
|
|
43438
43913
|
if (process.env.ZLT_RUNTIME_CONFIG) return process.env.ZLT_RUNTIME_CONFIG;
|
|
43439
43914
|
const candidates = [
|
|
43440
|
-
|
|
43441
|
-
|
|
43442
|
-
|
|
43915
|
+
path39.resolve(path39.dirname(resolveCliEntrypoint() || ""), "..", "runtime.cfg.json"),
|
|
43916
|
+
path39.resolve(path39.dirname(resolveCliEntrypoint() || ""), "runtime.cfg.json"),
|
|
43917
|
+
path39.resolve(process.cwd(), "runtime.cfg.json")
|
|
43443
43918
|
];
|
|
43444
|
-
return candidates.find((candidate) =>
|
|
43919
|
+
return candidates.find((candidate) => fs38.existsSync(candidate));
|
|
43445
43920
|
}
|
|
43446
43921
|
var matchingPipeNames2 = matchingPipeNames;
|
|
43447
43922
|
|
|
@@ -43483,8 +43958,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
43483
43958
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
43484
43959
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
43485
43960
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
43486
|
-
var
|
|
43487
|
-
var
|
|
43961
|
+
var fs39 = __toESM(require("node:fs"), 1);
|
|
43962
|
+
var path40 = __toESM(require("node:path"), 1);
|
|
43488
43963
|
var MAX_INVENTORY_ENTRIES = 25e3;
|
|
43489
43964
|
var MAX_INVENTORY_DEPTH = 8;
|
|
43490
43965
|
var SAFE_SEGMENT = /^[A-Za-z0-9_-]+$/;
|
|
@@ -43581,11 +44056,11 @@ async function downloadAndVerify(args, invoke, inventory2, onUuid) {
|
|
|
43581
44056
|
}
|
|
43582
44057
|
function configuredDownloadHome(clientRootDir) {
|
|
43583
44058
|
try {
|
|
43584
|
-
const configPath =
|
|
43585
|
-
const config2 = JSON.parse(
|
|
44059
|
+
const configPath = path40.join(clientRootDir, "zltHost", "moudles", "dcm.json");
|
|
44060
|
+
const config2 = JSON.parse(fs39.readFileSync(configPath, "utf8"));
|
|
43586
44061
|
if (!isRecord3(config2) || typeof config2.download_home !== "string" || !config2.download_home.trim()) return null;
|
|
43587
44062
|
const expanded = config2.download_home.trim().replace(/%HomePath%/gi, clientRootDir);
|
|
43588
|
-
return
|
|
44063
|
+
return path40.isAbsolute(expanded) ? path40.resolve(expanded) : path40.resolve(clientRootDir, expanded);
|
|
43589
44064
|
} catch {
|
|
43590
44065
|
return null;
|
|
43591
44066
|
}
|
|
@@ -43594,7 +44069,7 @@ function diskSpaceDownloadHome(result) {
|
|
|
43594
44069
|
const data = dataRecord(result);
|
|
43595
44070
|
if (!data) return null;
|
|
43596
44071
|
const value = data.download_home ?? data.downloadHome;
|
|
43597
|
-
return typeof value === "string" && value.trim() ?
|
|
44072
|
+
return typeof value === "string" && value.trim() ? path40.resolve(value.trim()) : null;
|
|
43598
44073
|
}
|
|
43599
44074
|
function requestedScopes(params) {
|
|
43600
44075
|
if (!Array.isArray(params) || params.length === 0) return null;
|
|
@@ -43621,7 +44096,7 @@ function inventoryDownloadedFiles(clientRootDir, params, diskSpace, limits = {})
|
|
|
43621
44096
|
if (!configured) return unknown2("download-home-config-unavailable");
|
|
43622
44097
|
const reported = diskSpaceDownloadHome(diskSpace);
|
|
43623
44098
|
if (!reported) return unknown2("disk-space-download-home-unavailable", configured);
|
|
43624
|
-
if (
|
|
44099
|
+
if (path40.resolve(configured).toLowerCase() !== path40.resolve(reported).toLowerCase()) return unknown2("download-home-mismatch", configured);
|
|
43625
44100
|
const scopes = requestedScopes(params);
|
|
43626
44101
|
if (!scopes) return unknown2("invalid-request-scope", configured);
|
|
43627
44102
|
if (scopes.some((scope) => !scope.exchangeId || !/^(dk|mk|tk)[a-z0-9_-]*$/.test(scope.dataType))) {
|
|
@@ -43629,12 +44104,12 @@ function inventoryDownloadedFiles(clientRootDir, params, diskSpace, limits = {})
|
|
|
43629
44104
|
}
|
|
43630
44105
|
let root2;
|
|
43631
44106
|
try {
|
|
43632
|
-
const configuredStat =
|
|
44107
|
+
const configuredStat = fs39.lstatSync(configured);
|
|
43633
44108
|
if (configuredStat.isSymbolicLink() || typeof configuredStat.attributes === "number" && (configuredStat.attributes & 1024) !== 0) {
|
|
43634
44109
|
return unknown2("symlink-or-reparse-point", configured);
|
|
43635
44110
|
}
|
|
43636
|
-
root2 =
|
|
43637
|
-
if (!
|
|
44111
|
+
root2 = fs39.realpathSync(configured);
|
|
44112
|
+
if (!fs39.statSync(root2).isDirectory()) return unknown2("download-home-not-directory", configured);
|
|
43638
44113
|
} catch {
|
|
43639
44114
|
return unknown2("download-home-unavailable", configured);
|
|
43640
44115
|
}
|
|
@@ -43648,10 +44123,10 @@ function inventoryDownloadedFiles(clientRootDir, params, diskSpace, limits = {})
|
|
|
43648
44123
|
let candidate = root2;
|
|
43649
44124
|
let present = true;
|
|
43650
44125
|
for (const segment of ["hqdata", lane, scope.exchangeId, scope.dataType]) {
|
|
43651
|
-
candidate =
|
|
44126
|
+
candidate = path40.join(candidate, segment);
|
|
43652
44127
|
let component;
|
|
43653
44128
|
try {
|
|
43654
|
-
component =
|
|
44129
|
+
component = fs39.lstatSync(candidate);
|
|
43655
44130
|
} catch (error2) {
|
|
43656
44131
|
if (error2.code === "ENOENT") {
|
|
43657
44132
|
present = false;
|
|
@@ -43672,12 +44147,12 @@ function inventoryDownloadedFiles(clientRootDir, params, diskSpace, limits = {})
|
|
|
43672
44147
|
}
|
|
43673
44148
|
while (queue.length > 0) {
|
|
43674
44149
|
const current = queue.shift();
|
|
43675
|
-
for (const entry of
|
|
44150
|
+
for (const entry of fs39.readdirSync(current.dir, { withFileTypes: true })) {
|
|
43676
44151
|
entries += 1;
|
|
43677
44152
|
if (entries > (limits.maxEntries ?? MAX_INVENTORY_ENTRIES)) return unknown2("inventory-entry-limit", configured);
|
|
43678
|
-
const full =
|
|
44153
|
+
const full = path40.join(current.dir, entry.name);
|
|
43679
44154
|
if (entry.isSymbolicLink()) return unknown2("symlink-or-reparse-point", configured);
|
|
43680
|
-
const stat2 =
|
|
44155
|
+
const stat2 = fs39.lstatSync(full);
|
|
43681
44156
|
const attrs = stat2.attributes;
|
|
43682
44157
|
if (stat2.isSymbolicLink() || typeof attrs === "number" && (attrs & 1024) !== 0) return unknown2("symlink-or-reparse-point", configured);
|
|
43683
44158
|
if (entry.isDirectory()) {
|
|
@@ -43700,9 +44175,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
43700
44175
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
43701
44176
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
43702
44177
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
43703
|
-
var
|
|
44178
|
+
var fs40 = __toESM(require("node:fs"), 1);
|
|
43704
44179
|
var os11 = __toESM(require("node:os"), 1);
|
|
43705
|
-
var
|
|
44180
|
+
var path41 = __toESM(require("node:path"), 1);
|
|
43706
44181
|
var RECOVERY_HANDLERS = /* @__PURE__ */ new Set([
|
|
43707
44182
|
"currentUser",
|
|
43708
44183
|
"runtimeDoctor",
|
|
@@ -43715,8 +44190,8 @@ function resolveLocalCredentialsPath(env = process.env) {
|
|
|
43715
44190
|
const configuredPath2 = env.ZLTQUANT_CREDENTIALS?.trim();
|
|
43716
44191
|
if (configuredPath2) return expandHome2(configuredPath2);
|
|
43717
44192
|
const configuredHome = env.ZLTQUANT_HOME?.trim();
|
|
43718
|
-
const home = configuredHome ? expandHome2(configuredHome) :
|
|
43719
|
-
return
|
|
44193
|
+
const home = configuredHome ? expandHome2(configuredHome) : path41.join(os11.homedir(), ".zltquant");
|
|
44194
|
+
return path41.join(home, "credentials.json");
|
|
43720
44195
|
}
|
|
43721
44196
|
function inspectLocalCredential(env = process.env) {
|
|
43722
44197
|
const credentialsPath = resolveLocalCredentialsPath(env);
|
|
@@ -43761,8 +44236,8 @@ function guardBusinessCredential(tool, args, env = process.env) {
|
|
|
43761
44236
|
}
|
|
43762
44237
|
function inspectCredentialFile(credentialsPath) {
|
|
43763
44238
|
try {
|
|
43764
|
-
if (!
|
|
43765
|
-
const parsed = JSON.parse(
|
|
44239
|
+
if (!fs40.existsSync(credentialsPath)) return null;
|
|
44240
|
+
const parsed = JSON.parse(fs40.readFileSync(credentialsPath, "utf8"));
|
|
43766
44241
|
if (isRecord4(parsed) && typeof parsed.apiKey === "string" && parsed.apiKey.trim()) {
|
|
43767
44242
|
return { configured: true, status: "configured", source: "file", credentialsPath };
|
|
43768
44243
|
}
|
|
@@ -43786,8 +44261,8 @@ function preservedTaskIdentity(args) {
|
|
|
43786
44261
|
}
|
|
43787
44262
|
function expandHome2(input2) {
|
|
43788
44263
|
if (input2 === "~") return os11.homedir();
|
|
43789
|
-
if (input2.startsWith("~/") || input2.startsWith("~\\")) return
|
|
43790
|
-
return
|
|
44264
|
+
if (input2.startsWith("~/") || input2.startsWith("~\\")) return path41.join(os11.homedir(), input2.slice(2));
|
|
44265
|
+
return path41.resolve(input2);
|
|
43791
44266
|
}
|
|
43792
44267
|
function isRecord4(value) {
|
|
43793
44268
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -43798,11 +44273,11 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
43798
44273
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
43799
44274
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
43800
44275
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
43801
|
-
var
|
|
43802
|
-
var
|
|
44276
|
+
var fs41 = __toESM(require("node:fs"), 1);
|
|
44277
|
+
var path42 = __toESM(require("node:path"), 1);
|
|
43803
44278
|
init_shared_workspaces();
|
|
43804
44279
|
function clientLiteXmlFields(file2) {
|
|
43805
|
-
const bytes =
|
|
44280
|
+
const bytes = fs41.readFileSync(file2);
|
|
43806
44281
|
const declared = bytes.subarray(0, 256).toString("ascii").match(/<\?xml\s+[^>]*encoding=["']([^"']+)["']/i)?.[1]?.toLowerCase() ?? "utf-8";
|
|
43807
44282
|
if (!["gbk", "gb2312", "gb18030", "utf-8", "utf8"].includes(declared)) throw new Error(`Unsupported InstallInfo.xml encoding: ${declared}`);
|
|
43808
44283
|
const xml = new TextDecoder(declared, { fatal: true }).decode(bytes);
|
|
@@ -43851,45 +44326,45 @@ function clientLiteXmlFields(file2) {
|
|
|
43851
44326
|
}
|
|
43852
44327
|
function inspectLocalRuntimeReadiness(workRoot) {
|
|
43853
44328
|
const macos = process.platform === "darwin";
|
|
43854
|
-
const incomplete =
|
|
44329
|
+
const incomplete = path42.join(workRoot, ".clientlite-incomplete");
|
|
43855
44330
|
try {
|
|
43856
|
-
|
|
44331
|
+
fs41.lstatSync(incomplete);
|
|
43857
44332
|
return { ready: false, workRoot, reason: "ClientLite root awaits native qualification", missingPath: incomplete };
|
|
43858
44333
|
} catch (error2) {
|
|
43859
44334
|
if (error2.code !== "ENOENT") {
|
|
43860
44335
|
return { ready: false, workRoot, reason: "Cannot inspect ClientLite qualification state", missingPath: incomplete };
|
|
43861
44336
|
}
|
|
43862
44337
|
}
|
|
43863
|
-
if (macos || process.platform === "win32" &&
|
|
44338
|
+
if (macos || process.platform === "win32" && fs41.existsSync(path42.join(workRoot, "InstallInfo.xml"))) {
|
|
43864
44339
|
try {
|
|
43865
|
-
const xmlFields = clientLiteXmlFields(
|
|
44340
|
+
const xmlFields = clientLiteXmlFields(path42.join(workRoot, "InstallInfo.xml"));
|
|
43866
44341
|
if (macos && !xmlFields) throw new Error("Prepared Mac ClientLite requires InstallInfo.xml InstallType clientlite");
|
|
43867
44342
|
if (xmlFields) {
|
|
43868
44343
|
if (xmlFields.get("installappid")) throw new Error("ClientLite must not claim an Assistant InstallAppId");
|
|
43869
|
-
const stdlibName =
|
|
44344
|
+
const stdlibName = path42.basename(xmlFields.get("pythondir") ?? "");
|
|
43870
44345
|
if (macos && !/^python3\.\d+$/.test(stdlibName)) throw new Error("ClientLite PythonDir must identify the owned Python stdlib");
|
|
43871
44346
|
const samePath3 = (a2, b2) => {
|
|
43872
|
-
const left =
|
|
43873
|
-
const right =
|
|
44347
|
+
const left = fs41.realpathSync.native(a2);
|
|
44348
|
+
const right = fs41.realpathSync.native(b2);
|
|
43874
44349
|
return macos ? left === right : left.toLowerCase() === right.toLowerCase();
|
|
43875
44350
|
};
|
|
43876
44351
|
const fields = [
|
|
43877
44352
|
["InstallDir", workRoot],
|
|
43878
44353
|
["InstallDocRedir", workRoot],
|
|
43879
|
-
["PublicDataDir",
|
|
43880
|
-
["PrivateDataDir", registeredClientLiteDataPaths(workRoot)?.userDataRoot ??
|
|
43881
|
-
["TemporaryDataDir",
|
|
43882
|
-
["PythonDir", macos ?
|
|
44354
|
+
["PublicDataDir", path42.join(workRoot, "Public")],
|
|
44355
|
+
["PrivateDataDir", registeredClientLiteDataPaths(workRoot)?.userDataRoot ?? path42.join(workRoot, "Users")],
|
|
44356
|
+
["TemporaryDataDir", path42.join(workRoot, "Temporary")],
|
|
44357
|
+
["PythonDir", macos ? path42.join(workRoot, "python", "lib", stdlibName) : path42.join(workRoot, "python")]
|
|
43883
44358
|
];
|
|
43884
44359
|
for (const [key2, expected] of fields) {
|
|
43885
44360
|
const value = xmlFields.get(key2.toLowerCase());
|
|
43886
|
-
if (!value || !
|
|
44361
|
+
if (!value || !path42.isAbsolute(value) || !samePath3(value, expected)) {
|
|
43887
44362
|
throw new Error(`ClientLite InstallInfo.xml ${key2} does not match selected root`);
|
|
43888
44363
|
}
|
|
43889
44364
|
}
|
|
43890
|
-
const suffix =
|
|
44365
|
+
const suffix = fs41.readFileSync(path42.join(workRoot, "Temporary", "zlt"), "utf8").trim();
|
|
43891
44366
|
if (!/^[0-9a-f]{32}$/i.test(suffix)) throw new Error("Prepared ClientLite requires Temporary/zlt installation identity");
|
|
43892
|
-
const properties2 =
|
|
44367
|
+
const properties2 = fs41.readFileSync(path42.join(workRoot, "zltaf", "application-local.properties"), "utf8");
|
|
43893
44368
|
const settings = /* @__PURE__ */ new Map();
|
|
43894
44369
|
for (const line of properties2.split(/\r?\n/)) {
|
|
43895
44370
|
const match = line.match(/^\s*([^#!\s:=]+)\s*[:=]\s*(.*?)\s*$/);
|
|
@@ -43897,7 +44372,7 @@ function inspectLocalRuntimeReadiness(workRoot) {
|
|
|
43897
44372
|
}
|
|
43898
44373
|
const absolute = (key2) => {
|
|
43899
44374
|
const value = settings.get(key2);
|
|
43900
|
-
if (!value || !
|
|
44375
|
+
if (!value || !path42.isAbsolute(value) || /\$\{|%[^%]+%/.test(value)) throw new Error(`Prepared ClientLite requires absolute ${key2}`);
|
|
43901
44376
|
return value;
|
|
43902
44377
|
};
|
|
43903
44378
|
if (!samePath3(absolute("slave.install-path"), workRoot)) {
|
|
@@ -43905,26 +44380,26 @@ function inspectLocalRuntimeReadiness(workRoot) {
|
|
|
43905
44380
|
}
|
|
43906
44381
|
const python = absolute("slave.python-path");
|
|
43907
44382
|
const git = absolute("slave.mingit-path");
|
|
43908
|
-
const nativeFiles = macos ? ["zlthost/ZLTHost", "zlthost/zlthost_macos_start.sh", "zltaf/zltaf"].map((file2) =>
|
|
44383
|
+
const nativeFiles = macos ? ["zlthost/ZLTHost", "zlthost/zlthost_macos_start.sh", "zltaf/zltaf"].map((file2) => path42.join(workRoot, file2)) : [path42.join(workRoot, "zlthost", "ZLTHost.exe"), path42.join(workRoot, "zltaf", "zltaf.exe")];
|
|
43909
44384
|
for (const file2 of [...nativeFiles, python, git]) {
|
|
43910
|
-
if (!
|
|
43911
|
-
if (macos)
|
|
44385
|
+
if (!fs41.statSync(file2).isFile()) throw new Error(`Prepared ClientLite file missing: ${file2}`);
|
|
44386
|
+
if (macos) fs41.accessSync(file2, fs41.constants.X_OK);
|
|
43912
44387
|
}
|
|
43913
|
-
if (!samePath3(python,
|
|
44388
|
+
if (!samePath3(python, path42.join(workRoot, "python", ...macos ? ["bin", "python3"] : ["Scripts", "python.exe"]))) {
|
|
43914
44389
|
throw new Error("ClientLite Python must belong to the selected installation");
|
|
43915
44390
|
}
|
|
43916
44391
|
if (macos) {
|
|
43917
44392
|
const requireOwned = (prefix, file2) => {
|
|
43918
|
-
const relative13 =
|
|
43919
|
-
if (relative13 === ".." || relative13.startsWith(`..${
|
|
44393
|
+
const relative13 = path42.relative(fs41.realpathSync.native(prefix), fs41.realpathSync.native(file2));
|
|
44394
|
+
if (relative13 === ".." || relative13.startsWith(`..${path42.sep}`) || path42.isAbsolute(relative13)) {
|
|
43920
44395
|
throw new Error(`ClientLite file must belong to the selected installation: ${file2}`);
|
|
43921
44396
|
}
|
|
43922
44397
|
};
|
|
43923
44398
|
for (const file2 of [...nativeFiles, python]) requireOwned(workRoot, file2);
|
|
43924
|
-
const stdlib =
|
|
43925
|
-
if (!
|
|
43926
|
-
requireOwned(
|
|
43927
|
-
requireOwned(
|
|
44399
|
+
const stdlib = path42.join(workRoot, "python", "lib", stdlibName);
|
|
44400
|
+
if (!fs41.statSync(stdlib).isDirectory()) throw new Error("ClientLite PythonDir must be a stdlib directory");
|
|
44401
|
+
requireOwned(path42.join(workRoot, "python"), python);
|
|
44402
|
+
requireOwned(path42.join(workRoot, "python"), stdlib);
|
|
43928
44403
|
}
|
|
43929
44404
|
return { ready: true, workRoot, gitPath: git };
|
|
43930
44405
|
}
|
|
@@ -43935,17 +44410,17 @@ function inspectLocalRuntimeReadiness(workRoot) {
|
|
|
43935
44410
|
}
|
|
43936
44411
|
const required2 = [
|
|
43937
44412
|
["\u5DE5\u7A0B\u8DEF\u5F84", workRoot],
|
|
43938
|
-
["ZLTAF \u7A0B\u5E8F",
|
|
43939
|
-
["ZLTAF \u914D\u7F6E",
|
|
43940
|
-
["Python \u7A0B\u5E8F",
|
|
43941
|
-
["MinGit \u7A0B\u5E8F",
|
|
44413
|
+
["ZLTAF \u7A0B\u5E8F", path42.join(workRoot, "zltaf", "zltaf.exe")],
|
|
44414
|
+
["ZLTAF \u914D\u7F6E", path42.join(workRoot, "zltaf", "application-local.properties")],
|
|
44415
|
+
["Python \u7A0B\u5E8F", path42.join(workRoot, "python", "python.exe")],
|
|
44416
|
+
["MinGit \u7A0B\u5E8F", path42.join(workRoot, "mingit", "cmd", "git.exe")]
|
|
43942
44417
|
];
|
|
43943
44418
|
for (const [label, filePath] of required2) {
|
|
43944
|
-
if (!
|
|
44419
|
+
if (!fs41.existsSync(filePath)) {
|
|
43945
44420
|
return { ready: false, workRoot, reason: `\u7F3A\u5C11${label}: ${filePath}`, missingPath: filePath };
|
|
43946
44421
|
}
|
|
43947
44422
|
}
|
|
43948
|
-
return { ready: true, workRoot, gitPath:
|
|
44423
|
+
return { ready: true, workRoot, gitPath: path42.join(workRoot, "mingit", "cmd", "git.exe") };
|
|
43949
44424
|
}
|
|
43950
44425
|
|
|
43951
44426
|
// src/factor-operations.ts
|
|
@@ -43953,8 +44428,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
43953
44428
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
43954
44429
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
43955
44430
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
43956
|
-
var
|
|
43957
|
-
var
|
|
44431
|
+
var fs43 = __toESM(require("node:fs"), 1);
|
|
44432
|
+
var path44 = __toESM(require("node:path"), 1);
|
|
43958
44433
|
|
|
43959
44434
|
// src/factor-result-transforms.ts
|
|
43960
44435
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
@@ -44099,8 +44574,8 @@ function pickByPeriod(source, period, index) {
|
|
|
44099
44574
|
if (isRecord2(source)) return numberOrNull(source[period]);
|
|
44100
44575
|
return null;
|
|
44101
44576
|
}
|
|
44102
|
-
function ownPathValue(root2,
|
|
44103
|
-
const parts =
|
|
44577
|
+
function ownPathValue(root2, path64) {
|
|
44578
|
+
const parts = path64.split(".").filter(Boolean);
|
|
44104
44579
|
if (parts.length === 0) return { found: false };
|
|
44105
44580
|
let current = root2;
|
|
44106
44581
|
for (const part of parts) {
|
|
@@ -44109,8 +44584,8 @@ function ownPathValue(root2, path63) {
|
|
|
44109
44584
|
}
|
|
44110
44585
|
return { found: true, value: current };
|
|
44111
44586
|
}
|
|
44112
|
-
function reportPathParent(root2,
|
|
44113
|
-
const parts =
|
|
44587
|
+
function reportPathParent(root2, path64) {
|
|
44588
|
+
const parts = path64.split(".").filter(Boolean);
|
|
44114
44589
|
if (parts.length === 0) return void 0;
|
|
44115
44590
|
const parentPath = parts.slice(0, -1).join(".");
|
|
44116
44591
|
const parent = parentPath ? ownPathValue(root2, parentPath).value : root2;
|
|
@@ -44612,7 +45087,7 @@ function shapeDataResultDisclosure(tool, args, result) {
|
|
|
44612
45087
|
const units = [];
|
|
44613
45088
|
const totals = /* @__PURE__ */ new Map();
|
|
44614
45089
|
const selectedIndexes = /* @__PURE__ */ new Map();
|
|
44615
|
-
const target = (
|
|
45090
|
+
const target = (path64) => /\.(ranges|series|missing|changed|windows)$/.test(path64);
|
|
44616
45091
|
const nested = (entry) => isRecord2(entry) && Object.entries(entry).some(([key2, child]) => target(`.${key2}`) && Array.isArray(child) && child.length > 0);
|
|
44617
45092
|
const scan = (value, jsonPath) => {
|
|
44618
45093
|
if (Array.isArray(value)) {
|
|
@@ -44670,11 +45145,11 @@ function shapeDataResultDisclosure(tool, args, result) {
|
|
|
44670
45145
|
}
|
|
44671
45146
|
let data = render(displaySource, "$.Data");
|
|
44672
45147
|
data = fitDataBudget(data, ARRAY_BUDGET - 2048);
|
|
44673
|
-
const paths = [...totals.keys()].filter((
|
|
45148
|
+
const paths = [...totals.keys()].filter((path64) => !path64.includes("[") || selectedIndexes.has(path64));
|
|
44674
45149
|
const shownPaths = paths.slice(0, 50);
|
|
44675
|
-
const arrays = shownPaths.map((
|
|
44676
|
-
const returnedCount = new Set([...selected].filter((key2) => key2.startsWith(`${
|
|
44677
|
-
return { path:
|
|
45150
|
+
const arrays = shownPaths.map((path64) => {
|
|
45151
|
+
const returnedCount = new Set([...selected].filter((key2) => key2.startsWith(`${path64}[`)).map((key2) => key2.slice(path64.length + 1).split("]")[0])).size;
|
|
45152
|
+
return { path: path64, total: totals.get(path64), returned: returnedCount, omitted: totals.get(path64) - returnedCount };
|
|
44678
45153
|
});
|
|
44679
45154
|
data.disclosure = {
|
|
44680
45155
|
kind: KIND,
|
|
@@ -44846,8 +45321,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
44846
45321
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
44847
45322
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
44848
45323
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
44849
|
-
var
|
|
44850
|
-
var
|
|
45324
|
+
var fs42 = __toESM(require("node:fs"), 1);
|
|
45325
|
+
var path43 = __toESM(require("node:path"), 1);
|
|
44851
45326
|
var MARKET_ID_TO_NAME = {
|
|
44852
45327
|
29544: "\u4E0A\u4EA4\u6240(sh)",
|
|
44853
45328
|
29562: "\u6DF1\u4EA4\u6240(sz)",
|
|
@@ -44917,7 +45392,7 @@ function normalizeDataRoot(raw, clientRootDir) {
|
|
|
44917
45392
|
}
|
|
44918
45393
|
function readJsonFile(filePath) {
|
|
44919
45394
|
try {
|
|
44920
|
-
const parsed = JSON.parse(
|
|
45395
|
+
const parsed = JSON.parse(fs42.readFileSync(filePath, "utf-8"));
|
|
44921
45396
|
return isRecord2(parsed) ? parsed : void 0;
|
|
44922
45397
|
} catch {
|
|
44923
45398
|
return void 0;
|
|
@@ -44932,8 +45407,8 @@ function resolveDataRoots(clientRootDir, preparedPaths) {
|
|
|
44932
45407
|
const cached2 = Date.now() - readAt < DATA_ROOTS_TTL_MS ? dataRootsCache.get(cacheKey2) : void 0;
|
|
44933
45408
|
if (cached2) return cached2;
|
|
44934
45409
|
const root2 = clientRootDir.replace(/[\\/]+$/, "");
|
|
44935
|
-
const dcSdk = readJsonFile(preparedPaths?.dcSdkConfigPath ??
|
|
44936
|
-
const dcm = readJsonFile(preparedPaths?.dcmConfigPath ??
|
|
45410
|
+
const dcSdk = readJsonFile(preparedPaths?.dcSdkConfigPath ?? path43.join(root2, ...DC_SDK_CONFIG_SEGMENTS));
|
|
45411
|
+
const dcm = readJsonFile(preparedPaths?.dcmConfigPath ?? path43.join(root2, ...DCM_CONFIG_SEGMENTS));
|
|
44937
45412
|
const normalize5 = (value) => {
|
|
44938
45413
|
const normalized = normalizeDataRoot(value, root2);
|
|
44939
45414
|
return preparedPaths ? normalized : normalized.toLowerCase();
|
|
@@ -45007,9 +45482,9 @@ function engineHasHqSeries(engineRoot, series) {
|
|
|
45007
45482
|
if (!engineRoot || !series.exchangeId || !HQ_DATA_FAMILIES.has(splitDataTypeToken(series.dataType).family)) {
|
|
45008
45483
|
return void 0;
|
|
45009
45484
|
}
|
|
45010
|
-
const dir2 =
|
|
45485
|
+
const dir2 = path43.join(engineRoot, "hqdata", "his", series.exchangeId, series.dataType);
|
|
45011
45486
|
try {
|
|
45012
|
-
return
|
|
45487
|
+
return fs42.readdirSync(dir2).length > 0;
|
|
45013
45488
|
} catch (error2) {
|
|
45014
45489
|
return isRecord2(error2) && error2.code === "ENOENT" ? false : void 0;
|
|
45015
45490
|
}
|
|
@@ -45591,7 +46066,7 @@ function readSlaveProperties(filePath) {
|
|
|
45591
46066
|
const entries = /* @__PURE__ */ new Map();
|
|
45592
46067
|
let raw;
|
|
45593
46068
|
try {
|
|
45594
|
-
raw =
|
|
46069
|
+
raw = fs43.readFileSync(filePath, "utf-8");
|
|
45595
46070
|
} catch {
|
|
45596
46071
|
return entries;
|
|
45597
46072
|
}
|
|
@@ -45615,18 +46090,18 @@ function resolveFactorProjectRoot(clientRootDir) {
|
|
|
45615
46090
|
if (cached2) return cached2;
|
|
45616
46091
|
const root2 = clientRootDir.replace(/[\\/]+$/, "");
|
|
45617
46092
|
const configured = expandSlaveValue(
|
|
45618
|
-
readSlaveProperties(
|
|
46093
|
+
readSlaveProperties(path44.join(root2, ...ZLTAF_CONFIG_SEGMENTS)),
|
|
45619
46094
|
"slave.factor.project-path",
|
|
45620
46095
|
root2
|
|
45621
46096
|
);
|
|
45622
|
-
const resolved = configured ?
|
|
46097
|
+
const resolved = configured ? path44.normalize(configured) : path44.join(root2, ...FALLBACK_FACTOR_PROJECT_PATH);
|
|
45623
46098
|
factorProjectRootCache.set(clientRootDir, resolved);
|
|
45624
46099
|
return resolved;
|
|
45625
46100
|
}
|
|
45626
46101
|
function resolveFactorWorkspacePath(clientRootDir, factorId) {
|
|
45627
46102
|
if (!clientRootDir || !factorId) return void 0;
|
|
45628
46103
|
const projectRoot = resolveFactorProjectRoot(clientRootDir);
|
|
45629
|
-
return projectRoot ?
|
|
46104
|
+
return projectRoot ? path44.join(projectRoot, factorId) : void 0;
|
|
45630
46105
|
}
|
|
45631
46106
|
var MODULE_LEVEL_FACTOR_EXPORT = /^(?:(?:async\s+)?def\s+get_factor\s*\(|get_factor\s*=(?!=)|Factor\s*=(?!=))/m;
|
|
45632
46107
|
function checkFactorSourceLoadable(clientRootDir, factorId) {
|
|
@@ -45634,7 +46109,7 @@ function checkFactorSourceLoadable(clientRootDir, factorId) {
|
|
|
45634
46109
|
if (!workspacePath) return null;
|
|
45635
46110
|
let source;
|
|
45636
46111
|
try {
|
|
45637
|
-
source =
|
|
46112
|
+
source = fs43.readFileSync(path44.join(workspacePath, "main.py"), "utf8");
|
|
45638
46113
|
} catch {
|
|
45639
46114
|
return null;
|
|
45640
46115
|
}
|
|
@@ -45971,7 +46446,7 @@ async function fillFactorValuesFromEdms(base, args, client2, timeout, recordEndD
|
|
|
45971
46446
|
async function fillFactorValuesFromCurrentStore(tool, base, args, client2, timeout, recordEndDate, session2) {
|
|
45972
46447
|
const root2 = session2.clientRootDir;
|
|
45973
46448
|
if (root2) {
|
|
45974
|
-
const properties2 = readSlaveProperties(
|
|
46449
|
+
const properties2 = readSlaveProperties(path44.join(root2, ...ZLTAF_CONFIG_SEGMENTS));
|
|
45975
46450
|
if (properties2.get("slave.factor.output-type") === "parquet") {
|
|
45976
46451
|
if (!session2.factorParquetReader) return base;
|
|
45977
46452
|
const storageRoot = expandSlaveValue(properties2, "slave.factor.storage-root", root2);
|
|
@@ -46193,23 +46668,23 @@ function getTimestampISO() {
|
|
|
46193
46668
|
return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
|
|
46194
46669
|
}
|
|
46195
46670
|
function ensureDir(dir2) {
|
|
46196
|
-
|
|
46671
|
+
fs44.mkdirSync(dir2, { recursive: true });
|
|
46197
46672
|
}
|
|
46198
46673
|
function writeResponseFile(outputDir, content) {
|
|
46199
46674
|
ensureDir(outputDir);
|
|
46200
46675
|
const filename = `resp_${getTimestamp()}.json`;
|
|
46201
|
-
const filePath =
|
|
46202
|
-
|
|
46676
|
+
const filePath = path45.join(outputDir, filename);
|
|
46677
|
+
fs44.writeFileSync(filePath, content, "utf-8");
|
|
46203
46678
|
return filePath;
|
|
46204
46679
|
}
|
|
46205
46680
|
function appendHistory(outputDir, uri, statusCode, contentSize, respFile) {
|
|
46206
46681
|
ensureDir(outputDir);
|
|
46207
|
-
const historyPath =
|
|
46208
|
-
if (
|
|
46209
|
-
const lines =
|
|
46682
|
+
const historyPath = path45.join(outputDir, "history.jsonl");
|
|
46683
|
+
if (fs44.existsSync(historyPath)) {
|
|
46684
|
+
const lines = fs44.readFileSync(historyPath, "utf-8").split("\n").filter((l) => l.trim());
|
|
46210
46685
|
if (lines.length > HISTORY_MAX_LINES) {
|
|
46211
46686
|
const kept = lines.slice(lines.length - HISTORY_MAX_LINES);
|
|
46212
|
-
|
|
46687
|
+
fs44.writeFileSync(historyPath, kept.join("\n") + "\n", "utf-8");
|
|
46213
46688
|
}
|
|
46214
46689
|
}
|
|
46215
46690
|
const record7 = {
|
|
@@ -46219,20 +46694,20 @@ function appendHistory(outputDir, uri, statusCode, contentSize, respFile) {
|
|
|
46219
46694
|
size: contentSize
|
|
46220
46695
|
};
|
|
46221
46696
|
if (respFile) record7.file = respFile;
|
|
46222
|
-
|
|
46697
|
+
fs44.appendFileSync(historyPath, JSON.stringify(record7) + "\n", "utf-8");
|
|
46223
46698
|
}
|
|
46224
46699
|
function cleanOutput(clientRootDir, maxDays = 1) {
|
|
46225
46700
|
const outputDir = getOutputDir(clientRootDir);
|
|
46226
|
-
if (!
|
|
46701
|
+
if (!fs44.existsSync(outputDir)) return 0;
|
|
46227
46702
|
const now = Date.now();
|
|
46228
46703
|
const cutoff = now - maxDays * 864e5;
|
|
46229
46704
|
let removed = 0;
|
|
46230
|
-
for (const entry of
|
|
46705
|
+
for (const entry of fs44.readdirSync(outputDir)) {
|
|
46231
46706
|
if (!entry.startsWith("resp_") || !entry.endsWith(".json")) continue;
|
|
46232
|
-
const filePath =
|
|
46233
|
-
const stat2 =
|
|
46707
|
+
const filePath = path45.join(outputDir, entry);
|
|
46708
|
+
const stat2 = fs44.statSync(filePath);
|
|
46234
46709
|
if (stat2.mtimeMs < cutoff) {
|
|
46235
|
-
|
|
46710
|
+
fs44.unlinkSync(filePath);
|
|
46236
46711
|
removed++;
|
|
46237
46712
|
}
|
|
46238
46713
|
}
|
|
@@ -46243,7 +46718,7 @@ async function execCommand(funcName, options) {
|
|
|
46243
46718
|
throw new Error("On macOS and Linux use zlt-mcp call <tool> so runtime leases and active jobs are tracked. Raw exec is unavailable.");
|
|
46244
46719
|
}
|
|
46245
46720
|
const resolver = resolveDefaultConfigPath;
|
|
46246
|
-
const configPath = typeof resolver === "function" ? resolver() : process.env.ZLT_MCP_CONFIG ||
|
|
46721
|
+
const configPath = typeof resolver === "function" ? resolver() : process.env.ZLT_MCP_CONFIG || path45.resolve(process.cwd(), "config.json");
|
|
46247
46722
|
const config2 = loadConfig2(configPath);
|
|
46248
46723
|
const tool = config2.tools.find((t) => t.name === funcName);
|
|
46249
46724
|
if (!tool) {
|
|
@@ -46304,7 +46779,7 @@ async function execCommand(funcName, options) {
|
|
|
46304
46779
|
}
|
|
46305
46780
|
let bodyFromFile = bodyOverride || "";
|
|
46306
46781
|
if (!bodyFromFile && bodyFile) {
|
|
46307
|
-
bodyFromFile =
|
|
46782
|
+
bodyFromFile = fs44.readFileSync(bodyFile, "utf-8");
|
|
46308
46783
|
}
|
|
46309
46784
|
const pipePath = discoverPipePath2(clientRootDir, tool?.pipName || config2.zltconfig.pipName);
|
|
46310
46785
|
const client2 = new ZltafIpcClient();
|
|
@@ -46359,7 +46834,7 @@ function parseMcpArgs(argsJson, argsFile) {
|
|
|
46359
46834
|
if (argsJson !== void 0 && argsFile !== void 0) {
|
|
46360
46835
|
throw new Error("Use only one of --args-json and --args-file");
|
|
46361
46836
|
}
|
|
46362
|
-
const raw = argsFile !== void 0 ?
|
|
46837
|
+
const raw = argsFile !== void 0 ? fs44.readFileSync(argsFile, "utf-8").replace(/^\uFEFF/, "") : argsJson !== void 0 ? argsJson : "{}";
|
|
46363
46838
|
let parsed;
|
|
46364
46839
|
try {
|
|
46365
46840
|
parsed = JSON.parse(raw);
|
|
@@ -46409,7 +46884,7 @@ function childEnvironment(clientRoot) {
|
|
|
46409
46884
|
if (/^ZLT(?:QUANT)?_/i.test(key2) || /^(?:TMPDIR|TEMP|TMP)$/i.test(key2) || key2 === "PYTHONUTF8" || hostNodeContextKeys.has(key2)) forwarded[key2] = value;
|
|
46410
46885
|
}
|
|
46411
46886
|
const root2 = clientRoot;
|
|
46412
|
-
if (root2 &&
|
|
46887
|
+
if (root2 && fs44.existsSync(root2) && !process.env.ZLT_RUNTIME_ENV?.trim() && !process.env.ZLT_ASSISTANT_ENV_MODE?.trim()) {
|
|
46413
46888
|
const context2 = readInstallationContextSync(
|
|
46414
46889
|
loadAssistantRuntimeConfig(resolveDefaultRuntimeConfigPath?.()),
|
|
46415
46890
|
root2
|
|
@@ -46574,7 +47049,7 @@ function backtestHandoff(result) {
|
|
|
46574
47049
|
const rawCodePath = typeof record7.codePath === "string" ? record7.codePath.trim() : typeof evidence?.runDir === "string" ? evidence.runDir.trim() : "";
|
|
46575
47050
|
return {
|
|
46576
47051
|
runId,
|
|
46577
|
-
...rawCodePath &&
|
|
47052
|
+
...rawCodePath && path45.isAbsolute(rawCodePath) ? { codePath: rawCodePath } : {},
|
|
46578
47053
|
...record7.attemptFence !== void 0 ? { attemptFence: record7.attemptFence } : {}
|
|
46579
47054
|
};
|
|
46580
47055
|
}
|
|
@@ -46591,7 +47066,7 @@ function mergeBacktestWait(launched, waited, handoff) {
|
|
|
46591
47066
|
for (const id of [data.runId, data.backtestId]) {
|
|
46592
47067
|
if (id !== void 0 && id !== handoff.runId) throw new Error("Backtest wait returned a different run ID");
|
|
46593
47068
|
}
|
|
46594
|
-
if (data.codePath !== void 0 && handoff.codePath && (typeof data.codePath !== "string" ||
|
|
47069
|
+
if (data.codePath !== void 0 && handoff.codePath && (typeof data.codePath !== "string" || path45.resolve(data.codePath).toLowerCase() !== path45.resolve(handoff.codePath).toLowerCase())) {
|
|
46595
47070
|
throw new Error("Backtest wait returned a different run directory");
|
|
46596
47071
|
}
|
|
46597
47072
|
const status = typeof data.status === "number" || typeof data.status === "string" && data.status.trim() ? Number(data.status) : NaN;
|
|
@@ -46873,8 +47348,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
46873
47348
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
46874
47349
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
46875
47350
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
46876
|
-
var
|
|
46877
|
-
var
|
|
47351
|
+
var fs45 = __toESM(require("fs"), 1);
|
|
47352
|
+
var path46 = __toESM(require("path"), 1);
|
|
46878
47353
|
function generateSkills(configPath, opts) {
|
|
46879
47354
|
const config2 = loadConfig(configPath);
|
|
46880
47355
|
const toolsWithSkills = config2.tools.filter((t) => t.skill);
|
|
@@ -46891,11 +47366,11 @@ ${content}
|
|
|
46891
47366
|
`);
|
|
46892
47367
|
} else {
|
|
46893
47368
|
const outDir = opts.output || ".claude/skills/zlt";
|
|
46894
|
-
if (!
|
|
46895
|
-
|
|
47369
|
+
if (!fs45.existsSync(outDir)) {
|
|
47370
|
+
fs45.mkdirSync(outDir, { recursive: true });
|
|
46896
47371
|
}
|
|
46897
|
-
const filePath =
|
|
46898
|
-
|
|
47372
|
+
const filePath = path46.join(outDir, `zlt-${tool.name.replace(/_/g, "-")}.md`);
|
|
47373
|
+
fs45.writeFileSync(filePath, content);
|
|
46899
47374
|
process.stderr.write(`Generated: ${filePath}
|
|
46900
47375
|
`);
|
|
46901
47376
|
}
|
|
@@ -47607,19 +48082,19 @@ var StdioServerTransport = class {
|
|
|
47607
48082
|
};
|
|
47608
48083
|
|
|
47609
48084
|
// src/mcp-server.ts
|
|
47610
|
-
var
|
|
47611
|
-
var
|
|
47612
|
-
var
|
|
48085
|
+
var fs55 = __toESM(require("node:fs"), 1);
|
|
48086
|
+
var path57 = __toESM(require("node:path"), 1);
|
|
48087
|
+
var import_node_crypto27 = require("node:crypto");
|
|
47613
48088
|
|
|
47614
48089
|
// src/clientlite-uninstall-tool.ts
|
|
47615
48090
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
47616
48091
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
47617
48092
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
47618
48093
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
47619
|
-
var
|
|
48094
|
+
var import_node_crypto21 = require("node:crypto");
|
|
47620
48095
|
init_dist();
|
|
47621
48096
|
function clientLiteUninstallPlanToken(plan) {
|
|
47622
|
-
return (0,
|
|
48097
|
+
return (0, import_node_crypto21.createHash)("sha256").update(JSON.stringify(plan)).digest("hex");
|
|
47623
48098
|
}
|
|
47624
48099
|
async function executeClientLiteUninstallTool(root2, args, store, operations = { plan: planClientLiteUninstall, uninstall: uninstallClientLite }) {
|
|
47625
48100
|
const plan = operations.plan(root2, store);
|
|
@@ -47689,39 +48164,39 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
47689
48164
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
47690
48165
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
47691
48166
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
47692
|
-
var
|
|
48167
|
+
var fs46 = __toESM(require("node:fs"), 1);
|
|
47693
48168
|
var os12 = __toESM(require("node:os"), 1);
|
|
47694
|
-
var
|
|
48169
|
+
var path47 = __toESM(require("node:path"), 1);
|
|
47695
48170
|
var import_node_child_process17 = require("node:child_process");
|
|
47696
|
-
var
|
|
47697
|
-
var DEFAULT_TASK_ROOT =
|
|
48171
|
+
var import_node_crypto22 = require("node:crypto");
|
|
48172
|
+
var DEFAULT_TASK_ROOT = path47.join(os12.tmpdir(), "zlt-mcp-install-tasks");
|
|
47698
48173
|
var STARTUP_GRACE_MS = 3e4;
|
|
47699
48174
|
function unsafeTaskDirectory(directory) {
|
|
47700
48175
|
return new Error(`Unsafe Linux install task directory: ${directory}`);
|
|
47701
48176
|
}
|
|
47702
48177
|
function linuxTaskRoot(create) {
|
|
47703
48178
|
const requestedHome = process.env.HOME || os12.homedir();
|
|
47704
|
-
if (!
|
|
47705
|
-
const home =
|
|
48179
|
+
if (!path47.isAbsolute(requestedHome)) throw unsafeTaskDirectory(requestedHome);
|
|
48180
|
+
const home = path47.resolve(requestedHome);
|
|
47706
48181
|
const uid2 = process.geteuid();
|
|
47707
|
-
const homeStat =
|
|
48182
|
+
const homeStat = fs46.lstatSync(home);
|
|
47708
48183
|
if (!homeStat.isDirectory() || homeStat.uid !== uid2 || homeStat.mode & 18) throw unsafeTaskDirectory(home);
|
|
47709
|
-
for (let ancestor =
|
|
47710
|
-
const stat2 =
|
|
48184
|
+
for (let ancestor = path47.dirname(home); ; ancestor = path47.dirname(ancestor)) {
|
|
48185
|
+
const stat2 = fs46.lstatSync(ancestor);
|
|
47711
48186
|
if (!stat2.isDirectory() || stat2.uid !== uid2 && stat2.uid !== 0 || stat2.mode & 18 && !(stat2.mode & 512)) throw unsafeTaskDirectory(ancestor);
|
|
47712
|
-
if (
|
|
48187
|
+
if (path47.dirname(ancestor) === ancestor) break;
|
|
47713
48188
|
}
|
|
47714
|
-
const state2 =
|
|
47715
|
-
const root2 =
|
|
48189
|
+
const state2 = path47.join(home, ".zltquant");
|
|
48190
|
+
const root2 = path47.join(state2, "install-tasks");
|
|
47716
48191
|
for (const directory of [state2, root2]) {
|
|
47717
48192
|
if (create) {
|
|
47718
48193
|
try {
|
|
47719
|
-
|
|
48194
|
+
fs46.mkdirSync(directory, { mode: 448 });
|
|
47720
48195
|
} catch (error2) {
|
|
47721
48196
|
if (error2.code !== "EEXIST") throw error2;
|
|
47722
48197
|
}
|
|
47723
48198
|
}
|
|
47724
|
-
const stat2 =
|
|
48199
|
+
const stat2 = fs46.lstatSync(directory, { throwIfNoEntry: false });
|
|
47725
48200
|
if (!stat2) return root2;
|
|
47726
48201
|
if (!stat2.isDirectory() || stat2.uid !== uid2 || (directory === root2 ? (stat2.mode & 511) !== 448 : stat2.mode & 18)) throw unsafeTaskDirectory(directory);
|
|
47727
48202
|
}
|
|
@@ -47731,24 +48206,24 @@ function taskRoot(create = false) {
|
|
|
47731
48206
|
const override = process.env.ZLT_MCP_INSTALL_TASK_ROOT;
|
|
47732
48207
|
if (!override && process.platform === "linux") return linuxTaskRoot(create);
|
|
47733
48208
|
const root2 = override || DEFAULT_TASK_ROOT;
|
|
47734
|
-
if (create)
|
|
48209
|
+
if (create) fs46.mkdirSync(root2, { recursive: true });
|
|
47735
48210
|
return root2;
|
|
47736
48211
|
}
|
|
47737
48212
|
function taskPath(taskId) {
|
|
47738
|
-
return
|
|
48213
|
+
return path47.join(taskRoot(), `${taskId}.json`);
|
|
47739
48214
|
}
|
|
47740
48215
|
function write(record7) {
|
|
47741
|
-
const target =
|
|
48216
|
+
const target = path47.join(taskRoot(true), `${record7.taskId}.json`);
|
|
47742
48217
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
47743
|
-
|
|
48218
|
+
fs46.writeFileSync(temporary, `${JSON.stringify(record7)}
|
|
47744
48219
|
`, "utf8");
|
|
47745
|
-
|
|
48220
|
+
fs46.renameSync(temporary, target);
|
|
47746
48221
|
}
|
|
47747
48222
|
function readRaw(taskId) {
|
|
47748
48223
|
if (!/^[A-Za-z0-9_-]+$/.test(taskId)) return void 0;
|
|
47749
48224
|
const target = taskPath(taskId);
|
|
47750
48225
|
try {
|
|
47751
|
-
const record7 = JSON.parse(
|
|
48226
|
+
const record7 = JSON.parse(fs46.readFileSync(target, "utf8"));
|
|
47752
48227
|
return record7.taskId === taskId ? record7 : void 0;
|
|
47753
48228
|
} catch {
|
|
47754
48229
|
return void 0;
|
|
@@ -47780,7 +48255,7 @@ function readInstallTask(taskId) {
|
|
|
47780
48255
|
let pid = current.workerPid;
|
|
47781
48256
|
if (!pid) {
|
|
47782
48257
|
try {
|
|
47783
|
-
pid = Number(
|
|
48258
|
+
pid = Number(fs46.readFileSync(`${taskPath(taskId)}.pid`, "utf8"));
|
|
47784
48259
|
} catch {
|
|
47785
48260
|
}
|
|
47786
48261
|
}
|
|
@@ -47790,11 +48265,11 @@ function readInstallTask(taskId) {
|
|
|
47790
48265
|
return fail2(taskId, INTERRUPTED);
|
|
47791
48266
|
}
|
|
47792
48267
|
function startInstallTask(entrypoint, argsJson, spawnProcess = import_node_child_process17.spawn) {
|
|
47793
|
-
const lock3 =
|
|
48268
|
+
const lock3 = path47.join(taskRoot(true), ".launch-lock");
|
|
47794
48269
|
const deadline = Date.now() + 3e3;
|
|
47795
48270
|
while (true) {
|
|
47796
48271
|
try {
|
|
47797
|
-
|
|
48272
|
+
fs46.mkdirSync(lock3);
|
|
47798
48273
|
break;
|
|
47799
48274
|
} catch (error2) {
|
|
47800
48275
|
if (error2.code !== "EEXIST") throw error2;
|
|
@@ -47803,11 +48278,11 @@ function startInstallTask(entrypoint, argsJson, spawnProcess = import_node_child
|
|
|
47803
48278
|
}
|
|
47804
48279
|
}
|
|
47805
48280
|
try {
|
|
47806
|
-
|
|
48281
|
+
fs46.writeFileSync(path47.join(lock3, "owner.json"), JSON.stringify({ pid: process.pid, createdAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx" });
|
|
47807
48282
|
return startLocked(entrypoint, argsJson, spawnProcess);
|
|
47808
48283
|
} finally {
|
|
47809
|
-
|
|
47810
|
-
|
|
48284
|
+
fs46.rmSync(path47.join(lock3, "owner.json"), { force: true });
|
|
48285
|
+
fs46.rmdirSync(lock3);
|
|
47811
48286
|
}
|
|
47812
48287
|
}
|
|
47813
48288
|
function startLocked(entrypoint, argsJson, spawnProcess) {
|
|
@@ -47818,15 +48293,15 @@ function startLocked(entrypoint, argsJson, spawnProcess) {
|
|
|
47818
48293
|
function installRequestKey(args) {
|
|
47819
48294
|
const normalized = { ...args };
|
|
47820
48295
|
if (typeof normalized.installDir === "string") {
|
|
47821
|
-
const resolved =
|
|
48296
|
+
const resolved = path47.resolve(normalized.installDir);
|
|
47822
48297
|
normalized.installDir = process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
47823
48298
|
}
|
|
47824
|
-
return (0,
|
|
48299
|
+
return (0, import_node_crypto22.createHash)("sha256").update(JSON.stringify(Object.keys(normalized).sort().map((key2) => [key2, normalized[key2]]))).update(args.installType === "clientlite" && !args.releaseIdentity ? process.env.ZLT_CLIENTLITE_LOCAL_INPUTS ?? "" : "").digest("hex");
|
|
47825
48300
|
}
|
|
47826
48301
|
function launchLocked(entrypoint, argsJson, args, requestKey, spawnProcess) {
|
|
47827
48302
|
let files = [];
|
|
47828
48303
|
try {
|
|
47829
|
-
files =
|
|
48304
|
+
files = fs46.readdirSync(taskRoot());
|
|
47830
48305
|
} catch (error2) {
|
|
47831
48306
|
if (error2.code !== "ENOENT") throw error2;
|
|
47832
48307
|
}
|
|
@@ -47849,7 +48324,7 @@ function launchLocked(entrypoint, argsJson, args, requestKey, spawnProcess) {
|
|
|
47849
48324
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
47850
48325
|
launcherPid: process.pid,
|
|
47851
48326
|
requestKey,
|
|
47852
|
-
logPath:
|
|
48327
|
+
logPath: path47.join(taskRoot(), `${taskId}.log`),
|
|
47853
48328
|
installType: args.installType === "clientlite" ? "clientlite" : "assistant",
|
|
47854
48329
|
...args.operation === "update" || args.operation === "recover" ? { operation: args.operation } : {},
|
|
47855
48330
|
...typeof args.releaseIdentity === "string" ? { releaseIdentity: args.releaseIdentity } : {}
|
|
@@ -47857,7 +48332,7 @@ function launchLocked(entrypoint, argsJson, args, requestKey, spawnProcess) {
|
|
|
47857
48332
|
write(record7);
|
|
47858
48333
|
let logFd;
|
|
47859
48334
|
try {
|
|
47860
|
-
logFd =
|
|
48335
|
+
logFd = fs46.openSync(record7.logPath, "a");
|
|
47861
48336
|
const child = spawnProcess(process.execPath, [entrypoint, "__install-worker", taskId, argsJson], {
|
|
47862
48337
|
detached: true,
|
|
47863
48338
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -47870,12 +48345,12 @@ function launchLocked(entrypoint, argsJson, args, requestKey, spawnProcess) {
|
|
|
47870
48345
|
child.once("exit", (code, signal) => {
|
|
47871
48346
|
fail2(taskId, `${INTERRUPTED} (exit=${code}, signal=${signal})`);
|
|
47872
48347
|
});
|
|
47873
|
-
if (child.pid)
|
|
48348
|
+
if (child.pid) fs46.writeFileSync(`${taskPath(taskId)}.pid`, String(child.pid), "utf8");
|
|
47874
48349
|
child.unref();
|
|
47875
48350
|
} catch (error2) {
|
|
47876
48351
|
fail2(taskId, `\u5B89\u88C5\u5DE5\u4F5C\u8FDB\u7A0B\u542F\u52A8\u5931\u8D25: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
47877
48352
|
} finally {
|
|
47878
|
-
if (logFd !== void 0)
|
|
48353
|
+
if (logFd !== void 0) fs46.closeSync(logFd);
|
|
47879
48354
|
}
|
|
47880
48355
|
return readRaw(taskId);
|
|
47881
48356
|
}
|
|
@@ -47886,7 +48361,7 @@ async function runInstallWorker(taskId, argsJson, install2) {
|
|
|
47886
48361
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !current.requestKey || installRequestKey(parsed) !== current.requestKey) throw new Error("Install worker arguments differ from the queued request");
|
|
47887
48362
|
const claim = `${taskPath(taskId)}.worker-claim`;
|
|
47888
48363
|
const owner = `${process.pid} ${Math.random()}`;
|
|
47889
|
-
|
|
48364
|
+
fs46.writeFileSync(claim, owner, { flag: "wx" });
|
|
47890
48365
|
try {
|
|
47891
48366
|
const queued = readRaw(taskId);
|
|
47892
48367
|
if (!queued || queued.status !== "queued" || queued.requestKey !== current.requestKey) return;
|
|
@@ -47909,7 +48384,7 @@ async function runInstallWorker(taskId, argsJson, install2) {
|
|
|
47909
48384
|
} catch (error2) {
|
|
47910
48385
|
fail2(taskId, error2 instanceof Error ? error2.message : String(error2));
|
|
47911
48386
|
} finally {
|
|
47912
|
-
if (
|
|
48387
|
+
if (fs46.existsSync(claim) && fs46.readFileSync(claim, "utf8") === owner) fs46.unlinkSync(claim);
|
|
47913
48388
|
}
|
|
47914
48389
|
}
|
|
47915
48390
|
function updateInstallTask(taskId, update) {
|
|
@@ -47993,9 +48468,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
47993
48468
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
47994
48469
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
47995
48470
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
47996
|
-
var
|
|
47997
|
-
var
|
|
47998
|
-
var
|
|
48471
|
+
var fs51 = __toESM(require("node:fs"), 1);
|
|
48472
|
+
var path52 = __toESM(require("node:path"), 1);
|
|
48473
|
+
var import_node_crypto25 = require("node:crypto");
|
|
47999
48474
|
|
|
48000
48475
|
// src/feature-set.ts
|
|
48001
48476
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
@@ -48013,9 +48488,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
48013
48488
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
48014
48489
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
48015
48490
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
48016
|
-
var
|
|
48017
|
-
var
|
|
48018
|
-
var
|
|
48491
|
+
var fs47 = __toESM(require("node:fs"), 1);
|
|
48492
|
+
var path48 = __toESM(require("node:path"), 1);
|
|
48493
|
+
var import_node_crypto23 = require("node:crypto");
|
|
48019
48494
|
var BACKTEST_CONFIG_KEYS = [
|
|
48020
48495
|
"start",
|
|
48021
48496
|
"end",
|
|
@@ -48060,13 +48535,13 @@ function readBacktestBaseline(tool, args) {
|
|
|
48060
48535
|
if (!create && tool !== "mcp-re-backtest") return void 0;
|
|
48061
48536
|
const directory = args[create ? "strategyPath" : "codePath"];
|
|
48062
48537
|
if (directory === void 0) return void 0;
|
|
48063
|
-
if (typeof directory !== "string" || !
|
|
48064
|
-
const root2 =
|
|
48065
|
-
if (create &&
|
|
48538
|
+
if (typeof directory !== "string" || !path48.isAbsolute(directory)) throw new Error("Configuration baseline requires an absolute directory path");
|
|
48539
|
+
const root2 = fs47.realpathSync(directory);
|
|
48540
|
+
if (create && path48.basename(path48.dirname(root2)).toLowerCase() === "backtest") {
|
|
48066
48541
|
throw new Error("strategyPath must identify the strategy root, not a historical backtest directory");
|
|
48067
48542
|
}
|
|
48068
|
-
const file2 =
|
|
48069
|
-
const raw =
|
|
48543
|
+
const file2 = path48.join(root2, ".vscode", "tradesetting.json");
|
|
48544
|
+
const raw = fs47.readFileSync(file2);
|
|
48070
48545
|
let config2;
|
|
48071
48546
|
try {
|
|
48072
48547
|
config2 = JSON.parse(raw.toString("utf8").replace(/^\uFEFF/, ""));
|
|
@@ -48103,7 +48578,7 @@ function readBacktestBaseline(tool, args) {
|
|
|
48103
48578
|
return { params, evidence: {
|
|
48104
48579
|
kind: create ? "strategy_current" : "selected_run",
|
|
48105
48580
|
path: file2,
|
|
48106
|
-
sha256: (0,
|
|
48581
|
+
sha256: (0, import_node_crypto23.createHash)("sha256").update(raw).digest("hex")
|
|
48107
48582
|
} };
|
|
48108
48583
|
}
|
|
48109
48584
|
function reconcileBaselineCapital(params, overrides) {
|
|
@@ -48130,8 +48605,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
48130
48605
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
48131
48606
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
48132
48607
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
48133
|
-
var
|
|
48134
|
-
var
|
|
48608
|
+
var fs48 = __toESM(require("node:fs"), 1);
|
|
48609
|
+
var path49 = __toESM(require("node:path"), 1);
|
|
48135
48610
|
var MAX_TAIL_BYTES = 128 * 1024;
|
|
48136
48611
|
var FUTURE_SKEW_MS = 5e3;
|
|
48137
48612
|
function beijingTimestamp(value) {
|
|
@@ -48146,22 +48621,22 @@ function readBacktestExecutionProgress(input2) {
|
|
|
48146
48621
|
const { runId, codePath, attemptStartedAtMs, nowMs = Date.now() } = input2;
|
|
48147
48622
|
if (!runId || !codePath || !Number.isFinite(attemptStartedAtMs) || attemptStartedAtMs <= 0 || !Number.isFinite(nowMs)) return void 0;
|
|
48148
48623
|
try {
|
|
48149
|
-
const config2 = JSON.parse(
|
|
48624
|
+
const config2 = JSON.parse(fs48.readFileSync(path49.join(codePath, ".vscode", "tradesetting.json"), "utf8"));
|
|
48150
48625
|
if (config2?.backtest_id !== runId) return void 0;
|
|
48151
|
-
const fd =
|
|
48626
|
+
const fd = fs48.openSync(path49.join(codePath, "log", "strategy.log"), "r");
|
|
48152
48627
|
let text3;
|
|
48153
48628
|
try {
|
|
48154
|
-
const before =
|
|
48629
|
+
const before = fs48.fstatSync(fd);
|
|
48155
48630
|
if (!before.isFile()) return void 0;
|
|
48156
48631
|
const start = Math.max(0, before.size - MAX_TAIL_BYTES);
|
|
48157
48632
|
const buffer = Buffer.alloc(Math.min(before.size, MAX_TAIL_BYTES));
|
|
48158
|
-
const count2 =
|
|
48159
|
-
if (
|
|
48633
|
+
const count2 = fs48.readSync(fd, buffer, 0, buffer.length, start);
|
|
48634
|
+
if (fs48.fstatSync(fd).size < before.size) return void 0;
|
|
48160
48635
|
text3 = buffer.subarray(0, count2).toString("utf8");
|
|
48161
48636
|
if (start > 0) text3 = text3.slice(text3.indexOf("\n") + 1);
|
|
48162
48637
|
text3 = text3.slice(0, text3.lastIndexOf("\n") + 1);
|
|
48163
48638
|
} finally {
|
|
48164
|
-
|
|
48639
|
+
fs48.closeSync(fd);
|
|
48165
48640
|
}
|
|
48166
48641
|
let latest;
|
|
48167
48642
|
for (const line of text3.split("\n")) {
|
|
@@ -48184,12 +48659,12 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
48184
48659
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
48185
48660
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
48186
48661
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
48187
|
-
var
|
|
48188
|
-
var
|
|
48662
|
+
var fs49 = __toESM(require("node:fs"), 1);
|
|
48663
|
+
var path50 = __toESM(require("node:path"), 1);
|
|
48189
48664
|
var STRATEGY_DOCS_TOOLS = /* @__PURE__ */ new Set(["mcp-create-strategy", "mcp-create-strategy-with-template"]);
|
|
48190
48665
|
function resolveStrategyDocsPath(clientRootDir, preparedDocsPath) {
|
|
48191
48666
|
if (!clientRootDir) return void 0;
|
|
48192
|
-
const docsPath = preparedDocsPath ??
|
|
48667
|
+
const docsPath = preparedDocsPath ?? path50.join(
|
|
48193
48668
|
clientRootDir,
|
|
48194
48669
|
"python",
|
|
48195
48670
|
"Lib",
|
|
@@ -48199,7 +48674,7 @@ function resolveStrategyDocsPath(clientRootDir, preparedDocsPath) {
|
|
|
48199
48674
|
"docs"
|
|
48200
48675
|
);
|
|
48201
48676
|
try {
|
|
48202
|
-
if (!
|
|
48677
|
+
if (!fs49.existsSync(docsPath)) return void 0;
|
|
48203
48678
|
} catch {
|
|
48204
48679
|
return void 0;
|
|
48205
48680
|
}
|
|
@@ -48216,7 +48691,7 @@ function injectDebugRunId(tool, result) {
|
|
|
48216
48691
|
const localPath = typeof parsed.Data.localPath === "string" ? parsed.Data.localPath.trim() : "";
|
|
48217
48692
|
if (!localPath) return result;
|
|
48218
48693
|
const settings = JSON.parse(
|
|
48219
|
-
|
|
48694
|
+
fs49.readFileSync(path50.join(localPath, ".vscode", "tradesetting.json"), "utf8")
|
|
48220
48695
|
);
|
|
48221
48696
|
const debugRunId = isRecord2(settings) && typeof settings.backtest_id === "string" ? settings.backtest_id.trim() : "";
|
|
48222
48697
|
if (!debugRunId) return result;
|
|
@@ -48628,9 +49103,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
48628
49103
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
48629
49104
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
48630
49105
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
48631
|
-
var
|
|
48632
|
-
var
|
|
48633
|
-
var
|
|
49106
|
+
var fs50 = __toESM(require("node:fs"), 1);
|
|
49107
|
+
var path51 = __toESM(require("node:path"), 1);
|
|
49108
|
+
var import_node_crypto24 = require("node:crypto");
|
|
48634
49109
|
async function executeSteps(steps, client2, initialBody, timeout, repairHint = identityRepairHint, toolName, onNativeStartDispatch) {
|
|
48635
49110
|
let body = { ...initialBody };
|
|
48636
49111
|
for (let i2 = 0; i2 < steps.length; i2++) {
|
|
@@ -48773,12 +49248,12 @@ function preflightCreatedBacktestSource(toolName, body) {
|
|
|
48773
49248
|
if (toolName !== "mcp-create-and-run-backtest") return null;
|
|
48774
49249
|
const runId = typeof body.runId === "string" ? body.runId.trim() : "";
|
|
48775
49250
|
const codePath = typeof body.codePath === "string" ? body.codePath.trim() : "";
|
|
48776
|
-
if (!codePath || !
|
|
48777
|
-
const sourcePath =
|
|
48778
|
-
if (!
|
|
49251
|
+
if (!codePath || !fs50.existsSync(codePath)) return null;
|
|
49252
|
+
const sourcePath = path51.join(codePath, "main.py");
|
|
49253
|
+
if (!fs50.existsSync(sourcePath)) return null;
|
|
48779
49254
|
let source;
|
|
48780
49255
|
try {
|
|
48781
|
-
source =
|
|
49256
|
+
source = fs50.readFileSync(sourcePath, "utf8");
|
|
48782
49257
|
} catch (error2) {
|
|
48783
49258
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
48784
49259
|
return jsonToolResult(10061, "\u56DE\u6D4B\u4EE3\u7801\u5FEB\u7167\u65E0\u6CD5\u8BFB\u53D6\uFF0C\u672A\u542F\u52A8\u7B56\u7565\u5F15\u64CE\u3002", {
|
|
@@ -48798,7 +49273,7 @@ function preflightCreatedBacktestSource(toolName, body) {
|
|
|
48798
49273
|
codePath,
|
|
48799
49274
|
sourcePath,
|
|
48800
49275
|
sourcePreflight: "blocked",
|
|
48801
|
-
sourceSha256: (0,
|
|
49276
|
+
sourceSha256: (0, import_node_crypto24.createHash)("sha256").update(source).digest("hex"),
|
|
48802
49277
|
violations,
|
|
48803
49278
|
userAction: "\u628A current_data.get(security) \u6539\u4E3A current_data[security]\uFF0C\u5E76\u7528 KeyError \u5904\u7406\u7F3A\u5931\u8BC1\u5238\uFF1B\u7136\u540E\u91CD\u65B0\u521B\u5EFA\u5E76\u8FD0\u884C\u56DE\u6D4B\u3002"
|
|
48804
49279
|
}, true);
|
|
@@ -48923,7 +49398,7 @@ function validateToolCallArguments(tool, args) {
|
|
|
48923
49398
|
}
|
|
48924
49399
|
function validateDataRangeArguments(args) {
|
|
48925
49400
|
const errors = [];
|
|
48926
|
-
const error2 = (
|
|
49401
|
+
const error2 = (path64, message) => errors.push({ path: path64, message });
|
|
48927
49402
|
const input2 = stripControlParams(args, "mcp-get-data-range");
|
|
48928
49403
|
for (const key2 of Object.keys(input2)) {
|
|
48929
49404
|
if (key2 !== "params") error2(`$.${key2}`, "Unsupported top-level field; query combinations belong in params[]. Date filters are not accepted.");
|
|
@@ -49223,18 +49698,18 @@ function backtestWindowPreflightError(tool, reason, message, details) {
|
|
|
49223
49698
|
}, true);
|
|
49224
49699
|
}
|
|
49225
49700
|
function isExistingAbsoluteDirectory(value) {
|
|
49226
|
-
if (!value || !
|
|
49701
|
+
if (!value || !path52.isAbsolute(value)) return false;
|
|
49227
49702
|
try {
|
|
49228
|
-
return
|
|
49703
|
+
return fs51.statSync(value).isDirectory();
|
|
49229
49704
|
} catch {
|
|
49230
49705
|
return false;
|
|
49231
49706
|
}
|
|
49232
49707
|
}
|
|
49233
49708
|
function readBacktestIdFromCodePath(codePath) {
|
|
49234
49709
|
try {
|
|
49235
|
-
const tradesettingPath =
|
|
49236
|
-
if (!
|
|
49237
|
-
const parsed = JSON.parse(
|
|
49710
|
+
const tradesettingPath = path52.join(codePath, ".vscode", "tradesetting.json");
|
|
49711
|
+
if (!fs51.existsSync(tradesettingPath)) return void 0;
|
|
49712
|
+
const parsed = JSON.parse(fs51.readFileSync(tradesettingPath, "utf-8"));
|
|
49238
49713
|
if (!isRecord2(parsed)) return void 0;
|
|
49239
49714
|
const value = parsed.backtest_id ?? parsed.backtestId;
|
|
49240
49715
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -49709,18 +50184,18 @@ function applyBacktestResultGuards(tool, args, result, states, contexts, activeR
|
|
|
49709
50184
|
}
|
|
49710
50185
|
function readRunResultFile(codePath) {
|
|
49711
50186
|
try {
|
|
49712
|
-
const resultPath =
|
|
49713
|
-
if (!
|
|
49714
|
-
const before =
|
|
49715
|
-
const raw =
|
|
49716
|
-
const after =
|
|
50187
|
+
const resultPath = path52.join(codePath, "log", "result.json");
|
|
50188
|
+
if (!fs51.existsSync(resultPath)) return null;
|
|
50189
|
+
const before = fs51.statSync(resultPath);
|
|
50190
|
+
const raw = fs51.readFileSync(resultPath);
|
|
50191
|
+
const after = fs51.statSync(resultPath);
|
|
49717
50192
|
if (before.mtimeMs !== after.mtimeMs || before.size !== after.size) return null;
|
|
49718
50193
|
const parsed = JSON.parse(raw.toString("utf-8"));
|
|
49719
50194
|
if (!isRecord2(parsed)) return null;
|
|
49720
50195
|
return {
|
|
49721
50196
|
data: parsed,
|
|
49722
50197
|
identity: {
|
|
49723
|
-
sha256: (0,
|
|
50198
|
+
sha256: (0, import_node_crypto25.createHash)("sha256").update(raw).digest("hex"),
|
|
49724
50199
|
mtimeMs: after.mtimeMs,
|
|
49725
50200
|
size: after.size
|
|
49726
50201
|
}
|
|
@@ -49928,9 +50403,9 @@ function echoResolvedBacktestConfig(tool, args, result, contexts) {
|
|
|
49928
50403
|
function hashBacktestSource(codePath) {
|
|
49929
50404
|
if (!codePath) return void 0;
|
|
49930
50405
|
try {
|
|
49931
|
-
const sourcePath =
|
|
49932
|
-
if (!
|
|
49933
|
-
return (0,
|
|
50406
|
+
const sourcePath = path52.join(codePath, "main.py");
|
|
50407
|
+
if (!fs51.statSync(sourcePath).isFile()) return void 0;
|
|
50408
|
+
return (0, import_node_crypto25.createHash)("sha256").update(fs51.readFileSync(sourcePath)).digest("hex");
|
|
49934
50409
|
} catch {
|
|
49935
50410
|
return void 0;
|
|
49936
50411
|
}
|
|
@@ -50071,33 +50546,33 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
50071
50546
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
50072
50547
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
50073
50548
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
50074
|
-
var
|
|
50075
|
-
var
|
|
50549
|
+
var fs52 = __toESM(require("node:fs"), 1);
|
|
50550
|
+
var path53 = __toESM(require("node:path"), 1);
|
|
50076
50551
|
var import_node_child_process18 = require("node:child_process");
|
|
50077
50552
|
function resolveFactorParquetPython(clientRoot) {
|
|
50078
|
-
if (!
|
|
50553
|
+
if (!path53.isAbsolute(clientRoot)) throw new Error("\u56E0\u5B50\u8BFB\u53D6\u9700\u8981\u5DF2\u9009\u5B89\u88C5\u7684\u7EDD\u5BF9\u8DEF\u5F84");
|
|
50079
50554
|
if (process.platform === "darwin") {
|
|
50080
50555
|
const values = /* @__PURE__ */ new Map();
|
|
50081
|
-
for (const line of
|
|
50556
|
+
for (const line of fs52.readFileSync(path53.join(clientRoot, "zltaf", "application-local.properties"), "utf8").split(/\r?\n/)) {
|
|
50082
50557
|
const match = line.match(/^\s*([^#!\s:=]+)\s*[:=]\s*(.*?)\s*$/);
|
|
50083
50558
|
if (match) values.set(match[1], match[2]);
|
|
50084
50559
|
}
|
|
50085
50560
|
const setting = (key2) => {
|
|
50086
50561
|
const value = values.get(key2);
|
|
50087
|
-
if (!value || !
|
|
50562
|
+
if (!value || !path53.isAbsolute(value) || /\$\{|%[^%]+%/.test(value)) throw new Error(`Prepared ClientLite requires absolute ${key2}`);
|
|
50088
50563
|
return value;
|
|
50089
50564
|
};
|
|
50090
|
-
if (
|
|
50565
|
+
if (fs52.realpathSync(setting("slave.install-path")) !== fs52.realpathSync(clientRoot)) throw new Error("ClientLite install path conflicts with selected root");
|
|
50091
50566
|
const python2 = setting("slave.python-path");
|
|
50092
|
-
if (!
|
|
50093
|
-
|
|
50567
|
+
if (!fs52.statSync(python2).isFile()) throw new Error("Prepared Python missing");
|
|
50568
|
+
fs52.accessSync(python2, fs52.constants.X_OK);
|
|
50094
50569
|
return python2;
|
|
50095
50570
|
}
|
|
50096
|
-
const xml =
|
|
50571
|
+
const xml = fs52.readFileSync(path53.join(clientRoot, "InstallInfo.xml"), "latin1");
|
|
50097
50572
|
const clientLite = /<InstallType(?:\s[^>]*)?>\s*clientlite\s*<\/InstallType\s*>/i.test(xml);
|
|
50098
|
-
const python =
|
|
50099
|
-
const relative13 =
|
|
50100
|
-
if (!relative13 || relative13.startsWith("..") ||
|
|
50573
|
+
const python = path53.join(clientRoot, "python", ...clientLite ? ["Scripts"] : [], "python.exe");
|
|
50574
|
+
const relative13 = path53.relative(fs52.realpathSync(clientRoot), fs52.realpathSync(python));
|
|
50575
|
+
if (!relative13 || relative13.startsWith("..") || path53.isAbsolute(relative13) || !fs52.statSync(python).isFile()) {
|
|
50101
50576
|
throw new Error("\u56E0\u5B50\u8BFB\u53D6Python\u4E0D\u5C5E\u4E8E\u6240\u9009\u5B89\u88C5");
|
|
50102
50577
|
}
|
|
50103
50578
|
return python;
|
|
@@ -50190,7 +50665,7 @@ async function readFactorParquet(python, request3) {
|
|
|
50190
50665
|
timeout: 3e4,
|
|
50191
50666
|
maxBuffer: 512 * 1024,
|
|
50192
50667
|
env,
|
|
50193
|
-
cwd:
|
|
50668
|
+
cwd: path53.dirname(python)
|
|
50194
50669
|
}, (error2, stdout) => {
|
|
50195
50670
|
if (error2) return reject(new Error("\u6240\u9009\u5B89\u88C5\u7684Python\u672A\u80FD\u8BFB\u53D6\u4EA7\u7269\uFF0C\u8BF7\u6838\u5BF9pyarrow\u3001\u6587\u4EF6\u683C\u5F0F\u548C\u8BFB\u53D6\u9650\u989D\uFF1B\u672A\u5B89\u88C5\u4F9D\u8D56\u6216\u91CD\u8DD1\u8BA1\u7B97\u3002"));
|
|
50196
50671
|
try {
|
|
@@ -50237,11 +50712,11 @@ async function fillFactorValuesFromParquet(base, args, storageRoot, clientRoot,
|
|
|
50237
50712
|
if (segments.length !== 5 || segments.some((s2) => !s2 || s2 === "." || s2 === ".." || s2.includes(":")) || segments[3] !== "\u65E5\u7EBF" || segments[4] !== "\u622A\u9762" || segments[2] !== outputs[0].outputName) {
|
|
50238
50713
|
throw new Error("\u5F53\u524D\u53EA\u8BFB\u9002\u914D\u4EC5\u652F\u6301\u5E73\u53F0\u8FD4\u56DE\u7684\u7814\u53D1\u65E5\u7EBF\u622A\u9762\u8DEF\u5F84");
|
|
50239
50714
|
}
|
|
50240
|
-
if (!
|
|
50241
|
-
const canonicalRoot2 =
|
|
50242
|
-
const folder =
|
|
50243
|
-
const relative13 =
|
|
50244
|
-
if (!relative13 || relative13.startsWith("..") ||
|
|
50715
|
+
if (!path53.isAbsolute(storageRoot) || !path53.isAbsolute(clientRoot)) throw new Error("\u6240\u9009\u5B89\u88C5\u6216\u5B58\u50A8\u76EE\u5F55\u4E0D\u662F\u7EDD\u5BF9\u8DEF\u5F84");
|
|
50716
|
+
const canonicalRoot2 = fs52.realpathSync(storageRoot);
|
|
50717
|
+
const folder = fs52.realpathSync(path53.join(canonicalRoot2, ...segments));
|
|
50718
|
+
const relative13 = path53.relative(canonicalRoot2, folder);
|
|
50719
|
+
if (!relative13 || relative13.startsWith("..") || path53.isAbsolute(relative13)) throw new Error("\u4EA7\u7269\u76EE\u5F55\u8D85\u51FA\u9009\u5B9A\u5B58\u50A8\u76EE\u5F55");
|
|
50245
50720
|
const limit = args.limit === void 0 ? 100 : args.limit;
|
|
50246
50721
|
if (!Number.isInteger(limit) || limit <= 0) throw new Error("limit\u5FC5\u987B\u4E3A\u6B63\u6574\u6570");
|
|
50247
50722
|
if (args.stockCodes !== void 0 && (!Array.isArray(args.stockCodes) || args.stockCodes.length > 1e3 || args.stockCodes.some((code) => typeof code !== "string" || code.length > 80))) throw new Error("\u8BC1\u5238\u7B5B\u9009\u8D85\u51FA\u652F\u6301\u8303\u56F4");
|
|
@@ -50300,7 +50775,7 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
50300
50775
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
50301
50776
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
50302
50777
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
50303
|
-
var
|
|
50778
|
+
var import_node_crypto26 = require("node:crypto");
|
|
50304
50779
|
|
|
50305
50780
|
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
50306
50781
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
@@ -50362,8 +50837,8 @@ async function random(size) {
|
|
|
50362
50837
|
const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
|
|
50363
50838
|
let result = "";
|
|
50364
50839
|
while (result.length < size) {
|
|
50365
|
-
const
|
|
50366
|
-
for (const randomByte of
|
|
50840
|
+
const randomBytes3 = await getRandomValues(size - result.length);
|
|
50841
|
+
for (const randomByte of randomBytes3) {
|
|
50367
50842
|
if (randomByte < evenDistCutoff) {
|
|
50368
50843
|
result += mask[randomByte % mask.length];
|
|
50369
50844
|
}
|
|
@@ -51526,13 +52001,13 @@ var StreamableHTTPClientTransport = class {
|
|
|
51526
52001
|
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
51527
52002
|
return;
|
|
51528
52003
|
}
|
|
51529
|
-
const
|
|
52004
|
+
const delay5 = this._getNextReconnectionDelay(attemptCount);
|
|
51530
52005
|
this._reconnectionTimeout = setTimeout(() => {
|
|
51531
52006
|
this._startOrAuthSse(options).catch((error2) => {
|
|
51532
52007
|
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
51533
52008
|
this._scheduleReconnection(options, attemptCount + 1);
|
|
51534
52009
|
});
|
|
51535
|
-
},
|
|
52010
|
+
}, delay5);
|
|
51536
52011
|
}
|
|
51537
52012
|
_handleSseStream(stream, options, isReconnectable) {
|
|
51538
52013
|
if (!stream) {
|
|
@@ -52097,7 +52572,7 @@ var RemoteMarketMcp = class {
|
|
|
52097
52572
|
if (!session2.users) void this.closeSession(session2);
|
|
52098
52573
|
}
|
|
52099
52574
|
acquire(credentials) {
|
|
52100
|
-
const identity2 = (0,
|
|
52575
|
+
const identity2 = (0, import_node_crypto26.createHash)("sha256").update(JSON.stringify(credentials)).digest("hex");
|
|
52101
52576
|
if (this.current?.identity === identity2 && !this.current.retired) {
|
|
52102
52577
|
this.current.users++;
|
|
52103
52578
|
return this.current;
|
|
@@ -52490,21 +52965,21 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
52490
52965
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
52491
52966
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
52492
52967
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
52493
|
-
var
|
|
52494
|
-
var
|
|
52968
|
+
var fs53 = __toESM(require("node:fs"), 1);
|
|
52969
|
+
var path54 = __toESM(require("node:path"), 1);
|
|
52495
52970
|
var import_node_child_process19 = require("node:child_process");
|
|
52496
52971
|
var import_node_util3 = require("node:util");
|
|
52497
52972
|
var exec = (0, import_node_util3.promisify)(import_node_child_process19.execFile);
|
|
52498
52973
|
var DEFAULT_GIT_IDENTITY = { "user.name": "ZLTQuant", "user.email": "zltquant@users.noreply.local" };
|
|
52499
52974
|
async function ensureStrategyGitIdentity(directory, gitCommand) {
|
|
52500
|
-
if (!
|
|
52501
|
-
const root2 =
|
|
52502
|
-
if (!
|
|
52975
|
+
if (!path54.isAbsolute(directory)) throw new Error("Strategy Git identity requires an absolute directory");
|
|
52976
|
+
const root2 = fs53.realpathSync.native(directory);
|
|
52977
|
+
if (!fs53.existsSync(path54.join(root2, ".git"))) return;
|
|
52503
52978
|
const env = { ...process.env };
|
|
52504
52979
|
for (const key2 of ["GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR", "GIT_INDEX_FILE"]) delete env[key2];
|
|
52505
52980
|
const git = (args) => exec(gitCommand, ["-C", root2, ...args], { env, timeout: 1e4, windowsHide: true });
|
|
52506
52981
|
const top = (await git(["rev-parse", "--show-toplevel"])).stdout.trim();
|
|
52507
|
-
if (
|
|
52982
|
+
if (path54.relative(root2, fs53.realpathSync.native(top)) !== "") throw new Error("Strategy path does not identify its Git repository root");
|
|
52508
52983
|
let configScope = "--local";
|
|
52509
52984
|
try {
|
|
52510
52985
|
if ((await git(["config", "--bool", "--get", "extensions.worktreeConfig"])).stdout.trim() === "true") {
|
|
@@ -53106,11 +53581,11 @@ var LinuxZltafClient = class extends ZltafIpcClient {
|
|
|
53106
53581
|
};
|
|
53107
53582
|
function validateLinuxProjectPath(root2, value, strategyId) {
|
|
53108
53583
|
if (value === void 0 || value === "") return;
|
|
53109
|
-
if (typeof value !== "string" || !
|
|
53110
|
-
const projects =
|
|
53111
|
-
if (
|
|
53112
|
-
const relative13 =
|
|
53113
|
-
if (!relative13 || relative13 === ".." || relative13.startsWith("../") ||
|
|
53584
|
+
if (typeof value !== "string" || !path57.isAbsolute(value)) throw new Error("Linux strategy or run path must be absolute");
|
|
53585
|
+
const projects = path57.join(root2, "Users/projects");
|
|
53586
|
+
if (fs55.realpathSync(projects) !== projects) throw new Error("Linux projects path must belong to the selected installation");
|
|
53587
|
+
const relative13 = path57.relative(projects, fs55.realpathSync(value));
|
|
53588
|
+
if (!relative13 || relative13 === ".." || relative13.startsWith("../") || path57.isAbsolute(relative13)) {
|
|
53114
53589
|
throw new Error("Linux strategy or run path is outside the selected ClientLite projects");
|
|
53115
53590
|
}
|
|
53116
53591
|
const [strategy, ...rest] = relative13.split("/");
|
|
@@ -53155,9 +53630,9 @@ async function startMcpServer(options = {}) {
|
|
|
53155
53630
|
let processRoot;
|
|
53156
53631
|
const canonicalRoot2 = (root2) => {
|
|
53157
53632
|
try {
|
|
53158
|
-
return
|
|
53633
|
+
return fs55.realpathSync.native(root2);
|
|
53159
53634
|
} catch {
|
|
53160
|
-
return
|
|
53635
|
+
return path57.resolve(root2);
|
|
53161
53636
|
}
|
|
53162
53637
|
};
|
|
53163
53638
|
const resolveSelectedRoot2 = async () => {
|
|
@@ -53802,7 +54277,7 @@ async function startMcpServer(options = {}) {
|
|
|
53802
54277
|
return settleStatus(special);
|
|
53803
54278
|
}
|
|
53804
54279
|
const taskType = asyncTaskType(name, toolArgs);
|
|
53805
|
-
const attemptId = (0,
|
|
54280
|
+
const attemptId = (0, import_node_crypto27.randomUUID)();
|
|
53806
54281
|
const pendingOwner = taskType && runtimeLease ? `${taskType}:pending:${process.pid}:${++pendingSequence}` : void 0;
|
|
53807
54282
|
const pendingJob = taskType && registeredClientLite ? `pending:${attemptId}` : void 0;
|
|
53808
54283
|
const ownerLease = runtimeLease;
|
|
@@ -53990,7 +54465,7 @@ async function handleWorkspaceTool(name, args, store, binding, boundRoot) {
|
|
|
53990
54465
|
if (!selected) throw new Error("Unknown workspace");
|
|
53991
54466
|
await store.selectDefault(selected.workspace.workspaceId);
|
|
53992
54467
|
const current = binding.current;
|
|
53993
|
-
const normalizeRoot = (root2) => process.platform === "win32" ?
|
|
54468
|
+
const normalizeRoot = (root2) => process.platform === "win32" ? path57.resolve(root2).toLowerCase() : path57.resolve(root2);
|
|
53994
54469
|
const sameRoot2 = !boundRoot || normalizeRoot(boundRoot) === normalizeRoot(selected.installation.root);
|
|
53995
54470
|
const reconnectRequired = current ? current.workspace.workspaceId !== selected.workspace.workspaceId : !sameRoot2;
|
|
53996
54471
|
return jsonToolResult(0, "", {
|
|
@@ -54377,7 +54852,7 @@ async function handleRuntimeTool(handler, args, runtimeConfig, acquireRuntime, i
|
|
|
54377
54852
|
let clientliteArgs;
|
|
54378
54853
|
if (args.installType === "clientlite") {
|
|
54379
54854
|
if (process.env.ZLT_CLIENTLITE_LOCAL_INPUTS) {
|
|
54380
|
-
if (typeof args.installDir !== "string" || !
|
|
54855
|
+
if (typeof args.installDir !== "string" || !path57.isAbsolute(args.installDir)) {
|
|
54381
54856
|
return jsonToolResult(10046, "Local ClientLite qualification requires an absolute fresh installDir", { toolExecution: "not_started" }, true);
|
|
54382
54857
|
}
|
|
54383
54858
|
} else {
|
|
@@ -54444,9 +54919,9 @@ function sameRootPath(left, right) {
|
|
|
54444
54919
|
const normalize5 = (value) => {
|
|
54445
54920
|
let resolved;
|
|
54446
54921
|
try {
|
|
54447
|
-
resolved =
|
|
54922
|
+
resolved = fs55.realpathSync.native(value);
|
|
54448
54923
|
} catch {
|
|
54449
|
-
resolved =
|
|
54924
|
+
resolved = path57.resolve(value);
|
|
54450
54925
|
}
|
|
54451
54926
|
const normalized = resolved.replace(/[\\/]+$/, "");
|
|
54452
54927
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
@@ -54753,7 +55228,7 @@ function isExplicitFullPipeName2(value) {
|
|
|
54753
55228
|
function inspectDoctorAuth() {
|
|
54754
55229
|
try {
|
|
54755
55230
|
const auth2 = getAuthStatus();
|
|
54756
|
-
const invalidFile = !auth2.configured &&
|
|
55231
|
+
const invalidFile = !auth2.configured && fs55.existsSync(auth2.credentialsPath);
|
|
54757
55232
|
return {
|
|
54758
55233
|
configured: auth2.configured,
|
|
54759
55234
|
status: auth2.configured ? "configured" : invalidFile ? "invalid-config" : "missing",
|
|
@@ -54899,19 +55374,19 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
54899
55374
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
54900
55375
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
54901
55376
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
54902
|
-
var
|
|
54903
|
-
var
|
|
55377
|
+
var fs56 = __toESM(require("node:fs"), 1);
|
|
55378
|
+
var path58 = __toESM(require("node:path"), 1);
|
|
54904
55379
|
init_dist();
|
|
54905
55380
|
function readClientLiteLocalInputs(file2 = process.env.ZLT_CLIENTLITE_LOCAL_INPUTS) {
|
|
54906
|
-
if (!file2 || !
|
|
54907
|
-
if (
|
|
54908
|
-
const input2 = JSON.parse(
|
|
55381
|
+
if (!file2 || !path58.isAbsolute(file2)) throw new Error("ClientLite public installation is not qualified. Set ZLT_CLIENTLITE_LOCAL_INPUTS to an absolute local qualification JSON path.");
|
|
55382
|
+
if (fs56.statSync(file2).size > 16384) throw new Error("ClientLite local input file is too large");
|
|
55383
|
+
const input2 = JSON.parse(fs56.readFileSync(file2, "utf8"));
|
|
54909
55384
|
if (!input2 || typeof input2 !== "object" || Array.isArray(input2)) throw new Error("Invalid ClientLite local inputs");
|
|
54910
55385
|
const keys = ["archivePath", "archiveSha256", "lockPath", "lockSha256", "wheelhouse"];
|
|
54911
55386
|
if (Object.keys(input2).some((key2) => !keys.includes(key2))) throw new Error("Unknown ClientLite local input");
|
|
54912
55387
|
for (const key2 of keys) {
|
|
54913
55388
|
const value = input2[key2];
|
|
54914
|
-
if (typeof value !== "string" || (key2.endsWith("Sha256") ? !/^[a-f0-9]{64}$/i.test(value) : !
|
|
55389
|
+
if (typeof value !== "string" || (key2.endsWith("Sha256") ? !/^[a-f0-9]{64}$/i.test(value) : !path58.isAbsolute(value))) {
|
|
54915
55390
|
throw new Error(`Invalid ClientLite local input: ${key2}`);
|
|
54916
55391
|
}
|
|
54917
55392
|
}
|
|
@@ -54919,7 +55394,7 @@ function readClientLiteLocalInputs(file2 = process.env.ZLT_CLIENTLITE_LOCAL_INPU
|
|
|
54919
55394
|
}
|
|
54920
55395
|
async function installLocalClientLite(args, config2, onProgress) {
|
|
54921
55396
|
if (args.confirm !== true) throw new Error("ClientLite installation requires confirm=true");
|
|
54922
|
-
if (typeof args.installDir !== "string" || !
|
|
55397
|
+
if (typeof args.installDir !== "string" || !path58.isAbsolute(args.installDir)) {
|
|
54923
55398
|
throw new Error("Local ClientLite qualification requires an explicit absolute fresh installDir");
|
|
54924
55399
|
}
|
|
54925
55400
|
const prepared = await prepareLocalClientLite({ ...readClientLiteLocalInputs(), installDir: args.installDir, onProgress });
|
|
@@ -54927,12 +55402,12 @@ async function installLocalClientLite(args, config2, onProgress) {
|
|
|
54927
55402
|
const lease = await acquireWindowsClientLiteRuntime(prepared.installDir, config2, { allowIncompleteQualification: true });
|
|
54928
55403
|
const released = await releaseRuntimeLease(lease);
|
|
54929
55404
|
if (!released.stopped) throw new Error(`ClientLite qualification cleanup incomplete: ${released.reason}`);
|
|
54930
|
-
|
|
54931
|
-
|
|
55405
|
+
fs56.writeFileSync(
|
|
55406
|
+
path58.join(prepared.installDir, "clientlite-native-qualification.json"),
|
|
54932
55407
|
JSON.stringify({ ...prepared, status: "native-handshakes-passed", selected: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
54933
55408
|
{ flag: "wx" }
|
|
54934
55409
|
);
|
|
54935
|
-
|
|
55410
|
+
fs56.unlinkSync(path58.join(prepared.installDir, ".clientlite-incomplete"));
|
|
54936
55411
|
onProgress("Local ClientLite qualified; select this root explicitly for subsequent calls. Public release remains unqualified.");
|
|
54937
55412
|
return prepared.installDir;
|
|
54938
55413
|
}
|
|
@@ -54942,7 +55417,7 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
54942
55417
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
54943
55418
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
54944
55419
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
54945
|
-
var
|
|
55420
|
+
var path59 = __toESM(require("node:path"), 1);
|
|
54946
55421
|
init_dist();
|
|
54947
55422
|
init_dist();
|
|
54948
55423
|
async function installNpmClientLite(args, config2, onProgress, beforeQualification) {
|
|
@@ -54956,11 +55431,11 @@ async function installNpmClientLite(args, config2, onProgress, beforeQualificati
|
|
|
54956
55431
|
}
|
|
54957
55432
|
const entrypoint = resolveCliEntrypoint();
|
|
54958
55433
|
if (!entrypoint) throw new Error("Private Linux CLI entrypoint is unavailable");
|
|
54959
|
-
const assets =
|
|
55434
|
+
const assets = path59.join(path59.dirname(entrypoint), "linux-clientlite-install");
|
|
54960
55435
|
return installClientLiteRelease(args, config2, onProgress, release, beforeQualification, {
|
|
54961
|
-
script:
|
|
54962
|
-
nativeTarball:
|
|
54963
|
-
pugixml:
|
|
55436
|
+
script: path59.join(assets, "prepare-linux-clientlite-release.py"),
|
|
55437
|
+
nativeTarball: path59.join(assets, "clientlite-native.tgz"),
|
|
55438
|
+
pugixml: path59.join(assets, "libpugixml.so.1")
|
|
54964
55439
|
});
|
|
54965
55440
|
}
|
|
54966
55441
|
|
|
@@ -54969,8 +55444,8 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
54969
55444
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
54970
55445
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
54971
55446
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
54972
|
-
var
|
|
54973
|
-
var
|
|
55447
|
+
var fs57 = __toESM(require("node:fs"), 1);
|
|
55448
|
+
var path60 = __toESM(require("node:path"), 1);
|
|
54974
55449
|
init_dist();
|
|
54975
55450
|
function components(release) {
|
|
54976
55451
|
const result = {
|
|
@@ -54994,8 +55469,8 @@ function components(release) {
|
|
|
54994
55469
|
return result;
|
|
54995
55470
|
}
|
|
54996
55471
|
function physical4(file2) {
|
|
54997
|
-
let resolved =
|
|
54998
|
-
if (
|
|
55472
|
+
let resolved = path60.resolve(file2);
|
|
55473
|
+
if (fs57.existsSync(resolved)) resolved = fs57.realpathSync.native(resolved);
|
|
54999
55474
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
55000
55475
|
}
|
|
55001
55476
|
function runtimeDataPaths(root2, registered) {
|
|
@@ -55017,11 +55492,11 @@ function clientLiteUpdatePlan(options = {}, dependencies) {
|
|
|
55017
55492
|
if (selected.installation.kind !== "clientlite") {
|
|
55018
55493
|
throw new Error("Full/mini installations use Assistant module updates; ClientLite update cannot modify them");
|
|
55019
55494
|
}
|
|
55020
|
-
const receiptPath =
|
|
55021
|
-
const stat2 =
|
|
55495
|
+
const receiptPath = path60.join(selected.installation.root, "clientlite-npm-receipt.json");
|
|
55496
|
+
const stat2 = fs57.lstatSync(receiptPath);
|
|
55022
55497
|
if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > 32 * 1024 * 1024) throw new Error("Unsafe ClientLite receipt; preserve the installation for inspection");
|
|
55023
|
-
const receipt = JSON.parse(
|
|
55024
|
-
if (receipt.status !== "native-qualified" ||
|
|
55498
|
+
const receipt = JSON.parse(fs57.readFileSync(receiptPath, "utf8"));
|
|
55499
|
+
if (receipt.status !== "native-qualified" || fs57.existsSync(path60.join(selected.installation.root, ".clientlite-incomplete"))) {
|
|
55025
55500
|
throw new Error("Current ClientLite installation is incomplete or unqualified; inspect the original install task");
|
|
55026
55501
|
}
|
|
55027
55502
|
validateClientLiteRelease(receipt.release, receipt.release?.channel);
|
|
@@ -55108,9 +55583,9 @@ init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
|
55108
55583
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
55109
55584
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
55110
55585
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
55111
|
-
var
|
|
55112
|
-
var
|
|
55113
|
-
var
|
|
55586
|
+
var fs58 = __toESM(require("node:fs"), 1);
|
|
55587
|
+
var path61 = __toESM(require("node:path"), 1);
|
|
55588
|
+
var import_node_crypto28 = require("node:crypto");
|
|
55114
55589
|
var import_node_child_process20 = require("node:child_process");
|
|
55115
55590
|
init_dist();
|
|
55116
55591
|
var SOFTWARE2 = [
|
|
@@ -55133,44 +55608,44 @@ var softwareEntries = () => [.../* @__PURE__ */ new Set([
|
|
|
55133
55608
|
function state(root2) {
|
|
55134
55609
|
let current = root2;
|
|
55135
55610
|
for (const name of ["Temporary", "zlt-mcp-runtime"]) {
|
|
55136
|
-
current =
|
|
55137
|
-
if (
|
|
55138
|
-
const stat2 =
|
|
55611
|
+
current = path61.join(current, name);
|
|
55612
|
+
if (fs58.existsSync(current)) {
|
|
55613
|
+
const stat2 = fs58.lstatSync(current);
|
|
55139
55614
|
if (stat2.isSymbolicLink() || !stat2.isDirectory()) throw new Error("Redirected ClientLite update state directory");
|
|
55140
55615
|
}
|
|
55141
55616
|
}
|
|
55142
55617
|
return current;
|
|
55143
55618
|
}
|
|
55144
|
-
var journalPath = (root2) =>
|
|
55619
|
+
var journalPath = (root2) => path61.join(state(root2), "update-journal.json");
|
|
55145
55620
|
function save(j) {
|
|
55146
|
-
const file2 = journalPath(j.root), temp = file2 + "." + (0,
|
|
55147
|
-
const fd =
|
|
55621
|
+
const file2 = journalPath(j.root), temp = file2 + "." + (0, import_node_crypto28.randomUUID)() + ".tmp";
|
|
55622
|
+
const fd = fs58.openSync(temp, "wx", 384);
|
|
55148
55623
|
try {
|
|
55149
|
-
|
|
55150
|
-
|
|
55624
|
+
fs58.writeFileSync(fd, JSON.stringify(j, null, 2) + "\n");
|
|
55625
|
+
fs58.fsyncSync(fd);
|
|
55151
55626
|
} finally {
|
|
55152
|
-
|
|
55627
|
+
fs58.closeSync(fd);
|
|
55153
55628
|
}
|
|
55154
|
-
|
|
55629
|
+
fs58.renameSync(temp, file2);
|
|
55155
55630
|
}
|
|
55156
55631
|
var INPUTS = [".clientlite-input-archive.zip", ".clientlite-input-native.zip", ".clientlite-input-python.tar.gz", ".clientlite-input-lock.txt", ".clientlite-incomplete"];
|
|
55157
55632
|
function regularTree(file2) {
|
|
55158
|
-
const stat2 =
|
|
55633
|
+
const stat2 = fs58.lstatSync(file2);
|
|
55159
55634
|
if (stat2.isSymbolicLink() || !stat2.isFile() && !stat2.isDirectory()) throw new Error(`Unsafe upgrade data path: ${file2}`);
|
|
55160
|
-
if (stat2.isDirectory()) for (const name of
|
|
55635
|
+
if (stat2.isDirectory()) for (const name of fs58.readdirSync(file2)) regularTree(path61.join(file2, name));
|
|
55161
55636
|
}
|
|
55162
55637
|
function copyData(from, to) {
|
|
55163
55638
|
regularTree(from);
|
|
55164
|
-
|
|
55639
|
+
fs58.cpSync(from, to, { recursive: true, errorOnExist: true, force: false, preserveTimestamps: true });
|
|
55165
55640
|
}
|
|
55166
55641
|
function validateJournal(j, root2) {
|
|
55167
|
-
if (j.schemaVersion !== 1 || j.root !== root2 || !/^[a-f0-9-]{36}$/i.test(j.token) ||
|
|
55168
|
-
if (
|
|
55642
|
+
if (j.schemaVersion !== 1 || j.root !== root2 || !/^[a-f0-9-]{36}$/i.test(j.token) || path61.dirname(j.backup) !== path61.dirname(root2) || !path61.basename(j.backup).startsWith(path61.basename(root2) + ".upgrade-") || j.originalSoftware.some((name) => !softwareEntries().includes(name))) throw new Error("Unsafe ClientLite upgrade journal");
|
|
55643
|
+
if (fs58.lstatSync(j.backup).isSymbolicLink()) throw new Error("Redirected upgrade backup");
|
|
55169
55644
|
validateClientLiteDataLocations(j.dataPaths, root2);
|
|
55170
55645
|
}
|
|
55171
55646
|
function assertClientLiteProcessesStopped(root2, platform = process.platform) {
|
|
55172
55647
|
if (platform === "win32") {
|
|
55173
|
-
const powershell =
|
|
55648
|
+
const powershell = path61.join(process.env.SystemRoot || "C:\\Windows", "System32/WindowsPowerShell/v1.0/powershell.exe");
|
|
55174
55649
|
const result = (0, import_node_child_process20.spawnSync)(
|
|
55175
55650
|
powershell,
|
|
55176
55651
|
[
|
|
@@ -55193,7 +55668,7 @@ function assertClientLiteProcessesStopped(root2, platform = process.platform) {
|
|
|
55193
55668
|
const inspected = (0, import_node_child_process20.spawnSync)("/usr/sbin/lsof", ["-a", "-p", pid, "-d", "txt", "-Fpn"], { encoding: "utf8", timeout: 5e3 });
|
|
55194
55669
|
const lines = String(inspected.stdout ?? "").trim().split("\n");
|
|
55195
55670
|
const executables = lines.filter((line) => line.startsWith("n")).map((line) => line.slice(1));
|
|
55196
|
-
if (inspected.status !== 0 || lines[0] !== "p" + pid || !executables.length || executables.some((file2) => !
|
|
55671
|
+
if (inspected.status !== 0 || lines[0] !== "p" + pid || !executables.length || executables.some((file2) => !path61.isAbsolute(file2))) {
|
|
55197
55672
|
try {
|
|
55198
55673
|
process.kill(Number(pid), 0);
|
|
55199
55674
|
} catch (error2) {
|
|
@@ -55204,10 +55679,10 @@ function assertClientLiteProcessesStopped(root2, platform = process.platform) {
|
|
|
55204
55679
|
}
|
|
55205
55680
|
if (executables.some((file2) => {
|
|
55206
55681
|
try {
|
|
55207
|
-
file2 =
|
|
55682
|
+
file2 = fs58.realpathSync.native(file2);
|
|
55208
55683
|
} catch {
|
|
55209
55684
|
}
|
|
55210
|
-
return file2 === root2 || file2.startsWith(root2 +
|
|
55685
|
+
return file2 === root2 || file2.startsWith(root2 + path61.sep);
|
|
55211
55686
|
})) {
|
|
55212
55687
|
throw new Error("Selected ClientLite processes are running; stop them before updating");
|
|
55213
55688
|
}
|
|
@@ -55215,17 +55690,17 @@ function assertClientLiteProcessesStopped(root2, platform = process.platform) {
|
|
|
55215
55690
|
} else throw new Error("ClientLite update requires Windows x64 or macOS ARM64");
|
|
55216
55691
|
}
|
|
55217
55692
|
async function prefetch(proposal, progress) {
|
|
55218
|
-
const release = proposal.release, cache =
|
|
55693
|
+
const release = proposal.release, cache = path61.join(sharedDiscoveryHome(), "cache");
|
|
55219
55694
|
if (release.platform === "linux") throw new Error("Linux ClientLite in-place updates are not qualified");
|
|
55220
55695
|
const downloads = [acquireClientLiteNativePayload({
|
|
55221
55696
|
release,
|
|
55222
|
-
cacheDir:
|
|
55697
|
+
cacheDir: path61.join(cache, "clientlite-npm"),
|
|
55223
55698
|
onProgress: progress,
|
|
55224
55699
|
...release.nativeNpmRegistry ? { registryUrl: release.nativeNpmRegistry } : {}
|
|
55225
55700
|
})];
|
|
55226
|
-
if ("pipSdk" in release) downloads.push(acquireClientLitePipSdk({ sdk: release.pipSdk, cacheDir:
|
|
55227
|
-
else downloads.push(acquireClientLiteNpmPayloads({ release, cacheDir:
|
|
55228
|
-
if (release.platform === "darwin") downloads.push(acquireClientLitePythonArchive(release.python,
|
|
55701
|
+
if ("pipSdk" in release) downloads.push(acquireClientLitePipSdk({ sdk: release.pipSdk, cacheDir: path61.join(cache, "clientlite-pip"), onProgress: progress }));
|
|
55702
|
+
else downloads.push(acquireClientLiteNpmPayloads({ release, cacheDir: path61.join(cache, "clientlite-npm"), onProgress: progress }));
|
|
55703
|
+
if (release.platform === "darwin") downloads.push(acquireClientLitePythonArchive(release.python, path61.join(cache, "clientlite-python"), void 0, progress));
|
|
55229
55704
|
else downloads.push(prepareClientLiteReleaseToolchains({ python: release.python, git: release.git }, proposal.toolchainPlan, { onProgress: progress }));
|
|
55230
55705
|
const results = await Promise.allSettled(downloads);
|
|
55231
55706
|
for (const result of results) if (result.status === "rejected") throw result.reason;
|
|
@@ -55243,59 +55718,59 @@ function defaults() {
|
|
|
55243
55718
|
}
|
|
55244
55719
|
function restoreDatabasesBeforeQualification(j) {
|
|
55245
55720
|
for (const relative13 of ["moudles/dcm.json", "zlthost/moudles/dcm.json"]) {
|
|
55246
|
-
const original =
|
|
55247
|
-
if (!
|
|
55248
|
-
const old = JSON.parse(
|
|
55249
|
-
const current =
|
|
55721
|
+
const original = path61.join(j.backup, relative13), target = path61.join(j.root, relative13);
|
|
55722
|
+
if (!fs58.existsSync(original)) continue;
|
|
55723
|
+
const old = JSON.parse(fs58.readFileSync(original, "utf8"));
|
|
55724
|
+
const current = fs58.existsSync(target) ? JSON.parse(fs58.readFileSync(target, "utf8")) : {};
|
|
55250
55725
|
if (!old || Array.isArray(old) || typeof old !== "object" || !current || Array.isArray(current) || typeof current !== "object") throw new Error("Invalid native data-manager configuration");
|
|
55251
|
-
|
|
55252
|
-
|
|
55726
|
+
fs58.mkdirSync(path61.dirname(target), { recursive: true });
|
|
55727
|
+
fs58.writeFileSync(target, JSON.stringify({ ...current, ...old, download_home: j.dataPaths.quantDataRoot }, null, 2) + "\n");
|
|
55253
55728
|
}
|
|
55254
55729
|
for (const component of ["zlthost", "zltaf"]) {
|
|
55255
|
-
const original =
|
|
55256
|
-
if (!
|
|
55257
|
-
const target =
|
|
55258
|
-
if (
|
|
55259
|
-
|
|
55260
|
-
|
|
55730
|
+
const original = path61.join(j.backup, component, "db");
|
|
55731
|
+
if (!fs58.existsSync(original)) continue;
|
|
55732
|
+
const target = path61.join(j.root, component, "db");
|
|
55733
|
+
if (fs58.existsSync(target)) {
|
|
55734
|
+
fs58.mkdirSync(path61.join(j.backup, "new-database-seeds"), { recursive: true });
|
|
55735
|
+
fs58.renameSync(target, path61.join(j.backup, "new-database-seeds", component));
|
|
55261
55736
|
}
|
|
55262
55737
|
copyData(original, target);
|
|
55263
55738
|
}
|
|
55264
|
-
const oldConfig =
|
|
55265
|
-
const newConfig =
|
|
55266
|
-
if (
|
|
55267
|
-
const preserved =
|
|
55739
|
+
const oldConfig = path61.join(j.backup, "zltaf/application-local.properties");
|
|
55740
|
+
const newConfig = path61.join(j.root, "zltaf/application-local.properties");
|
|
55741
|
+
if (fs58.existsSync(oldConfig) && fs58.existsSync(newConfig)) {
|
|
55742
|
+
const preserved = fs58.readFileSync(oldConfig, "utf8").split(/\r?\n/).filter((line) => /^\s*slave\.factor\./.test(line));
|
|
55268
55743
|
if (preserved.length) {
|
|
55269
|
-
const current =
|
|
55270
|
-
|
|
55744
|
+
const current = fs58.readFileSync(newConfig, "utf8").split(/\r?\n/).filter((line) => !/^\s*slave\.factor\./.test(line));
|
|
55745
|
+
fs58.writeFileSync(newConfig, [...current, ...preserved].join("\n"));
|
|
55271
55746
|
}
|
|
55272
55747
|
}
|
|
55273
55748
|
}
|
|
55274
55749
|
function restoreOldFiles(j) {
|
|
55275
55750
|
validateJournal(j, j.root);
|
|
55276
|
-
const failed =
|
|
55277
|
-
|
|
55751
|
+
const failed = path61.join(j.backup, "failed-new-software-" + (0, import_node_crypto28.randomUUID)());
|
|
55752
|
+
fs58.mkdirSync(failed);
|
|
55278
55753
|
for (const name of softwareEntries()) {
|
|
55279
|
-
const old =
|
|
55280
|
-
if (
|
|
55281
|
-
if (
|
|
55282
|
-
|
|
55283
|
-
} else if (!j.originalSoftware.includes(name) && j.stage !== "snapshot" &&
|
|
55284
|
-
|
|
55754
|
+
const old = path61.join(j.backup, name), current = path61.join(j.root, name);
|
|
55755
|
+
if (fs58.existsSync(old)) {
|
|
55756
|
+
if (fs58.existsSync(current)) fs58.renameSync(current, path61.join(failed, name));
|
|
55757
|
+
fs58.renameSync(old, current);
|
|
55758
|
+
} else if (!j.originalSoftware.includes(name) && j.stage !== "snapshot" && fs58.existsSync(current)) {
|
|
55759
|
+
fs58.renameSync(current, path61.join(failed, name));
|
|
55285
55760
|
}
|
|
55286
55761
|
}
|
|
55287
|
-
const db =
|
|
55288
|
-
if (j.dbSnapshotComplete &&
|
|
55289
|
-
j.quarantinedDatabase = db + ".failed-upgrade-" + (0,
|
|
55762
|
+
const db = path61.join(j.dataPaths.userDataRoot, "db"), snapshot = path61.join(j.backup, "user-db-snapshot");
|
|
55763
|
+
if (j.dbSnapshotComplete && fs58.existsSync(snapshot)) {
|
|
55764
|
+
j.quarantinedDatabase = db + ".failed-upgrade-" + (0, import_node_crypto28.randomUUID)();
|
|
55290
55765
|
save(j);
|
|
55291
|
-
if (
|
|
55766
|
+
if (fs58.existsSync(db)) fs58.renameSync(db, j.quarantinedDatabase);
|
|
55292
55767
|
copyData(snapshot, db);
|
|
55293
55768
|
}
|
|
55294
|
-
for (const name of INPUTS) if (
|
|
55769
|
+
for (const name of INPUTS) if (fs58.existsSync(path61.join(j.root, name))) fs58.renameSync(path61.join(j.root, name), path61.join(failed, name));
|
|
55295
55770
|
}
|
|
55296
55771
|
function releaseDeadFileLock(file2, expectedPid) {
|
|
55297
|
-
if (!
|
|
55298
|
-
const stat2 =
|
|
55772
|
+
if (!fs58.existsSync(file2)) return;
|
|
55773
|
+
const stat2 = fs58.lstatSync(file2), raw = fs58.readFileSync(file2, "utf8");
|
|
55299
55774
|
if (!stat2.isFile() || stat2.isSymbolicLink() || Number(raw.split(" ")[0]) !== expectedPid) throw new Error("Unexpected install lock; preserve it for inspection");
|
|
55300
55775
|
try {
|
|
55301
55776
|
process.kill(expectedPid, 0);
|
|
@@ -55303,28 +55778,28 @@ function releaseDeadFileLock(file2, expectedPid) {
|
|
|
55303
55778
|
} catch (error2) {
|
|
55304
55779
|
if (error2.code !== "ESRCH") throw error2;
|
|
55305
55780
|
}
|
|
55306
|
-
const again =
|
|
55307
|
-
if (again.dev !== stat2.dev || again.ino !== stat2.ino ||
|
|
55308
|
-
const retired = file2 + ".retired-" + (0,
|
|
55309
|
-
|
|
55310
|
-
if (
|
|
55781
|
+
const again = fs58.lstatSync(file2);
|
|
55782
|
+
if (again.dev !== stat2.dev || again.ino !== stat2.ino || fs58.readFileSync(file2, "utf8") !== raw) throw new Error("Install lock changed during recovery");
|
|
55783
|
+
const retired = file2 + ".retired-" + (0, import_node_crypto28.randomUUID)();
|
|
55784
|
+
fs58.renameSync(file2, retired);
|
|
55785
|
+
if (fs58.readFileSync(retired, "utf8") !== raw) throw new Error("Retired install lock identity changed; preserve recovery evidence");
|
|
55311
55786
|
}
|
|
55312
55787
|
async function installClientLiteInPlace(args, config2, progress, deps = defaults()) {
|
|
55313
55788
|
if (args.confirm !== true || typeof args.installDir !== "string" || typeof args.previousRelease !== "string") throw new Error("In-place update requires a confirmed original installation");
|
|
55314
|
-
const root2 =
|
|
55789
|
+
const root2 = fs58.realpathSync.native(args.installDir), selected = deps.store.resolve({ root: root2 });
|
|
55315
55790
|
state(root2);
|
|
55316
55791
|
if (!selected || selected.installation.kind !== "clientlite" || selected.installation.release !== args.previousRelease || selected.workspace.bindingGeneration !== args.expectedGeneration) throw new Error("Original update binding changed; preview again");
|
|
55317
55792
|
const proposal = deps.proposal(root2), targetRelease = clientLiteReleaseIdentity(proposal.release);
|
|
55318
55793
|
if (targetRelease !== args.releaseIdentity || targetRelease === args.previousRelease) throw new Error("Update release differs from the confirmed target");
|
|
55319
|
-
const receipt = JSON.parse(
|
|
55320
|
-
if (receipt.status !== "native-qualified" || receipt.releaseIdentity !== args.previousRelease || clientLiteReleaseIdentity(receipt.release) !== args.previousRelease ||
|
|
55794
|
+
const receipt = JSON.parse(fs58.readFileSync(path61.join(root2, "clientlite-npm-receipt.json"), "utf8"));
|
|
55795
|
+
if (receipt.status !== "native-qualified" || receipt.releaseIdentity !== args.previousRelease || clientLiteReleaseIdentity(receipt.release) !== args.previousRelease || fs58.existsSync(path61.join(root2, ".clientlite-incomplete"))) throw new Error("Original ClientLite receipt is not qualified");
|
|
55321
55796
|
const actual = process.platform === "darwin" ? clientLiteMacosSoftwareIdentity(root2) : clientLiteWindowsSoftwareHashes(root2);
|
|
55322
55797
|
const expected = process.platform === "darwin" ? receipt.softwareIdentity : receipt.softwareHashes;
|
|
55323
55798
|
if (JSON.stringify(actual) !== JSON.stringify(expected)) throw new Error("Original software differs from its receipt; update will not overwrite customizations");
|
|
55324
55799
|
const dataPaths = readClientLiteDataLocations(root2);
|
|
55325
55800
|
if (!dataPaths || selected.workspace.dataPaths && JSON.stringify(dataPaths) !== JSON.stringify(selected.workspace.dataPaths)) throw new Error("User/quant data locations are not consistently registered/configured");
|
|
55326
|
-
regularTree(
|
|
55327
|
-
for (const name of INPUTS) if (
|
|
55801
|
+
regularTree(path61.join(dataPaths.userDataRoot, "db"));
|
|
55802
|
+
for (const name of INPUTS) if (fs58.existsSync(path61.join(root2, name))) throw new Error("Previous prepare inputs remain; inspect or recover the original transaction");
|
|
55328
55803
|
progress("Downloading and verifying the confirmed release before entering maintenance");
|
|
55329
55804
|
await deps.prefetch(proposal, progress);
|
|
55330
55805
|
deps.stopped(root2);
|
|
@@ -55332,16 +55807,16 @@ async function installClientLiteInPlace(args, config2, progress, deps = defaults
|
|
|
55332
55807
|
try {
|
|
55333
55808
|
const current = deps.store.resolve({ root: root2 });
|
|
55334
55809
|
if (!current || current.installation.installationId !== selected.installation.installationId || current.workspace.workspaceId !== selected.workspace.workspaceId || current.installation.release !== args.previousRelease || current.workspace.bindingGeneration !== args.expectedGeneration) throw new Error("Original update binding changed; preview again");
|
|
55335
|
-
const currentReceipt = JSON.parse(
|
|
55810
|
+
const currentReceipt = JSON.parse(fs58.readFileSync(path61.join(root2, "clientlite-npm-receipt.json"), "utf8"));
|
|
55336
55811
|
const currentSoftware = process.platform === "darwin" ? clientLiteMacosSoftwareIdentity(root2) : clientLiteWindowsSoftwareHashes(root2);
|
|
55337
|
-
if (JSON.stringify(currentReceipt) !== JSON.stringify(receipt) || JSON.stringify(currentSoftware) !== JSON.stringify(expected) ||
|
|
55812
|
+
if (JSON.stringify(currentReceipt) !== JSON.stringify(receipt) || JSON.stringify(currentSoftware) !== JSON.stringify(expected) || fs58.existsSync(path61.join(root2, ".clientlite-incomplete")) || JSON.stringify(readClientLiteDataLocations(root2)) !== JSON.stringify(dataPaths) || current.workspace.dataPaths && JSON.stringify(current.workspace.dataPaths) !== JSON.stringify(dataPaths)) throw new Error("Original update inputs changed; preview again");
|
|
55338
55813
|
} catch (error2) {
|
|
55339
55814
|
await deps.finish(handle);
|
|
55340
55815
|
throw error2;
|
|
55341
55816
|
}
|
|
55342
|
-
const backup = `${root2}.upgrade-${(0,
|
|
55817
|
+
const backup = `${root2}.upgrade-${(0, import_node_crypto28.randomUUID)()}`;
|
|
55343
55818
|
try {
|
|
55344
|
-
|
|
55819
|
+
fs58.mkdirSync(backup);
|
|
55345
55820
|
} catch (error2) {
|
|
55346
55821
|
await deps.finish(handle);
|
|
55347
55822
|
throw error2;
|
|
@@ -55359,7 +55834,7 @@ async function installClientLiteInPlace(args, config2, progress, deps = defaults
|
|
|
55359
55834
|
previousRelease: String(args.previousRelease),
|
|
55360
55835
|
targetRelease,
|
|
55361
55836
|
dataPaths,
|
|
55362
|
-
originalSoftware: softwareEntries().filter((name) =>
|
|
55837
|
+
originalSoftware: softwareEntries().filter((name) => fs58.existsSync(path61.join(root2, name))),
|
|
55363
55838
|
dbSnapshotComplete: false
|
|
55364
55839
|
};
|
|
55365
55840
|
try {
|
|
@@ -55371,29 +55846,29 @@ async function installClientLiteInPlace(args, config2, progress, deps = defaults
|
|
|
55371
55846
|
let registryCommitted = false;
|
|
55372
55847
|
try {
|
|
55373
55848
|
deps.stopped(root2);
|
|
55374
|
-
const userDb =
|
|
55375
|
-
const disk =
|
|
55849
|
+
const userDb = path61.join(dataPaths.userDataRoot, "db");
|
|
55850
|
+
const disk = fs58.statfsSync(path61.dirname(root2));
|
|
55376
55851
|
let databaseBytes = 0;
|
|
55377
55852
|
const count2 = (dir2) => {
|
|
55378
|
-
for (const entry of
|
|
55379
|
-
const file2 =
|
|
55853
|
+
for (const entry of fs58.readdirSync(dir2, { withFileTypes: true })) {
|
|
55854
|
+
const file2 = path61.join(dir2, entry.name);
|
|
55380
55855
|
if (entry.isDirectory()) count2(file2);
|
|
55381
|
-
else databaseBytes +=
|
|
55856
|
+
else databaseBytes += fs58.statSync(file2).size;
|
|
55382
55857
|
}
|
|
55383
55858
|
};
|
|
55384
55859
|
count2(userDb);
|
|
55385
55860
|
if (disk.bavail * disk.bsize < proposal.downloadBytes * 3 + databaseBytes * 2) throw new Error("Insufficient space for software replacement and database rollback snapshot");
|
|
55386
|
-
const dataDisk =
|
|
55861
|
+
const dataDisk = fs58.statfsSync(dataPaths.userDataRoot);
|
|
55387
55862
|
if (dataDisk.bavail * dataDisk.bsize < databaseBytes) throw new Error("Insufficient data-volume space for recoverable database replacement");
|
|
55388
|
-
copyData(userDb,
|
|
55863
|
+
copyData(userDb, path61.join(backup, "user-db-snapshot"));
|
|
55389
55864
|
j.dbSnapshotComplete = true;
|
|
55390
55865
|
save(j);
|
|
55391
55866
|
j.stage = "replacing";
|
|
55392
55867
|
save(j);
|
|
55393
|
-
for (const name of j.originalSoftware)
|
|
55868
|
+
for (const name of j.originalSoftware) fs58.renameSync(path61.join(root2, name), path61.join(backup, name));
|
|
55394
55869
|
j.stage = "installing";
|
|
55395
55870
|
save(j);
|
|
55396
|
-
const pipeSuffix =
|
|
55871
|
+
const pipeSuffix = fs58.readFileSync(path61.join(root2, "Temporary/zlt"), "utf8").trim();
|
|
55397
55872
|
await deps.install(
|
|
55398
55873
|
{
|
|
55399
55874
|
...args,
|
|
@@ -55445,29 +55920,29 @@ async function installClientLiteInPlace(args, config2, progress, deps = defaults
|
|
|
55445
55920
|
}
|
|
55446
55921
|
}
|
|
55447
55922
|
async function recoverClientLiteInPlace(root2, deps = defaults()) {
|
|
55448
|
-
root2 =
|
|
55449
|
-
const lock3 =
|
|
55450
|
-
if (
|
|
55451
|
-
const pid = Number(
|
|
55923
|
+
root2 = fs58.realpathSync.native(root2);
|
|
55924
|
+
const lock3 = path61.join(state(root2), "recovery.lock");
|
|
55925
|
+
if (fs58.existsSync(lock3)) {
|
|
55926
|
+
const pid = Number(fs58.readFileSync(lock3, "utf8").split(" ")[0]);
|
|
55452
55927
|
if (!Number.isSafeInteger(pid) || pid <= 0) throw new Error("Invalid recovery lock; preserve it for inspection");
|
|
55453
55928
|
releaseDeadFileLock(lock3, pid);
|
|
55454
55929
|
}
|
|
55455
|
-
const raw = `${process.pid} ${(0,
|
|
55456
|
-
|
|
55930
|
+
const raw = `${process.pid} ${(0, import_node_crypto28.randomUUID)()}`;
|
|
55931
|
+
fs58.writeFileSync(lock3, raw, { flag: "wx", mode: 384 });
|
|
55457
55932
|
try {
|
|
55458
55933
|
return await recoverLocked(root2, deps);
|
|
55459
55934
|
} finally {
|
|
55460
|
-
if (!
|
|
55461
|
-
|
|
55935
|
+
if (!fs58.lstatSync(lock3).isFile() || fs58.lstatSync(lock3).isSymbolicLink() || fs58.readFileSync(lock3, "utf8") !== raw) throw new Error("Recovery lock changed; evidence retained");
|
|
55936
|
+
fs58.unlinkSync(lock3);
|
|
55462
55937
|
}
|
|
55463
55938
|
}
|
|
55464
55939
|
async function recoverLocked(root2, deps) {
|
|
55465
|
-
const gate =
|
|
55466
|
-
if (!
|
|
55467
|
-
const marker = JSON.parse(
|
|
55940
|
+
const gate = path61.join(state(root2), "update.json");
|
|
55941
|
+
if (!fs58.lstatSync(gate).isFile() || fs58.lstatSync(gate).isSymbolicLink()) throw new Error("Unsafe update recovery gate");
|
|
55942
|
+
const marker = JSON.parse(fs58.readFileSync(gate, "utf8"));
|
|
55468
55943
|
if (!Number.isInteger(marker.workerPid) || marker.workerPid <= 0 || !/^[a-f0-9-]{36}$/i.test(marker.token) || marker.status !== "preparing") throw new Error("Unsafe update recovery gate");
|
|
55469
|
-
if (
|
|
55470
|
-
let j =
|
|
55944
|
+
if (fs58.existsSync(journalPath(root2)) && (!fs58.lstatSync(journalPath(root2)).isFile() || fs58.lstatSync(journalPath(root2)).isSymbolicLink())) throw new Error("Unsafe update recovery journal");
|
|
55945
|
+
let j = fs58.existsSync(journalPath(root2)) ? JSON.parse(fs58.readFileSync(journalPath(root2), "utf8")) : null;
|
|
55471
55946
|
if (j) validateJournal(j, root2);
|
|
55472
55947
|
const previous = j && marker.token !== j.token && ["committed", "rolled-back"].includes(j.stage) ? j : null;
|
|
55473
55948
|
if (previous) j = null;
|
|
@@ -55484,16 +55959,16 @@ async function recoverLocked(root2, deps) {
|
|
|
55484
55959
|
const selected = deps.store.resolve({ root: root2 });
|
|
55485
55960
|
if (!selected) throw new Error("Recovery binding is not registered");
|
|
55486
55961
|
if (!j) {
|
|
55487
|
-
const receipt = JSON.parse(
|
|
55962
|
+
const receipt = JSON.parse(fs58.readFileSync(path61.join(root2, "clientlite-npm-receipt.json"), "utf8"));
|
|
55488
55963
|
const actual = process.platform === "darwin" ? clientLiteMacosSoftwareIdentity(root2) : clientLiteWindowsSoftwareHashes(root2);
|
|
55489
55964
|
if (receipt.status !== "native-qualified" || receipt.releaseIdentity !== selected.installation.release || JSON.stringify(actual) !== JSON.stringify(process.platform === "darwin" ? receipt.softwareIdentity : receipt.softwareHashes)) throw new Error("Initialization recovery requires an unchanged qualified installation");
|
|
55490
55965
|
if (previous && (selected.installation.installationId !== previous.installationId || selected.workspace.workspaceId !== previous.workspaceId || selected.installation.release !== (previous.stage === "committed" ? previous.targetRelease : previous.previousRelease) || selected.workspace.bindingGeneration !== previous.expectedGeneration)) throw new Error("Previous completed update binding changed; evidence retained");
|
|
55491
55966
|
} else if (selected.installation.installationId !== j.installationId || selected.workspace.workspaceId !== j.workspaceId || marker.token !== j.token) throw new Error("Recovery binding/gate changed; evidence retained");
|
|
55492
55967
|
const priorPid = j?.workerPid ?? marker.workerPid;
|
|
55493
55968
|
marker.workerPid = process.pid;
|
|
55494
|
-
const temp = gate + "." + (0,
|
|
55495
|
-
|
|
55496
|
-
|
|
55969
|
+
const temp = gate + "." + (0, import_node_crypto28.randomUUID)() + ".recovery.tmp";
|
|
55970
|
+
fs58.writeFileSync(temp, JSON.stringify(marker), { flag: "wx", mode: 384 });
|
|
55971
|
+
fs58.renameSync(temp, gate);
|
|
55497
55972
|
if (!j) {
|
|
55498
55973
|
await deps.finish({ workRoot: root2, token: marker.token, workerPid: process.pid });
|
|
55499
55974
|
return root2;
|
|
@@ -55502,7 +55977,7 @@ async function recoverLocked(root2, deps) {
|
|
|
55502
55977
|
j.workerPid = process.pid;
|
|
55503
55978
|
save(j);
|
|
55504
55979
|
if (selected.installation.release === j.targetRelease) {
|
|
55505
|
-
const receipt = JSON.parse(
|
|
55980
|
+
const receipt = JSON.parse(fs58.readFileSync(path61.join(root2, "clientlite-npm-receipt.json"), "utf8"));
|
|
55506
55981
|
const actual = process.platform === "darwin" ? clientLiteMacosSoftwareIdentity(root2) : clientLiteWindowsSoftwareHashes(root2);
|
|
55507
55982
|
if (receipt.releaseIdentity !== j.targetRelease || receipt.status !== "native-qualified" || selected.workspace.bindingGeneration !== j.expectedGeneration || JSON.stringify(actual) !== JSON.stringify(process.platform === "darwin" ? receipt.softwareIdentity : receipt.softwareHashes)) throw new Error("Committed update receipt/software is inconsistent");
|
|
55508
55983
|
j.stage = "committed";
|
|
@@ -55520,15 +55995,16 @@ async function recoverLocked(root2, deps) {
|
|
|
55520
55995
|
// src/index.ts
|
|
55521
55996
|
init_dist();
|
|
55522
55997
|
init_dist();
|
|
55998
|
+
init_dist();
|
|
55523
55999
|
|
|
55524
56000
|
// src/auth-cli.ts
|
|
55525
56001
|
init_define_CLIENTLITE_MACOS_NPM_RELEASE();
|
|
55526
56002
|
init_define_CLIENTLITE_NPM_RELEASE();
|
|
55527
56003
|
init_define_CLIENTLITE_PUBLIC_LINUX_ASSETS();
|
|
55528
56004
|
init_define_CLIENTLITE_PUBLIC_LINUX_RELEASE();
|
|
55529
|
-
var
|
|
55530
|
-
var
|
|
55531
|
-
var
|
|
56005
|
+
var fs59 = __toESM(require("node:fs"), 1);
|
|
56006
|
+
var path62 = __toESM(require("node:path"), 1);
|
|
56007
|
+
var import_node_crypto29 = require("node:crypto");
|
|
55532
56008
|
init_dist();
|
|
55533
56009
|
var SOURCE = "zlt-mcp-device-login";
|
|
55534
56010
|
var IGNORED_API_ENV = /* @__PURE__ */ new Set(["ZLTQUANT_API_KEY", "ZLTQUANT_API_BASE"]);
|
|
@@ -55560,14 +56036,14 @@ function buildShowWidgetPayload(s2) {
|
|
|
55560
56036
|
}
|
|
55561
56037
|
};
|
|
55562
56038
|
}
|
|
55563
|
-
var root = (e = process.env) =>
|
|
56039
|
+
var root = (e = process.env) => path62.join(resolveZltQuantHome(e), "device-auth-sessions");
|
|
55564
56040
|
function saveDeviceSession(s2, e = process.env) {
|
|
55565
56041
|
if (!validSession(s2)) throw new Error("Invalid authentication session");
|
|
55566
|
-
const id = (0,
|
|
55567
|
-
|
|
56042
|
+
const id = (0, import_node_crypto29.randomUUID)();
|
|
56043
|
+
fs59.mkdirSync(root(e), { recursive: true, mode: 448 });
|
|
55568
56044
|
protectPrivatePath(root(e), true);
|
|
55569
|
-
|
|
55570
|
-
|
|
56045
|
+
fs59.writeFileSync(
|
|
56046
|
+
path62.join(root(e), id + ".json"),
|
|
55571
56047
|
JSON.stringify({ authorization: s2, expiresAt: s2.issuedAt + s2.expiresIn * 1e3 }),
|
|
55572
56048
|
{ mode: 384, flag: "wx" }
|
|
55573
56049
|
);
|
|
@@ -55576,11 +56052,11 @@ function saveDeviceSession(s2, e = process.env) {
|
|
|
55576
56052
|
function load(id, e = process.env) {
|
|
55577
56053
|
sessionPath(id, e);
|
|
55578
56054
|
try {
|
|
55579
|
-
if (
|
|
56055
|
+
if (fs59.lstatSync(root(e)).isSymbolicLink()) throw Error();
|
|
55580
56056
|
const file2 = sessionPath(id, e);
|
|
55581
|
-
const stat2 =
|
|
56057
|
+
const stat2 = fs59.lstatSync(file2);
|
|
55582
56058
|
if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > 8192) throw Error();
|
|
55583
|
-
const saved = JSON.parse(
|
|
56059
|
+
const saved = JSON.parse(fs59.readFileSync(file2, "utf8"));
|
|
55584
56060
|
if (!saved || typeof saved !== "object" || !("authorization" in saved) || !validSession(saved.authorization)) throw Error();
|
|
55585
56061
|
return { authorization: saved.authorization };
|
|
55586
56062
|
} catch {
|
|
@@ -55603,13 +56079,13 @@ function authErrorMessage(error2) {
|
|
|
55603
56079
|
}
|
|
55604
56080
|
function sessionPath(id, e = process.env) {
|
|
55605
56081
|
if (!SESSION_ID.test(id)) throw Error("Invalid authentication session");
|
|
55606
|
-
return
|
|
56082
|
+
return path62.join(root(e), id + ".json");
|
|
55607
56083
|
}
|
|
55608
56084
|
function validateAuthSessionId(id) {
|
|
55609
56085
|
if (!SESSION_ID.test(id)) throw Error("Invalid authentication session");
|
|
55610
56086
|
}
|
|
55611
56087
|
function drop(id, e = process.env) {
|
|
55612
|
-
|
|
56088
|
+
fs59.rmSync(sessionPath(id, e), { force: true });
|
|
55613
56089
|
}
|
|
55614
56090
|
function preflight(e) {
|
|
55615
56091
|
if (e.ZLTQUANT_CREDENTIALS || readCredentials(e))
|
|
@@ -55668,7 +56144,7 @@ async function runAuthWait(id, o = {}) {
|
|
|
55668
56144
|
const lockPath = sessionPath(id, e) + ".lock";
|
|
55669
56145
|
let lock3;
|
|
55670
56146
|
try {
|
|
55671
|
-
lock3 =
|
|
56147
|
+
lock3 = fs59.openSync(lockPath, "wx", 384);
|
|
55672
56148
|
} catch {
|
|
55673
56149
|
throw Error("Authentication session is unavailable or already being waited on");
|
|
55674
56150
|
}
|
|
@@ -55681,8 +56157,8 @@ async function runAuthWait(id, o = {}) {
|
|
|
55681
56157
|
if (error2 instanceof DeviceAuthorizationError && ["expired_token", "access_denied"].includes(error2.code)) drop(id, e);
|
|
55682
56158
|
throw error2;
|
|
55683
56159
|
} finally {
|
|
55684
|
-
|
|
55685
|
-
|
|
56160
|
+
fs59.closeSync(lock3);
|
|
56161
|
+
fs59.rmSync(lockPath, { force: true });
|
|
55686
56162
|
}
|
|
55687
56163
|
}
|
|
55688
56164
|
var authStatus = (e = process.env) => getAuthStatus(authCliEnv(e));
|
|
@@ -55758,7 +56234,7 @@ if (process.argv.length <= 2) {
|
|
|
55758
56234
|
const workspaces = program2.command("runtime").description("Inspect research workspaces and prepare ClientLite prerequisites");
|
|
55759
56235
|
workspaces.command("update").description("Compare or update ClientLite in its existing directory, preserving registered user and quant data locations").option("--root <path>", "Registered current ClientLite root; otherwise use the bound root or default workspace").option("--install-dir <path>", "Must match the current installation root for an update").option("--confirm", "Confirm same-directory software replacement or explicit recovery").option("--recover", "Recover an interrupted update using its maintenance journal; requires --root and --confirm").option("--expect-release <sha256>", "Required with --confirm; exact target release identity from the preview").option("--agent-output <path>", "Save the complete component comparison and task receipt in a new JSON file").action((options) => {
|
|
55760
56236
|
agentOutput?.started();
|
|
55761
|
-
if (options.recover && (!options.confirm || !options.root || !
|
|
56237
|
+
if (options.recover && (!options.confirm || !options.root || !path63.isAbsolute(options.root))) throw new Error("Explicit recovery requires --root <absolute-path> and --confirm");
|
|
55762
56238
|
const result = options.recover ? (() => {
|
|
55763
56239
|
const task = startInstallTask(resolveCliEntrypoint(), JSON.stringify({
|
|
55764
56240
|
installType: "clientlite",
|
|
@@ -55789,7 +56265,7 @@ if (process.argv.length <= 2) {
|
|
|
55789
56265
|
workspaces.command("uninstall").description("Uninstall registered ClientLite software, preserving research data and credentials").option("--root <path>", "ClientLite root; otherwise use the selected workspace").option("--confirm", "Confirm the exact preview and stop only this installation\u2019s owned runtime").option("--installation-id <id>", "Exact installation.installationId from the preview").option("--expect-plan <sha256>", "Exact planToken from the preview").option("--recover", "Recover an interrupted uninstall; requires --root and --confirm").action(async (options) => {
|
|
55790
56266
|
if (process.platform !== "win32" && process.platform !== "darwin") throw new Error("ClientLite uninstall and recovery require Windows or macOS");
|
|
55791
56267
|
if (options.recover) {
|
|
55792
|
-
if (!options.confirm || !options.root || !
|
|
56268
|
+
if (!options.confirm || !options.root || !path63.isAbsolute(options.root)) throw new Error("Uninstall recovery requires --root <absolute-path> and --confirm");
|
|
55793
56269
|
process.stdout.write(JSON.stringify(await recoverClientLiteUninstall(options.root, { confirm: true })) + "\n");
|
|
55794
56270
|
return;
|
|
55795
56271
|
}
|
|
@@ -55832,6 +56308,37 @@ if (process.argv.length <= 2) {
|
|
|
55832
56308
|
action: `zlt-mcp call mcp-wait --args-json '${JSON.stringify({ kind: "install", id: task.taskId })}'`
|
|
55833
56309
|
}) + "\n");
|
|
55834
56310
|
});
|
|
56311
|
+
if (isLinuxClientLiteCandidate()) {
|
|
56312
|
+
workspaces.command("prepare-data").description("Prepare official market foundation data and one daily stock window in the selected Linux workspace").requiredOption("--market <market>", "Stock market: sh or sz").requiredOption("--start <date>", "First day (YYYY-MM-DD)").requiredOption("--end <date>", "Last day (YYYY-MM-DD)").option("--workspace-id <id>", "Workspace returned by the preview").option("--installation-id <id>", "Installation returned by the preview").option("--confirm", "Authorize official data downloads for this workspace and window").action(async (options) => {
|
|
56313
|
+
const request3 = linuxDailyDataRequest(options.market, options.start, options.end);
|
|
56314
|
+
if (options.confirm && (!options.workspaceId || !options.installationId)) {
|
|
56315
|
+
throw new Error("Preview first and pass its --workspace-id and --installation-id with --confirm");
|
|
56316
|
+
}
|
|
56317
|
+
const binding = sharedStore().resolve({
|
|
56318
|
+
workspaceId: options.workspaceId,
|
|
56319
|
+
installationId: options.installationId,
|
|
56320
|
+
root: selectedClientRoot() ?? void 0
|
|
56321
|
+
});
|
|
56322
|
+
if (binding?.installation.kind !== "clientlite") throw new Error("Install ClientLite and select its workspace before preparing data");
|
|
56323
|
+
if (!options.confirm) {
|
|
56324
|
+
const { workspaceId } = binding.workspace;
|
|
56325
|
+
const { installationId } = binding.installation;
|
|
56326
|
+
process.stdout.write(JSON.stringify({
|
|
56327
|
+
status: "proposed",
|
|
56328
|
+
downloaded: false,
|
|
56329
|
+
marketFoundation: true,
|
|
56330
|
+
request: request3,
|
|
56331
|
+
workspaceId,
|
|
56332
|
+
installationId,
|
|
56333
|
+
installLocation: binding.installation.root
|
|
56334
|
+
}) + "\n");
|
|
56335
|
+
return;
|
|
56336
|
+
}
|
|
56337
|
+
const config2 = loadAssistantRuntimeConfig(resolveDefaultRuntimeConfigPath?.());
|
|
56338
|
+
const result = await runLinuxClientLiteData(binding, config2, request3);
|
|
56339
|
+
process.stdout.write(JSON.stringify(withCliProvenance(result)) + "\n");
|
|
56340
|
+
});
|
|
56341
|
+
}
|
|
55835
56342
|
workspaces.command("toolchains").description("Inspect Windows x64 ClientLite Python/Git; downloads occur only with --prepare").option("--prepare", "Use compatible tools from the active Agent; download only missing tools from pinned mirrors").action(async (options) => {
|
|
55836
56343
|
try {
|
|
55837
56344
|
const toolchainPlan = planClientLiteReleaseToolchains(CLIENTLITE_TOOLCHAIN_PINS);
|
|
@@ -55866,7 +56373,7 @@ if (process.argv.length <= 2) {
|
|
|
55866
56373
|
process.stdout.write(JSON.stringify(sharedStore().list()) + "\n");
|
|
55867
56374
|
});
|
|
55868
56375
|
workspaces.command("register").description("Register an existing installation and its current in-place data layout").requiredOption("--root <path>", "Existing native installation root").requiredOption("--kind <kind>", "mini, clientlite or full").requiredOption("--data-root <path>", "Existing research data root").option("--release <release>", "Native release identity if known").action(async (options) => {
|
|
55869
|
-
if (
|
|
56376
|
+
if (fs60.realpathSync.native(options.root) !== fs60.realpathSync.native(options.dataRoot)) {
|
|
55870
56377
|
throw new Error("Split-root registration requires a verified native data-root contract");
|
|
55871
56378
|
}
|
|
55872
56379
|
const store = sharedStore();
|
|
@@ -55907,7 +56414,7 @@ if (process.argv.length <= 2) {
|
|
|
55907
56414
|
if (args.installType === "clientlite") return args.releaseIdentity ? installNpmClientLite(args, config2, onProgress) : installLocalClientLite(args, config2, onProgress);
|
|
55908
56415
|
if (args.installType !== void 0 && args.installType !== "assistant") throw new Error("Unsupported installType");
|
|
55909
56416
|
const installDir = typeof args.installDir === "string" && args.installDir ? args.installDir : (await resolveInstallationRoot(config2)).workRoot ?? void 0;
|
|
55910
|
-
const existing2 = selectedClientRoot() || installDir &&
|
|
56417
|
+
const existing2 = selectedClientRoot() || installDir && fs60.existsSync(path63.join(installDir, "InstallInfo.xml"));
|
|
55911
56418
|
return installRuntime({
|
|
55912
56419
|
config: config2,
|
|
55913
56420
|
installType: existing2 ? void 0 : "mini",
|
|
@@ -56066,7 +56573,25 @@ if (process.argv.length <= 2) {
|
|
|
56066
56573
|
await runAuthCommand("zlt-auth-login-wait", { sessionId });
|
|
56067
56574
|
});
|
|
56068
56575
|
if (process.platform === "linux") {
|
|
56069
|
-
program2.command("research").description("Read data using the selected Linux ClientLite research workspace")
|
|
56576
|
+
const research = program2.command("research").description("Read data using the selected Linux ClientLite research workspace");
|
|
56577
|
+
research.command("check").description("Check local research runtime trust without using credentials or starting the SDK").action(async () => {
|
|
56578
|
+
let config2;
|
|
56579
|
+
try {
|
|
56580
|
+
config2 = loadAssistantRuntimeConfig(resolveDefaultRuntimeConfigPath?.());
|
|
56581
|
+
} catch {
|
|
56582
|
+
process.stdout.write(JSON.stringify(withCliProvenance({
|
|
56583
|
+
status: "blocked",
|
|
56584
|
+
reason: "runtime-config-unreadable",
|
|
56585
|
+
message: "Check that the runtime configuration is readable and valid in this environment."
|
|
56586
|
+
})) + "\n");
|
|
56587
|
+
process.exitCode = 1;
|
|
56588
|
+
return;
|
|
56589
|
+
}
|
|
56590
|
+
const result = await checkResearchRuntime(config2);
|
|
56591
|
+
process.stdout.write(JSON.stringify(withCliProvenance(result)) + "\n");
|
|
56592
|
+
if (result.status === "blocked") process.exitCode = 1;
|
|
56593
|
+
});
|
|
56594
|
+
research.command("prices").description("Read historical daily bars from the local cache using the existing CLI login").requiredOption("--symbols <codes>", "Comma-separated sh/sz security codes").requiredOption("--end-date <date>", "Historical trading day (YYYY-MM-DD) that must exist in the result").option("--count <bars>", "Bars per security (1\u2013100)", "1").action(async (options) => {
|
|
56070
56595
|
try {
|
|
56071
56596
|
const config2 = loadAssistantRuntimeConfig(resolveDefaultRuntimeConfigPath?.());
|
|
56072
56597
|
const result = await runResearchPrices(options, config2);
|
|
@@ -56121,7 +56646,7 @@ if (process.argv.length <= 2) {
|
|
|
56121
56646
|
stage = "output_write";
|
|
56122
56647
|
if (agentOutput) agentOutput.completedResult(complete, "success", 0);
|
|
56123
56648
|
else if (evidence) {
|
|
56124
|
-
|
|
56649
|
+
fs60.writeFileSync(evidence.resultFile, JSON.stringify(complete) + "\n", { encoding: "utf8", flag: "wx" });
|
|
56125
56650
|
evidence.writeReadable(complete);
|
|
56126
56651
|
evidence.completed("success", 0);
|
|
56127
56652
|
process.stdout.write(JSON.stringify({ ok: true, cliReport, ...evidence.receiptFields() }) + "\n");
|
|
@@ -56156,9 +56681,9 @@ if (process.argv.length <= 2) {
|
|
|
56156
56681
|
const args = parseMcpArgs(options.argsJson, options.argsFile);
|
|
56157
56682
|
const timeoutMs = parseTimeoutOption(options.timeoutMs, "--timeout-ms") ?? (tool === MARKET_OBSERVATION_TOOL ? 75e3 : void 0);
|
|
56158
56683
|
const maxTotalTimeoutMs = parseTimeoutOption(options.maxTotalTimeoutMs, "--max-total-timeout-ms");
|
|
56159
|
-
const resultFile = evidence?.resultFile ?? (options.outputJson === void 0 ? void 0 :
|
|
56684
|
+
const resultFile = evidence?.resultFile ?? (options.outputJson === void 0 ? void 0 : path63.resolve(options.outputJson));
|
|
56160
56685
|
stage = "output_prepare";
|
|
56161
|
-
if (resultFile !== void 0) outputFd =
|
|
56686
|
+
if (resultFile !== void 0) outputFd = fs60.openSync(resultFile, "wx");
|
|
56162
56687
|
if (options.panelOutput !== void 0) panelOutput = new CliMarketPanelOutput(options.panelOutput, tool);
|
|
56163
56688
|
stage = "tool_call";
|
|
56164
56689
|
delivery?.started(tool);
|
|
@@ -56209,10 +56734,10 @@ if (process.argv.length <= 2) {
|
|
|
56209
56734
|
if (outputFd !== void 0 && resultFile !== void 0) {
|
|
56210
56735
|
stage = "output_write";
|
|
56211
56736
|
try {
|
|
56212
|
-
|
|
56737
|
+
fs60.writeFileSync(outputFd, serialized, "utf-8");
|
|
56213
56738
|
const fd = outputFd;
|
|
56214
56739
|
outputFd = void 0;
|
|
56215
|
-
|
|
56740
|
+
fs60.closeSync(fd);
|
|
56216
56741
|
if (evidence) {
|
|
56217
56742
|
stage = "readable_write";
|
|
56218
56743
|
evidence.writeReadable(complete);
|
|
@@ -56240,7 +56765,7 @@ if (process.argv.length <= 2) {
|
|
|
56240
56765
|
try {
|
|
56241
56766
|
agentOutput?.receivedResult(received, factorError.factor);
|
|
56242
56767
|
if (outputFd !== void 0) {
|
|
56243
|
-
|
|
56768
|
+
fs60.writeFileSync(outputFd, JSON.stringify(received) + "\n", "utf-8");
|
|
56244
56769
|
evidence?.writeReadable(received);
|
|
56245
56770
|
} else if (!agentOutput) process.stdout.write(JSON.stringify(received) + "\n");
|
|
56246
56771
|
} catch (saveError) {
|
|
@@ -56276,7 +56801,7 @@ if (process.argv.length <= 2) {
|
|
|
56276
56801
|
const fd = outputFd;
|
|
56277
56802
|
outputFd = void 0;
|
|
56278
56803
|
try {
|
|
56279
|
-
|
|
56804
|
+
fs60.closeSync(fd);
|
|
56280
56805
|
} catch (error2) {
|
|
56281
56806
|
process.exitCode = 1;
|
|
56282
56807
|
process.stderr.write(`Error: result file close failed; toolExecution=${toolExecution}; ${String(error2)}
|
|
@@ -56474,17 +56999,17 @@ async function runAuthCommand(tool, args) {
|
|
|
56474
56999
|
}
|
|
56475
57000
|
}
|
|
56476
57001
|
function resolveCliPackageProvenance() {
|
|
56477
|
-
let current =
|
|
57002
|
+
let current = path63.dirname(path63.resolve(resolveCliEntrypoint() || process.cwd()));
|
|
56478
57003
|
for (let depth = 0; depth < 6; depth += 1) {
|
|
56479
|
-
const manifestPath =
|
|
57004
|
+
const manifestPath = path63.join(current, "package.json");
|
|
56480
57005
|
try {
|
|
56481
|
-
const manifest = JSON.parse(
|
|
57006
|
+
const manifest = JSON.parse(fs60.readFileSync(manifestPath, "utf-8"));
|
|
56482
57007
|
if ((manifest.name === "@zltquant/zlt-mcp" || manifest.name === "zlt-mcp-proxy") && typeof manifest.version === "string") {
|
|
56483
57008
|
return { packageName: manifest.name, packageVersion: manifest.version };
|
|
56484
57009
|
}
|
|
56485
57010
|
} catch {
|
|
56486
57011
|
}
|
|
56487
|
-
const parent =
|
|
57012
|
+
const parent = path63.dirname(current);
|
|
56488
57013
|
if (parent === current) break;
|
|
56489
57014
|
current = parent;
|
|
56490
57015
|
}
|