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
12 changes: 12 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "coreinfra-wizard",
"metadata": { "description": "Skills for Claude connected through CoreInfra Wizard." },
"owner": { "name": "CoreInfra" },
"plugins": [
{
"name": "coreinfra-video",
"source": "./plugins/coreinfra-video",
"description": "Generate and retrieve videos through CoreInfra Wizard."
}
]
}
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,23 @@ jobs:
- name: Install Codex for the video skill E2E
run: npm install --prefix "${{ runner.temp }}/video-codex" --no-save --no-package-lock --no-audit --no-fund "@openai/[email protected]"

- name: Verify the installed skill can list live video models
- name: Verify the installed Codex skill can list live video models
timeout-minutes: 5
env:
WIZARD_VIDEO_TEST_CODEX: ${{ runner.temp }}/video-codex/node_modules/@openai/codex/bin/codex.js
WIZARD_VIDEO_TEST_PYTHON: python
run: cargo test --locked -p wizard-core --lib video::tests::codex_skill_lists_public_video_models -- --exact --ignored --nocapture

- name: Install Claude Code for the video skill E2E
run: npm install --prefix "${{ runner.temp }}/video-claude" --no-save --no-package-lock --no-audit --no-fund "@anthropic-ai/[email protected]"

- name: Verify the installed Claude Code skill can list live video models
timeout-minutes: 5
env:
WIZARD_VIDEO_TEST_CLAUDE: ${{ runner.temp }}/video-claude/node_modules/@anthropic-ai/claude-code/bin/claude.exe
WIZARD_VIDEO_TEST_PYTHON: python
run: cargo test --locked -p wizard-core --lib agents::claude::video_e2e::claude_code_skill_lists_public_video_models -- --exact --ignored --nocapture

frontend:
name: Frontend
runs-on: ubuntu-latest
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An application for configuring agents to use CoreInfra.

## Video in ChatGPT Work and Codex
## Video in ChatGPT Work, Codex and Claude Code

Start Wizard, sign in to CoreInfra Hub and select the Hub to charge. Keep Wizard running and ask for a video in a new ChatGPT Work or Codex chat, or invoke `$coreinfra-video`. Wizard automatically installs the skill and registers its MCP server at startup.

Expand All @@ -12,6 +12,14 @@ The bundled skill and the `coreinfra_video` MCP registration live in the profile

For new jobs Wizard uses the oldest active key named `agent-codex` in the selected Hub, the same default that Wizard provisions for Codex. If it is missing, Wizard issues one as part of the generation request. Only Wizard adds the Hub key to the outgoing `Authorization` header. A job records its Hub ID, key fingerprint, provider, model and upstream ID so Wizard can poll with the original key. Wizard keeps no job table or MCP session. A Python MCP client with permission to reach loopback can use the URL and current local `http_headers` from the registration.

### Claude Code

In Wizard choose **Claude Code → API-доступ → Применить** and confirm the configuration plan. Start a new local Claude Code session and ask «Какие видеомодели доступны?» or invoke `/coreinfra-video`. Keep Wizard running. The CLI routing command applies the same configuration.

Wizard installs the bundled skill under `~/.claude/skills/coreinfra-video` and registers the HTTP MCP server `coreinfra_video` 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 rotates the bearer on startup and removes the headers file when video is disabled. Generation uses Wizard’s `agent-codex` key in the selected Hub. The video connection switch is shared across Claude Code and Codex. Switching Claude Code away from API access removes its managed MCP entry and unmodified skill. Reapplying API access installs the version shipped with Wizard.

The Claude Code E2E in the Linux, macOS and Windows CI matrix configures a fresh profile, launches native Claude Code, asks it to read the installed skill, and verifies that the next inference request and the final answer receive live catalog data. 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_video_models -- --ignored --nocapture` with Python 3 available.

### Custom video fields

Put provider-specific JSON in `fields`. Wizard merges its entries into the outgoing JSON body and preserves nested objects, arrays, numbers, booleans and nulls. For clients that cannot express open-ended object arguments, `fields_json` accepts the same object as a JSON string. Use one representation per request. `model` and `prompt` are reserved tool arguments. The destination, authentication and HTTP headers are controlled by Wizard.
Expand All @@ -33,7 +41,7 @@ For OpenRouter, put per-provider options under `fields.provider.options` and inl

The [client compatibility test](crates/wizard-core/tests/video_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 skill and MCP registration into a fresh profile. A native Codex turn uses the installed skill to call `video_models` and receives model IDs from the public Hub. A local Responses fixture requests that single read-only tool call. 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_video_models -- --ignored --nocapture` with Python 3 available and port 33789 free.
CI also runs a catalog E2E on Linux, macOS and Windows. Wizard installs the bundled skill and MCP registration into a fresh profile. A native Codex turn uses the installed skill to call `video_models` and receives model IDs from the public Hub. A local Responses fixture requests that single read-only tool call. 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_video_models -- --ignored --nocapture` with Python 3 available. The test uses its own loopback listener.

## How to build

Expand Down
2 changes: 1 addition & 1 deletion crates/wizard-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dirs.workspace = true
ed25519-dalek.workspace = true
log.workspace = true
regex.workspace = true
rmcp.workspace = true
rmcp = { workspace = true, features = ["transport-io"] }
quick-xml.workspace = true
reqwest.workspace = true
serde.workspace = true
Expand Down
180 changes: 169 additions & 11 deletions crates/wizard-core/src/agents/claude.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mod video;
#[cfg(test)]
mod video_e2e;

use super::{
AgentDetection, AgentToken, RoutingMode,
detection::{self, Agent, AgentInfo},
Expand Down Expand Up @@ -32,6 +36,7 @@ pub(crate) struct Claude {
pub info: AgentInfo,
pub routing_mode: RoutingMode,
pub token: Option<AgentToken>,
pub video_needs_apply: bool,
}

pub(super) fn detect(settings: &Settings) -> AgentDetection<Claude> {
Expand All @@ -40,14 +45,15 @@ pub(super) fn detect(settings: &Settings) -> AgentDetection<Claude> {
AgentDetection::NotFound => return AgentDetection::NotFound,
AgentDetection::Error(error) => return AgentDetection::Error(error),
};
let (routing_mode, token) = match read_routing() {
let (routing_mode, token, video_needs_apply) = match read_routing() {
Ok(routing) => routing,
Err(error) => return AgentDetection::Error(format!("{error:#}")),
};
AgentDetection::Found(Claude {
info,
routing_mode,
token,
video_needs_apply,
})
}

Expand Down Expand Up @@ -75,11 +81,20 @@ pub fn configured_token() -> Result<Option<String>> {
Ok(read_routing()?.1.map(AgentToken::into_secret))
}

fn read_routing() -> Result<(RoutingMode, Option<AgentToken>)> {
fn read_routing() -> Result<(RoutingMode, Option<AgentToken>, bool)> {
let _guard = PreparedAgent::Claude.lock()?;
let settings = config_files::json::read(&config_dir()?.join("settings.json"))?;
let dir = config_dir()?;
let settings = config_files::json::read(&dir.join("settings.json"))?;
let mode = mode_from_config(&settings);
Ok((mode, token_from_config(&settings, mode)))
let video_needs_apply = if mode == RoutingMode::Hub {
let mut global = FileChange::read(global_config_path()?)?;
video::configure(&dir, &mut global, &video_server()?, true).map_or(true, |files| {
global.is_changed() || files.iter().any(FileChange::is_changed)
})
} else {
false
};
Ok((mode, token_from_config(&settings, mode), video_needs_apply))
}

/// Reads only keys owned by the active mode: a disabled API key may belong to the user.
Expand Down Expand Up @@ -109,19 +124,77 @@ pub fn get_backups() -> Result<Vec<super::Backup>> {
}

pub fn restore_backup(id: u32) -> Result<()> {
let _guard = PreparedAgent::Claude.lock()?;
BackupManager::new(AgentKind::Claude)?.load_backup(id)
let manager = BackupManager::new(AgentKind::Claude)?;
let plan = {
let _guard = PreparedAgent::Claude.lock()?;
prepare_restore_at(
&config_dir()?,
&global_config_path()?,
&video_server()?,
&manager,
id,
)?
};
plan.apply_with_backup(
Some(manager),
|_| bail!("Unexpected desktop proxy"),
|_| bail!("Unexpected Codex proxy"),
)
}

fn prepare_restore_at(
dir: &Path,
global_path: &Path,
server: &Value,
manager: &BackupManager,
id: u32,
) -> Result<PreparedPlan> {
let mut changes = manager.restore_changes(id)?;
let path = dir.join("settings.json");
let settings = if let Some(change) = changes.iter().find(|change| change.path() == &path) {
config_files::json::parse(&change.after)?
} else {
config_files::json::read(&path)?
};
let mut global = FileChange::read(global_path.to_owned())?;
changes.extend(video::configure(
dir,
&mut global,
server,
mode_from_config(&settings) == RoutingMode::Hub,
)?);
changes.push(global);
Ok(prepare_plan(changes))
}

/// `token` is ignored when disabled.
pub fn prepare_routing(mode: RoutingMode, token: &str) -> Result<PreparedPlan> {
let _guard = PreparedAgent::Claude.lock()?;

let dir = config_dir()?;
prepare_routing_at(
&config_dir()?,
&global_config_path()?,
&video_server()?,
mode,
token,
)
}

fn video_server() -> Result<Value> {
video::server(crate::video::URL, &crate::video::install::headers_path()?)
}

fn prepare_routing_at(
dir: &Path,
global_path: &Path,
server: &Value,
mode: RoutingMode,
token: &str,
) -> Result<PreparedPlan> {
let script_path = dir.join("no-proxy.sh");

let mut settings = FileChange::read(dir.join("settings.json"))?;
let mut global = FileChange::read(global_config_path()?)?;
let mut global = FileChange::read(global_path.to_owned())?;
let mut script = FileChange::read(script_path.clone())?;

let current_mode = mode_from_config(&config_files::json::parse(&settings.after)?);
Expand Down Expand Up @@ -158,12 +231,13 @@ pub fn prepare_routing(mode: RoutingMode, token: &str) -> Result<PreparedPlan> {
}

// Keep preparation files before activation, and script deletion after it.
let changes = if mode == RoutingMode::Sub {
let mut changes = video::configure(dir, &mut global, server, mode == RoutingMode::Hub)?;
changes.extend(if mode == RoutingMode::Sub {
[global, script, settings]
} else {
[global, settings, script]
};
Ok(prepare_plan(changes.into()))
});
Ok(prepare_plan(changes))
}

fn prepare_plan(changes: Vec<FileChange>) -> PreparedPlan {
Expand Down Expand Up @@ -319,6 +393,90 @@ fn approve_key(after: &mut FileSnapshot, suffix: &str) -> Result<()> {
mod tests {
use super::*;

#[test]
fn video_follows_gateway_mode_and_backup_restores_preserve_other_servers() -> Result<()> {
let temp = tempfile::tempdir()?;
let dir = temp.path().join(".claude");
let global = temp.path().join(".claude.json");
let skill = dir.join("skills/coreinfra-video/SKILL.md");
let registration =
video::server(crate::video::URL, &temp.path().join("video headers.json"))?;
let manager =
|| BackupManager::in_directory(AgentKind::Claude, temp.path().join("backups"));
let apply = |plan: PreparedPlan| {
plan.apply_with_backup(
Some(manager()),
|_| bail!("Unexpected desktop proxy"),
|_| bail!("Unexpected Codex proxy"),
)
};
let prepare =
|mode| prepare_routing_at(&dir, &global, &registration, mode, "inference-key");
let read_global = || config_files::json::read(&global);
let foreign = json!({"type":"http","url":"https://example.org/mcp"});
std::fs::write(
&global,
json!({"mcpServers":{"other":foreign},"theme":"dark"}).to_string(),
)?;

let first = prepare(RoutingMode::Hub)?;
assert!(!skill.exists());
apply(first)?;
assert!(skill.is_file());
assert_eq!(
read_global()?["mcpServers"]["coreinfra_video"],
registration
);
assert!(!registration.to_string().contains("inference-key"));
assert!(prepare(RoutingMode::Hub)?.steps().iter().all(
|step| matches!(step, PreparedStep::ChangeFile { change } if !change.is_changed())
));
assert_eq!(manager().get_backups()?.len(), 1);

// Claude itself can change its global state between configuration and restore.
let mut updated = read_global()?;
updated["theme"] = json!("light");
std::fs::write(&global, updated.to_string())?;
apply(prepare_restore_at(
&dir,
&global,
&registration,
&manager(),
1,
)?)?;
assert!(!skill.exists());
assert_eq!(read_global()?["theme"], "light");
assert_eq!(read_global()?["mcpServers"], json!({"other":foreign}));

apply(prepare(RoutingMode::Hub)?)?;
std::fs::write(&skill, "my edited skill")?;
assert!(prepare(RoutingMode::Hub).is_err());
for mode in [RoutingMode::Sub, RoutingMode::Disabled] {
apply(prepare(mode)?)?;
assert_eq!(std::fs::read_to_string(&skill)?, "my edited skill");
assert_eq!(read_global()?["mcpServers"], json!({"other":foreign}));
}
Ok(())
}

#[test]
fn foreign_video_entries_block_install_without_changing_any_files() -> Result<()> {
let temp = tempfile::tempdir()?;
let dir = temp.path().join("claude");
let global = temp.path().join("global.json");
let server = video::server(crate::video::URL, &temp.path().join("headers.json"))?;
let existing = json!({"mcpServers":{"coreinfra_video":{"type":"http","url":crate::video::URL,"headersHelper":"user-helper"}}});
std::fs::write(&global, existing.to_string())?;
assert!(prepare_routing_at(&dir, &global, &server, RoutingMode::Hub, "key").is_err());
assert!(!dir.exists());
assert_eq!(config_files::json::read(&global)?, existing);
let plan = prepare_routing_at(&dir, &global, &server, RoutingMode::Disabled, "")?;
assert!(plan.steps().iter().all(
|step| matches!(step, PreparedStep::ChangeFile { change } if !change.is_changed())
));
Ok(())
}

#[test]
fn user_credentials_that_override_a_mode_are_rejected() {
let env = |key: &str| {
Expand Down
Loading
Loading