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(runtime): stop probe-only Programs without claiming a process
Flandernbc1d80dbde37
diff --git a/packages/cli/src/commands/environment.ts b/packages/cli/src/commands/environment.tsindex d1f3945b..ca63971e 100644--- a/packages/cli/src/commands/environment.ts+++ b/packages/cli/src/commands/environment.ts@@ -195,11 +195,13 @@ export async function runEnvironmentCommand(input: {: await controller.programs.report(args.endpoints === undefined ? {} : { endpoints: args.endpoints });const ready = result.programs.every((item) => item.state.state === "ready");const needsAttention = (item: typeof result.programs[number]) => args.action === "down"- ? item.state.state !== "down" || (item.action !== "stopped" && item.action !== "nothing-to-stop")+ ? item.action !== "nothing-to-stop"+ && (item.state.state !== "down" || item.action !== "stopped"): item.state.state !== "ready";// Readiness describes the service, not whether a stop was performed. An owned process can// still be loading, and another command may have declined a concurrent stop during preparation.const lifecycleOk = args.action === "status" || !result.programs.some(needsAttention);+ const stoppedAny = result.programs.some((item) => item.action === "stopped");const relevant = result.programs.filter((item) => args.presentation.verbose || args.action === "status" || needsAttention(item));const urgent = relevant.filter(needsAttention);const shownPrograms = [...urgent, ...relevant.filter((item) => !needsAttention(item)).slice(0, Math.max(0, args.limit - urgent.length))];@@ -209,7 +211,8 @@ export async function runEnvironmentCommand(input: {: args.action === "up"? lifecycleOk ? "External programs ready" : "External programs need attention": args.action === "down"- ? lifecycleOk ? "External programs stopped" : "External program stop needs attention"+ ? lifecycleOk ? stoppedAny ? "External programs stopped" : "No external programs to stop"+ : "External program stop needs attention": "External program status";write({format: "hypit.cli-programs@1",@@ -298,7 +301,7 @@ export async function runEnvironmentCommand(input: {write({ format: "hypit.cli-runtime-down@1", worker: worker.state },stopped ? "Runtime Worker is down" : "Runtime Worker is still running",stopped ? "success" : "warning", [["Worker", worker.state]],- [`Managed programs were left running. To stop them: ${commandHint(["programs", "down"], { projectRoot, runtimeProfile: resolve(profile) })}`]);+ [`Managed Programs are unchanged. To stop processes started by Hypit: ${commandHint(["programs", "down"], { projectRoot, runtimeProfile: resolve(profile) })}`]);if (!stopped) io.setExitCode?.(1);return;}diff --git a/packages/cli/test/programs-command.test.ts b/packages/cli/test/programs-command.test.tsindex 8e386a4d..321e870b 100644--- a/packages/cli/test/programs-command.test.ts+++ b/packages/cli/test/programs-command.test.ts@@ -170,6 +170,29 @@ test("a declined stop stays visible even when the service is not Ready", async (assert.equal(stopped.ready, false, "a successful stop is not service readiness");});+test("programs down accepts a ready probe-only Program with nothing to stop", async () => {+ const reports: CliManagedProgramReport[] = [{+ id: "toolchain", endpoint: "media.local", action: "nothing-to-stop", state: { state: "ready" },+ }];+ let human = "";+ await runCli(["programs", "down", "/p/profile.json"], {+ write(text) { human += text; },+ }, distribution([], reports));+ assert.match(human, /No external programs to stop/u);++ let output = "";+ let exitCode: number | undefined;+ await runCli(["programs", "down", "/p/profile.json", "--json"], {+ write(text) { output += text; }, setExitCode(code) { exitCode = code; },+ }, distribution([], reports));+ const stopped = JSON.parse(output);+ assert.equal(exitCode, undefined);+ assert.equal(stopped.ok, true);+ assert.equal(stopped.ready, true);+ assert.equal(stopped.programCount, 1);+ assert.equal(stopped.readyCount, 1);+});+test("Runtime headlines preserve a running Worker when Programs are down or stop fails", async () => {const selected = {bootstrapPackages: [],@@ -354,6 +377,8 @@ test("Worker stop suggests Program control in the same project and Profile", asywrite(text) { output += text; },}, distribution([]));assert.ok(output.includes(commandHint(["programs", "down"], { projectRoot, runtimeProfile })));+ assert.match(output, /Managed Programs are unchanged/u);+ assert.doesNotMatch(output, /were left running/u);});diff --git a/packages/runtime-local/src/programs.ts b/packages/runtime-local/src/programs.tsindex 431d91e8..81038c56 100644--- a/packages/runtime-local/src/programs.ts+++ b/packages/runtime-local/src/programs.ts@@ -504,11 +504,14 @@ export async function takeManagedProgramsDown(if (pid === undefined || !processAlive(pid)) {if (pid !== undefined) await rm(join(directory(dataRoot, program), "process.pid"), { force: true });const state = await program.probe();- return state.state === "down"- ? { ...base, action: "nothing-to-stop", state }- // Someone else's process, or one started by hand. Killing it is not this- // command's business; saying so is.- : { ...base, action: "not-ours", state, detail: `${program.id} is running without a Hypit process record` };+ if (state.state === "down" || program.start === undefined) {+ // Probe-only Programs describe installed tools or resources. Readiness means they are+ // usable, not that a process exists for Hypit to stop.+ return { ...base, action: "nothing-to-stop", state };+ }+ // Someone else's process, or one started by hand. Killing it is not this+ // command's business; saying so is.+ return { ...base, action: "not-ours", state, detail: `${program.id} is running without a Hypit process record` };}const term = await stopProcessTree(pid);if (term === "denied") {diff --git a/packages/runtime-local/test/programs.test.ts b/packages/runtime-local/test/programs.test.tsindex a48ce44d..3ffc6e64 100644--- a/packages/runtime-local/test/programs.test.ts+++ b/packages/runtime-local/test/programs.test.ts@@ -219,6 +219,18 @@ test("down leaves a running program without a Hypit process record", async () =>assert.match(result.programs[0]!.detail ?? "", /without a Hypit process record/u);});+test("down treats a ready probe-only Program as having nothing to stop", async () => {+ const { path, options } = await project(() => ({+ id: "toolchain",+ probe: async () => ({ state: "ready" }),+ }));+ const result = await takeManagedProgramsDown(path, options);+ assert.equal(result.programs[0]!.action, "nothing-to-stop");+ assert.deepEqual(result.programs[0]!.state, { state: "ready" });+ assert.equal(result.programs[0]!.detail, undefined);+ assert.equal(result.programs[0]!.pid, undefined);+});+test("a program with nothing to start is installed once, and installation is the whole job", async () => {const directory = await mkdtemp(join(tmpdir(), "hypit-prepare-"));const marker = join(directory, "installed");