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: remove the domain-neutral tier's unreachable code and stale words
kashorin1fc9f7cd1f70
diff --git a/docs/guide/packages.md b/docs/guide/packages.mdindex 03081447..d63df416 100644--- a/docs/guide/packages.md+++ b/docs/guide/packages.md@@ -39,7 +39,6 @@ Script, Seedance, Film or any video concept.@narratage/artifact-store-s3 S3 Artifact store@narratage/credential-store-env environment credentials@narratage/transport invocation seams-@narratage/transport-process local process transport@narratage/transport-aws-lambda Lambda transport@narratage/local SQLite/filesystem developer assembly```diff --git a/docs/zh/guide/packages.md b/docs/zh/guide/packages.mdindex b1e50048..c0c86223 100644--- a/docs/zh/guide/packages.md+++ b/docs/zh/guide/packages.md@@ -36,7 +36,6 @@ description: 四个分层、依赖边界、包的结构与 facet。@narratage/artifact-store-s3 S3 Artifact store@narratage/credential-store-env environment credentials@narratage/transport invocation seams-@narratage/transport-process local process transport@narratage/transport-aws-lambda Lambda transport@narratage/local SQLite/filesystem developer assembly```diff --git a/packages/core/src/graph.ts b/packages/core/src/graph.tsindex c1dd05a2..04e2e1e0 100644--- a/packages/core/src/graph.ts+++ b/packages/core/src/graph.ts@@ -171,8 +171,6 @@ export function satisfactionForOutput(}/** @deprecated Use satisfactionForOutput. */-export const bindingForOutput = satisfactionForOutput;-export function selectedSatisfaction(graph: CompiledGraph,request: BuildRequest,@@ -185,8 +183,6 @@ export function selectedSatisfaction(}/** @deprecated Use selectedSatisfaction. */-export const selectedCandidate = selectedSatisfaction;-export function operationResultRecord(operation: OperationNode): string {return operation.result.record;}@@ -476,6 +472,3 @@ export function verifyBuildRequest(}}-export function sameProducerRef(left: ProducerRef, right: ProducerRef): boolean {- return producerKey(left) === producerKey(right);-}diff --git a/packages/core/src/index.ts b/packages/core/src/index.tsindex 7a59cc55..d43a0faf 100644--- a/packages/core/src/index.ts+++ b/packages/core/src/index.ts@@ -5,7 +5,6 @@ export {computeModuleDigest,createResolvedClosure,link,- resolveCapability,resolveProducer,resolveType,sealRecord,@@ -18,7 +17,6 @@ export {} from "./link.js";export {EMPTY_REALIZATION_DIGEST,- bindingForOutput,operationResultRecord,operationResultType,resolveCandidate,@@ -26,14 +24,13 @@ export {resolveOperation,sealBuildRequest,sealCompiledGraph,- selectedCandidate,selectedSatisfaction,satisfactionForOutput,valueRefKey,verifyBuildRequest,verifyCompiledGraph,} from "./graph.js";-export { compileBuild, deriveBuildPlan, validatePlan } from "./plan.js";+export { compileBuild, validatePlan } from "./plan.js";export { reduce, start } from "./reducer.js";export { verifyBuildState } from "./verify.js";export { validateStoredValue } from "./schema.js";diff --git a/packages/core/src/link.ts b/packages/core/src/link.tsindex cf2eaead..b997adf9 100644--- a/packages/core/src/link.ts+++ b/packages/core/src/link.ts@@ -295,27 +295,6 @@ export function resolveProducer(return { ...declaration, ref };}-export function resolveCapability(- closure: ResolvedModuleClosure,- ref: CapabilityRef,-): ResolvedCapabilityDeclaration {- const module = closure.modules.find((item) => sameModule(item.ref, ref.module));- invariant(- module !== undefined,- "UNKNOWN_MODULE",- `unknown module ${moduleKey(ref.module)}`,- capabilityKey(ref),- );- const declaration = module.manifest.capabilities.find((item) => item.name === ref.name);- invariant(- declaration !== undefined,- "UNKNOWN_CAPABILITY",- `unknown capability ${capabilityKey(ref)}`,- capabilityKey(ref),- );- return { ...declaration, ref };-}-export function sealRecord(record: TypedRecordDraft): TypedRecord {return { ...record, digest: recordDigest(record.type, record.value) };}diff --git a/packages/core/src/plan.ts b/packages/core/src/plan.tsindex 36b3754a..0b4958f8 100644--- a/packages/core/src/plan.ts+++ b/packages/core/src/plan.ts@@ -418,4 +418,3 @@ export function producerStep(plan: BuildPlan, id: string): ProducerStep {}/** @deprecated Use compileBuild. */-export const deriveBuildPlan = compileBuild;diff --git a/packages/local/src/index.ts b/packages/local/src/index.tsindex b0faddd1..1389574f 100644--- a/packages/local/src/index.ts+++ b/packages/local/src/index.ts@@ -20,7 +20,6 @@ export {} from "./external-services.js";export {RuntimeAdapterRegistry,- RuntimeAdapterRegistry as RuntimeConfigRegistry,} from "@narratage/runtime-adapter";export type * from "./types.js";export type * from "./config.js";diff --git a/packages/local/test/config.test.ts b/packages/local/test/config.test.tsindex a86e1e7f..4e85e3b6 100644--- a/packages/local/test/config.test.ts+++ b/packages/local/test/config.test.ts@@ -10,7 +10,7 @@ import {createRuntimeFromConfig,doctorRuntimeConfig,parseRuntimeConfig,- RuntimeConfigRegistry,+ RuntimeAdapterRegistry,} from "@narratage/local";test("declarative Runtime config starts the domain-neutral local defaults", async () => {@@ -22,7 +22,7 @@ test("declarative Runtime config starts the domain-neutral local defaults", asynpermissions: [],scheduling: { maxConcurrency: 3, lanes: { generation: 2 } },}));- const runtime = await createRuntimeFromConfig(path, { registry: new RuntimeConfigRegistry() });+ const runtime = await createRuntimeFromConfig(path, { registry: new RuntimeAdapterRegistry() });try {assert.equal((await runtime.status("absent")).build, undefined);} finally {@@ -54,7 +54,7 @@ test("declarative adapters are explicit and never guessed", async () => {permissions: [],}));await assert.rejects(- async () => await createRuntimeFromConfig(path, { registry: new RuntimeConfigRegistry() }),+ async () => await createRuntimeFromConfig(path, { registry: new RuntimeAdapterRegistry() }),/adapter example\.missing is not registered/u,);});@@ -98,7 +98,7 @@ test("doctor names the external program a Provider needs, and the command that spermissions: [],}));- const registry = new RuntimeConfigRegistry();+ const registry = new RuntimeAdapterRegistry();const declare = (use: string, service: unknown) =>registry.registerFacet(createRuntimeEndpointAdapterFacet({use,diff --git a/packages/local/test/external-services.test.ts b/packages/local/test/external-services.test.tsindex ef2d51a4..7c0602ae 100644--- a/packages/local/test/external-services.test.ts+++ b/packages/local/test/external-services.test.ts@@ -11,7 +11,7 @@ import type { RuntimeExternalService } from "@narratage/runtime-adapter";import {bringExternalServicesUp,reportExternalServices,- RuntimeConfigRegistry,+ RuntimeAdapterRegistry,takeExternalServicesDown,} from "@narratage/local";@@ -32,7 +32,7 @@ async function project(service: (root: string) => RuntimeExternalService) {],permissions: [],}));- const registry = new RuntimeConfigRegistry();+ const registry = new RuntimeAdapterRegistry();registry.registerFacet(createRuntimeEndpointAdapterFacet({use: "example.program",create: () => ({}) as never,diff --git a/packages/transport-process/README.md b/packages/transport-process/README.mddeleted file mode 100644index 7f48e5fd..00000000--- a/packages/transport-process/README.md+++ /dev/null@@ -1,14 +0,0 @@-# `@narratage/transport-process`--Least-authority JSON child-process transport for trusted local Endpoint packages. It is not an-Endpoint and declares no capability.--- executable path must be absolute;-- `shell` is always disabled;-- the parent environment is not inherited;-- timeout and output size are mandatory/bounded;-- one canonical JSON document goes to stdin and one comes from stdout.--A WhisperX-local or HyperFrames-local Endpoint may wrap this transport and own the actual request-schema, artifact protocol and Endpoint lifecycle. Author source can never select an executable or-pass shell arguments through this API.diff --git a/packages/transport-process/package.json b/packages/transport-process/package.jsondeleted file mode 100644index f8092f77..00000000--- a/packages/transport-process/package.json+++ /dev/null@@ -1,13 +0,0 @@-{- "name": "@narratage/transport-process",- "version": "0.0.0-dev",- "private": true,- "type": "module",- "exports": {- ".": "./src/index.ts"- },- "dependencies": {- "@narratage/protocol": "workspace:*",- "@narratage/transport": "workspace:*"- }-}diff --git a/packages/transport-process/src/index.ts b/packages/transport-process/src/index.tsdeleted file mode 100644index 5ebb640d..00000000--- a/packages/transport-process/src/index.ts+++ /dev/null@@ -1,150 +0,0 @@-import { spawn } from "node:child_process";-import { isAbsolute, resolve } from "node:path";--import { canonicalize } from "@narratage/protocol";-import type { CanonicalValue } from "@narratage/protocol";-import type { JsonInvoker } from "@narratage/transport";--export type ProcessJsonInvokerOptions = {- /** Must be absolute; shell lookup and shell interpolation are never used. */- readonly executable: string;- readonly args?: readonly string[];- readonly cwd?: string;- /** The child receives exactly these variables. Parent environment inheritance is never implicit. */- readonly environment?: Readonly<Record<string, string>>;- readonly timeoutMs: number;- readonly maxInputBytes?: number;- readonly maxOutputBytes?: number;-};--function assert(condition: unknown, message: string): asserts condition {- if (!condition) throw new Error(message);-}--function positiveInteger(value: number, subject: string): number {- assert(Number.isSafeInteger(value) && value > 0, `${subject} must be a positive safe integer`);- return value;-}--function append(- chunks: Uint8Array[],- chunk: Uint8Array,- current: number,- limit: number,-): number {- const next = current + chunk.byteLength;- if (next > limit) throw new Error(`child process output exceeded ${limit} bytes`);- chunks.push(Uint8Array.from(chunk));- return next;-}--function concatenate(chunks: readonly Uint8Array[], size: number): Uint8Array {- const output = new Uint8Array(size);- let offset = 0;- for (const chunk of chunks) {- output.set(chunk, offset);- offset += chunk.byteLength;- }- return output;-}--/** One JSON document on stdin, one JSON document on stdout, no shell and no ambient environment. */-export class ProcessJsonInvoker implements JsonInvoker {- readonly #options: Required<Pick<- ProcessJsonInvokerOptions,- "executable" | "timeoutMs" | "maxInputBytes" | "maxOutputBytes"- >> & Omit<ProcessJsonInvokerOptions, "executable" | "timeoutMs" | "maxInputBytes" | "maxOutputBytes">;-- constructor(options: ProcessJsonInvokerOptions) {- assert(isAbsolute(options.executable), "process executable must be an absolute path");- assert(options.args?.every((arg) => typeof arg === "string") ?? true, "process args are invalid");- assert(Object.entries(options.environment ?? {}).every(([key, value]) =>- key.length > 0 && !key.includes("=") && typeof value === "string"),- "process environment contains an invalid name");- this.#options = {- executable: options.executable,- timeoutMs: positiveInteger(options.timeoutMs, "process timeoutMs"),- maxInputBytes: positiveInteger(options.maxInputBytes ?? 16 * 1024 * 1024, "process maxInputBytes"),- maxOutputBytes: positiveInteger(options.maxOutputBytes ?? 16 * 1024 * 1024, "process maxOutputBytes"),- ...(options.args === undefined ? {} : { args: [...options.args] }),- ...(options.cwd === undefined ? {} : { cwd: resolve(options.cwd) }),- ...(options.environment === undefined ? {} : { environment: { ...options.environment } }),- };- }-- async invoke(- request: CanonicalValue,- options: { readonly signal?: AbortSignal } = {},- ): Promise<CanonicalValue> {- if (options.signal?.aborted === true) throw options.signal.reason ?? new Error("process invocation was aborted");- const input = new TextEncoder().encode(JSON.stringify(canonicalize(request)));- assert(input.byteLength <= this.#options.maxInputBytes,- `process JSON input is ${input.byteLength} bytes, over limit ${this.#options.maxInputBytes}`);- return await new Promise<CanonicalValue>((resolveResult, reject) => {- const child = spawn(this.#options.executable, [...(this.#options.args ?? [])], {- shell: false,- stdio: ["pipe", "pipe", "pipe"],- env: { ...(this.#options.environment ?? {}) },- ...(this.#options.cwd === undefined ? {} : { cwd: this.#options.cwd }),- });- const stdout: Uint8Array[] = [];- const stderr: Uint8Array[] = [];- let stdoutSize = 0;- let stderrSize = 0;- let failure: Error | undefined;- let settled = false;- const fail = (error: Error): void => {- failure ??= error;- child.kill("SIGKILL");- };- const abort = (): void => fail(- options.signal?.reason instanceof Error- ? options.signal.reason- : new Error("process invocation was aborted"),- );- const timer = setTimeout(() => fail(new Error(- `process invocation exceeded ${this.#options.timeoutMs}ms`,- )), this.#options.timeoutMs);- options.signal?.addEventListener("abort", abort, { once: true });- child.stdout.on("data", (chunk: Buffer) => {- try {- stdoutSize = append(stdout, chunk, stdoutSize, this.#options.maxOutputBytes);- } catch (error) {- fail(error instanceof Error ? error : new Error(String(error)));- }- });- child.stderr.on("data", (chunk: Buffer) => {- try {- stderrSize = append(stderr, chunk, stderrSize, this.#options.maxOutputBytes);- } catch (error) {- fail(error instanceof Error ? error : new Error(String(error)));- }- });- child.on("error", (error) => fail(error));- child.on("close", (code, signal) => {- if (settled) return;- settled = true;- clearTimeout(timer);- options.signal?.removeEventListener("abort", abort);- if (failure !== undefined) {- reject(failure);- return;- }- if (code !== 0) {- // stderr is drained and bounded, but never copied into framework errors where secrets may persist.- reject(new Error(`process exited with ${code ?? `signal ${signal ?? "unknown"}`}`));- return;- }- try {- const text = new TextDecoder("utf-8", { fatal: true }).decode(concatenate(stdout, stdoutSize));- assert(text.length > 0, "process returned an empty JSON response");- resolveResult(canonicalize(JSON.parse(text)));- } catch (error) {- reject(error);- }- });- child.stdin.on("error", (error) => fail(error));- child.stdin.end(input);- });- }-}diff --git a/packages/transport-process/test/invoker.test.ts b/packages/transport-process/test/invoker.test.tsdeleted file mode 100644index 409b5288..00000000--- a/packages/transport-process/test/invoker.test.ts+++ /dev/null@@ -1,49 +0,0 @@-import assert from "node:assert/strict";-import test from "node:test";--import { ProcessJsonInvoker } from "@narratage/transport-process";--test("process transport uses an absolute executable, no shell and no inherited environment", async () => {- const script = [- "let input = '';",- "process.stdin.setEncoding('utf8');",- "process.stdin.on('data', chunk => input += chunk);",- "process.stdin.on('end', () => {",- " const value = JSON.parse(input);",- " process.stdout.write(JSON.stringify({ value, inherited: process.env.SVML_SHOULD_NOT_LEAK ?? null }));",- "});",- ].join("\n");- const transport = new ProcessJsonInvoker({- executable: process.execPath,- args: ["-e", script],- timeoutMs: 5_000,- });- const previous = process.env.SVML_SHOULD_NOT_LEAK;- process.env.SVML_SHOULD_NOT_LEAK = "secret";- try {- assert.deepEqual(await transport.invoke({ hello: "world" }), {- inherited: null,- value: { hello: "world" },- });- } finally {- if (previous === undefined) delete process.env.SVML_SHOULD_NOT_LEAK;- else process.env.SVML_SHOULD_NOT_LEAK = previous;- }-});--test("process transport enforces timeout and output bounds", async () => {- const timeout = new ProcessJsonInvoker({- executable: process.execPath,- args: ["-e", "setInterval(() => {}, 1000)"],- timeoutMs: 20,- });- await assert.rejects(timeout.invoke({}), /exceeded 20ms/u);-- const output = new ProcessJsonInvoker({- executable: process.execPath,- args: ["-e", "process.stdin.resume(); process.stdin.on('end', () => process.stdout.write('x'.repeat(1024)))"],- timeoutMs: 5_000,- maxOutputBytes: 32,- });- await assert.rejects(output.invoke({}), /output exceeded 32 bytes/u);-});diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex e3614868..8001d70c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1687,15 +1687,6 @@ importers:specifier: workspace:*version: link:../transport- packages/transport-process:- dependencies:- '@narratage/protocol':- specifier: workspace:*- version: link:../protocol- '@narratage/transport':- specifier: workspace:*- version: link:../transport-packages/validation:dependencies:'@narratage/core':diff --git a/tools/package-boundaries.test.mjs b/tools/package-boundaries.test.mjsindex ba79f9e3..900d2a72 100644--- a/tools/package-boundaries.test.mjs+++ b/tools/package-boundaries.test.mjs@@ -70,7 +70,6 @@ const domainNeutralPackages = new Set(["@narratage/artifact-store-s3","@narratage/credential-store-env","@narratage/transport",- "@narratage/transport-process","@narratage/transport-aws-lambda","@narratage/local",]);@@ -225,3 +224,47 @@ test("every workspace package is exercised by some test, directly or through a tconst uncovered = [...packages.keys()].filter((name) => !testedImports.has(name)).sort();assert.deepEqual(uncovered, [], "packages reachable from no test at all");});++test("every package is reachable: imported, activatable, or a declared entry point", async () => {+ const { readdir, readFile } = await import("node:fs/promises");+ const packages = await workspacePackages();+ // A CLI is nobody's dependency by construction; it is what a person runs.+ const entryPoints = new Set(["@narratage/video-cli", "@narratage/test-support"]);++ // Anything imported by non-test source anywhere in the workspace, including+ // the deployment services, which are real consumers even though they are not+ // workspace packages.+ const imported = new Set();+ const scan = async (directory, owner) => {+ let entries;+ try {+ entries = await readdir(directory, { withFileTypes: true });+ } catch {+ return;+ }+ for (const entry of entries) {+ const path = `${directory}/${entry.name}`;+ if (entry.isDirectory() && entry.name !== "node_modules") await scan(path, owner);+ else if (entry.name.endsWith(".ts")) {+ for (const match of (await readFile(path, "utf8")).matchAll(/"(@narratage\/[a-z0-9-]+)"/gu)) {+ if (match[1] !== owner) imported.add(match[1]);+ }+ }+ }+ };+ for (const name of packages.keys()) await scan(`packages/${name.replace("@narratage/", "")}/src`, name);+ await scan("services", undefined);++ // A package with an activation entry is loaded by the Package Loader from a+ // lock, never by an import, so having no importer is what it is supposed to+ // look like.+ const activatable = new Set([...packages]+ .filter(([, manifest]) => manifest.svml?.activation !== undefined)+ .map(([name]) => name));++ const unreachable = [...packages.keys()]+ .filter((name) => !imported.has(name) && !activatable.has(name) && !entryPoints.has(name))+ .sort();+ assert.deepEqual(unreachable, [],+ "packages nothing imports, nothing can activate, and no one runs — delete them or give them a consumer");+});diff --git a/tsconfig.json b/tsconfig.jsonindex 59db554e..1244739d 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -170,9 +170,6 @@"@narratage/transport-aws-lambda": ["packages/transport-aws-lambda/src/index.ts"],- "@narratage/transport-process": [- "packages/transport-process/src/index.ts"- ],"@narratage/transport": ["packages/transport/src/index.ts"],