fix: avoid duplicate doctor config output
This commit is contained in:
@@ -16,7 +16,7 @@ export async function checkGatewayHealth(params: {
|
|||||||
typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 10_000;
|
typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 10_000;
|
||||||
let healthOk = false;
|
let healthOk = false;
|
||||||
try {
|
try {
|
||||||
await healthCommand({ json: false, timeoutMs }, params.runtime);
|
await healthCommand({ json: false, timeoutMs, config: params.cfg }, params.runtime);
|
||||||
healthOk = true;
|
healthOk = true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const message = String(err);
|
const message = String(err);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
resolveHooksGmailModel,
|
resolveHooksGmailModel,
|
||||||
} from "../agents/model-selection.js";
|
} from "../agents/model-selection.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.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 { resolveGatewayService } from "../daemon/service.js";
|
||||||
import { buildGatewayConnectionDetails } from "../gateway/call.js";
|
import { buildGatewayConnectionDetails } from "../gateway/call.js";
|
||||||
import { resolveClawdbotPackageRoot } from "../infra/clawdbot-root.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.");
|
outro("Doctor complete.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { resolveChannelDefaultAccountId } from "../channels/plugins/helpers.js";
|
|||||||
import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js";
|
import { getChannelPlugin, listChannelPlugins } from "../channels/plugins/index.js";
|
||||||
import type { ChannelAccountSnapshot } from "../channels/plugins/types.js";
|
import type { ChannelAccountSnapshot } from "../channels/plugins/types.js";
|
||||||
import { withProgress } from "../cli/progress.js";
|
import { withProgress } from "../cli/progress.js";
|
||||||
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
import { loadSessionStore, resolveStorePath } from "../config/sessions.js";
|
||||||
import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js";
|
import { buildGatewayConnectionDetails, callGateway } from "../gateway/call.js";
|
||||||
@@ -501,9 +502,10 @@ export async function getHealthSnapshot(params?: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function healthCommand(
|
export async function healthCommand(
|
||||||
opts: { json?: boolean; timeoutMs?: number; verbose?: boolean },
|
opts: { json?: boolean; timeoutMs?: number; verbose?: boolean; config?: ClawdbotConfig },
|
||||||
runtime: RuntimeEnv,
|
runtime: RuntimeEnv,
|
||||||
) {
|
) {
|
||||||
|
const cfg = opts.config ?? loadConfig();
|
||||||
// Always query the running gateway; do not open a direct Baileys socket here.
|
// Always query the running gateway; do not open a direct Baileys socket here.
|
||||||
const summary = await withProgress(
|
const summary = await withProgress(
|
||||||
{
|
{
|
||||||
@@ -516,6 +518,7 @@ export async function healthCommand(
|
|||||||
method: "health",
|
method: "health",
|
||||||
params: opts.verbose ? { probe: true } : undefined,
|
params: opts.verbose ? { probe: true } : undefined,
|
||||||
timeoutMs: opts.timeoutMs,
|
timeoutMs: opts.timeoutMs,
|
||||||
|
config: cfg,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
// Gateway reachability defines success; channel issues are reported but not fatal here.
|
// Gateway reachability defines success; channel issues are reported but not fatal here.
|
||||||
@@ -526,13 +529,12 @@ export async function healthCommand(
|
|||||||
} else {
|
} else {
|
||||||
const debugEnabled = isTruthyEnvValue(process.env.CLAWDBOT_DEBUG_HEALTH);
|
const debugEnabled = isTruthyEnvValue(process.env.CLAWDBOT_DEBUG_HEALTH);
|
||||||
if (opts.verbose) {
|
if (opts.verbose) {
|
||||||
const details = buildGatewayConnectionDetails();
|
const details = buildGatewayConnectionDetails({ config: cfg });
|
||||||
runtime.log(info("Gateway connection:"));
|
runtime.log(info("Gateway connection:"));
|
||||||
for (const line of details.message.split("\n")) {
|
for (const line of details.message.split("\n")) {
|
||||||
runtime.log(` ${line}`);
|
runtime.log(` ${line}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const cfg = loadConfig();
|
|
||||||
const localAgents = resolveAgentOrder(cfg);
|
const localAgents = resolveAgentOrder(cfg);
|
||||||
const defaultAgentId = summary.defaultAgentId ?? localAgents.defaultAgentId;
|
const defaultAgentId = summary.defaultAgentId ?? localAgents.defaultAgentId;
|
||||||
const agents = Array.isArray(summary.agents) ? summary.agents : [];
|
const agents = Array.isArray(summary.agents) ? summary.agents : [];
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export type CallGatewayOptions = {
|
|||||||
url?: string;
|
url?: string;
|
||||||
token?: string;
|
token?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
|
config?: ClawdbotConfig;
|
||||||
method: string;
|
method: string;
|
||||||
params?: unknown;
|
params?: unknown;
|
||||||
expectFinal?: boolean;
|
expectFinal?: boolean;
|
||||||
@@ -109,7 +110,7 @@ export function buildGatewayConnectionDetails(
|
|||||||
|
|
||||||
export async function callGateway<T = unknown>(opts: CallGatewayOptions): Promise<T> {
|
export async function callGateway<T = unknown>(opts: CallGatewayOptions): Promise<T> {
|
||||||
const timeoutMs = opts.timeoutMs ?? 10_000;
|
const timeoutMs = opts.timeoutMs ?? 10_000;
|
||||||
const config = loadConfig();
|
const config = opts.config ?? loadConfig();
|
||||||
const isRemoteMode = config.gateway?.mode === "remote";
|
const isRemoteMode = config.gateway?.mode === "remote";
|
||||||
const remote = isRemoteMode ? config.gateway?.remote : undefined;
|
const remote = isRemoteMode ? config.gateway?.remote : undefined;
|
||||||
const urlOverride =
|
const urlOverride =
|
||||||
|
|||||||
Reference in New Issue
Block a user