@napuketto/kernel 0.18.0 → 0.19.0
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.d.mts +7 -7
- package/dist/index.mjs +58 -43
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2681,8 +2681,8 @@ export declare const EXIT_CONFIG_INVALID = 78;
|
|
|
2681
2681
|
* 避免两处手写解析漂移。输入为 TOML 解析后的 [log] 段原对象(缺失传 undefined)
|
|
2682
2682
|
* + 环境变量快照;输出为已解析的 LogConfig(env 覆盖优先于 toml)。
|
|
2683
2683
|
*
|
|
2684
|
-
* 环境变量(优先级高于 toml
|
|
2685
|
-
* - NAPUKETTO_LOG_LEVEL
|
|
2684
|
+
* 环境变量(优先级高于 toml;非法值忽略):
|
|
2685
|
+
* - NAPUKETTO_LOG_LEVEL(唯一规范拼写)
|
|
2686
2686
|
* - NAPUKETTO_LOG_FORMAT(pretty | single-line | json)
|
|
2687
2687
|
* - NAPUKETTO_NO_BANNER(1/true = 关 banner)
|
|
2688
2688
|
* - NAPUKETTO_LOG_COLORIZE(1/true/0/false,CLI 顶层进程向子进程传播控制台
|
|
@@ -2818,7 +2818,7 @@ interface ConfigPathOptions {
|
|
|
2818
2818
|
* 数据仍按数据根组织**——数据根只承载账号目录/日志/缓存/QQ 数据)。
|
|
2819
2819
|
*
|
|
2820
2820
|
* 优先级:
|
|
2821
|
-
* 1. `
|
|
2821
|
+
* 1. `NAPUKETTO_CONFIG` 环境变量(显式指定完整路径,任意场景可用)
|
|
2822
2822
|
* 2. 项目根探测(入口模块向上找 pnpm-workspace.yaml → cwd 向上找,见 resolveProjectRoot)
|
|
2823
2823
|
* 3. 数据根兜底 `<dataRoot>/napuketto.toml`(旧行为兼容)
|
|
2824
2824
|
*
|
|
@@ -2869,7 +2869,7 @@ export declare function sleep(ms: number): Promise<void>;
|
|
|
2869
2869
|
export declare function electronProcessType(): string | undefined;
|
|
2870
2870
|
/** `resolveQqUserDataRoot` 选项(平台覆盖供测试/联调,缺省按 `process.platform` 探测)。 */
|
|
2871
2871
|
interface QqDataRootOptions {
|
|
2872
|
-
/** 数据根(`
|
|
2872
|
+
/** 数据根(`NAPUKETTO_DATA` / `--data-dir` 解析结果)。Linux 和调试沙箱在此存放 QQ 数据。 */
|
|
2873
2873
|
dataRoot?: string | undefined;
|
|
2874
2874
|
/** 平台覆盖(缺省 `detectPlatformType()`)。 */
|
|
2875
2875
|
platform?: PlatformType | undefined;
|
|
@@ -2973,7 +2973,7 @@ interface BootEnv {
|
|
|
2973
2973
|
selfUid?: string | undefined;
|
|
2974
2974
|
/**
|
|
2975
2975
|
* wrapper.node 绝对路径(appid 自动解析用:同目录 major.node)。
|
|
2976
|
-
* 缺省回退 `NAPUKETTO_WRAPPER_PATH`
|
|
2976
|
+
* 缺省回退 `NAPUKETTO_WRAPPER_PATH` 环境变量。
|
|
2977
2977
|
*/
|
|
2978
2978
|
wrapperPath?: string | undefined;
|
|
2979
2979
|
}
|
|
@@ -3275,7 +3275,7 @@ interface CoreLoginOptions {
|
|
|
3275
3275
|
/**
|
|
3276
3276
|
* appid(登录握手)。**可选**:未传时自动从 wrapperPath 同目录 major.node
|
|
3277
3277
|
* 解析(`resolveAppidQua`);wrapperPath 缺省回退 `NAPUKETTO_WRAPPER_PATH` /
|
|
3278
|
-
* `
|
|
3278
|
+
* `NAPUKETTO_WRAPPER_PATH` 环境变量。仍无法解析则抛 INVALID_PARAM。
|
|
3279
3279
|
*/
|
|
3280
3280
|
appid?: string | undefined;
|
|
3281
3281
|
/** session.init 超时(毫秒),默认 15s。 */
|
|
@@ -3457,7 +3457,7 @@ export declare function parseJsonWithGuard<T>(raw: string, guard: (val: unknown)
|
|
|
3457
3457
|
export declare function requireKernelService<T extends object>(service: T | null | undefined, serviceName: string, requiredMethods?: readonly (keyof T & string)[]): T;
|
|
3458
3458
|
/**
|
|
3459
3459
|
* 探测 wrapper 运行时:dump session 方法与各 service 方法名到 JSON。
|
|
3460
|
-
* 返回探测结果对象;同时写文件(
|
|
3460
|
+
* 返回探测结果对象;同时写文件(NAPUKETTO_CFG_DIR/<file>,默认 napuketto-probe.json)。
|
|
3461
3461
|
* 服务枚举逐项增量落盘(persist)——活 session 上原生崩溃时文件保留断点。
|
|
3462
3462
|
*/
|
|
3463
3463
|
export declare function probeRuntime(ctx: WrapperContext, file?: string): Record<string, unknown>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
-
import { appendFileSync, chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, chmodSync, constants, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
5
|
-
import process from "node:process";
|
|
5
|
+
import process$1 from "node:process";
|
|
6
6
|
import { parse, stringify } from "smol-toml";
|
|
7
7
|
import pino from "pino";
|
|
8
8
|
import { homedir, hostname, platform, release, type, version } from "node:os";
|
|
@@ -276,7 +276,7 @@ var ConfigBase = class {
|
|
|
276
276
|
const file = await open(tmpPath, "wx", 384);
|
|
277
277
|
try {
|
|
278
278
|
try {
|
|
279
|
-
if (process.platform !== "win32") await file.chmod(384);
|
|
279
|
+
if (process$1.platform !== "win32") await file.chmod(384);
|
|
280
280
|
await file.writeFile(text, "utf8");
|
|
281
281
|
} finally {
|
|
282
282
|
await file.close();
|
|
@@ -331,8 +331,8 @@ function stringifyToml(value) {
|
|
|
331
331
|
* 避免两处手写解析漂移。输入为 TOML 解析后的 [log] 段原对象(缺失传 undefined)
|
|
332
332
|
* + 环境变量快照;输出为已解析的 LogConfig(env 覆盖优先于 toml)。
|
|
333
333
|
*
|
|
334
|
-
* 环境变量(优先级高于 toml
|
|
335
|
-
* - NAPUKETTO_LOG_LEVEL
|
|
334
|
+
* 环境变量(优先级高于 toml;非法值忽略):
|
|
335
|
+
* - NAPUKETTO_LOG_LEVEL(唯一规范拼写)
|
|
336
336
|
* - NAPUKETTO_LOG_FORMAT(pretty | single-line | json)
|
|
337
337
|
* - NAPUKETTO_NO_BANNER(1/true = 关 banner)
|
|
338
338
|
* - NAPUKETTO_LOG_COLORIZE(1/true/0/false,CLI 顶层进程向子进程传播控制台
|
|
@@ -442,10 +442,10 @@ function applySectionFields(draft, raw) {
|
|
|
442
442
|
applyBoolean(draft, raw, "banner");
|
|
443
443
|
applyBoolean(draft, raw, "unboundReceive");
|
|
444
444
|
}
|
|
445
|
-
/** env 覆盖(优先级高于 toml
|
|
445
|
+
/** env 覆盖(优先级高于 toml;非法值忽略)。
|
|
446
446
|
* file.level 显式配置时不被 env 全局级别顶掉(缺省跟随全局)。 */
|
|
447
447
|
function applyEnvOverrides(draft, env) {
|
|
448
|
-
const envLevel = optionalLevel(env["NAPUKETTO_LOG_LEVEL"])
|
|
448
|
+
const envLevel = optionalLevel(env["NAPUKETTO_LOG_LEVEL"]);
|
|
449
449
|
if (envLevel !== void 0) {
|
|
450
450
|
draft.level = envLevel;
|
|
451
451
|
if (draft.file !== void 0 && draft.fileLevelExplicit !== true) draft.file = {
|
|
@@ -712,7 +712,7 @@ function renderPrettyLine(record, ctx) {
|
|
|
712
712
|
}
|
|
713
713
|
/** 创建控制台渲染流(pretty / single-line / json)。 */
|
|
714
714
|
function createConsoleFormatStream(opts) {
|
|
715
|
-
const out = opts.destination ?? process.stdout;
|
|
715
|
+
const out = opts.destination ?? process$1.stdout;
|
|
716
716
|
const ctx = {
|
|
717
717
|
timestamp: opts.timestamp,
|
|
718
718
|
timeOriginMs: performance.timeOrigin,
|
|
@@ -814,7 +814,7 @@ function isPathWithin(root, path) {
|
|
|
814
814
|
* <项目根>/.napuketto/ # 数据根(默认值,2026-08-08 用户拍板:直接放项目主目录)
|
|
815
815
|
* ```
|
|
816
816
|
*
|
|
817
|
-
* 数据根优先级:cli `--data-dir`(显式参数)> `
|
|
817
|
+
* 数据根优先级:cli `--data-dir`(显式参数)> `NAPUKETTO_DATA` 环境变量 >
|
|
818
818
|
* `<项目根>/.napuketto`(默认,部署原因不放用户目录)。
|
|
819
819
|
* 配置文件路径见 `resolveConfigPath`(项目根探测,与数据根解耦)。
|
|
820
820
|
*/
|
|
@@ -824,7 +824,7 @@ const DEFAULT_DATA_ROOT_NAME = ".napuketto";
|
|
|
824
824
|
const MAIN_CONFIG_FILE = "napuketto.toml";
|
|
825
825
|
/** Check an actual write destination when the development launcher has set a boundary. */
|
|
826
826
|
function resolveSandboxWritePath(path, field) {
|
|
827
|
-
const sandbox = process.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
827
|
+
const sandbox = process$1.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
828
828
|
if (!sandbox) return path;
|
|
829
829
|
const target = resolve(path);
|
|
830
830
|
if (!isPathWithin(sandbox, target)) throw configError(`${field} 必须位于调试沙箱内: ${target}`);
|
|
@@ -850,7 +850,7 @@ function expandTilde(p) {
|
|
|
850
850
|
function resolveProjectRoot() {
|
|
851
851
|
const moduleRoot = findProjectRoot(dirname(fileURLToPath(import.meta.url)), "pnpm-workspace.yaml");
|
|
852
852
|
if (moduleRoot !== void 0) return moduleRoot;
|
|
853
|
-
return findProjectRoot(process.cwd(), "pnpm-workspace.yaml") ?? findProjectRoot(process.cwd(), "package.json");
|
|
853
|
+
return findProjectRoot(process$1.cwd(), "pnpm-workspace.yaml") ?? findProjectRoot(process$1.cwd(), "package.json");
|
|
854
854
|
}
|
|
855
855
|
/**
|
|
856
856
|
* 解析数据根:显式参数 > 环境变量 > `<项目根>/.napuketto`(默认)> 用户目录兜底(裸脚本)。
|
|
@@ -858,9 +858,9 @@ function resolveProjectRoot() {
|
|
|
858
858
|
* 返回绝对路径。独立导出便于 cli / 探测脚本复用。
|
|
859
859
|
*/
|
|
860
860
|
function resolveDataRoot(dataRoot) {
|
|
861
|
-
const explicit = dataRoot ?? process.env["NAPUKETTO_DATA"]
|
|
861
|
+
const explicit = dataRoot ?? process$1.env["NAPUKETTO_DATA"];
|
|
862
862
|
if (explicit !== void 0 && explicit !== "") return resolveSandboxWritePath(resolve(expandTilde(explicit)), "数据目录");
|
|
863
|
-
const sandbox = process.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
863
|
+
const sandbox = process$1.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
864
864
|
if (sandbox) return resolveSandboxWritePath(join(sandbox, DEFAULT_DATA_ROOT_NAME), "数据目录");
|
|
865
865
|
const projectRoot = resolveProjectRoot();
|
|
866
866
|
if (projectRoot !== void 0) return join(projectRoot, DEFAULT_DATA_ROOT_NAME);
|
|
@@ -881,16 +881,16 @@ function findProjectRoot(startDir, marker) {
|
|
|
881
881
|
* 数据仍按数据根组织**——数据根只承载账号目录/日志/缓存/QQ 数据)。
|
|
882
882
|
*
|
|
883
883
|
* 优先级:
|
|
884
|
-
* 1. `
|
|
884
|
+
* 1. `NAPUKETTO_CONFIG` 环境变量(显式指定完整路径,任意场景可用)
|
|
885
885
|
* 2. 项目根探测(入口模块向上找 pnpm-workspace.yaml → cwd 向上找,见 resolveProjectRoot)
|
|
886
886
|
* 3. 数据根兜底 `<dataRoot>/napuketto.toml`(旧行为兼容)
|
|
887
887
|
*
|
|
888
888
|
* 返回绝对路径。独立导出便于 cli / loader 装配链复用。
|
|
889
889
|
*/
|
|
890
890
|
function resolveConfigPath(opts = {}) {
|
|
891
|
-
const explicit = process.env["NAPUKETTO_CONFIG"]
|
|
891
|
+
const explicit = process$1.env["NAPUKETTO_CONFIG"];
|
|
892
892
|
if (explicit !== void 0 && explicit !== "") return resolveSandboxWritePath(resolve(explicit), "配置文件");
|
|
893
|
-
const sandbox = process.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
893
|
+
const sandbox = process$1.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
894
894
|
if (sandbox) return resolveSandboxWritePath(join(sandbox, MAIN_CONFIG_FILE), "配置文件");
|
|
895
895
|
const projectRoot = resolveProjectRoot();
|
|
896
896
|
if (projectRoot !== void 0) return join(projectRoot, MAIN_CONFIG_FILE);
|
|
@@ -1029,7 +1029,7 @@ function mergeTargets(targets) {
|
|
|
1029
1029
|
*/
|
|
1030
1030
|
function createLogger(opts = {}) {
|
|
1031
1031
|
const consoleLevel = opts.level ?? "info";
|
|
1032
|
-
const destination = opts.destination ?? process.stdout;
|
|
1032
|
+
const destination = opts.destination ?? process$1.stdout;
|
|
1033
1033
|
const isTty = destination.isTTY === true;
|
|
1034
1034
|
const format = opts.format ?? (isTty ? "pretty" : "single-line");
|
|
1035
1035
|
const targets = [buildConsoleTarget(opts, {
|
|
@@ -1045,7 +1045,7 @@ function createLogger(opts = {}) {
|
|
|
1045
1045
|
hooks: { streamWrite: redactLogLine },
|
|
1046
1046
|
timestamp: () => `,"time":${wallMs()}`,
|
|
1047
1047
|
...opts.base === void 0 ? {} : { base: {
|
|
1048
|
-
pid: process.pid,
|
|
1048
|
+
pid: process$1.pid,
|
|
1049
1049
|
...opts.base
|
|
1050
1050
|
} }
|
|
1051
1051
|
};
|
|
@@ -2534,8 +2534,25 @@ async function statFile(path, label = "图片") {
|
|
|
2534
2534
|
/** 计算文件 md5(十六进制小写)。 */
|
|
2535
2535
|
async function hashFile(path, label = "图片") {
|
|
2536
2536
|
try {
|
|
2537
|
-
const
|
|
2538
|
-
|
|
2537
|
+
const flags = constants.O_RDONLY | (process.platform === "win32" ? 0 : constants.O_NONBLOCK);
|
|
2538
|
+
const handle = await open(path, flags);
|
|
2539
|
+
try {
|
|
2540
|
+
const info = await handle.stat();
|
|
2541
|
+
if (!info.isFile()) throw new Error("摘要输入必须是普通文件");
|
|
2542
|
+
const hash = createHash("md5");
|
|
2543
|
+
const chunk = Buffer.alloc(65536);
|
|
2544
|
+
let remaining = info.size;
|
|
2545
|
+
while (remaining > 0) {
|
|
2546
|
+
const { bytesRead } = await handle.read(chunk, 0, Math.min(remaining, chunk.length));
|
|
2547
|
+
if (bytesRead === 0) throw new Error("摘要读取期间文件缩短");
|
|
2548
|
+
hash.update(chunk.subarray(0, bytesRead));
|
|
2549
|
+
remaining -= bytesRead;
|
|
2550
|
+
}
|
|
2551
|
+
if ((await handle.read(chunk, 0, 1)).bytesRead !== 0) throw new Error("摘要读取期间文件增长");
|
|
2552
|
+
return hash.digest("hex");
|
|
2553
|
+
} finally {
|
|
2554
|
+
await handle.close();
|
|
2555
|
+
}
|
|
2539
2556
|
} catch {
|
|
2540
2557
|
throw kernelError(`${label}文件读取失败: ${path}`, "INVALID_PARAM");
|
|
2541
2558
|
}
|
|
@@ -5608,14 +5625,14 @@ function getElectronProcessType(proc) {
|
|
|
5608
5625
|
* 默认 engine 配置(按平台探测)。
|
|
5609
5626
|
*
|
|
5610
5627
|
* 平台:`process.platform` → KLINUX/KMAC/KWINDOWS;qua 优先从 wrapper.node 同目录
|
|
5611
|
-
* major.node 扫描(`
|
|
5628
|
+
* major.node 扫描(`NAPUKETTO_WRAPPER_PATH` 由 loader 注入),找不到再按版本拼。
|
|
5612
5629
|
* Linux 实测需要 `V1_LNX_NQ_3.2.35_54395_GW_B`;Windows 旧行为(qua 空)仅在
|
|
5613
5630
|
* 拿不到版本/major.node 时保底。
|
|
5614
5631
|
*/
|
|
5615
5632
|
function defaultEngineConfig(env, qqDataPath) {
|
|
5616
5633
|
const platform = detectPlatformType();
|
|
5617
5634
|
const fullVersion = env.qqVersion ?? "";
|
|
5618
|
-
const wrapperPath = env.wrapperPath ?? process.env["NAPUKETTO_WRAPPER_PATH"] ??
|
|
5635
|
+
const wrapperPath = env.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"] ?? "";
|
|
5619
5636
|
const majorPath = wrapperPath !== "" ? join(dirname(wrapperPath), "major.node") : "";
|
|
5620
5637
|
const qua = (majorPath !== "" ? parseQuaFromMajor(majorPath) : null) ?? (fullVersion !== "" ? buildQua(fullVersion, platform) : "");
|
|
5621
5638
|
return {
|
|
@@ -5623,7 +5640,7 @@ function defaultEngineConfig(env, qqDataPath) {
|
|
|
5623
5640
|
platform_type: platform,
|
|
5624
5641
|
app_type: 4,
|
|
5625
5642
|
app_version: fullVersion,
|
|
5626
|
-
os_version: version() || process.platform,
|
|
5643
|
+
os_version: version() || process$1.platform,
|
|
5627
5644
|
use_xlog: platform !== PlatformType.KWINDOWS,
|
|
5628
5645
|
qua,
|
|
5629
5646
|
global_path_config: { desktopGlobalPath: qqDataPath ?? env.dataDir ?? "" },
|
|
@@ -5641,7 +5658,7 @@ function defaultEngineConfig(env, qqDataPath) {
|
|
|
5641
5658
|
* - "utility":utilityProcess Worker(路线 B,2026-08-06)
|
|
5642
5659
|
*/
|
|
5643
5660
|
function electronProcessType() {
|
|
5644
|
-
return getElectronProcessType(process);
|
|
5661
|
+
return getElectronProcessType(process$1);
|
|
5645
5662
|
}
|
|
5646
5663
|
/**
|
|
5647
5664
|
* 解析 QQ 用户数据根(登录数据目录,如 `C:\Users\<user>\Documents\Tencent Files`)。
|
|
@@ -5659,13 +5676,13 @@ function electronProcessType() {
|
|
|
5659
5676
|
* 其余 Windows 场景走官方 API + 默认位置兜底。
|
|
5660
5677
|
*/
|
|
5661
5678
|
function resolveQqUserDataRoot(exports, opts = {}) {
|
|
5662
|
-
if (process.env["NAPUKETTO_SANDBOX_ROOT"]) {
|
|
5663
|
-
const dataRoot = resolveDataRoot(opts.dataRoot || process.env["NAPUKETTO_DATA_ROOT"]
|
|
5679
|
+
if (process$1.env["NAPUKETTO_SANDBOX_ROOT"]) {
|
|
5680
|
+
const dataRoot = resolveDataRoot(opts.dataRoot || process$1.env["NAPUKETTO_DATA_ROOT"]);
|
|
5664
5681
|
resolveSandboxWritePath(resolveQqGlobalPath(dataRoot), "QQ 数据目录");
|
|
5665
5682
|
return dataRoot;
|
|
5666
5683
|
}
|
|
5667
5684
|
if ((opts.platform ?? detectPlatformType()) === PlatformType.KLINUX) {
|
|
5668
|
-
const dataRoot = opts.dataRoot ?? process.env["NAPUKETTO_DATA_ROOT"] ?? process.env["
|
|
5685
|
+
const dataRoot = opts.dataRoot ?? process$1.env["NAPUKETTO_DATA_ROOT"] ?? process$1.env["NAPUKETTO_DATA"] ?? "";
|
|
5669
5686
|
if (dataRoot !== "") return dataRoot;
|
|
5670
5687
|
}
|
|
5671
5688
|
return extractUserDataRoot(exports) ?? join(homedir(), "Documents", "Tencent Files");
|
|
@@ -5810,7 +5827,7 @@ function startNapuketto(options) {
|
|
|
5810
5827
|
prepareSession(ctx, hasCapturedSession, isSelfHost);
|
|
5811
5828
|
initEngine(ctx, resolveEngineConfig(ctx, env, engineConfig));
|
|
5812
5829
|
resolveLoginService(ctx, qqLoginService);
|
|
5813
|
-
ctx.wrapperPath = env?.wrapperPath ?? process.env["NAPUKETTO_WRAPPER_PATH"]
|
|
5830
|
+
ctx.wrapperPath = env?.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"];
|
|
5814
5831
|
if (isSelfHost) activateO3MiscService(wrapperExports);
|
|
5815
5832
|
finishSession(ctx, hasCapturedSession, isSelfHost, sessionConfig);
|
|
5816
5833
|
return ctx;
|
|
@@ -5846,7 +5863,7 @@ function captureSession(ctx, qqSession) {
|
|
|
5846
5863
|
* engine,无需解析。
|
|
5847
5864
|
*
|
|
5848
5865
|
* `dataRoot` 在 Linux 和调试沙箱生效(`resolveQqUserDataRoot` 平台分流):loader 由
|
|
5849
|
-
* `
|
|
5866
|
+
* `NAPUKETTO_DATA_ROOT` 注入,QQ 数据固定落 `<数据根>/nt_qq/global`。
|
|
5850
5867
|
*/
|
|
5851
5868
|
function resolveBootQqGlobalPath(ctx, dataRoot) {
|
|
5852
5869
|
if (electronProcessType() === "browser") return;
|
|
@@ -5887,7 +5904,7 @@ function getOrCreateLoginService(exports) {
|
|
|
5887
5904
|
*/
|
|
5888
5905
|
function dlopenWrapper(wrapperPath) {
|
|
5889
5906
|
const m = { exports: {} };
|
|
5890
|
-
process.dlopen(m, wrapperPath);
|
|
5907
|
+
process$1.dlopen(m, wrapperPath);
|
|
5891
5908
|
if (!Object.keys(m.exports).includes("NodeIKernelLoginService")) throw kernelError("exports 无 NodeIKernelLoginService(stub 环境异常?)", "INVALID_STATE");
|
|
5892
5909
|
if (!isWrapperNodeApi(m.exports)) throw kernelError(`wrapper.node at ${wrapperPath} did not export expected QQNT symbols`, "INVALID_STATE");
|
|
5893
5910
|
return m.exports;
|
|
@@ -6186,15 +6203,13 @@ var NapukettoCore = class NapukettoCore {
|
|
|
6186
6203
|
this.stop();
|
|
6187
6204
|
}
|
|
6188
6205
|
};
|
|
6189
|
-
/** wrapperPath
|
|
6190
|
-
const
|
|
6206
|
+
/** wrapperPath 环境变量键(唯一规范拼写)。 */
|
|
6207
|
+
const WRAPPER_PATH_ENV_KEY = "NAPUKETTO_WRAPPER_PATH";
|
|
6191
6208
|
/** 解析 wrapperPath:wrapper 上下文优先,其次环境变量。 */
|
|
6192
6209
|
function resolveWrapperPath$1(wrapper) {
|
|
6193
6210
|
if (wrapper.wrapperPath !== void 0 && wrapper.wrapperPath !== "") return wrapper.wrapperPath;
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
if (value !== void 0 && value !== "") return value;
|
|
6197
|
-
}
|
|
6211
|
+
const value = process$1.env[WRAPPER_PATH_ENV_KEY];
|
|
6212
|
+
if (value !== void 0 && value !== "") return value;
|
|
6198
6213
|
}
|
|
6199
6214
|
/**
|
|
6200
6215
|
* appid 解析:显式传入优先;否则从 wrapperPath 同目录 major.node 解析。
|
|
@@ -6635,9 +6650,9 @@ const LOGIN_GETTER_PROBES = [
|
|
|
6635
6650
|
*
|
|
6636
6651
|
* 注入链路打通后(2026-08-05),wrapper exports 是 QQ 已注册的单例。
|
|
6637
6652
|
* 本模块在 **QQ 主进程内**反射枚举 session / service 的真实方法名与返回形状,
|
|
6638
|
-
* 产出 JSON 到
|
|
6653
|
+
* 产出 JSON 到 NAPUKETTO_CFG_DIR/napuketto-probe.json,作为 types/services/ 的权威来源。
|
|
6639
6654
|
*
|
|
6640
|
-
* 用法:boot.cjs 在
|
|
6655
|
+
* 用法:boot.cjs 在 NAPUKETTO_PROBE=1 时于 startNapuketto 后调用 probeRuntime(ctx)。
|
|
6641
6656
|
* 产物是研究工具数据,类型层据此补全(自研描述,非移植)。
|
|
6642
6657
|
*
|
|
6643
6658
|
* 工具拆分(2026-08-08 FTA 优化):方法枚举/安全调用 → probe-utils.ts;
|
|
@@ -6876,7 +6891,7 @@ function probeServiceGetter(session, getter) {
|
|
|
6876
6891
|
}
|
|
6877
6892
|
/**
|
|
6878
6893
|
* 探测 wrapper 运行时:dump session 方法与各 service 方法名到 JSON。
|
|
6879
|
-
* 返回探测结果对象;同时写文件(
|
|
6894
|
+
* 返回探测结果对象;同时写文件(NAPUKETTO_CFG_DIR/<file>,默认 napuketto-probe.json)。
|
|
6880
6895
|
* 服务枚举逐项增量落盘(persist)——活 session 上原生崩溃时文件保留断点。
|
|
6881
6896
|
*/
|
|
6882
6897
|
function probeRuntime(ctx, file = "napuketto-probe.json") {
|
|
@@ -6897,7 +6912,7 @@ function probeRuntime(ctx, file = "napuketto-probe.json") {
|
|
|
6897
6912
|
/** 探测结果落盘(增量与最终共用;最终写入后记 probeFile 路径)。 */
|
|
6898
6913
|
function writeProbeFile(result, file) {
|
|
6899
6914
|
try {
|
|
6900
|
-
const dir = process.env["NAPUKETTO_CFG_DIR"] ?? process.
|
|
6915
|
+
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.cwd();
|
|
6901
6916
|
mkdirSync(dir, { recursive: true });
|
|
6902
6917
|
const full = join(dir, file);
|
|
6903
6918
|
writeFileSync(full, JSON.stringify(result, null, 2), "utf8");
|
|
@@ -6915,8 +6930,8 @@ function writeProbeFile(result, file) {
|
|
|
6915
6930
|
* JS 对象 + NAPI 按名反射回调(MsgBridge 模式),用 Proxy get 陷阱构造万能
|
|
6916
6931
|
* 监听器,原生调什么记什么,不需要预先知道回调名。
|
|
6917
6932
|
*
|
|
6918
|
-
* 开关:
|
|
6919
|
-
* 产物:
|
|
6933
|
+
* 开关:NAPUKETTO_LISTENER_RECORD=1(loader bootstrap 挂起,位置与 runProbePhase 相邻)。
|
|
6934
|
+
* 产物:NAPUKETTO_CFG_DIR/napuketto-listener-record.jsonl(JSONL 追加,注册过程
|
|
6920
6935
|
* 逐行落盘,原生崩溃保留断点定位肇事服务)。
|
|
6921
6936
|
*
|
|
6922
6937
|
* 安全边界:记录函数只序列化入参后回调 onEvent,绝不反向调用原生;录制器与
|
|
@@ -7006,7 +7021,7 @@ function createRecordingListener(service, onEvent) {
|
|
|
7006
7021
|
* 空壳的 service getter 函数仍在但调用返回 null(late probe 61/63 null 的根因)。
|
|
7007
7022
|
*/
|
|
7008
7023
|
function startListenerRecording(ctx, file = "napuketto-listener-record.jsonl") {
|
|
7009
|
-
const dir = process.env["NAPUKETTO_CFG_DIR"] ?? process.
|
|
7024
|
+
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.cwd();
|
|
7010
7025
|
mkdirSync(dir, { recursive: true });
|
|
7011
7026
|
const full = join(dir, file);
|
|
7012
7027
|
writeFileSync(full, "", "utf8");
|