@napuketto/cli 0.7.0 → 0.7.2
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 +12 -8
- 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";
|
|
@@ -434,7 +434,8 @@ groupUploadAsNotice = false
|
|
|
434
434
|
|
|
435
435
|
# 远程媒体默认仅公网。仅受信任的调用方需要访问 LAN/本机媒体时改为 compat。
|
|
436
436
|
# [accounts.onebot11.media]
|
|
437
|
-
# outboundPolicy = "
|
|
437
|
+
# outboundPolicy = "public-only"
|
|
438
|
+
# localMediaRoots = [] # 默认拒绝本地文件,可填写专用导出目录
|
|
438
439
|
|
|
439
440
|
# ---- HTTP 反向服务器(接收第三方 POST 指令),可配置多个 ----
|
|
440
441
|
[[accounts.onebot11.httpServers]]
|
|
@@ -475,6 +476,7 @@ port = 3001
|
|
|
475
476
|
# # token = "" # 可选:Satori 鉴权 token
|
|
476
477
|
# [accounts.satori.media]
|
|
477
478
|
# outboundPolicy = "public-only" # 受信任 LAN 部署可显式设为 "compat"
|
|
479
|
+
# localMediaRoots = [] # 默认拒绝本地文件,可填写专用导出目录
|
|
478
480
|
# [[accounts.satori.httpServers]] # HTTP RPC(POST /v1/{resource}.{method})
|
|
479
481
|
# enabled = true
|
|
480
482
|
# host = "127.0.0.1"
|
|
@@ -516,6 +518,7 @@ port = 3001
|
|
|
516
518
|
# # cacheDir = "cache" # 可选:发送远程媒体 URI 的下载缓存目录
|
|
517
519
|
# [accounts.milky.media]
|
|
518
520
|
# outboundPolicy = "public-only" # 受信任 LAN 部署可显式设为 "compat"
|
|
521
|
+
# localMediaRoots = [] # 默认拒绝本地文件,可填写专用导出目录
|
|
519
522
|
`;
|
|
520
523
|
}
|
|
521
524
|
// src/config/store.ts
|
|
@@ -1023,11 +1026,11 @@ function isOptionalString(val) {
|
|
|
1023
1026
|
}
|
|
1024
1027
|
/** runtime.json 形状守卫(损坏 / 旧格式 / 手工改错的文件一律判非法)。 */
|
|
1025
1028
|
function isAccountRuntime(val) {
|
|
1026
|
-
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"]);
|
|
1027
1030
|
}
|
|
1028
1031
|
/** supervisor.json 形状守卫。 */
|
|
1029
1032
|
function isSupervisorRuntime(val) {
|
|
1030
|
-
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"]);
|
|
1031
1034
|
}
|
|
1032
1035
|
/** 读账号运行时状态(缺失/损坏返回 null)。 */
|
|
1033
1036
|
function readAccountRuntime(dataRoot, uin) {
|
|
@@ -1068,7 +1071,7 @@ function listAccountRuntimes(dataRoot) {
|
|
|
1068
1071
|
}
|
|
1069
1072
|
/** pid 存活检测(signal 0;EPERM 视为存活——进程存在但无权限)。 */
|
|
1070
1073
|
function isPidAlive(pid) {
|
|
1071
|
-
if (!
|
|
1074
|
+
if (!isValidPid(pid)) return false;
|
|
1072
1075
|
try {
|
|
1073
1076
|
process$1.kill(pid, 0);
|
|
1074
1077
|
return true;
|
|
@@ -1080,9 +1083,9 @@ function isPidAlive(pid) {
|
|
|
1080
1083
|
function isNoSuchProcess(err) {
|
|
1081
1084
|
return isRecord(err) && err["code"] === "ESRCH";
|
|
1082
1085
|
}
|
|
1083
|
-
/** 去重并过滤非法 pid
|
|
1086
|
+
/** 去重并过滤非法 pid(类型/范围统一走 loader isValidPid)。 */
|
|
1084
1087
|
function uniquePids(pids) {
|
|
1085
|
-
return [...new Set(pids)].filter((pid) =>
|
|
1088
|
+
return [...new Set(pids)].filter((pid) => isValidPid(pid));
|
|
1086
1089
|
}
|
|
1087
1090
|
/**
|
|
1088
1091
|
* 树杀(超时兜底强杀):win32 走 `taskkill /T /F`;POSIX 先 SIGTERM,宽限后对
|
|
@@ -1153,6 +1156,7 @@ function selfArgvFingerprint() {
|
|
|
1153
1156
|
* (调用方保守沿用旧行为,不因升级而让 stop 失效)。
|
|
1154
1157
|
*/
|
|
1155
1158
|
function checkProcessIdentity(pid, cmdline) {
|
|
1159
|
+
if (!isValidPid(pid)) return "mismatch";
|
|
1156
1160
|
if (cmdline === void 0 || cmdline === "" || !CMDLINE_PROBE_SUPPORTED) return "unverified";
|
|
1157
1161
|
const current = readCmdlineForPid(pid);
|
|
1158
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.2",
|
|
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.21.1",
|
|
57
|
+
"@napuketto/kernel": "^0.17.0",
|
|
58
|
+
"@napuketto/loader": "^0.14.0",
|
|
59
59
|
"@napuketto/network": "^0.5.0",
|
|
60
60
|
"commander": "^15.1.0",
|
|
61
61
|
"uqr": "^0.1.3"
|