agent-phonon 0.2.7 → 0.2.8

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.d.ts CHANGED
@@ -24,17 +24,20 @@ interface AdapterConfig {
24
24
  /** 默认 OpenClaw sub-agent。 */
25
25
  defaultAgent?: string;
26
26
  /** claude-code:网关 baseUrl/token/默认模型。 */
27
+ claudeBinPath?: string;
27
28
  claudeBaseUrl?: string;
28
29
  claudeAuthToken?: string;
29
30
  claudeDefaultModel?: string;
30
31
  claudeModels?: ModelInfo[];
31
32
  /** codex:网关 baseUrl(/v1)/key/默认模型/wireApi。 */
33
+ codexBinPath?: string;
32
34
  codexBaseUrl?: string;
33
35
  codexApiKey?: string;
34
36
  codexDefaultModel?: string;
35
37
  codexModels?: ModelInfo[];
36
38
  codexWireApi?: "responses" | "chat";
37
39
  /** hermes:默认模型/provider(用现有 hermes config)。 */
40
+ hermesBinPath?: string;
38
41
  hermesModel?: string;
39
42
  hermesProvider?: string;
40
43
  /** opencode:binary 路径/默认模型。 */
package/dist/daemon.js CHANGED
@@ -4723,7 +4723,7 @@ ${prompt}`;
4723
4723
  }
4724
4724
  run(args, stdin, turnId, emit, opts) {
4725
4725
  return new Promise((resolve5) => {
4726
- const child = spawn3("codex", args, {
4726
+ const child = spawn3(this.env.binPath ?? "codex", args, {
4727
4727
  cwd: this.cwd,
4728
4728
  env: { ...process.env, ...opts.environment ?? {}, ...this.env.apiKey ? { OPENAI_API_KEY: this.env.apiKey } : {} }
4729
4729
  });
@@ -4852,7 +4852,7 @@ var CodexAdapter = class {
4852
4852
  }
4853
4853
  probeVersion() {
4854
4854
  return new Promise((resolve5) => {
4855
- const child = spawn3("codex", ["--version"]);
4855
+ const child = spawn3(this.env.binPath ?? "codex", ["--version"]);
4856
4856
  let out = "";
4857
4857
  child.stdout.on("data", (d) => out += d.toString());
4858
4858
  child.on("error", () => resolve5(null));
@@ -5162,7 +5162,7 @@ ${prompt}`;
5162
5162
  }
5163
5163
  run(args, turnId, emit, opts) {
5164
5164
  return new Promise((resolve5) => {
5165
- const child = spawn5("hermes", args, {
5165
+ const child = spawn5(this.env.binPath ?? "hermes", args, {
5166
5166
  cwd: this.cwd,
5167
5167
  env: { ...process.env, ...opts.environment ?? {}, HERMES_PROFILE: this.profile }
5168
5168
  });
@@ -5328,7 +5328,7 @@ var HermesAdapter = class {
5328
5328
  /** 枚举 Hermes profile(去 ANSI 色解析 profile list)。 */
5329
5329
  listProfiles() {
5330
5330
  return new Promise((resolve5) => {
5331
- const child = spawn5("hermes", ["profile", "list"]);
5331
+ const child = spawn5(this.env.binPath ?? "hermes", ["profile", "list"]);
5332
5332
  let out = "";
5333
5333
  child.stdout.on("data", (d) => out += d.toString());
5334
5334
  child.on("error", () => resolve5([{ name: this.defaultProfile }]));
@@ -5348,7 +5348,7 @@ var HermesAdapter = class {
5348
5348
  }
5349
5349
  probeVersion() {
5350
5350
  return new Promise((resolve5) => {
5351
- const child = spawn5("hermes", ["--version"]);
5351
+ const child = spawn5(this.env.binPath ?? "hermes", ["--version"]);
5352
5352
  let out = "";
5353
5353
  child.stdout.on("data", (d) => out += d.toString());
5354
5354
  child.on("error", () => resolve5(null));
@@ -5583,7 +5583,7 @@ ${prompt}`;
5583
5583
  if (v !== void 0)
5584
5584
  childEnv[k] = v;
5585
5585
  }
5586
- const child = spawn6("claude", args, { cwd: this.cwd, env: { ...childEnv, ...opts.environment ?? {} } });
5586
+ const child = spawn6(this.env.binPath ?? "claude", args, { cwd: this.cwd, env: { ...childEnv, ...opts.environment ?? {} } });
5587
5587
  this.current = child;
5588
5588
  let buf = "";
5589
5589
  let acc = "";
@@ -5725,7 +5725,7 @@ var ClaudeCodeAdapter = class {
5725
5725
  }
5726
5726
  probeVersion() {
5727
5727
  return new Promise((resolve5) => {
5728
- const child = spawn6("claude", ["--version"]);
5728
+ const child = spawn6(this.env.binPath ?? "claude", ["--version"]);
5729
5729
  let out = "";
5730
5730
  child.stdout.on("data", (d) => out += d.toString());
5731
5731
  child.on("error", () => resolve5(null));
@@ -6092,6 +6092,21 @@ function probe(bin, args = ["--version"]) {
6092
6092
  const r = spawnSync(bin, args, { timeout: 8e3 });
6093
6093
  return { ok: r.status === 0, out: (r.stdout?.toString() ?? "").trim().split("\n")[0] ?? "" };
6094
6094
  }
6095
+ 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}`
6104
+ ];
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];
6108
+ return r.status === 0 && out ? out : void 0;
6109
+ }
6095
6110
  function openCodeBin() {
6096
6111
  const bundled = join12(homedir10(), ".opencode", "bin", "opencode");
6097
6112
  return existsSync12(bundled) ? bundled : "opencode";
@@ -6099,11 +6114,25 @@ function openCodeBin() {
6099
6114
  function autoDetectAdapters(adapters) {
6100
6115
  const out = [...adapters];
6101
6116
  const has = (type2) => out.some((a) => a.type === type2);
6102
- if (!has("hermes") && probe("hermes").ok) out.push({ type: "hermes" });
6117
+ if (!has("hermes")) {
6118
+ const hermesPath = commandPath("hermes");
6119
+ if (hermesPath && probe(hermesPath).ok) out.push({ type: "hermes", hermesBinPath: hermesPath });
6120
+ }
6103
6121
  const ocBin = openCodeBin();
6104
6122
  if (!has("opencode") && probe(ocBin).ok) out.push({ type: "opencode", opencodeBinPath: ocBin === "opencode" ? void 0 : ocBin });
6105
- if (!has("claude-code") && probe("claude").ok) out.push({ type: "claude-code", claudeDefaultModel: "default" });
6106
- if (!has("codex") && probe("codex").ok) out.push({ type: "codex", codexDefaultModel: "default" });
6123
+ for (const a of out) {
6124
+ if (a.type === "hermes" && !a.hermesBinPath) a.hermesBinPath = commandPath("hermes");
6125
+ if (a.type === "claude-code" && !a.claudeBinPath) a.claudeBinPath = commandPath("claude");
6126
+ if (a.type === "codex" && !a.codexBinPath) a.codexBinPath = commandPath("codex");
6127
+ }
6128
+ if (!has("claude-code")) {
6129
+ const claudePath = commandPath("claude");
6130
+ if (claudePath && probe(claudePath).ok) out.push({ type: "claude-code", claudeBinPath: claudePath, claudeDefaultModel: "default" });
6131
+ }
6132
+ if (!has("codex")) {
6133
+ const codexPath = commandPath("codex");
6134
+ if (codexPath && probe(codexPath).ok) out.push({ type: "codex", codexBinPath: codexPath, codexDefaultModel: "default" });
6135
+ }
6107
6136
  return out;
6108
6137
  }
6109
6138
 
@@ -6248,11 +6277,11 @@ var PhononDaemon = class {
6248
6277
  this.gatewayAdapters.push(ad);
6249
6278
  this.registry.register(ad);
6250
6279
  } else if (a.type === "claude-code") {
6251
- this.registry.register(new ClaudeCodeAdapter({ env: { baseUrl: a.claudeBaseUrl, authToken: a.claudeAuthToken, defaultModel: a.claudeDefaultModel ?? "default", models: a.claudeModels } }));
6280
+ this.registry.register(new ClaudeCodeAdapter({ env: { binPath: a.claudeBinPath, baseUrl: a.claudeBaseUrl, authToken: a.claudeAuthToken, defaultModel: a.claudeDefaultModel ?? "default", models: a.claudeModels } }));
6252
6281
  } else if (a.type === "codex") {
6253
- this.registry.register(new CodexAdapter({ env: { baseUrl: a.codexBaseUrl, apiKey: a.codexApiKey, defaultModel: a.codexDefaultModel ?? "default", models: a.codexModels, wireApi: a.codexWireApi ?? "responses" } }));
6282
+ this.registry.register(new CodexAdapter({ env: { binPath: a.codexBinPath, baseUrl: a.codexBaseUrl, apiKey: a.codexApiKey, defaultModel: a.codexDefaultModel ?? "default", models: a.codexModels, wireApi: a.codexWireApi ?? "responses" } }));
6254
6283
  } else if (a.type === "hermes") {
6255
- this.registry.register(new HermesAdapter({ env: { defaultModel: a.hermesModel, provider: a.hermesProvider } }));
6284
+ this.registry.register(new HermesAdapter({ env: { binPath: a.hermesBinPath, defaultModel: a.hermesModel, provider: a.hermesProvider } }));
6256
6285
  } else if (a.type === "opencode") {
6257
6286
  this.registry.register(new OpenCodeAdapter({ env: { binPath: a.opencodeBinPath, defaultModel: a.opencodeModel } }));
6258
6287
  } else if (a.type === "openclaw-cli") {