@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
39 lines • 2.45 kB
TypeScript
import { type NativeWebViewClass } from "./native-webview.ts";
import { type AttachDeadline } from "./webview-readiness.ts";
/** A Bun Chrome process; a browser names the temp profile Bun made for it in `profileDir`. */
export interface BunChromeBrowser {
readonly pid: number;
readonly profileDir?: string;
}
/** Bun's running Chrome: its browsers, and on Windows every process of their tree. */
export declare function listBunChromeBrowsers(): Promise<BunChromeBrowser[]>;
/**
* Resolves once no killed-but-unreaped Chrome child is left (bounded). A Chrome that died (crash,
* kill) stays a zombie until Bun reaps it, and Chrome's profile lock still names that pid, so a
* Chrome Bun launches in that window exits at once ("Chrome process closed the pipe").
*/
export declare function settleDeadBunChrome(): Promise<void>;
/** The process and timing boundary of a retirement; tests substitute it. */
export interface ChromeRetireSeams {
readonly platform: NodeJS.Platform;
readonly listBrowsers: () => Promise<readonly BunChromeBrowser[]>;
readonly alive: (pid: number) => boolean;
readonly signal: (pid: number, signal: NodeJS.Signals) => void;
readonly deadline: (ms: number) => AttachDeadline;
/** Sends CDP `Browser.close`; resolves false once that failed (see `requestBrowserClose`). */
readonly requestClose: (webViewClass: NativeWebViewClass) => Promise<boolean>;
/** Ends Bun's Chrome tree on Windows; resolves true once no process of it is left. */
readonly killWindowsTree: (webViewClass: NativeWebViewClass) => Promise<boolean>;
readonly removeProfile: (dir: string) => Promise<void>;
}
/**
* Ends the Chrome Bun spawned once no proxied view needs it; the next Chrome-backed view respawns it.
* Chrome is first asked to quit over CDP `Browser.close` (senpi#4174: only a graceful quit lets macOS
* Chrome delete its `code_sign_clone`), and only a Chrome still running after the bound is killed:
* on Windows by the tree kill, elsewhere by SIGTERM then SIGKILL. `WebView.closeAll()` is not used on
* macOS, where it also kills the shared WebKit host that native worker views run on. Resolves once
* those processes are gone (bounded) and their temp profiles removed, so a released kernel leaves no
* Chrome behind.
*/
export declare function retireBunChrome(webViewClass: NativeWebViewClass, seams?: ChromeRetireSeams): Promise<void>;
//# sourceMappingURL=bun-chrome.d.ts.map