UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

41 lines • 1.88 kB
import { isRecoverableInspectorVmImportError } from "../inspector-policy.js"; import { hasModeCrashHandler } from "./bootstrap-crash-listeners.js"; import { isStaleExtensionContextError } from "./extensions/builtin/goal/stale-context.js"; import { appendDebugLogEntry } from "./hidden-stdout-log.js"; /** * The runner's stale guard throws before a retired generation's operation runs, so the live session * must keep running: log the stack (it names the extension to fix) and stop there (oh-my-openagent#7114). */ export function containStaleExtensionError(error, origin) { if (!isStaleExtensionContextError(error)) return false; try { appendDebugLogEntry(`contained stale extension ctx (${origin})`, error.stack ?? error.message); } catch { } return true; } let installed = false; /** * Print, RPC and host processes have no crash handler of their own. This contains only the stale-ctx * error and keeps every other uncaught throw fatal, exactly like the runtime default. It adds no * `unhandledRejection` listener: that would change the default routing of every rejection, including * the Inspector rejection the early seam recovers through `uncaughtException`. */ export function installStaleExtensionContainment() { if (installed) return; installed = true; process.on("uncaughtException", (error, origin) => { if (containStaleExtensionError(error, origin ?? "uncaughtException")) return; if (hasModeCrashHandler("uncaughtException")) return; // The early Inspector seam (installed just before this one) owns its recoverable rejection. if (isRecoverableInspectorVmImportError(error, origin ?? "uncaughtException")) return; console.error(error); process.exit(1); }); } //# sourceMappingURL=stale-extension-containment.js.map