@adhdev/daemon-standalone 1.0.23 → 1.0.24

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.js CHANGED
@@ -33262,10 +33262,10 @@ var require_dist3 = __commonJS({
33262
33262
  }
33263
33263
  function getDaemonBuildInfo() {
33264
33264
  if (cached2) return cached2;
33265
- const commit = readInjected(true ? "36423311b45e2c0b4bc6532cbe7287d316e3f9fd" : void 0) ?? "unknown";
33266
- const commitShort = readInjected(true ? "3642331" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
33267
- const version2 = readInjected(true ? "1.0.23" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
33268
- const builtAt = readInjected(true ? "2026-07-24T07:14:12.424Z" : void 0);
33265
+ const commit = readInjected(true ? "fa38da370c3925b5df93429a904251198b295976" : void 0) ?? "unknown";
33266
+ const commitShort = readInjected(true ? "fa38da3" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
33267
+ const version2 = readInjected(true ? "1.0.24" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
33268
+ const builtAt = readInjected(true ? "2026-07-24T11:48:22.149Z" : void 0);
33269
33269
  cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
33270
33270
  return cached2;
33271
33271
  }
@@ -45816,6 +45816,73 @@ ${rendered}`, "utf-8");
45816
45816
  linesBelowPrompt: promptLineIndex >= 0 ? lines.slice(promptLineIndex + 1) : []
45817
45817
  };
45818
45818
  }
45819
+ function windowsExecutableExtensions() {
45820
+ const raw = process.env.PATHEXT;
45821
+ const fromEnv = raw ? raw.split(";").map((e) => e.trim().toLowerCase()).filter(Boolean) : [".exe", ".cmd", ".bat"];
45822
+ const merged = [...fromEnv];
45823
+ if (!merged.includes(".ps1")) merged.push(".ps1");
45824
+ if (!merged.includes("")) merged.push("");
45825
+ return Array.from(new Set(merged));
45826
+ }
45827
+ function npmGlobalPrefix() {
45828
+ if (cachedNpmPrefix !== void 0) return cachedNpmPrefix ?? void 0;
45829
+ try {
45830
+ const prefix = (0, import_child_process2.execSync)("npm config get prefix", {
45831
+ encoding: "utf-8",
45832
+ timeout: 2e3,
45833
+ windowsHide: true,
45834
+ stdio: ["ignore", "pipe", "ignore"]
45835
+ }).trim();
45836
+ cachedNpmPrefix = prefix && prefix !== "undefined" ? prefix : null;
45837
+ } catch {
45838
+ cachedNpmPrefix = null;
45839
+ }
45840
+ return cachedNpmPrefix ?? void 0;
45841
+ }
45842
+ function windowsExtraBinDirs() {
45843
+ const dirs = [];
45844
+ const fs44 = require("fs");
45845
+ const push = (dir) => {
45846
+ if (!dir) return;
45847
+ try {
45848
+ if (fs44.existsSync(dir)) dirs.push(dir);
45849
+ } catch {
45850
+ }
45851
+ };
45852
+ if (process.env.APPDATA) push(path11.join(process.env.APPDATA, "npm"));
45853
+ if (process.env.LOCALAPPDATA) push(path11.join(process.env.LOCALAPPDATA, "npm"));
45854
+ if (process.env.USERPROFILE) push(path11.join(process.env.USERPROFILE, "scoop", "shims"));
45855
+ push(npmGlobalPrefix());
45856
+ try {
45857
+ push(path11.dirname(process.execPath));
45858
+ } catch {
45859
+ }
45860
+ return dirs;
45861
+ }
45862
+ function unixExtraBinDirs() {
45863
+ const dirs = [];
45864
+ const fs44 = require("fs");
45865
+ const home = os6.homedir();
45866
+ const push = (dir) => {
45867
+ if (!dir) return;
45868
+ try {
45869
+ if (fs44.existsSync(dir)) dirs.push(dir);
45870
+ } catch {
45871
+ }
45872
+ };
45873
+ push(path11.join(home, ".local", "bin"));
45874
+ push(path11.join(home, ".claude", "local", "bin"));
45875
+ push(path11.join(home, ".npm-global", "bin"));
45876
+ push("/usr/local/bin");
45877
+ push("/opt/homebrew/bin");
45878
+ const prefix = npmGlobalPrefix();
45879
+ if (prefix) push(path11.join(prefix, "bin"));
45880
+ try {
45881
+ push(path11.dirname(process.execPath));
45882
+ } catch {
45883
+ }
45884
+ return dirs;
45885
+ }
45819
45886
  function findBinary(name) {
45820
45887
  const trimmed = String(name || "").trim();
45821
45888
  if (!trimmed) return trimmed;
@@ -45827,21 +45894,12 @@ ${rendered}`, "utf-8");
45827
45894
  const paths = (process.env.PATH || "").split(path11.delimiter);
45828
45895
  const extraDirs = [];
45829
45896
  if (isWin) {
45830
- if (process.env.APPDATA) extraDirs.push(path11.join(process.env.APPDATA, "npm"));
45831
- try {
45832
- extraDirs.push(path11.dirname(process.execPath));
45833
- } catch {
45834
- }
45897
+ extraDirs.push(...windowsExtraBinDirs());
45835
45898
  } else {
45836
- extraDirs.push(path11.join(os6.homedir(), ".npm-global", "bin"));
45837
- extraDirs.push("/usr/local/bin", "/opt/homebrew/bin");
45838
- try {
45839
- extraDirs.push(path11.dirname(process.execPath));
45840
- } catch {
45841
- }
45899
+ extraDirs.push(...unixExtraBinDirs());
45842
45900
  }
45843
45901
  const searchDirs = [...paths, ...extraDirs];
45844
- const exes = isWin ? [".exe", ".cmd", ".bat", ""] : [""];
45902
+ const exes = isWin ? windowsExecutableExtensions() : [""];
45845
45903
  for (const p of searchDirs) {
45846
45904
  if (!p) continue;
45847
45905
  for (const ext of exes) {
@@ -45968,17 +46026,20 @@ ${rendered}`, "utf-8");
45968
46026
  }
45969
46027
  var os6;
45970
46028
  var path11;
46029
+ var import_child_process2;
45971
46030
  var TerminalTranscriptAccumulator;
45972
46031
  var MESH_SEND_KEY_ENCODING;
45973
46032
  var MESH_DESTRUCTIVE_KEYS;
45974
46033
  var MESH_SEND_KEYS_MAX_ITEMS;
45975
46034
  var MESH_SEND_KEYS_MAX_TEXT_BYTES;
45976
46035
  var buildCliSpawnEnv;
46036
+ var cachedNpmPrefix;
45977
46037
  var init_provider_cli_shared = __esm2({
45978
46038
  "src/cli-adapters/provider-cli-shared.ts"() {
45979
46039
  "use strict";
45980
46040
  os6 = __toESM2(require("os"));
45981
46041
  path11 = __toESM2(require("path"));
46042
+ import_child_process2 = require("child_process");
45982
46043
  init_spawn_env();
45983
46044
  TerminalTranscriptAccumulator = class {
45984
46045
  lines = [[]];
@@ -46151,6 +46212,7 @@ ${rendered}`, "utf-8");
46151
46212
  MESH_SEND_KEYS_MAX_ITEMS = 64;
46152
46213
  MESH_SEND_KEYS_MAX_TEXT_BYTES = 4096;
46153
46214
  buildCliSpawnEnv = import_session_host_core22.sanitizeSpawnEnv;
46215
+ cachedNpmPrefix = void 0;
46154
46216
  }
46155
46217
  });
46156
46218
  function parseVersion(raw) {
@@ -46191,7 +46253,7 @@ ${rendered}`, "utf-8");
46191
46253
  }
46192
46254
  function execAsync(cmd, timeoutMs = 5e3) {
46193
46255
  return new Promise((resolve28) => {
46194
- const child = (0, import_child_process2.exec)(cmd, {
46256
+ const child = (0, import_child_process3.exec)(cmd, {
46195
46257
  encoding: "utf-8",
46196
46258
  timeout: timeoutMs,
46197
46259
  ...process.platform === "win32" ? { windowsHide: true } : {}
@@ -46316,7 +46378,7 @@ ${rendered}`, "utf-8");
46316
46378
  }
46317
46379
  return { ...cachedProviderVersions };
46318
46380
  }
46319
- var import_child_process2;
46381
+ var import_child_process3;
46320
46382
  var os7;
46321
46383
  var path12;
46322
46384
  var import_fs12;
@@ -46328,7 +46390,7 @@ ${rendered}`, "utf-8");
46328
46390
  var init_cli_detector = __esm2({
46329
46391
  "src/detection/cli-detector.ts"() {
46330
46392
  "use strict";
46331
- import_child_process2 = require("child_process");
46393
+ import_child_process3 = require("child_process");
46332
46394
  os7 = __toESM2(require("os"));
46333
46395
  path12 = __toESM2(require("path"));
46334
46396
  import_fs12 = require("fs");
@@ -51311,7 +51373,7 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
51311
51373
  };
51312
51374
  }
51313
51375
  var os8;
51314
- var import_child_process3;
51376
+ var import_child_process4;
51315
51377
  var import_util3;
51316
51378
  var execAsync2;
51317
51379
  var cachedDarwinAvail;
@@ -51320,9 +51382,9 @@ The mesh has no work in flight. For each mission, decide its outcome: continue i
51320
51382
  "src/system/host-memory.ts"() {
51321
51383
  "use strict";
51322
51384
  os8 = __toESM2(require("os"));
51323
- import_child_process3 = require("child_process");
51385
+ import_child_process4 = require("child_process");
51324
51386
  import_util3 = require("util");
51325
- execAsync2 = (0, import_util3.promisify)(import_child_process3.exec);
51387
+ execAsync2 = (0, import_util3.promisify)(import_child_process4.exec);
51326
51388
  cachedDarwinAvail = null;
51327
51389
  darwinMemoryInterval = null;
51328
51390
  }
@@ -65060,6 +65122,7 @@ ${lastSnapshot}`;
65060
65122
  getActiveMeshMissionSummaries: () => getActiveMeshMissionSummaries,
65061
65123
  getActiveSessionDeliveries: () => getActiveSessionDeliveries,
65062
65124
  getAvailableIdeIds: () => getAvailableIdeIds,
65125
+ getConfigDir: () => getConfigDir,
65063
65126
  getCoordinatorForSession: () => getCoordinatorForSession,
65064
65127
  getCurrentDaemonLogPath: () => getCurrentDaemonLogPath,
65065
65128
  getDaemonBuildInfo: () => getDaemonBuildInfo,
@@ -65236,6 +65299,7 @@ ${lastSnapshot}`;
65236
65299
  resolveDeliveryDecision: () => resolveDeliveryDecision,
65237
65300
  resolveEffectiveMeshNodeHealth: () => resolveEffectiveMeshNodeHealth,
65238
65301
  resolveGitRepository: () => resolveGitRepository,
65302
+ resolveInstanceDir: () => resolveInstanceDir,
65239
65303
  resolveMagiSessionCleanupMode: () => resolveMagiSessionCleanupMode,
65240
65304
  resolveMaxParallelTasks: () => resolveMaxParallelTasks,
65241
65305
  resolveMeshHostStatus: () => resolveMeshHostStatus,
@@ -66809,7 +66873,7 @@ ${lastSnapshot}`;
66809
66873
  }
66810
66874
  };
66811
66875
  init_state_store();
66812
- var import_child_process4 = require("child_process");
66876
+ var import_child_process5 = require("child_process");
66813
66877
  var import_util22 = require("util");
66814
66878
  var import_fs16 = require("fs");
66815
66879
  var import_os22 = require("os");
@@ -66866,7 +66930,7 @@ ${lastSnapshot}`;
66866
66930
  }
66867
66931
  return false;
66868
66932
  }
66869
- var execAsync3 = (0, import_util22.promisify)(import_child_process4.exec);
66933
+ var execAsync3 = (0, import_util22.promisify)(import_child_process5.exec);
66870
66934
  var BUILTIN_IDE_DEFINITIONS = [];
66871
66935
  var registeredIDEs = /* @__PURE__ */ new Map();
66872
66936
  function registerIDEDefinition(def) {
@@ -76615,18 +76679,18 @@ ${formatManifestValidationIssues2(validation.issues)}`,
76615
76679
  }
76616
76680
  };
76617
76681
  init_config();
76618
- var import_child_process7 = require("child_process");
76619
76682
  var import_child_process8 = require("child_process");
76683
+ var import_child_process9 = require("child_process");
76620
76684
  var fs15 = __toESM2(require("fs"));
76621
76685
  var os14 = __toESM2(require("os"));
76622
76686
  var path21 = __toESM2(require("path"));
76623
- var import_child_process6 = require("child_process");
76687
+ var import_child_process7 = require("child_process");
76624
76688
  var fs14 = __toESM2(require("fs"));
76625
76689
  var http2 = __toESM2(require("http"));
76626
76690
  var path20 = __toESM2(require("path"));
76627
- var import_child_process5 = require("child_process");
76691
+ var import_child_process6 = require("child_process");
76628
76692
  function defaultExecFileSync() {
76629
- return import_child_process5.execFileSync;
76693
+ return import_child_process6.execFileSync;
76630
76694
  }
76631
76695
  function getWindowsProcessCommandLine(pid, exec7) {
76632
76696
  const pidFilter = `ProcessId=${pid}`;
@@ -76843,10 +76907,16 @@ ${formatManifestValidationIssues2(validation.issues)}`,
76843
76907
  function normalizeForCompare(value) {
76844
76908
  return path20.resolve(value).replace(/[\\/]+$/, "").toLowerCase();
76845
76909
  }
76910
+ var DEFAULT_INSTANCE_DIR = ".adhdev";
76911
+ function normalizeInstanceDir(instanceDir) {
76912
+ const trimmed = instanceDir?.trim();
76913
+ return trimmed ? trimmed : DEFAULT_INSTANCE_DIR;
76914
+ }
76846
76915
  function resolveWindowsInstallerLayout(options) {
76847
76916
  if ((options.platform || process.platform) !== "win32" || !options.installPrefix) return null;
76848
- const installRoot = path20.join(options.homeDir, ".adhdev", "npm-installs");
76849
- const stablePrefix = path20.join(options.homeDir, ".adhdev", "npm-global");
76917
+ const instanceDir = normalizeInstanceDir(options.instanceDir);
76918
+ const installRoot = path20.join(options.homeDir, instanceDir, "npm-installs");
76919
+ const stablePrefix = path20.join(options.homeDir, instanceDir, "npm-global");
76850
76920
  const pointerPath = path20.join(stablePrefix, POINTER_NAME);
76851
76921
  const activeVersionName = path20.basename(options.installPrefix);
76852
76922
  if (!activeVersionName.startsWith("version-")) return null;
@@ -76862,7 +76932,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
76862
76932
  }
76863
76933
  function nodeMajor(nodeExecutable) {
76864
76934
  try {
76865
- const version2 = String((0, import_child_process6.execFileSync)(nodeExecutable, ["-p", "process.versions.node"], {
76935
+ const version2 = String((0, import_child_process7.execFileSync)(nodeExecutable, ["-p", "process.versions.node"], {
76866
76936
  encoding: "utf8",
76867
76937
  timeout: 5e3,
76868
76938
  windowsHide: true,
@@ -76874,9 +76944,9 @@ ${formatManifestValidationIssues2(validation.issues)}`,
76874
76944
  return null;
76875
76945
  }
76876
76946
  }
76877
- function findPortableNode22(homeDir, currentNode = process.execPath) {
76947
+ function findPortableNode22(homeDir, currentNode = process.execPath, instanceDir = DEFAULT_INSTANCE_DIR) {
76878
76948
  const candidates = [currentNode];
76879
- const portableRoot = path20.join(homeDir, ".adhdev", "tools", "node22");
76949
+ const portableRoot = path20.join(homeDir, normalizeInstanceDir(instanceDir), "tools", "node22");
76880
76950
  try {
76881
76951
  const dirs = fs14.readdirSync(portableRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => path20.join(portableRoot, entry.name, "node.exe"));
76882
76952
  candidates.push(...dirs);
@@ -76950,7 +77020,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
76950
77020
  }
76951
77021
  }
76952
77022
  function validateStagedCli(portableNode, cliEntry, targetVersion) {
76953
- const output = String((0, import_child_process6.execFileSync)(portableNode, [cliEntry, "--version"], {
77023
+ const output = String((0, import_child_process7.execFileSync)(portableNode, [cliEntry, "--version"], {
76954
77024
  encoding: "utf8",
76955
77025
  timeout: 15e3,
76956
77026
  windowsHide: true,
@@ -76979,7 +77049,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
76979
77049
  `} finally { if ([IO.File]::Exists($temporary)) { [IO.File]::Delete($temporary) } }`
76980
77050
  ].join("\n");
76981
77051
  const encoded = Buffer.from(script, "utf16le").toString("base64");
76982
- const result = (0, import_child_process6.spawnSync)("powershell.exe", [
77052
+ const result = (0, import_child_process7.spawnSync)("powershell.exe", [
76983
77053
  "-NoLogo",
76984
77054
  "-NoProfile",
76985
77055
  "-NonInteractive",
@@ -77139,7 +77209,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77139
77209
  };
77140
77210
  const pathKey = Object.keys(env2).find((key2) => key2.toLowerCase() === "path") || "Path";
77141
77211
  env2[pathKey] = `${path20.dirname(portableNode)};${env2[pathKey] || ""}`;
77142
- const installOutput = String((0, import_child_process6.execFileSync)(portableNode, [
77212
+ const installOutput = String((0, import_child_process7.execFileSync)(portableNode, [
77143
77213
  options.npmCliPath,
77144
77214
  "install",
77145
77215
  "-g",
@@ -77160,7 +77230,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77160
77230
  restart: (portableNode, stagedCliEntry) => {
77161
77231
  const restartArgv = options.restartArgv.map((arg, index) => index === 0 ? stagedCliEntry : arg);
77162
77232
  if (restartArgv.length === 0) throw new Error("replacement daemon restart arguments are missing");
77163
- const child = (0, import_child_process6.spawn)(portableNode, restartArgv, {
77233
+ const child = (0, import_child_process7.spawn)(portableNode, restartArgv, {
77164
77234
  detached: true,
77165
77235
  stdio: "ignore",
77166
77236
  windowsHide: true,
@@ -77172,7 +77242,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77172
77242
  },
77173
77243
  restartOld: (portableNode) => {
77174
77244
  if (options.restartArgv.length === 0) return;
77175
- const child = (0, import_child_process6.spawn)(portableNode, options.restartArgv, {
77245
+ const child = (0, import_child_process7.spawn)(portableNode, options.restartArgv, {
77176
77246
  detached: true,
77177
77247
  stdio: "ignore",
77178
77248
  windowsHide: true,
@@ -77212,7 +77282,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77212
77282
  },
77213
77283
  stopProcess: (pid) => {
77214
77284
  try {
77215
- (0, import_child_process6.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
77285
+ (0, import_child_process7.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
77216
77286
  } catch {
77217
77287
  }
77218
77288
  },
@@ -77258,7 +77328,12 @@ exec "${portableNode}" "${cliEntry}" "$@"
77258
77328
  log?.(`Failed to remove inactive prefix ${target}: ${error48?.message || String(error48)}`);
77259
77329
  }
77260
77330
  }
77331
+ init_config();
77261
77332
  var UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
77333
+ function resolveInstanceDir(configDir = getConfigDir()) {
77334
+ const base = path21.basename(configDir).trim();
77335
+ return base || ".adhdev";
77336
+ }
77262
77337
  function getUpgradeLogPath(home = os14.homedir()) {
77263
77338
  const dir = path21.join(home, ".adhdev");
77264
77339
  fs15.mkdirSync(dir, { recursive: true });
@@ -77340,16 +77415,16 @@ exec "${portableNode}" "${cliEntry}" "$@"
77340
77415
  }
77341
77416
  return maybeLibDir;
77342
77417
  }
77343
- function isPortableNode22Prefix(prefix, homeDir) {
77418
+ function isPortableNode22Prefix(prefix, homeDir, instanceDir = ".adhdev") {
77344
77419
  if (!prefix) return false;
77345
- const portableRoot = path21.join(homeDir, ".adhdev", "tools", "node22");
77420
+ const portableRoot = path21.join(homeDir, instanceDir, "tools", "node22");
77346
77421
  const normalizedPrefix = path21.resolve(prefix).replace(/[\\/]+$/, "").toLowerCase();
77347
77422
  const normalizedRoot = path21.resolve(portableRoot).replace(/[\\/]+$/, "").toLowerCase();
77348
77423
  return normalizedPrefix === normalizedRoot || normalizedPrefix.startsWith(`${normalizedRoot}${path21.sep.toLowerCase()}`);
77349
77424
  }
77350
- function canonicalDispatcherInstallPrefix(homeDir) {
77351
- const installRoot = path21.join(homeDir, ".adhdev", "npm-installs");
77352
- const pointerPath = path21.join(homeDir, ".adhdev", "npm-global", ".adhdev-current");
77425
+ function canonicalDispatcherInstallPrefix(homeDir, instanceDir = ".adhdev") {
77426
+ const installRoot = path21.join(homeDir, instanceDir, "npm-installs");
77427
+ const pointerPath = path21.join(homeDir, instanceDir, "npm-global", ".adhdev-current");
77353
77428
  try {
77354
77429
  const activeVersion = fs15.readFileSync(pointerPath, "utf8").trim();
77355
77430
  if (activeVersion.startsWith("version-")) return path21.join(installRoot, activeVersion);
@@ -77362,9 +77437,10 @@ exec "${portableNode}" "${cliEntry}" "$@"
77362
77437
  const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
77363
77438
  const platform10 = options.platform || process.platform;
77364
77439
  const homeDir = options.homeDir || os14.homedir();
77440
+ const instanceDir = options.instanceDir || resolveInstanceDir();
77365
77441
  let installPrefix = packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null;
77366
- if (platform10 === "win32" && isPortableNode22Prefix(installPrefix, homeDir)) {
77367
- installPrefix = canonicalDispatcherInstallPrefix(homeDir);
77442
+ if (platform10 === "win32" && isPortableNode22Prefix(installPrefix, homeDir, instanceDir)) {
77443
+ installPrefix = canonicalDispatcherInstallPrefix(homeDir, instanceDir);
77368
77444
  }
77369
77445
  return {
77370
77446
  npmExecutable: npmInvocation.executable,
@@ -77406,7 +77482,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77406
77482
  }
77407
77483
  function execNpmCommandSync(args, options = {}, surface) {
77408
77484
  const execOptions = surface?.execOptions || getNpmExecOptions();
77409
- return (0, import_child_process7.execFileSync)(
77485
+ return (0, import_child_process8.execFileSync)(
77410
77486
  surface?.npmExecutable || "npm",
77411
77487
  [...surface?.npmArgsPrefix || [], ...args],
77412
77488
  {
@@ -77463,7 +77539,7 @@ exec "${portableNode}" "${cliEntry}" "$@"
77463
77539
  ].join("\n");
77464
77540
  let out = "";
77465
77541
  try {
77466
- out = String((0, import_child_process7.execFileSync)("powershell.exe", [
77542
+ out = String((0, import_child_process8.execFileSync)("powershell.exe", [
77467
77543
  "-NoProfile",
77468
77544
  "-NonInteractive",
77469
77545
  "-ExecutionPolicy",
@@ -77587,7 +77663,7 @@ ${body}
77587
77663
  }
77588
77664
  function spawnDetachedDaemonUpgradeHelper(payload) {
77589
77665
  const env2 = { ...process.env, [UPGRADE_HELPER_ENV]: JSON.stringify(payload) };
77590
- const child = (0, import_child_process8.spawn)(process.execPath, process.argv.slice(1), {
77666
+ const child = (0, import_child_process9.spawn)(process.execPath, process.argv.slice(1), {
77591
77667
  detached: true,
77592
77668
  stdio: "ignore",
77593
77669
  windowsHide: true,
@@ -77614,12 +77690,14 @@ ${body}
77614
77690
  }
77615
77691
  await stopSessionHostProcesses(sessionHostAppName);
77616
77692
  removeDaemonPidFile();
77693
+ const instanceDir = resolveInstanceDir();
77617
77694
  const windowsInstallerLayout = resolveWindowsInstallerLayout({
77618
77695
  homeDir: os14.homedir(),
77619
- installPrefix: installCommand.surface.installPrefix
77696
+ installPrefix: installCommand.surface.installPrefix,
77697
+ instanceDir
77620
77698
  });
77621
77699
  if (windowsInstallerLayout) {
77622
- const portableNode = findPortableNode22(os14.homedir());
77700
+ const portableNode = findPortableNode22(os14.homedir(), process.execPath, instanceDir);
77623
77701
  if (!portableNode) {
77624
77702
  throw new Error("installer-managed Windows update requires the portable Node.js 22 runtime");
77625
77703
  }
@@ -77681,7 +77759,7 @@ ${body}
77681
77759
  let installOutput = "";
77682
77760
  for (let attempt = 1; attempt <= maxInstallAttempts; attempt++) {
77683
77761
  try {
77684
- installOutput = String((0, import_child_process7.execFileSync)(
77762
+ installOutput = String((0, import_child_process8.execFileSync)(
77685
77763
  installCommand.command,
77686
77764
  installCommand.args,
77687
77765
  {
@@ -77734,7 +77812,7 @@ ${body}
77734
77812
  const env2 = { ...process.env };
77735
77813
  delete env2[UPGRADE_HELPER_ENV];
77736
77814
  appendUpgradeLog(`Restarting daemon with args: ${restartArgv.join(" ")}`);
77737
- const child = (0, import_child_process8.spawn)(process.execPath, restartArgv, {
77815
+ const child = (0, import_child_process9.spawn)(process.execPath, restartArgv, {
77738
77816
  detached: true,
77739
77817
  stdio: "ignore",
77740
77818
  windowsHide: true,
@@ -78298,7 +78376,7 @@ ${body}
78298
78376
  var path30 = __toESM2(require("path"));
78299
78377
  var crypto6 = __toESM2(require("crypto"));
78300
78378
  var import_fs17 = require("fs");
78301
- var import_child_process10 = require("child_process");
78379
+ var import_child_process11 = require("child_process");
78302
78380
  var import_chalk = __toESM2((init_source(), __toCommonJS(source_exports)));
78303
78381
  init_provider_cli_adapter();
78304
78382
  init_cli_detector();
@@ -81952,6 +82030,7 @@ ${body}
81952
82030
  init_debug_trace();
81953
82031
  init_debug_config();
81954
82032
  init_mesh_event_trace();
82033
+ init_mesh_events_utils();
81955
82034
  init_control_effects();
81956
82035
  init_approval_utils();
81957
82036
  init_provider_patch_state();
@@ -83415,6 +83494,17 @@ ${body}
83415
83494
  // this to refuse a SECOND completion for a turn whose completion already fired —
83416
83495
  // so a worker that finished cleanly and is simply being auto-cleaned never emits a
83417
83496
  // duplicate. taskId '' covers an ad-hoc (no-task) turn. null = none emitted yet.
83497
+ //
83498
+ // COMPLETION-WEAK-REARM (fix1): the latch now carries the EVIDENCE STRENGTH of the
83499
+ // recorded emit. `weak` mirrors isWeakCompletionEvidence() over the exact event that
83500
+ // was pushed (evidenceLevel ∈ {weak,insufficient}, reviewRecommended, or a
83501
+ // missing_final_assistant diagnostic — the CANON-C decoupled-immediate emit and the
83502
+ // startup-grace fast-collapse synth are the two weak producers). `emittedAtEpoch`
83503
+ // snapshots busyEpoch at emit time so the transcript re-emit paths can require a real
83504
+ // generating→idle transition (busyEpoch advanced past this) before re-arming — a
83505
+ // static idle screen can never re-fire the same weak frame. A weak latch is a
83506
+ // ONE-SHOT re-arm: the genuine re-emit overwrites this with weak=false, so a
83507
+ // subsequent idle tick hits the non-weak latch and stops (never a third emit).
83418
83508
  lastEmittedCompletion = null;
83419
83509
  async enforceFreshSessionLaunchIfNeeded() {
83420
83510
  const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
@@ -84170,7 +84260,7 @@ ${body}
84170
84260
  flushMeshCompletionBeforeCleanup() {
84171
84261
  if (!this.isMeshWorkerSession()) return false;
84172
84262
  const taskId = this.completingTurnTaskId();
84173
- if (this.lastEmittedCompletion && this.lastEmittedCompletion.taskId === (taskId ?? "")) {
84263
+ if (this.shouldSuppressCompletionReEmit(taskId)) {
84174
84264
  return false;
84175
84265
  }
84176
84266
  if (!this.injectedTaskHasStartedGenerating()) return false;
@@ -84234,7 +84324,7 @@ ${body}
84234
84324
  if (observedStatus !== "idle") return false;
84235
84325
  if (this.hasAdapterPendingResponse()) return false;
84236
84326
  const taskId = this.completingTurnTaskId();
84237
- if (this.lastEmittedCompletion && this.lastEmittedCompletion.taskId === (taskId ?? "")) {
84327
+ if (this.shouldSuppressCompletionReEmit(taskId)) {
84238
84328
  return false;
84239
84329
  }
84240
84330
  if (!this.injectedTaskHasStartedGenerating()) return false;
@@ -84299,7 +84389,7 @@ ${body}
84299
84389
  if (observedStatus !== "idle") return false;
84300
84390
  if (this.hasAdapterPendingResponse()) return false;
84301
84391
  const taskId = this.completingTurnTaskId();
84302
- if (this.lastEmittedCompletion && this.lastEmittedCompletion.taskId === (taskId ?? "")) {
84392
+ if (this.shouldSuppressCompletionReEmit(taskId)) {
84303
84393
  return false;
84304
84394
  }
84305
84395
  if (!this.injectedTaskHasStartedGenerating()) return false;
@@ -84732,8 +84822,7 @@ ${body}
84732
84822
  if (summary) {
84733
84823
  this.lastCompletionSummary = { content: summary, receivedAt: opts.timestamp };
84734
84824
  }
84735
- this.lastEmittedCompletion = { taskId: typeof opts.taskId === "string" ? opts.taskId : "", at: Date.now() };
84736
- this.pushEvent({
84825
+ const completionEvent = {
84737
84826
  event: "agent:generating_completed",
84738
84827
  chatTitle: opts.chatTitle,
84739
84828
  duration: opts.duration,
@@ -84745,11 +84834,49 @@ ${body}
84745
84834
  finalSummary: opts.finalSummary,
84746
84835
  ...opts.evidenceLevel !== void 0 ? { evidenceLevel: opts.evidenceLevel } : {},
84747
84836
  ...opts.completionDiagnostic !== void 0 ? { completionDiagnostic: opts.completionDiagnostic } : {}
84748
- });
84837
+ };
84838
+ this.lastEmittedCompletion = {
84839
+ taskId: typeof opts.taskId === "string" ? opts.taskId : "",
84840
+ at: Date.now(),
84841
+ evidenceLevel: opts.evidenceLevel,
84842
+ weak: isWeakCompletionEvidence(completionEvent),
84843
+ emittedAtEpoch: this.busyEpoch
84844
+ };
84845
+ this.pushEvent(completionEvent);
84749
84846
  if (this.settings?.silentNextIdlePush === true) {
84750
84847
  this.updateSettings({ silentNextIdlePush: void 0, silentNextIdlePushArmedAt: void 0 });
84751
84848
  }
84752
84849
  }
84850
+ /**
84851
+ * COMPLETION-WEAK-REARM (fix1): the double-emit guard shared by the three transcript
84852
+ * re-emit paths (flushMeshCompletionBeforeCleanup, tryReconcilePurePtyCompletionForStall,
84853
+ * tryReconcileNativeSourceCompletionForStall). Returns true when a re-emit for `taskId`
84854
+ * must be SUPPRESSED because this turn's completion already fired with strong evidence.
84855
+ *
84856
+ * The defect this replaces: the old guard short-circuited on ANY prior emit for the
84857
+ * taskId, regardless of its evidence. After a WEAK completion (CANON-C decoupled-immediate
84858
+ * missing_final_assistant, or a startup-grace fast-collapse synth), the same session
84859
+ * reaching a GENUINE idle later (final assistant present) was silently swallowed — the
84860
+ * worker never emitted the genuine completion and the coordinator held on the acked-death
84861
+ * deadline (8 min).
84862
+ *
84863
+ * New behavior:
84864
+ * • no latch / taskId mismatch → NOT suppressed (the caller's own evidence gate runs).
84865
+ * • prior emit was GENUINE (not weak) → SUPPRESSED (single-shot; a clean completion is
84866
+ * never re-emitted).
84867
+ * • prior emit was WEAK → re-arm ONE-SHOT, but only across a real generating→idle
84868
+ * transition: require busyEpoch to have advanced past the weak emit's epoch, so a
84869
+ * static idle screen cannot re-fire the same weak frame. The genuine re-emit passes
84870
+ * evidenceLevel:'transcript' (non-weak), overwriting the latch → any subsequent idle
84871
+ * tick hits the now-genuine latch and is suppressed. Never a third emit.
84872
+ */
84873
+ shouldSuppressCompletionReEmit(taskId) {
84874
+ const latch = this.lastEmittedCompletion;
84875
+ if (!latch || latch.taskId !== (taskId ?? "")) return false;
84876
+ if (!latch.weak) return true;
84877
+ if (this.busyEpoch <= latch.emittedAtEpoch) return true;
84878
+ return false;
84879
+ }
84753
84880
  /**
84754
84881
  * AUTOAPPROVE-FLAP-INBOX-MISSING sticky-approval overlay. Returns the adapterStatus a
84755
84882
  * flap-prone claude-cli approval SHOULD present this frame — either the raw status
@@ -85869,7 +85996,7 @@ ${buttons.join("\n")}`;
85869
85996
  };
85870
85997
  var path29 = __toESM2(require("path"));
85871
85998
  var import_stream = require("stream");
85872
- var import_child_process9 = require("child_process");
85999
+ var import_child_process10 = require("child_process");
85873
86000
  var import_sdk = (init_acp(), __toCommonJS(acp_exports));
85874
86001
  init_contracts2();
85875
86002
  init_provider_input_support();
@@ -86393,7 +86520,7 @@ ${buttons.join("\n")}`;
86393
86520
  this.errorMessage = null;
86394
86521
  this.errorReason = null;
86395
86522
  this.stderrBuffer = [];
86396
- this.process = (0, import_child_process9.spawn)(command, args, {
86523
+ this.process = (0, import_child_process10.spawn)(command, args, {
86397
86524
  cwd: this.workingDir,
86398
86525
  env: env2,
86399
86526
  stdio: ["pipe", "pipe", "pipe"],
@@ -87138,7 +87265,7 @@ ${rawInput}` : rawInput;
87138
87265
  return (0, import_fs17.existsSync)(expandExecutable(trimmed));
87139
87266
  }
87140
87267
  try {
87141
- (0, import_child_process10.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
87268
+ (0, import_child_process11.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
87142
87269
  stdio: "ignore",
87143
87270
  ...process.platform === "win32" ? { windowsHide: true } : {}
87144
87271
  });
@@ -88650,7 +88777,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
88650
88777
  return ctx.deps.cliManager.handleCliCommand("restart_session", args);
88651
88778
  }
88652
88779
  };
88653
- var import_child_process11 = require("child_process");
88780
+ var import_child_process12 = require("child_process");
88654
88781
  var net3 = __toESM2(require("net"));
88655
88782
  var os28 = __toESM2(require("os"));
88656
88783
  var path38 = __toESM2(require("path"));
@@ -92630,7 +92757,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
92630
92757
  }
92631
92758
  async function execQuiet(command, options = {}) {
92632
92759
  return new Promise((resolve28) => {
92633
- (0, import_child_process11.exec)(command, options, (error48, stdout) => {
92760
+ (0, import_child_process12.exec)(command, options, (error48, stdout) => {
92634
92761
  if (error48) return resolve28("");
92635
92762
  resolve28(stdout.toString());
92636
92763
  });
@@ -93030,10 +93157,10 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
93030
93157
  const canUseAppLauncher = !!appName;
93031
93158
  const useAppLauncher = preferredMethod === "app" ? canUseAppLauncher : preferredMethod === "cli" ? false : !canUseCli && canUseAppLauncher;
93032
93159
  if (!useAppLauncher && ide.cliCommand) {
93033
- (0, import_child_process11.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
93160
+ (0, import_child_process12.spawn)(ide.cliCommand, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
93034
93161
  } else if (appName) {
93035
93162
  const openArgs = ["-a", appName, "--args", ...args];
93036
- (0, import_child_process11.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
93163
+ (0, import_child_process12.spawn)("open", openArgs, { detached: true, stdio: "ignore" }).unref();
93037
93164
  } else {
93038
93165
  throw new Error(`No app identifier or CLI for ${ide.displayName}`);
93039
93166
  }
@@ -93059,7 +93186,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
93059
93186
  const args = ["--remote-debugging-port=" + port];
93060
93187
  if (newWindow) args.push("--new-window");
93061
93188
  if (workspace) args.push(workspace);
93062
- (0, import_child_process11.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
93189
+ (0, import_child_process12.spawn)(cli, args, { detached: true, stdio: "ignore", windowsHide: true }).unref();
93063
93190
  }
93064
93191
  function getAvailableIdeIds() {
93065
93192
  return getProviderLoader().getAvailableIdeTypes();
@@ -103017,7 +103144,7 @@ ${e?.stderr || ""}`;
103017
103144
  var path40 = __toESM2(require("path"));
103018
103145
  var os30 = __toESM2(require("os"));
103019
103146
  var import_os5 = require("os");
103020
- var import_child_process12 = require("child_process");
103147
+ var import_child_process13 = require("child_process");
103021
103148
  var ARCHIVE_PATH = path40.join(os30.homedir(), ".adhdev", "version-history.json");
103022
103149
  var MAX_ENTRIES_PER_PROVIDER = 20;
103023
103150
  var VersionArchive = class {
@@ -103073,7 +103200,7 @@ ${e?.stderr || ""}`;
103073
103200
  };
103074
103201
  async function runCommand(cmd, timeout = 1e4) {
103075
103202
  return new Promise((resolve28) => {
103076
- (0, import_child_process12.exec)(cmd, {
103203
+ (0, import_child_process13.exec)(cmd, {
103077
103204
  encoding: "utf-8",
103078
103205
  timeout
103079
103206
  }, (error48, stdout) => {
@@ -108606,7 +108733,7 @@ data: ${JSON.stringify(msg.data)}
108606
108733
  });
108607
108734
  }
108608
108735
  }
108609
- var import_child_process13 = require("child_process");
108736
+ var import_child_process14 = require("child_process");
108610
108737
  var fs43 = __toESM2(require("fs"));
108611
108738
  var os322 = __toESM2(require("os"));
108612
108739
  var path45 = __toESM2(require("path"));
@@ -108661,7 +108788,7 @@ data: ${JSON.stringify(msg.data)}
108661
108788
  if (process.platform === "win32") {
108662
108789
  const spawnOpts = { stdio: "ignore" };
108663
108790
  if (options.killWindowsHide) spawnOpts.windowsHide = true;
108664
- (0, import_child_process13.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], spawnOpts);
108791
+ (0, import_child_process14.execFileSync)("taskkill", ["/PID", String(pid), "/T", "/F"], spawnOpts);
108665
108792
  } else {
108666
108793
  process.kill(pid, "SIGTERM");
108667
108794
  }
@@ -108670,8 +108797,31 @@ data: ${JSON.stringify(msg.data)}
108670
108797
  return false;
108671
108798
  }
108672
108799
  }
108800
+ function resolveSessionHostNode() {
108801
+ if (process.platform !== "win32") {
108802
+ return process.execPath;
108803
+ }
108804
+ let portableNode = null;
108805
+ try {
108806
+ portableNode = findPortableNode22(os322.homedir(), process.execPath, resolveInstanceDir());
108807
+ } catch (error48) {
108808
+ LOG2.warn(
108809
+ "SessionHost",
108810
+ `Failed to resolve portable Node 22 for the session-host spawn: ${error48 instanceof Error ? error48.message : String(error48)}`
108811
+ );
108812
+ }
108813
+ if (portableNode) {
108814
+ return portableNode;
108815
+ }
108816
+ LOG2.warn(
108817
+ "SessionHost",
108818
+ `Portable Node 22 not found; spawning the session-host with ${process.execPath}. node-pty may fail to load its conpty.node prebuild under a non-22 Node on win32.`
108819
+ );
108820
+ return process.execPath;
108821
+ }
108673
108822
  function spawnHost() {
108674
108823
  const entry = resolveEntry();
108824
+ const nodeExecutable = resolveSessionHostNode();
108675
108825
  let stdio = "ignore";
108676
108826
  let logFd = null;
108677
108827
  if (options.spawnStdio === "logfile") {
@@ -108680,7 +108830,7 @@ data: ${JSON.stringify(msg.data)}
108680
108830
  logFd = fs43.openSync(path45.join(logDir, "session-host.log"), "a");
108681
108831
  stdio = ["ignore", logFd, logFd];
108682
108832
  }
108683
- const child = (0, import_child_process13.spawn)(process.execPath, [entry], {
108833
+ const child = (0, import_child_process14.spawn)(nodeExecutable, [entry], {
108684
108834
  detached: true,
108685
108835
  stdio,
108686
108836
  windowsHide: true,
@@ -108776,7 +108926,7 @@ data: ${JSON.stringify(msg.data)}
108776
108926
  if (raw === "0" || raw === "false" || raw === "no") return false;
108777
108927
  return raw === "1" || raw === "true" || raw === "yes";
108778
108928
  }
108779
- var import_child_process14 = require("child_process");
108929
+ var import_child_process15 = require("child_process");
108780
108930
  var import_util32 = require("util");
108781
108931
  var EXTENSION_CATALOG = [
108782
108932
  // AI Agent extensions
@@ -108864,7 +109014,7 @@ data: ${JSON.stringify(msg.data)}
108864
109014
  apiKeyName: "OpenAI/Anthropic API key"
108865
109015
  }
108866
109016
  ];
108867
- var execAsync4 = (0, import_util32.promisify)(import_child_process14.exec);
109017
+ var execAsync4 = (0, import_util32.promisify)(import_child_process15.exec);
108868
109018
  async function isExtensionInstalled(ide, marketplaceId) {
108869
109019
  if (!ide.cliCommand) return false;
108870
109020
  try {
@@ -108908,7 +109058,7 @@ data: ${JSON.stringify(msg.data)}
108908
109058
  fs44.writeFileSync(vsixPath, buffer);
108909
109059
  return new Promise((resolve28) => {
108910
109060
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
108911
- (0, import_child_process14.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
109061
+ (0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
108912
109062
  resolve28({
108913
109063
  extensionId: extension.id,
108914
109064
  marketplaceId: extension.marketplaceId,
@@ -108924,7 +109074,7 @@ data: ${JSON.stringify(msg.data)}
108924
109074
  }
108925
109075
  return new Promise((resolve28) => {
108926
109076
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
108927
- (0, import_child_process14.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
109077
+ (0, import_child_process15.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
108928
109078
  if (error48) {
108929
109079
  resolve28({
108930
109080
  extensionId: extension.id,
@@ -108961,7 +109111,7 @@ data: ${JSON.stringify(msg.data)}
108961
109111
  if (!ide.cliCommand) return false;
108962
109112
  try {
108963
109113
  const args = workspacePath ? `"${workspacePath}"` : "";
108964
- (0, import_child_process14.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
109114
+ (0, import_child_process15.exec)(`"${ide.cliCommand}" ${args}`, { timeout: 1e4 });
108965
109115
  return true;
108966
109116
  } catch {
108967
109117
  return false;