openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
397 lines (396 loc) • 10.1 kB
JavaScript
import { a as getCommandArgsWithRootOptions, t as FLAG_TERMINATOR } from "./cli-root-options-xlQx6o4R.mjs";
import { N as removeCommandByName, h as normalizeRootLogLevelArgv, n as getCommandPathWithRootOptions } from "./argv-CbnKpH-r.mjs";
import { t as formatDocsHelp } from "./help-format-D2ytHW5E.mjs";
import { a as providerSummaryText, n as runCapabilityCommand } from "./providers-command-D9EdIVJQ.mjs";
//#region src/cli/capability-cli/metadata.ts
const IMAGE_GENERATION_FLAGS = [
"--prompt",
"--model",
"--count",
"--size",
"--aspect-ratio",
"--resolution",
"--output-format",
"--background",
"--openai-background",
"--openai-moderation",
"--quality",
"--timeout-ms",
"--output",
"--agent",
"--json"
];
const CAPABILITY_METADATA = [
{
id: "model.run",
description: "Run a one-shot inference turn through the selected model provider.",
transports: ["local", "gateway"],
flags: [
"--prompt",
"--file",
"--model",
"--thinking",
"--local",
"--gateway",
"--agent",
"--json"
],
resultShape: "normalized payloads plus provider/model attribution"
},
{
id: "model.list",
description: "List known models from the model catalog.",
transports: ["local"],
flags: ["--json"],
resultShape: "catalog entries"
},
{
id: "model.inspect",
description: "Inspect one model catalog entry.",
transports: ["local"],
flags: ["--model", "--json"],
resultShape: "single catalog entry"
},
{
id: "model.providers",
description: "List model providers discovered from the catalog.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids with counts and defaults"
},
{
id: "model.auth.login",
description: "Run the existing provider auth login flow.",
transports: ["local"],
flags: [
"--provider",
"--method",
"--agent"
],
resultShape: "interactive auth result"
},
{
id: "model.auth.logout",
description: "Remove saved auth profiles for one provider.",
transports: ["local"],
flags: [
"--provider",
"--agent",
"--json"
],
resultShape: "removed profile ids"
},
{
id: "model.auth.status",
description: "Show configured model auth state.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "model status summary"
},
{
id: "image.generate",
description: "Generate raster images with configured image providers.",
transports: ["local"],
flags: [...IMAGE_GENERATION_FLAGS],
resultShape: "saved image files plus attempts"
},
{
id: "image.edit",
description: "Generate edited images from one or more input files.",
transports: ["local"],
flags: ["--file", ...IMAGE_GENERATION_FLAGS],
resultShape: "saved image files plus attempts"
},
{
id: "image.describe",
description: "Describe one image file through media-understanding providers.",
transports: ["local"],
flags: [
"--file",
"--prompt",
"--model",
"--timeout-ms",
"--agent",
"--json"
],
resultShape: "normalized text output"
},
{
id: "image.describe-many",
description: "Describe multiple image files independently.",
transports: ["local"],
flags: [
"--file",
"--prompt",
"--model",
"--timeout-ms",
"--agent",
"--json"
],
resultShape: "one text output per file"
},
{
id: "image.providers",
description: "List image generation providers.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids and defaults"
},
{
id: "audio.transcribe",
description: "Transcribe one audio file.",
transports: ["local"],
flags: [
"--file",
"--agent",
"--language",
"--prompt",
"--model",
"--json"
],
resultShape: "normalized text output"
},
{
id: "audio.providers",
description: "List audio transcription providers.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids and capabilities"
},
{
id: "tts.convert",
description: "Convert text to speech.",
transports: ["local", "gateway"],
flags: [
"--text",
"--channel",
"--voice",
"--provider",
"--model",
"--output",
"--local",
"--gateway",
"--json"
],
resultShape: "saved audio file plus attempts"
},
{
id: "tts.voices",
description: "List voices for a speech provider.",
transports: ["local"],
flags: ["--provider", "--json"],
resultShape: "voice entries"
},
{
id: "tts.providers",
description: "List speech providers.",
transports: ["local", "gateway"],
flags: [
"--agent",
"--local",
"--gateway",
"--json"
],
resultShape: "provider ids, configured state, models, voices"
},
{
id: "tts.personas",
description: "List TTS personas.",
transports: ["local", "gateway"],
flags: [
"--local",
"--gateway",
"--json"
],
resultShape: "persona ids, labels, providers, active persona"
},
{
id: "tts.status",
description: "Show gateway-managed TTS state.",
transports: ["gateway"],
flags: ["--gateway", "--json"],
resultShape: "enabled/provider state"
},
{
id: "tts.enable",
description: "Enable TTS in prefs.",
transports: ["local", "gateway"],
flags: [
"--local",
"--gateway",
"--json"
],
resultShape: "enabled state"
},
{
id: "tts.disable",
description: "Disable TTS in prefs.",
transports: ["local", "gateway"],
flags: [
"--local",
"--gateway",
"--json"
],
resultShape: "enabled state"
},
{
id: "tts.set-provider",
description: "Set the active TTS provider.",
transports: ["local", "gateway"],
flags: [
"--provider",
"--local",
"--gateway",
"--json"
],
resultShape: "selected provider"
},
{
id: "tts.set-persona",
description: "Set the active TTS persona.",
transports: ["local", "gateway"],
flags: [
"--persona",
"--off",
"--local",
"--gateway",
"--json"
],
resultShape: "selected persona"
},
{
id: "video.generate",
description: "Generate video files with configured video providers.",
transports: ["local"],
flags: [
"--prompt",
"--model",
"--size",
"--aspect-ratio",
"--resolution",
"--duration",
"--audio",
"--watermark",
"--timeout-ms",
"--output",
"--agent",
"--json"
],
resultShape: "saved video files plus attempts"
},
{
id: "video.describe",
description: "Describe one video file through media-understanding providers.",
transports: ["local"],
flags: [
"--file",
"--agent",
"--model",
"--json"
],
resultShape: "normalized text output"
},
{
id: "video.providers",
description: "List video generation and description providers.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids and defaults"
},
{
id: "web.search",
description: "Run provider-backed web search.",
transports: ["local"],
flags: [
"--query",
"--provider",
"--limit",
"--json"
],
resultShape: "search provider result"
},
{
id: "web.fetch",
description: "Fetch URL content directly or through a selected web fetch provider.",
transports: ["local"],
flags: [
"--url",
"--provider",
"--format",
"--json"
],
resultShape: "page content with fetch metadata"
},
{
id: "web.providers",
description: "List web search and fetch providers.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids grouped by family"
},
{
id: "embedding.create",
description: "Create embeddings through embedding providers.",
transports: ["local"],
flags: [
"--text",
"--provider",
"--model",
"--agent",
"--json"
],
resultShape: "vectors with provider/model attribution"
},
{
id: "embedding.providers",
description: "List embedding providers.",
transports: ["local"],
flags: ["--agent", "--json"],
resultShape: "provider ids and default models"
}
];
//#endregion
//#region src/cli/capability-cli.ts
const capabilityCommandGroups = [
["model", async () => (await import("./model-Ddu2Cb8O.mjs")).registerModelCapabilityCommands],
["image", async () => (await import("./image-DvIuHiPJ.mjs")).registerImageCapabilityCommands],
["audio", async () => (await import("./audio-D130Q3hN.mjs")).registerAudioCapabilityCommands],
["tts", async () => (await import("./tts-Cy-kNOSb.mjs")).registerTtsCapabilityCommands],
["video", async () => (await import("./video-D5uHWM8B.mjs")).registerVideoCapabilityCommands],
["web", async () => (await import("./web-BwmNzT25.mjs")).registerWebCapabilityCommands],
["embedding", async () => (await import("./embedding-DDanpToF.mjs")).registerEmbeddingCapabilityCommands]
];
async function registerCapabilityCli(e, t = process.argv) {
removeCommandByName(e, "infer");
removeCommandByName(e, "capability");
const n = e.command("infer").alias("capability").description("Run provider-backed inference commands through a stable CLI surface").addHelpText("after", () => formatDocsHelp("/cli/infer"));
n.command("list").description("List capability IDs and supported transports").option("--json", "Output JSON", false).action((e) => runCapabilityCommand(e.json, providerSummaryText, () => CAPABILITY_METADATA.map((e) => ({
id: e.id,
transports: e.transports,
description: e.description
}))));
n.command("inspect").description("Inspect one capability ID").requiredOption("--name <capability>", "Capability id").option("--json", "Output JSON", false).action((e) => runCapabilityCommand(e.json, void 0, () => {
const t = String(e.name);
const n = CAPABILITY_METADATA.find((e) => e.id === t);
if (!n) throw new Error(`Unknown capability: ${String(e.name)}`);
return n;
}));
const r = normalizeRootLogLevelArgv(t);
const i = getCommandPathWithRootOptions(r, 2);
const a = i[0];
const o = a === "infer" || a === "capability" ? getCommandArgsWithRootOptions(r, {
commandPath: [a],
mode: "command-path"
}) : void 0;
const s = o?.[0] === "--" ? i[1] : o?.[0];
if (s === "list" || s === "inspect") return;
const c = capabilityCommandGroups.find(([e]) => e === s);
if (c) {
(await c[1]())(n);
return;
}
const l = await Promise.all(capabilityCommandGroups.map(([, e]) => e()));
for (const e of l) e(n);
}
//#endregion
export { registerCapabilityCli };