fix: avoid duplicate doctor config output

This commit is contained in:
Peter Steinberger
2026-01-20 06:32:45 +00:00
parent d5ffc672dd
commit 5d7e38a786
4 changed files with 18 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ export async function checkGatewayHealth(params: {
typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 10_000;
let healthOk = false;
try {
await healthCommand({ json: false, timeoutMs }, params.runtime);
await healthCommand({ json: false, timeoutMs, config: params.cfg }, params.runtime);
healthOk = true;
} catch (err) {
const message = String(err);

View File

@@ -10,7 +10,7 @@ import {
resolveHooksGmailModel,
} from "../agents/model-selection.js";
import type { ClawdbotConfig } from "../config/config.js";
import { CONFIG_PATH_CLAWDBOT, writeConfigFile } from "../config/config.js";
import { CONFIG_PATH_CLAWDBOT, readConfigFileSnapshot, writeConfigFile } from "../config/config.js";
import { resolveGatewayService } from "../daemon/service.js";
import { buildGatewayConnectionDetails } from "../gateway/call.js";
import { resolveClawdbotPackageRoot } from "../infra/clawdbot-root.js";
@@ -269,5 +269,14 @@ export async function doctorCommand(
}
}
const finalSnapshot = await readConfigFileSnapshot();
if (finalSnapshot.exists && !finalSnapshot.valid) {
runtime.error("Invalid config:");
for (const issue of finalSnapshot.issues) {
const path = issue.path || "<root>";
runtime.error(`- ${path}: ${issue.message}`);
}
}
outro("Doctor complete.");
}

View File

@@ -3,6 +3,7 @@ import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js";
import type { ChannelAccountSnapshot } from "../channels/plugins/types.js";
import { withProgress } from "../cli/progress.js";
import type { ClawdbotConfig } from "../config/config.js";
import { loadConfig } from "../config/config.js";
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js";
@@ -501,9 +502,10 @@ export async function getHealthSnapshot(params?: {
}
export async function healthCommand(
opts: { json?: boolean; timeoutMs?: number; verbose?: boolean },
opts: { json?: boolean; timeoutMs?: number; verbose?: boolean; config?: ClawdbotConfig },
runtime: RuntimeEnv,
) {
const cfg = opts.config ?? loadConfig();
// Always query the running gateway; do not open a direct Baileys socket here.
const summary = await withProgress(
{
@@ -516,6 +518,7 @@ export async function healthCommand(
method: "health",
params: opts.verbose ? { probe: true } : undefined,
timeoutMs: opts.timeoutMs,
config: cfg,
}),
);
// Gateway reachability defines success; channel issues are reported but not fatal here.
@@ -526,13 +529,12 @@ export async function healthCommand(
} else {
const debugEnabled = isTruthyEnvValue(process.env.CLAWDBOT_DEBUG_HEALTH);
if (opts.verbose) {
const details = buildGatewayConnectionDetails();
const details = buildGatewayConnectionDetails({ config: cfg });
runtime.log(info("Gateway connection:"));
for (const line of details.message.split("\n")) {
runtime.log(` ${line}`);
}
}
const cfg = loadConfig();
const localAgents = resolveAgentOrder(cfg);
const defaultAgentId = summary.defaultAgentId ?? localAgents.defaultAgentId;
const agents = Array.isArray(summary.agents) ? summary.agents : [];

View File

@@ -22,6 +22,7 @@ export type CallGatewayOptions = {
url?: string;
token?: string;
password?: string;
config?: ClawdbotConfig;
method: string;
params?: unknown;
expectFinal?: boolean;
@@ -109,7 +110,7 @@ export function buildGatewayConnectionDetails(
export async function callGateway<T = unknown>(opts: CallGatewayOptions): Promise<T> {
const timeoutMs = opts.timeoutMs ?? 10_000;
const config = loadConfig();
const config = opts.config ?? loadConfig();
const isRemoteMode = config.gateway?.mode === "remote";
const remote = isRemoteMode ? config.gateway?.remote : undefined;
const urlOverride =