@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
38 lines • 2.16 kB
TypeScript
import { type MessagePort } from "node:worker_threads";
import { type NativeWebViewClass } from "./native-webview.ts";
import { type AttachDeadline, type ReadinessEvent, type WebViewReadinessPolicy } from "./webview-readiness.ts";
export interface WebViewServiceOptions {
readonly readiness?: Partial<WebViewReadinessPolicy>;
readonly onReadiness?: (event: ReadinessEvent) => void;
/** The readiness bound of each launch; defaults to `attachBoundMs`. Tests signal it instead of waiting. */
readonly attachDeadline?: (launch: number) => AttachDeadline;
/** Ends the Chrome no view uses; defaults to `retireBunChrome`. Tests substitute it to fail a retirement. */
readonly retireChrome?: (webViewClass: NativeWebViewClass) => Promise<void>;
/** Told when a retirement failed; without it (or when it throws) the failure becomes a process warning. */
readonly onRetireFailure?: (message: string) => void;
}
export interface WebViewClientGrant {
readonly clientId: string;
readonly port: MessagePort;
}
/**
* Serves Chrome-backed `Bun.WebView`s on the process main thread (Bun allows that backend nowhere
* else) for eval kernels running in worker threads. Every kernel gets its own client: a private
* MessagePort plus the views created through it, released as a unit by the owner that asked.
*/
export declare class WebViewService {
#private;
constructor(webViewClass: NativeWebViewClass, options?: WebViewServiceOptions);
get viewCount(): number;
connect(owner: object): WebViewClientGrant;
/**
* Only the owner that connected a client can release it. Resolves after the client's in-flight
* launches settled and any Chrome retirement in flight ended, including one a closed port (the
* client's worker died first) already started.
*/
release(clientId: string, owner: object): Promise<void>;
releaseOwner(owner: object): Promise<void>;
}
/** The process-wide service, created on first use; undefined off the main thread or without `Bun.WebView`. */
export declare function mainThreadWebViewService(): WebViewService | undefined;
//# sourceMappingURL=webview-service.d.ts.map