engine7 7.1.130 → 7.1.132

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.
@@ -29138,6 +29138,18 @@ function defaultProviderKey(cfg) {
29138
29138
  }
29139
29139
  return "";
29140
29140
  }
29141
+ function needsMem7EnableForFreeInstall(cfg) {
29142
+ if (cfg?.mem7?.enabled !== void 0) return false;
29143
+ if (!cfg?.models?.providers?.[FREE_TIER_PROVIDER_ID]) return false;
29144
+ return defaultProviderKey(cfg) !== "";
29145
+ }
29146
+ async function applyMem7EnableForFreeInstall(io) {
29147
+ const cfg = io.all();
29148
+ if (!needsMem7EnableForFreeInstall(cfg)) return false;
29149
+ const changed = await io.set("mem7.enabled", true);
29150
+ if (changed) console.log("[startup] mem7 enabled for legacy free-tier install (1026 \u51B3\u7B56\u8865\u5168\uFF0C1102)");
29151
+ return changed === true;
29152
+ }
29141
29153
  function usesDefaultProvider(cfg) {
29142
29154
  const defaults = mem7ServiceDefaults(cfg.mem7, cfg.everos?.rerank);
29143
29155
  return Object.keys(defaults).length > 0 || [cfg.mem7?.embedding, cfg.mem7?.rerank ?? cfg.everos?.rerank].some((service) => typeof service?.model === "string" && service.model.startsWith(`${FREE_TIER_PROVIDER_ID}/`));
@@ -29214,6 +29226,96 @@ var init_mem7_services_fixup = __esm({
29214
29226
  }
29215
29227
  });
29216
29228
 
29229
+ // src/free-tier-apply.ts
29230
+ function isFreeTierConfig(cfg) {
29231
+ const hasProvider = !!cfg?.models?.providers?.[FREE_TIER_PROVIDER_ID];
29232
+ const primary = String(cfg?.agents?.defaults?.model?.primary || "");
29233
+ return hasProvider && primary.startsWith(`${FREE_TIER_PROVIDER_ID}/`);
29234
+ }
29235
+ var init_free_tier_apply = __esm({
29236
+ "src/free-tier-apply.ts"() {
29237
+ "use strict";
29238
+ init_cli_init_config();
29239
+ init_provision_free();
29240
+ init_cli_init_config();
29241
+ }
29242
+ });
29243
+
29244
+ // src/startup/free-tier-nort-fixup.ts
29245
+ function legacyDefaultExtract(cfg) {
29246
+ const ex = cfg?.topics?.extract;
29247
+ if (typeof ex?.model !== "string") return false;
29248
+ const model = ex.model.trim();
29249
+ const provider = typeof ex.provider === "string" ? ex.provider.trim() : "";
29250
+ if (model === FREE_TIER_FAST_REF && (!provider || provider === FREE_TIER_PROVIDER_ID)) return true;
29251
+ return provider === FREE_TIER_PROVIDER_ID && (LANE_MODELS.some((id) => id === model) || model === FREE_TIER_NORT_REF);
29252
+ }
29253
+ function needsFreeTierNortFixup(cfg) {
29254
+ const free = isFreeTierConfig(cfg);
29255
+ if (!free && !legacyDefaultExtract(cfg)) return false;
29256
+ const provider = cfg?.models?.providers?.[FREE_TIER_PROVIDER_ID];
29257
+ if (!provider) return false;
29258
+ const lanes = free || readPath(cfg, "topics.clean.model") === void 0 ? LANE_MODELS : [FREE_TIER_NORT_MODEL];
29259
+ if (lanes.some((id) => !(provider.models || []).some((m) => m?.id === id))) return true;
29260
+ return free && Object.keys(FIELD_REFS).some((path86) => readPath(cfg, path86) === void 0) || legacyDefaultExtract(cfg);
29261
+ }
29262
+ function readPath(obj, dotPath) {
29263
+ return dotPath.split(".").reduce((acc, k) => acc == null ? void 0 : acc[k], obj);
29264
+ }
29265
+ async function applyFreeTierNortFixup(io) {
29266
+ const cfg = io.all();
29267
+ if (!needsFreeTierNortFixup(cfg)) return false;
29268
+ const provider = cfg.models.providers[FREE_TIER_PROVIDER_ID];
29269
+ const registry2 = PROVIDER_DEFS[FREE_TIER_PROVIDER_ID]?.models ?? [];
29270
+ const free = isFreeTierConfig(cfg);
29271
+ const lanes = free || readPath(cfg, "topics.clean.model") === void 0 ? LANE_MODELS : [FREE_TIER_NORT_MODEL];
29272
+ const missingEntries = lanes.filter((id) => !(provider.models || []).some((m) => m?.id === id)).map((id) => registry2.find((m) => m.id === id));
29273
+ if (missingEntries.some((entry) => !entry)) return false;
29274
+ const writes = [];
29275
+ if (missingEntries.length) {
29276
+ const newModels = [...provider.models || [], ...missingEntries.map((entry) => ({ ...entry }))];
29277
+ writes.push([`models.providers.${FREE_TIER_PROVIDER_ID}.models`, newModels]);
29278
+ const pCopy = cfg.providers?.[FREE_TIER_PROVIDER_ID];
29279
+ if (pCopy && pCopy !== provider) pCopy.models = newModels;
29280
+ }
29281
+ for (const [path86, ref] of Object.entries(FIELD_REFS)) {
29282
+ if (free && readPath(cfg, path86) === void 0) writes.push([path86, ref]);
29283
+ }
29284
+ if (!free && readPath(cfg, "topics.clean.model") === void 0) {
29285
+ writes.push(["topics.clean.model", FREE_TIER_FAST_REF]);
29286
+ }
29287
+ const migratedLegacyExtract = legacyDefaultExtract(cfg);
29288
+ if (migratedLegacyExtract) {
29289
+ writes.push(["topics.extract.model", FREE_TIER_NORT_REF]);
29290
+ if ("provider" in cfg.topics.extract) writes.push(["topics.extract.provider", void 0]);
29291
+ }
29292
+ if (!writes.length) return false;
29293
+ let persisted = true;
29294
+ for (const [path86, value] of writes) {
29295
+ if (await io.set(path86, value) === false) persisted = false;
29296
+ }
29297
+ if (!persisted) {
29298
+ console.error("[startup] \u540E\u53F0\u6A21\u578B\u8865\u9F50 **\u672A\u5168\u90E8\u843D\u76D8**\uFF08\u672C\u6B21\u8FD0\u884C\u5185\u5B58\u91CC\u5DF2\u751F\u6548\uFF0C\u914D\u7F6E\u6587\u4EF6\u4ECD\u662F\u65E7\u7684\u2014\u2014\u4E0B\u6B21\u542F\u52A8\u4F1A\u91CD\u653E\uFF09\u3002\u4E0A\u9762 [liveConfig] \u90A3\u51E0\u884C\u662F\u539F\u56E0\u3002");
29299
+ return true;
29300
+ }
29301
+ console.log(`[startup] \u540E\u53F0\u6A21\u578B\u914D\u7F6E\u5DF2\u8865\u9F50\uFF08${writes.map(([p]) => p).join(", ")}\uFF1B\u81EA\u5B9A\u4E49\u6A21\u578B\u4FDD\u7559${migratedLegacyExtract ? `\uFF1B\u65E7\u9ED8\u8BA4 extract \u5DF2\u8FC1 ${FREE_TIER_NORT_REF}` : ""}\uFF09`);
29302
+ return true;
29303
+ }
29304
+ var FIELD_REFS, LANE_MODELS;
29305
+ var init_free_tier_nort_fixup = __esm({
29306
+ "src/startup/free-tier-nort-fixup.ts"() {
29307
+ "use strict";
29308
+ init_cli_init_config();
29309
+ init_free_tier_apply();
29310
+ FIELD_REFS = {
29311
+ "topics.extract.model": FREE_TIER_NORT_REF,
29312
+ "topics.clean.model": FREE_TIER_FAST_REF,
29313
+ "innerVoice.model": FREE_TIER_NORT_REF
29314
+ };
29315
+ LANE_MODELS = [FREE_TIER_FAST_MODEL, FREE_TIER_NORT_MODEL];
29316
+ }
29317
+ });
29318
+
29217
29319
  // src/reload/orchestrator.ts
29218
29320
  function sliceEnabled(slice) {
29219
29321
  if (slice == null) return false;
@@ -29457,6 +29559,7 @@ async function doReloadConfigInner(config, deps, provider, force = false) {
29457
29559
  });
29458
29560
  reloadOrchestrator.beginReload();
29459
29561
  liveConfig.assign(newConfig);
29562
+ await applyFreeTierNortFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
29460
29563
  await applyMem7ServicesFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
29461
29564
  console.log(`[reload-debug] newConfig.tools.my_voice.provider = ${newConfig?.tools?.my_voice?.provider}`);
29462
29565
  console.log(`[reload-debug] post-assign liveConfig.tools.my_voice = ${JSON.stringify(liveConfig.get("tools.my_voice"))}`);
@@ -29697,6 +29800,7 @@ function startSecretsWatcher(config, deps, provider, watchFn = fs14.watch) {
29697
29800
  try {
29698
29801
  const content = fs14.readFileSync(p, "utf-8");
29699
29802
  let updated = 0;
29803
+ const changedKeys = [];
29700
29804
  for (const line of content.split("\n")) {
29701
29805
  const trimmed = line.trim();
29702
29806
  if (!trimmed || trimmed.startsWith("#")) continue;
@@ -29705,12 +29809,13 @@ function startSecretsWatcher(config, deps, provider, watchFn = fs14.watch) {
29705
29809
  const k = trimmed.slice(0, eq).trim();
29706
29810
  const v = trimmed.slice(eq + 1).trim();
29707
29811
  if (k) {
29812
+ if (process.env[k] !== v) changedKeys.push(k);
29708
29813
  process.env[k] = v;
29709
29814
  updated++;
29710
29815
  }
29711
29816
  }
29712
29817
  }
29713
- console.log(`[secrets-watch] ${updated} keys reloaded from ${p}`);
29818
+ console.log(`[secrets-watch] ${updated} keys loaded, ${changedKeys.length} changed` + (changedKeys.length ? `: ${changedKeys.join(", ")} (values not logged)` : "") + ` \u2014 from ${p}`);
29714
29819
  console.log(`[secrets-watch] force reload\uFF08\u8DF3\u8FC7\u539F\u6587\u5BF9\u6BD4\uFF09`);
29715
29820
  const result = await doReloadConfig(config, deps, provider, true);
29716
29821
  console.log(`[secrets-watch] config reloaded: ok=${result.ok} changes=${result.changes.join(",")}`);
@@ -29766,6 +29871,7 @@ var init_reload = __esm({
29766
29871
  "use strict";
29767
29872
  init_loader();
29768
29873
  init_mem7_services_fixup();
29874
+ init_free_tier_nort_fixup();
29769
29875
  init_live();
29770
29876
  init_secrets_env();
29771
29877
  init_orchestrator();
@@ -38474,6 +38580,27 @@ var init_ffmpeg_path = __esm({
38474
38580
  }
38475
38581
  });
38476
38582
 
38583
+ // src/utils/api-port.ts
38584
+ var api_port_exports = {};
38585
+ __export(api_port_exports, {
38586
+ computeApiPort: () => computeApiPort
38587
+ });
38588
+ function computeApiPort(config) {
38589
+ const basePort = config.api?.port || 16890;
38590
+ const profileId = config.profile?.id;
38591
+ if (profileId && profileId !== "default") {
38592
+ let hash6 = 0;
38593
+ for (const ch of profileId) hash6 = (hash6 << 5) - hash6 + ch.charCodeAt(0) | 0;
38594
+ return basePort + Math.abs(hash6) % 100;
38595
+ }
38596
+ return basePort;
38597
+ }
38598
+ var init_api_port = __esm({
38599
+ "src/utils/api-port.ts"() {
38600
+ "use strict";
38601
+ }
38602
+ });
38603
+
38477
38604
  // src/startup/skill-sync.ts
38478
38605
  import * as fs22 from "node:fs";
38479
38606
  import * as path19 from "node:path";
@@ -43862,8 +43989,12 @@ ${conversationText}`
43862
43989
  let result = "";
43863
43990
  let completed = false;
43864
43991
  let hadError = false;
43992
+ let completionReason;
43865
43993
  for await (const chunk of extractEngine.query(extractMessages, void 0, toolContext)) {
43866
- if (chunk.type === "result") completed = chunk.completionReason === "completed";
43994
+ if (chunk.type === "result") {
43995
+ completionReason = chunk.completionReason;
43996
+ completed = completionReason === "completed";
43997
+ }
43867
43998
  if (chunk.type === "error" || chunk.type === "tool_result" && chunk.isError) hadError = true;
43868
43999
  if (chunk.type === "text" && chunk.text) {
43869
44000
  result += chunk.text;
@@ -43873,7 +44004,7 @@ ${conversationText}`
43873
44004
  }
43874
44005
  }
43875
44006
  if (!completed || hadError || generation !== (state2.generations.get(sessionId) ?? 0)) {
43876
- console.warn(`[memory] extractMemories incomplete \u2014 input remains eligible, tools=${toolCount}, error=${hadError}`);
44007
+ console.warn(`[memory] extractMemories incomplete \u2014 input remains eligible, tools=${toolCount}, error=${hadError}, reason=${completionReason ?? "unknown"}, reset=${generation !== (state2.generations.get(sessionId) ?? 0)}`);
43877
44008
  return;
43878
44009
  }
43879
44010
  if (maxNewTs > 0) state2.lastTs.set(sessionId, maxNewTs);
@@ -43900,11 +44031,15 @@ ${conversationText}`
43900
44031
  },
43901
44032
  execute(messages, provider, model, sessionId, disableThinking, intervalMinutes) {
43902
44033
  if (!enabled) return Promise.resolve();
44034
+ const generation = state2.generations.get(sessionId) ?? 0;
43903
44035
  const previous = state2.tail;
43904
44036
  const lastTime = state2.lastExtractTime.get(sessionId);
43905
44037
  const alreadyCoolingDown = Boolean(intervalMinutes && intervalMinutes > 0 && lastTime && Date.now() - lastTime < intervalMinutes * 6e4);
43906
44038
  const snapshot = structuredClone(messages);
43907
- const task = (previous ?? Promise.resolve()).then(() => extract(snapshot, provider, model, sessionId, disableThinking, previous && !alreadyCoolingDown ? 0 : intervalMinutes));
44039
+ const task = (previous ?? Promise.resolve()).then(() => {
44040
+ if (generation !== (state2.generations.get(sessionId) ?? 0)) return;
44041
+ return extract(snapshot, provider, model, sessionId, disableThinking, previous && !alreadyCoolingDown ? 0 : intervalMinutes);
44042
+ });
43908
44043
  const tail2 = task.finally(() => {
43909
44044
  if (state2.tail === tail2) state2.tail = void 0;
43910
44045
  });
@@ -48349,27 +48484,6 @@ var init_qr_render = __esm({
48349
48484
  }
48350
48485
  });
48351
48486
 
48352
- // src/utils/api-port.ts
48353
- var api_port_exports = {};
48354
- __export(api_port_exports, {
48355
- computeApiPort: () => computeApiPort
48356
- });
48357
- function computeApiPort(config) {
48358
- const basePort = config.api?.port || 16890;
48359
- const profileId = config.profile?.id;
48360
- if (profileId && profileId !== "default") {
48361
- let hash6 = 0;
48362
- for (const ch of profileId) hash6 = (hash6 << 5) - hash6 + ch.charCodeAt(0) | 0;
48363
- return basePort + Math.abs(hash6) % 100;
48364
- }
48365
- return basePort;
48366
- }
48367
- var init_api_port = __esm({
48368
- "src/utils/api-port.ts"() {
48369
- "use strict";
48370
- }
48371
- });
48372
-
48373
48487
  // src/version.ts
48374
48488
  import { readFileSync as readFileSync57 } from "node:fs";
48375
48489
  import { dirname as dirname23, join as join77 } from "node:path";
@@ -49297,7 +49411,7 @@ __export(voice_chat_tts_daemon_exports, {
49297
49411
  stopTtsDaemon: () => stopTtsDaemon
49298
49412
  });
49299
49413
  import { spawn as spawn5 } from "child_process";
49300
- import net2 from "net";
49414
+ import net3 from "net";
49301
49415
  import path54 from "path";
49302
49416
  import fs53 from "fs";
49303
49417
  function _log(msg2) {
@@ -49305,7 +49419,7 @@ function _log(msg2) {
49305
49419
  }
49306
49420
  function _healthOnce() {
49307
49421
  return new Promise((resolve26) => {
49308
- const sock = net2.connect(SOCK_PATH);
49422
+ const sock = net3.connect(SOCK_PATH);
49309
49423
  sock.setTimeout(2e3);
49310
49424
  sock.on("connect", () => {
49311
49425
  sock.write(JSON.stringify({ action: "health" }) + "\n");
@@ -54344,12 +54458,18 @@ function splitBubbles(message) {
54344
54458
  init_providers();
54345
54459
  init_reload();
54346
54460
 
54461
+ // src/reload/channels-entry.ts
54462
+ function channelsSelectSlice(cfg) {
54463
+ return { enabled: true, channels: cfg?.channels ?? null };
54464
+ }
54465
+
54347
54466
  // src/startup/bootstrap.ts
54348
54467
  import * as fs24 from "node:fs";
54349
54468
  import * as path21 from "node:path";
54350
54469
 
54351
54470
  // src/pid-lock.ts
54352
54471
  import fs15 from "node:fs";
54472
+ import net from "node:net";
54353
54473
  import path14 from "node:path";
54354
54474
  import { execSync as execSync2 } from "node:child_process";
54355
54475
  function enginePidFile(stateDir) {
@@ -54361,7 +54481,25 @@ function isEngineImage(text) {
54361
54481
  function isPidAlive(pid) {
54362
54482
  try {
54363
54483
  process.kill(pid, 0);
54364
- return true;
54484
+ } catch (err) {
54485
+ return err?.code === "EPERM";
54486
+ }
54487
+ return !isPidZombie(pid);
54488
+ }
54489
+ function statFieldIsZombie(statContent) {
54490
+ const state2 = statContent.slice(statContent.lastIndexOf(")") + 2).trim().charAt(0);
54491
+ return state2 === "Z";
54492
+ }
54493
+ function isPidZombie(pid) {
54494
+ try {
54495
+ if (process.platform === "linux") {
54496
+ return statFieldIsZombie(fs15.readFileSync(`/proc/${pid}/stat`, "utf-8"));
54497
+ }
54498
+ if (process.platform === "darwin") {
54499
+ const st = execSync2(`ps -p ${pid} -o stat=`, { encoding: "utf-8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] });
54500
+ return st.trim().startsWith("Z");
54501
+ }
54502
+ return false;
54365
54503
  } catch {
54366
54504
  return false;
54367
54505
  }
@@ -54444,6 +54582,206 @@ function ownEnginePid(stateDir, myPid = process.pid) {
54444
54582
  isEngineImage: probeEngineImage
54445
54583
  });
54446
54584
  }
54585
+ function decidePortEviction(probe) {
54586
+ if (probe.ownerPid === null) return { action: "none" };
54587
+ if (probe.ownerPid === probe.myPid) return { action: "skip-self", pid: probe.ownerPid };
54588
+ const image = probe.imageText ?? "";
54589
+ if (!isEngineImage(image)) return { action: "skip-foreign", pid: probe.ownerPid, reason: "image" };
54590
+ if (imageBasename(image) === "engine7") return { action: "kill", pid: probe.ownerPid };
54591
+ if (probe.commandLineOk === true) return { action: "kill", pid: probe.ownerPid };
54592
+ if (probe.commandLineOk === false) return { action: "skip-foreign", pid: probe.ownerPid, reason: "cmdline" };
54593
+ return { action: "skip-foreign", pid: probe.ownerPid, reason: "cmdline-unprobeable" };
54594
+ }
54595
+ function imageBasename(imageText) {
54596
+ const s = (imageText ?? "").trim();
54597
+ if (!s) return "";
54598
+ const firstField = s.split(",")[0].trim().replace(/^"|"$/g, "");
54599
+ const base = firstField.split(/[\\/]/).pop() ?? firstField;
54600
+ return base.replace(/\.exe$/i, "").toLowerCase();
54601
+ }
54602
+ function pickConflictingPortOwners(probeOutput, port, myPid = process.pid) {
54603
+ if (!probeOutput) return [];
54604
+ const out = /* @__PURE__ */ new Set();
54605
+ const conflict = (addr) => {
54606
+ let a = addr.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
54607
+ if (a.startsWith("::ffff:")) a = a.slice("::ffff:".length);
54608
+ return a === "*" || a === "0.0.0.0" || a === "127.0.0.1" || a === "::";
54609
+ };
54610
+ for (const line of probeOutput.split(/\r?\n/)) {
54611
+ const net5 = /^\s*TCP\s+(\S*?):(\d+)\s+\S+\s+LISTENING\s+(\d+)\s*$/i.exec(line);
54612
+ if (net5) {
54613
+ const pid = Number(net5[3]);
54614
+ if (Number(net5[2]) === port && conflict(net5[1]) && pid !== myPid) out.add(pid);
54615
+ continue;
54616
+ }
54617
+ const cols = line.trim().split(/\s+/);
54618
+ if (cols.length >= 9 && /^\d+$/.test(cols[1] ?? "")) {
54619
+ const pid = Number(cols[1]);
54620
+ let name = cols[cols.length - 1] ?? "";
54621
+ if (/^\(/.test(name)) name = cols[cols.length - 2] ?? "";
54622
+ const lp = name.lastIndexOf(":");
54623
+ if (lp > 0 && Number(name.slice(lp + 1)) === port && conflict(name.slice(0, lp)) && pid !== myPid) out.add(pid);
54624
+ continue;
54625
+ }
54626
+ if (line.includes("pid=")) {
54627
+ const m = /^\S+\s+\d+\s+\d+\s+(\S+?):(\d+)\s/.exec(line);
54628
+ const pids = [...line.matchAll(/pid=(\d+)/g)].map((x) => Number(x[1]));
54629
+ if (m && Number(m[2]) === port && conflict(m[1])) {
54630
+ for (const pid of pids) if (pid !== myPid) out.add(pid);
54631
+ }
54632
+ }
54633
+ }
54634
+ return [...out];
54635
+ }
54636
+ function probePortOwnersRaw(port) {
54637
+ try {
54638
+ if (process.platform === "win32") {
54639
+ return { output: execSync2("netstat -ano -p tcp", {
54640
+ encoding: "utf-8",
54641
+ timeout: 5e3,
54642
+ stdio: ["ignore", "pipe", "ignore"],
54643
+ windowsHide: true
54644
+ // 1011:GUI 宿主下别闪黑窗
54645
+ }), unknown: false };
54646
+ }
54647
+ if (process.platform === "darwin") {
54648
+ return { output: execSync2(`lsof -nP -iTCP:${port} -sTCP:LISTEN`, {
54649
+ encoding: "utf-8",
54650
+ timeout: 5e3,
54651
+ stdio: ["ignore", "pipe", "ignore"]
54652
+ }), unknown: false };
54653
+ }
54654
+ return { output: execSync2(`ss -lptn sport = :${port}`, {
54655
+ encoding: "utf-8",
54656
+ timeout: 5e3,
54657
+ stdio: ["ignore", "pipe", "ignore"]
54658
+ }), unknown: false };
54659
+ } catch (err) {
54660
+ const status = err?.status;
54661
+ const unknown = status === null || status === void 0 || status === 127 || status > 1 || err?.code === "ENOENT" || err?.code === "ETIMEDOUT";
54662
+ return { output: null, unknown };
54663
+ }
54664
+ }
54665
+ function engineCommandlineMentions(pid, stateDir) {
54666
+ let cmd = "";
54667
+ try {
54668
+ if (process.platform === "win32") {
54669
+ cmd = execSync2(
54670
+ `powershell -NoProfile -Command "(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine"`,
54671
+ { encoding: "utf-8", timeout: 1e4, stdio: ["ignore", "pipe", "ignore"], windowsHide: true }
54672
+ );
54673
+ } else if (process.platform === "darwin") {
54674
+ cmd = execSync2(`ps -p ${pid} -o command=`, { encoding: "utf-8", timeout: 3e3, stdio: ["ignore", "pipe", "ignore"] });
54675
+ } else {
54676
+ cmd = fs15.readFileSync(`/proc/${pid}/cmdline`, "utf-8").replace(/\0/g, " ");
54677
+ }
54678
+ } catch {
54679
+ return false;
54680
+ }
54681
+ return commandlineMentionsEngine(cmd, stateDir);
54682
+ }
54683
+ function commandlineMentionsEngine(cmd, stateDir) {
54684
+ const normalized = (cmd || "").toLowerCase();
54685
+ const dir = (stateDir || "").toLowerCase();
54686
+ if (dir && normalized.includes(dir)) return true;
54687
+ return /(?:^|[\\/":\s])engine7(?=$|[\\/."'\s])/.test(normalized);
54688
+ }
54689
+ function classifyPortOwner(pid, stateDir, myPid) {
54690
+ const imageText = probeImage(pid);
54691
+ const commandLineOk = imageBasename(imageText) === "engine7" ? true : /^(node|electron)(\.exe)?$/i.test(imageBasename(imageText)) ? engineCommandlineMentions(pid, stateDir) : false;
54692
+ return { decision: decidePortEviction({ ownerPid: pid, imageText, commandLineOk, myPid }), imageText };
54693
+ }
54694
+ function skipReason(decision) {
54695
+ return decision.action === "skip-self" ? "\u672C\u8FDB\u7A0B" : decision.action === "skip-foreign" && decision.reason === "image" ? "\u975E\u5F15\u64CE\u6620\u50CF" : decision.action === "skip-foreign" && decision.reason === "cmdline" ? "\u547D\u4EE4\u884C\u4E0D\u542B engine7/stateDir\uFF08\u65E0\u5173 node \u7A0B\u5E8F\uFF09" : "\u547D\u4EE4\u884C\u63A2\u4E0D\u5230\uFF08\u4FDD\u5B88\u4E0D\u6740\uFF09";
54696
+ }
54697
+ async function evictEngineOnApiPort(stateDir, apiPort, myPid = process.pid) {
54698
+ const probe1 = probePortOwnersRaw(apiPort);
54699
+ if (probe1.unknown) {
54700
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u6E05\u573A\u63A2\u9488\u8DD1\u4E0D\u4E86\uFF08\u547D\u4EE4\u7F3A\u5931/\u8D85\u65F6\uFF09\u2014\u2014\u515C\u5E95\u8FD9\u8F6E\u5931\u6548\uFF0C\u7531\u62A2\u9501\u65B9\u8BD5\u7ED1\u7AEF\u53E3\u88C1\u51B3\u3002`);
54701
+ return { killed: [], blockedKind: "foreign", probeUnknown: true, remaining: [] };
54702
+ }
54703
+ const owners = pickConflictingPortOwners(probe1.output, apiPort, myPid);
54704
+ const killed = [];
54705
+ let sawUndead = false;
54706
+ for (const pid of owners) {
54707
+ const { decision, imageText } = classifyPortOwner(pid, stateDir, myPid);
54708
+ if (decision.action !== "kill") {
54709
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u88AB\u975E\u6E05\u573A\u76EE\u6807\u5360\u7528\uFF08pid ${pid}\uFF0C\u6620\u50CF ${(imageText ?? "").trim().slice(0, 60) || "\u63A2\u4E0D\u5230"}\uFF1B${skipReason(decision)}\uFF09\u2014\u2014\u4E0D\u52A8\u5B83\u3002`);
54710
+ continue;
54711
+ }
54712
+ console.log(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u88AB\u65E7\u5F15\u64CE\u5B9E\u4F8B\u5360\u7528\uFF08pid ${pid}\uFF09\uFF0C\u6E05\u573A...`);
54713
+ killAndLog(stateDir, pid, `api port ${apiPort} occupied by stale engine`);
54714
+ if (await waitForPidGone(pid)) killed.push(pid);
54715
+ else sawUndead = true;
54716
+ }
54717
+ const probe2 = probePortOwnersRaw(apiPort);
54718
+ if (probe2.unknown) {
54719
+ if (sawUndead) {
54720
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u7684\u65E7\u5F15\u64CE\u6CA1\u80FD\u6740\u6389\uFF0C\u4E14\u590D\u6838\u63A2\u9488\u4E5F\u5931\u6548\u2014\u2014\u6309\u53CC\u5F00\u98CE\u9669\u5904\u7406\uFF0C\u5F15\u64CE\u62D2\u7EDD\u5E26\u75C5\u542F\u52A8\u3002`);
54721
+ return { killed, blockedKind: "undead", probeUnknown: true, remaining: [] };
54722
+ }
54723
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u590D\u6838\u63A2\u9488\u5931\u6548\u2014\u2014\u7531\u62A2\u9501\u65B9\u8BD5\u7ED1\u7AEF\u53E3\u88C1\u51B3\u3002`);
54724
+ return { killed, blockedKind: "foreign", probeUnknown: true, remaining: [] };
54725
+ }
54726
+ for (const pid of pickConflictingPortOwners(probe2.output, apiPort, myPid)) {
54727
+ const { decision, imageText } = classifyPortOwner(pid, stateDir, myPid);
54728
+ if (decision.action !== "kill") {
54729
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u88AB\u975E\u6E05\u573A\u76EE\u6807\u5360\u7528\uFF08pid ${pid}\uFF0C\u6620\u50CF ${(imageText ?? "").trim().slice(0, 60) || "\u63A2\u4E0D\u5230"}\uFF1B${skipReason(decision)}\uFF09\u2014\u2014\u4E0D\u52A8\u5B83\u3002`);
54730
+ continue;
54731
+ }
54732
+ console.log(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u590D\u6838\u53D1\u73B0\u65B0\u5360\u7528\uFF08pid ${pid}\uFF09\uFF0C\u518D\u6E05\u4E00\u6B21...`);
54733
+ killAndLog(stateDir, pid, `api port ${apiPort} re-check kill`);
54734
+ if (await waitForPidGone(pid)) killed.push(pid);
54735
+ else sawUndead = true;
54736
+ }
54737
+ const probe3 = probePortOwnersRaw(apiPort);
54738
+ const remaining = probe3.unknown ? [] : pickConflictingPortOwners(probe3.output, apiPort, myPid);
54739
+ let remainingEngine = false;
54740
+ for (const pid of remaining) {
54741
+ const { decision, imageText } = classifyPortOwner(pid, stateDir, myPid);
54742
+ if (decision.action === "kill") {
54743
+ remainingEngine = true;
54744
+ continue;
54745
+ }
54746
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u88AB\u975E\u6E05\u573A\u76EE\u6807\u5360\u7528\uFF08pid ${pid}\uFF0C\u6620\u50CF ${(imageText ?? "").trim().slice(0, 60) || "\u63A2\u4E0D\u5230"}\uFF1B${skipReason(decision)}\uFF09\u2014\u2014\u4E0D\u52A8\u5B83\u3002`);
54747
+ }
54748
+ if (sawUndead || remainingEngine) {
54749
+ console.error(`[pid-lock] \u7AEF\u53E3 ${apiPort} \u4ECD\u6709\u5F15\u64CE\u8EAB\u4EFD\u7684\u5360\u7528\u8005\uFF08${remaining.join(",")}\uFF09${sawUndead ? "\uFF08\u6216\u6709\u7B49\u6B7B\u5931\u8D25\uFF09" : ""}\u2014\u2014\u6309\u53CC\u5F00\u98CE\u9669\u5904\u7406\uFF0C\u5F15\u64CE\u62D2\u7EDD\u5E26\u75C5\u542F\u52A8\u3002`);
54750
+ return { killed, blockedKind: "undead", probeUnknown: false, remaining };
54751
+ }
54752
+ if (remaining.length > 0) return { killed, blockedKind: "foreign", probeUnknown: false, remaining };
54753
+ return { killed, blockedKind: "none", probeUnknown: false, remaining: [] };
54754
+ }
54755
+ var EngineLockConflictError = class extends Error {
54756
+ };
54757
+ function tryBindLoopback(port, timeoutMs = 3e3) {
54758
+ return new Promise((resolve26) => {
54759
+ let settled = false;
54760
+ const srv = net.createServer();
54761
+ const finish = (ok) => {
54762
+ if (settled) return;
54763
+ settled = true;
54764
+ clearTimeout(timer);
54765
+ try {
54766
+ srv.close();
54767
+ } catch {
54768
+ }
54769
+ resolve26(ok);
54770
+ };
54771
+ const timer = setTimeout(() => finish(false), timeoutMs);
54772
+ srv.once("error", () => finish(false));
54773
+ srv.listen({ port, host: "127.0.0.1" }, () => finish(true));
54774
+ });
54775
+ }
54776
+ function pickRacingLockOwner(probe) {
54777
+ const cur = parseInt((probe.pidFileContent ?? "").trim(), 10);
54778
+ if (!Number.isInteger(cur) || cur <= 0) return null;
54779
+ if (cur === probe.myPid) return null;
54780
+ if (cur === probe.stalePid) return null;
54781
+ if (!probe.isAlive(cur)) return null;
54782
+ if (!probe.isEngineImage(cur)) return null;
54783
+ return cur;
54784
+ }
54447
54785
  async function waitForPidGone(pid, timeoutMs = 5e3) {
54448
54786
  const t0 = Date.now();
54449
54787
  while (Date.now() - t0 < timeoutMs) {
@@ -54452,13 +54790,47 @@ async function waitForPidGone(pid, timeoutMs = 5e3) {
54452
54790
  }
54453
54791
  return !isPidAlive(pid);
54454
54792
  }
54455
- function acquireEngineLock(stateDir) {
54793
+ async function acquireEngineLock(stateDir, apiPort) {
54456
54794
  const lockFile = enginePidFile(stateDir);
54457
54795
  const myPid = process.pid;
54458
54796
  const stale = ownEnginePid(stateDir, myPid);
54459
54797
  if (stale !== null) {
54460
54798
  console.log(`[pid-lock] Stale engine PID ${stale} still alive (engine), killing tree...`);
54461
54799
  killAndLog(stateDir, stale, "stale engine in lock file");
54800
+ if (!await waitForPidGone(stale)) {
54801
+ throw new EngineLockConflictError(
54802
+ `pid \u6587\u4EF6\u91CC\u7684\u65E7\u5F15\u64CE\uFF08pid ${stale}\uFF09\u6740\u4E0D\u6389\uFF08\u63D0\u6743/\u6740\u8F6F\u63E1\u7740\uFF1F\uFF09\u2014\u2014\u62D2\u7EDD\u5E26\u75C5\u542F\u52A8\uFF0C\u907F\u514D\u4E0E\u5B83\u53CC\u5F00\u3002 \u5904\u7F6E\uFF1A\u4ECE\u4EFB\u52A1\u7BA1\u7406\u5668\u7ED3\u675F\u8BE5\u8FDB\u7A0B\uFF0C\u6216\u7528\u7BA1\u7406\u5458\u6743\u9650\u91CD\u8BD5\uFF0C\u518D\u542F\u52A8\u5F15\u64CE\u3002`
54803
+ );
54804
+ }
54805
+ }
54806
+ if (apiPort && apiPort > 0) {
54807
+ const evict = await evictEngineOnApiPort(stateDir, apiPort, myPid);
54808
+ if (evict.blockedKind === "undead") {
54809
+ throw new EngineLockConflictError(
54810
+ `API \u7AEF\u53E3 ${apiPort} \u88AB\u6740\u4E0D\u6389\u7684\u65E7\u5F15\u64CE\u5B9E\u4F8B\u5360\u7740\uFF08pid ${evict.remaining.join(",")}\uFF09\u2014\u2014\u62D2\u7EDD\u5E26\u75C5\u542F\u52A8\uFF0C\u907F\u514D\u53CC\u5F00\u3002 \u5904\u7F6E\uFF1A\u4ECE\u4EFB\u52A1\u7BA1\u7406\u5668\u7ED3\u675F\u8BE5\u8FDB\u7A0B\uFF0C\u6216\u6539 config \u7684 api.port\u3002`
54811
+ );
54812
+ }
54813
+ if (evict.probeUnknown) {
54814
+ if (!await tryBindLoopback(apiPort)) {
54815
+ throw new EngineLockConflictError(
54816
+ `API \u7AEF\u53E3 ${apiPort} \u88AB\u8EAB\u4EFD\u4E0D\u660E\u7684\u7A0B\u5E8F\u5360\u7528\uFF08\u6E05\u573A\u63A2\u9488\u5931\u6548\uFF0C\u8BD5\u7ED1\u5931\u8D25\uFF09\u2014\u2014\u62D2\u7EDD\u5E26\u75C5\u542F\u52A8\u3002 \u5904\u7F6E\uFF1A\u627E\u51FA\u5360\u7528\u8005\uFF08netstat -ano | findstr ":${apiPort}" / lsof -iTCP:${apiPort}\uFF09\u6216\u6539 config \u7684 api.port\u3002`
54817
+ );
54818
+ }
54819
+ }
54820
+ }
54821
+ {
54822
+ const racer = pickRacingLockOwner({
54823
+ pidFileContent: readOwnEnginePidText(stateDir),
54824
+ stalePid: stale,
54825
+ myPid,
54826
+ isAlive: isPidAlive,
54827
+ isEngineImage: probeEngineImage
54828
+ });
54829
+ if (racer !== null) {
54830
+ throw new EngineLockConflictError(
54831
+ `\u542F\u52A8\u671F\u95F4\u53E6\u4E00\u4E2A\u5F15\u64CE\uFF08pid ${racer}\uFF09\u5DF2\u62A2\u5230\u8FD9\u4EFD stateDir\u2014\u2014\u672C\u6B21\u542F\u52A8\u9000\u51FA\uFF0C\u907F\u514D\u53CC\u5F00\u3002`
54832
+ );
54833
+ }
54462
54834
  }
54463
54835
  try {
54464
54836
  fs15.mkdirSync(stateDir, { recursive: true });
@@ -55816,10 +56188,19 @@ if (!verifyPublicKeyIntegrity()) {
55816
56188
  // src/startup/bootstrap.ts
55817
56189
  init_loader();
55818
56190
  init_ffmpeg_path();
56191
+ init_api_port();
55819
56192
  init_skill_sync();
55820
56193
  async function bootEnvironment(config) {
55821
56194
  process.env.ENGINE_STATE_DIR = config.stateDir;
55822
- acquireEngineLock(config.stateDir);
56195
+ try {
56196
+ await acquireEngineLock(config.stateDir, computeApiPort(config));
56197
+ } catch (err) {
56198
+ if (err instanceof EngineLockConflictError) {
56199
+ console.error(`[pid-lock] ${err.message}`);
56200
+ process.exit(1);
56201
+ }
56202
+ throw err;
56203
+ }
55823
56204
  process.env.ENGINE_MEDIA_DIR = config.mediaDir;
55824
56205
  process.env.ENGINE7_WORKSPACE = config.workspace;
55825
56206
  process.env.ENGINE7_STATE_DIR = config.stateDir;
@@ -55947,18 +56328,7 @@ function applyFreeTierVideoFixup(io) {
55947
56328
 
55948
56329
  // src/startup/free-tier-voice-fixup.ts
55949
56330
  init_cli_init_config();
55950
-
55951
- // src/free-tier-apply.ts
55952
- init_cli_init_config();
55953
- init_provision_free();
55954
- init_cli_init_config();
55955
- function isFreeTierConfig(cfg) {
55956
- const hasProvider = !!cfg?.models?.providers?.[FREE_TIER_PROVIDER_ID];
55957
- const primary = String(cfg?.agents?.defaults?.model?.primary || "");
55958
- return hasProvider && primary.startsWith(`${FREE_TIER_PROVIDER_ID}/`);
55959
- }
55960
-
55961
- // src/startup/free-tier-voice-fixup.ts
56331
+ init_free_tier_apply();
55962
56332
  function needsFreeTierVoiceFixup(cfg) {
55963
56333
  if (!isFreeTierConfig(cfg)) return false;
55964
56334
  return cfg?.tools?.my_voice === void 0;
@@ -55975,64 +56345,8 @@ async function applyFreeTierVoiceFixup(io) {
55975
56345
  return true;
55976
56346
  }
55977
56347
 
55978
- // src/startup/free-tier-nort-fixup.ts
55979
- init_cli_init_config();
55980
- var FIELD_REFS = {
55981
- "topics.extract.model": FREE_TIER_NORT_REF,
55982
- "topics.clean.model": FREE_TIER_FAST_REF,
55983
- "innerVoice.model": FREE_TIER_NORT_REF
55984
- };
55985
- var LANE_MODELS = [FREE_TIER_FAST_MODEL, FREE_TIER_NORT_MODEL];
55986
- function legacyTwoFieldExtract(cfg) {
55987
- const ex = cfg?.topics?.extract;
55988
- return typeof ex?.provider === "string" && ex.provider.trim() === FREE_TIER_PROVIDER_ID && typeof ex?.model === "string" && LANE_MODELS.some((id) => id === ex.model.trim());
55989
- }
55990
- function needsFreeTierNortFixup(cfg) {
55991
- if (!isFreeTierConfig(cfg)) return false;
55992
- const provider = cfg?.models?.providers?.[FREE_TIER_PROVIDER_ID];
55993
- if (!provider) return false;
55994
- if (LANE_MODELS.some((id) => !(provider.models || []).some((m) => m?.id === id))) return true;
55995
- return Object.keys(FIELD_REFS).some((path86) => readPath(cfg, path86) === void 0) || legacyTwoFieldExtract(cfg);
55996
- }
55997
- function readPath(obj, dotPath) {
55998
- return dotPath.split(".").reduce((acc, k) => acc == null ? void 0 : acc[k], obj);
55999
- }
56000
- async function applyFreeTierNortFixup(io) {
56001
- const cfg = io.all();
56002
- if (!needsFreeTierNortFixup(cfg)) return false;
56003
- const provider = cfg.models.providers[FREE_TIER_PROVIDER_ID];
56004
- const registry2 = PROVIDER_DEFS[FREE_TIER_PROVIDER_ID]?.models ?? [];
56005
- const missingEntries = LANE_MODELS.filter((id) => !(provider.models || []).some((m) => m?.id === id)).map((id) => registry2.find((m) => m.id === id));
56006
- if (missingEntries.some((entry) => !entry)) return false;
56007
- const writes = [];
56008
- if (missingEntries.length) {
56009
- const newModels = [...provider.models || [], ...missingEntries.map((entry) => ({ ...entry }))];
56010
- writes.push([`models.providers.${FREE_TIER_PROVIDER_ID}.models`, newModels]);
56011
- const pCopy = cfg.providers?.[FREE_TIER_PROVIDER_ID];
56012
- if (pCopy && pCopy !== provider) pCopy.models = newModels;
56013
- }
56014
- for (const [path86, ref] of Object.entries(FIELD_REFS)) {
56015
- if (readPath(cfg, path86) === void 0) writes.push([path86, ref]);
56016
- }
56017
- const migratedLegacyExtract = legacyTwoFieldExtract(cfg);
56018
- if (migratedLegacyExtract) {
56019
- writes.push(["topics.extract.model", FREE_TIER_NORT_REF]);
56020
- writes.push(["topics.extract.provider", void 0]);
56021
- }
56022
- if (!writes.length) return false;
56023
- let persisted = true;
56024
- for (const [path86, value] of writes) {
56025
- if (await io.set(path86, value) === false) persisted = false;
56026
- }
56027
- if (!persisted) {
56028
- console.error("[startup] \u514D\u8D39\u6863 nort \u8865\u9F50 **\u672A\u5168\u90E8\u843D\u76D8**\uFF08\u672C\u6B21\u8FD0\u884C\u5185\u5B58\u91CC\u5DF2\u751F\u6548\uFF0C\u914D\u7F6E\u6587\u4EF6\u4ECD\u662F\u65E7\u7684\u2014\u2014\u4E0B\u6B21\u542F\u52A8\u4F1A\u91CD\u653E\uFF09\u3002\u4E0A\u9762 [liveConfig] \u90A3\u51E0\u884C\u662F\u539F\u56E0\u3002");
56029
- return true;
56030
- }
56031
- console.log(`[startup] \u514D\u8D39\u6863\u8865\u9F50\u540E\u53F0\u8F66\u9053\uFF1Aextract/innerVoice \u2192 ${FREE_TIER_NORT_REF}\u3001clean \u2192 ${FREE_TIER_FAST_REF}\uFF08\u5B58\u91CF\u6E05\u6D17\u8D70\u5FEB\u6863\uFF09\uFF08${writes.map(([p]) => p).join(", ")}\uFF1B\u7528\u6237\u81EA\u5DF1\u914D\u8FC7\u7684\u4E0D\u52A8${migratedLegacyExtract ? "\uFF1B\u65E7\u4E24\u5B57\u6BB5 extract \u5DF2\u8FC1 nort" : ""}\uFF09`);
56032
- return true;
56033
- }
56034
-
56035
56348
  // src/engine-startup.ts
56349
+ init_free_tier_nort_fixup();
56036
56350
  init_mem7_services_fixup();
56037
56351
 
56038
56352
  // src/startup/extract-cooldown-fixup.ts
@@ -62114,7 +62428,7 @@ var VoiceChatPlugin = class {
62114
62428
 
62115
62429
  // src/memory/everos/plugin.ts
62116
62430
  import { spawn as spawn4 } from "node:child_process";
62117
- import net from "node:net";
62431
+ import net2 from "node:net";
62118
62432
  import path46 from "node:path";
62119
62433
  import fs48 from "node:fs";
62120
62434
 
@@ -62554,7 +62868,7 @@ var EverosPlugin = class {
62554
62868
  }
62555
62869
  async isPortAlive(port) {
62556
62870
  return new Promise((resolve26) => {
62557
- const socket = new net.Socket();
62871
+ const socket = new net2.Socket();
62558
62872
  socket.setTimeout(2e3);
62559
62873
  socket.on("connect", () => {
62560
62874
  socket.destroy();
@@ -68095,7 +68409,7 @@ import { promisify as promisify4 } from "node:util";
68095
68409
  import * as fs54 from "node:fs";
68096
68410
  import * as path55 from "node:path";
68097
68411
  import * as os6 from "node:os";
68098
- import net3 from "net";
68412
+ import net4 from "net";
68099
68413
  var execFileAsync2 = promisify4(execFile5);
68100
68414
  var VOICE_DIR = path55.join(os6.tmpdir(), "engine-voice");
68101
68415
  function wavDurationSec(buf) {
@@ -68271,7 +68585,7 @@ async function ttsCosyvoiceWorker(text, cfg, onChunk) {
68271
68585
  }
68272
68586
  }
68273
68587
  return new Promise((resolve26, reject) => {
68274
- const sock = net3.connect(getSockPath());
68588
+ const sock = net4.connect(getSockPath());
68275
68589
  let buf = "";
68276
68590
  const finish = (err) => {
68277
68591
  try {
@@ -68607,8 +68921,8 @@ var DeskBuddyAdapter = class {
68607
68921
  startAsr() {
68608
68922
  if (this.asrSock) return;
68609
68923
  const port = this.asrBackend === "sensevoice" ? 9790 : 9791;
68610
- const net4 = __require("node:net");
68611
- const sock = net4.connect(port, "127.0.0.1");
68924
+ const net5 = __require("node:net");
68925
+ const sock = net5.connect(port, "127.0.0.1");
68612
68926
  sock.setNoDelay(true);
68613
68927
  this.asrSock = sock;
68614
68928
  this.asrBuf = "";
@@ -82033,6 +82347,7 @@ async function startEngine(config, opts) {
82033
82347
  } });
82034
82348
  await applyFreeTierVoiceFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
82035
82349
  await applyFreeTierNortFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
82350
+ await applyMem7EnableForFreeInstall({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
82036
82351
  await applyMem7ServicesFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
82037
82352
  await applyExtractCooldownFixup({ all: () => liveConfig.all(), set: (p, v) => liveConfig.set(p, v) });
82038
82353
  let provider;
@@ -82589,8 +82904,10 @@ async function startEngine(config, opts) {
82589
82904
  };
82590
82905
  reloadOrchestrator.register({
82591
82906
  name: "channels",
82592
- // channels 段常开(空段 = 全拆,reconcile 自然处理)
82593
- select: (cfg) => ({ enabled: true, channels: cfg.channels ?? null }),
82907
+ // channels 段常开(空段 = 全拆,reconcile 自然处理)。select 抽出为纯函数——
82908
+ // 它吃的是 resolveEnv **之后**的活树,secrets-only 换 token 也要能触发重建
82909
+ // (1102:这条链没有回归钉害我误诊一轮,见 channels-entry.ts 头注)
82910
+ select: channelsSelectSlice,
82594
82911
  start: () => runChannelsReconcile(),
82595
82912
  // fire-and-forget:defer 重试不阻塞后续 entry
82596
82913
  stop: () => {