@adhdev/daemon-core 0.9.46 → 0.9.48

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.mjs CHANGED
@@ -12180,7 +12180,8 @@ function getCliScriptCommand(payload) {
12180
12180
  if (command.type !== "send_message" && command.type !== "pty_write") return null;
12181
12181
  const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
12182
12182
  if (!text) return null;
12183
- return { type: command.type, text };
12183
+ const enterCount = Number.isInteger(command.enterCount) && command.enterCount > 0 && command.enterCount <= 5 ? command.enterCount : void 0;
12184
+ return { type: command.type, text, ...enterCount ? { enterCount } : {} };
12184
12185
  }
12185
12186
 
12186
12187
  // src/commands/stream-commands.ts
@@ -12438,7 +12439,12 @@ async function executeProviderScript(h, args, scriptName) {
12438
12439
  if (cliCommand?.type === "send_message" && cliCommand.text) {
12439
12440
  await adapter.sendMessage(cliCommand.text);
12440
12441
  } else if (cliCommand?.type === "pty_write" && cliCommand.text && adapter.writeRaw) {
12442
+ const enterCount = cliCommand.enterCount || 1;
12441
12443
  await adapter.writeRaw(cliCommand.text + "\r");
12444
+ for (let i = 1; i < enterCount; i += 1) {
12445
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
12446
+ await adapter.writeRaw("\r");
12447
+ }
12442
12448
  }
12443
12449
  applyProviderPatch(h, args, parsed.payload);
12444
12450
  return {
@@ -13645,7 +13651,12 @@ var CliProviderInstance = class {
13645
13651
  if (cliCommand?.type === "send_message" && cliCommand.text) {
13646
13652
  await this.adapter.sendMessage(cliCommand.text);
13647
13653
  } else if (cliCommand?.type === "pty_write" && cliCommand.text) {
13654
+ const enterCount = cliCommand.enterCount || 1;
13648
13655
  await this.adapter.writeRaw(cliCommand.text + "\r");
13656
+ for (let i = 1; i < enterCount; i += 1) {
13657
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
13658
+ await this.adapter.writeRaw("\r");
13659
+ }
13649
13660
  }
13650
13661
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
13651
13662
  }
@@ -18801,16 +18812,28 @@ function appendUpgradeLog(message) {
18801
18812
  } catch {
18802
18813
  }
18803
18814
  }
18804
- function resolveSiblingNpmExecutable(nodeExecutable) {
18815
+ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
18805
18816
  const binDir = path16.dirname(nodeExecutable);
18806
- const candidates = process.platform === "win32" ? ["npm.cmd", "npm.exe", "npm"] : ["npm"];
18807
- for (const candidate of candidates) {
18817
+ if (platform10 === "win32") {
18818
+ const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
18819
+ if (fs8.existsSync(npmCliPath)) {
18820
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
18821
+ }
18822
+ for (const candidate of ["npm.exe", "npm"]) {
18823
+ const candidatePath = path16.join(binDir, candidate);
18824
+ if (fs8.existsSync(candidatePath)) {
18825
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
18826
+ }
18827
+ }
18828
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
18829
+ }
18830
+ for (const candidate of ["npm"]) {
18808
18831
  const candidatePath = path16.join(binDir, candidate);
18809
18832
  if (fs8.existsSync(candidatePath)) {
18810
- return candidatePath;
18833
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
18811
18834
  }
18812
18835
  }
18813
- return "npm";
18836
+ return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
18814
18837
  }
18815
18838
  function findCurrentPackageRoot(currentCliPath, packageName) {
18816
18839
  if (!currentCliPath) return null;
@@ -18859,26 +18882,30 @@ function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
18859
18882
  }
18860
18883
  function resolveCurrentGlobalInstallSurface(options) {
18861
18884
  const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
18885
+ const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
18862
18886
  return {
18863
- npmExecutable: resolveSiblingNpmExecutable(options.nodeExecutable || process.execPath),
18887
+ npmExecutable: npmInvocation.executable,
18888
+ npmArgsPrefix: npmInvocation.argsPrefix,
18864
18889
  packageRoot,
18865
- installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null
18890
+ installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null,
18891
+ execOptions: npmInvocation.execOptions
18866
18892
  };
18867
18893
  }
18868
18894
  function buildPinnedGlobalInstallCommand(options) {
18869
18895
  const surface = resolveCurrentGlobalInstallSurface(options);
18870
- const args = ["install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
18896
+ const args = [...surface.npmArgsPrefix || [], "install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
18871
18897
  if (surface.installPrefix) {
18872
18898
  args.push("--prefix", surface.installPrefix);
18873
18899
  }
18874
18900
  return {
18875
18901
  command: surface.npmExecutable,
18876
18902
  args,
18877
- surface
18903
+ surface,
18904
+ execOptions: surface.execOptions || getNpmExecOptions(options.platform)
18878
18905
  };
18879
18906
  }
18880
- function getNpmExecOptions() {
18881
- return { shell: process.platform === "win32" };
18907
+ function getNpmExecOptions(_platform = process.platform) {
18908
+ return { shell: false };
18882
18909
  }
18883
18910
  function killPid(pid) {
18884
18911
  try {
@@ -18973,11 +19000,10 @@ function removeDaemonPidFile() {
18973
19000
  }
18974
19001
  }
18975
19002
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
18976
- const npmExecOpts = getNpmExecOptions();
18977
19003
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
18978
- const npmRoot = execFileSync2(surface.npmExecutable, ["root", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
19004
+ const npmRoot = execFileSync2(surface.npmExecutable, [...surface.npmArgsPrefix || [], "root", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
18979
19005
  if (!npmRoot) return;
18980
- const npmPrefix = surface.installPrefix || execFileSync2(surface.npmExecutable, ["prefix", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
19006
+ const npmPrefix = surface.installPrefix || execFileSync2(surface.npmExecutable, [...surface.npmArgsPrefix || [], "prefix", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
18981
19007
  const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
18982
19008
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
18983
19009
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -19047,7 +19073,7 @@ async function runDaemonUpgradeHelper(payload) {
19047
19073
  encoding: "utf8",
19048
19074
  stdio: "pipe",
19049
19075
  maxBuffer: 20 * 1024 * 1024,
19050
- ...getNpmExecOptions()
19076
+ ...installCommand.execOptions
19051
19077
  }
19052
19078
  );
19053
19079
  if (installOutput.trim()) {
@@ -19468,7 +19494,7 @@ var DaemonCommandRouter = class {
19468
19494
  const wantsAll = args?.all === true;
19469
19495
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
19470
19496
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
19471
- const providerMeta = this.deps.providerLoader.getMeta(providerType);
19497
+ const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
19472
19498
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
19473
19499
  canonicalHistory: providerMeta?.canonicalHistory,
19474
19500
  offset,