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
refactor: name the Runtime's own parts runtimeServices
kashorina12f82d9379a
diff --git a/docs/guide/runtime-profile.md b/docs/guide/runtime-profile.mdindex 46fc3d90..8eee4602 100644--- a/docs/guide/runtime-profile.md+++ b/docs/guide/runtime-profile.md@@ -23,7 +23,6 @@ Two forms are supported:"format": "svml.runtime-config@1","packageLock": "./svml.packages.lock","runtimePackageLock": "./svml.runtime-packages.lock",- "services": [],"endpoints": [{"use": "@narratage/provider-kie",diff --git a/docs/zh/guide/runtime-profile.md b/docs/zh/guide/runtime-profile.mdindex 34a06ece..0cd0b030 100644--- a/docs/zh/guide/runtime-profile.md+++ b/docs/zh/guide/runtime-profile.md@@ -21,7 +21,6 @@ Runtime Profile 声明冻结后的 Build *在哪里*执行:Endpoint、凭据"format": "svml.runtime-config@1","packageLock": "./svml.packages.lock","runtimePackageLock": "./svml.runtime-packages.lock",- "services": [],"endpoints": [{"use": "@narratage/provider-kie",diff --git a/examples/echo-pro-aroll/svml.runtime.json b/examples/echo-pro-aroll/svml.runtime.jsonindex 2e85a771..e9a40665 100644--- a/examples/echo-pro-aroll/svml.runtime.json+++ b/examples/echo-pro-aroll/svml.runtime.json@@ -2,7 +2,6 @@"format": "svml.runtime-config@1","packageLock": "./svml.packages.lock","runtimePackageLock": "./svml.runtime-packages.lock",- "services": [],"endpoints": [{"use": "@narratage/provider-kie",diff --git a/examples/talking-film-live/svml.runtime.json b/examples/talking-film-live/svml.runtime.jsonindex 5102f63f..37d46da0 100644--- a/examples/talking-film-live/svml.runtime.json+++ b/examples/talking-film-live/svml.runtime.json@@ -2,7 +2,6 @@"format": "svml.runtime-config@1","packageLock": "./svml.packages.lock","runtimePackageLock": "./svml.runtime-packages.lock",- "services": [],"endpoints": [{"use": "@narratage/provider-kie",diff --git a/packages/local/src/config.ts b/packages/local/src/config.tsindex 3438ed34..69558975 100644--- a/packages/local/src/config.ts+++ b/packages/local/src/config.ts@@ -31,17 +31,9 @@ export type RuntimeConfigDocument = {readonly packageLock?: string;/** Locked physical packages allowed to configure privileged Runtime adapters. */readonly runtimePackageLock?: string;- readonly services: readonly RuntimeConfigEntry[];+ /** Replaceable parts of the Runtime itself. One package may fill several roles. */+ readonly runtimeServices: readonly RuntimeConfigEntry[];readonly endpoints: readonly RuntimeConfigEntry[];- readonly selection?: {- readonly scheduler?: string;- readonly stores?: {- readonly build?: string;- readonly operations?: string;- readonly artifacts?: string;- readonly credentials?: string;- };- };readonly permissions: readonly string[];readonly scheduling?: {readonly maxConcurrency?: number;@@ -98,23 +90,6 @@ function entry(value: unknown, subject: string, laneAllowed: boolean): RuntimeCo};}-function selection(value: unknown): RuntimeConfigDocument["selection"] {- if (value === undefined) return undefined;- const item = object(value, "$runtime.selection");- exactKeys(item, ["scheduler", "stores"], "$runtime.selection");- const stores = item.stores === undefined ? undefined : object(item.stores, "$runtime.selection.stores");- if (stores !== undefined) exactKeys(stores, ["build", "operations", "artifacts", "credentials"], "$runtime.selection.stores");- const scheduler = optionalString(item.scheduler, "$runtime.selection.scheduler");- return {- ...(scheduler === undefined ? {} : { scheduler }),- ...(stores === undefined ? {} : { stores: {- ...(optionalString(stores.build, "$runtime.selection.stores.build") === undefined ? {} : { build: stores.build as string }),- ...(optionalString(stores.operations, "$runtime.selection.stores.operations") === undefined ? {} : { operations: stores.operations as string }),- ...(optionalString(stores.artifacts, "$runtime.selection.stores.artifacts") === undefined ? {} : { artifacts: stores.artifacts as string }),- ...(optionalString(stores.credentials, "$runtime.selection.stores.credentials") === undefined ? {} : { credentials: stores.credentials as string }),- } }),- };-}function scheduling(value: unknown): RuntimeConfigDocument["scheduling"] {if (value === undefined) return undefined;@@ -140,21 +115,20 @@ export function parseRuntimeConfig(value: unknown): RuntimeConfigDocument {const item = object(value, "$runtime");exactKeys(item, ["format", "root", "statePath", "catalogPath", "artifactPath", "packageLock", "runtimePackageLock",- "services", "endpoints",- "selection", "permissions", "scheduling",+ "runtimeServices", "endpoints",+ "permissions", "scheduling",], "$runtime");if (item.format !== "svml.runtime-config@1") throw new Error("$runtime.format must be svml.runtime-config@1");- const services = item.services === undefined ? [] : (() => {- if (!Array.isArray(item.services)) throw new Error("$runtime.services must be an array");- return item.services.map((value, index) => entry(value, `$runtime.services[${index}]`, false));+ const runtimeServices = item.runtimeServices === undefined ? [] : (() => {+ if (!Array.isArray(item.runtimeServices)) throw new Error("$runtime.runtimeServices must be an array");+ return item.runtimeServices.map((value, index) => entry(value, `$runtime.runtimeServices[${index}]`, false));})();const endpoints = item.endpoints === undefined ? [] : (() => {if (!Array.isArray(item.endpoints)) throw new Error("$runtime.endpoints must be an array");return item.endpoints.map((value, index) => entry(value, `$runtime.endpoints[${index}]`, true));})();- const instances = [...services, ...endpoints].map((value) => value.instance);+ const instances = [...runtimeServices, ...endpoints].map((value) => value.instance);if (new Set(instances).size !== instances.length) throw new Error("$runtime repeats a Runtime instance id");- const selected = selection(item.selection);const scheduled = scheduling(item.scheduling);return {format: "svml.runtime-config@1",@@ -166,9 +140,8 @@ export function parseRuntimeConfig(value: unknown): RuntimeConfigDocument {...(optionalString(item.runtimePackageLock, "$runtime.runtimePackageLock") === undefined? {}: { runtimePackageLock: item.runtimePackageLock as string }),- services,+ runtimeServices,endpoints,- ...(selected === undefined ? {} : { selection: selected }),permissions: stringList(item.permissions, "$runtime.permissions"),...(scheduled === undefined ? {} : { scheduling: scheduled }),};@@ -248,7 +221,7 @@ export async function doctorRuntimeConfig(diagnostics.push(diagnostic(error, "IMPLEMENTATION_PACKAGE_LOCK_INVALID", document.packageLock));}}- for (const item of document.services) {+ for (const item of document.runtimeServices) {const context = { root, instance: item.instance, config: item.config ?? {} };try {diagnostics.push(...await registry.doctor(item.use, "service", context));@@ -293,7 +266,7 @@ export async function createRuntimeFromConfig(const root = resolve(dirname(absolute), document.root ?? ".");const registry = options.registry ?? new RuntimeAdapterRegistry();await installLockedRuntimeAdapters(registry, document.runtimePackageLock, root);- const services = await Promise.all(document.services.map(async (item) => {+ const runtimeServices = await Promise.all(document.runtimeServices.map(async (item) => {return await registry.createService(item.use, {root,instance: item.instance,@@ -314,8 +287,7 @@ export async function createRuntimeFromConfig(...(document.catalogPath === undefined ? {} : { catalogPath: document.catalogPath }),...(document.artifactPath === undefined ? {} : { artifactPath: document.artifactPath }),...(document.packageLock === undefined ? {} : { packageLock: document.packageLock }),- runtimeServices: services,- ...(document.selection === undefined ? {} : { runtimeSelection: document.selection }),+ runtimeServices,components: options.components ?? [],endpoints,allowedPermissions: document.permissions,diff --git a/packages/local/src/project-services.ts b/packages/local/src/project-services.tsindex 01fbd2ea..9b106ec0 100644--- a/packages/local/src/project-services.ts+++ b/packages/local/src/project-services.ts@@ -59,17 +59,23 @@ function configuredServiceIds(.map((service) => service.instance.id));}+/**+ * A Runtime fills each role exactly once. One package may fill several roles —+ * the SQLite package supplies both stores from one file — but two packages+ * filling the same role is a configuration to correct, not an ambiguity to+ * resolve after the fact.+ */function chooseService(packages: readonly RuntimeServicePackage[],role: RuntimeServiceFacetRole,- explicit: string | undefined,fallback: string,): string {const configured = configuredServiceIds(packages, role);- if (explicit !== undefined) return explicit;if (configured.length === 0) return fallback;if (configured.length === 1) return configured[0]!;- throw new Error(`multiple ${role} services are configured; runtimeSelection must choose one`);+ throw new Error(+ `runtimeServices configures ${configured.length} ${role} implementations (${configured.join(", ")}); a Runtime uses one`,+ );}function hasConfiguredService(@@ -109,37 +115,12 @@ function projectSelection(options: ProjectLocalRuntimeOptions,): ProjectRuntimeServiceSelection {return {- scheduler: chooseService(- packages,- "scheduler",- options.runtimeSelection?.scheduler,- "scheduler.local",- ),+ scheduler: chooseService(packages, "scheduler", "scheduler.local"),stores: {- build: chooseService(- packages,- "build-store",- options.runtimeSelection?.stores?.build,- "builds.sqlite",- ),- operations: chooseService(- packages,- "operation-store",- options.runtimeSelection?.stores?.operations,- "operations.sqlite",- ),- artifacts: chooseService(- packages,- "artifact-store",- options.runtimeSelection?.stores?.artifacts,- "artifacts.fs",- ),- credentials: chooseService(- packages,- "credential-store",- options.runtimeSelection?.stores?.credentials,- "credentials.env",- ),+ build: chooseService(packages, "build-store", "builds.sqlite"),+ operations: chooseService(packages, "operation-store", "operations.sqlite"),+ artifacts: chooseService(packages, "artifact-store", "artifacts.fs"),+ credentials: chooseService(packages, "credential-store", "credentials.env"),},};}diff --git a/packages/local/src/types.ts b/packages/local/src/types.tsindex 494259e6..03dbc2bb 100644--- a/packages/local/src/types.ts+++ b/packages/local/src/types.ts@@ -63,18 +63,12 @@ export type ProjectLocalRuntimeOptions = {readonly buildCatalog?: BuildCatalog;/** Exact installed implementation package lock. Source imports cannot change this selection. */readonly packageLock?: string;- /** Additional configured Runtime services. A unique supplied role replaces that role's local default. */+ /**+ * Replaceable parts of the Runtime itself. One package may fill several roles;+ * a supplied role replaces that role's local default, and two packages filling+ * one role is a configuration error rather than a choice made here.+ */readonly runtimeServices?: readonly RuntimeServicePackage[];- /** Required only when more than one supplied instance can fulfill the same Runtime service role. */- readonly runtimeSelection?: {- readonly scheduler?: string;- readonly stores?: {- readonly build?: string;- readonly operations?: string;- readonly artifacts?: string;- readonly credentials?: string;- };- };readonly components?: readonly ComponentPackage[];readonly endpoints?: readonly EndpointPackage[];readonly allowedPermissions?: readonly string[];diff --git a/packages/local/test/config.test.ts b/packages/local/test/config.test.tsindex bd507726..f1d21372 100644--- a/packages/local/test/config.test.ts+++ b/packages/local/test/config.test.ts@@ -1,5 +1,5 @@import assert from "node:assert/strict";-import { mkdtemp, writeFile } from "node:fs/promises";+import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";import { tmpdir } from "node:os";import { join } from "node:path";import test from "node:test";@@ -15,7 +15,6 @@ test("declarative Runtime config starts the domain-neutral local defaults", asynconst path = join(root, "svml.runtime.json");await writeFile(path, JSON.stringify({format: "svml.runtime-config@1",- services: [],endpoints: [],permissions: [],scheduling: { maxConcurrency: 3, lanes: { generation: 2 } },@@ -32,13 +31,11 @@ test("Runtime config is closed data and rejects unknown environment authority",assert.equal(parseRuntimeConfig({format: "svml.runtime-config@1",catalogPath: ".svml/catalog.sqlite",- services: [],endpoints: [],permissions: [],}).catalogPath, ".svml/catalog.sqlite");assert.throws(() => parseRuntimeConfig({format: "svml.runtime-config@1",- services: [],endpoints: [],permissions: [],apiKey: "must-not-live-here",@@ -50,7 +47,6 @@ test("declarative adapters are explicit and never guessed", async () => {const path = join(root, "svml.runtime.json");await writeFile(path, JSON.stringify({format: "svml.runtime-config@1",- services: [],endpoints: [{ use: "example.missing", instance: "missing", config: {} }],permissions: [],}));@@ -59,3 +55,29 @@ test("declarative adapters are explicit and never guessed", async () => {/adapter example\.missing is not registered/u,);});++test("runtimeServices names the Runtime's own replaceable parts, apart from external services", async () => {+ const root = await mkdtemp(join(tmpdir(), "svml-runtime-config-"));+ const path = join(root, "svml.runtime.json");+ await writeFile(path, JSON.stringify({+ format: "svml.runtime-config@1",+ runtimeServices: [{ use: "@example/store", instance: "artifacts.example" }],+ endpoints: [],+ permissions: [],+ }));+ const document = parseRuntimeConfig(JSON.parse(await readFile(path, "utf8")));+ assert.deepEqual(document.runtimeServices, [{ use: "@example/store", instance: "artifacts.example" }]);++ await writeFile(path, JSON.stringify({+ format: "svml.runtime-config@1",+ services: [],+ endpoints: [],+ permissions: [],+ }));+ await assert.rejects(+ async () => parseRuntimeConfig(JSON.parse(await readFile(path, "utf8"))),+ /does not accept services/u,+ "the word services now belongs to the external processes a deployment must have running",+ );+ await rm(root, { recursive: true, force: true });+});diff --git a/packages/local/test/local.test.ts b/packages/local/test/local.test.tsindex 96c07808..615950df 100644--- a/packages/local/test/local.test.ts+++ b/packages/local/test/local.test.ts@@ -342,7 +342,7 @@ test("project local runtime infers one supplied Scheduler service without knowin}});-test("multiple Scheduler services require exact selection and unselected code never gains authority", async () => {+test("two Scheduler services are refused and neither gains authority", async () => {const directory = await mkdtemp(join(tmpdir(), "svml-local-scheduler-selection-"));const creates = { one: 0, two: 0 };const closes = { one: 0, two: 0 };@@ -367,23 +367,23 @@ test("multiple Scheduler services require exact selection and unselected code neclose() { closes[name] += 1; },});try {+ // Two schedulers is a configuration to correct, not a choice to make later.await assert.rejects(createProjectLocalRuntime({root: directory,runtimeServices: [scheduler("one"), scheduler("two")],}),- /runtimeSelection must choose one/u,+ /configures 2 scheduler implementations/u,);assert.deepEqual(closes, { one: 1, two: 1 });const runtime = await createProjectLocalRuntime({root: directory,- runtimeServices: [scheduler("one"), scheduler("two")],- runtimeSelection: { scheduler: "scheduler.two" },+ runtimeServices: [scheduler("two")],});assert.deepEqual(creates, { one: 0, two: 1 });await runtime.close();- assert.deepEqual(closes, { one: 2, two: 2 });+ assert.deepEqual(closes, { one: 1, two: 2 });} finally {await rm(directory, { recursive: true, force: true });}diff --git a/packages/video-cli/test/cli.test.ts b/packages/video-cli/test/cli.test.tsindex d13505fc..d226bda4 100644--- a/packages/video-cli/test/cli.test.ts+++ b/packages/video-cli/test/cli.test.ts@@ -308,7 +308,6 @@ test("CLI accepts a declarative Runtime Profile without an executable config modcatalogPath: join(root, "catalog.sqlite"),artifactPath: join(root, "artifacts"),runtimePackageLock,- services: [],endpoints: [{use: "@narratage/provider-kie",instance: "kie.cli-test",