mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 00:43:43 +00:00
fix: avoid doctor token regeneration on invalid repairs
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import { intro as clackIntro, outro as clackOutro } from "@clack/prompts";
|
||||
import fs from "node:fs";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js";
|
||||
import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "../agents/defaults.js";
|
||||
import { loadModelCatalog } from "../agents/model-catalog.js";
|
||||
@@ -9,14 +11,12 @@ import {
|
||||
resolveHooksGmailModel,
|
||||
} from "../agents/model-selection.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { CONFIG_PATH, readConfigFileSnapshot, writeConfigFile } from "../config/config.js";
|
||||
import { logConfigUpdated } from "../config/logging.js";
|
||||
import { resolveGatewayService } from "../daemon/service.js";
|
||||
import { resolveGatewayAuth } from "../gateway/auth.js";
|
||||
import { buildGatewayConnectionDetails } from "../gateway/call.js";
|
||||
import { resolveOpenClawPackageRoot } from "../infra/openclaw-root.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
import { stylePromptTitle } from "../terminal/prompt-style.js";
|
||||
@@ -98,6 +98,8 @@ export async function doctorCommand(
|
||||
confirm: (p) => prompter.confirm(p),
|
||||
});
|
||||
let cfg: OpenClawConfig = configResult.cfg;
|
||||
const cfgForPersistence = structuredClone(cfg);
|
||||
const sourceConfigValid = configResult.sourceConfigValid ?? true;
|
||||
|
||||
const configPath = configResult.path ?? CONFIG_PATH;
|
||||
if (!cfg.gateway?.mode) {
|
||||
@@ -123,7 +125,7 @@ export async function doctorCommand(
|
||||
if (gatewayDetails.remoteFallbackNote) {
|
||||
note(gatewayDetails.remoteFallbackNote, "Gateway");
|
||||
}
|
||||
if (resolveMode(cfg) === "local") {
|
||||
if (resolveMode(cfg) === "local" && sourceConfigValid) {
|
||||
const auth = resolveGatewayAuth({
|
||||
authConfig: cfg.gateway?.auth,
|
||||
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off",
|
||||
@@ -283,7 +285,8 @@ export async function doctorCommand(
|
||||
healthOk,
|
||||
});
|
||||
|
||||
const shouldWriteConfig = prompter.shouldRepair || configResult.shouldWriteConfig;
|
||||
const shouldWriteConfig =
|
||||
configResult.shouldWriteConfig || JSON.stringify(cfg) !== JSON.stringify(cfgForPersistence);
|
||||
if (shouldWriteConfig) {
|
||||
cfg = applyWizardMetadata(cfg, { command: "doctor", mode: resolveMode(cfg) });
|
||||
await writeConfigFile(cfg);
|
||||
|
||||
Reference in New Issue
Block a user