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: give Windows media children the process-creation variables they need
fetw14904838cc29
diff --git a/packages/media-execution/src/execute.ts b/packages/media-execution/src/execute.tsindex f5e5ccd8..668699ae 100644--- a/packages/media-execution/src/execute.ts+++ b/packages/media-execution/src/execute.ts@@ -33,6 +33,7 @@ import {} from "@hypit/protocol";import type { BlobRef, CanonicalValue, StoredValue } from "@hypit/protocol";+import { mediaProcessEnv } from "./process-env.js";import { parseMediaInspection } from "./probe.js";import {compositeAnimatedWebpFrame,@@ -98,10 +99,7 @@ async function runProcess(args: {shell: false,windowsHide: true,stdio: ["ignore", "pipe", "pipe"],- env: {- PATH: process.env.PATH ?? "",- ...(args.sharedLibraryPath === undefined ? {} : { LD_LIBRARY_PATH: args.sharedLibraryPath }),- },+ env: mediaProcessEnv(args.sharedLibraryPath === undefined ? undefined : { LD_LIBRARY_PATH: args.sharedLibraryPath }),});const stdout: Buffer[] = [];let stdoutBytes = 0;diff --git a/packages/media-execution/src/process-env.ts b/packages/media-execution/src/process-env.tsnew file mode 100644index 00000000..bf8d3793--- /dev/null+++ b/packages/media-execution/src/process-env.ts@@ -0,0 +1,20 @@+const windowsProcessCreation = ["PATHEXT", "SYSTEMROOT", "WINDIR", "ComSpec"] as const;++/**+ * ffmpeg and ffprobe are started as PATH executables. The Host environment is+ * not forwarded, so credential values stay out of those processes. Windows still+ * needs the process-creation variables CreateProcess uses to resolve `.exe`.+ */+export function mediaProcessEnv(+ extra?: Readonly<Record<string, string>>,+): NodeJS.ProcessEnv {+ const env: NodeJS.ProcessEnv = { PATH: process.env.PATH ?? "" };+ if (process.platform === "win32") {+ for (const name of windowsProcessCreation) {+ const value = process.env[name];+ if (value !== undefined && value.length > 0) env[name] = value;+ }+ }+ if (extra !== undefined) Object.assign(env, extra);+ return env;+}diff --git a/packages/media-execution/src/surface.ts b/packages/media-execution/src/surface.tsindex eea23b9d..4c8cb2e7 100644--- a/packages/media-execution/src/surface.ts+++ b/packages/media-execution/src/surface.ts@@ -4,6 +4,7 @@ import { tmpdir } from "node:os";import { join } from "node:path";import { assertCompositableSurfaceRef } from "@hypit/media";+import { mediaProcessEnv } from "./process-env.js";import type { CompositableSurfaceRef } from "@hypit/media";type JsonObject = Record<string, unknown>;@@ -57,7 +58,7 @@ async function runProcess(args: {shell: false,windowsHide: true,stdio: ["ignore", "pipe", "pipe"],- env: { PATH: process.env.PATH ?? "" },+ env: mediaProcessEnv(),});const stdout: Buffer[] = [];let bytes = 0;diff --git a/packages/media-execution/test/process-env.test.ts b/packages/media-execution/test/process-env.test.tsnew file mode 100644index 00000000..f0afe3e2--- /dev/null+++ b/packages/media-execution/test/process-env.test.ts@@ -0,0 +1,32 @@+import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import test from "node:test";++import { mediaProcessEnv } from "../src/process-env.js";++test("media processes inherit PATH without the rest of the Host environment", () => {+ const previous = process.env.HYPIT_MEDIA_ENV_PROBE;+ process.env.HYPIT_MEDIA_ENV_PROBE = "secret";+ try {+ const env = mediaProcessEnv();+ assert.equal(env.PATH, process.env.PATH ?? "");+ assert.equal(env.HYPIT_MEDIA_ENV_PROBE, undefined);+ if (process.platform === "win32") {+ if (process.env.SYSTEMROOT !== undefined) assert.equal(env.SYSTEMROOT, process.env.SYSTEMROOT);+ if (process.env.PATHEXT !== undefined) assert.equal(env.PATHEXT, process.env.PATHEXT);+ }+ const report = spawnSync(process.execPath, ["-e", "process.stdout.write(JSON.stringify({ secret: process.env.HYPIT_MEDIA_ENV_PROBE, path: Boolean(process.env.PATH), systemRoot: Boolean(process.env.SYSTEMROOT) }))"], {+ env,+ encoding: "utf8",+ windowsHide: true,+ });+ assert.equal(report.status, 0, report.stderr);+ const body = JSON.parse(report.stdout) as { secret?: string; path: boolean; systemRoot: boolean };+ assert.equal(body.secret, undefined);+ assert.equal(body.path, true);+ if (process.platform === "win32") assert.equal(body.systemRoot, true);+ } finally {+ if (previous === undefined) delete process.env.HYPIT_MEDIA_ENV_PROBE;+ else process.env.HYPIT_MEDIA_ENV_PROBE = previous;+ }+});