@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
24 lines • 1.36 kB
TypeScript
import { AsyncLocalStorage } from "node:async_hooks";
/**
* Process-level hooks that record the servers, sockets and timers an extension's own
* code creates, so a session can close what its extension instances left open
* (senpi#2292).
*
* Two facts decide ownership. The async context (`handleOwnerStore`) says which
* session's extension instance the work runs for: senpi enters it around every call
* into extension code. The creating stack frame says whether the extension's code
* created the handle or senpi code running on its behalf did (a turn the extension
* started, a UI toast it showed): only the first is recorded. Senpi's own timers
* therefore never end with an extension's session.
*/
export type OwnedHandleKind = "server" | "socket" | "timer";
export interface HandleOwner {
/** True when a handle created by code at `path` belongs to this owner. */
ownsCreatorFrame(path: string): boolean;
/** Records a handle; the returned function forgets it once the extension released it itself. */
track(kind: OwnedHandleKind, release: () => void): () => void;
}
export declare const handleOwnerStore: AsyncLocalStorage<HandleOwner>;
/** Installs the hooks once per process; a no-op for every call after the first. */
export declare function installHandleTracking(): void;
//# sourceMappingURL=extension-handle-tracking.d.ts.map