openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
434 lines (433 loc) • 20.8 kB
JavaScript
import "./redact-BDinS1q9.js";
import "./errors-BxyFnvP3.js";
import "./unhandled-rejections-CDJ8dOVP.js";
import "./logger-kwZIqwuw.js";
import "./paths-ViKUYWUK.js";
import "./tmp-openclaw-dir-idKIOMmb.js";
import { r as theme } from "./theme-CdOoMzRk.js";
import { s as setVerbose, t as danger } from "./globals-DBUMOBZ8.js";
import { m as defaultRuntime } from "./subsystem-DISldKSB.js";
import { t as sanitizeForLog } from "./ansi-BEJF8NKS.js";
import "./boolean-C3GkJetE.js";
import "./env-Dnra1IpT.js";
import "./warning-filter-CBhOcgHd.js";
import "./utils-CS0Ikux6.js";
import { t as formatDocsLink } from "./links-8xRhWBQL.js";
import { t as hasExplicitOptions } from "./command-options-5coRiipK.js";
import "./paths-C4Oy7wjk.js";
import "./auth-profiles-DRuJBw5y.js";
import { t as isBlockedObjectKey } from "./prototype-keys-Cm_8mWvq.js";
import "./agent-scope-bjWqU22i.js";
import "./boundary-path-Dm0QJ7-y.js";
import "./boundary-file-read-DcZxlWD8.js";
import "./logger-BmpSCz93.js";
import "./exec-B5_AYfQG.js";
import "./workspace-D4K6QX9X.js";
import "./model-selection-BnFtDmP7.js";
import { g as writeConfigFile, s as loadConfig } from "./io-y3Az_Onx.js";
import "./shell-env-BOu7XeT_.js";
import "./safe-text-yavot2qw.js";
import "./version-CD3oP1-d.js";
import "./env-substitution-O6uabUmO.js";
import "./includes-Bj3eLUWH.js";
import "./zod-schema.providers-core-COy5nBQ0.js";
import "./legacy-web-search-BB-ZHEhz.js";
import "./registry-C5UkPpaO.js";
import "./config-state-Br0ucqMb.js";
import "./min-host-version-RMBWtIAR.js";
import "./manifest-registry-B5JNQdOM.js";
import "./runtime-guard-PhQ6PwQa.js";
import "./avatar-policy-B5nOfso_.js";
import "./ip-Ce8EDTBZ.js";
import "./zod-schema.agent-runtime-Dtg4Jy6G.js";
import "./zod-schema.core-BuVz8Rk7.js";
import "./config-D4zN4BRl.js";
import "./file-lock-DEiVq2ow.js";
import "./audit-fs-DTQIjp2r.js";
import "./resolve-B7S4PlnO.js";
import "./profiles-COPO-hHI.js";
import "./tailscale-CxY-91GZ.js";
import "./tailnet-DHiKSG7V.js";
import "./net-JAg9zL0G.js";
import "./auth-Buq0Niri.js";
import "./credentials-D8pfRimu.js";
import "./message-channel-BliByQBl.js";
import "./store-C5UK26Ce.js";
import "./runtime-Iz8uZ7EU.js";
import { c as listChannelPlugins, l as normalizeChannelId } from "./plugins-B09-vgme.js";
import "./sessions-D9ZgHCHb.js";
import "./paths-rhN9LKM_.js";
import "./session-write-lock-va3qZE6f.js";
import "./method-scopes-BiEi0X2g.js";
import "./call-CQbSO4Fr.js";
import "./prompt-style-C4CV4Y_p.js";
import "./ports-lsof-BLEgL_Gn.js";
import "./restart-stale-pids-BsPvlGJd.js";
import "./ports-FldL_Lhq.js";
import "./logging-CznuqaMu.js";
import "./commands-C6oAw_H-.js";
import "./issue-format-BtLIwOtN.js";
import "./progress-C78aA91n.js";
import { t as formatHelpExamples } from "./help-format-C_5MeE_w.js";
import "./identity-Dp-UIak4.js";
import "./heartbeat-Bdfr_onc.js";
import "./pi-embedded-CbCYZxIb.js";
import "./internal-hooks-CIUghoK4.js";
import "./multimodal-B8yEZcl5.js";
import "./memory-search-B_aq08y5.js";
import "./provider-catalog-rVN7ZbR5.js";
import "./secret-input-DXoOLNgb.js";
import "./bindings-CFudGB9Z.js";
import "./resolve-route-DwFWP4JW.js";
import "./routing-zOQ0wwtV.js";
import "./identity-file-DVLib087.js";
import "./outbound-runtime-m-y0nd6F.js";
import "./provider-env-vars-CpUJqT5v.js";
import "./provider-auth-input-Bus9W_qh.js";
import "./provider-model-minimax-DSmX4BNO.js";
import "./provider-models-BKjzpTsb.js";
import "./anthropic-vertex-provider-B2x4YywE.js";
import "./provider-catalog-BTgF8VyO.js";
import "./provider-catalog-D0IlX18O.js";
import "./provider-catalog-BTmUX0Mp.js";
import "./provider-catalog-sph_Rl63.js";
import "./provider-catalog-C7tUyBwV.js";
import "./provider-catalog-C8dPZpHW.js";
import "./provider-catalog-BJNff1VI.js";
import "./provider-catalog-IAdymoqT.js";
import "./provider-catalog-Bjc7evzh.js";
import "./models-config.providers.discovery-CjkO08q6.js";
import "./text-runtime-DVXt5xhi.js";
import "./tool-catalog-BjSY4C4F.js";
import "./docker-Bhjg8g2t.js";
import "./sandbox-DTlKNieF.js";
import "./common-zReYuoMM.js";
import "./image-ops-By4YfyWa.js";
import "./thinking-CJoSRIGR.js";
import "./path-alias-guards-CwRM04O1.js";
import "./sandbox-paths-Cn8i8Jxm.js";
import "./channel-actions-fV93bLjV.js";
import "./mime-CsUtzcn2.js";
import "./ssrf-0bPJMoZR.js";
import "./fetch-guard-CYl1q2XH.js";
import "./provider-web-search-COZNygbd.js";
import "./manager-Bw8JrihM.js";
import "./config-schema-CPzP2Ds6.js";
import "./channel-plugin-common-ClptUZHU.js";
import { i as resolveChannelDefaultAccountId } from "./helpers-BhHi_aZN.js";
import "./status-helpers-Cflmo90d.js";
import "./conversation-runtime-nmWgJSXS.js";
import "./runtime-whatsapp-boundary-XjdkYMz_.js";
import "./pairing-store-BGKLrjo6.js";
import "./json-store--JDX3zNL.js";
import "./secret-file-Bif7RlZ-.js";
import "./channel-config-schema-CgpS17zB.js";
import "./setup-binary-C2MYZTCc.js";
import "./archive-pOxyr9r4.js";
import "./fs-safe-DZyOgpPN.js";
import "./signal-cli-install-fVOL9FvX.js";
import "./setup-wizard-proxy-DoOpOF8S.js";
import "./setup-BI3ohdrT.js";
import "./dm-policy-shared-DtcQProI.js";
import "./runtime-env-DQOYrXVl.js";
import "./temp-path-B91lt0LF.js";
import "./diagnostic-CDTtMQBT.js";
import "./logging-CCTKg_fh.js";
import "./config-runtime-BYNizC50.js";
import "./level-overrides-DzIzQ3ZY.js";
import "./exec-approvals-BF_Qfdq8.js";
import "./webhook-ingress-D-H5frou.js";
import "./system-events-BU_NYynX.js";
import "./ssrf-policy-DYINyIKC.js";
import "./hook-runtime-BUYmDbaA.js";
import "./templating-BDXRiJUh.js";
import "./channel-reply-pipeline-BxH4-AP2.js";
import "./reply-history-n7nOPLta.js";
import "./commands-registry.data-BFXJWoqi.js";
import "./commands-registry-Bh9pJ817.js";
import "./frontmatter-CP5371Rm.js";
import "./env-overrides-BNSo89u5.js";
import "./skills-M0AZJeXx.js";
import "./skills-remote-BHxDA4Jw.js";
import "./workspace-dirs-DqDLiRvZ.js";
import "./pairing-token-DAszGmwD.js";
import "./skill-commands-D73dGR_l.js";
import "./config-CLRQPUSt.js";
import "./routes-XT2JfvT-.js";
import "./ssh-tunnel-LM52qY6N.js";
import "./server-middleware-BP59C6FL.js";
import "./provider-auth-ref-CQEp9sp3.js";
import "./provider-auth-helpers-Do3RFvdi.js";
import "./provider-api-key-auth-BEeRW3dq.js";
import "./pairing-labels-D27Y4Vv6.js";
import "./directory-runtime-D9Y42mW-.js";
import "./read-only-account-inspect-CJPRBFj7.js";
import "./src-BoNU6eQs.js";
import "./web-media-PKy3RbRG.js";
import "./media-understanding-BDOSvuM9.js";
import "./web-media-CiSbdGPs.js";
import "./state-paths-Dvb3Mfl3.js";
import "./llm-task-Br6Ixjlh.js";
import "./pi-model-discovery-DO3tFksS.js";
import "./exec-inline-eval-CpmxWJsW.js";
import "./target-registry-9OUOvlxj.js";
import "./external-content-DZI9vlJn.js";
import "./brave-onFD06fq.js";
import "./duckduckgo-CZuAOfiQ.js";
import "./exa-5bwgY04k.js";
import "./security-runtime-xlw0Fxx2.js";
import "./provider-usage-ClxTGn5c.js";
import "./provider-models-Bjv0V4OP.js";
import "./media-understanding-provider-DllGbg-v.js";
import "./media-understanding-provider-BDq4rFL-.js";
import "./provider-onboard-CSnPvkMM.js";
import "./onboard-BU8aRvq7.js";
import "./perplexity-web-search-provider-CI38RNUU.js";
import "./perplexity-CMZbsreI.js";
import "./model-definitions-CLagLj0g.js";
import "./onboard-0P7GBI2D.js";
import "./provider-catalog-CKHo9CRM.js";
import "./provider-models-Dmjtw6kn.js";
import "./stream-C-KGzzT0.js";
import "./web-search-CO1hvu_l.js";
import "./stagger-CFqdtCYL.js";
import "./command-secret-targets-DLs8jC2H.js";
import "./delivery-queue-DHURMSqX.js";
import "./channel-summary-Ctrv7moa.js";
import "./follow-redirects-CVAaqIk4.js";
import "./tool-policy-match-DQWWRSN4.js";
import "./runtime-CAdCdG-M.js";
import "./channel-status-BfM90KqH.js";
import "./discord-core-DLbIyXWy.js";
import "./cli-runtime-Cx1v7N7v.js";
import "./config-presence-DA3j8Nmi.js";
import "./query-expansion-BOJBTXsp.js";
import "./search-manager-DNBHwaee.js";
import "./acp-runtime-BHZj-SLU.js";
import "./telegram-core-DD8gCuaX.js";
import "./audit-BI48Fi3j.js";
import "./gateway-runtime-Dn2qAGY7.js";
import "./connection-auth-Nl2a3tDb.js";
import "./mcp-config-CDIWSqVk.js";
import "./install-source-utils-C3NuFv6M.js";
import "./installs-Qst5vOrV.js";
import { n as runCommandWithRuntime } from "./cli-utils-C5ijQCJ_.js";
import "./catalog-CgTRyvtW.js";
import "./note-Cq-EkeJ6.js";
import "./clack-prompter-BKFiPwYT.js";
import "./plugin-install-plan-L6kxUjNd.js";
import "./bundled-sources-xtMJNHi6.js";
import "./plugin-install-Bu44eMFG.js";
import { t as resolveInstallableChannelPlugin } from "./channel-plugin-resolution-BaxHpstt.js";
import { t as formatCliChannelOptions } from "./channel-options-DbO6O2eH.js";
//#region src/cli/channel-auth.ts
function supportsChannelAuthMode(plugin, mode) {
return mode === "login" ? Boolean(plugin.auth?.login) : Boolean(plugin.gateway?.logoutAccount);
}
function isConfiguredAuthPlugin(plugin, cfg) {
const channels = cfg.channels;
const key = plugin.id;
if (!channels || isBlockedObjectKey(key) || !Object.prototype.hasOwnProperty.call(channels, key)) return false;
const channelCfg = channels[key];
if (!channelCfg || typeof channelCfg !== "object") return false;
for (const accountId of plugin.config.listAccountIds(cfg)) try {
const account = plugin.config.resolveAccount(cfg, accountId);
if (plugin.config.isEnabled ? plugin.config.isEnabled(account, cfg) : account && typeof account === "object" ? account.enabled ?? true : true) return true;
} catch {
continue;
}
return false;
}
function resolveConfiguredAuthChannelInput(cfg, mode) {
const configured = listChannelPlugins().filter((plugin) => supportsChannelAuthMode(plugin, mode)).filter((plugin) => isConfiguredAuthPlugin(plugin, cfg)).map((plugin) => plugin.id);
if (configured.length === 1) return configured[0];
if (configured.length === 0) throw new Error(`Channel is required (no configured channels support ${mode}).`);
const safeIds = configured.map(sanitizeForLog);
throw new Error(`Channel is required when multiple configured channels support ${mode}: ${safeIds.join(", ")}`);
}
async function resolveChannelPluginForMode(opts, mode, cfg, runtime) {
const channelInput = opts.channel?.trim() || resolveConfiguredAuthChannelInput(cfg, mode);
const normalizedChannelId = normalizeChannelId(channelInput);
const resolved = await resolveInstallableChannelPlugin({
cfg,
runtime,
rawChannel: channelInput,
...normalizedChannelId ? { channelId: normalizedChannelId } : {},
allowInstall: true,
supports: (candidate) => supportsChannelAuthMode(candidate, mode)
});
const channelId = resolved.channelId ?? normalizedChannelId;
if (!channelId) throw new Error(`Unsupported channel: ${channelInput}`);
const plugin = resolved.plugin;
if (!plugin || !supportsChannelAuthMode(plugin, mode)) throw new Error(`Channel ${channelId} does not support ${mode}`);
return {
cfg: resolved.cfg,
configChanged: resolved.configChanged,
channelInput,
channelId,
plugin
};
}
function resolveAccountContext(plugin, opts, cfg) {
return { accountId: opts.account?.trim() || resolveChannelDefaultAccountId({
plugin,
cfg
}) };
}
async function runChannelLogin(opts, runtime = defaultRuntime) {
const { cfg, configChanged, channelInput, plugin } = await resolveChannelPluginForMode(opts, "login", loadConfig(), runtime);
if (configChanged) await writeConfigFile(cfg);
const login = plugin.auth?.login;
if (!login) throw new Error(`Channel ${channelInput} does not support login`);
setVerbose(Boolean(opts.verbose));
const { accountId } = resolveAccountContext(plugin, opts, cfg);
await login({
cfg,
accountId,
runtime,
verbose: Boolean(opts.verbose),
channelInput
});
}
async function runChannelLogout(opts, runtime = defaultRuntime) {
const { cfg, configChanged, channelInput, plugin } = await resolveChannelPluginForMode(opts, "logout", loadConfig(), runtime);
if (configChanged) await writeConfigFile(cfg);
const logoutAccount = plugin.gateway?.logoutAccount;
if (!logoutAccount) throw new Error(`Channel ${channelInput} does not support logout`);
const { accountId } = resolveAccountContext(plugin, opts, cfg);
await logoutAccount({
cfg,
accountId,
account: plugin.config.resolveAccount(cfg, accountId),
runtime
});
}
//#endregion
//#region src/cli/channels-cli.ts
const optionNamesAdd = [
"channel",
"account",
"name",
"token",
"privateKey",
"tokenFile",
"botToken",
"appToken",
"signalNumber",
"cliPath",
"dbPath",
"service",
"region",
"authDir",
"httpUrl",
"httpHost",
"httpPort",
"webhookPath",
"webhookUrl",
"audienceType",
"audience",
"useEnv",
"homeserver",
"userId",
"accessToken",
"password",
"deviceName",
"initialSyncLimit",
"ship",
"url",
"relayUrls",
"code",
"groupChannels",
"dmAllowlist",
"autoDiscoverChannels"
];
const optionNamesRemove = [
"channel",
"account",
"delete"
];
function runChannelsCommand(action) {
return runCommandWithRuntime(defaultRuntime, action);
}
function runChannelsCommandWithDanger(action, label) {
return runCommandWithRuntime(defaultRuntime, action, (err) => {
defaultRuntime.error(danger(`${label}: ${String(err)}`));
defaultRuntime.exit(1);
});
}
function registerChannelsCli(program) {
const channelNames = formatCliChannelOptions();
const channels = program.command("channels").description("Manage connected chat channels and accounts").addHelpText("after", () => `\n${theme.heading("Examples:")}\n${formatHelpExamples([
["openclaw channels list", "List configured channels and auth profiles."],
["openclaw channels status --probe", "Run channel status checks and probes."],
["openclaw channels add --channel telegram --token <token>", "Add or update a channel account non-interactively."],
["openclaw channels login --channel whatsapp", "Link a WhatsApp Web account."]
])}\n\n${theme.muted("Docs:")} ${formatDocsLink("/cli/channels", "docs.openclaw.ai/cli/channels")}\n`);
channels.command("list").description("List configured channels + auth profiles").option("--no-usage", "Skip model provider usage/quota snapshots").option("--json", "Output JSON", false).action(async (opts) => {
await runChannelsCommand(async () => {
const { channelsListCommand } = await import("./channels-DMkwBJzH.js");
await channelsListCommand(opts, defaultRuntime);
});
});
channels.command("status").description("Show gateway channel status (use status --deep for local)").option("--probe", "Probe channel credentials", false).option("--timeout <ms>", "Timeout in ms", "10000").option("--json", "Output JSON", false).action(async (opts) => {
await runChannelsCommand(async () => {
const { channelsStatusCommand } = await import("./channels-DMkwBJzH.js");
await channelsStatusCommand(opts, defaultRuntime);
});
});
channels.command("capabilities").description("Show provider capabilities (intents/scopes + supported features)").option("--channel <name>", `Channel (${formatCliChannelOptions(["all"])})`).option("--account <id>", "Account id (only with --channel)").option("--target <dest>", "Channel target for permission audit (Discord channel:<id>)").option("--timeout <ms>", "Timeout in ms", "10000").option("--json", "Output JSON", false).action(async (opts) => {
await runChannelsCommand(async () => {
const { channelsCapabilitiesCommand } = await import("./channels-DMkwBJzH.js");
await channelsCapabilitiesCommand(opts, defaultRuntime);
});
});
channels.command("resolve").description("Resolve channel/user names to IDs").argument("<entries...>", "Entries to resolve (names or ids)").option("--channel <name>", `Channel (${channelNames})`).option("--account <id>", "Account id (accountId)").option("--kind <kind>", "Target kind (auto|user|group)", "auto").option("--json", "Output JSON", false).action(async (entries, opts) => {
await runChannelsCommand(async () => {
const { channelsResolveCommand } = await import("./channels-DMkwBJzH.js");
await channelsResolveCommand({
channel: opts.channel,
account: opts.account,
kind: opts.kind,
json: Boolean(opts.json),
entries: Array.isArray(entries) ? entries : [String(entries)]
}, defaultRuntime);
});
});
channels.command("logs").description("Show recent channel logs from the gateway log file").option("--channel <name>", `Channel (${formatCliChannelOptions(["all"])})`, "all").option("--lines <n>", "Number of lines (default: 200)", "200").option("--json", "Output JSON", false).action(async (opts) => {
await runChannelsCommand(async () => {
const { channelsLogsCommand } = await import("./channels-DMkwBJzH.js");
await channelsLogsCommand(opts, defaultRuntime);
});
});
channels.command("add").description("Add or update a channel account").option("--channel <name>", `Channel (${channelNames})`).option("--account <id>", "Account id (default when omitted)").option("--name <name>", "Display name for this account").option("--token <token>", "Bot token (Telegram/Discord)").option("--private-key <key>", "Nostr private key (nsec... or hex)").option("--token-file <path>", "Bot token file (Telegram)").option("--bot-token <token>", "Slack bot token (xoxb-...)").option("--app-token <token>", "Slack app token (xapp-...)").option("--signal-number <e164>", "Signal account number (E.164)").option("--cli-path <path>", "CLI path (signal-cli or imsg)").option("--db-path <path>", "iMessage database path").option("--service <service>", "iMessage service (imessage|sms|auto)").option("--region <region>", "iMessage region (for SMS)").option("--auth-dir <path>", "WhatsApp auth directory override").option("--http-url <url>", "Signal HTTP daemon base URL").option("--http-host <host>", "Signal HTTP host").option("--http-port <port>", "Signal HTTP port").option("--webhook-path <path>", "Webhook path (Google Chat/BlueBubbles)").option("--webhook-url <url>", "Google Chat webhook URL").option("--audience-type <type>", "Google Chat audience type (app-url|project-number)").option("--audience <value>", "Google Chat audience value (app URL or project number)").option("--homeserver <url>", "Matrix homeserver URL").option("--user-id <id>", "Matrix user ID").option("--access-token <token>", "Matrix access token").option("--password <password>", "Matrix password").option("--device-name <name>", "Matrix device name").option("--initial-sync-limit <n>", "Matrix initial sync limit").option("--ship <ship>", "Tlon ship name (~sampel-palnet)").option("--url <url>", "Tlon ship URL").option("--relay-urls <list>", "Nostr relay URLs (comma-separated)").option("--code <code>", "Tlon login code").option("--group-channels <list>", "Tlon group channels (comma-separated)").option("--dm-allowlist <list>", "Tlon DM allowlist (comma-separated ships)").option("--auto-discover-channels", "Tlon auto-discover group channels").option("--no-auto-discover-channels", "Disable Tlon auto-discovery").option("--use-env", "Use env token (default account only)", false).action(async (opts, command) => {
await runChannelsCommand(async () => {
const { channelsAddCommand } = await import("./channels-DMkwBJzH.js");
await channelsAddCommand(opts, defaultRuntime, { hasFlags: hasExplicitOptions(command, optionNamesAdd) });
});
});
channels.command("remove").description("Disable or delete a channel account").option("--channel <name>", `Channel (${channelNames})`).option("--account <id>", "Account id (default when omitted)").option("--delete", "Delete config entries (no prompt)", false).action(async (opts, command) => {
await runChannelsCommand(async () => {
const { channelsRemoveCommand } = await import("./channels-DMkwBJzH.js");
await channelsRemoveCommand(opts, defaultRuntime, { hasFlags: hasExplicitOptions(command, optionNamesRemove) });
});
});
channels.command("login").description("Link a channel account (if supported)").option("--channel <channel>", "Channel alias (auto when only one is configured)").option("--account <id>", "Account id (accountId)").option("--verbose", "Verbose connection logs", false).action(async (opts) => {
await runChannelsCommandWithDanger(async () => {
await runChannelLogin({
channel: opts.channel,
account: opts.account,
verbose: Boolean(opts.verbose)
}, defaultRuntime);
}, "Channel login failed");
});
channels.command("logout").description("Log out of a channel session (if supported)").option("--channel <channel>", "Channel alias (auto when only one is configured)").option("--account <id>", "Account id (accountId)").action(async (opts) => {
await runChannelsCommandWithDanger(async () => {
await runChannelLogout({
channel: opts.channel,
account: opts.account
}, defaultRuntime);
}, "Channel logout failed");
});
}
//#endregion
export { registerChannelsCli };