chore: expand provider details in status
This commit is contained in:
@@ -35,6 +35,21 @@ export function formatGatewayProvidersStatusLines(
|
|||||||
if (typeof account.running === "boolean") {
|
if (typeof account.running === "boolean") {
|
||||||
bits.push(account.running ? "running" : "stopped");
|
bits.push(account.running ? "running" : "stopped");
|
||||||
}
|
}
|
||||||
|
if (typeof account.mode === "string" && account.mode.length > 0) {
|
||||||
|
bits.push(`mode:${account.mode}`);
|
||||||
|
}
|
||||||
|
if (typeof account.tokenSource === "string" && account.tokenSource) {
|
||||||
|
bits.push(`token:${account.tokenSource}`);
|
||||||
|
}
|
||||||
|
if (typeof account.botTokenSource === "string" && account.botTokenSource) {
|
||||||
|
bits.push(`bot:${account.botTokenSource}`);
|
||||||
|
}
|
||||||
|
if (typeof account.appTokenSource === "string" && account.appTokenSource) {
|
||||||
|
bits.push(`app:${account.appTokenSource}`);
|
||||||
|
}
|
||||||
|
if (typeof account.baseUrl === "string" && account.baseUrl) {
|
||||||
|
bits.push(`url:${account.baseUrl}`);
|
||||||
|
}
|
||||||
const probe = account.probe as { ok?: boolean } | undefined;
|
const probe = account.probe as { ok?: boolean } | undefined;
|
||||||
if (probe && typeof probe.ok === "boolean") {
|
if (probe && typeof probe.ok === "boolean") {
|
||||||
bits.push(probe.ok ? "works" : "probe failed");
|
bits.push(probe.ok ? "works" : "probe failed");
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import { type ClawdbotConfig, loadConfig } from "../config/config.js";
|
import { type ClawdbotConfig, loadConfig } from "../config/config.js";
|
||||||
import { resolveTelegramToken } from "../telegram/token.js";
|
import { resolveTelegramAccount, listTelegramAccountIds } from "../telegram/accounts.js";
|
||||||
|
import { resolveDiscordAccount, listDiscordAccountIds } from "../discord/accounts.js";
|
||||||
|
import { resolveSlackAccount, listSlackAccountIds } from "../slack/accounts.js";
|
||||||
|
import { resolveSignalAccount, listSignalAccountIds } from "../signal/accounts.js";
|
||||||
|
import { resolveIMessageAccount, listIMessageAccountIds } from "../imessage/accounts.js";
|
||||||
import { theme } from "../terminal/theme.js";
|
import { theme } from "../terminal/theme.js";
|
||||||
import { normalizeE164 } from "../utils.js";
|
import { normalizeE164 } from "../utils.js";
|
||||||
import {
|
import {
|
||||||
@@ -7,6 +11,8 @@ import {
|
|||||||
readWebSelfId,
|
readWebSelfId,
|
||||||
webAuthExists,
|
webAuthExists,
|
||||||
} from "../web/session.js";
|
} from "../web/session.js";
|
||||||
|
import { listWhatsAppAccountIds, resolveWhatsAppAccount } from "../web/accounts.js";
|
||||||
|
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
|
||||||
|
|
||||||
export type ProviderSummaryOptions = {
|
export type ProviderSummaryOptions = {
|
||||||
colorize?: boolean;
|
colorize?: boolean;
|
||||||
@@ -27,6 +33,13 @@ export async function buildProviderSummary(
|
|||||||
const resolved = { ...DEFAULT_OPTIONS, ...options };
|
const resolved = { ...DEFAULT_OPTIONS, ...options };
|
||||||
const tint = (value: string, color?: (input: string) => string) =>
|
const tint = (value: string, color?: (input: string) => string) =>
|
||||||
resolved.colorize && color ? color(value) : value;
|
resolved.colorize && color ? color(value) : value;
|
||||||
|
const formatAccountLabel = (params: { accountId: string; name?: string }) => {
|
||||||
|
const base = params.accountId || DEFAULT_ACCOUNT_ID;
|
||||||
|
if (params.name?.trim()) return `${base} (${params.name.trim()})`;
|
||||||
|
return base;
|
||||||
|
};
|
||||||
|
const accountLine = (label: string, details: string[]) =>
|
||||||
|
` - ${label}${details.length ? ` (${details.join(", ")})` : ""}`;
|
||||||
|
|
||||||
const webEnabled = effective.web?.enabled !== false;
|
const webEnabled = effective.web?.enabled !== false;
|
||||||
if (!webEnabled) {
|
if (!webEnabled) {
|
||||||
@@ -44,52 +57,198 @@ export async function buildProviderSummary(
|
|||||||
)
|
)
|
||||||
: tint("WhatsApp: not linked", theme.error),
|
: tint("WhatsApp: not linked", theme.error),
|
||||||
);
|
);
|
||||||
|
if (webLinked) {
|
||||||
|
for (const accountId of listWhatsAppAccountIds(effective)) {
|
||||||
|
const account = resolveWhatsAppAccount({ cfg: effective, accountId });
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
if (account.selfChatMode) details.push("self-chat");
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const telegramEnabled = effective.telegram?.enabled !== false;
|
const telegramEnabled = effective.telegram?.enabled !== false;
|
||||||
if (!telegramEnabled) {
|
if (!telegramEnabled) {
|
||||||
lines.push(tint("Telegram: disabled", theme.muted));
|
lines.push(tint("Telegram: disabled", theme.muted));
|
||||||
} else {
|
} else {
|
||||||
const { token: telegramToken } = resolveTelegramToken(effective);
|
const accounts = listTelegramAccountIds(effective).map((accountId) =>
|
||||||
const telegramConfigured = Boolean(telegramToken?.trim());
|
resolveTelegramAccount({ cfg: effective, accountId }),
|
||||||
|
);
|
||||||
|
const configuredAccounts = accounts.filter((account) =>
|
||||||
|
Boolean(account.token?.trim()),
|
||||||
|
);
|
||||||
|
const telegramConfigured = configuredAccounts.length > 0;
|
||||||
lines.push(
|
lines.push(
|
||||||
telegramConfigured
|
telegramConfigured
|
||||||
? tint("Telegram: configured", theme.success)
|
? tint("Telegram: configured", theme.success)
|
||||||
: tint("Telegram: not configured", theme.muted),
|
: tint("Telegram: not configured", theme.muted),
|
||||||
);
|
);
|
||||||
|
if (telegramConfigured) {
|
||||||
|
for (const account of configuredAccounts) {
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
if (account.tokenSource && account.tokenSource !== "none") {
|
||||||
|
details.push(`token:${account.tokenSource}`);
|
||||||
|
}
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const discordEnabled = effective.discord?.enabled !== false;
|
||||||
|
if (!discordEnabled) {
|
||||||
|
lines.push(tint("Discord: disabled", theme.muted));
|
||||||
|
} else {
|
||||||
|
const accounts = listDiscordAccountIds(effective).map((accountId) =>
|
||||||
|
resolveDiscordAccount({ cfg: effective, accountId }),
|
||||||
|
);
|
||||||
|
const configuredAccounts = accounts.filter((account) =>
|
||||||
|
Boolean(account.token?.trim()),
|
||||||
|
);
|
||||||
|
const discordConfigured = configuredAccounts.length > 0;
|
||||||
|
lines.push(
|
||||||
|
discordConfigured
|
||||||
|
? tint("Discord: configured", theme.success)
|
||||||
|
: tint("Discord: not configured", theme.muted),
|
||||||
|
);
|
||||||
|
if (discordConfigured) {
|
||||||
|
for (const account of configuredAccounts) {
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
if (account.tokenSource && account.tokenSource !== "none") {
|
||||||
|
details.push(`token:${account.tokenSource}`);
|
||||||
|
}
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const slackEnabled = effective.slack?.enabled !== false;
|
||||||
|
if (!slackEnabled) {
|
||||||
|
lines.push(tint("Slack: disabled", theme.muted));
|
||||||
|
} else {
|
||||||
|
const accounts = listSlackAccountIds(effective).map((accountId) =>
|
||||||
|
resolveSlackAccount({ cfg: effective, accountId }),
|
||||||
|
);
|
||||||
|
const configuredAccounts = accounts.filter(
|
||||||
|
(account) =>
|
||||||
|
Boolean(account.botToken?.trim()) && Boolean(account.appToken?.trim()),
|
||||||
|
);
|
||||||
|
const slackConfigured = configuredAccounts.length > 0;
|
||||||
|
lines.push(
|
||||||
|
slackConfigured
|
||||||
|
? tint("Slack: configured", theme.success)
|
||||||
|
: tint("Slack: not configured", theme.muted),
|
||||||
|
);
|
||||||
|
if (slackConfigured) {
|
||||||
|
for (const account of configuredAccounts) {
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
if (account.botTokenSource && account.botTokenSource !== "none") {
|
||||||
|
details.push(`bot:${account.botTokenSource}`);
|
||||||
|
}
|
||||||
|
if (account.appTokenSource && account.appTokenSource !== "none") {
|
||||||
|
details.push(`app:${account.appTokenSource}`);
|
||||||
|
}
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const signalEnabled = effective.signal?.enabled !== false;
|
const signalEnabled = effective.signal?.enabled !== false;
|
||||||
if (!signalEnabled) {
|
if (!signalEnabled) {
|
||||||
lines.push(tint("Signal: disabled", theme.muted));
|
lines.push(tint("Signal: disabled", theme.muted));
|
||||||
} else {
|
} else {
|
||||||
const signalConfigured =
|
const accounts = listSignalAccountIds(effective).map((accountId) =>
|
||||||
Boolean(effective.signal) &&
|
resolveSignalAccount({ cfg: effective, accountId }),
|
||||||
Boolean(
|
);
|
||||||
effective.signal?.account?.trim() ||
|
const configuredAccounts = accounts.filter((account) => account.configured);
|
||||||
effective.signal?.httpUrl?.trim() ||
|
const signalConfigured = configuredAccounts.length > 0;
|
||||||
effective.signal?.cliPath?.trim() ||
|
|
||||||
effective.signal?.httpHost?.trim() ||
|
|
||||||
typeof effective.signal?.httpPort === "number" ||
|
|
||||||
typeof effective.signal?.autoStart === "boolean",
|
|
||||||
);
|
|
||||||
lines.push(
|
lines.push(
|
||||||
signalConfigured
|
signalConfigured
|
||||||
? tint("Signal: configured", theme.success)
|
? tint("Signal: configured", theme.success)
|
||||||
: tint("Signal: not configured", theme.muted),
|
: tint("Signal: not configured", theme.muted),
|
||||||
);
|
);
|
||||||
|
if (signalConfigured) {
|
||||||
|
for (const account of configuredAccounts) {
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
if (account.baseUrl) details.push(account.baseUrl);
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const imessageEnabled = effective.imessage?.enabled !== false;
|
const imessageEnabled = effective.imessage?.enabled !== false;
|
||||||
if (!imessageEnabled) {
|
if (!imessageEnabled) {
|
||||||
lines.push(tint("iMessage: disabled", theme.muted));
|
lines.push(tint("iMessage: disabled", theme.muted));
|
||||||
} else {
|
} else {
|
||||||
const imessageConfigured = Boolean(effective.imessage);
|
const accounts = listIMessageAccountIds(effective).map((accountId) =>
|
||||||
|
resolveIMessageAccount({ cfg: effective, accountId }),
|
||||||
|
);
|
||||||
|
const configuredAccounts = accounts.filter((account) => account.configured);
|
||||||
|
const imessageConfigured = configuredAccounts.length > 0;
|
||||||
lines.push(
|
lines.push(
|
||||||
imessageConfigured
|
imessageConfigured
|
||||||
? tint("iMessage: configured", theme.success)
|
? tint("iMessage: configured", theme.success)
|
||||||
: tint("iMessage: not configured", theme.muted),
|
: tint("iMessage: not configured", theme.muted),
|
||||||
);
|
);
|
||||||
|
if (imessageConfigured) {
|
||||||
|
for (const account of configuredAccounts) {
|
||||||
|
const details: string[] = [];
|
||||||
|
if (!account.enabled) details.push("disabled");
|
||||||
|
lines.push(
|
||||||
|
accountLine(
|
||||||
|
formatAccountLabel({
|
||||||
|
accountId: account.accountId,
|
||||||
|
name: account.name,
|
||||||
|
}),
|
||||||
|
details,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolved.includeAllowFrom) {
|
if (resolved.includeAllowFrom) {
|
||||||
|
|||||||
Reference in New Issue
Block a user