// AUTO-GENERATED from docs/openapi.yaml. Do not edit. import { apiFetch } from "../api.mjs"; import { emit } from "../output.mjs"; import { readFileSync } from "node:fs"; export function register_playground(parent) { const tag = parent.command("playground").description("Playground endpoints"); tag.command("post-api-playground-improve-prompt") .description("Improve prompt via LLM") .option("--body ", "JSON body or @path/to/file.json") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/improve-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: "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-playground-presets") .description("List playground presets") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/presets"; 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-playground-presets") .description("Create playground preset") .option("--body ", "JSON body or @path/to/file.json") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/presets"; 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-playground-presets-id-") .description("Get playground preset") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/presets/{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("put-api-playground-presets-id-") .description("Update playground preset") .option("--body ", "JSON body or @path/to/file.json") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/presets/{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: "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-playground-presets-id-") .description("Delete playground preset") .action(async (opts, cmd) => { const gOpts = cmd.optsWithGlobals(); let url = "/api/playground/presets/{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); }); }