fix: resume transient original-job collection and guard probe input

This commit is contained in:
Wenxin Duan
2026-09-15 01:29:13 +08:00
parent cc80265bb2
commit 2ad089d68a
7 changed files with 133 additions and 16 deletions
@@ -0,0 +1,14 @@
import { spawnSync } from "node:child_process";
import { resolve } from "node:path";
import { expect, it } from "vitest";
it("rejects a TTY before reading credentials and directs the operator to a controlled pipe", () => {
const script = resolve(import.meta.dirname, "../../../scripts/probe-image-video-mcp.mjs");
// Instrument only the process boundary; do not provide a token or allow a network call.
const source = `Object.defineProperty(process.stdin,'isTTY',{value:true}); const fakeRead=()=>{throw new Error('UNSAFE_STDIN_READ');}; process.stdin.on=fakeRead; await import(${JSON.stringify(script)});`;
const result = spawnSync(process.execPath, ["--input-type=module", "-e", source], { encoding: "utf8", timeout: 5000 });
expect(result.status).toBe(1);
expect(result.stderr).toContain("controlled pipe");
expect(result.stderr).not.toContain("UNSAFE_STDIN_READ");
expect(result.stdout).not.toContain("hidden stdin");
});