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.

1.7 KB
Raw Blame
import { installDistributionPackageResolution } from "@hypit/hypit/loader/node";
import type { LoadedPackage } from "@hypit/hypit/loader";
import { studioContributionFromPackage } from "@hypit/studio-companion";

import { fallbackStudioTrackCompanions } from "./fallback-companions.js";
import { StudioCompanionRegistry } from "./studio-registry.js";

/**
 * Assemble the immutable Companion Registry for one Source closure.
 *
 * Every package actually selected by the Source may contribute its own Companion through the
 * same package host-facet boundary. There is no second project profile, central Companion list or
 * replacement table.
 */
export async function loadStudioCompanionRegistry(input: {
  readonly distributionPackageRoot: string;
  readonly sourcePackages: readonly LoadedPackage[];
}): Promise<StudioCompanionRegistry> {
  installDistributionPackageResolution([input.distributionPackageRoot]);
  const selected = new Map<string, LoadedPackage>();
  for (const item of input.sourcePackages) {
    if (!selected.has(item.specifier)) selected.set(item.specifier, item);
  }
  const contributions = [...selected.values()].map((item) =>
    studioContributionFromPackage(item.specifier, item.contribution.facets ?? []));
  return new StudioCompanionRegistry(
    [...fallbackStudioTrackCompanions, ...contributions.flatMap((item) => item.tracks)],
    {
      films: contributions.flatMap((item) => item.films),
      temporalDomains: contributions.flatMap((item) => item.temporalDomains),
      temporalDeclarations: contributions.flatMap((item) => item.temporalDeclarations),
      temporalRelations: contributions.flatMap((item) => item.temporalRelations),
      parameters: contributions.flatMap((item) => item.parameters),
    },
  );
}