UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

129 lines (128 loc) • 8.89 kB
import { Q as removeCommandByName, b as loadPrivateQaCliModule, v as getSubCliEntriesCore } from "./argv-DOP3xhLd.mjs"; import { t as resolveCliArgvInvocation } from "./argv-invocation-Ck9B-0kW.mjs"; import { t as createLazyImportLoader } from "./lazy-promise-DGqyc4Y4.mjs"; import { n as shouldEagerRegisterSubcommands } from "./command-registration-policy-S0kaIQsG.mjs"; import { t as resolveCliCommandPathPolicy } from "./command-path-policy-egtY21gZ.mjs"; import { i as registerCommandGroups, r as registerCommandGroupByName, t as findCommandGroupEntry } from "./register-command-groups-CxTS3a53.mjs"; import { t as buildCommandGroupEntries } from "./command-group-descriptors-DsGlvOmH.mjs"; //#region src/cli/program/register.subclis.ts const pluginCliLoader = createLazyImportLoader(() => import("./cli-9oYhhuq7.mjs")); function shouldRegisterGatewayRunOnly(name, argv) { if (name !== "gateway") return false; const invocation = resolveCliArgvInvocation(argv); if (invocation.hasHelpOrVersion || invocation.commandPath[0] !== "gateway") return false; return invocation.commandPath.length === 1 || invocation.commandPath[1] === "run"; } async function registerGatewayRunOnly(program) { const { addGatewayRunCommand } = await import("./run-command-Bqd7BPAh.mjs"); removeCommandByName(program, "gateway"); addGatewayRunCommand(addGatewayRunCommand(program.command("gateway").description("Run, inspect, and query the WebSocket Gateway")).command("run").description("Run the WebSocket Gateway (foreground)")); } async function registerSubCliWithPluginCommands(program, argv, registerSubCli, pluginCliPosition) { const invocation = resolveCliArgvInvocation(argv); const shouldRegisterPluginCommands = !invocation.hasHelpOrVersion && resolveCliCommandPathPolicy(invocation.commandPath).loadPlugins !== "never"; if (pluginCliPosition === "before" && shouldRegisterPluginCommands) { const { registerPluginCliCommandsFromValidatedConfig } = await pluginCliLoader.load(); await registerPluginCliCommandsFromValidatedConfig(program); } await registerSubCli(); if (pluginCliPosition === "after" && shouldRegisterPluginCommands) { const { registerPluginCliCommandsFromValidatedConfig } = await pluginCliLoader.load(); await registerPluginCliCommandsFromValidatedConfig(program); } } const entrySpecs = [ [["acp"], async (program) => (await import("./acp-cli-DmWpUsr7.mjs")).registerAcpCli(program)], [["gateway"], async (program) => (await import("./gateway-cli-DIaxn1an.mjs")).registerGatewayCli(program)], [["daemon"], async (program) => (await import("./cli/daemon-cli.js")).registerDaemonCli(program)], [["logs"], async (program) => (await import("./logs-cli-DxDvnG48.mjs")).registerLogsCli(program)], [["system"], async (program) => (await import("./system-cli-Cq47EDjr.mjs")).registerSystemCli(program)], [["models"], async (program) => (await import("./models-cli-GpWEx_P6.mjs")).registerModelsCli(program)], [["promos"], async (program) => (await import("./promos-cli-DTp4pIxG.mjs")).registerPromosCli(program)], [["telemetry"], async (program) => (await import("./telemetry-cli-DbotBZGu.mjs")).registerTelemetryCli(program)], [["infer", "capability"], async (program, argv) => (await import("./capability-cli-C5-lqU1c.mjs")).registerCapabilityCli(program, argv)], [["approvals", "exec-approvals"], async (program) => (await import("./exec-approvals-cli-EGjmyCc4.mjs")).registerExecApprovalsCli(program)], [["exec-policy"], async (program) => (await import("./exec-policy-cli-oDv7K0tZ.mjs")).registerExecPolicyCli(program)], [["nodes"], async (program, argv) => (await import("./nodes-cli-CY0hzIOb.mjs")).registerNodesCli(program, argv)], [["devices"], async (program) => (await import("./devices-cli-SdmI3iQb.mjs")).registerDevicesCli(program)], [["users"], async (program) => (await import("./users-cli-DLF1nOpU.mjs")).registerUsersCli(program)], [["node"], async (program) => (await import("./node-cli-Cnl5ZkIk.mjs")).registerNodeCli(program)], [["connect"], async (program) => (await import("./connect-cli-DXs3vdqJ.mjs")).registerConnectCli(program)], [["worker"], async (program) => (await import("./worker-cli-BWeJmGUU.mjs")).registerWorkerCli(program)], [["sandbox"], async (program) => (await import("./sandbox-cli-DieFF4uR.mjs")).registerSandboxCli(program)], [["fleet"], async (program) => (await import("./fleet-cli-Dsjk6Ebc.mjs")).registerFleetCli(program)], [["worktrees"], async (program) => (await import("./worktrees-cli-Rr7KrtrD.mjs")).registerWorktreesCli(program)], [["attach"], async (program) => (await import("./attach-cli-PbAbUonN.mjs")).registerAttachCli(program)], [[ "tui", "terminal", "chat" ], async (program) => (await import("./tui-cli-DR8S6WZT.mjs")).registerTuiCli(program)], [["resume"], async (program) => (await import("./resume-cli-B5C1vO-d.mjs")).registerResumeCli(program)], [["cron", "automations"], async (program) => (await import("./cron-cli-BnRuCFwM.mjs")).registerCronCli(program)], [["dns"], async (program) => (await import("./dns-cli-B4QfKAxn.mjs")).registerDnsCli(program)], [["docs"], async (program) => (await import("./docs-cli-BqN7hbkK.mjs")).registerDocsCli(program)], [["qa"], async (program) => { const { registerQaLabCli } = await loadPrivateQaCliModule(); if (typeof registerQaLabCli !== "function") throw new Error("Missing program command registrar: registerQaLabCli"); await registerQaLabCli(program); }], [["proxy"], async (program) => (await import("./proxy-cli-Coq8JiKW.mjs")).registerProxyCli(program)], [["hooks"], async (program) => (await import("./hooks-cli-C4NrAEBY.mjs")).registerHooksCli(program)], [["webhooks"], async (program) => (await import("./webhooks-cli-C-9IQHGw.mjs")).registerWebhooksCli(program)], [["qr"], async (program) => (await import("./qr-cli-2HZyj9eH.mjs")).registerQrCli(program)], [["clawbot"], async (program) => (await import("./clawbot-cli-BMEF76uJ.mjs")).registerClawbotCli(program)], [["pairing"], async (program, argv) => { await registerSubCliWithPluginCommands(program, argv, async () => (await import("./pairing-cli-KNllj6Pt.mjs")).registerPairingCli(program), "before"); }], [["plugins"], async (program, argv) => { await registerSubCliWithPluginCommands(program, argv, async () => (await import("./plugins-cli-DlA2emQ7.mjs")).registerPluginsCli(program), "after"); }], [["channels"], async (program, argv, context) => (await import("./channels-cli-B5rLZDDt.mjs")).registerChannelsCli(program, argv, { includeSetupOptions: context.purpose === "completion" })], [["directory"], async (program) => (await import("./directory-cli-CtSDfLDy.mjs")).registerDirectoryCli(program)], [["security"], async (program) => (await import("./security-cli-DRmkFxju.mjs")).registerSecurityCli(program)], [["secrets"], async (program) => (await import("./secrets-cli-CjiSWJbl.mjs")).registerSecretsCli(program)], [["skills"], async (program) => (await import("./skills-cli-hAaeAAA2.mjs")).registerSkillsCli(program)], [["update"], async (program) => (await import("./update-cli-B6EP2WvV.mjs")).registerUpdateCli(program)], [["completion"], async (program) => (await import("./completion-cli-DTWAKXqc.mjs")).registerCompletionCli(program)] ]; function resolveSubCliCommandGroups(argv, context = {}) { const descriptors = getSubCliEntriesCore(); const descriptorNames = new Set(descriptors.map((descriptor) => descriptor.name)); return buildCommandGroupEntries(descriptors, entrySpecs.filter(([commandNames]) => commandNames.every((name) => descriptorNames.has(name))), argv, context); } function getSubCliCompletionGroups(argv = process.argv) { const entries = resolveSubCliCommandGroups(argv, { purpose: "completion" }); const groups = []; let previous; for (const { name } of getSubCliEntriesCore()) { const entry = name === "completion" ? void 0 : findCommandGroupEntry(entries, name); if (entry && entry !== previous) groups.push({ name, entry }); previous = entry; } return groups; } async function registerSubCliByName(program, name, argv = process.argv, context = {}) { if (shouldRegisterGatewayRunOnly(name, argv)) { await registerGatewayRunOnly(program); return true; } return registerCommandGroupByName(program, resolveSubCliCommandGroups(argv, context), name); } function registerSubCliCommands(program, argv = process.argv) { const { primary } = resolveCliArgvInvocation(argv); const entries = resolveSubCliCommandGroups(argv); const completion = findCommandGroupEntry(entries, "completion"); const options = { eager: shouldEagerRegisterSubcommands(), primary, registerPrimaryOnly: true }; registerCommandGroups(program, entries.filter((entry) => entry !== completion), options); if (completion) registerCommandGroups(program, [completion], options); } //#endregion export { registerSubCliByName as n, registerSubCliCommands as r, getSubCliCompletionGroups as t };