The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(media): add README for the media module
Steven Enamakel172125623885
diff --git a/crates/openhuman-core/src/media/README.md b/crates/openhuman-core/src/media/README.mdindex b061cf60f7..03191a63cc 100644--- a/crates/openhuman-core/src/media/README.md+++ b/crates/openhuman-core/src/media/README.md@@ -8,22 +8,18 @@ The tool registry in `tools/ops.rs` is the only caller.## How it works-The work is split across three owners. This crate holds only the host policy.+The work is split across four owners. The core holds the tools and the+reference policy; the generators (endpoint, credential, egress and budget+policy) come from the host that owns the media service.```text- tools/ops.rs (#[cfg(feature = "media")], DomainSet::media)- |- v- media::generation::build_media_tools(config, action_dir)- |- |-- provider::managed_generators(config)- | BackendClient: raw_client(), url_for(OPENROUTER_PROXY_PATH)- | (OPENROUTER_PROXY_PATH = "/agent-integrations/openrouter")- | no backend transport installed -> None -> no media tools- |- | MediaGenerators { image, video }, each wrapped in a Guard:+ host tool source (openhuman-tinyhumans: integrations/media)+ | managed_generators(config) -> MediaGenerators { image, video }+ | each wrapped in a Guard:| admit(): local-only enforcement, then egress disclosure| budget(): refuse a billed submit when managed credits are out+ v+ media::generation::media_tools_for_config(generators, config, action_dir, allowlist)|vtinyagents_harness::media::{GenerateImageTool, GenerateVideoTool}@@ -33,28 +29,25 @@ The work is split across three owners. This crate holds only the host policy.|vtinyinference-image / tinyinference-video- OpenRouter wire contract, submit -> poll -> download job loop+ wire contract, submit -> poll -> download job loop```+`tools/ops.rs` only records the files roots the reference policy reads+(`#[cfg(feature = "media")]`, `DomainSet::media`); it builds no media tools. A+core with no tool source registered has no media tools at all, rather than+broken ones.+When the agent calls `media_generate_image`, the TinyAgents tool parses thearguments and calls the guarded generator. The guard checks the privacypolicy and announces the external transfer, checks the managed-credit budget,-then hands the request to TinyInference, which talks to OpenRouter through the-backend proxy. TinyAgents stores generated bytes in its media blob store.-`MediaArtifactTool` copies each blob into the visible files folder, records it-as an artifact (metadata under the workspace's `artifacts/<id>/`), and updates-the JSON and Markdown result paths plus `artifact_id` so the chat UI-can show a card. Video works the same way, except the generator submits a job-and polls it (every 5 s, for up to 600 s) before downloading the clip. A-timed-out video can be resumed with `resume_job_id` instead of paying for a-new job.--The credential is resolved per request through `resolve_backend_credential`,-so a desktop session JWT and a library API key both work, and a refreshed-session is picked up mid-run. Billing and margin stay on the backend; this-module never charges, it only refuses to submit when-`integrations::client::budget_gate::managed_tool_budget_exhausted` says the-account is out of managed credits.+then hands the request to TinyInference. TinyAgents stores generated bytes in+its media blob store. `MediaArtifactTool` copies each blob into the visible+files folder, records it as an artifact (metadata under the workspace's+`artifacts/<id>/`), and updates the JSON and Markdown result paths plus+`artifact_id` so the chat UI can show a card. Video works the same way, except+the generator submits a job and polls it (every 5 s, for up to 600 s) before+downloading the clip. A timed-out video can be resumed with `resume_job_id`+instead of paying for a new job.## Layout@@ -67,17 +60,18 @@ Inside `generation/`:| File | What it does || --- | --- |-| `provider.rs` | `managed_generators`, `MediaGenerators`, `OPENROUTER_PROXY_PATH`, the per-request bearer resolver, and the `Guard` that wraps both generators. |-| `tools.rs` | `build_media_tools`, `media_tools_from` (the same assembly over any generators, used by tests), `reference_policy`, `MediaListModelsTool`, and the tool-name constants. |+| `provider.rs` | `MediaGenerators` (the image + video pair, with an optional per-chat router) and `GeneratorRouter`. |+| `tools.rs` | `media_tools_for_config` (the registry entry point over host-supplied generators), `media_tools_from` (the same assembly, used by tests), `reference_policy`, `MediaListModelsTool`, and the tool-name constants. || `artifact_tool.rs` | `MediaArtifactTool<T>`: runs the inner tool unchanged, then files every reported output as an artifact, or annotates that one entry with `artifact_error` on failure. |## Key types and entry points-- `build_media_tools(&Config, &Path)` ([`generation/tools.rs`](./generation/tools.rs)) is the registry- entry point. It returns an empty list, not an error, when no backend is- reachable.-- `managed_generators(&Config)` ([`generation/provider.rs`](./generation/provider.rs)) builds- `MediaGenerators { image, video }` against the backend proxy.+- `media_tools_for_config(generators, &Config, &Path, allowlist)`+ ([`generation/tools.rs`](./generation/tools.rs)) is the entry point a host's+ tool source calls.+- `MediaGenerators` ([`generation/provider.rs`](./generation/provider.rs)) is+ the image + video pair the tools run over; `MediaGenerators::with_router`+ lets a host rebuild them per chat.- `MediaArtifactTool` ([`generation/artifact_tool.rs`](./generation/artifact_tool.rs)) is the artifact-trackingwrapper, following the same `create_artifact_for_call` /`finalize_artifact` / `fail_artifact` pattern the document and presentation@@ -101,7 +95,8 @@ Inside `generation/`:`tinyhumansai/tinyinference`), reached through `tinyagents_harness`.- Argument parsing, writing files into the workspace, and result wordingbelong to TinyAgents (`tinyagents_harness::media`, in `vendor/tinyagents`).-- Provider keys, billing, and the proxy route belong to the backend.+- Provider keys, billing, the proxy route and the generators that reach it+ belong to the host (`openhuman-tinyhumans`: `integrations/media`).- Artifact storage belongs to `agent::artifacts`.## Gotchas@@ -116,8 +111,6 @@ Inside `generation/`:- Local reference files are limited by `reference_policy` to the actiondirectory or workspace, with no `..` and nothing under an always-forbiddenpath (credential stores, system roots). Anything else must be an https URL.-- A core with no backend transport installed (a library host with no- TinyHumans connection) has no media tools at all, rather than broken ones.## Tests