@pollinations/cli 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -217,13 +217,13 @@ function readConfig(path) {
217
217
  process.exit(1);
218
218
  }
219
219
  }
220
- function agentBody(configPath, opts) {
220
+ function agentBody(configPath2, opts) {
221
221
  if (opts.visibility !== void 0 && opts.visibility !== "private" && opts.visibility !== "public") {
222
222
  printError("--visibility must be 'private' or 'public'");
223
223
  process.exit(1);
224
224
  }
225
225
  return {
226
- ...readConfig(configPath),
226
+ ...readConfig(configPath2),
227
227
  ...opts.name !== void 0 && { name: opts.name },
228
228
  ...opts.title !== void 0 && { title: opts.title },
229
229
  ...opts.description !== void 0 && {
@@ -685,12 +685,25 @@ import { Command as Command5 } from "commander";
685
685
  // src/lib/errors.ts
686
686
  async function budgetHint(status2, bodyText) {
687
687
  if (status2 !== 402) return null;
688
+ let code;
689
+ try {
690
+ code = JSON.parse(bodyText)?.error?.code;
691
+ } catch {
692
+ }
693
+ if (code === "KEY_BUDGET_EXHAUSTED") {
694
+ return [
695
+ "API key budget exhausted. Topping up the wallet does not increase the key budget.",
696
+ "Manage key budget: https://enter.pollinations.ai/keys",
697
+ `Server said: ${bodyText}`
698
+ ].join("\n");
699
+ }
688
700
  const balance = await gen("/account/balance", {
689
701
  apiKey: requireKey()
690
702
  }).then((r) => r.balance).catch(() => null);
691
703
  const lines = [
692
- "Insufficient pollen balance.",
704
+ code === "INSUFFICIENT_BALANCE" ? "Insufficient pollen balance." : "Check your pollen balance and API key budget.",
693
705
  "Top up: https://enter.pollinations.ai/pollen",
706
+ ...code === "INSUFFICIENT_BALANCE" ? [] : ["Manage key budget: https://enter.pollinations.ai/keys"],
694
707
  ""
695
708
  ];
696
709
  if (balance != null) lines.push(`Account balance: ${balance} pollen`);
@@ -1264,15 +1277,17 @@ import { homedir as homedir2 } from "os";
1264
1277
  import { Command as Command12 } from "commander";
1265
1278
 
1266
1279
  // src/harnesses/dsh.ts
1267
- import { join as join4, resolve } from "path";
1280
+ import { join as join4 } from "path";
1268
1281
  import { parseEnv } from "util";
1269
1282
  import { isMap, isSeq, parseDocument, Scalar } from "yaml";
1270
1283
 
1271
1284
  // SKILL.md?raw
1272
- var SKILL_default = '---\nname: polli\ndescription: Generate images, text, audio, video, and transcribe speech via the Pollinations API using the polli CLI. Use when asked to generate media, call pollinations.ai, check pollen balance, list models, manage API keys, inspect quests, manage agents or my-models, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Filter models by type | `polli models --type image` |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`, max 90) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Connect a coding harness to Pollinations | `polli harness dsh on` (available adapters: `polli harness --help`) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status`.\nOverride the stored key for a single command with `--key <key>`.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `zimage`, 1024x1024. Pick a different model with `--model flux` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `flux` and `zimage` are text-only and will silently ignore `--image`. Find i2i-capable models with `polli models --type image --json | jq -r \'.[] | select(.input_modalities | contains(["image"])) | .name\'` (common choices: `nanobanana`, `kontext`, `p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe).\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` posts a multipart upload to `media.pollinations.ai` (100MB max; 30-day lifecycle, refreshed by GETs once the object is at least 15 days old). Each upload receives a unique id. Human mode: URL on stdout and id/size/contentType on stderr. `--json`: full upload response on stdout. The returned URL is public (no auth to fetch) and works anywhere `--image` is accepted \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave to file: `--output summary.txt`. Use `--system "<msg>"` to set system prompt. For reasoning models, pass `--reasoning low|medium|high` to control reasoning effort. **Only send `--reasoning` to models where `reasoning: true`** in `polli models --type text --json` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 repeatable for multi-image prompts. Local paths aren\'t supported; run them through `polli upload` first (see the upload recipe above). **Only text models with `"image"` in `input_modalities` actually read the image** \u2014 filter with `polli models --type text --json | jq -r \'.[] | select(.input_modalities | index("image")) | .name\'`. Non-vision models silently ignore the attachment. Good defaults: `openai`, `gemini`, `claude`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nDefault voice is `sage`. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 each audio model entry includes its `voices[]` array. Format defaults to mp3; `--format opus|aac|flac|wav` to change. Accepts stdin (same as `gen text`). Add `--play` to save and then play the audio back (handy for narration/demos). Playback starts after the file is fully written, and the command blocks until playback finishes \u2014 if you want fire-and-forget, wrap in a subshell: `( polli gen audio "..." --play & )`. Player on macOS: `afplay`; on Linux it tries `ffplay`, then `mpv`, then `mpg123` in that order.\n\n### Generate music (elevenmusic)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (eleven-sfx)\n```bash\npolli gen audio "thunderclap with heavy rain" --model eleven-sfx --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model wan-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 you always pay for and receive 5 sec). For image-to-video, pass `--image <url>` with a **public HTTPS URL** (local file paths and 404/rate-limited hosts will fail with a server error).\n\n**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, and `--audio` are forwarded to the server but may be silently ignored \u2014 verified on `wan-fast` where duration is locked to 5s, `--aspect-ratio 9:16` still returns 16:9, and `--audio` produces no audio track. Always inspect the output (`file`, `ffprobe`) before trusting a flag worked. Check `polli models --type video --json` for per-model capabilities.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 the stats pipe only records text/image/audio events. To compare video models, fall back to `polli models --type video --json` and look at price/description fields.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `whisper` (default), `scribe`, `universal-2`, `universal-3.5-pro`. Accepts common audio formats (mp3, wav, m4a, flac, ogg); non-audio input (e.g. a `.txt` file) returns a clear `400 invalid_request_error: extension "txt" not supported` \u2014 no need to pre-validate with `file`. Default output is the plain transcript on stdout as a single line (pipe-friendly). Use `--json` for structured output: **whisper** and **AssemblyAI** return timing data when requested through the API; **scribe** returns only `{text: "..."}` \u2014 use whisper or AssemblyAI if you need timing data. `--language <ISO-639-1>` (e.g. `en`, `fr`) is an optional hint that can improve accuracy for non-English or accented speech.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models --type image --verbose # with context length / pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 a model can show `0.0%` while having massive 4xx rates (auth, validation, etc.). For the full picture use `--stats --json` and read `errors_4xx`, `errors_5xx`, `latency_p95_ms`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `gptimage` lands at ~$0.008, not $0.000008. Flat-priced image models (`flux`, `zimage`) expose `completionImageTokens` as the whole-image price because they emit exactly one "token" per image. When in doubt, make one call and read the true cost from `polli usage --history --limit 5 --json`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window, max 90\npolli quests # your quests + claim state (open/claimable/claimed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. When matching costs to freshly-generated media, use `--limit 50` and filter by timestamp, and retry if the expected entry is missing. `polli usage --json` returns `{"pollen": <number>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. Use `account:usage` for narrow read-only usage and `polli quests`; use both permissions when a client needs both read-only account state and admin operations. Quest claiming is dashboard-only; `polli quests` is read-only and account-aware.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents update <id> --config agent.json\npolli agents delete <id>\n```\nThe config file contains `systemPrompt`, `baseModel`, and optional `mcpServers`; create also requires `--name` and `--title` for the callable model listing. The only supported server ID is currently `"pollinations"`. Updates replace the complete agent configuration.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--permissions <perms...>` scopes what the new key can do on the account (e.g. `profile usage` lets it call `polli --key <new> usage`). **Without `--permissions`, new scoped keys can generate media but cannot read account state** \u2014 `polli --key <new> usage` will 403. `"keys"` is auto-stripped from the list so a scoped key can never mint further keys. Existing keys with `account:keys` can manage my-models where that invite-only feature is enabled, but still need `account:usage` for read-only account state. Publishable app keys default developer earnings off; pass `--earnings` to enable them. To inspect a specific key other than the current one, use `polli keys list --json | jq \'.[] | select(.id == "<id>")\'`. `keys info` is intentionally scoped to the caller\'s own key.\n\n### Connect a coding harness\n```bash\npolli harness --help # supported harnesses\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model kimi # any tool-calling text model from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\n```\nThe DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). It stores one dedicated child key in `$DSH_HOME/.env` for the provider and MCP, plus a private snapshot under `~/.pollinations/harnesses/`. Reruns reuse a valid key already in the harness config. Other adapters may use their harness\'s official plugin or installer instead. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 most emit `key: value` pairs or tab-separated tables with a header row. Exceptions: `gen text` prints the full response to stdout; `gen transcribe` prints the transcript as plain text; `gen chat` runs an interactive REPL. Status/progress messages go to stderr, so pipes stay clean.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 5, `avg` latency in a reasonable range for the modality (standard text <5s, image <10s, video <60s), and `requests` high enough to be statistically meaningful (ignore rows with <10 requests \u2014 noise). **Filter by capability first, then optimize by health** \u2014 e.g. for a reasoning task, narrow to models where `reasoning: true` (via `polli models --type text --json`), *then* cross-reference against `--stats` output. The healthiest model overall may not support the capability you need. **Reasoning models are inherently slower \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **For stdin-as-context** on `gen text`, pipe the context and pass the question as the positional argument: `cat file | polli gen text "question about the file"`.\n7. **For exact flag lists, run `polli <cmd> --help` or `polli gen <cmd> --help`.** This skill\'s recipes cover the common path; the CLI\'s own help is always the source of truth.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 a human at the terminal sees tokens tick in, a pipe/redirect gets the full response once. Force either mode with `--stream` or `--no-stream`. For scripts and chains like `polli gen text \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **Translating a `polli` workflow into a browser app.** `gen.pollinations.ai` requires a bearer token for generation requests, so a plain client-side `fetch` with no auth returns 401 unless it is served from cache. Mint a scoped key with `polli keys create` and proxy via your own backend.\n';
1285
+ var SKILL_default = '---\nname: polli\ndescription: Generate images, text, audio, video, and transcribe speech via the Pollinations API using the polli CLI. Use when asked to generate media, call pollinations.ai, check pollen balance, list models, manage API keys, inspect quests, manage agents or my-models, or run polli commands.\nallowed-tools: Bash(polli *)\n---\n\n# polli \u2014 Pollinations CLI\n\nThin wrapper around `gen.pollinations.ai`. Generates images, text, audio, video; transcribes speech; manages API keys, usage, quests, agents, and invite-only my-models.\n\nIf `polli` is not installed, run `npm i -g @pollinations/cli@latest` (provides the `polli` binary).\n\n## When to use this skill\n\n- User asks to **generate an image / text / audio / video** via pollinations\n- User mentions **polli, pollinations, pollen, pollinations.ai**\n- User wants to **transcribe speech** or run TTS\n- User asks about their **pollen balance, usage, or API keys**\n- User wants to **browse or filter available models**\n- User wants to inspect **quests** or manage invite-only **my-models**\n- User wants to create or update a hosted prompt **agent**\n\n## Quick reference\n\n| Intent | Command |\n|---|---|\n| Log in once | `polli auth login` |\n| Store an existing key | `printf \'%s\' "$POLLINATIONS_API_KEY" \\| polli auth login --with-token` |\n| Generate image | `polli gen image "<prompt>" --output out.png` |\n| Generate text | `polli gen text "<prompt>"` |\n| Text with stdin as context | `echo "<ctx>" \\| polli gen text "<question>"` |\n| Describe an image (vision) | `polli gen text "what is this?" --image <url>` |\n| One-shot TTS | `polli gen audio "<text>" --output speech.mp3` |\n| Speak out loud | `polli gen audio "<text>" --play` (uses `afplay` on macOS; `ffplay`/`mpv`/`mpg123` on Linux) |\n| Generate video | `polli gen video "<prompt>" --output out.mp4` |\n| Transcribe audio | `polli gen transcribe path/to.mp3` |\n| Upload a local file | `polli upload path/to.png` (prints public URL) |\n| List all models | `polli models` |\n| Filter models by type | `polli models --type image` |\n| Model health + latency | `polli models --stats` (default 60m, `--window <min>`) |\n| Check balance | `polli usage` |\n| Developer earnings | `polli earnings` (`--days <n>`, max 90) |\n| List your quests + claim state | `polli quests` (filters: `--open --claimable --claimed --coming-soon`) |\n| Manage prompt agents | `polli agents list` |\n| Manage invite-only community models | `polli my-models list` |\n| Connect a coding harness to Pollinations | `polli harness <dsh\\|opencode\\|openclaw\\|pi\\|prime> on` (available adapters: `polli harness --help`) |\n| Machine-readable output | append `--json` to any command |\n\n## Setup\n\nOne-time: `polli auth login` (device-flow; creates a key with `profile`, `usage`, and `keys`). To store an existing key, run\n`printf \'%s\' "$POLLINATIONS_API_KEY" | polli auth login --with-token`. Verify\nwith `polli auth status`.\nOverride the stored key for a single command with `--key <key>`.\n\n## Recipes\n\n### Generate an image to a file\n```bash\npolli gen image "a fox reading a book, studio ghibli style" --output fox.png\n```\nDefaults: `zimage`, 1024x1024. Pick a different model with `--model flux` (see `polli models --type image`). For edits / img2img, pass one or more `--image <url>` flags \u2014 **must be public http(s) URLs**, local paths are rejected client-side. **Only models that list `"image"` in `input_modalities` actually consume the flag** \u2014 `flux` and `zimage` are text-only and will silently ignore `--image`. Find i2i-capable models with `polli models --type image --json | jq -r \'.[] | select(.input_modalities | contains(["image"])) | .name\'` (common choices: `nanobanana`, `kontext`, `p-image-edit`). To use a local file, upload it first with `polli upload` (see next recipe).\n\n### Upload a local file to get a public URL\n```bash\nURL=$(polli upload cat.png)\npolli gen image "make the cat purple" --image "$URL" --output purple.png\n```\n`polli upload <file>` posts a multipart upload to `media.pollinations.ai` (100MB max; 30-day lifecycle, refreshed by GETs once the object is at least 15 days old). Each upload receives a unique id. Human mode: URL on stdout and id/size/contentType on stderr. `--json`: full upload response on stdout. The returned URL is public (no auth to fetch) and works anywhere `--image` is accepted \u2014 `gen image`, `gen video`, etc.\n\n### Generate text\n```bash\npolli gen text "summarize the three laws of robotics"\n```\nSave to file: `--output summary.txt`. Use `--system "<msg>"` to set system prompt. For reasoning models, pass `--reasoning low|medium|high` to control reasoning effort. **Only send `--reasoning` to models where `reasoning: true`** in `polli models --type text --json` \u2014 the flag is not validated client-side, and non-reasoning models may silently accept it (openai), ignore it, or return a 400 (mistral).\n\n### Describe an image with a vision model\n```bash\nURL=$(polli upload selfie.jpg)\npolli gen text "turn this person into a cartoon pet in one playful sentence" --image "$URL"\n```\n`gen text --image <url...>` attaches one or more **public https URLs** as an OpenAI-style multimodal message \u2014 repeatable for multi-image prompts. Local paths aren\'t supported; run them through `polli upload` first (see the upload recipe above). **Only text models with `"image"` in `input_modalities` actually read the image** \u2014 filter with `polli models --type text --json | jq -r \'.[] | select(.input_modalities | index("image")) | .name\'`. Non-vision models silently ignore the attachment. Good defaults: `openai`, `gemini`, `claude`.\n\n### Pipe stdin as context into text generation\n```bash\ncat README.md | polli gen text "what does this project do?"\n```\nstdin becomes context; the positional argument is the question.\n\n### Interactive chat session\n```bash\npolli gen chat --model openai --system "you are a terse assistant"\n```\nSlash commands inside the session: `/exit`, `/clear`, `/save <path>`.\n\n### Text-to-speech\n```bash\npolli gen audio "hello world" --voice nova --output hello.mp3\necho "long script" | polli gen audio --voice nova --output out.mp3\n```\nDefault voice is `sage`. To discover the full live voice list, use the model registry: `polli models --type audio --json | jq -r \'.[].voices[]?\'` \u2014 each audio model entry includes its `voices[]` array. Format defaults to mp3; `--format opus|aac|flac|wav` to change. Accepts stdin (same as `gen text`). Add `--play` to save and then play the audio back (handy for narration/demos). Playback starts after the file is fully written, and the command blocks until playback finishes \u2014 if you want fire-and-forget, wrap in a subshell: `( polli gen audio "..." --play & )`. Player on macOS: `afplay`; on Linux it tries `ffplay`, then `mpv`, then `mpg123` in that order.\n\n### Generate music (elevenmusic)\n```bash\npolli gen audio "lofi hip-hop beat" --model elevenmusic --duration 30 --instrumental --output track.mp3\n```\n\n### Generate sound effects (eleven-sfx)\n```bash\npolli gen audio "thunderclap with heavy rain" --model eleven-sfx --duration 5 --output thunder.mp3\n```\nText-to-sound-effect via ElevenLabs (aliases: `sfx`, `sound-effects`). `--duration` 0.5\u201330s (omit to let the model pick). Billed per second of output (~$0.004/s, capped at $0.12 for a full 30s).\n\n### Multilingual TTS (eleven-multilingual-v2)\n```bash\npolli gen audio "Bonjour, ceci est un test" --model multilingual-v2 --voice rachel --output fr.mp3\n```\nStable, lifelike TTS across 29 languages (aliases: `multilingual-v2`, `eleven-v2`) \u2014 a non-alpha alternative to the default v3.\n\n### Generate video\n```bash\npolli gen video "a spacecraft landing on mars" --model wan-fast --duration 5 --output mars.mp4\n```\nCheapest path: `--model wan-fast` at ~$0.01/sec, **fixed 5-second output** (any `--duration` value is ignored \u2014 you always pay for and receive 5 sec). For image-to-video, pass `--image <url>` with a **public HTTPS URL** (local file paths and 404/rate-limited hosts will fail with a server error).\n\n**Flag support varies per model and is not enforced client-side.** `--duration`, `--aspect-ratio`, and `--audio` are forwarded to the server but may be silently ignored \u2014 verified on `wan-fast` where duration is locked to 5s, `--aspect-ratio 9:16` still returns 16:9, and `--audio` produces no audio track. Always inspect the output (`file`, `ffprobe`) before trusting a flag worked. Check `polli models --type video --json` for per-model capabilities.\n\n**Video is not tracked by `--stats`.** `polli models --type video --stats` returns empty \u2014 the stats pipe only records text/image/audio events. To compare video models, fall back to `polli models --type video --json` and look at price/description fields.\n\n### Transcribe audio to text\n```bash\npolli gen transcribe recording.mp3 --language en\n```\nModels: `whisper` (default), `scribe`, `universal-2`, `universal-3.5-pro`. Accepts common audio formats (mp3, wav, m4a, flac, ogg); non-audio input (e.g. a `.txt` file) returns a clear `400 invalid_request_error: extension "txt" not supported` \u2014 no need to pre-validate with `file`. Default output is the plain transcript on stdout as a single line (pipe-friendly). Use `--json` for structured output: **whisper** and **AssemblyAI** return timing data when requested through the API; **scribe** returns only `{text: "..."}` \u2014 use whisper or AssemblyAI if you need timing data. `--language <ISO-639-1>` (e.g. `en`, `fr`) is an optional hint that can improve accuracy for non-English or accented speech.\n\n### Discover models\n```bash\npolli models --type text # text models only\npolli models --type image --verbose # with context length / pricing\npolli models --stats # health + avg latency + err% (60m default)\npolli models --stats --window 5 # last 5 minutes only\n```\nUse `--stats` before choosing a model. **Caveat**: the `err%` column counts **5xx only** \u2014 a model can show `0.0%` while having massive 4xx rates (auth, validation, etc.). For the full picture use `--stats --json` and read `errors_4xx`, `errors_5xx`, `latency_p95_ms`.\n\n**Pricing fields are per-token, not per-request.** `completionImageTokens: 0.000008` means each output image-token costs that much \u2014 a single 1024x1024 image from `gptimage` lands at ~$0.008, not $0.000008. Flat-priced image models (`flux`, `zimage`) expose `completionImageTokens` as the whole-image price because they emit exactly one "token" per image. When in doubt, make one call and read the true cost from `polli usage --history --limit 5 --json`.\n\n### Check usage and balance\n```bash\npolli usage # current pollen balance\npolli usage --history # recent individual requests\npolli usage --daily # daily cost summary\npolli earnings # developer earnings total + per-entity breakdown (default 30d)\npolli earnings --days 7 # rolling window, max 90\npolli quests # your quests + claim state (open/claimable/claimed/coming)\npolli quests --claimable # only rewards ready to claim\n```\n**History is eventually consistent** \u2014 a request you just made may not appear for 30\u201360s. When matching costs to freshly-generated media, use `--limit 50` and filter by timestamp, and retry if the expected entry is missing. `polli usage --json` returns `{"pollen": <number>}` \u2014 the current balance only; use `--history --json` or `--daily --json` for cost breakdowns.\n\n### Manage my-models\n```bash\npolli my-models list\npolli my-models models --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY"\npolli my-models create --name my-model --title "My Model" --api chat_completions --url https://api.example.com/v1/chat/completions --bearer-token "$UPSTREAM_KEY" --upstream-model gpt-4.1-mini --required-safety privacy,secrets,sexual,violence,shield\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model flux\npolli my-models update <id> --description "Updated description"\npolli my-models update <id> --paid-only # only accept Paid Pollen; --no-paid-only reverts\npolli my-models update <id> --required-safety privacy,secrets,sexual,violence,shield\npolli my-models delete <id>\n```\n`my-models` manages owned community text, image, and transcription models. Any account can create private models; `communityEndpointsAllowed: true` is required only to publish them. API keys require `account:keys`. Use `account:usage` for narrow read-only usage and `polli quests`; use both permissions when a client needs both read-only account state and admin operations. Quest claiming is dashboard-only; `polli quests` is read-only and account-aware.\n\n### Register an image my-model\n```bash\npolli my-models test --modality image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --model image-v1\npolli my-models create --name my-image --title "My Image" --modality image --image-pricing request --completion-image-price 0.01 --input-modalities text,image --base-url https://api.example.com/v1 --bearer-token "$UPSTREAM_KEY" --upstream-model image-v1\n```\nTest before creating. The probe reports the pricing mode it detected and the input modalities it found, including whether the endpoint accepts image edits; pass those back as `--input-modalities text,image` to advertise edit support. `polli my-models list` shows them in the `inputs` column.\n\nTwo billing modes: `--image-pricing request` charges `--completion-image-price` per generated image, while `--image-pricing tokens` bills returned token usage per 1M through `--prompt-text-price`, `--prompt-image-price`, and `--completion-image-price`.\n\nPrices only apply to `--visibility public` models. A private model is owner-only and always free, so every price flag above is stored as `0` until you publish \u2014 and making a published model private clears its prices again.\n\n`--modality` is fixed at creation \u2014 `update` cannot change it.\n\n### Manage agents\n\n```bash\npolli agents list\npolli agents get <id>\npolli agents create --config agent.json --name my-agent --title "My Agent"\npolli agents update <id> --config agent.json\npolli agents delete <id>\n```\nThe config file contains `systemPrompt`, `baseModel`, and optional `mcpServers`; create also requires `--name` and `--title` for the callable model listing. Use server IDs from the MCP catalog. Updates replace the complete agent configuration.\n\nCreating an agent also creates its callable model listing. Managed agents are text-only and free, with no fallbacks or per-user RPM. Deleting the agent also deletes its model listing. See [Publish an Agent](https://github.com/pollinations/pollinations/blob/main/BUILD_YOUR_OWN_AGENT.md).\n\n### Manage API keys\n```bash\npolli keys list # list all keys on the account\npolli keys info # details about the CURRENTLY AUTHENTICATED key only (takes no id)\npolli keys create --name "my-bot" --type secret --budget 1000 --permissions profile usage # scoped key\npolli keys create --name "my-app" --type publishable --redirect-uri https://app.example/callback --earnings\npolli keys revoke <id> # id comes from `keys list --json`\n```\n`--permissions <perms...>` scopes what the new key can do on the account (e.g. `profile usage` lets it call `polli --key <new> usage`). **Without `--permissions`, new scoped keys can generate media but cannot read account state** \u2014 `polli --key <new> usage` will 403. `"keys"` is auto-stripped from the list so a scoped key can never mint further keys. Existing keys with `account:keys` can manage my-models where that invite-only feature is enabled, but still need `account:usage` for read-only account state. Publishable app keys default developer earnings off; pass `--earnings` to enable them. To inspect a specific key other than the current one, use `polli keys list --json | jq \'.[] | select(.id == "<id>")\'`. `keys info` is intentionally scoped to the caller\'s own key.\n\n### Connect a coding harness\n```bash\npolli harness --help # supported harnesses\npolli harness dsh on # login if needed, mint key "polli-harness-dsh", write provider + default model\npolli harness dsh on --model kimi # any tool-calling text model from `polli models`\npolli harness dsh on --no-mcp # configure the provider and skill without MCP tools\npolli harness dsh off # restore the config backed up before "on"\npolli harness opencode on # enable the Pollinations OpenCode plugin\npolli harness opencode off # remove the plugin setup and stored key\npolli harness pi on # login if needed, mint key "polli-harness-pi", configure Pi with Pollinations\npolli harness pi on --model kimi # any tool-calling text model from `polli models`\npolli harness pi off # restore the Pi config backed up before "on"\npolli harness openclaw on # login if needed, mint key "polli-harness-openclaw", add provider + Polli skill\npolli harness openclaw off # remove the Pollinations provider, key, and skill\n```\nEach adapter checks that its harness can be launched before login, key creation, or configuration. DSH\'s official launch uses `npx`, so its adapter checks for `npx`; OpenCode, OpenClaw, and Pi require their installed commands.\n\nThe DSH adapter globally configures the Pollinations provider, hosted Pollinations MCP, and this skill under `$DSH_HOME` (default `~/.dsh`). OpenCode enables the existing Pollinations plugin and stores its dedicated key in the plugin config. OpenClaw adds a `pollinations` provider to `~/.openclaw/openclaw.json`, stores a dedicated key in `env.vars`, and installs this skill under `~/.openclaw/skills/polli/`. Pi writes `~/.pi/agent/models.json`, `auth.json`, and `settings.json`, and installs this skill under `~/.pi/agent/skills/polli/`. Guide: `polli docs` section "Coding Harnesses".\n\n### Read API docs\n```bash\npolli docs # full llm.txt reference\npolli docs /v1/chat/completions # filter to one endpoint\npolli docs --open # open in browser\n```\n\n## Output contract\n\n- **Default (human mode):** varies by command \u2014 most emit `key: value` pairs or tab-separated tables with a header row. Exceptions: `gen text` prints the full response to stdout; `gen transcribe` prints the transcript as plain text; `gen chat` runs an interactive REPL. Status/progress messages go to stderr, so pipes stay clean.\n- **`--json`:** every command emits machine-parseable JSON to stdout; all human messages go to stderr. **Always prefer `--json` when piping into `jq` or parsing** \u2014 it\'s the only shape with a stable contract.\n- **Exit codes:** 0 on success, non-zero on auth failure, rate limit, network error, or invalid args. Error messages go to stderr.\n\n## Agent operating rules\n\n1. **Run `polli auth status` first** if you don\'t know whether the user is logged in. Fail fast with a clear "run `polli auth login`" message if not.\n2. **Prefer `--json`** whenever you\'ll parse the output. Never grep human-formatted tables.\n3. **Don\'t hardcode model IDs.** Fetch the live list with `polli models --type <type>`. Model availability changes.\n4. **Before picking a model for production use, check `polli models --stats`.** Rule of thumb for "healthy": `err%` \u2264 5, `avg` latency in a reasonable range for the modality (standard text <5s, image <10s, video <60s), and `requests` high enough to be statistically meaningful (ignore rows with <10 requests \u2014 noise). **Filter by capability first, then optimize by health** \u2014 e.g. for a reasoning task, narrow to models where `reasoning: true` (via `polli models --type text --json`), *then* cross-reference against `--stats` output. The healthiest model overall may not support the capability you need. **Reasoning models are inherently slower \u2014 expect 5\u201350s, not <5s**; when picking among them, prioritize low `err%` and request count over raw latency, and compare latency only within the reasoning-capable subset.\n5. **Always pass `--output <path>`** for `gen image`, `gen audio`, `gen video` \u2014 otherwise the file lands in the current directory with a default name.\n6. **For stdin-as-context** on `gen text`, pipe the context and pass the question as the positional argument: `cat file | polli gen text "question about the file"`.\n7. **For exact flag lists, run `polli <cmd> --help` or `polli gen <cmd> --help`.** This skill\'s recipes cover the common path; the CLI\'s own help is always the source of truth.\n8. **Use `polli docs [endpoint]` over guessing API shapes.** It prints the canonical `llm.txt` reference from the live API.\n\n## Common pitfalls\n\n- Forgetting `--output` on binary generators (image/audio/video) \u2014 the file goes to a default path, which may not be what the user wants.\n- Using `polli gen text --json` expecting OpenAI chat-completions shape \u2014 the CLI\'s `--json` wraps its own structure. Use `polli docs /v1/chat/completions` to see the raw API shape if you need it.\n- Running commands without auth \u2014 `polli auth status` tells you who you\'re logged in as and your balance in one call.\n- **`gen text` streams to a TTY, buffers when piped.** The default now auto-detects \u2014 a human at the terminal sees tokens tick in, a pipe/redirect gets the full response once. Force either mode with `--stream` or `--no-stream`. For scripts and chains like `polli gen text \u2026 | polli gen audio \u2026`, you don\'t need to do anything; buffering happens automatically.\n- **Translating a `polli` workflow into a browser app.** `gen.pollinations.ai` requires a bearer token for generation requests, so a plain client-side `fetch` with no auth returns 401 unless it is served from cache. Mint a scoped key with `polli keys create` and proxy via your own backend.\n';
1273
1286
 
1274
1287
  // src/harnesses/fs.ts
1275
1288
  import {
1289
+ accessSync,
1290
+ constants,
1276
1291
  existsSync as existsSync2,
1277
1292
  mkdirSync as mkdirSync2,
1278
1293
  readFileSync as readFileSync4,
@@ -1281,7 +1296,25 @@ import {
1281
1296
  unlinkSync as unlinkSync2,
1282
1297
  writeFileSync as writeFileSync7
1283
1298
  } from "fs";
1284
- import { basename as basename2, dirname, join as join2 } from "path";
1299
+ import { basename as basename2, delimiter, dirname, join as join2, resolve } from "path";
1300
+ var resolveHomePath = (home, path) => resolve(
1301
+ path === "~" ? home : path.startsWith("~/") || path.startsWith("~\\") ? join2(home, path.slice(2)) : path
1302
+ );
1303
+ var isExecutable = (path) => {
1304
+ try {
1305
+ accessSync(path, constants.X_OK);
1306
+ return true;
1307
+ } catch {
1308
+ return false;
1309
+ }
1310
+ };
1311
+ var commandExists = (command, env, fallbacks = []) => {
1312
+ const extensions = process.platform === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";") : [""];
1313
+ const candidates = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean).flatMap(
1314
+ (dir) => extensions.map((extension) => join2(dir, `${command}${extension}`))
1315
+ );
1316
+ return [...candidates, ...fallbacks].some(isExecutable);
1317
+ };
1285
1318
  var readTextIfExists = (path) => existsSync2(path) ? readFileSync4(path, "utf-8") : null;
1286
1319
  var writeTextAtomic = (path, text, mode) => {
1287
1320
  mkdirSync2(dirname(path), { recursive: true, mode: 448 });
@@ -1319,17 +1352,21 @@ var resolveHarnessKey = async (harness, options) => {
1319
1352
  const created = await gen("/account/keys", {
1320
1353
  method: "POST",
1321
1354
  apiKey: accountKey,
1322
- body: { name, type: "secret" }
1355
+ body: {
1356
+ name,
1357
+ type: "secret",
1358
+ ...harness.accountPermissions ? { accountPermissions: harness.accountPermissions } : {}
1359
+ }
1323
1360
  });
1324
1361
  printSuccess(`Created API key "${name}" for ${harness.label}.`);
1325
1362
  return created.key;
1326
1363
  };
1327
1364
 
1328
1365
  // src/harnesses/models.ts
1329
- var fetchHarnessModels = async () => {
1366
+ var fetchHarnessModels = async (selectedModel) => {
1330
1367
  const { data } = await gen("/v1/models");
1331
- return data.filter(
1332
- (m) => m.tools === true && m.output_modalities?.includes("text") && m.context_length && !m.agent && !m.id.includes("/")
1368
+ const models2 = data.filter(
1369
+ (m) => m.tools === true && m.output_modalities?.includes("text") && m.supported_endpoints?.includes("/v1/chat/completions") && m.context_length && !m.agent && m.community !== true
1333
1370
  ).map((m) => ({
1334
1371
  id: m.id,
1335
1372
  contextWindow: m.context_length,
@@ -1337,6 +1374,12 @@ var fetchHarnessModels = async () => {
1337
1374
  (modality) => modality === "text" || modality === "image"
1338
1375
  )
1339
1376
  }));
1377
+ if (!models2.some((model) => model.id === selectedModel)) {
1378
+ throw new Error(
1379
+ `Model "${selectedModel}" is not a tool-calling text model. Run: polli models`
1380
+ );
1381
+ }
1382
+ return models2;
1340
1383
  };
1341
1384
 
1342
1385
  // src/harnesses/snapshot.ts
@@ -1359,8 +1402,8 @@ var captureFiles = (paths) => Object.fromEntries(
1359
1402
  { before: readTextIfExists(path), afterHash: null }
1360
1403
  ])
1361
1404
  );
1362
- var restoreFiles = (files2) => {
1363
- for (const [path, file] of Object.entries(files2)) {
1405
+ var restoreFiles = (files6) => {
1406
+ for (const [path, file] of Object.entries(files6)) {
1364
1407
  if (file.before === null) removeIfExists(path);
1365
1408
  else writeTextAtomic(path, file.before);
1366
1409
  }
@@ -1398,23 +1441,18 @@ var applyWithSnapshot = (ctx, id, paths, apply) => {
1398
1441
  snapshot.complete = true;
1399
1442
  writeSnapshot(ctx, id, paths, snapshot);
1400
1443
  };
1401
- var restoreSnapshot = (ctx, id, paths) => {
1444
+ var restoreOrStrip = (ctx, id, paths, strip) => {
1402
1445
  const snapshot = loadSnapshot(ctx, id, paths);
1403
- if (!snapshot) return "missing";
1404
- if (!snapshot.complete) {
1446
+ if (snapshot && (!snapshot.complete || Object.entries(snapshot.files).every(
1447
+ ([path, file]) => contentHash(readTextIfExists(path)) === file.afterHash
1448
+ ))) {
1405
1449
  restoreFiles(snapshot.files);
1406
- removeIfExists(snapshotPath(ctx, id, paths));
1450
+ clearSnapshot(ctx, id, paths);
1407
1451
  return "restored";
1408
1452
  }
1409
- const entries = Object.entries(snapshot.files);
1410
- if (entries.some(
1411
- ([path, file]) => contentHash(readTextIfExists(path)) !== file.afterHash
1412
- )) {
1413
- return "modified";
1414
- }
1415
- restoreFiles(snapshot.files);
1416
- removeIfExists(snapshotPath(ctx, id, paths));
1417
- return "restored";
1453
+ const outcome = strip() ? "stripped" : "unchanged";
1454
+ clearSnapshot(ctx, id, paths);
1455
+ return outcome;
1418
1456
  };
1419
1457
  var clearSnapshot = (ctx, id, paths) => removeIfExists(snapshotPath(ctx, id, paths));
1420
1458
 
@@ -1422,7 +1460,7 @@ var clearSnapshot = (ctx, id, paths) => removeIfExists(snapshotPath(ctx, id, pat
1422
1460
  var ID = "dsh";
1423
1461
  var LABEL = "DeepSeek Harness";
1424
1462
  var PROVIDER = "pollinations";
1425
- var DEFAULT_MODEL = "deepseek";
1463
+ var DEFAULT_MODEL = "deepseek/deepseek-v4-flash";
1426
1464
  var KEY_ENV = "POLLI_DSH_API_KEY";
1427
1465
  var MCP_ID = "mcp-pollinations";
1428
1466
  var MCP_URL = `${BASE_URL}/mcp/pollinations`;
@@ -1436,8 +1474,7 @@ var JS_TAG = {
1436
1474
  var dshHome = (ctx) => {
1437
1475
  const configured = ctx.env.DSH_HOME;
1438
1476
  if (!configured?.trim()) return join4(ctx.home, ".dsh");
1439
- const expanded = configured === "~" ? ctx.home : configured.startsWith("~/") || configured.startsWith("~\\") ? join4(ctx.home, configured.slice(2)) : configured;
1440
- return resolve(expanded);
1477
+ return resolveHomePath(ctx.home, configured);
1441
1478
  };
1442
1479
  var settingsPath = (ctx) => join4(dshHome(ctx), "settings.yaml");
1443
1480
  var envPath = (ctx) => join4(dshHome(ctx), ".env");
@@ -1617,12 +1654,7 @@ var configureDsh = (ctx, settings) => {
1617
1654
  return result(ctx);
1618
1655
  };
1619
1656
  var disableDsh = (ctx) => {
1620
- const managedFiles = files(ctx);
1621
- let outcome = "restored";
1622
- if (restoreSnapshot(ctx, ID, managedFiles) !== "restored") {
1623
- outcome = stripConfig(ctx) ? "stripped" : "unchanged";
1624
- clearSnapshot(ctx, ID, managedFiles);
1625
- }
1657
+ const outcome = restoreOrStrip(ctx, ID, files(ctx), () => stripConfig(ctx));
1626
1658
  return { ...result(ctx), configured: false, outcome };
1627
1659
  };
1628
1660
  var dsh = {
@@ -1631,13 +1663,13 @@ var dsh = {
1631
1663
  description: "Configure DeepSeek Harness as a Pollinations provider",
1632
1664
  restartHint: "Changes apply on the next request. Start DeepSeek Harness with: npx @deepseek-ai/dsh web",
1633
1665
  async on(ctx, options) {
1634
- const model = options.model ?? DEFAULT_MODEL;
1635
- const models2 = await fetchHarnessModels();
1636
- if (!models2.some((candidate) => candidate.id === model)) {
1666
+ if (!commandExists("npx", ctx.env)) {
1637
1667
  throw new Error(
1638
- `Model "${model}" is not a tool-calling text model. Run: polli models`
1668
+ "DeepSeek Harness requires npx. Install Node.js, then run: npx @deepseek-ai/dsh web"
1639
1669
  );
1640
1670
  }
1671
+ const model = options.model ?? DEFAULT_MODEL;
1672
+ const models2 = await fetchHarnessModels(model);
1641
1673
  const apiKey = await resolveHarnessKey(
1642
1674
  { id: ID, label: LABEL, existingKey: readKey(ctx) },
1643
1675
  { browser: options.browser }
@@ -1653,8 +1685,656 @@ var dsh = {
1653
1685
  status: result
1654
1686
  };
1655
1687
 
1688
+ // src/harnesses/openclaw.ts
1689
+ import { spawnSync as spawnSync2 } from "child_process";
1690
+ import { join as join5 } from "path";
1691
+ import JSON5 from "json5";
1692
+ var ID2 = "openclaw";
1693
+ var LABEL2 = "OpenClaw";
1694
+ var PROVIDER2 = "pollinations";
1695
+ var DEFAULT_MODEL2 = "moonshotai/kimi-k2.6";
1696
+ var KEY_ENV2 = "POLLI_OPENCLAW_API_KEY";
1697
+ var openclawStateDir = (ctx) => {
1698
+ const stateDir = ctx.env.OPENCLAW_STATE_DIR?.trim();
1699
+ if (stateDir) return resolveHomePath(ctx.home, stateDir);
1700
+ const home = ctx.env.OPENCLAW_HOME?.trim();
1701
+ return join5(home ? resolveHomePath(ctx.home, home) : ctx.home, ".openclaw");
1702
+ };
1703
+ var configPath = (ctx) => {
1704
+ const override = ctx.env.OPENCLAW_CONFIG_PATH?.trim();
1705
+ return override ? resolveHomePath(ctx.home, override) : join5(openclawStateDir(ctx), "openclaw.json");
1706
+ };
1707
+ var skillFile = (ctx) => join5(openclawStateDir(ctx), "skills", "polli", "SKILL.md");
1708
+ var files2 = (ctx) => [configPath(ctx), skillFile(ctx)];
1709
+ var loadJson = (path) => {
1710
+ const text = readTextIfExists(path);
1711
+ if (!text?.trim()) return {};
1712
+ return JSON5.parse(text);
1713
+ };
1714
+ var saveJson = (path, data) => {
1715
+ writeTextAtomic(path, `${JSON.stringify(data, null, 2)}
1716
+ `, 384);
1717
+ };
1718
+ var readKey2 = (ctx) => {
1719
+ const env = loadJson(configPath(ctx)).env;
1720
+ const key = env?.vars?.[KEY_ENV2];
1721
+ return typeof key === "string" && key ? key : null;
1722
+ };
1723
+ var providerEntry = (models2) => ({
1724
+ baseUrl: `${BASE_URL}/v1`,
1725
+ apiKey: `\${${KEY_ENV2}}`,
1726
+ api: "openai-completions",
1727
+ models: models2.map((model) => ({
1728
+ id: model.id,
1729
+ name: model.id,
1730
+ contextWindow: model.contextWindow,
1731
+ input: model.input
1732
+ }))
1733
+ });
1734
+ var asRecord = (value) => value && typeof value === "object" ? value : {};
1735
+ var writeConfig2 = (ctx, models2, apiKey, model) => {
1736
+ const doc = loadJson(configPath(ctx));
1737
+ const env = asRecord(doc.env);
1738
+ const vars = asRecord(env.vars);
1739
+ vars[KEY_ENV2] = apiKey;
1740
+ env.vars = vars;
1741
+ doc.env = env;
1742
+ const modelsConfig = asRecord(doc.models);
1743
+ const providers = asRecord(modelsConfig.providers);
1744
+ providers[PROVIDER2] = providerEntry(models2);
1745
+ modelsConfig.providers = providers;
1746
+ doc.models = modelsConfig;
1747
+ const agents = asRecord(doc.agents);
1748
+ const defaults = asRecord(agents.defaults);
1749
+ const agentModel = asRecord(defaults.model);
1750
+ agentModel.primary = `${PROVIDER2}/${model}`;
1751
+ defaults.model = agentModel;
1752
+ agents.defaults = defaults;
1753
+ doc.agents = agents;
1754
+ saveJson(configPath(ctx), doc);
1755
+ if (readTextIfExists(skillFile(ctx)) === null) {
1756
+ writeTextAtomic(skillFile(ctx), SKILL_default, 384);
1757
+ }
1758
+ };
1759
+ var stripConfig2 = (ctx) => {
1760
+ let changed = false;
1761
+ const doc = loadJson(configPath(ctx));
1762
+ if (doc.env?.vars && KEY_ENV2 in asRecord(doc.env.vars)) {
1763
+ const vars = asRecord(doc.env.vars);
1764
+ delete vars[KEY_ENV2];
1765
+ if (Object.keys(vars).length === 0) delete doc.env.vars;
1766
+ saveJson(configPath(ctx), doc);
1767
+ changed = true;
1768
+ }
1769
+ const providers = asRecord(doc.models?.providers);
1770
+ if (PROVIDER2 in providers) {
1771
+ delete providers[PROVIDER2];
1772
+ if (Object.keys(providers).length === 0)
1773
+ delete asRecord(doc.models).providers;
1774
+ saveJson(configPath(ctx), doc);
1775
+ changed = true;
1776
+ }
1777
+ const primary = asRecord(doc.agents?.defaults?.model).primary;
1778
+ if (typeof primary === "string" && primary.startsWith(`${PROVIDER2}/`)) {
1779
+ delete asRecord(asRecord(doc.agents).defaults).model.primary;
1780
+ saveJson(configPath(ctx), doc);
1781
+ changed = true;
1782
+ }
1783
+ if (readTextIfExists(skillFile(ctx)) === SKILL_default) {
1784
+ removeIfExists(skillFile(ctx));
1785
+ changed = true;
1786
+ }
1787
+ return changed;
1788
+ };
1789
+ var result2 = (ctx) => {
1790
+ const doc = loadJson(configPath(ctx));
1791
+ const provider = asRecord(doc.models?.providers?.[PROVIDER2]);
1792
+ const primary = asRecord(doc.agents?.defaults?.model).primary;
1793
+ return {
1794
+ harness: ID2,
1795
+ label: LABEL2,
1796
+ configured: provider?.baseUrl === `${BASE_URL}/v1` && provider?.api === "openai-completions" && provider?.apiKey === `\${${KEY_ENV2}}` && typeof primary === "string" && primary.startsWith(`${PROVIDER2}/`) && readKey2(ctx) !== null && readTextIfExists(skillFile(ctx)) !== null,
1797
+ model: typeof primary === "string" && primary.startsWith(`${PROVIDER2}/`) ? primary.slice(`${PROVIDER2}/`.length) : void 0,
1798
+ files: files2(ctx)
1799
+ };
1800
+ };
1801
+ var configureOpenClaw = (ctx, models2, apiKey, model) => {
1802
+ applyWithSnapshot(
1803
+ ctx,
1804
+ ID2,
1805
+ files2(ctx),
1806
+ () => writeConfig2(ctx, models2, apiKey, model)
1807
+ );
1808
+ return result2(ctx);
1809
+ };
1810
+ var disableOpenClaw = (ctx) => {
1811
+ const outcome = restoreOrStrip(ctx, ID2, files2(ctx), () => stripConfig2(ctx));
1812
+ return { ...result2(ctx), configured: false, outcome };
1813
+ };
1814
+ var openclawInstalled = (ctx) => commandExists("openclaw", ctx.env);
1815
+ var initializeOpenClaw = (ctx) => {
1816
+ if (readTextIfExists(configPath(ctx)) !== null) return;
1817
+ const setup = spawnSync2("openclaw", ["setup", "--baseline"], {
1818
+ env: ctx.env,
1819
+ stdio: "ignore"
1820
+ });
1821
+ if (setup.error) throw setup.error;
1822
+ if (setup.status !== 0 || readTextIfExists(configPath(ctx)) === null) {
1823
+ throw new Error("OpenClaw baseline setup failed");
1824
+ }
1825
+ };
1826
+ var openclaw = {
1827
+ id: ID2,
1828
+ label: LABEL2,
1829
+ description: "Add Pollinations as a provider in OpenClaw",
1830
+ restartHint: "Restart the gateway: openclaw gateway restart (or /model inside chat to switch).",
1831
+ async on(ctx, options) {
1832
+ if (!openclawInstalled(ctx)) {
1833
+ throw new Error(
1834
+ "OpenClaw was not found. Install it from: https://openclaw.ai/install"
1835
+ );
1836
+ }
1837
+ const model = options.model ?? DEFAULT_MODEL2;
1838
+ const models2 = await fetchHarnessModels(model);
1839
+ initializeOpenClaw(ctx);
1840
+ const apiKey = await resolveHarnessKey(
1841
+ { id: ID2, label: LABEL2, existingKey: readKey2(ctx) },
1842
+ { browser: options.browser }
1843
+ );
1844
+ return configureOpenClaw(ctx, models2, apiKey, model);
1845
+ },
1846
+ off: disableOpenClaw,
1847
+ status: result2
1848
+ };
1849
+
1850
+ // src/harnesses/opencode.ts
1851
+ import { join as join6 } from "path";
1852
+ import JSON52 from "json5";
1853
+ var ID3 = "opencode";
1854
+ var LABEL3 = "OpenCode";
1855
+ var DEFAULT_MODEL3 = "openai/gpt-5.4-nano";
1856
+ var PLUGIN_SPEC = "opencode-pollinations-plugin";
1857
+ var pollinationsConfigDir = (ctx) => {
1858
+ if (process.platform === "win32") {
1859
+ return join6(ctx.env.APPDATA ?? ctx.home, "pollinations");
1860
+ }
1861
+ if (process.platform === "darwin") {
1862
+ return join6(ctx.home, "Library", "Application Support", "pollinations");
1863
+ }
1864
+ const xdg = ctx.env.XDG_CONFIG_HOME?.trim();
1865
+ return join6(
1866
+ xdg ? resolveHomePath(ctx.home, xdg) : join6(ctx.home, ".config"),
1867
+ "pollinations"
1868
+ );
1869
+ };
1870
+ var opencodeConfigFile = (ctx) => {
1871
+ if (ctx.env.OPENCODE_CONFIG?.trim()) {
1872
+ return resolveHomePath(ctx.home, ctx.env.OPENCODE_CONFIG);
1873
+ }
1874
+ const dir = ctx.env.OPENCODE_CONFIG_DIR?.trim() ? resolveHomePath(ctx.home, ctx.env.OPENCODE_CONFIG_DIR) : join6(ctx.home, ".config", "opencode");
1875
+ return ["opencode.jsonc", "opencode.json", "config.json"].map((name) => join6(dir, name)).find((path) => readTextIfExists(path) !== null) ?? join6(dir, "opencode.json");
1876
+ };
1877
+ var pluginConfigFile = (ctx) => join6(pollinationsConfigDir(ctx), "config.json");
1878
+ var files3 = (ctx) => [
1879
+ opencodeConfigFile(ctx),
1880
+ pluginConfigFile(ctx)
1881
+ ];
1882
+ var readJson = (path) => {
1883
+ const text = readTextIfExists(path);
1884
+ if (text === null) return null;
1885
+ try {
1886
+ const parsed = JSON52.parse(text);
1887
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
1888
+ return parsed;
1889
+ }
1890
+ } catch (error) {
1891
+ throw new Error(`Could not parse OpenCode config at ${path}`, {
1892
+ cause: error
1893
+ });
1894
+ }
1895
+ throw new Error(`OpenCode config at ${path} must contain an object`);
1896
+ };
1897
+ var writeJson = (path, data) => writeTextAtomic(path, `${JSON.stringify(data, null, 2)}
1898
+ `, 384);
1899
+ var isPluginEntry = (entry) => typeof entry === "string" ? entry === PLUGIN_SPEC || entry.includes(PLUGIN_SPEC) : entry !== null && typeof entry === "object" && Object.values(entry).some(
1900
+ (value) => typeof value === "string" && value.includes(PLUGIN_SPEC)
1901
+ );
1902
+ var pluginListKey = (config) => Array.isArray(config.plugins) && !Array.isArray(config.plugin) ? "plugins" : "plugin";
1903
+ var hasPluginEntry = (config) => {
1904
+ const entries = config[pluginListKey(config)];
1905
+ return Array.isArray(entries) && entries.some(isPluginEntry);
1906
+ };
1907
+ var readApiKey = (ctx) => {
1908
+ const key = readJson(pluginConfigFile(ctx))?.apiKey;
1909
+ return typeof key === "string" && key.length > 5 ? key : null;
1910
+ };
1911
+ var writeApiKey = (ctx, apiKey) => {
1912
+ const config = readJson(pluginConfigFile(ctx)) ?? {};
1913
+ config.apiKey = apiKey;
1914
+ writeJson(pluginConfigFile(ctx), config);
1915
+ };
1916
+ var deleteApiKey = (ctx) => {
1917
+ const path = pluginConfigFile(ctx);
1918
+ const config = readJson(path);
1919
+ if (config === null || config.apiKey === void 0) return false;
1920
+ delete config.apiKey;
1921
+ if (Object.keys(config).length === 0) removeIfExists(path);
1922
+ else writeJson(path, config);
1923
+ return true;
1924
+ };
1925
+ var openCodeConfig = (ctx) => readJson(opencodeConfigFile(ctx)) ?? {};
1926
+ var defaultModelRef = (model) => `pollinations/enter/${model}`;
1927
+ var isOurDefaultModel = (model) => typeof model === "string" && model.startsWith("pollinations/enter/");
1928
+ var writeOpenCodeConfig = (ctx, model) => {
1929
+ const config = openCodeConfig(ctx);
1930
+ if (typeof config.$schema !== "string") {
1931
+ config.$schema = "https://opencode.ai/config.json";
1932
+ }
1933
+ if (!hasPluginEntry(config)) {
1934
+ const key = pluginListKey(config);
1935
+ const entries = Array.isArray(config[key]) ? config[key] : [];
1936
+ config[key] = [...entries, PLUGIN_SPEC];
1937
+ }
1938
+ config.model = defaultModelRef(model);
1939
+ writeJson(opencodeConfigFile(ctx), config);
1940
+ };
1941
+ var stripOpenCodeConfig = (ctx) => {
1942
+ const path = opencodeConfigFile(ctx);
1943
+ const config = readJson(path);
1944
+ if (config === null) return false;
1945
+ let changed = false;
1946
+ const key = pluginListKey(config);
1947
+ const entries = config[key];
1948
+ if (Array.isArray(entries) && entries.some(isPluginEntry)) {
1949
+ const filtered = entries.filter((entry) => !isPluginEntry(entry));
1950
+ if (filtered.length === 0) delete config[key];
1951
+ else config[key] = filtered;
1952
+ changed = true;
1953
+ }
1954
+ if (isOurDefaultModel(config.model)) {
1955
+ delete config.model;
1956
+ changed = true;
1957
+ }
1958
+ if (changed) writeJson(path, config);
1959
+ return changed;
1960
+ };
1961
+ var result3 = (ctx) => {
1962
+ const config = openCodeConfig(ctx);
1963
+ const model = isOurDefaultModel(config.model) ? config.model.slice("pollinations/enter/".length) : void 0;
1964
+ return {
1965
+ harness: ID3,
1966
+ label: LABEL3,
1967
+ configured: hasPluginEntry(config) && isOurDefaultModel(config.model) && readApiKey(ctx) !== null,
1968
+ model,
1969
+ files: files3(ctx)
1970
+ };
1971
+ };
1972
+ var writeConfig3 = (ctx, settings) => {
1973
+ writeOpenCodeConfig(ctx, settings.model);
1974
+ writeApiKey(ctx, settings.apiKey);
1975
+ };
1976
+ var stripConfig3 = (ctx) => {
1977
+ let changed = stripOpenCodeConfig(ctx);
1978
+ changed = deleteApiKey(ctx) || changed;
1979
+ return changed;
1980
+ };
1981
+ var configureOpenCode = (ctx, settings) => {
1982
+ applyWithSnapshot(ctx, ID3, files3(ctx), () => writeConfig3(ctx, settings));
1983
+ return result3(ctx);
1984
+ };
1985
+ var disableOpenCode = (ctx) => {
1986
+ const outcome = restoreOrStrip(ctx, ID3, files3(ctx), () => stripConfig3(ctx));
1987
+ return { ...result3(ctx), configured: false, outcome };
1988
+ };
1989
+ var openCodeInstalled = (ctx) => commandExists("opencode", ctx.env, [
1990
+ join6(ctx.home, ".opencode", "bin", "opencode")
1991
+ ]);
1992
+ var opencode = {
1993
+ id: ID3,
1994
+ label: LABEL3,
1995
+ description: "Configure OpenCode to use Pollinations",
1996
+ restartHint: "Restart OpenCode, then pick a Pollinations model with /models. Inside OpenCode: /poll quests shows claimable Pollen, /poll help lists the media tools.",
1997
+ async on(ctx, options) {
1998
+ if (!openCodeInstalled(ctx)) {
1999
+ throw new Error(
2000
+ "OpenCode was not found. Install it first: curl -fsSL https://opencode.ai/install | bash"
2001
+ );
2002
+ }
2003
+ const model = options.model ?? DEFAULT_MODEL3;
2004
+ await fetchHarnessModels(model);
2005
+ const apiKey = await resolveHarnessKey(
2006
+ {
2007
+ id: ID3,
2008
+ label: LABEL3,
2009
+ existingKey: readApiKey(ctx),
2010
+ accountPermissions: ["profile", "usage"]
2011
+ },
2012
+ { browser: options.browser }
2013
+ );
2014
+ return configureOpenCode(ctx, { apiKey, model });
2015
+ },
2016
+ off: disableOpenCode,
2017
+ status: result3
2018
+ };
2019
+
2020
+ // src/harnesses/pi.ts
2021
+ import { join as join7 } from "path";
2022
+ var ID4 = "pi";
2023
+ var LABEL4 = "Pi";
2024
+ var PROVIDER3 = "pollinations";
2025
+ var DEFAULT_MODEL4 = "deepseek/deepseek-v4-flash";
2026
+ var piAgentDir = (ctx) => {
2027
+ const configured = ctx.env.PI_CODING_AGENT_DIR;
2028
+ if (!configured?.trim()) return join7(ctx.home, ".pi", "agent");
2029
+ return resolveHomePath(ctx.home, configured);
2030
+ };
2031
+ var modelsPath = (ctx) => join7(piAgentDir(ctx), "models.json");
2032
+ var authPath = (ctx) => join7(piAgentDir(ctx), "auth.json");
2033
+ var settingsPath2 = (ctx) => join7(piAgentDir(ctx), "settings.json");
2034
+ var skillFile2 = (ctx) => join7(piAgentDir(ctx), "skills", "polli", "SKILL.md");
2035
+ var files4 = (ctx) => [
2036
+ modelsPath(ctx),
2037
+ authPath(ctx),
2038
+ settingsPath2(ctx),
2039
+ skillFile2(ctx)
2040
+ ];
2041
+ var loadJson2 = (path) => {
2042
+ const text = readTextIfExists(path);
2043
+ if (!text?.trim()) return {};
2044
+ return JSON.parse(text);
2045
+ };
2046
+ var saveJson2 = (path, data) => {
2047
+ writeTextAtomic(path, `${JSON.stringify(data, null, 2)}
2048
+ `, 384);
2049
+ };
2050
+ var readKey3 = (ctx) => {
2051
+ const auth = loadJson2(authPath(ctx));
2052
+ const entry = auth[PROVIDER3];
2053
+ if (!entry || typeof entry !== "object") return null;
2054
+ const key = entry.key;
2055
+ return typeof key === "string" && key ? key : null;
2056
+ };
2057
+ var providerConfig2 = (models2) => ({
2058
+ baseUrl: `${BASE_URL}/v1`,
2059
+ api: "openai-completions",
2060
+ compat: {
2061
+ supportsStore: false,
2062
+ supportsDeveloperRole: false,
2063
+ supportsReasoningEffort: true,
2064
+ supportsUsageInStreaming: true,
2065
+ supportsStrictMode: false,
2066
+ maxTokensField: "max_tokens"
2067
+ },
2068
+ models: models2.map((model) => ({
2069
+ id: model.id,
2070
+ name: model.id,
2071
+ contextWindow: model.contextWindow,
2072
+ input: model.input
2073
+ }))
2074
+ });
2075
+ var writeConfig4 = (ctx, settings) => {
2076
+ const modelsData = loadJson2(modelsPath(ctx));
2077
+ const providers = modelsData.providers ?? {};
2078
+ modelsData.providers = {
2079
+ ...providers,
2080
+ [PROVIDER3]: providerConfig2(settings.models)
2081
+ };
2082
+ saveJson2(modelsPath(ctx), modelsData);
2083
+ const auth = loadJson2(authPath(ctx));
2084
+ auth[PROVIDER3] = { type: "api_key", key: settings.apiKey };
2085
+ saveJson2(authPath(ctx), auth);
2086
+ const piSettings = loadJson2(settingsPath2(ctx));
2087
+ piSettings.defaultProvider = PROVIDER3;
2088
+ piSettings.defaultModel = settings.model;
2089
+ saveJson2(settingsPath2(ctx), piSettings);
2090
+ if (readTextIfExists(skillFile2(ctx)) === null) {
2091
+ writeTextAtomic(skillFile2(ctx), SKILL_default, 384);
2092
+ }
2093
+ };
2094
+ var stripConfig4 = (ctx) => {
2095
+ let changed = false;
2096
+ const modelsText = readTextIfExists(modelsPath(ctx));
2097
+ if (modelsText?.trim()) {
2098
+ const data = JSON.parse(modelsText);
2099
+ if (data.providers && typeof data.providers === "object" && PROVIDER3 in data.providers) {
2100
+ delete data.providers[PROVIDER3];
2101
+ saveJson2(modelsPath(ctx), data);
2102
+ changed = true;
2103
+ }
2104
+ }
2105
+ const authText = readTextIfExists(authPath(ctx));
2106
+ if (authText?.trim()) {
2107
+ const data = JSON.parse(authText);
2108
+ if (PROVIDER3 in data) {
2109
+ delete data[PROVIDER3];
2110
+ saveJson2(authPath(ctx), data);
2111
+ changed = true;
2112
+ }
2113
+ }
2114
+ const settingsText = readTextIfExists(settingsPath2(ctx));
2115
+ if (settingsText?.trim()) {
2116
+ const data = JSON.parse(settingsText);
2117
+ if (data.defaultProvider === PROVIDER3) {
2118
+ delete data.defaultProvider;
2119
+ delete data.defaultModel;
2120
+ saveJson2(settingsPath2(ctx), data);
2121
+ changed = true;
2122
+ }
2123
+ }
2124
+ if (readTextIfExists(skillFile2(ctx)) === SKILL_default) {
2125
+ removeIfExists(skillFile2(ctx));
2126
+ changed = true;
2127
+ }
2128
+ return changed;
2129
+ };
2130
+ var result4 = (ctx) => {
2131
+ const modelsData = loadJson2(modelsPath(ctx));
2132
+ const authData = loadJson2(authPath(ctx));
2133
+ const settingsData = loadJson2(settingsPath2(ctx));
2134
+ const providers = modelsData.providers;
2135
+ const provider = providers?.[PROVIDER3];
2136
+ const hasProvider = provider?.baseUrl === `${BASE_URL}/v1` && provider?.api === "openai-completions";
2137
+ const authEntry = authData[PROVIDER3];
2138
+ const hasKey = authEntry?.type === "api_key" && typeof authEntry.key === "string" && !!authEntry.key;
2139
+ const hasDefaultProvider = settingsData.defaultProvider === PROVIDER3;
2140
+ const model = typeof settingsData.defaultModel === "string" ? settingsData.defaultModel : void 0;
2141
+ return {
2142
+ harness: ID4,
2143
+ label: LABEL4,
2144
+ configured: hasProvider && hasKey && hasDefaultProvider && readTextIfExists(skillFile2(ctx)) !== null,
2145
+ model,
2146
+ files: files4(ctx)
2147
+ };
2148
+ };
2149
+ var configurePi = (ctx, settings) => {
2150
+ applyWithSnapshot(ctx, ID4, files4(ctx), () => writeConfig4(ctx, settings));
2151
+ return result4(ctx);
2152
+ };
2153
+ var disablePi = (ctx) => {
2154
+ const outcome = restoreOrStrip(ctx, ID4, files4(ctx), () => stripConfig4(ctx));
2155
+ return { ...result4(ctx), configured: false, outcome };
2156
+ };
2157
+ var pi = {
2158
+ id: ID4,
2159
+ label: LABEL4,
2160
+ description: "Configure Pi as a Pollinations provider",
2161
+ restartHint: "Changes apply on the next Pi session. Start Pi with: pi",
2162
+ async on(ctx, options) {
2163
+ if (!commandExists("pi", ctx.env)) {
2164
+ throw new Error(
2165
+ "Pi was not found. Install it first: npm install -g --ignore-scripts @earendil-works/pi-coding-agent"
2166
+ );
2167
+ }
2168
+ const model = options.model ?? DEFAULT_MODEL4;
2169
+ const models2 = await fetchHarnessModels(model);
2170
+ const apiKey = await resolveHarnessKey(
2171
+ { id: ID4, label: LABEL4, existingKey: readKey3(ctx) },
2172
+ { browser: options.browser }
2173
+ );
2174
+ return configurePi(ctx, { apiKey, model, models: models2 });
2175
+ },
2176
+ off: disablePi,
2177
+ status: result4
2178
+ };
2179
+
2180
+ // src/harnesses/prime.ts
2181
+ import { join as join8 } from "path";
2182
+ var ID5 = "prime";
2183
+ var LABEL5 = "Prime Agent";
2184
+ var PROVIDER4 = "pollinations";
2185
+ var DEFAULT_MODEL5 = "deepseek/deepseek-v4-flash";
2186
+ var primeAgentDir = (ctx) => {
2187
+ const configured = ctx.env.PRIME_AGENT_CODING_AGENT_DIR;
2188
+ if (!configured?.trim()) return join8(ctx.home, ".prime", "agent");
2189
+ return resolveHomePath(ctx.home, configured);
2190
+ };
2191
+ var modelsPath2 = (ctx) => join8(primeAgentDir(ctx), "models.json");
2192
+ var authPath2 = (ctx) => join8(primeAgentDir(ctx), "auth.json");
2193
+ var settingsPath3 = (ctx) => join8(primeAgentDir(ctx), "settings.json");
2194
+ var skillPath2 = (ctx) => join8(primeAgentDir(ctx), "skills", "polli", "SKILL.md");
2195
+ var files5 = (ctx) => [
2196
+ modelsPath2(ctx),
2197
+ authPath2(ctx),
2198
+ settingsPath3(ctx),
2199
+ skillPath2(ctx)
2200
+ ];
2201
+ var loadJson3 = (path) => {
2202
+ const text = readTextIfExists(path);
2203
+ if (!text?.trim()) return {};
2204
+ return JSON.parse(text);
2205
+ };
2206
+ var saveJson3 = (path, data) => {
2207
+ writeTextAtomic(path, `${JSON.stringify(data, null, 2)}
2208
+ `, 384);
2209
+ };
2210
+ var compat = {
2211
+ supportsStore: false,
2212
+ supportsDeveloperRole: false,
2213
+ supportsReasoningEffort: true,
2214
+ supportsUsageInStreaming: true,
2215
+ supportsStrictMode: false,
2216
+ maxTokensField: "max_tokens"
2217
+ };
2218
+ var providerEntry2 = (models2) => ({
2219
+ baseUrl: `${BASE_URL}/v1`,
2220
+ api: "openai-completions",
2221
+ // Prime validates custom providers before resolving their auth.json entry.
2222
+ apiKey: PROVIDER4,
2223
+ compat,
2224
+ models: models2.map((model) => ({
2225
+ id: model.id,
2226
+ name: model.id,
2227
+ input: model.input,
2228
+ contextWindow: model.contextWindow
2229
+ }))
2230
+ });
2231
+ var readKey4 = (ctx) => {
2232
+ const auth = loadJson3(authPath2(ctx));
2233
+ const credential = auth[PROVIDER4];
2234
+ return credential?.type === "api_key" && credential.key ? credential.key : null;
2235
+ };
2236
+ var writeAuth = (ctx, apiKey) => {
2237
+ const auth = loadJson3(authPath2(ctx));
2238
+ auth[PROVIDER4] = { type: "api_key", key: apiKey };
2239
+ saveJson3(authPath2(ctx), auth);
2240
+ };
2241
+ var deleteAuth = (ctx) => {
2242
+ const auth = loadJson3(authPath2(ctx));
2243
+ if (!(PROVIDER4 in auth)) return false;
2244
+ delete auth[PROVIDER4];
2245
+ if (Object.keys(auth).length === 0) removeIfExists(authPath2(ctx));
2246
+ else saveJson3(authPath2(ctx), auth);
2247
+ return true;
2248
+ };
2249
+ var writeConfig5 = (ctx, models2, apiKey, model) => {
2250
+ const doc = loadJson3(modelsPath2(ctx));
2251
+ const providers = doc.providers ?? {};
2252
+ providers[PROVIDER4] = providerEntry2(models2);
2253
+ doc.providers = providers;
2254
+ saveJson3(modelsPath2(ctx), doc);
2255
+ writeAuth(ctx, apiKey);
2256
+ const settings = loadJson3(settingsPath3(ctx));
2257
+ settings.defaultProvider = PROVIDER4;
2258
+ settings.defaultModel = model;
2259
+ saveJson3(settingsPath3(ctx), settings);
2260
+ if (readTextIfExists(skillPath2(ctx)) === null) {
2261
+ writeTextAtomic(skillPath2(ctx), SKILL_default, 384);
2262
+ }
2263
+ };
2264
+ var stripConfig5 = (ctx) => {
2265
+ let changed = false;
2266
+ const doc = loadJson3(modelsPath2(ctx));
2267
+ if (doc?.providers && PROVIDER4 in doc.providers) {
2268
+ delete doc.providers[PROVIDER4];
2269
+ if (Object.keys(doc.providers).length === 0) delete doc.providers;
2270
+ saveJson3(modelsPath2(ctx), doc);
2271
+ changed = true;
2272
+ }
2273
+ changed = deleteAuth(ctx) || changed;
2274
+ const settings = loadJson3(settingsPath3(ctx));
2275
+ if (settings && settings.defaultProvider === PROVIDER4) {
2276
+ delete settings.defaultProvider;
2277
+ delete settings.defaultModel;
2278
+ saveJson3(settingsPath3(ctx), settings);
2279
+ changed = true;
2280
+ }
2281
+ if (readTextIfExists(skillPath2(ctx)) === SKILL_default) {
2282
+ removeIfExists(skillPath2(ctx));
2283
+ changed = true;
2284
+ }
2285
+ return changed;
2286
+ };
2287
+ var result5 = (ctx) => {
2288
+ const doc = loadJson3(modelsPath2(ctx));
2289
+ const provider = doc?.providers?.[PROVIDER4];
2290
+ const settings = loadJson3(settingsPath3(ctx));
2291
+ const model = settings?.defaultProvider === PROVIDER4 ? settings.defaultModel : void 0;
2292
+ return {
2293
+ harness: ID5,
2294
+ label: LABEL5,
2295
+ configured: provider?.baseUrl === `${BASE_URL}/v1` && provider?.api === "openai-completions" && provider?.apiKey === PROVIDER4 && readKey4(ctx) !== null && readTextIfExists(skillPath2(ctx)) !== null,
2296
+ model: typeof model === "string" ? model : void 0,
2297
+ files: files5(ctx)
2298
+ };
2299
+ };
2300
+ var configurePrime = (ctx, models2, apiKey, model) => {
2301
+ applyWithSnapshot(
2302
+ ctx,
2303
+ ID5,
2304
+ files5(ctx),
2305
+ () => writeConfig5(ctx, models2, apiKey, model)
2306
+ );
2307
+ return result5(ctx);
2308
+ };
2309
+ var disablePrime = (ctx) => {
2310
+ const outcome = restoreOrStrip(ctx, ID5, files5(ctx), () => stripConfig5(ctx));
2311
+ return { ...result5(ctx), configured: false, outcome };
2312
+ };
2313
+ var prime = {
2314
+ id: ID5,
2315
+ label: LABEL5,
2316
+ description: "Add Pollinations as a custom provider in Prime Agent",
2317
+ restartHint: "Models reload when you open /model. Start Prime Agent with: prime-agent",
2318
+ async on(ctx, options) {
2319
+ if (!commandExists("prime-agent", ctx.env)) {
2320
+ throw new Error(
2321
+ "Prime Agent was not found. Install it first: curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh"
2322
+ );
2323
+ }
2324
+ const model = options.model ?? DEFAULT_MODEL5;
2325
+ const models2 = await fetchHarnessModels(model);
2326
+ const apiKey = await resolveHarnessKey(
2327
+ { id: ID5, label: LABEL5, existingKey: readKey4(ctx) },
2328
+ { browser: options.browser }
2329
+ );
2330
+ return configurePrime(ctx, models2, apiKey, model);
2331
+ },
2332
+ off: disablePrime,
2333
+ status: result5
2334
+ };
2335
+
1656
2336
  // src/harnesses/index.ts
1657
- var HARNESSES = [dsh];
2337
+ var HARNESSES = [dsh, opencode, openclaw, pi, prime];
1658
2338
 
1659
2339
  // src/commands/harness.ts
1660
2340
  var context = () => ({ home: homedir2(), env: process.env });
@@ -1665,22 +2345,22 @@ var OFF_MESSAGES = {
1665
2345
  };
1666
2346
  var runOn = async (harness, options) => {
1667
2347
  try {
1668
- const result2 = await harness.on(context(), options);
1669
- const model = result2.model ? ` (model: ${result2.model})` : "";
2348
+ const result6 = await harness.on(context(), options);
2349
+ const model = result6.model ? ` (model: ${result6.model})` : "";
1670
2350
  printSuccess(`${harness.label} now uses Pollinations${model}.`);
1671
2351
  printInfo(harness.restartHint);
1672
- printResult(result2);
2352
+ printResult(result6);
1673
2353
  } catch (error) {
1674
2354
  fail(`Failed to connect ${harness.label}`, error);
1675
2355
  }
1676
2356
  };
1677
2357
  var runOff = async (harness) => {
1678
2358
  try {
1679
- const result2 = await harness.off(context());
1680
- const outcome = result2.outcome ?? "unchanged";
2359
+ const result6 = await harness.off(context());
2360
+ const outcome = result6.outcome ?? "unchanged";
1681
2361
  printSuccess(`${harness.label}: ${OFF_MESSAGES[outcome]}`);
1682
2362
  if (outcome !== "unchanged") printInfo(harness.restartHint);
1683
- printResult(result2);
2363
+ printResult(result6);
1684
2364
  } catch (error) {
1685
2365
  fail(`Failed to disconnect ${harness.label}`, error);
1686
2366
  }
@@ -2063,7 +2743,8 @@ var PRICE_FLAGS = [
2063
2743
  [
2064
2744
  "--completion-image-price <number>",
2065
2745
  "Generated-image price (per image when --image-pricing request; per token when --image-pricing tokens)"
2066
- ]
2746
+ ],
2747
+ ["--completion-video-price <number>", "Generated-video price per second"]
2067
2748
  ];
2068
2749
  var PRICE_OPTION_KEYS = [
2069
2750
  "promptTextPrice",
@@ -2074,7 +2755,8 @@ var PRICE_OPTION_KEYS = [
2074
2755
  "completionTextPrice",
2075
2756
  "completionReasoningPrice",
2076
2757
  "completionAudioPrice",
2077
- "completionImagePrice"
2758
+ "completionImagePrice",
2759
+ "completionVideoPrice"
2078
2760
  ];
2079
2761
  function addPriceOptions(command) {
2080
2762
  for (const [flag, description] of PRICE_FLAGS) {
@@ -2096,13 +2778,35 @@ function readPriceOptions(opts) {
2096
2778
  }
2097
2779
  return prices;
2098
2780
  }
2781
+ function commaSeparatedList(value) {
2782
+ return String(value).split(",").map((item) => item.trim()).filter(Boolean);
2783
+ }
2784
+ function endpointTarget(opts, required) {
2785
+ if (opts.api !== void 0 || opts.url !== void 0 || required && (opts.modality ?? "text") === "text") {
2786
+ if (opts.baseUrl !== void 0) {
2787
+ fail("Text endpoints use --api and --url; omit --base-url");
2788
+ }
2789
+ if (opts.modality !== void 0 && opts.modality !== "text") {
2790
+ fail("--api and --url are only supported for text endpoints");
2791
+ }
2792
+ if (opts.api !== "chat_completions" && opts.api !== "responses") {
2793
+ fail("--api must be 'chat_completions' or 'responses'");
2794
+ }
2795
+ if (!opts.url) fail("--api and --url must be provided together");
2796
+ return { api: opts.api, url: opts.url };
2797
+ }
2798
+ if (required && !opts.baseUrl) fail("--base-url is required for media");
2799
+ return opts.baseUrl !== void 0 ? { baseUrl: opts.baseUrl } : {};
2800
+ }
2099
2801
  function modelBody(opts, includeRequired) {
2100
- const body = readPriceOptions(opts);
2802
+ const body = {
2803
+ ...readPriceOptions(opts),
2804
+ ...endpointTarget(opts, includeRequired)
2805
+ };
2101
2806
  const fields = [
2102
2807
  ["name", "name"],
2103
2808
  ["title", "title"],
2104
2809
  ["description", "description"],
2105
- ["baseUrl", "baseUrl"],
2106
2810
  ["upstreamModel", "upstreamModel"],
2107
2811
  ["bearerToken", "bearerToken"],
2108
2812
  ["paidOnly", "paidOnly"]
@@ -2117,8 +2821,10 @@ function modelBody(opts, includeRequired) {
2117
2821
  body.visibility = opts.visibility;
2118
2822
  }
2119
2823
  if (includeRequired && opts.modality !== void 0) {
2120
- if (opts.modality !== "text" && opts.modality !== "image" && opts.modality !== "transcription") {
2121
- fail("--modality must be 'text', 'image', or 'transcription'");
2824
+ if (opts.modality !== "text" && opts.modality !== "image" && opts.modality !== "video" && opts.modality !== "transcription" && opts.modality !== "speech" && opts.modality !== "embedding") {
2825
+ fail(
2826
+ "--modality must be 'text', 'image', 'video', 'transcription', 'speech', or 'embedding'"
2827
+ );
2122
2828
  }
2123
2829
  body.modality = opts.modality;
2124
2830
  }
@@ -2129,10 +2835,13 @@ function modelBody(opts, includeRequired) {
2129
2835
  body.imagePricing = opts.imagePricing;
2130
2836
  }
2131
2837
  if (opts.fallbacks !== void 0) {
2132
- body.fallbacks = String(opts.fallbacks).split(",").map((id) => id.trim()).filter((id) => id.length > 0);
2838
+ body.fallbacks = commaSeparatedList(opts.fallbacks);
2133
2839
  }
2134
2840
  if (opts.inputModalities !== void 0) {
2135
- body.inputModalities = String(opts.inputModalities).split(",").map((modality) => modality.trim()).filter((modality) => modality.length > 0);
2841
+ body.inputModalities = commaSeparatedList(opts.inputModalities);
2842
+ }
2843
+ if (opts.requiredSafety !== void 0) {
2844
+ body.requiredSafetyFeatures = String(opts.requiredSafety).trim() === "none" ? [] : commaSeparatedList(opts.requiredSafety);
2136
2845
  }
2137
2846
  if (includeRequired) {
2138
2847
  for (const required of ["name", "title"]) {
@@ -2142,7 +2851,6 @@ function modelBody(opts, includeRequired) {
2142
2851
  );
2143
2852
  }
2144
2853
  }
2145
- if (!body.baseUrl) fail("--base-url is required");
2146
2854
  if (!body.bearerToken) fail("--bearer-token is required");
2147
2855
  }
2148
2856
  return body;
@@ -2162,10 +2870,12 @@ function printModels(models2) {
2162
2870
  // Price and billing mode read as one unit, so they share a cell
2163
2871
  // rather than widening an already wide table by two columns.
2164
2872
  image_price: model.type === "proxy" && model.modality === "image" ? `${model.completionImagePrice}/${model.imagePricing === "tokens" ? "token" : "req"}` : "-",
2873
+ video_price: model.type === "proxy" && model.modality === "video" ? `${model.completionVideoPrice}/sec` : "-",
2165
2874
  inputs: model.type === "proxy" ? model.inputModalities?.join(", ") || "-" : "-",
2166
2875
  visibility: model.type === "proxy" && model.paidOnly ? `${model.visibility} (paid only)` : model.visibility,
2167
- upstream: model.upstreamModel,
2168
- base_url: model.baseUrl,
2876
+ upstream: model.type === "proxy" && model.modality === "video" ? "-" : model.upstreamModel ?? "-",
2877
+ api: model.type === "prompt_agent" ? "responses" : model.api ?? "-",
2878
+ endpoint: model.url ?? model.baseUrl ?? "-",
2169
2879
  fallbacks: model.type === "proxy" ? model.fallbacks?.join(", ") || "-" : "-",
2170
2880
  description: model.description ?? "-"
2171
2881
  })),
@@ -2176,10 +2886,12 @@ function printModels(models2) {
2176
2886
  "type",
2177
2887
  "modality",
2178
2888
  "image_price",
2889
+ "video_price",
2179
2890
  "inputs",
2180
2891
  "visibility",
2181
2892
  "upstream",
2182
- "base_url",
2893
+ "api",
2894
+ "endpoint",
2183
2895
  "fallbacks",
2184
2896
  "description"
2185
2897
  ]
@@ -2197,7 +2909,16 @@ var list3 = new Command15("list").description("List models owned by your account
2197
2909
  }
2198
2910
  });
2199
2911
  var create3 = addPriceOptions(
2200
- new Command15("create").description("Register an OpenAI-compatible model endpoint").requiredOption("--name <name>", "Model name").requiredOption("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option("--base-url <url>", "OpenAI-compatible base URL").option("--upstream-model <model>", "Upstream model id").option("--bearer-token <token>", "Upstream bearer token").option(
2912
+ new Command15("create").description("Register a community model endpoint").requiredOption("--name <name>", "Model name").requiredOption("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option(
2913
+ "--base-url <url>",
2914
+ "Media API base URL, or exact video endpoint URL"
2915
+ ).option(
2916
+ "--api <api>",
2917
+ "Text upstream API: chat_completions or responses"
2918
+ ).option("--url <url>", "Exact text endpoint URL for the selected API").option(
2919
+ "--upstream-model <model>",
2920
+ "Upstream model id (not used for video)"
2921
+ ).option("--bearer-token <token>", "Upstream bearer token").option(
2201
2922
  "--visibility <visibility>",
2202
2923
  "Model visibility: private (default) or public"
2203
2924
  ).option(
@@ -2209,9 +2930,12 @@ var create3 = addPriceOptions(
2209
2930
  ).option(
2210
2931
  "--input-modalities <types>",
2211
2932
  "Comma-separated accepted inputs: text,image,audio,video"
2933
+ ).option(
2934
+ "--required-safety <features>",
2935
+ "Comma-separated required checks: privacy,secrets,sexual,violence,shield; none clears them"
2212
2936
  ).option(
2213
2937
  "--modality <modality>",
2214
- "Model family: text (default), image, or transcription"
2938
+ "Model family: text (default), image, video, transcription, or embedding"
2215
2939
  ).option(
2216
2940
  "--image-pricing <mode>",
2217
2941
  "Image billing: request (per image, default) or tokens"
@@ -2234,7 +2958,16 @@ var create3 = addPriceOptions(
2234
2958
  }
2235
2959
  });
2236
2960
  var update2 = addPriceOptions(
2237
- new Command15("update").description("Update one of your models").argument("<id>", "Model id").option("--name <name>", "Model name").option("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option("--base-url <url>", "OpenAI-compatible base URL").option("--upstream-model <model>", "Upstream model id").option("--bearer-token <token>", "Upstream bearer token").option(
2961
+ new Command15("update").description("Update one of your models").argument("<id>", "Model id").option("--name <name>", "Model name").option("--title <title>", "Display title shown in the catalog").option("--description <text>", "Model description").option(
2962
+ "--base-url <url>",
2963
+ "Media API base URL, or exact video endpoint URL"
2964
+ ).option(
2965
+ "--api <api>",
2966
+ "Text upstream API: chat_completions or responses (requires --url)"
2967
+ ).option("--url <url>", "Exact text endpoint URL (requires --api)").option(
2968
+ "--upstream-model <model>",
2969
+ "Upstream model id (not used for video)"
2970
+ ).option("--bearer-token <token>", "Upstream bearer token").option(
2238
2971
  "--visibility <visibility>",
2239
2972
  "Model visibility: private or public"
2240
2973
  ).option(
@@ -2246,6 +2979,9 @@ var update2 = addPriceOptions(
2246
2979
  ).option(
2247
2980
  "--input-modalities <types>",
2248
2981
  "Comma-separated accepted inputs: text,image,audio,video"
2982
+ ).option(
2983
+ "--required-safety <features>",
2984
+ "Comma-separated required checks: privacy,secrets,sexual,violence,shield; none clears them"
2249
2985
  ).option(
2250
2986
  "--image-pricing <mode>",
2251
2987
  "Image billing: request (per image) or tokens"
@@ -2311,13 +3047,23 @@ var models = new Command15("models").description("List upstream models from an e
2311
3047
  fail("Failed to fetch upstream models", err);
2312
3048
  }
2313
3049
  });
2314
- var test = new Command15("test").description("Test an endpoint/model before registering it").requiredOption("--base-url <url>", "OpenAI-compatible base URL").requiredOption("--bearer-token <token>", "Upstream bearer token").requiredOption("--model <model>", "Upstream model id").option(
3050
+ var test = new Command15("test").description("Test an endpoint/model before registering it").option(
3051
+ "--base-url <url>",
3052
+ "Media API base URL, or exact video endpoint URL"
3053
+ ).option("--api <api>", "Text upstream API: chat_completions or responses").option("--url <url>", "Exact text endpoint URL for the selected API").requiredOption("--bearer-token <token>", "Upstream bearer token").option("--model <model>", "Upstream model id (not used for video)").option(
2315
3054
  "--modality <modality>",
2316
- "Model family: text (default), image, or transcription"
3055
+ "Model family: text (default), image, video, transcription, or embedding"
2317
3056
  ).action(async (opts) => {
2318
3057
  const key = requireKey();
2319
- if (opts.modality !== void 0 && opts.modality !== "text" && opts.modality !== "image" && opts.modality !== "transcription") {
2320
- fail("--modality must be 'text', 'image', or 'transcription'");
3058
+ if (opts.modality !== void 0 && opts.modality !== "text" && opts.modality !== "image" && opts.modality !== "video" && opts.modality !== "transcription" && opts.modality !== "speech" && opts.modality !== "embedding") {
3059
+ fail(
3060
+ "--modality must be 'text', 'image', 'video', 'transcription', 'speech', or 'embedding'"
3061
+ );
3062
+ }
3063
+ const modality = opts.modality ?? "text";
3064
+ const target = endpointTarget(opts, true);
3065
+ if (modality !== "video" && !opts.model) {
3066
+ fail("--model is required unless --modality is video");
2321
3067
  }
2322
3068
  try {
2323
3069
  const res = await gen(
@@ -2326,12 +3072,10 @@ var test = new Command15("test").description("Test an endpoint/model before regi
2326
3072
  apiKey: key,
2327
3073
  method: "POST",
2328
3074
  body: {
2329
- baseUrl: opts.baseUrl,
3075
+ ...target,
2330
3076
  bearerToken: opts.bearerToken,
2331
- model: opts.model,
2332
- ...opts.modality !== void 0 && {
2333
- modality: opts.modality
2334
- }
3077
+ ...opts.model && { model: opts.model },
3078
+ modality
2335
3079
  }
2336
3080
  }
2337
3081
  );
@@ -2341,7 +3085,7 @@ var test = new Command15("test").description("Test an endpoint/model before regi
2341
3085
  }
2342
3086
  });
2343
3087
  var myModelsCommand = new Command15("my-models").description(
2344
- "Manage private and published community text, image, and transcription models"
3088
+ "Manage private and published community text, image, video, transcription, and embedding models"
2345
3089
  ).addCommand(list3).addCommand(create3).addCommand(update2).addCommand(remove2).addCommand(models).addCommand(test);
2346
3090
 
2347
3091
  // src/commands/quests.ts