@napuketto/kernel 0.18.1 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +25 -27
- package/package.json +5 -6
package/README.md
CHANGED
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
|
@@ -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 = {
|
|
@@ -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
|
*/
|
|
@@ -858,7 +858,7 @@ function resolveProjectRoot() {
|
|
|
858
858
|
* 返回绝对路径。独立导出便于 cli / 探测脚本复用。
|
|
859
859
|
*/
|
|
860
860
|
function resolveDataRoot(dataRoot) {
|
|
861
|
-
const explicit = dataRoot ?? process$1.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
863
|
const sandbox = process$1.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
864
864
|
if (sandbox) return resolveSandboxWritePath(join(sandbox, DEFAULT_DATA_ROOT_NAME), "数据目录");
|
|
@@ -881,14 +881,14 @@ 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$1.env["NAPUKETTO_CONFIG"]
|
|
891
|
+
const explicit = process$1.env["NAPUKETTO_CONFIG"];
|
|
892
892
|
if (explicit !== void 0 && explicit !== "") return resolveSandboxWritePath(resolve(explicit), "配置文件");
|
|
893
893
|
const sandbox = process$1.env["NAPUKETTO_SANDBOX_ROOT"];
|
|
894
894
|
if (sandbox) return resolveSandboxWritePath(join(sandbox, MAIN_CONFIG_FILE), "配置文件");
|
|
@@ -5625,14 +5625,14 @@ function getElectronProcessType(proc) {
|
|
|
5625
5625
|
* 默认 engine 配置(按平台探测)。
|
|
5626
5626
|
*
|
|
5627
5627
|
* 平台:`process.platform` → KLINUX/KMAC/KWINDOWS;qua 优先从 wrapper.node 同目录
|
|
5628
|
-
* major.node 扫描(`
|
|
5628
|
+
* major.node 扫描(`NAPUKETTO_WRAPPER_PATH` 由 loader 注入),找不到再按版本拼。
|
|
5629
5629
|
* Linux 实测需要 `V1_LNX_NQ_3.2.35_54395_GW_B`;Windows 旧行为(qua 空)仅在
|
|
5630
5630
|
* 拿不到版本/major.node 时保底。
|
|
5631
5631
|
*/
|
|
5632
5632
|
function defaultEngineConfig(env, qqDataPath) {
|
|
5633
5633
|
const platform = detectPlatformType();
|
|
5634
5634
|
const fullVersion = env.qqVersion ?? "";
|
|
5635
|
-
const wrapperPath = env.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"] ??
|
|
5635
|
+
const wrapperPath = env.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"] ?? "";
|
|
5636
5636
|
const majorPath = wrapperPath !== "" ? join(dirname(wrapperPath), "major.node") : "";
|
|
5637
5637
|
const qua = (majorPath !== "" ? parseQuaFromMajor(majorPath) : null) ?? (fullVersion !== "" ? buildQua(fullVersion, platform) : "");
|
|
5638
5638
|
return {
|
|
@@ -5677,12 +5677,12 @@ function electronProcessType() {
|
|
|
5677
5677
|
*/
|
|
5678
5678
|
function resolveQqUserDataRoot(exports, opts = {}) {
|
|
5679
5679
|
if (process$1.env["NAPUKETTO_SANDBOX_ROOT"]) {
|
|
5680
|
-
const dataRoot = resolveDataRoot(opts.dataRoot || process$1.env["NAPUKETTO_DATA_ROOT"]
|
|
5680
|
+
const dataRoot = resolveDataRoot(opts.dataRoot || process$1.env["NAPUKETTO_DATA_ROOT"]);
|
|
5681
5681
|
resolveSandboxWritePath(resolveQqGlobalPath(dataRoot), "QQ 数据目录");
|
|
5682
5682
|
return dataRoot;
|
|
5683
5683
|
}
|
|
5684
5684
|
if ((opts.platform ?? detectPlatformType()) === PlatformType.KLINUX) {
|
|
5685
|
-
const dataRoot = opts.dataRoot ?? process$1.env["NAPUKETTO_DATA_ROOT"] ?? process$1.env["
|
|
5685
|
+
const dataRoot = opts.dataRoot ?? process$1.env["NAPUKETTO_DATA_ROOT"] ?? process$1.env["NAPUKETTO_DATA"] ?? "";
|
|
5686
5686
|
if (dataRoot !== "") return dataRoot;
|
|
5687
5687
|
}
|
|
5688
5688
|
return extractUserDataRoot(exports) ?? join(homedir(), "Documents", "Tencent Files");
|
|
@@ -5827,7 +5827,7 @@ function startNapuketto(options) {
|
|
|
5827
5827
|
prepareSession(ctx, hasCapturedSession, isSelfHost);
|
|
5828
5828
|
initEngine(ctx, resolveEngineConfig(ctx, env, engineConfig));
|
|
5829
5829
|
resolveLoginService(ctx, qqLoginService);
|
|
5830
|
-
ctx.wrapperPath = env?.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"]
|
|
5830
|
+
ctx.wrapperPath = env?.wrapperPath ?? process$1.env["NAPUKETTO_WRAPPER_PATH"];
|
|
5831
5831
|
if (isSelfHost) activateO3MiscService(wrapperExports);
|
|
5832
5832
|
finishSession(ctx, hasCapturedSession, isSelfHost, sessionConfig);
|
|
5833
5833
|
return ctx;
|
|
@@ -5863,7 +5863,7 @@ function captureSession(ctx, qqSession) {
|
|
|
5863
5863
|
* engine,无需解析。
|
|
5864
5864
|
*
|
|
5865
5865
|
* `dataRoot` 在 Linux 和调试沙箱生效(`resolveQqUserDataRoot` 平台分流):loader 由
|
|
5866
|
-
* `
|
|
5866
|
+
* `NAPUKETTO_DATA_ROOT` 注入,QQ 数据固定落 `<数据根>/nt_qq/global`。
|
|
5867
5867
|
*/
|
|
5868
5868
|
function resolveBootQqGlobalPath(ctx, dataRoot) {
|
|
5869
5869
|
if (electronProcessType() === "browser") return;
|
|
@@ -6203,15 +6203,13 @@ var NapukettoCore = class NapukettoCore {
|
|
|
6203
6203
|
this.stop();
|
|
6204
6204
|
}
|
|
6205
6205
|
};
|
|
6206
|
-
/** wrapperPath
|
|
6207
|
-
const
|
|
6206
|
+
/** wrapperPath 环境变量键(唯一规范拼写)。 */
|
|
6207
|
+
const WRAPPER_PATH_ENV_KEY = "NAPUKETTO_WRAPPER_PATH";
|
|
6208
6208
|
/** 解析 wrapperPath:wrapper 上下文优先,其次环境变量。 */
|
|
6209
6209
|
function resolveWrapperPath$1(wrapper) {
|
|
6210
6210
|
if (wrapper.wrapperPath !== void 0 && wrapper.wrapperPath !== "") return wrapper.wrapperPath;
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
if (value !== void 0 && value !== "") return value;
|
|
6214
|
-
}
|
|
6211
|
+
const value = process$1.env[WRAPPER_PATH_ENV_KEY];
|
|
6212
|
+
if (value !== void 0 && value !== "") return value;
|
|
6215
6213
|
}
|
|
6216
6214
|
/**
|
|
6217
6215
|
* appid 解析:显式传入优先;否则从 wrapperPath 同目录 major.node 解析。
|
|
@@ -6652,9 +6650,9 @@ const LOGIN_GETTER_PROBES = [
|
|
|
6652
6650
|
*
|
|
6653
6651
|
* 注入链路打通后(2026-08-05),wrapper exports 是 QQ 已注册的单例。
|
|
6654
6652
|
* 本模块在 **QQ 主进程内**反射枚举 session / service 的真实方法名与返回形状,
|
|
6655
|
-
* 产出 JSON 到
|
|
6653
|
+
* 产出 JSON 到 NAPUKETTO_CFG_DIR/napuketto-probe.json,作为 types/services/ 的权威来源。
|
|
6656
6654
|
*
|
|
6657
|
-
* 用法:boot.cjs 在
|
|
6655
|
+
* 用法:boot.cjs 在 NAPUKETTO_PROBE=1 时于 startNapuketto 后调用 probeRuntime(ctx)。
|
|
6658
6656
|
* 产物是研究工具数据,类型层据此补全(自研描述,非移植)。
|
|
6659
6657
|
*
|
|
6660
6658
|
* 工具拆分(2026-08-08 FTA 优化):方法枚举/安全调用 → probe-utils.ts;
|
|
@@ -6893,7 +6891,7 @@ function probeServiceGetter(session, getter) {
|
|
|
6893
6891
|
}
|
|
6894
6892
|
/**
|
|
6895
6893
|
* 探测 wrapper 运行时:dump session 方法与各 service 方法名到 JSON。
|
|
6896
|
-
* 返回探测结果对象;同时写文件(
|
|
6894
|
+
* 返回探测结果对象;同时写文件(NAPUKETTO_CFG_DIR/<file>,默认 napuketto-probe.json)。
|
|
6897
6895
|
* 服务枚举逐项增量落盘(persist)——活 session 上原生崩溃时文件保留断点。
|
|
6898
6896
|
*/
|
|
6899
6897
|
function probeRuntime(ctx, file = "napuketto-probe.json") {
|
|
@@ -6914,7 +6912,7 @@ function probeRuntime(ctx, file = "napuketto-probe.json") {
|
|
|
6914
6912
|
/** 探测结果落盘(增量与最终共用;最终写入后记 probeFile 路径)。 */
|
|
6915
6913
|
function writeProbeFile(result, file) {
|
|
6916
6914
|
try {
|
|
6917
|
-
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.
|
|
6915
|
+
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.cwd();
|
|
6918
6916
|
mkdirSync(dir, { recursive: true });
|
|
6919
6917
|
const full = join(dir, file);
|
|
6920
6918
|
writeFileSync(full, JSON.stringify(result, null, 2), "utf8");
|
|
@@ -6932,8 +6930,8 @@ function writeProbeFile(result, file) {
|
|
|
6932
6930
|
* JS 对象 + NAPI 按名反射回调(MsgBridge 模式),用 Proxy get 陷阱构造万能
|
|
6933
6931
|
* 监听器,原生调什么记什么,不需要预先知道回调名。
|
|
6934
6932
|
*
|
|
6935
|
-
* 开关:
|
|
6936
|
-
* 产物:
|
|
6933
|
+
* 开关:NAPUKETTO_LISTENER_RECORD=1(loader bootstrap 挂起,位置与 runProbePhase 相邻)。
|
|
6934
|
+
* 产物:NAPUKETTO_CFG_DIR/napuketto-listener-record.jsonl(JSONL 追加,注册过程
|
|
6937
6935
|
* 逐行落盘,原生崩溃保留断点定位肇事服务)。
|
|
6938
6936
|
*
|
|
6939
6937
|
* 安全边界:记录函数只序列化入参后回调 onEvent,绝不反向调用原生;录制器与
|
|
@@ -7023,7 +7021,7 @@ function createRecordingListener(service, onEvent) {
|
|
|
7023
7021
|
* 空壳的 service getter 函数仍在但调用返回 null(late probe 61/63 null 的根因)。
|
|
7024
7022
|
*/
|
|
7025
7023
|
function startListenerRecording(ctx, file = "napuketto-listener-record.jsonl") {
|
|
7026
|
-
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.
|
|
7024
|
+
const dir = process$1.env["NAPUKETTO_CFG_DIR"] ?? process$1.cwd();
|
|
7027
7025
|
mkdirSync(dir, { recursive: true });
|
|
7028
7026
|
const full = join(dir, file);
|
|
7029
7027
|
writeFileSync(full, "", "utf8");
|
package/package.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@napuketto/kernel",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.1",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "Core runtime kernel of
|
|
6
|
+
"description": "Core runtime kernel of Napuketto",
|
|
7
7
|
"keywords": [
|
|
8
|
-
"qq",
|
|
9
8
|
"qqnt",
|
|
10
9
|
"bot",
|
|
11
10
|
"napuketto",
|
|
12
11
|
"kernel",
|
|
13
12
|
"runtime"
|
|
14
13
|
],
|
|
15
|
-
"homepage": "https://github.com/NapukettoDev/
|
|
14
|
+
"homepage": "https://github.com/NapukettoDev/Napuketto/tree/main/packages/kernel#readme",
|
|
16
15
|
"bugs": {
|
|
17
|
-
"url": "https://github.com/NapukettoDev/
|
|
16
|
+
"url": "https://github.com/NapukettoDev/Napuketto/issues"
|
|
18
17
|
},
|
|
19
18
|
"repository": {
|
|
20
19
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/NapukettoDev/
|
|
20
|
+
"url": "git+https://github.com/NapukettoDev/Napuketto.git",
|
|
22
21
|
"directory": "packages/kernel"
|
|
23
22
|
},
|
|
24
23
|
"license": "MIT",
|