mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 19:36:04 +00:00
Audio effects launched Chrome with its own two flags and no retry, so inside an agent's macOS seatbelt Chrome died at startup with "Target closed" while the CLI's own browser launch recovered. The sandbox launch policy now lives in the engine; the engine's Chrome launch retries once in one process over a pipe when the sandbox refuses it, and audio effects use the shared Chrome flags in software GPU mode. The CLI imports the same policy from the engine.
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import type { LaunchOptions } from "puppeteer-core";
|
|
|
|
const MACH_SERVICE_DENIED = /bootstrap_check_in\b[^\n]*Permission denied/;
|
|
const SINGLE_PROCESS = "--single-process";
|
|
const CPU_COMPOSITING = "--disable-gpu-compositing";
|
|
|
|
export function machServiceDenied(errorMessage: string): boolean {
|
|
return MACH_SERVICE_DENIED.test(errorMessage);
|
|
}
|
|
|
|
export function pipeLaunchClosedOnMac(error: unknown, platform = process.platform): boolean {
|
|
return platform === "darwin" && error instanceof Error && error.name === "TargetCloseError";
|
|
}
|
|
|
|
/** Codex runs agent commands in a macOS seatbelt, which names itself in the environment. */
|
|
export function inAgentSandbox(env = process.env, platform = process.platform): boolean {
|
|
return platform === "darwin" && env.CODEX_SANDBOX === "seatbelt";
|
|
}
|
|
|
|
/** The one launch a seatbelt allows: no child process registers a mach port, nothing listens, no GPU composites. */
|
|
export function oneProcessOverPipe(options: LaunchOptions): LaunchOptions {
|
|
const args = options.args ?? [];
|
|
const missing = [SINGLE_PROCESS, CPU_COMPOSITING].filter((flag) => !args.includes(flag));
|
|
return { ...options, pipe: true, args: [...args, ...missing] };
|
|
}
|
|
|
|
export function isOneProcessOverPipe(options: LaunchOptions): boolean {
|
|
return options.pipe === true && (options.args ?? []).includes(SINGLE_PROCESS);
|
|
}
|
|
|
|
/** A process sandbox (an agent's macOS seatbelt) refused Chrome its mach service, so no browser starts here. */
|
|
export function sandboxDeniedRemediation(errorMessage: string): string | undefined {
|
|
if (!machServiceDenied(errorMessage)) return undefined;
|
|
return [
|
|
"The browser can't start inside this sandbox: macOS refused Chrome's mach service (bootstrap_check_in: Permission denied).",
|
|
"Rerun this command with escalation, outside the sandbox.",
|
|
].join("\n");
|
|
}
|