From d0a5ee0176c888be150419205d22f3de0193ac6d Mon Sep 17 00:00:00 2001 From: Operative-001 Date: Mon, 16 Feb 2026 14:48:00 +0100 Subject: [PATCH] fix: include token drift warning in JSON response Address review feedback - when --json mode is used, the drift warning was completely suppressed. Now it's included in the warnings array of the DaemonActionResponse so programmatic consumers can surface it. --- src/cli/daemon-cli/lifecycle-core.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cli/daemon-cli/lifecycle-core.ts b/src/cli/daemon-cli/lifecycle-core.ts index a202dc286..15cc586e7 100644 --- a/src/cli/daemon-cli/lifecycle-core.ts +++ b/src/cli/daemon-cli/lifecycle-core.ts @@ -259,6 +259,7 @@ export async function runServiceRestart(params: { } // Check for token drift before restart (service token vs config token) + const warnings: string[] = []; try { const command = await params.service.readCommand(process.env); const serviceToken = command?.environment?.OPENCLAW_GATEWAY_TOKEN; @@ -268,10 +269,16 @@ export async function runServiceRestart(params: { process.env.OPENCLAW_GATEWAY_TOKEN || process.env.CLAWDBOT_GATEWAY_TOKEN; const driftIssue = checkTokenDrift({ serviceToken, configToken }); - if (driftIssue && !json) { - defaultRuntime.log(`\n⚠️ ${driftIssue.message}`); - if (driftIssue.detail) { - defaultRuntime.log(` ${driftIssue.detail}\n`); + if (driftIssue) { + const warning = driftIssue.detail + ? `${driftIssue.message} ${driftIssue.detail}` + : driftIssue.message; + warnings.push(warning); + if (!json) { + defaultRuntime.log(`\n⚠️ ${driftIssue.message}`); + if (driftIssue.detail) { + defaultRuntime.log(` ${driftIssue.detail}\n`); + } } } } catch { @@ -290,6 +297,7 @@ export async function runServiceRestart(params: { ok: true, result: "restarted", service: buildDaemonServiceSnapshot(params.service, restarted), + warnings: warnings.length ? warnings : undefined, }); return true; } catch (err) {