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.

feat(studio): the display closure is everything the Run makes computable for free

kashorin82f5ce795bae
diff --git a/examples/ranking-football/swap-effect-banana-reference-sync/studio.svrun b/examples/ranking-football/swap-effect-banana-reference-sync/studio.svrun
deleted file mode 100644
index 05f3fe00..00000000
--- a/examples/ranking-football/swap-effect-banana-reference-sync/studio.svrun
+++ /dev/null
@@ -1,9 +0,0 @@
-<?svml using="@hypit/run-markup@1"?>
-<svrun version="1">
- <author source="./swap-effect-banana-reference-sync.svml"/>
- <target output="final.video"/>
- <file id="ronaldo-banana" type="@hypit/artifact@1#BlobArtifact" from="./reused/ronaldo.mp4" media-type="video/mp4"/>
- <file id="messi-banana" type="@hypit/artifact@1#BlobArtifact" from="./reused/messi.mp4" media-type="video/mp4"/>
- <satisfy output="ronaldo-take.video" candidate="ronaldo-banana"/>
- <satisfy output="messi-take.video" candidate="messi-banana"/>
-</svrun>
diff --git a/examples/ranking-football/swap-effect-banana/studio.svrun b/examples/ranking-football/swap-effect-banana/studio.svrun
deleted file mode 100644
index d294368c..00000000
--- a/examples/ranking-football/swap-effect-banana/studio.svrun
+++ /dev/null
@@ -1,9 +0,0 @@
-<?svml using="@hypit/run-markup@1"?>
-<svrun version="1">
- <author source="./swap-effect-banana.svml"/>
- <target output="final.video"/>
- <file id="ronaldo-banana" type="@hypit/artifact@1#BlobArtifact" from="./reused/ronaldo.mp4" media-type="video/mp4"/>
- <file id="messi-banana" type="@hypit/artifact@1#BlobArtifact" from="./reused/messi.mp4" media-type="video/mp4"/>
- <satisfy output="ronaldo-take.video" candidate="ronaldo-banana"/>
- <satisfy output="messi-take.video" candidate="messi-banana"/>
-</svrun>
diff --git a/packages/media-track/preview/preview.svml b/packages/media-track/preview/preview.svml
index a13af8bb..677cf647 100644
--- a/packages/media-track/preview/preview.svml
+++ b/packages/media-track/preview/preview.svml
@@ -10,10 +10,11 @@
preserve how it was authored; regenerating the encoded frame is a normal Build.
A placeholder shows the Frame treatment and nothing inside it. To show the component holding a
- picture, commit a sample beside this file and satisfy the media output in `build.svrun`:
+ picture, commit a sample beside this file and satisfy the generated output in `build.svrun`;
+ the Profile's local media Endpoint still inspects and normalizes it, in Studio as in a Build:
- <file id="sample-a" type="@hypit/artifact@1#BlobArtifact" from="./sample-a.png" media-type="image/png"/>
- <satisfy output="motion-a-media.media" candidate="sample-a"/>
+ <file id="sample-a" type="@hypit/artifact@1#BlobArtifact" from="./sample-a.mp4" media-type="video/mp4"/>
+ <satisfy output="motion-a.video" candidate="sample-a"/>
Candidate selection is explicit in the Run; Studio never replaces missing media itself. -->
<svml>
diff --git a/packages/runtime-host-node/package.json b/packages/runtime-host-node/package.json
index 972af95c..82e6e040 100644
--- a/packages/runtime-host-node/package.json
+++ b/packages/runtime-host-node/package.json
@@ -10,6 +10,7 @@
"dependencies": {
"@hypit/build-result": "workspace:*",
"@hypit/build-result-kit": "workspace:*",
+ "@hypit/driver-node": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/runtime": "workspace:*",
"@hypit/runtime-kit": "workspace:*",
diff --git a/packages/runtime-host-node/src/index.ts b/packages/runtime-host-node/src/index.ts
index c8da8857..ee4c4fe0 100644
--- a/packages/runtime-host-node/src/index.ts
+++ b/packages/runtime-host-node/src/index.ts
@@ -249,6 +249,13 @@ export type NodeRuntimeHost = {
* creates no Build, Result or state, and refuses asynchronous capabilities.
*/
invoke(need: Need, resources: ResourceStore): Promise<{ readonly value: StoredValue }>;
+ /**
+ * The Endpoints a display may execute without a Build: every Endpoint the Profile selects whose
+ * Provider declares `local` pricing, immediate capabilities only, with the Profile's bindings
+ * applied. A capability bound to a priced Endpoint stays unresolved here instead of falling to a
+ * local one, so nothing shown was ever paid for.
+ */
+ localEndpoints(): Promise<import("@hypit/driver-node").EndpointRegistry>;
runWorker(readyFile: string, owner: string): Promise<void>;
};
diff --git a/packages/runtime-local/src/config.ts b/packages/runtime-local/src/config.ts
index a4d8a8af..1c450f77 100644
--- a/packages/runtime-local/src/config.ts
+++ b/packages/runtime-local/src/config.ts
@@ -8,7 +8,7 @@ import {
} from "@hypit/package-loader-node";
import type { NodePackageSelectionRequest } from "@hypit/package-loader-node";
import { EndpointRegistry } from "@hypit/driver-node";
-import type { EndpointFulfillment } from "@hypit/endpoint-kit";
+import type { EndpointFulfillment, EndpointRegistrar } from "@hypit/endpoint-kit";
import { assertBuildId, canonicalize, canonicalStringify } from "@hypit/protocol";
import type { CanonicalValue, CapabilityRef, Need } from "@hypit/protocol";
import {
@@ -484,6 +484,32 @@ async function installedEndpointRegistry(
return endpoints;
}
+/**
+ * The Endpoints a display may execute without a Build. Only Providers that declare `local` pricing
+ * are installed, and only their immediate capabilities; the Profile's bindings still apply, so a
+ * capability bound to a priced Endpoint resolves to nothing here rather than to a local stand-in.
+ */
+export async function localRuntimeConfigEndpoints(
+ path: string,
+ options: LoadRuntimeConfigOptions = {},
+): Promise<EndpointRegistry> {
+ const { document, root, packageRoot } = await openRuntimeConfig(path, options.packageRoot);
+ const hostStateRoot = resolve(options.hostStateRoot ?? hypitHostStateRoot());
+ const registry = options.registry ?? new RuntimeAdapterRegistry();
+ await installRuntimeAdapters(registry, packageRoot, endpointPackageSelection(document), options.distributionPackageRoot);
+ const endpoints = new EndpointRegistry();
+ const immediateOnly: EndpointRegistrar = {
+ registerImmediateEndpoint: (...args) => endpoints.registerImmediateEndpoint(...args),
+ registerAsyncEndpoint: () => {},
+ };
+ for (const { activation } of await activatedEndpoints(document, root, hostStateRoot, registry)) {
+ if (activation.endpoint.pricing?.kind !== "local") continue;
+ await activation.endpoint.install(immediateOnly);
+ }
+ applyEndpointBindings(endpoints, document.bindings);
+ return endpoints;
+}
+
/** Static Endpoint selection per capability. Reads the Profile and activations only; never a credential or a service. */
export async function describeRuntimeConfigProviders(
path: string,
diff --git a/packages/runtime-local/src/host.ts b/packages/runtime-local/src/host.ts
index ec4fbdb1..45875224 100644
--- a/packages/runtime-local/src/host.ts
+++ b/packages/runtime-local/src/host.ts
@@ -15,6 +15,7 @@ import {
describeRuntimeConfigProviders,
doctorRuntimeConfig,
invokeRuntimeConfigNeed,
+ localRuntimeConfigEndpoints,
prepareRuntimeConfigPackages,
preflightRuntimeConfig,
resolveRuntimeConfigPaths,
@@ -140,6 +141,10 @@ export async function openLocalRuntimeHost(
packageRoot: basePackageRoot,
...distribution,
}),
+ localEndpoints: async () => await localRuntimeConfigEndpoints(profile, {
+ packageRoot: basePackageRoot,
+ ...distribution,
+ }),
runWorker: async (readyFile, owner) => {
const selected = await resolveRuntimeConfigPaths(profile, { packageRoot: basePackageRoot, ...distribution });
const leaseState = new SqliteRuntimeState(join(selected.dataRoot, "runtime.sqlite"));
diff --git a/packages/runtime-local/src/index.ts b/packages/runtime-local/src/index.ts
index 31711dfb..a90ea9c7 100644
--- a/packages/runtime-local/src/index.ts
+++ b/packages/runtime-local/src/index.ts
@@ -19,6 +19,7 @@ export {
describeRuntimeConfigProviders,
doctorRuntimeConfig,
invokeRuntimeConfigNeed,
+ localRuntimeConfigEndpoints,
prepareRuntimeConfigPackages,
preflightRuntimeConfig,
parseLocalRuntimeProfile,
diff --git a/packages/runtime-local/test/config.test.ts b/packages/runtime-local/test/config.test.ts
index 126b278e..0e2c7b3e 100644
--- a/packages/runtime-local/test/config.test.ts
+++ b/packages/runtime-local/test/config.test.ts
@@ -28,6 +28,7 @@ import {
doctorProjectBuildResultRepository,
doctorRuntimeConfig,
invokeRuntimeConfigNeed,
+ localRuntimeConfigEndpoints,
openProjectBuildResultRepository,
parseLocalRuntimeProfile,
preflightRuntimeConfig,
@@ -337,6 +338,59 @@ test("Runtime providers name the selected Endpoint and its declared price source
}
});
+test("local Endpoints for display install only local-priced Providers and keep the Profile's bindings", async () => {
+ const root = await mkdtemp(join(tmpdir(), "hypit-runtime-local-endpoints-"));
+ const path = join(root, "hypit.runtime.json");
+ const generate = { module: { name: "example.model", version: "1" }, name: "generate" } as const;
+ const render = { module: { name: "example.render", version: "1" }, name: "render" } as const;
+ const returns = { module: { name: "example.value", version: "1" }, name: "Output" } as const;
+ const handler = () => ({ value: { kind: "inline" as const, value: null } });
+ await writeFile(path, JSON.stringify(profile({
+ dataRoot: ".",
+ endpoints: { paid: { use: "example.paid" }, local: { use: "example.local" }, "local-b": { use: "example.local" } },
+ bindings: { "example.render@1#render": "local", "example.model@1#generate": "paid" },
+ })));
+ const registry = new RuntimeAdapterRegistry();
+ registry.registerFacet(createRuntimeEndpointAdapterFacet({
+ use: "example.paid",
+ activate: (context) => ({
+ endpoint: defineEndpointPackage({
+ module: { name: "example.provider", version: "1" },
+ facet: "paid",
+ instance: context.instance,
+ pool: context.pool ?? context.instance,
+ pricing: { kind: "page", url: "https://prices.example/models" },
+ capabilities: [
+ { capability: generate, returns, lifecycle: "immediate", handler },
+ { capability: render, returns, lifecycle: "immediate", handler },
+ ],
+ }),
+ }),
+ }));
+ registry.registerFacet(createRuntimeEndpointAdapterFacet({
+ use: "example.local",
+ activate: (context) => ({
+ endpoint: defineEndpointPackage({
+ module: { name: "example.local-provider", version: "1" },
+ facet: "local",
+ instance: context.instance,
+ pool: context.pool ?? context.instance,
+ pricing: { kind: "local" },
+ capabilities: [{ capability: render, returns, lifecycle: "immediate", handler }],
+ }),
+ }),
+ }));
+ try {
+ const endpoints = await localRuntimeConfigEndpoints(path, { registry });
+ assert.deepEqual(endpoints.endpointIds(), ["local", "local-b"], "a priced Provider is never installed for display");
+ assert.equal(endpoints.resolve({ capability: render, returns }).status, "resolved", "the binding picks one local Endpoint");
+ const bound = endpoints.resolve({ capability: generate, returns });
+ assert.deepEqual(bound, { status: "missing", endpointId: "paid" }, "a capability bound to a priced Endpoint stays unresolved");
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
test("Runtime provider inspection applies Endpoint supports when the complete request is available", async () => {
const root = await mkdtemp(join(tmpdir(), "hypit-runtime-provider-supports-"));
const path = join(root, "hypit.runtime.json");
diff --git a/packages/studio/README.md b/packages/studio/README.md
index 818e60aa..04be864c 100644
--- a/packages/studio/README.md
+++ b/packages/studio/README.md
@@ -76,12 +76,17 @@ endpoint's author authority and direct consumer edge. Common timeline inverses c
authority rather than Companion declarations. Track Companions never infer semantic sources from SVML
attribute names, runtime id prefixes or coincident frame spans.
-Opening Studio never invokes a Provider and never creates a Build. Every
-projection needed for display must already be supplied by the Run or be
-deterministically derivable from those supplied Candidates.
+Opening Studio never spends and never creates a Build. Its display closure is
+everything the Run makes computable for free: supplied Candidates, deterministic
+Producers, and Needs served by the selected Profile's local Endpoints (Providers
+that declare `local` pricing, such as the FFmpeg media Endpoint that inspects and
+normalizes a media file). Resolution is the same as `plan` and a Build use,
+including the Profile's bindings, minus every priced Endpoint; a Need that reaches
+a priced Endpoint or none at all stops Studio with the capability named, and the
+author supplies a Candidate for that output or builds the Run.
Studio and an encoded review use the same ordinary Run. Studio evaluates its
-deterministic display closure in the browser; building that Run evaluates the
+free display closure in the browser; building that Run evaluates the
full target closure and sends the resulting HyperFrames document to the chosen
render Endpoint. A separate review Run is useful only when the author wants a
different Candidate selection. Its path and filename carry no execution
diff --git a/packages/studio/src/build-library.ts b/packages/studio/src/build-library.ts
index a9f15fc9..a3b4da81 100644
--- a/packages/studio/src/build-library.ts
+++ b/packages/studio/src/build-library.ts
@@ -1,6 +1,7 @@
import { isAbsolute, relative, resolve, sep } from "node:path";
import { buildIdCreatedAt } from "@hypit/protocol";
+import type { EndpointRegistry } from "@hypit/driver-node";
import type { BuildView, NodeRuntimeHost } from "@hypit/runtime-host-node";
import type { StoredValue, TypeRef } from "@hypit/protocol";
import type {
@@ -22,6 +23,8 @@ type RuntimeControl = Awaited<ReturnType<NodeRuntimeHost["openControl"]>>;
export type StudioBuildLibrary = {
readonly profile?: string;
readonly runtime?: Pick<RuntimeControl, "activity">;
+ /** The Profile's local Endpoints: what Studio may execute for display without a Build. */
+ readonly endpoints?: EndpointRegistry;
readonly library: (before?: string) => Promise<StudioLibraryView>;
readonly resolveHistoricalOutput: (
build: string,
@@ -229,8 +232,10 @@ export async function openStudioBuildLibrary(
...(distributionPackageRoot === undefined ? {} : { distributionPackageRoot }),
});
const runtime = await host?.openControl({ readOnly: true });
+ let endpoints: EndpointRegistry | undefined;
let openedResults: Awaited<ReturnType<typeof videoCliDistribution.openProjectResults>>;
try {
+ endpoints = await host?.localEndpoints();
openedResults = await videoCliDistribution.openProjectResults(workspaceRoot, {
packageRoot,
...(distributionPackageRoot === undefined ? {} : { distributionPackageRoot }),
@@ -243,6 +248,7 @@ export async function openStudioBuildLibrary(
return {
...(resolvedProfile === undefined ? {} : { profile: resolvedProfile }),
...(runtime === undefined ? {} : { runtime }),
+ ...(endpoints === undefined ? {} : { endpoints }),
async library(before) {
return await readStudioLibrary({
...(resolvedProfile === undefined ? {} : { profile: resolvedProfile }),
diff --git a/packages/studio/src/execute.ts b/packages/studio/src/execute.ts
index cbab10c8..0d0a200a 100644
--- a/packages/studio/src/execute.ts
+++ b/packages/studio/src/execute.ts
@@ -11,13 +11,17 @@ export type Executed = {
readonly errors: readonly string[];
};
-/** Run only deterministic Producers; Studio never installs or invokes Provider endpoints. */
+/**
+ * Run the display closure: deterministic Producers, plus Needs served by the Profile's local
+ * Endpoints when the caller hands them in. Nothing priced is ever installed here; a Need that
+ * reaches no installed Endpoint is reported as unserved, never guessed at.
+ */
export async function executeDeterministic(
domain: StudioDomain,
planned: BuildState,
resources: ResourceStore,
+ endpoints: EndpointRegistry = new EndpointRegistry(),
): Promise<Executed> {
- const endpoints = new EndpointRegistry();
const result = await new NodeDriver({
producers: domain.producers,
validators: domain.validators,
diff --git a/packages/studio/src/programme.ts b/packages/studio/src/programme.ts
index e863bbac..22a15579 100644
--- a/packages/studio/src/programme.ts
+++ b/packages/studio/src/programme.ts
@@ -15,6 +15,8 @@ import type { StudioResolvedTrack, StudioTemporalBinding } from "@hypit/studio-a
import type { CompiledSource, ServedFile } from "./compile.js";
import type { StudioDomain } from "./domain.js";
+import type { EndpointRegistry } from "@hypit/driver-node";
+
import { executeDeterministic, MemoryResourceStore } from "./execute.js";
import type { RunPlan } from "./run.js";
import type { StudioViewRequirement } from "./studio-preflight.js";
@@ -109,6 +111,8 @@ export async function preview(input: {
readonly outputRefs: readonly string[];
readonly compositionRef: string;
readonly projections: readonly StudioViewRequirement[];
+ /** The Profile's local Endpoints, when a Runtime Profile is selected. */
+ readonly endpoints?: EndpointRegistry;
}): Promise<Preview> {
const exportsByRef = new Map(input.source.exports.map((item) => [item.ref, item] as const));
const targets = input.outputRefs.flatMap((ref) => {
@@ -146,7 +150,7 @@ export async function preview(input: {
},
};
const planned = input.run.plan(input.run.run, targets.map((target) => target.ref));
- const executed = await executeDeterministic(input.domain, planned.state, resources);
+ const executed = await executeDeterministic(input.domain, planned.state, resources, input.endpoints);
if (executed.unserved.length > 0) {
throw new Error(
`Studio projection is unresolved: ${executed.unserved.map((item) => item.capability).join(", ")}`,
diff --git a/packages/studio/src/server.ts b/packages/studio/src/server.ts
index e072a849..e78b0223 100644
--- a/packages/studio/src/server.ts
+++ b/packages/studio/src/server.ts
@@ -146,7 +146,7 @@ export function studioPlugin(options: StudioPluginOptions): Plugin {
domain: options.domain,
registry: options.registry,
run,
- ...(options.buildLibrary === undefined ? {} : { buildLibrary: options.buildLibrary }),
+ ...(options.buildLibrary?.endpoints === undefined ? {} : { endpoints: options.buildLibrary.endpoints }),
revision: attempt,
sourcePath: relative(options.workspaceRoot, run.authorSource),
workspaceRoot: options.workspaceRoot,
diff --git a/packages/studio/src/session.ts b/packages/studio/src/session.ts
index a7f7ba2e..ffb32469 100644
--- a/packages/studio/src/session.ts
+++ b/packages/studio/src/session.ts
@@ -1,6 +1,7 @@
import { existsSync, readFileSync } from "node:fs";
import { relative } from "node:path";
+import type { EndpointRegistry } from "@hypit/driver-node";
import { markupAuthorFrontendId } from "@hypit/markup";
import { svsFrontendId } from "@hypit/svs";
@@ -58,9 +59,10 @@ export async function readStudioSession(input: {
readonly revision: number;
readonly sourcePath?: string;
readonly workspaceRoot: string;
+ readonly endpoints?: EndpointRegistry;
}): Promise<StudioSession> {
const source = input.run.source;
- const inspection = inspectStudioRun(input.registry, source, input.run);
+ const inspection = inspectStudioRun(input.registry, source, input.run, input.endpoints);
const outputRefs = [
inspection.filmComposition,
...inspection.projections.map((projection) => projection.ref),
@@ -72,6 +74,7 @@ export async function readStudioSession(input: {
outputRefs,
compositionRef: inspection.filmComposition,
projections: inspection.projections,
+ ...(input.endpoints === undefined ? {} : { endpoints: input.endpoints }),
});
const rendered = renderPreview({
composition: built.composition,
diff --git a/packages/studio/src/studio-preflight.ts b/packages/studio/src/studio-preflight.ts
index db4b8a7e..04062531 100644
--- a/packages/studio/src/studio-preflight.ts
+++ b/packages/studio/src/studio-preflight.ts
@@ -1,4 +1,6 @@
import { plannedNeeds } from "@hypit/core";
+import type { PlannedNeed } from "@hypit/core";
+import type { EndpointRegistry } from "@hypit/driver-node";
import type { Candidate } from "@hypit/protocol";
import { sameType } from "@hypit/protocol";
import type { StudioFilmCompanion } from "@hypit/studio-adapter";
@@ -49,11 +51,20 @@ function candidateIsMaterialized(candidate: Candidate | undefined): boolean {
&& candidate.root.value.value.kind === "inline";
}
-function plannedExternalNeeds(base: RunPlan, refs: readonly string[]): readonly string[] {
+/**
+ * The capabilities of a display closure that no local Endpoint serves. With no Profile every Need
+ * is unserved; with one, a Need resolves exactly as `plan` and a Build resolve it, minus every
+ * priced Endpoint.
+ */
+export function unservedNeeds(needs: readonly PlannedNeed[], endpoints: EndpointRegistry | undefined): readonly string[] {
+ return unique(needs
+ .filter((need) => endpoints?.resolve({ capability: need.capability, returns: need.returns }).status !== "resolved")
+ .map((need) => `${need.capability.module.name}@${need.capability.module.version}#${need.capability.name}`));
+}
+
+function plannedExternalNeeds(base: RunPlan, refs: readonly string[], endpoints: EndpointRegistry | undefined): readonly string[] {
const planned = base.plan(base.run, refs);
- return unique(plannedNeeds(planned.state).map((need) =>
- `${need.capability.module.name}@${need.capability.module.version}#${need.capability.name}`,
- ));
+ return unservedNeeds(plannedNeeds(planned.state), endpoints);
}
function localName(value: string): string {
@@ -93,6 +104,7 @@ export function inspectStudioRun(
registry: StudioCompanionRegistry,
source: CompiledSource,
base: RunPlan,
+ endpoints?: EndpointRegistry,
): StudioInspection {
const issues: string[] = [];
if (base.targets.length === 0) issues.push("the Run Source has no target; Studio requires Film or Render");
@@ -187,9 +199,11 @@ export function inspectStudioRun(
}
if (derived.length > 0) {
- const needs = plannedExternalNeeds(base, derived.map((projection) => projection.ref));
+ const needs = plannedExternalNeeds(base, derived.map((projection) => projection.ref), endpoints);
if (needs.length > 0) {
- issues.push(`the Studio projection closure requires unresolved capabilities: ${needs.join(", ")}`);
+ issues.push(endpoints === undefined
+ ? `the display closure needs ${needs.join(", ")} and no Runtime Profile is selected; select one, or supply Candidates for those outputs`
+ : `the display closure needs ${needs.join(", ")}, which no local Endpoint of the Profile serves; supply Candidates for those outputs or build the Run`);
} else {
projections.push(...derived.map((projection) => ({
...projection,
diff --git a/packages/studio/start.ts b/packages/studio/start.ts
index 7a653dd1..dfc65669 100644
--- a/packages/studio/start.ts
+++ b/packages/studio/start.ts
@@ -94,7 +94,7 @@ try {
}
const source = run.authorSource;
try {
- inspectStudioRun(registry, run.source, run);
+ inspectStudioRun(registry, run.source, run, buildLibrary.endpoints);
} catch (error) {
await buildLibrary.close();
throw error;
diff --git a/packages/studio/test/preflight.test.ts b/packages/studio/test/preflight.test.ts
index a8f53306..b857e298 100644
--- a/packages/studio/test/preflight.test.ts
+++ b/packages/studio/test/preflight.test.ts
@@ -2,12 +2,14 @@ import assert from "node:assert/strict";
import test from "node:test";
import { compositionTypes } from "@hypit/composition";
+import type { PlannedNeed } from "@hypit/core";
+import { EndpointRegistry } from "@hypit/driver-node";
import { semanticTrackTypes } from "@hypit/semantic-track";
import type { StudioFilmCompanion, StudioPlacement } from "@hypit/studio-adapter";
import type { CompiledSource } from "../src/compile.js";
import type { RunPlan } from "../src/run.js";
-import { inspectStudioRun, StudioPreflightError } from "../src/studio-preflight.js";
+import { inspectStudioRun, StudioPreflightError, unservedNeeds } from "../src/studio-preflight.js";
import { StudioCompanionRegistry } from "../src/studio-registry.js";
const filmModule = { name: "@example/film", version: "1" } as const;
@@ -48,3 +50,20 @@ test("Studio rejects a Run that reaches two distinct Film compositions", () => {
&& error.issues.some((issue) => issue.includes("multiple Film compositions")),
);
});
+
+test("the display closure may reach a Need only through a local Endpoint the Profile installed", () => {
+ const normalize = { module: { name: "@hypit/media-pipeline", version: "1" }, name: "normalize-media" } as const;
+ const generate = { module: { name: "@hypit/seedance", version: "1" }, name: "seedance-2-mini" } as const;
+ const returns = { module: { name: "@hypit/artifact", version: "1" }, name: "BlobArtifact" } as const;
+ const needs: PlannedNeed[] = [
+ { step: "step:a", port: "media", need: "need:a", result: "record:a", capability: normalize, returns },
+ { step: "step:b", port: "video", need: "need:b", result: "record:b", capability: generate, returns },
+ ] as unknown as PlannedNeed[];
+ assert.deepEqual(unservedNeeds(needs, undefined), ["@hypit/media-pipeline@1#normalize-media", "@hypit/seedance@1#seedance-2-mini"]);
+ const endpoints = new EndpointRegistry();
+ endpoints.registerImmediateEndpoint("media.local", normalize, returns, () => ({ value: { kind: "inline", value: null } }));
+ assert.deepEqual(unservedNeeds(needs, endpoints), ["@hypit/seedance@1#seedance-2-mini"]);
+ endpoints.bind(normalize, "media.other");
+ assert.deepEqual(unservedNeeds(needs, endpoints), ["@hypit/media-pipeline@1#normalize-media", "@hypit/seedance@1#seedance-2-mini"],
+ "a binding to an Endpoint that is not installed for display leaves the Need unserved");
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 898ca485..9db6e5e1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2460,6 +2460,9 @@ importers:
'@hypit/build-result-kit':
specifier: workspace:*
version: link:../build-result-kit
+ '@hypit/driver-node':
+ specifier: workspace:*
+ version: link:../driver-node
'@hypit/protocol':
specifier: workspace:*
version: link:../protocol