agent-phonon 0.2.2 → 0.2.3

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/cli.js CHANGED
@@ -6383,6 +6383,39 @@ function gatewayReachable(url) {
6383
6383
  return false;
6384
6384
  }
6385
6385
  }
6386
+ function openCodeBin() {
6387
+ const bundled = join12(homedir10(), ".opencode", "bin", "opencode");
6388
+ return existsSync12(bundled) ? bundled : "opencode";
6389
+ }
6390
+ function readDefaultLlmGateway() {
6391
+ try {
6392
+ const p = join12(homedir10(), ".openclaw", "openclaw.json");
6393
+ const j = JSON.parse(readFileSync5(p, "utf8"));
6394
+ const provider = j.models?.providers?.["phgeek-gw"];
6395
+ if (provider?.baseUrl && provider?.apiKey) return { baseUrl: provider.baseUrl.replace(/\/$/, ""), apiKey: provider.apiKey };
6396
+ } catch {
6397
+ }
6398
+ const baseUrl = process.env.PHONON_LLM_BASE_URL;
6399
+ const apiKey = process.env.PHONON_LLM_API_KEY;
6400
+ return baseUrl && apiKey ? { baseUrl: baseUrl.replace(/\/$/, ""), apiKey } : void 0;
6401
+ }
6402
+ function autoDetectAdapters(adapters) {
6403
+ const out = [...adapters];
6404
+ const has = (type2) => out.some((a) => a.type === type2);
6405
+ if (!has("hermes") && probe("hermes").ok) out.push({ type: "hermes" });
6406
+ const ocBin = openCodeBin();
6407
+ if (!has("opencode") && probe(ocBin).ok) out.push({ type: "opencode", opencodeBinPath: ocBin === "opencode" ? void 0 : ocBin });
6408
+ const gw = readDefaultLlmGateway();
6409
+ if (gw) {
6410
+ if (!has("claude-code") && probe("claude").ok) {
6411
+ out.push({ type: "claude-code", claudeBaseUrl: gw.baseUrl, claudeAuthToken: gw.apiKey, claudeDefaultModel: "claude-opus-4.8" });
6412
+ }
6413
+ if (!has("codex") && probe("codex").ok) {
6414
+ out.push({ type: "codex", codexBaseUrl: `${gw.baseUrl}/v1`, codexApiKey: gw.apiKey, codexDefaultModel: "gpt-5.5", codexWireApi: "responses" });
6415
+ }
6416
+ }
6417
+ return out;
6418
+ }
6386
6419
  function cmdDoctor() {
6387
6420
  console.log("agent-phonon doctor\n");
6388
6421
  const gwToken = readOpenClawGatewayToken();
@@ -6396,13 +6429,14 @@ function cmdDoctor() {
6396
6429
  const p = probe(bin);
6397
6430
  console.log(` ${name} (${bin}): ${p.ok ? "\u2713 " + p.out : "\u2717 not found"}`);
6398
6431
  }
6399
- const ocBin = existsSync12(join12(homedir10(), ".opencode", "bin", "opencode")) ? join12(homedir10(), ".opencode", "bin", "opencode") : "opencode";
6432
+ const ocBin = openCodeBin();
6400
6433
  const oc = probe(ocBin);
6401
6434
  console.log(` OpenCode (${ocBin}): ${oc.ok ? "\u2713 " + oc.out : "\u2717 not found"}`);
6402
6435
  console.log("");
6403
6436
  try {
6404
6437
  const cfg = loadConfig();
6405
- console.log(`config: ${cfg.adapters.length} adapter(s), ${cfg.servers.length} server(s)`);
6438
+ const effective = autoDetectAdapters(cfg.adapters);
6439
+ console.log(`config: ${cfg.adapters.length} configured adapter(s), ${effective.length} effective adapter(s), ${cfg.servers.length} server(s)`);
6406
6440
  } catch {
6407
6441
  console.log("config: not initialized (run: agent-phonon init)");
6408
6442
  }
@@ -6428,7 +6462,7 @@ async function cmdDiscover() {
6428
6462
  }
6429
6463
  function buildRegistry(adapters) {
6430
6464
  const reg = new AdapterRegistry();
6431
- for (const a of adapters) {
6465
+ for (const a of autoDetectAdapters(adapters)) {
6432
6466
  if (a.type === "openclaw-gateway") {
6433
6467
  const token = a.gatewayToken ?? readOpenClawGatewayToken();
6434
6468
  if (token) reg.register(new OpenClawGatewayAdapter({ gateway: { baseUrl: a.gatewayUrl ?? "ws://127.0.0.1:18789", token }, defaultAgent: a.defaultAgent ?? "main" }));
@@ -6476,11 +6510,15 @@ function cmdAdapterAdd(type2, opts) {
6476
6510
  }
6477
6511
  function cmdAdapterList() {
6478
6512
  const cfg = loadConfig();
6479
- if (cfg.adapters.length === 0) {
6480
- console.log("(no adapters configured)");
6513
+ const effective = autoDetectAdapters(cfg.adapters);
6514
+ if (effective.length === 0) {
6515
+ console.log("(no adapters available)");
6481
6516
  return;
6482
6517
  }
6483
- for (const a of cfg.adapters) console.log(`- ${a.type}${a.defaultAgent ? ` (agent: ${a.defaultAgent})` : ""}`);
6518
+ for (const a of effective) {
6519
+ const auto = cfg.adapters.some((x) => x.type === a.type) ? "" : " [auto]";
6520
+ console.log(`- ${a.type}${a.defaultAgent ? ` (agent: ${a.defaultAgent})` : ""}${auto}`);
6521
+ }
6484
6522
  }
6485
6523
  function cmdPluginInstall(which) {
6486
6524
  if (which !== "openclaw") return fail(`plugin install supports: openclaw (got: ${which})`);
@@ -6576,7 +6614,7 @@ async function main() {
6576
6614
  break;
6577
6615
  case "discover":
6578
6616
  await cmdDiscover();
6579
- break;
6617
+ process.exit(0);
6580
6618
  case "adapter": {
6581
6619
  const sub = args[0];
6582
6620
  if (sub === "add") cmdAdapterAdd(args[1] ?? "", { gatewayUrl: opt("gateway-url"), token: opt("token"), defaultAgent: opt("agent"), baseUrl: opt("base-url"), apiKey: opt("api-key"), model: opt("model"), provider: opt("provider"), wireApi: opt("wire-api"), bin: opt("bin") });
@@ -6601,8 +6639,8 @@ async function main() {
6601
6639
  console.log("setup:");
6602
6640
  console.log(" init generate default config");
6603
6641
  console.log(" doctor check agent availability / Gateway / plugin");
6604
- console.log(" adapter add <type> [opts] configure an adapter (openclaw|claude-code|codex|hermes|opencode)");
6605
- console.log(" adapter list list configured adapters");
6642
+ console.log(" adapter add <type> [opts] configure an adapter override (auto-detect covers common local agents)");
6643
+ console.log(" adapter list list configured + auto-detected adapters");
6606
6644
  console.log(" plugin install openclaw install OpenClaw HITL plugin");
6607
6645
  console.log(" server add <url> [--trust-local] [--device-key <k>]");
6608
6646
  console.log(" server list");