Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
feat(cli): fase 9.3 — codegen de comandos a partir do OpenAPI spec (omniroute api <tag> <op>)
diegosouzapwcd62899f3117
diff --git a/bin/cli/api-commands/api-keys.mjs b/bin/cli/api-commands/api-keys.mjsnew file mode 100644index 0000000000..3ac9e570af--- /dev/null+++ b/bin/cli/api-commands/api-keys.mjs@@ -0,0 +1,58 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_api_keys(parent) {+ const tag = parent.command("api-keys").description("API Keys endpoints");+ tag+ .command("get-api-keys")+ .description("List API keys")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/keys";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-keys")+ .description("Create API key")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/keys";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-keys-id-")+ .description("Delete API key")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/keys/{id}";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/audio.mjs b/bin/cli/api-commands/audio.mjsnew file mode 100644index 0000000000..707d9f4e64--- /dev/null+++ b/bin/cli/api-commands/audio.mjs@@ -0,0 +1,52 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_audio(parent) {+ const tag = parent.command("audio").description("Audio endpoints");+ tag+ .command("post-api-v1-audio-speech")+ .description("Generate speech audio")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/audio/speech";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-audio-transcriptions")+ .description("Transcribe audio")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/audio/transcriptions";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/chat.mjs b/bin/cli/api-commands/chat.mjsnew file mode 100644index 0000000000..4912dfa079--- /dev/null+++ b/bin/cli/api-commands/chat.mjs@@ -0,0 +1,76 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_chat(parent) {+ const tag = parent.command("chat").description("Chat endpoints");+ tag+ .command("post-api-v1-chat-completions")+ .description("Create chat completion")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/chat/completions";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-providers-provider-chat-completions")+ .description("Create chat completion (provider-specific)")+ .requiredOption("--provider <provider>", "")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/providers/{provider}/chat/completions";+ url = url.replace("{provider}", encodeURIComponent(opts.provider ?? ""));+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-api-chat")+ .description("Ollama-compatible chat endpoint")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/api/chat";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/cli-tools.mjs b/bin/cli/api-commands/cli-tools.mjsnew file mode 100644index 0000000000..30f68eb0b0--- /dev/null+++ b/bin/cli/api-commands/cli-tools.mjs@@ -0,0 +1,526 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_cli_tools(parent) {+ const tag = parent.command("cli-tools").description("CLI Tools endpoints");+ tag+ .command("get-api-cli-tools-backups")+ .description("List CLI tool backups")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/backups";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-backups")+ .description("Create CLI tool backup")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/backups";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-runtime-tool-id-")+ .description("Get runtime status for a CLI tool")+ .requiredOption("--tool-id <toolId>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/runtime/{toolId}";+ url = url.replace("{toolId}", encodeURIComponent(opts.toolId ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-guide-settings-tool-id-")+ .description("Get guide settings for a tool")+ .requiredOption("--tool-id <toolId>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/guide-settings/{toolId}";+ url = url.replace("{toolId}", encodeURIComponent(opts.toolId ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-antigravity-mitm")+ .description("Get Antigravity MITM proxy settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/antigravity-mitm";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-antigravity-mitm")+ .description("Update Antigravity MITM proxy settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/antigravity-mitm";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-antigravity-mitm")+ .description("Reset Antigravity MITM proxy settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/antigravity-mitm";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-antigravity-mitm-alias")+ .description("Get Antigravity MITM alias configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/antigravity-mitm/alias";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-cli-tools-antigravity-mitm-alias")+ .description("Update Antigravity MITM alias configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/antigravity-mitm/alias";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-claude-settings")+ .description("Get Claude CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/claude-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-claude-settings")+ .description("Apply Claude CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/claude-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-claude-settings")+ .description("Reset Claude CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/claude-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-cline-settings")+ .description("Get Cline CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/cline-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-cline-settings")+ .description("Apply Cline CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/cline-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-cline-settings")+ .description("Reset Cline CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/cline-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-codex-profiles")+ .description("Get Codex profiles")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-profiles";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-codex-profiles")+ .description("Create Codex profile")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-profiles";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-cli-tools-codex-profiles")+ .description("Update Codex profile")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-profiles";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-codex-profiles")+ .description("Delete Codex profile")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-profiles";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-codex-settings")+ .description("Get Codex CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-codex-settings")+ .description("Apply Codex CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-codex-settings")+ .description("Reset Codex CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/codex-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-droid-settings")+ .description("Get Droid CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/droid-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-droid-settings")+ .description("Apply Droid CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/droid-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-droid-settings")+ .description("Reset Droid CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/droid-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-kilo-settings")+ .description("Get Kilo CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/kilo-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-kilo-settings")+ .description("Apply Kilo CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/kilo-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-kilo-settings")+ .description("Reset Kilo CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/kilo-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cli-tools-openclaw-settings")+ .description("Get OpenClaw CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/openclaw-settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cli-tools-openclaw-settings")+ .description("Apply OpenClaw CLI settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/openclaw-settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cli-tools-openclaw-settings")+ .description("Reset OpenClaw CLI settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cli-tools/openclaw-settings";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/cloud.mjs b/bin/cli/api-commands/cloud.mjsnew file mode 100644index 0000000000..d03353a072--- /dev/null+++ b/bin/cli/api-commands/cloud.mjs@@ -0,0 +1,110 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_cloud(parent) {+ const tag = parent.command("cloud").description("Cloud endpoints");+ tag+ .command("post-api-cloud-auth")+ .description("Authenticate with cloud worker")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cloud/auth";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-cloud-credentials-update")+ .description("Update cloud worker credentials")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cloud/credentials/update";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-cloud-model-resolve")+ .description("Resolve model via cloud")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cloud/model/resolve";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cloud-models-alias")+ .description("Get cloud model aliases")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cloud/models/alias";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-cloud-models-alias")+ .description("Update cloud model alias")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cloud/models/alias";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/combos.mjs b/bin/cli/api-commands/combos.mjsnew file mode 100644index 0000000000..57fe07c69e--- /dev/null+++ b/bin/cli/api-commands/combos.mjs@@ -0,0 +1,100 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_combos(parent) {+ const tag = parent.command("combos").description("Combos endpoints");+ tag+ .command("get-api-combos")+ .description("List routing combos")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-combos")+ .description("Create routing combo")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-combos-id-")+ .description("Update combo")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos/{id}";+ const res = await apiFetch(url, {+ method: "PATCH",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-combos-id-")+ .description("Delete combo")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos/{id}";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-combos-metrics")+ .description("Get combo metrics")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos/metrics";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-combos-test")+ .description("Test a combo configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/combos/test";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/compression.mjs b/bin/cli/api-commands/compression.mjsnew file mode 100644index 0000000000..d32ea40578--- /dev/null+++ b/bin/cli/api-commands/compression.mjs@@ -0,0 +1,182 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_compression(parent) {+ const tag = parent.command("compression").description("Compression endpoints");+ tag+ .command("get-api-settings-compression")+ .description("Get global compression settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/compression";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-settings-compression")+ .description("Update global compression settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/compression";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-compression-preview")+ .description("Preview compression for a message payload")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/compression/preview";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-compression-language-packs")+ .description("List Caveman compression language packs")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/compression/language-packs";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-compression-rules")+ .description("List Caveman compression rule metadata")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/compression/rules";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-context-rtk-config")+ .description("Get RTK compression settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/context/rtk/config";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-context-rtk-config")+ .description("Update RTK compression settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/context/rtk/config";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-context-rtk-filters")+ .description("List RTK filters and load diagnostics")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/context/rtk/filters";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-context-rtk-test")+ .description("Run RTK compression preview for text")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/context/rtk/test";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-context-rtk-raw-output-id-")+ .description("Read retained redacted RTK raw output")+ .requiredOption("--id <id>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/context/rtk/raw-output/{id}";+ url = url.replace("{id}", encodeURIComponent(opts.id ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/embeddings.mjs b/bin/cli/api-commands/embeddings.mjsnew file mode 100644index 0000000000..77d75271d2--- /dev/null+++ b/bin/cli/api-commands/embeddings.mjs@@ -0,0 +1,54 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_embeddings(parent) {+ const tag = parent.command("embeddings").description("Embeddings endpoints");+ tag+ .command("post-api-v1-embeddings")+ .description("Create embeddings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/embeddings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-providers-provider-embeddings")+ .description("Create embeddings (provider-specific)")+ .requiredOption("--provider <provider>", "")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/providers/{provider}/embeddings";+ url = url.replace("{provider}", encodeURIComponent(opts.provider ?? ""));+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/fallback.mjs b/bin/cli/api-commands/fallback.mjsnew file mode 100644index 0000000000..0e8824900c--- /dev/null+++ b/bin/cli/api-commands/fallback.mjs@@ -0,0 +1,66 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_fallback(parent) {+ const tag = parent.command("fallback").description("Fallback endpoints");+ tag+ .command("get-api-fallback-chains")+ .description("List fallback chains")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/fallback/chains";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-fallback-chains")+ .description("Create fallback chain")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/fallback/chains";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-fallback-chains")+ .description("Delete fallback chain")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/fallback/chains";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "DELETE",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/images.mjs b/bin/cli/api-commands/images.mjsnew file mode 100644index 0000000000..af14946f57--- /dev/null+++ b/bin/cli/api-commands/images.mjs@@ -0,0 +1,54 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_images(parent) {+ const tag = parent.command("images").description("Images endpoints");+ tag+ .command("post-api-v1-images-generations")+ .description("Generate images")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/images/generations";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-providers-provider-images-generations")+ .description("Generate images (provider-specific)")+ .requiredOption("--provider <provider>", "")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/providers/{provider}/images/generations";+ url = url.replace("{provider}", encodeURIComponent(opts.provider ?? ""));+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/messages.mjs b/bin/cli/api-commands/messages.mjsnew file mode 100644index 0000000000..cee8c4e5de--- /dev/null+++ b/bin/cli/api-commands/messages.mjs@@ -0,0 +1,52 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_messages(parent) {+ const tag = parent.command("messages").description("Messages endpoints");+ tag+ .command("post-api-v1-messages")+ .description("Create message (Anthropic-compatible)")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/messages";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1-messages-count-tokens")+ .description("Count tokens for a message")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/messages/count_tokens";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/models.mjs b/bin/cli/api-commands/models.mjsnew file mode 100644index 0000000000..73946c0e4f--- /dev/null+++ b/bin/cli/api-commands/models.mjs@@ -0,0 +1,129 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_models(parent) {+ const tag = parent.command("models").description("Models endpoints");+ tag+ .command("get-api-v1-models")+ .description("List available models")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-v1-providers-provider-models")+ .description("List models for a specific provider")+ .requiredOption(+ "--provider <provider>",+ "Provider id or alias (for example `openai`, `claude`, `cc`)."+ )+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/providers/{provider}/models";+ url = url.replace("{provider}", encodeURIComponent(opts.provider ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-models")+ .description("List models (management)")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-models-alias")+ .description("Create or update a model alias")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/models/alias";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-models-catalog")+ .description("Get full model catalog")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/models/catalog";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-v1beta-models")+ .description("List models (Gemini format)")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1beta/models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-v1beta-models-path-")+ .description("Gemini generateContent")+ .requiredOption("--path <path>", "")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1beta/models/{path}";+ url = url.replace("{path}", encodeURIComponent(opts.path ?? ""));+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/moderations.mjs b/bin/cli/api-commands/moderations.mjsnew file mode 100644index 0000000000..8bac14117f--- /dev/null+++ b/bin/cli/api-commands/moderations.mjs@@ -0,0 +1,30 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_moderations(parent) {+ const tag = parent.command("moderations").description("Moderations endpoints");+ tag+ .command("post-api-v1-moderations")+ .description("Create moderation")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/moderations";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/oauth.mjs b/bin/cli/api-commands/oauth.mjsnew file mode 100644index 0000000000..6aed0c8099--- /dev/null+++ b/bin/cli/api-commands/oauth.mjs@@ -0,0 +1,162 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_oauth(parent) {+ const tag = parent.command("oauth").description("OAuth endpoints");+ tag+ .command("get-api-oauth-provider-action-")+ .description("OAuth flow handler")+ .requiredOption("--provider <provider>", "")+ .requiredOption("--action <action>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/{provider}/{action}";+ url = url.replace("{provider}", encodeURIComponent(opts.provider ?? ""));+ url = url.replace("{action}", encodeURIComponent(opts.action ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-oauth-cursor-auto-import")+ .description("Auto-import Cursor OAuth credentials")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/cursor/auto-import";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-oauth-cursor-import")+ .description("Get Cursor import status")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/cursor/import";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-oauth-cursor-import")+ .description("Import Cursor OAuth credentials")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/cursor/import";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-oauth-kiro-auto-import")+ .description("Auto-import Kiro OAuth credentials")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/kiro/auto-import";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-oauth-kiro-import")+ .description("Get Kiro import status")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/kiro/import";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-oauth-kiro-import")+ .description("Import Kiro OAuth credentials")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/kiro/import";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-oauth-kiro-social-authorize")+ .description("Initiate Kiro social OAuth authorization")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/kiro/social-authorize";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-oauth-kiro-social-exchange")+ .description("Exchange Kiro social OAuth token")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/oauth/kiro/social-exchange";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/pricing.mjs b/bin/cli/api-commands/pricing.mjsnew file mode 100644index 0000000000..76d59680d0--- /dev/null+++ b/bin/cli/api-commands/pricing.mjs@@ -0,0 +1,64 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_pricing(parent) {+ const tag = parent.command("pricing").description("Pricing endpoints");+ tag+ .command("get-api-pricing")+ .description("Get model pricing")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/pricing";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-pricing")+ .description("Set model pricing")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/pricing";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-pricing-defaults")+ .description("Get default pricing")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/pricing/defaults";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-pricing-models")+ .description("Get pricing per model")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/pricing/models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/provider-nodes.mjs b/bin/cli/api-commands/provider-nodes.mjsnew file mode 100644index 0000000000..d8a96b51f6--- /dev/null+++ b/bin/cli/api-commands/provider-nodes.mjs@@ -0,0 +1,92 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_provider_nodes(parent) {+ const tag = parent.command("provider-nodes").description("Provider Nodes endpoints");+ tag+ .command("get-api-provider-nodes")+ .description("List provider nodes")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-nodes";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-provider-nodes")+ .description("Create provider node")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-nodes";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-provider-nodes-id-")+ .description("Update provider node")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-nodes/{id}";+ const res = await apiFetch(url, {+ method: "PATCH",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-provider-nodes-id-")+ .description("Delete provider node")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-nodes/{id}";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-provider-nodes-validate")+ .description("Validate a provider node")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-nodes/validate";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-provider-models")+ .description("List provider models")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/provider-models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/providers.mjs b/bin/cli/api-commands/providers.mjsnew file mode 100644index 0000000000..79a76e77bd--- /dev/null+++ b/bin/cli/api-commands/providers.mjs@@ -0,0 +1,164 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_providers(parent) {+ const tag = parent.command("providers").description("Providers endpoints");+ tag+ .command("get-api-providers")+ .description("List provider connections")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-providers")+ .description("Create provider connection")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-providers-id-")+ .description("Get provider connection")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/{id}";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-providers-id-")+ .description("Update provider connection")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/{id}";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PATCH",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-providers-id-")+ .description("Delete provider connection")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/{id}";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-providers-id-test")+ .description("Test provider connection")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/{id}/test";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-providers-id-models")+ .description("List models for a provider")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/{id}/models";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-providers-test-batch")+ .description("Test multiple providers at once")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/test-batch";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-providers-validate")+ .description("Validate provider credentials")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/validate";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-providers-client")+ .description("Get client-side provider info")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/providers/client";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/registry.mjs b/bin/cli/api-commands/registry.mjsnew file mode 100644index 0000000000..e214f6cd63--- /dev/null+++ b/bin/cli/api-commands/registry.mjs@@ -0,0 +1,88 @@+// AUTO-GENERATED. Do not edit.+import { register_chat } from "./chat.mjs";+import { register_messages } from "./messages.mjs";+import { register_responses } from "./responses.mjs";+import { register_embeddings } from "./embeddings.mjs";+import { register_images } from "./images.mjs";+import { register_audio } from "./audio.mjs";+import { register_moderations } from "./moderations.mjs";+import { register_rerank } from "./rerank.mjs";+import { register_system } from "./system.mjs";+import { register_models } from "./models.mjs";+import { register_providers } from "./providers.mjs";+import { register_provider_nodes } from "./provider-nodes.mjs";+import { register_api_keys } from "./api-keys.mjs";+import { register_combos } from "./combos.mjs";+import { register_settings } from "./settings.mjs";+import { register_compression } from "./compression.mjs";+import { register_usage } from "./usage.mjs";+import { register_pricing } from "./pricing.mjs";+import { register_translator } from "./translator.mjs";+import { register_cli_tools } from "./cli-tools.mjs";+import { register_oauth } from "./oauth.mjs";+import { register_cloud } from "./cloud.mjs";+import { register_fallback } from "./fallback.mjs";+import { register_telemetry } from "./telemetry.mjs";++export const API_TAGS = [+ "chat",+ "messages",+ "responses",+ "embeddings",+ "images",+ "audio",+ "moderations",+ "rerank",+ "system",+ "models",+ "providers",+ "provider-nodes",+ "api-keys",+ "combos",+ "settings",+ "compression",+ "usage",+ "pricing",+ "translator",+ "cli-tools",+ "oauth",+ "cloud",+ "fallback",+ "telemetry",+];++export function registerApiCommands(program) {+ const api = program+ .command("api")+ .description("Direct REST API access (generated from OpenAPI spec)");+ api+ .command("tags")+ .description("List available API tag groups")+ .action(() => {+ API_TAGS.forEach((t) => console.log(t));+ });+ register_chat(api);+ register_messages(api);+ register_responses(api);+ register_embeddings(api);+ register_images(api);+ register_audio(api);+ register_moderations(api);+ register_rerank(api);+ register_system(api);+ register_models(api);+ register_providers(api);+ register_provider_nodes(api);+ register_api_keys(api);+ register_combos(api);+ register_settings(api);+ register_compression(api);+ register_usage(api);+ register_pricing(api);+ register_translator(api);+ register_cli_tools(api);+ register_oauth(api);+ register_cloud(api);+ register_fallback(api);+ register_telemetry(api);+}diff --git a/bin/cli/api-commands/rerank.mjs b/bin/cli/api-commands/rerank.mjsnew file mode 100644index 0000000000..56c3d69fb3--- /dev/null+++ b/bin/cli/api-commands/rerank.mjs@@ -0,0 +1,30 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_rerank(parent) {+ const tag = parent.command("rerank").description("Rerank endpoints");+ tag+ .command("post-api-v1-rerank")+ .description("Rerank documents")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/rerank";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/responses.mjs b/bin/cli/api-commands/responses.mjsnew file mode 100644index 0000000000..549bbed641--- /dev/null+++ b/bin/cli/api-commands/responses.mjs@@ -0,0 +1,30 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_responses(parent) {+ const tag = parent.command("responses").description("Responses endpoints");+ tag+ .command("post-api-v1-responses")+ .description("Create response (OpenAI Responses API)")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1/responses";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/settings.mjs b/bin/cli/api-commands/settings.mjsnew file mode 100644index 0000000000..31a5437df3--- /dev/null+++ b/bin/cli/api-commands/settings.mjs@@ -0,0 +1,294 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_settings(parent) {+ const tag = parent.command("settings").description("Settings endpoints");+ tag+ .command("get-api-settings")+ .description("Get application settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-settings")+ .description("Update settings")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PATCH",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-payload-rules")+ .description("Get payload rules configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/payload-rules";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-settings-payload-rules")+ .description("Update payload rules configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/payload-rules";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-combo-defaults")+ .description("Get combo default settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/combo-defaults";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-proxy")+ .description("Get proxy settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/proxy";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-settings-proxy")+ .description("Update proxy settings")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/proxy";+ const res = await apiFetch(url, {+ method: "PATCH",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-settings-proxy-test")+ .description("Test proxy connection")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/proxy/test";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-settings-require-login")+ .description("Toggle login requirement")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/require-login";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-ip-filter")+ .description("Get IP filter configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/ip-filter";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-settings-ip-filter")+ .description("Update IP filter configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/ip-filter";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-system-prompt")+ .description("Get system prompt configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/system-prompt";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-settings-system-prompt")+ .description("Update system prompt configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/system-prompt";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-settings-thinking-budget")+ .description("Get thinking budget configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/thinking-budget";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("put-api-settings-thinking-budget")+ .description("Update thinking budget configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/settings/thinking-budget";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PUT",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-rate-limit")+ .description("Get rate limit configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/rate-limit";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-rate-limit")+ .description("Update rate limit configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/rate-limit";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/system.mjs b/bin/cli/api-commands/system.mjsnew file mode 100644index 0000000000..eb15c55f1c--- /dev/null+++ b/bin/cli/api-commands/system.mjs@@ -0,0 +1,466 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_system(parent) {+ const tag = parent.command("system").description("System endpoints");+ tag+ .command("get-api-v1")+ .description("API v1 root endpoint")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/v1";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-tags")+ .description("List Ollama-compatible model tags")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/tags";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-auth-login")+ .description("Authenticate user")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/auth/login";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-auth-logout")+ .description("Log out")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/auth/logout";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-init")+ .description("Initialize application")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/init";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-restart")+ .description("Restart the application")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/restart";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-shutdown")+ .description("Shutdown the application")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/shutdown";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-db-backups")+ .description("List database backups")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/db-backups";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-db-backups")+ .description("Create database backup")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/db-backups";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-storage-health")+ .description("Check storage health")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/storage/health";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-sync-cloud")+ .description("Sync with cloud")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/sync/cloud";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-sync-initialize")+ .description("Initialize cloud sync")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/sync/initialize";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-resilience")+ .description("Get resilience configuration")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/resilience";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("patch-api-resilience")+ .description("Update resilience configuration")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/resilience";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "PATCH",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-resilience-reset")+ .description("Reset circuit breakers")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/resilience/reset";+ const res = await apiFetch(url, {+ method: "POST",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-monitoring-health")+ .description("System health check")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/monitoring/health";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-rate-limits")+ .description("Get per-account rate limit status")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/rate-limits";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-sessions")+ .description("Get active sessions")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/sessions";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cache")+ .description("Get cache statistics")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cache";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cache")+ .description("Clear all caches")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cache";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-cache-stats")+ .description("Get detailed cache statistics")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cache/stats";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-cache-stats")+ .description("Clear cache statistics")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/cache/stats";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-evals")+ .description("List eval suites")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/evals";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-evals")+ .description("Run evaluation")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/evals";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-evals-suite-id-")+ .description("Get eval suite details")+ .requiredOption("--suite-id <suiteId>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/evals/{suiteId}";+ url = url.replace("{suiteId}", encodeURIComponent(opts.suiteId ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-policies")+ .description("List routing policies")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/policies";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-policies")+ .description("Create routing policy")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/policies";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("delete-api-policies")+ .description("Delete routing policy")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/policies";+ const res = await apiFetch(url, {+ method: "DELETE",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-compliance-audit-log")+ .description("Get compliance audit log")+ .option("--limit <limit>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/compliance/audit-log";+ const qs = new URLSearchParams();+ if (opts.limit != null) qs.set("limit", String(opts.limit));+ if (qs.toString()) url += "?" + qs.toString();+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-openapi-spec")+ .description("Get OpenAPI specification catalog")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/openapi/spec";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/telemetry.mjs b/bin/cli/api-commands/telemetry.mjsnew file mode 100644index 0000000000..c8dfa34b24--- /dev/null+++ b/bin/cli/api-commands/telemetry.mjs@@ -0,0 +1,36 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_telemetry(parent) {+ const tag = parent.command("telemetry").description("Telemetry endpoints");+ tag+ .command("get-api-telemetry-summary")+ .description("Get telemetry summary")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/telemetry/summary";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-token-health")+ .description("Get token health status")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/token-health";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/translator.mjs b/bin/cli/api-commands/translator.mjsnew file mode 100644index 0000000000..dae8df965c--- /dev/null+++ b/bin/cli/api-commands/translator.mjs@@ -0,0 +1,88 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_translator(parent) {+ const tag = parent.command("translator").description("Translator endpoints");+ tag+ .command("post-api-translator-detect")+ .description("Detect request format")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/translator/detect";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-translator-translate")+ .description("Translate between formats")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/translator/translate";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-translator-send")+ .description("Send translated request to provider")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/translator/send";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-translator-history")+ .description("Get translation history")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/translator/history";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/api-commands/usage.mjs b/bin/cli/api-commands/usage.mjsnew file mode 100644index 0000000000..a8d3b7ce4c--- /dev/null+++ b/bin/cli/api-commands/usage.mjs@@ -0,0 +1,168 @@+// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.+import { apiFetch } from "../api.mjs";+import { emit } from "../output.mjs";+import { readFileSync } from "node:fs";++export function register_usage(parent) {+ const tag = parent.command("usage").description("Usage endpoints");+ tag+ .command("get-api-usage-analytics")+ .description("Get usage analytics")+ .option("--period <period>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/analytics";+ const qs = new URLSearchParams();+ if (opts.period != null) qs.set("period", String(opts.period));+ if (qs.toString()) url += "?" + qs.toString();+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-call-logs")+ .description("Get call logs")+ .option("--limit <limit>", "")+ .option("--offset <offset>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/call-logs";+ const qs = new URLSearchParams();+ if (opts.limit != null) qs.set("limit", String(opts.limit));+ if (opts.offset != null) qs.set("offset", String(opts.offset));+ if (qs.toString()) url += "?" + qs.toString();+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-call-logs-id-")+ .description("Get a specific call log")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/call-logs/{id}";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-connection-id-")+ .description("Get usage for a specific connection")+ .requiredOption("--connection-id <connectionId>", "")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/{connectionId}";+ url = url.replace("{connectionId}", encodeURIComponent(opts.connectionId ?? ""));+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-history")+ .description("Get usage history")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/history";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-logs")+ .description("Get usage logs")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/logs";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-proxy-logs")+ .description("Get proxy logs")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/proxy-logs";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-request-logs")+ .description("Get request logs")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/request-logs";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("get-api-usage-budget")+ .description("Get usage budget status")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/budget";+ const res = await apiFetch(url, {+ method: "GET",+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+ tag+ .command("post-api-usage-budget")+ .description("Configure usage budget")+ .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")+ .action(async (opts, cmd) => {+ const gOpts = cmd.optsWithGlobals();+ let url = "/api/usage/budget";+ let body;+ if (opts.body) {+ body = opts.body.startsWith("@")+ ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))+ : JSON.parse(opts.body);+ }+ const res = await apiFetch(url, {+ method: "POST",+ body,+ baseUrl: gOpts.baseUrl,+ apiKey: gOpts.apiKey,+ });+ const data = res.ok ? await res.json() : await res.text();+ emit(data, gOpts);+ });+}diff --git a/bin/cli/commands/registry.mjs b/bin/cli/commands/registry.mjsindex de58b97aea..84f95cc5c9 100644--- a/bin/cli/commands/registry.mjs+++ b/bin/cli/commands/registry.mjs@@ -55,6 +55,7 @@ import { registerRuntime } from "./runtime.mjs";import { registerTray } from "./tray.mjs";import { registerAutostart } from "./autostart.mjs";import { registerRepl } from "./repl.mjs";+import { registerApiCommands } from "../api-commands/registry.mjs";export function registerCommands(program) {registerMemory(program);@@ -115,4 +116,5 @@ export function registerCommands(program) {registerTray(program);registerAutostart(program);registerRepl(program);+ registerApiCommands(program);}diff --git a/package.json b/package.jsonindex 2c8cae82ae..9755fef7cd 100644--- a/package.json+++ b/package.json@@ -118,12 +118,13 @@"coverage:report:legacy": "c8 report --output-dir coverage --exclude=open-sse --reporter=text --reporter=text-summary","test:all": "npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e","check": "npm run lint && npm run test",- "prepublishOnly": "npm run build:cli && npm run check:pack-artifact",+ "prepublishOnly": "npm run build:cli-api && npm run build:cli && npm run check:pack-artifact","postinstall": "node scripts/build/postinstall.mjs","uninstall": "node scripts/build/uninstall.mjs","uninstall:full": "node scripts/build/uninstall.mjs --full","prepare": "husky",- "system-info": "node scripts/dev/system-info.mjs"+ "system-info": "node scripts/dev/system-info.mjs",+ "build:cli-api": "node --import tsx/esm scripts/cli/generate-api-commands.mjs"},"dependencies": {"@lobehub/icons": "^5.8.0",diff --git a/scripts/check/check-env-doc-sync.mjs b/scripts/check/check-env-doc-sync.mjsindex 2320e937c9..2ba888b4f4 100644--- a/scripts/check/check-env-doc-sync.mjs+++ b/scripts/check/check-env-doc-sync.mjs@@ -80,6 +80,8 @@ const IGNORE_FROM_CODE = new Set([// X11/Wayland display server vars used by tray heuristic (isTraySupported)."DISPLAY","WAYLAND_DISPLAY",+ // Build-time override for OpenAPI spec path used by generate-api-commands.mjs.+ "OPENAPI_SPEC",// Aliases for documented vars handled via fallback ordering."API_KEY","APP_URL",diff --git a/scripts/cli/generate-api-commands.mjs b/scripts/cli/generate-api-commands.mjsnew file mode 100644index 0000000000..43bd10efad--- /dev/null+++ b/scripts/cli/generate-api-commands.mjs@@ -0,0 +1,179 @@+#!/usr/bin/env node+/**+ * Generates bin/cli/api-commands/<tag>.mjs from the OpenAPI spec.+ * Run: npm run build:cli-api+ */+import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";+import { join, dirname } from "node:path";+import { fileURLToPath } from "node:url";+import yaml from "js-yaml";++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = join(__dirname, "..", "..");+const SPEC_PATH = process.env.OPENAPI_SPEC || join(ROOT, "docs/reference/openapi.yaml");+const OUT_DIR = join(ROOT, "bin/cli/api-commands");++// Operations already covered by hand-crafted commands — skip in generated output.+const IGNORED_OP_IDS = new Set([+ "createChatCompletion",+ "streamChatCompletion",+ "listModels",+ "getModel",+ "createEmbedding",+ "createImage",+ "createImageEdit",+ "createImageVariation",+ "createTranscription",+ "createSpeech",+ "createModeration",+]);++function kebab(s) {+ return s+ .replace(/([A-Z])/g, (m) => "-" + m.toLowerCase())+ .replace(/^-/, "")+ .replace(/_/g, "-")+ .replace(/--+/g, "-");+}++function camelCase(s) {+ return s.replace(/[-_](\w)/g, (_, c) => c.toUpperCase());+}++function escapeStr(s) {+ return String(s || "")+ .replace(/\\/g, "\\\\")+ .replace(/"/g, '\\"')+ .slice(0, 150);+}++if (!existsSync(OUT_DIR)) mkdirSync(OUT_DIR, { recursive: true });++const spec = yaml.load(readFileSync(SPEC_PATH, "utf8"));++/** @type {Record<string, Array<{path: string, method: string, opId: string, op: object}>>} */+const byTag = {};++for (const [path, methods] of Object.entries(spec.paths || {})) {+ for (const [method, op] of Object.entries(methods)) {+ if (["parameters", "summary", "description", "servers"].includes(method)) continue;+ if (typeof op !== "object" || op === null) continue;+ if (IGNORED_OP_IDS.has(op.operationId)) continue;++ const rawTag = op.tags?.[0] || "uncategorized";+ const tag = rawTag+ .toLowerCase()+ .replace(/[^a-z0-9]+/g, "-")+ .replace(/-+/g, "-")+ .replace(/^-|-$/g, "");+ const opId = op.operationId || `${method}-${path.replace(/[^a-z0-9]/gi, "-")}`;++ byTag[tag] = byTag[tag] || [];+ byTag[tag].push({ path, method, opId, op });+ }+}++const generatedTags = [];++for (const [tag, ops] of Object.entries(byTag)) {+ const fnName = `register_${tag.replace(/-/g, "_")}`;+ const lines = [+ `// AUTO-GENERATED from ${SPEC_PATH.replace(ROOT + "/", "")}. Do not edit.`,+ `import { apiFetch } from "../api.mjs";`,+ `import { emit } from "../output.mjs";`,+ `import { readFileSync } from "node:fs";`,+ ``,+ `export function ${fnName}(parent) {`,+ ` const tag = parent.command("${tag}").description("${escapeStr(ops[0]?.op?.tags?.[0] || tag)} endpoints");`,+ ];++ for (const { path, method, opId, op } of ops) {+ const cmdName = kebab(opId);+ const params = op.parameters || [];+ const pathParams = params.filter((p) => p.in === "path");+ const queryParams = params.filter((p) => p.in === "query");+ const hasBody = !!op.requestBody;+ const summary = escapeStr(op.summary || op.description || cmdName);++ lines.push(` tag.command("${cmdName}")`);+ lines.push(` .description("${summary}")`);+ for (const p of pathParams) {+ lines.push(+ ` .requiredOption("--${kebab(p.name)} <${p.name}>", "${escapeStr(p.description)}")`+ );+ }+ for (const p of queryParams) {+ const flag = p.required ? "requiredOption" : "option";+ lines.push(` .${flag}("--${kebab(p.name)} <${p.name}>", "${escapeStr(p.description)}")`);+ }+ if (hasBody) {+ lines.push(` .option("--body <jsonOrPath>", "JSON body or @path/to/file.json")`);+ }+ lines.push(` .action(async (opts, cmd) => {`);+ lines.push(` const gOpts = cmd.optsWithGlobals();`);+ // Build URL with path param substitution+ lines.push(` let url = "${path}";`);+ for (const p of pathParams) {+ lines.push(+ ` url = url.replace("{${p.name}}", encodeURIComponent(opts.${camelCase(kebab(p.name))} ?? ""));`+ );+ }+ // Build query string from query params+ if (queryParams.length > 0) {+ lines.push(` const qs = new URLSearchParams();`);+ for (const p of queryParams) {+ const optName = camelCase(kebab(p.name));+ lines.push(+ ` if (opts.${optName} != null) qs.set("${p.name}", String(opts.${optName}));`+ );+ }+ lines.push(` if (qs.toString()) url += "?" + qs.toString();`);+ }+ // Body handling+ if (hasBody) {+ lines.push(` let body;`);+ lines.push(` if (opts.body) {`);+ lines.push(` body = opts.body.startsWith("@")`);+ lines.push(` ? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))`);+ lines.push(` : JSON.parse(opts.body);`);+ lines.push(` }`);+ }+ const bodyArg = hasBody ? ", body" : "";+ lines.push(+ ` const res = await apiFetch(url, { method: "${method.toUpperCase()}"${hasBody ? ", body" : ""}, baseUrl: gOpts.baseUrl, apiKey: gOpts.apiKey });`+ );+ lines.push(` const data = res.ok ? await res.json() : await res.text();`);+ lines.push(` emit(data, gOpts);`);+ lines.push(` });`);+ }++ lines.push(`}`);++ const content = lines.join("\n") + "\n";+ writeFileSync(join(OUT_DIR, `${tag}.mjs`), content);+ generatedTags.push(tag);+ console.log(`[generate] ${tag}.mjs — ${ops.length} operations`);+}++// Generate registry+const registryLines = [+ `// AUTO-GENERATED. Do not edit.`,+ ...generatedTags.map((t) => `import { register_${t.replace(/-/g, "_")} } from "./${t}.mjs";`),+ ``,+ `export const API_TAGS = ${JSON.stringify(generatedTags)};`,+ ``,+ `export function registerApiCommands(program) {`,+ ` const api = program`,+ ` .command("api")`,+ ` .description("Direct REST API access (generated from OpenAPI spec)");`,+ ` api`,+ ` .command("tags")`,+ ` .description("List available API tag groups")`,+ ` .action(() => { API_TAGS.forEach((t) => console.log(t)); });`,+ ...generatedTags.map((t) => ` register_${t.replace(/-/g, "_")}(api);`),+ `}`,+];++writeFileSync(join(OUT_DIR, "registry.mjs"), registryLines.join("\n") + "\n");+console.log(`[generate] registry.mjs — ${generatedTags.length} tags`);+console.log("[generate] Done.");diff --git a/tests/unit/cli-openapi-codegen.test.ts b/tests/unit/cli-openapi-codegen.test.tsnew file mode 100644index 0000000000..9c3d418639--- /dev/null+++ b/tests/unit/cli-openapi-codegen.test.ts@@ -0,0 +1,92 @@+import test from "node:test";+import assert from "node:assert/strict";+import { existsSync, readFileSync, readdirSync } from "node:fs";+import { join, dirname } from "node:path";+import { fileURLToPath } from "node:url";++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = join(__dirname, "..", "..");+const API_COMMANDS_DIR = join(ROOT, "bin", "cli", "api-commands");+const REGISTRY = join(API_COMMANDS_DIR, "registry.mjs");++test("bin/cli/api-commands/ directory exists", () => {+ assert.ok(existsSync(API_COMMANDS_DIR), "api-commands dir deve existir");+});++test("registry.mjs foi gerado e exporta registerApiCommands e API_TAGS", () => {+ assert.ok(existsSync(REGISTRY), "registry.mjs deve existir");+ const src = readFileSync(REGISTRY, "utf8");+ assert.ok(+ src.includes("export function registerApiCommands"),+ "deve exportar registerApiCommands"+ );+ assert.ok(src.includes("export const API_TAGS"), "deve exportar API_TAGS");+});++test("api-commands/ tem pelo menos 20 tag files gerados", () => {+ const files = readdirSync(API_COMMANDS_DIR).filter(+ (f) => f.endsWith(".mjs") && f !== "registry.mjs"+ );+ assert.ok(files.length >= 20, `esperado >=20 arquivos, encontrado ${files.length}`);+});++test("tags esperadas estão presentes (combos, providers, api-keys, settings)", () => {+ const files = readdirSync(API_COMMANDS_DIR);+ for (const expected of ["combos.mjs", "providers.mjs", "api-keys.mjs", "settings.mjs"]) {+ assert.ok(files.includes(expected), `${expected} deve estar presente`);+ }+});++test("registerApiCommands registra comando 'api' com subcomandos de tags", async () => {+ const { registerApiCommands, API_TAGS } = await import("../../bin/cli/api-commands/registry.mjs");+ const { Command } = await import("commander");+ const prog = new Command().exitOverride();+ registerApiCommands(prog);+ const apiCmd = prog.commands.find((c) => c.name() === "api");+ assert.ok(apiCmd, "comando 'api' deve existir");+ // subcommand 'tags' + all tag groups+ assert.ok(apiCmd.commands.length >= API_TAGS.length, "deve ter subcomandos para todos os tags");+});++test("API_TAGS contém pelo menos 20 entradas", async () => {+ const { API_TAGS } = await import("../../bin/cli/api-commands/registry.mjs");+ assert.ok(Array.isArray(API_TAGS));+ assert.ok(API_TAGS.length >= 20, `esperado >=20 tags, encontrado ${API_TAGS.length}`);+ assert.ok(API_TAGS.includes("combos"), "'combos' deve estar em API_TAGS");+ assert.ok(API_TAGS.includes("providers"), "'providers' deve estar em API_TAGS");+});++test("combos.mjs registra operações de combos com flags corretas", async () => {+ const { Command } = await import("commander");+ // Importar diretamente o módulo de combos+ const combosPath = join(API_COMMANDS_DIR, "combos.mjs");+ const src = readFileSync(combosPath, "utf8");+ // Deve ter operações CRUD+ assert.ok(src.includes("export function register_combos"), "deve exportar register_combos");+ assert.ok(src.includes("apiFetch"), "deve usar apiFetch");+ assert.ok(src.includes("emit"), "deve usar emit");+});++test("arquivos gerados têm cabeçalho AUTO-GENERATED", () => {+ const files = readdirSync(API_COMMANDS_DIR).filter((f) => f.endsWith(".mjs"));+ for (const file of files.slice(0, 5)) {+ const src = readFileSync(join(API_COMMANDS_DIR, file), "utf8");+ assert.ok(src.includes("AUTO-GENERATED"), `${file} deve ter cabeçalho AUTO-GENERATED`);+ }+});++test("generate-api-commands.mjs existe em scripts/cli/", () => {+ const scriptPath = join(ROOT, "scripts", "cli", "generate-api-commands.mjs");+ assert.ok(existsSync(scriptPath), "generate-api-commands.mjs deve existir");+ const src = readFileSync(scriptPath, "utf8");+ assert.ok(src.includes("IGNORED_OP_IDS"), "deve ter lista IGNORED_OP_IDS");+ assert.ok(+ src.includes("prepublishOnly") || src.includes("build:cli-api") || src.includes("generate"),+ "deve mencionar build"+ );+});++test("package.json tem script build:cli-api", () => {+ const pkg = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8"));+ assert.ok(pkg.scripts?.["build:cli-api"], "build:cli-api deve estar nos scripts");+});