Skip to content

armgit / hypit

Public Imported from GitHub
0

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.

fix: validate Film inputs and retain verbose execution receipts

kashorin300a1305935b
diff --git a/examples/semantic-composition/README.md b/examples/semantic-composition/README.md
index 22caacb3..0235b77c 100644
--- a/examples/semantic-composition/README.md
+++ b/examples/semantic-composition/README.md
@@ -28,7 +28,8 @@ node bin/hypit.mjs check examples/semantic-composition/chat.svml --workspace exa
node bin/hypit.mjs build examples/semantic-composition/chat.svrun --workspace examples/semantic-composition --runtime examples/semantic-composition/hypit.runtime.json --follow
```
-The Profile selects local HyperFrames and FFmpeg. Use the machine's prepared browser/media tools;
+The Profile selects local HyperFrames and FFmpeg. Its execution data lives in `.hypit/runtimes/local`;
+`.hypit/runtime` is reserved for the project's Profile-selection file. Use the machine's prepared browser/media tools;
there is no hosted generation account in this example. The final Output is `final.video`. The same
Run can be opened in Studio, where its component lane and physical clock work without a Script lane.
For an independent project, install `@hypit/hypit`, copy the component into `packages/`, replace its workspace
diff --git a/examples/semantic-composition/chat.svml b/examples/semantic-composition/chat.svml
index 68396b8e..adb386df 100644
--- a/examples/semantic-composition/chat.svml
+++ b/examples/semantic-composition/chat.svml
@@ -9,7 +9,7 @@
<import as="style" source="./chat.svs"/>
<time:Clock id="animation-clock" frame-rate="30"/>
-<time:Timeline id="animation" clock={animation-clock} end="8s"/>
+ <time:Timeline id="animation" clock={animation-clock} end="8s"/>
<spatial:Canvas id="canvas" width="540" height="960"/>
<fonts:Stack id="font" family="inter" weight="600" style="normal"/>
<chat:Scene id="conversation" timeline={animation.timeline} canvas={canvas} font={font}
diff --git a/examples/semantic-composition/hypit.runtime.json b/examples/semantic-composition/hypit.runtime.json
index c55e7b03..b0c57e14 100644
--- a/examples/semantic-composition/hypit.runtime.json
+++ b/examples/semantic-composition/hypit.runtime.json
@@ -1,6 +1,6 @@
{
"format": "hypit.runtime-local@1",
- "dataRoot": ".hypit/runtime",
+ "dataRoot": ".hypit/runtimes/local",
"endpoints": {
"media.local": { "use": "@hypit/provider-media-local", "config": { "defaultConcurrency": 2 } },
"hyperframes.local": { "use": "@hypit/provider-hyperframes-local", "config": { "workers": 2, "defaultConcurrency": 1 } }
diff --git a/packages/cli/src/view.ts b/packages/cli/src/view.ts
index f944a2f1..d6502d4e 100644
--- a/packages/cli/src/view.ts
+++ b/packages/cli/src/view.ts
@@ -164,6 +164,8 @@ export function buildStatusView(options: {
? "unavailable" as const
: options.result?.outcome ?? (options.result === undefined ? "missing" as const : "open" as const);
const issue = options.runtime?.issue;
+ const operations = (options.runtime?.operations ?? options.result?.operations ?? [])
+ .filter((item) => options.verbose || item.status !== "completed");
return {
id: options.id,
...((options.runtime?.targets ?? options.result?.targets) === undefined ? {} : {
@@ -197,9 +199,8 @@ export function buildStatusView(options: {
}
: { message: options.resultReadError! },
}),
- ...((options.runtime?.operations ?? options.result?.operations ?? []).some((item) => item.status !== "completed") ? {
- operations: groupOperationViews((options.runtime?.operations ?? options.result?.operations ?? [])
- .filter((item) => item.status !== "completed")
+ ...(operations.length > 0 ? {
+ operations: groupOperationViews(operations
.map((item) => ({
...(!options.verbose ? {} : "operation" in item ? { id: item.operation } : item.id === undefined ? {} : { id: item.id }),
...(item.receipt === undefined || (!options.verbose && item.failure === undefined) ? {} : { receipt: item.receipt }),
diff --git a/packages/cli/test/view.test.ts b/packages/cli/test/view.test.ts
index 20003d01..c4b0677b 100644
--- a/packages/cli/test/view.test.ts
+++ b/packages/cli/test/view.test.ts
@@ -42,7 +42,7 @@ test("status groups identical active requests and retains late failures without
const runtime = {
id: "build", targets: ["final"], activity: "running",
operations: [...pending,
- { id: "done", endpoint: "chosen", status: "completed" },
+ { id: "done", endpoint: "chosen", status: "completed", receipt: { id: "completed-remote" } },
{ id: "failed", endpoint: "chosen", status: "failed", receipt: { id: "failed-remote" },
failure: { code: "NETWORK", message: "download failed" } }],
commands: [{ id: "raw-command-id", endpoint: "renderer", progress: { phase: "capturing", completed: 50, total: 100, unit: "frames" } }],
@@ -57,6 +57,17 @@ test("status groups identical active requests and retains late failures without
assert.equal(view.commands?.[0]?.progress.completed, 50);
assert.equal(view.commands?.[0]?.id, undefined);
const detailed = buildStatusView({ id: "build", runtime, verbose: true });
- assert.equal(detailed.operations?.length, 31);
+ assert.equal(detailed.operations?.length, 32);
assert.equal(detailed.operations?.[0]?.receipt?.id, "remote-0");
+ assert.equal(detailed.operations?.find(item => item.state === "completed")?.receipt?.id, "completed-remote");
+});
+
+test("finished status retains completed receipts only when requested", () => {
+ const result = { outcome: "complete", outputs: {}, operations: [
+ { id: "done", endpoint: "chosen", status: "completed", receipt: { id: "remote-task" } },
+ ] } as unknown as BuildResultManifest;
+ assert.equal(buildStatusView({ id: "build", result }).operations, undefined);
+ const detailed = buildStatusView({ id: "build", result, verbose: true });
+ assert.equal(detailed.operations?.[0]?.receipt?.id, "remote-task");
+ assert.equal(detailed.work.outcome, "complete");
});
diff --git a/packages/film/src/surface.ts b/packages/film/src/surface.ts
index 22566d22..2d548dc8 100644
--- a/packages/film/src/surface.ts
+++ b/packages/film/src/surface.ts
@@ -117,7 +117,10 @@ export const decodeFilmSurface: StructuredSurfaceHandler = ({ element, resolveRe
const name = `track-${index + 1}`;
return { name, kind: trackKind(source), source };
});
- if (new Set(tracks.map((track) => track.name)).size !== tracks.length) {
+ const sourceKeys = tracks.map(({ source: { ref } }) => ref.kind === "record"
+ ? `record\u0000${ref.id}`
+ : `component-output\u0000${ref.component}\u0000${ref.output}`);
+ if (new Set(sourceKeys).size !== tracks.length) {
throw new Error(`${element.name} cannot include the same Track more than once`);
}
const fragment = createFilmAssemblyFragment({ name: "@hypit/film/surface-assembly@1", tracks });
diff --git a/packages/film/test/surface.test.ts b/packages/film/test/surface.test.ts
index bfe13c5a..96bbcffa 100644
--- a/packages/film/test/surface.test.ts
+++ b/packages/film/test/surface.test.ts
@@ -26,17 +26,19 @@ import {
filmTypes,
} from "@hypit/film";
import type { ModuleManifest } from "@hypit/protocol";
-import { svsFrontend } from "@hypit/svs";
+import { svsFrontend, svsRecipeType } from "@hypit/svs";
import {
decodeCanvasSurface,
spatialManifest,
spatialMarkupSurfaces,
spatialModuleRef,
+ spatialTypes,
} from "@hypit/spatial";
import {
MarkupSurfaceRegistry,
createMarkupAuthorFrontend,
} from "@hypit/markup";
+import type { StructuredElement, SurfaceResolvedReference } from "@hypit/markup";
import { createRecordAdmitter, TypeValidatorRegistry } from "@hypit/validation";
const fixtureModule = { name: "example.film-fixture", version: "1" } as const;
@@ -100,7 +102,7 @@ const validStyles = `<sheet version="1">
}
</sheet>`;
-async function compileFilm(options: { readonly styles?: string } = {}) {
+async function compileFilm(options: { readonly styles?: string; readonly tracks?: string } = {}) {
const surfaces = new MarkupSurfaceRegistry();
surfaces.registerStructured({ module: fixtureModule, declaration: fixtureSurface, handler: ({ element }) => ({
records: [
@@ -141,7 +143,7 @@ async function compileFilm(options: { readonly styles?: string } = {}) {
<fixture:Inputs/>
<space:Canvas id="vertical" width="1080" height="1920"/>
<film:Film id="main" canvas={vertical} timeline={semantic} appearance={recipes.film.vertical}>
- <film:Track source={visual}/><film:Track source={audio}/>
+ ${options.tracks ?? '<film:Track source={visual}/><film:Track source={audio}/>'}
</film:Film>
</svml>`),
closure,
@@ -180,3 +182,44 @@ test("Film rejects an invalid package-owned Recipe during check", async () => {
/Film Recipe requires exactly/u,
);
});
+
+test("Film rejects a repeated Track reference during check, before executing its inputs", async () => {
+ for (const track of ["visual", "audio"]) {
+ await assert.rejects(
+ compileFilm({ tracks: `<film:Track source={${track}}/><film:Track source={${track}}/>` }),
+ /cannot include the same Track more than once/u,
+ );
+ }
+});
+
+test("Film distinguishes component output ports and resolves duplicate aliases", async () => {
+ const range = { source: "main.svml", start: 0, end: 1 };
+ const refs = new Map<string, SurfaceResolvedReference>();
+ for (const [path, type] of [["canvas", spatialTypes.canvas], ["timeline", timelineTypes.track]] as const) {
+ refs.set(path, { path, type, ref: { kind: "record", id: path } });
+ }
+ refs.set("appearance", { path: "appearance", type: svsRecipeType,
+ ref: { kind: "record", id: "appearance" }, record: { id: "appearance", type: svsRecipeType,
+ value: { kind: "inline", value: { path: "film", properties: { background: "#000000" } } } } });
+ for (const [path, component, output, type] of [
+ ["board.visual", "board", "visual", compositionTypes.visualTrack],
+ ["board.audio", "board", "audio", compositionTypes.audioTrack],
+ ["other.visual", "other", "visual", compositionTypes.visualTrack],
+ ["board-alias.visual", "board", "visual", compositionTypes.visualTrack],
+ ] as const) {
+ refs.set(path, { path, type, ref: { kind: "component-output", component, output } });
+ }
+ const decode = (paths: string[]) => {
+ const element: StructuredElement = { kind: "element", name: "film:Film", range,
+ attributes: { id: "main", canvas: { kind: "reference", path: "canvas" },
+ timeline: { kind: "reference", path: "timeline" }, appearance: { kind: "reference", path: "appearance" } },
+ children: paths.map(path => ({ kind: "element", name: "film:Track", range, children: [],
+ attributes: { source: { kind: "reference", path } } })),
+ };
+ return decodeFilmSurface({ element, sourceName: "main.svml", resolveReference: path => refs.get(path),
+ resolveAsset: () => { throw new Error("Film reads explicit references only"); } });
+ };
+ const compiled = await decode(["board.visual", "board.audio", "other.visual"]);
+ assert.deepEqual(compiled.components[0]?.inputs["track-2"], refs.get("board.audio")!.ref);
+ assert.throws(() => decode(["board.visual", "board-alias.visual"]), /cannot include the same Track more than once/u);
+});