@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.
@@ -8,24 +8,33 @@ export interface DaemonUpgradeHelperPayload {
8
8
  }
9
9
  export interface CurrentGlobalInstallSurface {
10
10
  npmExecutable: string;
11
+ npmArgsPrefix?: string[];
11
12
  packageRoot: string | null;
12
13
  installPrefix: string | null;
14
+ execOptions?: {
15
+ shell: boolean;
16
+ };
13
17
  }
14
18
  export interface PinnedGlobalInstallCommand {
15
19
  command: string;
16
20
  args: string[];
17
21
  surface: CurrentGlobalInstallSurface;
22
+ execOptions: {
23
+ shell: boolean;
24
+ };
18
25
  }
19
26
  export declare function resolveCurrentGlobalInstallSurface(options: {
20
27
  packageName: string;
21
28
  currentCliPath?: string;
22
29
  nodeExecutable?: string;
30
+ platform?: NodeJS.Platform;
23
31
  }): CurrentGlobalInstallSurface;
24
32
  export declare function buildPinnedGlobalInstallCommand(options: {
25
33
  packageName: string;
26
34
  targetVersion: string;
27
35
  currentCliPath?: string;
28
36
  nodeExecutable?: string;
37
+ platform?: NodeJS.Platform;
29
38
  }): PinnedGlobalInstallCommand;
30
39
  export declare function stopSessionHostProcesses(appName: string): void;
31
40
  export declare function spawnDetachedDaemonUpgradeHelper(payload: DaemonUpgradeHelperPayload): void;
package/dist/index.js CHANGED
@@ -12333,7 +12333,8 @@ function getCliScriptCommand(payload) {
12333
12333
  if (command.type !== "send_message" && command.type !== "pty_write") return null;
12334
12334
  const text = typeof command.text === "string" ? command.text.trim() : typeof command.message === "string" ? command.message.trim() : "";
12335
12335
  if (!text) return null;
12336
- return { type: command.type, text };
12336
+ const enterCount = Number.isInteger(command.enterCount) && command.enterCount > 0 && command.enterCount <= 5 ? command.enterCount : void 0;
12337
+ return { type: command.type, text, ...enterCount ? { enterCount } : {} };
12337
12338
  }
12338
12339
 
12339
12340
  // src/commands/stream-commands.ts
@@ -12591,7 +12592,12 @@ async function executeProviderScript(h, args, scriptName) {
12591
12592
  if (cliCommand?.type === "send_message" && cliCommand.text) {
12592
12593
  await adapter.sendMessage(cliCommand.text);
12593
12594
  } else if (cliCommand?.type === "pty_write" && cliCommand.text && adapter.writeRaw) {
12595
+ const enterCount = cliCommand.enterCount || 1;
12594
12596
  await adapter.writeRaw(cliCommand.text + "\r");
12597
+ for (let i = 1; i < enterCount; i += 1) {
12598
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
12599
+ await adapter.writeRaw("\r");
12600
+ }
12595
12601
  }
12596
12602
  applyProviderPatch(h, args, parsed.payload);
12597
12603
  return {
@@ -13798,7 +13804,12 @@ var CliProviderInstance = class {
13798
13804
  if (cliCommand?.type === "send_message" && cliCommand.text) {
13799
13805
  await this.adapter.sendMessage(cliCommand.text);
13800
13806
  } else if (cliCommand?.type === "pty_write" && cliCommand.text) {
13807
+ const enterCount = cliCommand.enterCount || 1;
13801
13808
  await this.adapter.writeRaw(cliCommand.text + "\r");
13809
+ for (let i = 1; i < enterCount; i += 1) {
13810
+ await new Promise((resolve12) => setTimeout(resolve12, 50));
13811
+ await this.adapter.writeRaw("\r");
13812
+ }
13802
13813
  }
13803
13814
  this.applyProviderResponse(parsed.payload, { phase: "immediate" });
13804
13815
  }
@@ -18949,16 +18960,28 @@ function appendUpgradeLog(message) {
18949
18960
  } catch {
18950
18961
  }
18951
18962
  }
18952
- function resolveSiblingNpmExecutable(nodeExecutable) {
18963
+ function resolveSiblingNpmInvocation(nodeExecutable, platform10 = process.platform) {
18953
18964
  const binDir = path16.dirname(nodeExecutable);
18954
- const candidates = process.platform === "win32" ? ["npm.cmd", "npm.exe", "npm"] : ["npm"];
18955
- for (const candidate of candidates) {
18965
+ if (platform10 === "win32") {
18966
+ const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
18967
+ if (fs8.existsSync(npmCliPath)) {
18968
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
18969
+ }
18970
+ for (const candidate of ["npm.exe", "npm"]) {
18971
+ const candidatePath = path16.join(binDir, candidate);
18972
+ if (fs8.existsSync(candidatePath)) {
18973
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
18974
+ }
18975
+ }
18976
+ return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: { shell: false } };
18977
+ }
18978
+ for (const candidate of ["npm"]) {
18956
18979
  const candidatePath = path16.join(binDir, candidate);
18957
18980
  if (fs8.existsSync(candidatePath)) {
18958
- return candidatePath;
18981
+ return { executable: candidatePath, argsPrefix: [], execOptions: { shell: false } };
18959
18982
  }
18960
18983
  }
18961
- return "npm";
18984
+ return { executable: "npm", argsPrefix: [], execOptions: { shell: false } };
18962
18985
  }
18963
18986
  function findCurrentPackageRoot(currentCliPath, packageName) {
18964
18987
  if (!currentCliPath) return null;
@@ -19007,26 +19030,30 @@ function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
19007
19030
  }
19008
19031
  function resolveCurrentGlobalInstallSurface(options) {
19009
19032
  const packageRoot = findCurrentPackageRoot(options.currentCliPath || process.argv[1], options.packageName);
19033
+ const npmInvocation = resolveSiblingNpmInvocation(options.nodeExecutable || process.execPath, options.platform);
19010
19034
  return {
19011
- npmExecutable: resolveSiblingNpmExecutable(options.nodeExecutable || process.execPath),
19035
+ npmExecutable: npmInvocation.executable,
19036
+ npmArgsPrefix: npmInvocation.argsPrefix,
19012
19037
  packageRoot,
19013
- installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null
19038
+ installPrefix: packageRoot ? resolveInstallPrefixFromPackageRoot(packageRoot, options.packageName) : null,
19039
+ execOptions: npmInvocation.execOptions
19014
19040
  };
19015
19041
  }
19016
19042
  function buildPinnedGlobalInstallCommand(options) {
19017
19043
  const surface = resolveCurrentGlobalInstallSurface(options);
19018
- const args = ["install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
19044
+ const args = [...surface.npmArgsPrefix || [], "install", "-g", `${options.packageName}@${options.targetVersion || "latest"}`, "--force"];
19019
19045
  if (surface.installPrefix) {
19020
19046
  args.push("--prefix", surface.installPrefix);
19021
19047
  }
19022
19048
  return {
19023
19049
  command: surface.npmExecutable,
19024
19050
  args,
19025
- surface
19051
+ surface,
19052
+ execOptions: surface.execOptions || getNpmExecOptions(options.platform)
19026
19053
  };
19027
19054
  }
19028
- function getNpmExecOptions() {
19029
- return { shell: process.platform === "win32" };
19055
+ function getNpmExecOptions(_platform = process.platform) {
19056
+ return { shell: false };
19030
19057
  }
19031
19058
  function killPid(pid) {
19032
19059
  try {
@@ -19121,11 +19148,10 @@ function removeDaemonPidFile() {
19121
19148
  }
19122
19149
  }
19123
19150
  function cleanupStaleGlobalInstallDirs(pkgName, surface) {
19124
- const npmExecOpts = getNpmExecOptions();
19125
19151
  const prefixArgs = surface.installPrefix ? ["--prefix", surface.installPrefix] : [];
19126
- const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, ["root", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
19152
+ const npmRoot = (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "root", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
19127
19153
  if (!npmRoot) return;
19128
- const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, ["prefix", "-g", ...prefixArgs], { encoding: "utf8", ...npmExecOpts }).trim();
19154
+ const npmPrefix = surface.installPrefix || (0, import_child_process8.execFileSync)(surface.npmExecutable, [...surface.npmArgsPrefix || [], "prefix", "-g", ...prefixArgs], { encoding: "utf8", ...surface.execOptions }).trim();
19129
19155
  const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
19130
19156
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
19131
19157
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
@@ -19195,7 +19221,7 @@ async function runDaemonUpgradeHelper(payload) {
19195
19221
  encoding: "utf8",
19196
19222
  stdio: "pipe",
19197
19223
  maxBuffer: 20 * 1024 * 1024,
19198
- ...getNpmExecOptions()
19224
+ ...installCommand.execOptions
19199
19225
  }
19200
19226
  );
19201
19227
  if (installOutput.trim()) {
@@ -19616,7 +19642,7 @@ var DaemonCommandRouter = class {
19616
19642
  const wantsAll = args?.all === true;
19617
19643
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
19618
19644
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
19619
- const providerMeta = this.deps.providerLoader.getMeta(providerType);
19645
+ const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
19620
19646
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
19621
19647
  canonicalHistory: providerMeta?.canonicalHistory,
19622
19648
  offset,