UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

73 lines (72 loc) 3.02 kB
import { c as normalizeOptionalLowercaseString } from "./string-coerce-CIXf7egm.js"; import { a as writeRuntimeJson, r as defaultRuntime } from "./runtime-CF2WjnNZ.js"; import { r as createLazyRuntimeModule } from "./lazy-runtime-CgCh8H_K.js"; import { o as redactSensitiveUrlLikeString } from "./redact-sensitive-url-BN1NZvXG.js"; import { t as formatErrorMessage } from "./errors-Db3Ymjlb.js"; import { n as isGatewaySecretRefUnavailableError } from "./credentials-CXbS4PS0.js"; import { o as callGateway } from "./call-BWR5pPgw.js"; import { a as isExpectedCliError, n as formatCliFailureLines, o as isGatewayCredentialsCliError } from "./failure-output-Dc5ce9_F.js"; import { n as parseTimeoutMsWithFallback } from "./parse-timeout-BhPKqfrV.js"; import { r as withProgress } from "./progress-DSeqxbrQ.js"; //#region src/commands/channels/status.ts const loadChannelsStatusRuntime = createLazyRuntimeModule(() => import("./status.runtime-BZwmuw0i.js")); function redactGatewayUrlSecretsInText(text) { return text.replace(/\b(?:wss?|https?):\/\/[^\s"'<>]+/gi, (rawUrl) => { return redactSensitiveUrlLikeString(rawUrl); }); } function formatChannelsStatusError(err) { return redactGatewayUrlSecretsInText(formatErrorMessage(err)); } /** Query gateway channel status, falling back to config-only output when unavailable. */ async function channelsStatusCommand(opts, runtime = defaultRuntime) { const args = normalizeOptionalLowercaseString(opts.channel) === "all" ? { ...opts, channel: void 0 } : opts; const timeoutMs = parseTimeoutMsWithFallback(opts.timeout, opts.probe ? 3e4 : 1e4, { invalidType: "error" }); const statusLabel = opts.probe ? "Checking channel status (probe)…" : "Checking channel status…"; if (opts.json !== true && !process.stderr.isTTY) runtime.log(statusLabel); try { const payload = await withProgress({ label: statusLabel, indeterminate: true, enabled: opts.json !== true }, async () => { const params = { probe: Boolean(opts.probe), timeoutMs }; if (args.channel) params.channel = args.channel; return await callGateway({ method: "channels.status", params, timeoutMs }); }); if (opts.json) { writeRuntimeJson(runtime, payload); return; } const { formatGatewayChannelsStatusLines } = await loadChannelsStatusRuntime(); runtime.log(formatGatewayChannelsStatusLines(payload).join("\n")); } catch (err) { const safeError = formatChannelsStatusError(err); const expectedError = isExpectedCliError(err); const gatewayAuthUnavailable = isGatewayCredentialsCliError(err) || isGatewaySecretRefUnavailableError(err); const expectedErrorOutput = expectedError ? formatCliFailureLines({ title: "", error: err }).join("\n") : void 0; const { renderChannelsStatusFallback } = await loadChannelsStatusRuntime(); await renderChannelsStatusFallback({ opts: args, runtime, safeError, gatewayAuthUnavailable, expectedErrorOutput }); } } //#endregion export { channelsStatusCommand as t };