refactor: normalize cli command hints
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { PollInput } from "../polls.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
|
||||
|
||||
@@ -42,7 +43,7 @@ export function requireActiveWebListener(accountId?: string | null): {
|
||||
const listener = listeners.get(id) ?? null;
|
||||
if (!listener) {
|
||||
throw new Error(
|
||||
`No active WhatsApp Web listener (account: ${id}). Start the gateway, then link WhatsApp with: clawdbot channels login --channel whatsapp --account ${id}.`,
|
||||
`No active WhatsApp Web listener (account: ${id}). Start the gateway, then link WhatsApp with: ${formatCliCommand(`clawdbot channels login --channel whatsapp --account ${id}`)}.`,
|
||||
);
|
||||
}
|
||||
return { accountId: id, listener };
|
||||
|
||||
@@ -7,6 +7,7 @@ import { info, success } from "../globals.js";
|
||||
import { getChildLogger } from "../logging.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { WebChannel } from "../utils.js";
|
||||
import { jidToE164, resolveUserPath } from "../utils.js";
|
||||
|
||||
@@ -176,7 +177,7 @@ export async function pickWebChannel(
|
||||
const hasWeb = await webAuthExists(authDir);
|
||||
if (!hasWeb) {
|
||||
throw new Error(
|
||||
"No WhatsApp Web session found. Run `clawdbot channels login --channel whatsapp --verbose` to link.",
|
||||
`No WhatsApp Web session found. Run \`${formatCliCommand("clawdbot channels login --channel whatsapp --verbose")}\` to link.`,
|
||||
);
|
||||
}
|
||||
return choice;
|
||||
|
||||
@@ -11,6 +11,7 @@ import { registerUnhandledRejectionHandler } from "../../infra/unhandled-rejecti
|
||||
import { getChildLogger } from "../../logging.js";
|
||||
import { resolveAgentRoute } from "../../routing/resolve-route.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../../runtime.js";
|
||||
import { formatCliCommand } from "../../cli/command-format.js";
|
||||
import { resolveWhatsAppAccount } from "../accounts.js";
|
||||
import { setActiveWebListener } from "../active-listener.js";
|
||||
import { monitorWebInbox } from "../inbound.js";
|
||||
@@ -374,7 +375,7 @@ export async function monitorWebChannel(
|
||||
|
||||
if (loggedOut) {
|
||||
runtime.error(
|
||||
"WhatsApp session logged out. Run `clawdbot channels login --channel web` to relink.",
|
||||
`WhatsApp session logged out. Run \`${formatCliCommand("clawdbot channels login --channel web")}\` to relink.`,
|
||||
);
|
||||
await closeListener();
|
||||
break;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { loadConfig } from "../config/config.js";
|
||||
import { danger, info, success } from "../globals.js";
|
||||
import { logInfo } from "../logger.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import { resolveWhatsAppAccount } from "./accounts.js";
|
||||
import { createWaSocket, formatError, logoutWeb, waitForWaConnection } from "./session.js";
|
||||
|
||||
@@ -56,7 +57,7 @@ export async function loginWeb(
|
||||
});
|
||||
console.error(
|
||||
danger(
|
||||
"WhatsApp reported the session is logged out. Cleared cached web session; please rerun clawdbot channels login and scan the QR again.",
|
||||
`WhatsApp reported the session is logged out. Cleared cached web session; please rerun ${formatCliCommand("clawdbot channels login")} and scan the QR again.`,
|
||||
),
|
||||
);
|
||||
throw new Error("Session logged out; cache cleared. Re-run login.");
|
||||
|
||||
@@ -12,6 +12,7 @@ import { danger, success } from "../globals.js";
|
||||
import { getChildLogger, toPinoLikeLogger } from "../logging.js";
|
||||
import { ensureDir, resolveUserPath } from "../utils.js";
|
||||
import { VERSION } from "../version.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
|
||||
import {
|
||||
maybeRestoreCredsFromBackup,
|
||||
@@ -134,7 +135,11 @@ export async function createWaSocket(
|
||||
if (connection === "close") {
|
||||
const status = getStatusCode(lastDisconnect?.error);
|
||||
if (status === DisconnectReason.loggedOut) {
|
||||
console.error(danger("WhatsApp session logged out. Run: clawdbot channels login"));
|
||||
console.error(
|
||||
danger(
|
||||
`WhatsApp session logged out. Run: ${formatCliCommand("clawdbot channels login")}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (connection === "open" && verbose) {
|
||||
|
||||
Reference in New Issue
Block a user