Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.
TypeScript agentic-aiaiai-agentsai-videocompilerdslffmpeggenerative-aillmmarkup-languagemonorepoplugin-systemprogramming-languagetext-to-videotypescriptvideovideo-automationvideo-clonevideo-editingvideo-generation
fix: finish HypiHub provider and CLI integration
rpone33ba5c7ea015
diff --git a/.agents/skills/hypit/references/local-author-package.md b/.agents/skills/hypit/references/local-author-package.mdindex 65103a99..b6efe066 100644--- a/.agents/skills/hypit/references/local-author-package.md+++ b/.agents/skills/hypit/references/local-author-package.md@@ -259,8 +259,8 @@ For a media slot, declare an Artifact Fragment input. Producer inputs are `Typed`inputs.media.value`; a filled slot is a BlobRef (`kind === "blob"`), while an authored structuredvalue is under `kind === "inline"`. Branch on BlobRef `mediaType` (`image/*` or `video/*`) whenchoosing the Visual IR element, and still draw the empty frame/cell when no material is supplied.-`hypit image` is a direct, billed KIE image-model call (default `@hypit/gpt-image`, credential-`KIE_API_KEY`); it does not use a project Runtime Profile, Build or Run Source. Obtain approval+`hypit image` is a direct, billed HypiHub image-model call (default `@hypit/gpt-image`, credential+`HYPIHUB_API_KEY`; get a key at [hypit.ai](https://hypit.ai)); it does not use a project Runtime Profile, Build or Run Source. Obtain approvalbefore using it and reserve it for package-owned chrome.```typescriptdiff --git a/.agents/skills/hypit/references/playbooks/craft/graphic-compositions.md b/.agents/skills/hypit/references/playbooks/craft/graphic-compositions.mdindex 87a1fd8f..a805d485 100644--- a/.agents/skills/hypit/references/playbooks/craft/graphic-compositions.md+++ b/.agents/skills/hypit/references/playbooks/craft/graphic-compositions.md@@ -115,8 +115,8 @@ project that installs it to obtain a picture that was never theirs to choose. Ifwriting a Run Source whose only purpose is to produce a component's own texture, the texture is inthe wrong place: generate it once while authoring the package and commit the file.-Produce that file with `hypit image --prompt <text> --to <path>`, a direct billed KIE image-model-call (default `@hypit/gpt-image`, using `KIE_API_KEY`). It writes a picture and nothing else; no+Produce that file with `hypit image --prompt <text> --to <path>`, a direct billed HypiHub image-model+call (default `@hypit/gpt-image`, using `HYPIHUB_API_KEY`; get a key at [hypit.ai](https://hypit.ai)). It writes a picture and nothing else; noproject Runtime Profile, Source, Run, Build or Record participates. A package asset is authoringinput, not the output of anybody's video, so it is never a Target or Record.diff --git a/docs/quickstart/run.md b/docs/quickstart/run.mdindex 821ea855..19f3bd6d 100644--- a/docs/quickstart/run.md+++ b/docs/quickstart/run.md@@ -211,12 +211,15 @@ variables referenced by the selected Runtime Profile:| Variable | Provider/use ||---|---|-| `KIE_API_KEY` | KIE models, including Seedance and GPT Image |+| `HYPIHUB_API_KEY` | HypiHub paid generation and Gemini VLM; get one at https://hypit.ai |+| `KIE_API_KEY` | Explicit KIE Provider only || `MIMO_API_KEY` | Xiaomi MiMo TTS, only when that Endpoint is selected |Run only the lines for the Endpoints in your Profile. In macOS/Linux shells:```bash+read -r -s HYPIHUB_API_KEY+export HYPIHUB_API_KEYread -r -s KIE_API_KEYexport KIE_API_KEYread -r -s MIMO_API_KEY@@ -226,6 +229,7 @@ export MIMO_API_KEYIn Windows PowerShell:```powershell+$env:HYPIHUB_API_KEY = "your-key"$env:KIE_API_KEY = "your-key"$env:MIMO_API_KEY = "your-key"```diff --git a/docs/zh/quickstart/run.md b/docs/zh/quickstart/run.mdindex bee4718c..914ce21a 100644--- a/docs/zh/quickstart/run.md+++ b/docs/zh/quickstart/run.md@@ -185,12 +185,15 @@ hypit paths| 变量 | Provider / 用途 ||---|---|-| `KIE_API_KEY` | KIE 模型,包括 Seedance 与 GPT Image |+| `HYPIHUB_API_KEY` | HypiHub 付费生成与 Gemini VLM;前往 https://hypit.ai 获取 |+| `KIE_API_KEY` | 仅在显式选择 KIE Provider 时使用 || `MIMO_API_KEY` | Xiaomi MiMo TTS;只有选择该 Endpoint 时才需要 |只执行 Profile 中所选 Endpoint 对应的行。在 macOS/Linux Shell 中:```bash+read -r -s HYPIHUB_API_KEY+export HYPIHUB_API_KEYread -r -s KIE_API_KEYexport KIE_API_KEYread -r -s MIMO_API_KEY@@ -200,6 +203,7 @@ export MIMO_API_KEY在 Windows PowerShell 中:```powershell+$env:HYPIHUB_API_KEY = "your-key"$env:KIE_API_KEY = "your-key"$env:MIMO_API_KEY = "your-key"```diff --git a/packages/generation/src/mapping.ts b/packages/generation/src/mapping.tsindex 77f107f0..c7d98f66 100644--- a/packages/generation/src/mapping.ts+++ b/packages/generation/src/mapping.ts@@ -172,10 +172,15 @@ export function assertMappingCoversPorts(}assert(media.accepts.length === 1,`${subject} accepts ${media.accepts.join(", ")}; declare one port per media role so each maps to one wire field`);- assert(field.as === "url" || field.as === "urlArray", `${subject} must resolve media to a URL`);+ assert(field.as === "url" || field.as === "urlArray" || field.as === "itemObject",+ `${subject} must resolve media to a URL`);if (field.as === "url") {assert(port.maxItems === 1, `${subject} uses url but the port accepts up to ${port.maxItems} items`);}+ if (field.as === "itemObject") {+ assert(field.fieldKeys !== undefined && Object.keys(field.fieldKeys).length === 0,+ `${subject} itemObject must not map undeclared item fields`);+ }continue;}if (port.maxItems > 1) {diff --git a/packages/provider-hypihub/README.md b/packages/provider-hypihub/README.mdindex 2855fd53..639ae0a7 100644--- a/packages/provider-hypihub/README.md+++ b/packages/provider-hypihub/README.md@@ -6,8 +6,8 @@ when its key is configured.It maps the currently shipped image/video model capabilities to HypiHub, including image edits andimage-to-video first-frame inputs, submits jobs, polls them, downloads the first-class assets and-persists them in Hypit's configured ArtifactStore. Image references use HypiHub's `reference_images`-shape; video reference arrays use the documented `extra` passthrough so HypiHub can hand them to its+persists them in Hypit's configured ArtifactStore. Image references use HypiHub's documented+`reference_images` object shape (`[{ "url": "…" }]`); video reference arrays use the documented `extra` passthrough so HypiHub can hand them to itsselected upstream adaptor. First/last-frame images use `input_reference` and `last_frame`. It alsoexports a small Gemini-native VLM generator for callers that previously used Vertex.diff --git a/packages/provider-hypihub/src/mapping.ts b/packages/provider-hypihub/src/mapping.tsindex 61a65f6d..2b3327e6 100644--- a/packages/provider-hypihub/src/mapping.ts+++ b/packages/provider-hypihub/src/mapping.ts@@ -41,7 +41,7 @@ export const hypiHubMappings: readonly GenerationWireMapping[] = [prompt: { as: "value", field: "prompt" },aspectRatio: { as: "value", field: "aspect_ratio" },resolution: { as: "value", field: "size", whenAbsent: "1024x1024" },- images: { as: "urlArray", field: "reference_images" },+ images: { as: "itemObject", field: "reference_images", urlKey: "url", fieldKeys: {} },},},...(["nano-banana-2", "nano-banana-pro"] as const).map((model) => ({@@ -50,7 +50,7 @@ export const hypiHubMappings: readonly GenerationWireMapping[] = [prompt: { as: "value" as const, field: "prompt" },aspectRatio: { as: "value" as const, field: "aspect_ratio" },resolution: { as: "value" as const, field: "size", whenAbsent: "1024x1024" },- images: { as: "urlArray" as const, field: "reference_images" },+ images: { as: "itemObject" as const, field: "reference_images", urlKey: "url", fieldKeys: {} },outputFormat: { as: "value" as const, field: "output_format" },},})),@@ -62,7 +62,7 @@ export const hypiHubMappings: readonly GenerationWireMapping[] = [fields: {prompt: { as: "value", field: "prompt" },aspectRatio: { as: "value", field: "aspect_ratio" },- images: { as: "urlArray", field: "reference_images" },+ images: { as: "itemObject", field: "reference_images", urlKey: "url", fieldKeys: {} },quality: { as: "value", field: "quality" },outputFormat: { as: "value", field: "output_format" },nsfwCheck: { as: "value", field: "nsfw_checker" },@@ -93,7 +93,7 @@ export const hypiHubMappings: readonly GenerationWireMapping[] = [fields: {prompt: { as: "value", field: "prompt" }, duration: { as: "value", field: "seconds" },resolution: { as: "value", field: "resolution" }, aspectRatio: { as: "value", field: "aspect_ratio" },- images: { as: "urlArray", field: "reference_images" },+ images: { as: "itemObject", field: "reference_images", urlKey: "url", fieldKeys: {} },sourceTaskId: { as: "value", field: "source_task_id" },},},@@ -105,7 +105,7 @@ export const hypiHubMappings: readonly GenerationWireMapping[] = [fields: {prompt: { as: "value", field: "prompt" }, duration: { as: "value", field: "seconds" },resolution: { as: "value", field: "resolution" }, aspectRatio: { as: "value", field: "aspect_ratio" },- images: { as: "urlArray", field: "reference_images" },+ images: { as: "itemObject", field: "reference_images", urlKey: "url", fieldKeys: {} },},},{diff --git a/packages/provider-hypihub/src/routes.ts b/packages/provider-hypihub/src/routes.tsindex cd0aee5d..70085094 100644--- a/packages/provider-hypihub/src/routes.ts+++ b/packages/provider-hypihub/src/routes.ts@@ -53,8 +53,17 @@ function normalizeHypiHubRequest(}// Audio mappings already use HypiHub's public /audio/speech vocabulary.- // They must not fall through the video reference normalizer below.- if (mapping.result === "audio") return { model: request.model, input: canonicalize(input) };+ // MiMo voice-clone is the one exception: its upstream adaptor expects the+ // sample as bare base64 in `audio.voice`, while the provider's artifact+ // resolver quite correctly returns a data URL. Strip only that transport+ // prefix here so the provider stays decoupled from the upstream wire shape.+ if (mapping.result === "audio") {+ if (mapping.capability.name === "mimo-v2.5-tts-voiceclone" && typeof input.voice === "string") {+ const match = /^data:[^;,]+(?:;[^;,]+)*;base64,(.*)$/su.exec(input.voice);+ if (match !== null) input.voice = match[1];+ }+ return { model: request.model, input: canonicalize(input) };+ }if (typeof input.resolution === "string") input.resolution = input.resolution.toLowerCase();diff --git a/packages/provider-hypihub/test/routes.test.ts b/packages/provider-hypihub/test/routes.test.tsindex 4c14fb6e..e91081f9 100644--- a/packages/provider-hypihub/test/routes.test.ts+++ b/packages/provider-hypihub/test/routes.test.ts@@ -29,7 +29,7 @@ test("HypiHub GPT image requests use canonical edit references and size dimensioprompt: "edit",aspect_ratio: "1:1",size: "1024x1024",- reference_images: ["data:image/png;base64,AQID"],+ reference_images: [{ url: "data:image/png;base64,AQID" }],});});@@ -121,3 +121,16 @@ test("HypiHub MiMo TTS mappings use the public audio speech fields", async () =>assert.equal(result.model, "mimo-v2.5-tts-voicedesign");assert.deepEqual(result.input, { input: "hello", voice_description: "warm and calm" });});++test("HypiHub MiMo voice clone sends the upstream-required bare base64 sample", async () => {+ const voiceClone = hypiHubRoutes.find((item) => item.capability.name === "mimo-v2.5-tts-voiceclone");+ assert.ok(voiceClone);+ const result = await voiceClone.compile({+ ports: {+ text: ["hello"],+ sample: [{ role: "audio", artifact: { ...image, mediaType: "audio/wav" } }],+ },+ }, resolveAudio);+ assert.equal(result.model, "mimo-v2.5-tts-voiceclone");+ assert.deepEqual(result.input, { input: "hello", voice: "AQID" });+});diff --git a/packages/video-cli/package.json b/packages/video-cli/package.jsonindex 7bac1ad2..f32d5787 100644--- a/packages/video-cli/package.json+++ b/packages/video-cli/package.json@@ -20,7 +20,7 @@"@hypit/model-kit": "workspace:*","@hypit/package-loader-node": "workspace:*","@hypit/protocol": "workspace:*",- "@hypit/provider-kie": "workspace:*",+ "@hypit/provider-hypihub": "workspace:*","@hypit/runtime-host-node": "workspace:*","@hypit/runtime-local": "workspace:*","@hypit/workspace-fs-node": "workspace:*"diff --git a/packages/video-cli/src/picture.ts b/packages/video-cli/src/picture.tsindex fe0780f1..691ca6ae 100644--- a/packages/video-cli/src/picture.ts+++ b/packages/video-cli/src/picture.ts@@ -9,7 +9,7 @@ import { exactModelsFromHostFacets } from "@hypit/model-kit";import type { ExactModelEndpoint } from "@hypit/model-kit";import { loadNodePackageSelection } from "@hypit/package-loader-node";import type { BlobRef, CanonicalValue, Need } from "@hypit/protocol";-import { createKieProvider } from "@hypit/provider-kie";+import { createHypiHubProvider } from "@hypit/provider-hypihub";/*** The exact model family this Distribution reaches for when the author names none.@@ -99,7 +99,9 @@ async function resolveCredentials(for (const [slot, ref] of Object.entries(registration.credentials ?? {})) {const value = await store.resolve(ref);assert(value !== undefined, ref.store === "env"- ? `credential ${slot} is unavailable; set ${ref.key} in the environment`+ ? ref.key === "HYPIHUB_API_KEY"+ ? `credential ${slot} is unavailable; set ${ref.key} in the environment (get a HypiHub key at https://hypit.ai)`+ : `credential ${slot} is unavailable; set ${ref.key} in the environment`: `credential ${slot} lives in CredentialStore ${ref.store}, which hypit image cannot open`);resolved[slot] = value;}@@ -143,7 +145,7 @@ export async function generateVideoCliPicture(request: CliPictureRequest): Promiresult: "record:hypit-image",};const registry = new EndpointRegistry();- await createKieProvider({}).install(registry);+ await createHypiHubProvider({}).install(registry);const resolution = registry.resolve(need);assert(resolution.status === "resolved",`no Provider in this Distribution fulfils ${model.ports.model}`);diff --git a/packages/video-cli/test/cli.test.ts b/packages/video-cli/test/cli.test.tsindex 392c28e5..afadace3 100644--- a/packages/video-cli/test/cli.test.ts+++ b/packages/video-cli/test/cli.test.ts@@ -73,30 +73,31 @@ test("image writes one picture file with no Source, Build, Record or Runtime Proconst calls: string[] = [];const requests: Record<string, unknown>[] = [];const realFetch = globalThis.fetch;- const realKey = process.env.KIE_API_KEY;+ const realKey = process.env.HYPIHUB_API_KEY;globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {const url = String(input);calls.push(url);- if (url.endsWith("/api/v1/jobs/createTask")) {+ if (url.endsWith("/v1/models/gpt-image-2-text-to-image")) {+ assert.equal((init?.headers as Record<string, string>).authorization, "Bearer test-image-key");+ return Response.json({ id: "gpt-image-2-text-to-image", endpoints: ["images"] });+ }+ if (url.endsWith("/v1/images/generations")) {assert.equal((init?.headers as Record<string, string>).authorization, "Bearer test-image-key");requests.push(JSON.parse(String(init?.body)) as Record<string, unknown>);- return Response.json({ code: 200, msg: "success", data: { taskId: "task_image_test" } });+ return Response.json({ id: "job_image_test", status: "queued" }, { status: 202 });}- if (url.includes("/api/v1/jobs/recordInfo")) {- return Response.json({ code: 200, data: {- taskId: "task_image_test", model: "gpt-image-2", state: "success",- resultJson: JSON.stringify({ resultUrls: ["https://tempfile.aiquickdraw.com/paper.png"] }),- } });+ if (url.endsWith("/v1/jobs/job_image_test")) {+ return Response.json({ id: "job_image_test", status: "succeeded" });}- if (url.endsWith("/api/v1/common/download-url")) {- return Response.json({ code: 200, data: "https://download.kie.test/paper.png" });+ if (url.endsWith("/v1/jobs/job_image_test/assets")) {+ return Response.json({ items: [{ url: "https://download.hypihub.test/paper.png" }] });}- if (url === "https://download.kie.test/paper.png") {+ if (url === "https://download.hypihub.test/paper.png") {return new Response(pictureBytes, { status: 200, headers: { "content-type": "image/png" } });}throw new Error(`Unexpected URL ${url}`);}) as typeof globalThis.fetch;- process.env.KIE_API_KEY = "test-image-key";+ process.env.HYPIHUB_API_KEY = "test-image-key";try {const promptFile = join(root, "paper.txt");await writeFile(promptFile, "A sheet of warm cream laid paper, even lighting, no text.\n", "utf8");@@ -118,17 +119,15 @@ test("image writes one picture file with no Source, Build, Record or Runtime Pro// The author gave one option; every other port took the model's own first value.assert.deepEqual(requests, [{model: "gpt-image-2-text-to-image",- input: {- prompt: "A sheet of warm cream laid paper, even lighting, no text.",- aspect_ratio: "1:1",- resolution: "1K",- },+ prompt: "A sheet of warm cream laid paper, even lighting, no text.",+ aspect_ratio: "1:1",+ size: "1024x1024",}]);- assert.equal(calls.filter((item) => item.endsWith("/api/v1/jobs/createTask")).length, 1);+ assert.equal(calls.filter((item) => item.endsWith("/v1/images/generations")).length, 1);} finally {globalThis.fetch = realFetch;- if (realKey === undefined) delete process.env.KIE_API_KEY;- else process.env.KIE_API_KEY = realKey;+ if (realKey === undefined) delete process.env.HYPIHUB_API_KEY;+ else process.env.HYPIHUB_API_KEY = realKey;await rm(root, { recursive: true, force: true });}});diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex c8a69ad3..57123a37 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -3251,9 +3251,9 @@ importers:'@hypit/protocol':specifier: workspace:*version: link:../protocol- '@hypit/provider-kie':+ '@hypit/provider-hypihub':specifier: workspace:*- version: link:../provider-kie+ version: link:../provider-hypihub'@hypit/runtime-host-node':specifier: workspace:*version: link:../runtime-host-node