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: retain incremental component package closure
kashorinffec916dcddc
diff --git a/.agents/skills/hypit/references/runtime.md b/.agents/skills/hypit/references/runtime.mdindex 7d5ef280..b983153b 100644--- a/.agents/skills/hypit/references/runtime.md+++ b/.agents/skills/hypit/references/runtime.md@@ -66,6 +66,9 @@ Builds remain archived and neither command cancels remote Provider work.earlier Build; reuse across Builds exists only through explicit Run Source Candidates.- `inspect` reads durable Build state and accepted Records. `get` copies an archived Artifact to therequested destination.+- A running Worker loads an installed Component package when a Build first names it and remembers+ every physical package in that dependency closure. A later Build may add another installed+ Component package without restarting the Worker; shared dependencies are not registered twice.- There is no implicit cache or Pin state. Reuse Records through a new `.svrun` containing`build-record` and `satisfy`; the Candidate supplies the exact nominal Type required by thecurrent Logical Output.diff --git a/docs/guide/runtime.md b/docs/guide/runtime.mdindex 9c27a8af..674ec816 100644--- a/docs/guide/runtime.md+++ b/docs/guide/runtime.md@@ -115,6 +115,12 @@ is available. `status`, `queue` and `cancel` observe or control durable work. Aresumed. Reusing an earlier result is an explicit Candidate in a new `.svrun`, not hidden Runtimebehavior.+A running Worker loads installed Component packages as Builds first require them. A later Build may+name a new Component package without restarting the Worker; the Worker loads only packages it has+not already seen from that package's complete dependency closure. Loaded package code is not hot+reloaded, so editing a package or updating the Distribution still requires stopping an idle Worker+before the next Build.+Runtime packages are trusted local deployment code. npm or pnpm owns their installed versions;Hypit only selects exact requirements and invokes npm at the explicit `runtime up`/`packages install`boundary. It has no second package lock and does not claim that metadata is a sandbox.diff --git a/docs/zh/guide/runtime.md b/docs/zh/guide/runtime.mdindex b5760677..6e9ad567 100644--- a/docs/zh/guide/runtime.md+++ b/docs/zh/guide/runtime.md@@ -110,5 +110,10 @@ Program 并启动本地 Worker。`build` 不做部署:它执行便宜只读预Worker 可用。`status`、`queue`、`cancel` 用来观察和控制耐久工作。终态 Build 不恢复;复用以前的结果必须在新的 `.svrun` 中显式写 Candidate。+运行中的 Worker 会在 Build 第一次需要某个已安装 Component 包时加载它。后续 Build 可以在+不重启 Worker 的情况下新增 Component 包;Worker 会沿完整依赖闭包只加载尚未见过的部分。+已经加载的包代码不会热更新,因此修改包代码或更新 Distribution 后,仍需等 Worker 空闲再将+其停止,然后提交下一次 Build。+Runtime 包是本地可信部署代码,其安装版本由 npm 或 pnpm 管理。Hypit 只在显式 `runtime up` /`packages install` 边界选择精确依赖并调用 npm,不维护第二份包锁,也不会把元数据冒充成沙箱。diff --git a/packages/package-loader-node/src/contribution.ts b/packages/package-loader-node/src/contribution.tsindex 937e4bd9..055d932f 100644--- a/packages/package-loader-node/src/contribution.ts+++ b/packages/package-loader-node/src/contribution.ts@@ -1,6 +1,11 @@import type { ComponentPackage } from "@hypit/component-kit";-import type { NodeModuleContribution, NodePackageContribution } from "./types.js";+import type {+ LoadedComponentPackage,+ LoadedPackage,+ NodeModuleContribution,+ NodePackageContribution,+} from "./types.js";function assertPackage(value: NodePackageContribution): void {if (value.format !== "hypit.node-package@1") {@@ -79,3 +84,14 @@ export function collectNodePackageComponents(}return components;}++/** Validate a loaded selection while preserving the physical owner of every Component package. */+export function collectLoadedNodePackageComponents(+ packages: readonly LoadedPackage[],+): readonly LoadedComponentPackage[] {+ collectNodePackageComponents(packages.map((item) => item.contribution));+ return packages.map((item) => ({+ specifier: item.specifier,+ components: item.contribution.components ?? [],+ }));+}diff --git a/packages/package-loader-node/src/index.ts b/packages/package-loader-node/src/index.tsindex 44274305..868a1411 100644--- a/packages/package-loader-node/src/index.ts+++ b/packages/package-loader-node/src/index.ts@@ -1,4 +1,5 @@export {+ collectLoadedNodePackageComponents,collectNodePackageComponents,} from "./contribution.js";export {diff --git a/packages/package-loader-node/src/types.ts b/packages/package-loader-node/src/types.tsindex 4d0449af..4e619077 100644--- a/packages/package-loader-node/src/types.ts+++ b/packages/package-loader-node/src/types.ts@@ -33,6 +33,12 @@ export type LoadedPackage = {readonly contribution: NodePackageContribution;};+/** Runtime Component implementations grouped by their physical package owner. */+export type LoadedComponentPackage = {+ readonly specifier: string;+ readonly components: readonly ComponentPackage[];+};+export type NodePackageSelectionRequest = {/** Physical packages selected by Source discovery or a Runtime Profile. */readonly selected: readonly string[];diff --git a/packages/runtime-local/src/config.ts b/packages/runtime-local/src/config.tsindex 3173d95d..2866e8f2 100644--- a/packages/runtime-local/src/config.ts+++ b/packages/runtime-local/src/config.ts@@ -2,7 +2,7 @@ import { readFile, stat } from "node:fs/promises";import { dirname, resolve } from "node:path";import {- collectNodePackageComponents,+ collectLoadedNodePackageComponents,distributionExternalPackageRequirements,loadNodePackageSelection,} from "@hypit/package-loader-node";@@ -504,7 +504,7 @@ export async function createRuntimeFromConfig(? {}: { fallbackRoots: [options.distributionPackageRoot] }),});- return collectNodePackageComponents(loaded.map((item) => item.contribution));+ return collectLoadedNodePackageComponents(loaded);},endpoints,close: async () => {diff --git a/packages/runtime-local/src/runtime.ts b/packages/runtime-local/src/runtime.tsindex 1d934859..0fd25c30 100644--- a/packages/runtime-local/src/runtime.ts+++ b/packages/runtime-local/src/runtime.ts@@ -69,12 +69,15 @@ export async function createLocalRuntime(if (missing.length === 0) return;assert(options.loadComponentPackages !== undefined,`Build requires component package ${missing[0]} but this Runtime cannot load installed packages`);- const components = await options.loadComponentPackages(missing);- for (const component of components) {- registerTypeValidatorFacets(validators, component.validators ?? []);- registerProducerFacets(producers, component.producers ?? []);+ const loaded = await options.loadComponentPackages(missing);+ const fresh = loaded.filter((item) => !loadedComponentPackages.has(item.specifier));+ for (const item of fresh) {+ for (const component of item.components) {+ registerTypeValidatorFacets(validators, component.validators ?? []);+ registerProducerFacets(producers, component.producers ?? []);+ }}- for (const item of missing) loadedComponentPackages.add(item);+ for (const item of fresh) loadedComponentPackages.add(item.specifier);});componentInstallation = task.then(() => undefined, () => undefined);await task;diff --git a/packages/runtime-local/src/types.ts b/packages/runtime-local/src/types.tsindex f2e042e4..27be64a6 100644--- a/packages/runtime-local/src/types.ts+++ b/packages/runtime-local/src/types.ts@@ -1,5 +1,6 @@import type { Awaitable, ComponentPackage } from "@hypit/component-kit";import type { EndpointPackage } from "@hypit/endpoint-kit";+import type { LoadedComponentPackage } from "@hypit/package-loader-node";import type {ArtifactStore,BuildCatalog,@@ -26,8 +27,8 @@ export type CreateLocalRuntimeOptions = {readonly artifactStore: ArtifactStore;readonly credentialStore: CredentialStore;readonly components?: readonly ComponentPackage[];- /** Load the component packages named by a claimed Build. */- readonly loadComponentPackages?: (specifiers: readonly string[]) => Awaitable<readonly ComponentPackage[]>;+ /** Load the complete physical package closure named by a claimed Build. */+ readonly loadComponentPackages?: (specifiers: readonly string[]) => Awaitable<readonly LoadedComponentPackage[]>;readonly endpoints?: readonly EndpointPackage[];readonly close?: () => Awaitable<void>;};diff --git a/packages/runtime-local/test/local.test.ts b/packages/runtime-local/test/local.test.tsindex d7039e66..4bdb9932 100644--- a/packages/runtime-local/test/local.test.ts+++ b/packages/runtime-local/test/local.test.ts@@ -19,7 +19,7 @@ import type { ComponentPackage } from "@hypit/component-kit";import { createLocalRuntime } from "@hypit/runtime-local";import { defineBuild } from "@hypit/core";import {- collectNodePackageComponents,+ collectLoadedNodePackageComponents,loadNodePackageSelection,} from "@hypit/package-loader-node";import { credentialRef } from "@hypit/runtime";@@ -387,7 +387,7 @@ test("project local runtime accepts components loaded from an installed package"...projectRuntimeFixture(runtimeRoot),loadComponentPackages: async (specifiers) => {const loaded = await loadNodePackageSelection(specifiers, installedRoot);- return collectNodePackageComponents(loaded.map((item) => item.contribution));+ return collectLoadedNodePackageComponents(loaded);},});const result = await runtime.build({@@ -408,6 +408,71 @@ test("project local runtime accepts components loaded from an installed package"}});+test("project local runtime remembers the complete package closure across incremental Builds", async () => {+ const directory = await mkdtemp(join(tmpdir(), "hypit-local-component-closure-"));+ const loadedSelections: string[][] = [];+ const sharedComponents: ComponentPackage = {+ validators: [{ type: types.intent, handler() {} }],+ producers: [+ {+ producer: producers.makePrompt,+ handler({ inputs }) {+ const intent = inputs.intent?.value;+ assert.equal(intent?.kind, "inline");+ const name = (intent.value as { readonly name: string }).name;+ return { outputs: { prompt: { kind: "inline", value: `Greet ${name}` } }, needs: {} };+ },+ },+ {+ producer: producers.placeholderText,+ handler() {+ return { outputs: { generated: { kind: "inline", value: "Preview greeting" } }, needs: {} };+ },+ },+ {+ producer: producers.assemble,+ handler({ inputs }) {+ const generated = inputs.generated?.value;+ assert.equal(generated?.kind, "inline");+ return { outputs: { document: { kind: "inline", value: { text: generated.value } } }, needs: {} };+ },+ },+ ],+ };+ const runtime = await createLocalRuntime({+ ...projectRuntimeFixture(directory),+ loadComponentPackages(specifiers) {+ loadedSelections.push([...specifiers]);+ return [+ ...specifiers.map((specifier) => ({ specifier, components: [] })),+ { specifier: "example-shared-components", components: [sharedComponents] },+ ];+ },+ });+ try {+ for (const [id, specifier] of [+ ["component-closure-a", "example-feature-a"],+ ["component-closure-b", "example-feature-b"],+ ["component-closure-shared", "example-shared-components"],+ ] as const) {+ await runtime.build({+ id,+ definition: definition(createGreetingBuild({ generationRealization: "placeholder" })),+ componentPackages: [specifier],+ });+ const completed = await runtime.workOnce();+ assert.equal(completed?.terminal, "complete");+ }+ assert.deepEqual(loadedSelections, [+ ["example-feature-a"],+ ["example-feature-b"],+ ]);+ } finally {+ await runtime.close();+ await rm(directory, { recursive: true, force: true });+ }+});+test("project local runtime accepts an explicitly selected replacement ArtifactStore package", async () => {const directory = await mkdtemp(join(tmpdir(), "hypit-local-artifacts-"));const artifactStore = new MemoryArtifactStore();