@napuketto/loader 0.4.1 → 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.
@@ -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)。 */
@@ -2472,6 +2474,28 @@ function probeOnce(kernel, ctx) {
2472
2474
  log(`bootstrap: probe error: ${errMsg(e)}`);
2473
2475
  }
2474
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
+ }
2475
2499
  /** 探测模式(NAPUTO_PROBE=1):立即探测 + 35s 后晚探测(napuketto-probe-late.json)。 */
2476
2500
  function runProbePhase(kernel, ctx) {
2477
2501
  if (env.NAPUTO_PROBE !== "1") return;
@@ -2624,6 +2648,7 @@ async function bootstrapWithCore(kernel, state, bootEnv, Appid) {
2624
2648
  return false;
2625
2649
  }
2626
2650
  control.markReady();
2651
+ runListenerRecordingPhase(kernel, ctx);
2627
2652
  runProbePhase(kernel, ctx);
2628
2653
  return true;
2629
2654
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napuketto/loader",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "NapukettoQQ 引导组件:自建宿主(标准 Node + stub QQNT.dll)dlopen wrapper.node 并启动 kernel,不拉起 QQ / 不注入",
5
5
  "type": "module",
6
6
  "files": [