agent-phonon 0.2.8 → 0.2.9

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/daemon.js CHANGED
@@ -4725,6 +4725,7 @@ ${prompt}`;
4725
4725
  return new Promise((resolve5) => {
4726
4726
  const child = spawn3(this.env.binPath ?? "codex", args, {
4727
4727
  cwd: this.cwd,
4728
+ shell: process.platform === "win32",
4728
4729
  env: { ...process.env, ...opts.environment ?? {}, ...this.env.apiKey ? { OPENAI_API_KEY: this.env.apiKey } : {} }
4729
4730
  });
4730
4731
  this.current = child;
@@ -4852,7 +4853,7 @@ var CodexAdapter = class {
4852
4853
  }
4853
4854
  probeVersion() {
4854
4855
  return new Promise((resolve5) => {
4855
- const child = spawn3(this.env.binPath ?? "codex", ["--version"]);
4856
+ const child = spawn3(this.env.binPath ?? "codex", ["--version"], { shell: process.platform === "win32" });
4856
4857
  let out = "";
4857
4858
  child.stdout.on("data", (d) => out += d.toString());
4858
4859
  child.on("error", () => resolve5(null));
@@ -5164,6 +5165,7 @@ ${prompt}`;
5164
5165
  return new Promise((resolve5) => {
5165
5166
  const child = spawn5(this.env.binPath ?? "hermes", args, {
5166
5167
  cwd: this.cwd,
5168
+ shell: process.platform === "win32",
5167
5169
  env: { ...process.env, ...opts.environment ?? {}, HERMES_PROFILE: this.profile }
5168
5170
  });
5169
5171
  this.current = child;
@@ -5328,7 +5330,7 @@ var HermesAdapter = class {
5328
5330
  /** 枚举 Hermes profile(去 ANSI 色解析 profile list)。 */
5329
5331
  listProfiles() {
5330
5332
  return new Promise((resolve5) => {
5331
- const child = spawn5(this.env.binPath ?? "hermes", ["profile", "list"]);
5333
+ const child = spawn5(this.env.binPath ?? "hermes", ["profile", "list"], { shell: process.platform === "win32" });
5332
5334
  let out = "";
5333
5335
  child.stdout.on("data", (d) => out += d.toString());
5334
5336
  child.on("error", () => resolve5([{ name: this.defaultProfile }]));
@@ -5348,7 +5350,7 @@ var HermesAdapter = class {
5348
5350
  }
5349
5351
  probeVersion() {
5350
5352
  return new Promise((resolve5) => {
5351
- const child = spawn5(this.env.binPath ?? "hermes", ["--version"]);
5353
+ const child = spawn5(this.env.binPath ?? "hermes", ["--version"], { shell: process.platform === "win32" });
5352
5354
  let out = "";
5353
5355
  child.stdout.on("data", (d) => out += d.toString());
5354
5356
  child.on("error", () => resolve5(null));
@@ -5583,7 +5585,7 @@ ${prompt}`;
5583
5585
  if (v !== void 0)
5584
5586
  childEnv[k] = v;
5585
5587
  }
5586
- const child = spawn6(this.env.binPath ?? "claude", args, { cwd: this.cwd, env: { ...childEnv, ...opts.environment ?? {} } });
5588
+ const child = spawn6(this.env.binPath ?? "claude", args, { cwd: this.cwd, shell: process.platform === "win32", env: { ...childEnv, ...opts.environment ?? {} } });
5587
5589
  this.current = child;
5588
5590
  let buf = "";
5589
5591
  let acc = "";
@@ -5725,7 +5727,7 @@ var ClaudeCodeAdapter = class {
5725
5727
  }
5726
5728
  probeVersion() {
5727
5729
  return new Promise((resolve5) => {
5728
- const child = spawn6(this.env.binPath ?? "claude", ["--version"]);
5730
+ const child = spawn6(this.env.binPath ?? "claude", ["--version"], { shell: process.platform === "win32" });
5729
5731
  let out = "";
5730
5732
  child.stdout.on("data", (d) => out += d.toString());
5731
5733
  child.on("error", () => resolve5(null));
@@ -6085,31 +6087,51 @@ function readOpenClawGatewayToken() {
6085
6087
  // src/commands.ts
6086
6088
  import { spawnSync } from "node:child_process";
6087
6089
  import { existsSync as existsSync12, cpSync, mkdirSync as mkdirSync4, rmSync as rmSync3, writeFileSync as writeFileSync4, readFileSync as readFileSync5 } from "node:fs";
6088
- import { homedir as homedir10 } from "node:os";
6089
- import { join as join12, dirname as dirname5 } from "node:path";
6090
+ import { homedir as homedir10, platform as platform2 } from "node:os";
6091
+ import { join as join12, dirname as dirname5, delimiter } from "node:path";
6090
6092
  import { fileURLToPath } from "node:url";
6091
6093
  function probe(bin, args = ["--version"]) {
6092
- const r = spawnSync(bin, args, { timeout: 8e3 });
6094
+ const r = spawnSync(bin, args, { timeout: 8e3, shell: platform2() === "win32" });
6093
6095
  return { ok: r.status === 0, out: (r.stdout?.toString() ?? "").trim().split("\n")[0] ?? "" };
6094
6096
  }
6097
+ function executableNames(bin) {
6098
+ if (platform2() !== "win32") return [bin];
6099
+ const exts = (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((e) => e.toLowerCase());
6100
+ return [bin, ...exts.map((e) => `${bin}${e}`), ...exts.map((e) => `${bin}${e.toUpperCase()}`)];
6101
+ }
6095
6102
  function commandPath(bin) {
6096
- const candidates = [
6097
- join12(homedir10(), ".npm-global", "bin", bin),
6098
- join12(homedir10(), ".local", "bin", bin),
6099
- join12(homedir10(), ".bun", "bin", bin),
6100
- join12(homedir10(), ".cargo", "bin", bin),
6101
- `/opt/homebrew/bin/${bin}`,
6102
- `/usr/local/bin/${bin}`,
6103
- `/usr/bin/${bin}`
6103
+ const home = homedir10();
6104
+ const appData = process.env.APPDATA;
6105
+ const localAppData = process.env.LOCALAPPDATA;
6106
+ const dirs = [
6107
+ join12(home, ".npm-global", "bin"),
6108
+ join12(home, ".local", "bin"),
6109
+ join12(home, ".bun", "bin"),
6110
+ join12(home, ".cargo", "bin"),
6111
+ ...appData ? [join12(appData, "npm")] : [],
6112
+ ...localAppData ? [join12(localAppData, "Programs"), join12(localAppData, "Microsoft", "WindowsApps")] : [],
6113
+ "/opt/homebrew/bin",
6114
+ "/usr/local/bin",
6115
+ "/usr/bin",
6116
+ ...(process.env.PATH ?? "").split(delimiter).filter(Boolean)
6104
6117
  ];
6105
- for (const p of candidates) if (existsSync12(p)) return p;
6106
- const r = spawnSync("bash", ["-lc", `command -v ${bin}`], { timeout: 3e3 });
6107
- const out = (r.stdout?.toString() ?? "").trim().split("\n")[0];
6118
+ for (const dir of dirs) {
6119
+ for (const name of executableNames(bin)) {
6120
+ const p = join12(dir, name);
6121
+ if (existsSync12(p)) return p;
6122
+ }
6123
+ }
6124
+ const r = platform2() === "win32" ? spawnSync("where.exe", [bin], { timeout: 3e3 }) : spawnSync("sh", ["-lc", `command -v ${bin}`], { timeout: 3e3 });
6125
+ const out = (r.stdout?.toString() ?? "").trim().split(/\r?\n/)[0];
6108
6126
  return r.status === 0 && out ? out : void 0;
6109
6127
  }
6110
6128
  function openCodeBin() {
6111
- const bundled = join12(homedir10(), ".opencode", "bin", "opencode");
6112
- return existsSync12(bundled) ? bundled : "opencode";
6129
+ const bundledDir = join12(homedir10(), ".opencode", "bin");
6130
+ for (const name of executableNames("opencode")) {
6131
+ const p = join12(bundledDir, name);
6132
+ if (existsSync12(p)) return p;
6133
+ }
6134
+ return commandPath("opencode") ?? "opencode";
6113
6135
  }
6114
6136
  function autoDetectAdapters(adapters) {
6115
6137
  const out = [...adapters];