@napuketto/loader 0.4.0 → 0.4.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/host/self-host.cjs +27 -0
- package/package.json +1 -1
package/dist/host/self-host.cjs
CHANGED
|
@@ -371,6 +371,8 @@ const env = {
|
|
|
371
371
|
NAPUTO_SMOKE_PEER: process.env["NAPUTO_SMOKE_PEER"],
|
|
372
372
|
/** 运行时探测开关(=1 触发 probeRuntime)。 */
|
|
373
373
|
NAPUTO_PROBE: process.env["NAPUTO_PROBE"],
|
|
374
|
+
/** listener 录制器开关(=1 触发 startListenerRecording,先于探测挂起——批次三前置)。 */
|
|
375
|
+
NAPUTO_LISTENER_RECORD: process.env["NAPUTO_LISTENER_RECORD"],
|
|
374
376
|
/** 全局 TOML 配置显式路径(优先级最高)。 */
|
|
375
377
|
NAPKETTO_CONFIG: process.env["NAPKETTO_CONFIG"],
|
|
376
378
|
/** 内联主配置 JSON 文本(嵌入式宿主注入;优先级高于 NAPKETTO_CONFIG 文件,2026-10-25)。 */
|
|
@@ -1702,6 +1704,7 @@ async function assembleOb11AndSatori(kernel, services, loginResult) {
|
|
|
1702
1704
|
webApi: services.webApi,
|
|
1703
1705
|
groupNotifyApi: services.groupNotifyApi,
|
|
1704
1706
|
richMediaApi: services.richMediaApi,
|
|
1707
|
+
recentContactApi: services.recentContactApi,
|
|
1705
1708
|
self: services.self,
|
|
1706
1709
|
groupCache,
|
|
1707
1710
|
qqVersion: env.NAPUTO_QQ_VERSION || "unknown",
|
|
@@ -1893,6 +1896,7 @@ async function createKernelServices(kernel, ctx, loginResult, logCfg) {
|
|
|
1893
1896
|
groupNotifyApi,
|
|
1894
1897
|
ticketApi,
|
|
1895
1898
|
richMediaApi: new kernel.RichMediaApi(session),
|
|
1899
|
+
recentContactApi: new kernel.RecentContactApi(session),
|
|
1896
1900
|
profileApi: new kernel.ProfileApi(session),
|
|
1897
1901
|
profileLikeApi: new kernel.ProfileLikeApi(session),
|
|
1898
1902
|
webApi: new kernel.WebApi({ getCookies: (domain) => ticketApi.getCookies(domain, loginResult.uin) }),
|
|
@@ -2470,6 +2474,28 @@ function probeOnce(kernel, ctx) {
|
|
|
2470
2474
|
log(`bootstrap: probe error: ${errMsg(e)}`);
|
|
2471
2475
|
}
|
|
2472
2476
|
}
|
|
2477
|
+
/**
|
|
2478
|
+
* listener 录制模式(NAPUTO_LISTENER_RECORD=1,批次三前置):万能监听器挂满
|
|
2479
|
+
* 候选服务,回调逐行落盘 napuketto-listener-record.jsonl。
|
|
2480
|
+
* ⚠️ 必须先于 runProbePhase——probe 的 getMainSession 写回副作用会毒化
|
|
2481
|
+
* ctx.session(空壳主 session),录制器要先取服务。
|
|
2482
|
+
*/
|
|
2483
|
+
function runListenerRecordingPhase(kernel, ctx) {
|
|
2484
|
+
if (env.NAPUTO_LISTENER_RECORD !== "1") return;
|
|
2485
|
+
if (typeof kernel.startListenerRecording !== "function") {
|
|
2486
|
+
log("bootstrap: listener-record 请求但 kernel 缺 startListenerRecording(kernel 过旧)");
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
try {
|
|
2490
|
+
const rec = kernel.startListenerRecording(ctx);
|
|
2491
|
+
const ok = Object.values(rec.registered).filter((r) => r.ok).length;
|
|
2492
|
+
const total = Object.keys(rec.registered).length;
|
|
2493
|
+
log(`bootstrap: listener-record 挂起 ${ok}/${total} 服务 → ${rec.file}`);
|
|
2494
|
+
for (const [name, r] of Object.entries(rec.registered)) if (!r.ok) log(`bootstrap: listener-record ${name} 未挂: ${r.error ?? "unknown"}`);
|
|
2495
|
+
} catch (e) {
|
|
2496
|
+
log(`bootstrap: listener-record error: ${errMsg(e)}`);
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2473
2499
|
/** 探测模式(NAPUTO_PROBE=1):立即探测 + 35s 后晚探测(napuketto-probe-late.json)。 */
|
|
2474
2500
|
function runProbePhase(kernel, ctx) {
|
|
2475
2501
|
if (env.NAPUTO_PROBE !== "1") return;
|
|
@@ -2622,6 +2648,7 @@ async function bootstrapWithCore(kernel, state, bootEnv, Appid) {
|
|
|
2622
2648
|
return false;
|
|
2623
2649
|
}
|
|
2624
2650
|
control.markReady();
|
|
2651
|
+
runListenerRecordingPhase(kernel, ctx);
|
|
2625
2652
|
runProbePhase(kernel, ctx);
|
|
2626
2653
|
return true;
|
|
2627
2654
|
}
|