@gguf/claw
Version:
WhatsApp gateway CLI (Baileys web) with Pi RPC agent
191 lines (186 loc) • 8.14 kB
JavaScript
import { C as setVerbose, O as isRich, k as theme, n as isTruthyEnvValue, p as defaultRuntime } from "./entry.js";
import "./auth-profiles-CYBuGiBb.js";
import { n as replaceCliName, r as resolveCliName } from "./command-format-ayFsmwwz.js";
import "./utils-DX85MiPR.js";
import "./exec-B8JKbXKW.js";
import "./agent-scope-C9VjJXEK.js";
import "./github-copilot-token-SLWintYd.js";
import "./pi-model-discovery-DzEIEgHL.js";
import { j as VERSION } from "./config-CKLedg5Y.js";
import "./manifest-registry-C69Z-I4v.js";
import "./server-context-yKyxyxOJ.js";
import "./errors-CZ9opC6L.js";
import "./control-service-D2E9NKqQ.js";
import "./tailscale-9MusRvOi.js";
import "./auth-DksjO6WG.js";
import "./client-CxbkcEZ7.js";
import "./call-90HgQQ8o.js";
import "./message-channel-BlgPSDAh.js";
import { t as formatDocsLink } from "./links-D0uzJbi6.js";
import "./plugin-auto-enable-DyW8lHTT.js";
import "./plugins-BUPpq5aS.js";
import "./logging-CfEk_PnX.js";
import "./accounts-Dto4p9zB.js";
import "./loader-_Pj-TZS2.js";
import "./progress-Da1ehW-x.js";
import "./prompt-style-Dc0C5HC9.js";
import "./note-Ci08TSbV.js";
import "./clack-prompter-DuBVnTKy.js";
import "./onboard-channels-D-ZQTy5V.js";
import "./archive-D0z3LZDK.js";
import "./skill-scanner-Bp1D9gra.js";
import "./installs-DsJkyWfL.js";
import "./manager-BXiIQku7.js";
import "./paths-CTg8F3AE.js";
import "./sqlite-DqUEZnjO.js";
import "./routes-BSfXf8a5.js";
import "./pi-embedded-helpers-DF8SAHU-.js";
import "./deliver-Cau4HL7W.js";
import "./sandbox-DuqLKN5J.js";
import "./channel-summary-D9nzC5WB.js";
import "./wsl-ATjkMwMA.js";
import "./skills-CmU0Q92f.js";
import "./image-nRwqkmtf.js";
import "./redact-B8YiFlwn.js";
import "./tool-display-DmgKs6-V.js";
import "./channel-selection-PZuuCvrp.js";
import "./session-cost-usage-BTXosU1k.js";
import "./commands-DAC7XMAT.js";
import "./pairing-store-DTfv_FGA.js";
import "./login-qr-Cmsf7BGt.js";
import "./pairing-labels-BbydDT7w.js";
import "./channels-status-issues-CJ8PJgDc.js";
import { n as ensurePluginRegistryLoaded } from "./command-options-DUUINcz0.js";
import { n as resolveCliChannelOptions } from "./channel-options-DrUmtdd9.js";
import { a as getCommandPath, d as hasHelpOrVersion, l as getVerboseFlag } from "./register.subclis-BpIR6Iqi.js";
import "./completion-cli-BbhA_JbG.js";
import "./gateway-rpc-CWnTaSEY.js";
import "./deps-ytXmI88x.js";
import "./daemon-runtime-BCn_QIHK.js";
import "./service-_JwSmGSn.js";
import "./systemd-8sIc6isV.js";
import "./service-audit-DDX1kO3k.js";
import "./table-CJSx0YID.js";
import "./widearea-dns-CsSylzXH.js";
import "./audit-BWbjQmyv.js";
import "./onboard-skills-YobctE-R.js";
import "./health-format-ND2rUbQO.js";
import "./update-runner-2i8_mIG5.js";
import "./github-copilot-auth-B_lK1g__.js";
import "./logging-Cc7m6PTv.js";
import "./hooks-status-CKmUPU-M.js";
import "./status-BRXuHUsK.js";
import "./skills-status-DtXrj3fy.js";
import "./tui-DPorsF4z.js";
import "./agent-DztWhVCH.js";
import "./node-service-Lc1LlnFH.js";
import { t as forceFreePort } from "./ports-0V-Mu4ch.js";
import "./auth-health-C4bElkgf.js";
import { i as hasEmittedCliBanner, n as emitCliBanner, o as registerProgramCommands, r as formatCliBannerLine, t as ensureConfigReady } from "./config-guard-a5ynrKd-.js";
import "./help-format-CfZ94KRN.js";
import "./configure-ChnTy7Jz.js";
import "./systemd-linger-SsSOsJST.js";
import "./doctor-JnMryC_M.js";
import { Command } from "commander";
//#region src/cli/program/context.ts
function createProgramContext() {
const channelOptions = resolveCliChannelOptions();
return {
programVersion: VERSION,
channelOptions,
messageChannelOptions: channelOptions.join("|"),
agentChannelOptions: ["last", ...channelOptions].join("|")
};
}
//#endregion
//#region src/cli/program/help.ts
const CLI_NAME = resolveCliName();
const EXAMPLES = [
["openclaw channels login --verbose", "Link personal WhatsApp Web and show QR + connection logs."],
["openclaw message send --target +15555550123 --message \"Hi\" --json", "Send via your web session and print JSON result."],
["openclaw gateway --port 18789", "Run the WebSocket Gateway locally."],
["openclaw --dev gateway", "Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001."],
["openclaw gateway --force", "Kill anything bound to the default gateway port, then start it."],
["openclaw gateway ...", "Gateway control via WebSocket."],
["openclaw agent --to +15555550123 --message \"Run summary\" --deliver", "Talk directly to the agent using the Gateway; optionally send the WhatsApp reply."],
["openclaw message send --channel telegram --target @mychat --message \"Hi\"", "Send via your Telegram bot."]
];
function configureProgramHelp(program, ctx) {
program.name(CLI_NAME).description("").version(ctx.programVersion).option("--dev", "Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)").option("--profile <name>", "Use a named profile (isolates OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH under ~/.openclaw-<name>)");
program.option("--no-color", "Disable ANSI colors", false);
program.configureHelp({
sortSubcommands: true,
sortOptions: true,
optionTerm: (option) => theme.option(option.flags),
subcommandTerm: (cmd) => theme.command(cmd.name())
});
program.configureOutput({
writeOut: (str) => {
const colored = str.replace(/^Usage:/gm, theme.heading("Usage:")).replace(/^Options:/gm, theme.heading("Options:")).replace(/^Commands:/gm, theme.heading("Commands:"));
process.stdout.write(colored);
},
writeErr: (str) => process.stderr.write(str),
outputError: (str, write) => write(theme.error(str))
});
if (process.argv.includes("-V") || process.argv.includes("--version") || process.argv.includes("-v")) {
console.log(ctx.programVersion);
process.exit(0);
}
program.addHelpText("beforeAll", () => {
if (hasEmittedCliBanner()) return "";
const rich = isRich();
return `\n${formatCliBannerLine(ctx.programVersion, { richTty: rich })}\n`;
});
const fmtExamples = EXAMPLES.map(([cmd, desc]) => ` ${theme.command(replaceCliName(cmd, CLI_NAME))}\n ${theme.muted(desc)}`).join("\n");
program.addHelpText("afterAll", ({ command }) => {
if (command !== program) return "";
const docs = formatDocsLink("/cli", "docs.openclaw.ai/cli");
return `\n${theme.heading("Examples:")}\n${fmtExamples}\n\n${theme.muted("Docs:")} ${docs}\n`;
});
}
//#endregion
//#region src/cli/program/preaction.ts
function setProcessTitleForCommand(actionCommand) {
let current = actionCommand;
while (current.parent && current.parent.parent) current = current.parent;
const name = current.name();
const cliName = resolveCliName();
if (!name || name === cliName) return;
process.title = `${cliName}-${name}`;
}
const PLUGIN_REQUIRED_COMMANDS = new Set([
"message",
"channels",
"directory"
]);
function registerPreActionHooks(program, programVersion) {
program.hook("preAction", async (_thisCommand, actionCommand) => {
setProcessTitleForCommand(actionCommand);
const argv = process.argv;
if (hasHelpOrVersion(argv)) return;
const commandPath = getCommandPath(argv, 2);
if (!(isTruthyEnvValue(process.env.OPENCLAW_HIDE_BANNER) || commandPath[0] === "update" || commandPath[0] === "completion" || commandPath[0] === "plugins" && commandPath[1] === "update")) emitCliBanner(programVersion);
const verbose = getVerboseFlag(argv, { includeDebug: true });
setVerbose(verbose);
if (!verbose) process.env.NODE_NO_WARNINGS ??= "1";
if (commandPath[0] === "doctor" || commandPath[0] === "completion") return;
await ensureConfigReady({
runtime: defaultRuntime,
commandPath
});
if (PLUGIN_REQUIRED_COMMANDS.has(commandPath[0])) ensurePluginRegistryLoaded();
});
}
//#endregion
//#region src/cli/program/build-program.ts
function buildProgram() {
const program = new Command();
const ctx = createProgramContext();
const argv = process.argv;
configureProgramHelp(program, ctx);
registerPreActionHooks(program, ctx.programVersion);
registerProgramCommands(program, ctx, argv);
return program;
}
//#endregion
export { buildProgram };