@napuketto/cli 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +8 -7
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import process$1 from "node:process";
|
|
3
|
-
import { CONFIG_FILE_MODE, ConfigBase, ConfigError, EXIT_CONFIG_INVALID, configError, createLogger, errorMessage,
|
|
3
|
+
import { CONFIG_FILE_MODE, ConfigBase, ConfigError, EXIT_CONFIG_INVALID, configError, createLogger, errorMessage, hasStringProp, isKernelError, isRecord, kernelError, parseLogConfig, parseToml, resolveConfigPath, resolveDataRoot, resolveSandboxWritePath, stringifyToml } from "@napuketto/kernel";
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import { mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { readFile, writeFile } from "node:fs/promises";
|
|
7
7
|
import { basename, dirname, extname, isAbsolute, join, resolve, sep } from "node:path";
|
|
8
|
-
import { CMDLINE_PROBE_SUPPORTED, QR_LINE_PREFIX, checkInstanceLock, defaultStubDir, isNativeNoiseLine, launchSelfHost, normalizeCmdline, readCmdlineForPid, removeAccountStopSentinel, removeStopSentinel, resolveQqFiles, watchStopSentinel, writeAccountStopSentinel, writeStopSentinel } from "@napuketto/loader";
|
|
8
|
+
import { CMDLINE_PROBE_SUPPORTED, QR_LINE_PREFIX, checkInstanceLock, defaultStubDir, isNativeNoiseLine, isValidPid, launchSelfHost, normalizeCmdline, readCmdlineForPid, removeAccountStopSentinel, removeStopSentinel, resolveQqFiles, watchStopSentinel, writeAccountStopSentinel, writeStopSentinel } from "@napuketto/loader";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { fileURLToPath } from "node:url";
|
|
@@ -1026,11 +1026,11 @@ function isOptionalString(val) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
/** runtime.json 形状守卫(损坏 / 旧格式 / 手工改错的文件一律判非法)。 */
|
|
1028
1028
|
function isAccountRuntime(val) {
|
|
1029
|
-
return isRecord(val) && hasStringProp(val, "uin") &&
|
|
1029
|
+
return isRecord(val) && hasStringProp(val, "uin") && isValidPid(val["pid"]) && hasStringProp(val, "startedAt") && isAccountRuntimeKind(val["kind"]) && isAccountRuntimeStatus(val["status"]) && (val["selfHostPid"] === void 0 || isValidPid(val["selfHostPid"])) && isOptionalString(val["cmdline"]) && isOptionalString(val["selfHostCmdline"]);
|
|
1030
1030
|
}
|
|
1031
1031
|
/** supervisor.json 形状守卫。 */
|
|
1032
1032
|
function isSupervisorRuntime(val) {
|
|
1033
|
-
return isRecord(val) &&
|
|
1033
|
+
return isRecord(val) && isValidPid(val["pid"]) && hasStringProp(val, "startedAt") && Array.isArray(val["accounts"]) && val["accounts"].every((item) => typeof item === "string") && isOptionalString(val["cmdline"]);
|
|
1034
1034
|
}
|
|
1035
1035
|
/** 读账号运行时状态(缺失/损坏返回 null)。 */
|
|
1036
1036
|
function readAccountRuntime(dataRoot, uin) {
|
|
@@ -1071,7 +1071,7 @@ function listAccountRuntimes(dataRoot) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
/** pid 存活检测(signal 0;EPERM 视为存活——进程存在但无权限)。 */
|
|
1073
1073
|
function isPidAlive(pid) {
|
|
1074
|
-
if (!
|
|
1074
|
+
if (!isValidPid(pid)) return false;
|
|
1075
1075
|
try {
|
|
1076
1076
|
process$1.kill(pid, 0);
|
|
1077
1077
|
return true;
|
|
@@ -1083,9 +1083,9 @@ function isPidAlive(pid) {
|
|
|
1083
1083
|
function isNoSuchProcess(err) {
|
|
1084
1084
|
return isRecord(err) && err["code"] === "ESRCH";
|
|
1085
1085
|
}
|
|
1086
|
-
/** 去重并过滤非法 pid
|
|
1086
|
+
/** 去重并过滤非法 pid(类型/范围统一走 loader isValidPid)。 */
|
|
1087
1087
|
function uniquePids(pids) {
|
|
1088
|
-
return [...new Set(pids)].filter((pid) =>
|
|
1088
|
+
return [...new Set(pids)].filter((pid) => isValidPid(pid));
|
|
1089
1089
|
}
|
|
1090
1090
|
/**
|
|
1091
1091
|
* 树杀(超时兜底强杀):win32 走 `taskkill /T /F`;POSIX 先 SIGTERM,宽限后对
|
|
@@ -1156,6 +1156,7 @@ function selfArgvFingerprint() {
|
|
|
1156
1156
|
* (调用方保守沿用旧行为,不因升级而让 stop 失效)。
|
|
1157
1157
|
*/
|
|
1158
1158
|
function checkProcessIdentity(pid, cmdline) {
|
|
1159
|
+
if (!isValidPid(pid)) return "mismatch";
|
|
1159
1160
|
if (cmdline === void 0 || cmdline === "" || !CMDLINE_PROBE_SUPPORTED) return "unverified";
|
|
1160
1161
|
const current = readCmdlineForPid(pid);
|
|
1161
1162
|
if (current === null) return "mismatch";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@napuketto/cli",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Command line interface for NapukettoQQ",
|
|
7
7
|
"keywords": [
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"start": "node ./dist/index.mjs"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@napuketto/adapter": "^0.
|
|
57
|
-
"@napuketto/kernel": "^0.
|
|
58
|
-
"@napuketto/loader": "^0.
|
|
56
|
+
"@napuketto/adapter": "^0.22.0",
|
|
57
|
+
"@napuketto/kernel": "^0.18.0",
|
|
58
|
+
"@napuketto/loader": "^0.15.0",
|
|
59
59
|
"@napuketto/network": "^0.5.0",
|
|
60
60
|
"commander": "^15.1.0",
|
|
61
61
|
"uqr": "^0.1.3"
|