Skip to content
2 changes: 1 addition & 1 deletion ci/source-architecture-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"src/lib/cli/terminal-style.ts": 44,
"src/lib/core/json-types.ts": 37,
"src/lib/core/ports.ts": 87,
"src/lib/core/shell-quote.ts": 26,
"src/lib/core/shell-quote.ts": 27,
"src/lib/core/url-utils.ts": 28,
"src/lib/core/wait.ts": 35,
"src/lib/credentials/store.ts": 46,
Expand Down
5 changes: 4 additions & 1 deletion docs/manage-sandboxes/set-up-whatsapp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ Keep Shields down until `config set` finishes, then restore the restrictive post
The `--config-accept-new-path` flag lets the command write the `platforms.whatsapp.extra.session_path` configuration key when the generated config does not already contain it.
Dashboard pairing writes session credentials under `profiles/dashboard-home`; this bounded compatibility repair redirects the gateway to that session path while it still reads the default path otherwise.
The repair stays documented until Hermes dashboard pairing state and gateway startup converge on one shared session path; NemoClaw can redirect the configured path but does not rewrite Hermes pairing state.
Before removing the override, run `$$nemoclaw <sandbox> channels status --channel whatsapp` after dashboard pairing and gateway startup and confirm the report no longer shows a dashboard-home session with an empty gateway session path.
After the repair, `$$nemoclaw <sandbox> channels status --channel whatsapp` finds the default gateway session path empty and then checks the configured session path, so the split warning clears.
The report adds a `Session path override` line that states the gateway session check used the path set in `platforms.whatsapp.extra.session_path`.
Before removing the override, run `$$nemoclaw <sandbox> channels status --channel whatsapp` after dashboard pairing and gateway startup.
Confirm that the report no longer shows the `Session path override` line, which means the default gateway session path now holds the credentials.
Remove the override only after Hermes uses one shared WhatsApp session path for dashboard pairing and gateway startup.
Do not edit `/sandbox/.hermes/.env` or `/sandbox/.hermes/config.yaml` by hand.
Manual edits can cause the Hermes config-integrity guard to reject restart with `hash-mismatch`.
Expand Down
11 changes: 8 additions & 3 deletions docs/reference/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2486,9 +2486,14 @@ With `--channel`, it prints the detailed status for that channel.
For an OpenClaw WhatsApp sandbox, `--channel whatsapp` probes the sandbox to separately report pairing/session state, the Noise WebSocket connection, inbound event delivery, and policy coverage.
A paired channel with no observed inbound delivery exits non-zero with verdict `idle` so an unhealthy bridge cannot pass as healthy.
The detailed WhatsApp probe stays focused on QR/session runtime diagnostics and does not include rendered-config comparison lines.
For a Hermes WhatsApp sandbox, `--channel whatsapp` probes only whether the default gateway session path and the `profiles/dashboard-home` session path contain `creds.json`.
If the dashboard path has credentials and the gateway path is empty, the report prints the supported `config set` command for the `platforms.whatsapp.extra.session_path` configuration key, including the new-configuration-key opt-in when generated configs do not already contain that key.
NemoClaw does not treat a Hermes session file as live inbound-health evidence.
For a Hermes WhatsApp sandbox, `--channel whatsapp` reports only whether the gateway session path and the `profiles/dashboard-home` session path contain `creds.json`.
If no supported session-path override is set, the dashboard path has credentials, and the gateway path is empty, the report prints the supported `config set` command for the `platforms.whatsapp.extra.session_path` configuration key, including the new-configuration-key opt-in when generated configs do not already contain that key.
When the default gateway session path holds no credentials, the probe reads `platforms.whatsapp.extra.session_path` from `/sandbox/.hermes/config.yaml` and checks the configured path, so a completed session-path repair reports the session as found rather than as an unresolved split.
The report then adds an info `Session path override` line that states the gateway session check used the path set in `platforms.whatsapp.extra.session_path`.
Remove the override only after Hermes uses one WhatsApp session path for dashboard pairing and gateway startup.
The probe uses the configured path only when it is an absolute path under `/sandbox/.hermes` whose segments contain only letters, digits, periods, underscores, and hyphens.
Any other value, including a path with a `.` or `..` segment, keeps the default path check and reports the override as unsupported.
A repaired Hermes sandbox reports verdict `unknown` and exits 0, because NemoClaw does not treat a Hermes session file as live inbound-health evidence.

For Telegram, `--channel telegram` probes the sandbox to report the gateway process, Bot API reachability, and inbound delivery alongside the config comparison.
It classifies the state as `healthy`, `idle`, `token_rejected`, `unreachable`, `not_started`, `policy_gap`, `config_gap`, `unknown`, or `probe_failed`.
Expand Down
87 changes: 87 additions & 0 deletions src/lib/actions/sandbox/channel-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,42 @@ function hermesSessionProbeOutput(options: {
].join("\n");
}

const HERMES_DEFAULT_SESSION_DIR = "/sandbox/.hermes/platforms/whatsapp/session";
const HERMES_DASHBOARD_SESSION_DIR =
"/sandbox/.hermes/profiles/dashboard-home/platforms/whatsapp/session";

function hermesConfigYaml(sessionPath: string): string {
return [
"platforms:",
" whatsapp:",
" extra:",
` session_path: ${JSON.stringify(sessionPath)}`,
].join("\n");
}

function hermesExec(options: {
readonly configYaml?: string;
readonly credsDirs: readonly string[];
}) {
const hasCreds = (credsFile: string) =>
options.credsDirs.some((dir) => credsFile === `${dir}/creds.json`);
return vi.fn((_sandbox: string, command: string, _timeoutMs?: number) => {
if (command.startsWith("cat ")) {
return options.configYaml === undefined
? { status: 1, stdout: "", stderr: "cat: no such file" }
: { status: 0, stdout: options.configYaml, stderr: "" };
}
return {
status: 0,
stdout: hermesSessionProbeOutput({
gatewaySessionCreds: hasCreds(/gateway='([^']*)'/.exec(command)?.[1] ?? ""),
dashboardSessionCreds: hasCreds(/dashboard='([^']*)'/.exec(command)?.[1] ?? ""),
}),
stderr: "",
};
});
}

describe("showSandboxChannelStatus (whatsapp)", () => {
it("returns idle verdict and exit code 1 when paired but no inbound observed", async () => {
const stdout = waStatusJson({
Expand Down Expand Up @@ -281,6 +317,57 @@ describe("showSandboxChannelStatus (whatsapp)", () => {
expect(session?.severity).toBe("ok");
});

it("clears the session-path split after the documented session_path repair (#8718)", async () => {
const exec = hermesExec({
configYaml: hermesConfigYaml(HERMES_DASHBOARD_SESSION_DIR),
credsDirs: [HERMES_DASHBOARD_SESSION_DIR],
});
const { deps, out_lines } = makeDeps({
exec,
agentName: "hermes",
sandbox: entry(["whatsapp"], [], {}, "hermes"),
});
const result = await showSandboxChannelStatus("alpha", { deps, channel: "whatsapp" });
const signals = result && "report" in result ? result.report.signals : [];
const dump = out_lines.join("\n");
expect(result && "report" in result && result.report.verdict).not.toBe("unpaired");
expect(signals.find((signal) => signal.label === "Session location")?.severity).toBe("ok");
expect(signals.find((signal) => signal.label === "Session path override")?.severity).toBe(
"info",
);
expect(dump).not.toContain("the Hermes gateway session path is empty");
expect(exec.mock.calls.map((call) => String(call[1] ?? "")).join("\n")).toContain(
`gateway='${HERMES_DASHBOARD_SESSION_DIR}/creds.json'`,
);
Comment thread
apurvvkumaria marked this conversation as resolved.
Resolved
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

it("keeps the default session path when the configured session path is unsupported (#8718)", async () => {
const exec = hermesExec({
configYaml: hermesConfigYaml("/etc/hermes/session"),
credsDirs: [HERMES_DASHBOARD_SESSION_DIR],
});
const exitSpy = vi.spyOn(process, "exit").mockImplementation(((code?: number) => {
throw new Error(`process.exit(${code})`);
}) as never);
const { deps } = makeDeps({
exec,
agentName: "hermes",
sandbox: entry(["whatsapp"], [], {}, "hermes"),
});
let threw: Error | null = null;
try {
await showSandboxChannelStatus("alpha", { deps, channel: "whatsapp" });
} catch (err) {
threw = err as Error;
} finally {
exitSpy.mockRestore();
}
const commands = exec.mock.calls.map((call) => String(call[1] ?? "")).join("\n");
expect(threw?.message).toBe("process.exit(1)");
expect(commands).toContain(`gateway='${HERMES_DEFAULT_SESSION_DIR}/creds.json'`);
expect(commands).not.toContain("/etc/hermes/session");
});

it("skips the deep probe and reports paused state when WhatsApp is in disabledChannels", async () => {
// Regression guard: `channels stop whatsapp` deliberately drops the
// bridge and preset until the operator runs `channels start`. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,71 @@ describe("evaluateWhatsappDiagnostics", () => {
expect(session?.hint).toBe("use one active WhatsApp bridge for the paired account");
});

it("accepts credentials found through the configured session path (#8718)", () => {
const report = evaluateWhatsappDiagnostics(
baseInput({
agent: "hermes",
paired: null,
sessionLocations: {
gatewaySessionCreds: true,
dashboardSessionCreds: true,
gatewaySessionPathSource: "config",
},
}),
);
const session = report.signals.find((s) => s.label === "Session location");
const override = report.signals.find((s) => s.label === "Session path override");
expect(report.verdict).toBe("unknown");
expect(session?.severity).toBe("ok");
expect(session?.detail).toBe(
"the configured Hermes WhatsApp session path contains credentials",
);
expect(override?.severity).toBe("info");
expect(override?.detail).toContain("platforms.whatsapp.extra.session_path");
});

it("stops repeating the repair command when the configured session path is empty (#8718)", () => {
const report = evaluateWhatsappDiagnostics(
baseInput({
agent: "hermes",
paired: false,
sessionLocations: {
gatewaySessionCreds: false,
dashboardSessionCreds: true,
gatewaySessionPathSource: "config",
},
}),
);
const session = report.signals.find((s) => s.label === "Session location");
expect(report.verdict).toBe("unpaired");
expect(session?.severity).toBe("warn");
expect(session?.detail).toBe(
"the configured Hermes WhatsApp session path has no WhatsApp credentials",
);
expect(report.hints.join(" ")).not.toContain("--config-accept-new-path");
expect(report.hints.join(" ")).toContain("hermes whatsapp");
});

it("warns when the configured session path is not a supported sandbox path (#8718)", () => {
const report = evaluateWhatsappDiagnostics(
baseInput({
agent: "hermes",
paired: false,
sessionLocations: {
gatewaySessionCreds: false,
dashboardSessionCreds: true,
gatewaySessionPathSource: "unsupported",
},
}),
);
const session = report.signals.find((s) => s.label === "Session location");
const override = report.signals.find((s) => s.label === "Session path override");
expect(session?.severity).toBe("warn");
expect(session?.detail).toMatch(/dashboard-home has WhatsApp credentials/);
expect(override?.severity).toBe("warn");
expect(override?.detail).toContain("not a supported session path");
});

it("returns idle when paired with a live WebSocket but no inbound event observed", () => {
// This is the exact #4386 shape: pairing is fine, WebSocket is up, but
// lastInboundAt is still null. We MUST NOT report this as healthy.
Expand Down
43 changes: 42 additions & 1 deletion src/lib/messaging/channels/whatsapp/hooks/status-health-eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export type WhatsappProbeInput = {
export type WhatsappSessionLocations = {
gatewaySessionCreds: boolean | null;
dashboardSessionCreds: boolean | null;
gatewaySessionPathSource?: "default" | "config" | "unsupported";
};

/**
Expand Down Expand Up @@ -180,7 +181,8 @@ function hermesDashboardOnlySession(input: WhatsappProbeInput): boolean {
return (
input.agent === "hermes" &&
input.sessionLocations?.gatewaySessionCreds === false &&
input.sessionLocations.dashboardSessionCreds === true
input.sessionLocations.dashboardSessionCreds === true &&
input.sessionLocations.gatewaySessionPathSource !== "config"
);
}

Expand All @@ -189,6 +191,20 @@ function sessionLocationSignal(input: WhatsappProbeInput): DiagnosticSignal | nu
if (!locations) return null;
const gateway = locations.gatewaySessionCreds;
const dashboard = locations.dashboardSessionCreds;
if (locations.gatewaySessionPathSource === "config" && gateway !== null) {
return gateway
? {
label: "Session location",
severity: "ok",
detail: "the configured Hermes WhatsApp session path contains credentials",
}
: {
label: "Session location",
severity: "warn",
detail: "the configured Hermes WhatsApp session path has no WhatsApp credentials",
hint: "pair WhatsApp again, or set `platforms.whatsapp.extra.session_path` to the session path that holds the credentials",
};
}
if (gateway === false && dashboard === true) {
return {
label: "Session location",
Expand Down Expand Up @@ -227,6 +243,29 @@ function sessionLocationSignal(input: WhatsappProbeInput): DiagnosticSignal | nu
};
}

function sessionPathOverrideSignal(input: WhatsappProbeInput): DiagnosticSignal | null {
const source = input.sessionLocations?.gatewaySessionPathSource;
if (source === "config") {
return {
label: "Session path override",
severity: "info",
detail:
"the gateway session check used the path set in `platforms.whatsapp.extra.session_path`",
hint: "remove the override after Hermes uses one WhatsApp session path for dashboard pairing and gateway startup",
};
}
if (source === "unsupported") {
return {
label: "Session path override",
severity: "warn",
detail:
"`platforms.whatsapp.extra.session_path` is not a supported session path, so the gateway session check used the default path",
hint: "set `platforms.whatsapp.extra.session_path` to an absolute path under `/sandbox/.hermes` that has no `.` or `..` segment",
};
}
return null;
}

function websocketSignal(input: WhatsappProbeInput): DiagnosticSignal {
if (input.heartbeatParseError) {
return {
Expand Down Expand Up @@ -507,10 +546,12 @@ function buildHints(verdict: WhatsappVerdict, input: WhatsappProbeInput): string

export function evaluateWhatsappDiagnostics(input: WhatsappProbeInput): WhatsappDiagnosticReport {
const sessionSignal = sessionLocationSignal(input);
const overrideSignal = sessionPathOverrideSignal(input);
const signals: DiagnosticSignal[] = [
configCoverageSignal(input),
pairingSignal(input),
...(sessionSignal ? [sessionSignal] : []),
...(overrideSignal ? [overrideSignal] : []),
bridgeProcessSignal(input),
websocketSignal(input),
inboundSignal(input),
Expand Down
Loading
Loading