Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "coreinfra-media",
"source": "./plugins/coreinfra-media",
"description": "Generate video, synthesize speech and transcribe audio through CoreInfra Wizard."
"description": "Generate video and images, synthesize speech and transcribe audio through CoreInfra Wizard."
}
]
}
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ An application for configuring agents to use CoreInfra.

## Media in ChatGPT Work, Codex and Claude Code

Enable **Подключить `coreinfra-media` для видео, озвучки и распознавания речи** under **Дополнительные модели** on the agent’s page and apply the change. One switch connects video generation, speech synthesis (TTS) and transcription (STT). Ask for a video, a voiceover or a transcript in a new ChatGPT Work or Codex chat, or invoke `$coreinfra-video`, `$coreinfra-speech` or `$coreinfra-transcription`.
Enable **Подключить `coreinfra-media` для видео, изображений, озвучки и распознавания речи** under **Дополнительные модели** on the agent’s page and apply the change. One switch connects video generation, image generation, speech synthesis (TTS) and transcription (STT). Ask for a video, an image, a voiceover or a transcript in a new ChatGPT Work or Codex chat, or invoke `$coreinfra-video`, `$coreinfra-image`, `$coreinfra-speech` or `$coreinfra-transcription`.

The three bundled skills and the `coreinfra_media` MCP registration live in the profile selected by `CODEX_HOME`. The Wizard user daemon listens at `http://127.0.0.1:33789/mcp` and uses a separate local bearer for each enabled agent. Turning the switch off on the ChatGPT / Codex page revokes local access and removes the managed registration and unmodified skill files. The opt-out persists across restarts.
The four bundled skills and the `coreinfra_media` MCP registration live in the profile selected by `CODEX_HOME`. The Wizard user daemon listens at `http://127.0.0.1:33789/mcp` and uses a separate local bearer for each enabled agent. Turning the switch off on the ChatGPT / Codex page revokes local access and removes the managed registration and unmodified skill files. The opt-out persists across restarts.

Upgrading from Wizard 1.0.10: existing `coreinfra_video` registrations, skills and local grants are migrated to `coreinfra_media` on the next **Применить**, preserving Codex server restrictions, Claude Desktop `toolPolicy` rules and opt-out state. The legacy `--video-mcp-stdio` flag is still accepted. If you added custom `mcp__coreinfra_video__*` permission rules in Claude Code settings, update them to `mcp__coreinfra_media__*`.

Each paid request uses the calling agent’s active CoreInfra key, cached in memory on startup and after applying settings. Media tools do not issue keys or use the selected Wizard account. Wizard keeps no job table or MCP session. All files are written to **Downloads/CoreInfra Media**; callers cannot choose the path. Repeating a paid submission after a network timeout can incur another charge, so the tools never retry it automatically.

### Video

`video_models` returns the public catalog and prices in RUB per second. `video_create` submits one paid job. Save the full returned `job` object and pass it to `video_result` to poll, including after restarting Wizard. The original Hub and key must still be available. A completed download returns a local MP4 in **Downloads/CoreInfra Media**. Use `download: false` to poll without creating a file. fal also returns its signed result URL in this mode. A job records the key fingerprint, provider, model and upstream ID; polling with a different key is rejected.
`video_models` returns the public catalog, prices in RUB per second and `output_dir`. `video_create` submits one paid job. For image-to-video, put a PNG, JPEG, WebP or GIF (up to 24 MiB) in **Downloads/CoreInfra Media** and pass its path in `image_path`, or pass inline data URIs via `fields`. Save the full returned `job` object and pass it to `video_result` to poll, including after restarting Wizard. The original Hub and key must still be available. A completed download returns a local MP4 in **Downloads/CoreInfra Media**. Use `download: false` to poll without creating a file. fal also returns its signed result URL in this mode. A job records the key fingerprint, provider, model and upstream ID; polling with a different key is rejected.

### Speech

Expand All @@ -32,13 +32,12 @@ Each paid request uses the calling agent’s active CoreInfra key, cached in mem

### Transcription

`transcription_models` lists models with RUB per minute. `transcription_create` accepts audio only inline as raw base64 in `audio_base64` with its container in `format` (`wav`, `mp3`, `flac`, `m4a`, `ogg`, `webm`, `aac`). Wizard never reads files from disk for the agent; the agent encodes the file itself. Keep the audio under about 24 MiB so the request stays within 32 MiB. The result is the Hub JSON (`text`, optional `segments`/`words`, and `usage.cost_rub`) for `response_format` `json` or `verbose_json`.
`transcription_models` lists models with RUB per minute and `output_dir`. `transcription_create` reads an audio file from **Downloads/CoreInfra Media** via `audio_path` (absolute or relative to that folder; `format` is optional when the filename extension names it) or accepts inline base64 in `audio_base64` with its container in `format` (`wav`, `mp3`, `flac`, `m4a`, `ogg`, `webm`, `aac`). Wizard reads only that folder. Keep the audio under about 24 MiB. The result is the Hub JSON (`text`, optional `segments`/`words`, and `usage.cost_rub`) for `response_format` `json` or `verbose_json`.

```json
{
"model": "openai/whisper-large-v3-turbo",
"audio_base64": "<base64 of the recording>",
"format": "m4a",
"audio_path": "meeting.m4a",
"language": "ru",
"response_format": "verbose_json",
"fields": { "temperature": 0 }
Expand All @@ -47,19 +46,31 @@ Each paid request uses the calling agent’s active CoreInfra key, cached in mem

[OpenRouter speech](https://coreinfra.ru/docs/reference/openrouter/audio-speech) · [OpenRouter transcription](https://coreinfra.ru/docs/reference/openrouter/audio-transcriptions)

### Images

`image_models` lists the Hub image models with a RUB-per-image price range and names the folder where images are saved. The read is free and needs no key. `image_create` makes one paid request, billed per image, and returns `{images: [{path, content_type, size_bytes}], usage}`. It takes `model`, `prompt` and `n` (1 to 4 variants of one prompt, each billed), model options such as `aspect_ratio`, `size`, `quality` and `output_format` in `fields` or `fields_json`, and reference pictures in `reference_paths` or `references`. One file per image is saved as `image-<random>.<ext>` in **Downloads/CoreInfra Media**; the location cannot be chosen, and no image is returned inline.

Hub image generation is billed, while the image generation of the user’s subscription is not. The Hub tools therefore stay below the image tool a client already has. When the client generates images through the user’s plan, use them only for an image the user asks from CoreInfra or Hub, a named Hub image model, or Hub image models and prices. If the client’s own tool fails or refuses, the agent says what the Hub can do and waits for the user’s yes. Where the client has no image tool of its own (Claude Code, Claude Desktop, Codex in «API-доступ»), a plain image request uses the Hub tool. The rule is wording only: every agent and mode gets it in the tool description, and each skill text repeats it.

To edit, put the reference pictures in **Downloads/CoreInfra Media** and pass their paths in `reference_paths`, absolute or relative to that folder; the agent may copy a picture there itself. Small pictures can also go inline in `references` as `data:image/...;base64,...` URIs. References must be PNG, JPEG, WebP or GIF and take at most about 24 MiB together. Wizard reads only that folder.

A call may block for minutes: Wizard gives up 180 s after each Hub request it makes, and a generation that takes longer may be billed and is not saved. The agent is then told that the outcome is uncertain and must not submit again automatically.

[OpenRouter image API](https://coreinfra.ru/docs/reference/openrouter/images)

### Claude Code

In Wizard choose **Claude Code → API-доступ → Применить** and confirm the configuration plan. Start a new local Claude Code session and ask «Какие видеомодели доступны?», «Озвучь этот абзац» or «Расшифруй запись», or invoke `/coreinfra-video`, `/coreinfra-speech` or `/coreinfra-transcription`. Wizard can be closed after configuration. The CLI routing command applies the same configuration.
In Wizard choose **Claude Code → API-доступ → Применить** and confirm the configuration plan. Start a new local Claude Code session and ask «Какие видеомодели доступны?», «Какие модели генерации изображений есть в CoreInfra?», «Озвучь этот абзац» or «Расшифруй запись», or invoke `/coreinfra-video`, `/coreinfra-image`, `/coreinfra-speech` or `/coreinfra-transcription`. Wizard can be closed after configuration. The CLI routing command applies the same configuration.

Wizard installs the bundled skills under `~/.claude/skills/coreinfra-video`, `~/.claude/skills/coreinfra-speech` and `~/.claude/skills/coreinfra-transcription` and registers the HTTP MCP server `coreinfra_media` in the user’s `~/.claude.json`. Both locations follow `CLAUDE_CONFIG_DIR` when set. Claude Code reads the current local bearer through its native `headersHelper`. Enable the media switch separately for Claude Code; the registration stays active across routing modes while enabled. Disabling the media switch revokes its bearer and removes its headers file, managed MCP entry and unmodified skills without affecting Codex or Claude Desktop.
Wizard installs the bundled skills under `~/.claude/skills/coreinfra-video`, `~/.claude/skills/coreinfra-image`, `~/.claude/skills/coreinfra-speech` and `~/.claude/skills/coreinfra-transcription` and registers the HTTP MCP server `coreinfra_media` in the user’s `~/.claude.json`. Both locations follow `CLAUDE_CONFIG_DIR` when set. Claude Code reads the current local bearer through its native `headersHelper`. Wizard sets `timeout: 240000` on its own `coreinfra_media` entry and leaves any value it finds; a server’s `timeout` takes precedence over `MCP_TOOL_TIMEOUT`, so edit it in `~/.claude.json` to give media calls more time. Enable the media switch separately for Claude Code; the registration stays active across routing modes while enabled. Disabling the media switch revokes its bearer and removes its headers file, managed MCP entry and unmodified skills without affecting Codex or Claude Desktop.

### Claude Desktop

In Hub mode, Wizard configures a gateway credential helper for Claude Desktop. The helper and the media daemon read the selected key from the same per-profile Wizard file (mode `0600` on Unix). The Claude profile holds the helper path, profile ID and key fingerprint. If an older profile has a sealed static key, select the intended Hub key on Wizard’s Claude Desktop page and click **Применить** once after updating Wizard. Subsequent daemon restarts reload that key automatically. [Claude Desktop credential helpers](https://claude.com/docs/third-party/claude-desktop/credential-helper)

Claude Desktop uses the `coreinfra_media` connector configured by Wizard together with the plugin `coreinfra-media` from the marketplace `coreinfra-wizard` (this repository’s `.claude-plugin/marketplace.json`). The plugin bundles the same three skills.
In Hub mode, Claude Desktop uses the `coreinfra_media` connector configured by Wizard together with the plugin `coreinfra-media` from the marketplace `coreinfra-wizard` (this repository’s `.claude-plugin/marketplace.json`). The plugin bundles the same four skills. In its other modes the media switch registers the connector with its tools only, without the plugin.

The Claude Code E2E in the Linux, macOS and Windows CI matrix configures a fresh profile, launches native Claude Code and verifies that all three skills and media tools are installed. It loads each skill in turn and calls `video_models`, `speech_models` and `transcription_models`, then verifies that the following inference requests and the final answer receive live catalog data from all three. Chat inference is a local Messages fixture. To run it locally, set `WIZARD_VIDEO_TEST_CLAUDE` to a Claude Code executable and run `cargo test -p wizard-core claude_code_skill_lists_public_media_models -- --ignored --nocapture` with Python 3 available.
The Claude Code E2E in the Linux, macOS and Windows CI matrix configures a fresh profile, launches native Claude Code and verifies that all four skills and media tools are installed. It loads each skill in turn and calls `video_models`, `speech_models`, `transcription_models` and `image_models`, then verifies that the following inference requests and the final answer receive live catalog data from all four. Chat inference is a local Messages fixture. To run it locally, set `WIZARD_VIDEO_TEST_CLAUDE` to a Claude Code executable and run `cargo test -p wizard-core claude_code_skill_lists_public_media_models -- --ignored --nocapture` with Python 3 available.

### Custom fields

Expand All @@ -82,7 +93,7 @@ For OpenRouter, put per-provider options under `fields.provider.options` and inl

The [client compatibility test](crates/wizard-core/tests/media_clients.py) includes a Python SDK 2.x example using `streamable_http_client`. To repeat the end-to-end test, set `WIZARD_VIDEO_TEST_PYTHON` to a Python with `mcp` 2.x installed and `WIZARD_VIDEO_TEST_CODEX` to a Codex executable. Run `cargo test -p wizard-core native_and_python_clients -- --ignored --nocapture`. All submissions in this test go to its temporary local Hub.

CI also runs a catalog E2E on Linux, macOS and Windows. Wizard installs the bundled skills and MCP registration into a fresh profile. Codex must discover all three skills with their `coreinfra_media` dependency. A native Codex turn then calls `video_models`, `speech_models` and `transcription_models` and receives model IDs from the public Hub. A local Responses fixture requests these three read-only tool calls one after another. To run it locally, set `WIZARD_VIDEO_TEST_CODEX` to a Codex executable or its npm `bin/codex.js` launcher and run `cargo test -p wizard-core codex_skill_lists_public_media_models -- --ignored --nocapture` with Python 3 available. The test uses its own loopback listener.
CI also runs a catalog E2E on Linux, macOS and Windows. Wizard installs the bundled skills and MCP registration into a fresh profile. Codex must discover all four skills with their `coreinfra_media` dependency. A native Codex turn then calls `video_models`, `speech_models`, `transcription_models` and `image_models` and receives model IDs from the public Hub. A local Responses fixture requests these four read-only tool calls one after another. To run it locally, set `WIZARD_VIDEO_TEST_CODEX` to a Codex executable or its npm `bin/codex.js` launcher and run `cargo test -p wizard-core codex_skill_lists_public_media_models -- --ignored --nocapture` with Python 3 available. The test uses its own loopback listener.

## How to build

Expand Down
33 changes: 30 additions & 3 deletions crates/wizard-core/src/agents/claude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ mod tests {
"coreinfra-video",
"coreinfra-speech",
"coreinfra-transcription",
"coreinfra-image",
]
.map(|name| dir.join("skills").join(name).join("SKILL.md"));
let registration =
Expand Down Expand Up @@ -446,6 +447,8 @@ mod tests {
read_global()?["mcpServers"]["coreinfra_media"],
registration.entry
);
// The registration carries the timeout that an image generation needs.
assert_eq!(registration.entry["timeout"], 240_000);
assert!(!registration.entry.to_string().contains("inference-key"));
assert!(prepare(RoutingMode::Hub, true)?.steps().iter().all(
|step| matches!(step, PreparedStep::ChangeFile { change } if !change.is_changed())
Expand Down Expand Up @@ -478,6 +481,24 @@ mod tests {
);
assert_eq!(read_global()?["mcpServers"]["other"], foreign);
}

// An entry an older Wizard wrote has no timeout and gets one. A timeout that is
// there was set by the user and stays.
let mut older = registration.entry.clone();
older
.as_object_mut()
.expect("registration entry")
.shift_remove("timeout");
let mut custom = registration.entry.clone();
custom["timeout"] = json!(90_000);
for (written, expected) in [(older, &registration.entry), (custom.clone(), &custom)] {
let mut config = read_global()?;
config["mcpServers"]["coreinfra_media"] = written;
std::fs::write(&global, config.to_string())?;
apply(prepare(RoutingMode::Hub, true)?)?;
assert_eq!(read_global()?["mcpServers"]["coreinfra_media"], *expected);
assert_eq!(read_global()?["mcpServers"]["other"], foreign);
}
apply(prepare_restore_at(
&dir,
&global,
Expand All @@ -493,7 +514,7 @@ mod tests {
for mode in [RoutingMode::Hub, RoutingMode::Sub, RoutingMode::Disabled] {
apply(prepare(mode, false)?)?;
assert_eq!(std::fs::read_to_string(&skill)?, "my edited skill");
assert!(!skills[1].exists() && !skills[2].exists());
assert!(!skills[1..].iter().any(|skill| skill.exists()));
assert_eq!(read_global()?["mcpServers"], json!({"other":foreign}));
}
Ok(())
Expand All @@ -507,9 +528,14 @@ mod tests {
let headers = temp.path().join("media-claude-code-headers.json");
let legacy_headers = temp.path().join("video-claude-code-headers.json");
let registration = media::server(crate::media::URL, &headers)?;
// The 1.0.10 registration: same endpoint, previous name and headers file.
// The 1.0.10 registration: same endpoint, previous name and headers file, and no
// timeout, which no 1.0.10 entry had.
let legacy = media::server(crate::media::URL, &legacy_headers)?;
let legacy_entry = legacy.entry;
let mut legacy_entry = legacy.entry;
legacy_entry
.as_object_mut()
.expect("registration entry")
.shift_remove("timeout");
let old_skill = dir.join("skills/coreinfra-video");
std::fs::create_dir_all(&old_skill)?;
std::fs::write(old_skill.join("SKILL.md"), "1.0.10 skill")?;
Expand Down Expand Up @@ -545,6 +571,7 @@ mod tests {
dir.join("skills/coreinfra-transcription/SKILL.md")
.is_file()
);
assert!(dir.join("skills/coreinfra-image/SKILL.md").is_file());

// A foreign server under the old name is never touched.
let foreign =
Expand Down
Loading
Loading