@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
52 lines • 2.9 kB
TypeScript
import type { Duplex } from "node:stream";
/** Set only on the supervisor-to-engine hop: the engine claims its channels and never forwards them. */
export declare const PRIVATE_FDS_FINAL_ENV = "SENPI_PRIVATE_FDS_FINAL";
/** A name maps to a descriptor, or to null when the launcher declared it without a usable one. */
export type PrivateFdEntry = number | readonly [number, number] | null;
interface PrivateFdInspection {
readonly platform: NodeJS.Platform;
readonly bun: string | undefined;
readonly proven: {
readonly bun: string;
} | false;
readonly ipc: number | null | undefined;
readonly isSocket: (fd: number) => boolean;
readonly isPipe: (fd: number) => boolean;
readonly clearInherit: (fd: number) => boolean;
}
/** What the next engine hop receives: per-name entries, or the unparseable marker. */
export type PrivateFdForward = {
readonly kind: "entries";
readonly entries: ReadonlyMap<string, PrivateFdEntry>;
} | {
readonly kind: "unparseable";
};
/**
* Measured on Node 24/26 and Bun 1.4 (macOS and Linux): each runtime marks inherited descriptors up to
* at least 21 close-on-exec at startup, while Node on Linux leaks 24 and above into every child it
* spawns. POSIX adopts only 5..15; Windows pairs instead clear inheritance explicitly at receipt.
*/
export declare const ADOPTABLE_MAX = 15;
/**
* A valid name is always declared. Only an unshared POSIX socket or a version-proven Windows pipe pair
* becomes a channel. A table that does not parse declares the names it still quotes, without a channel.
*/
export declare function parseTable(encoded: string, inspection?: Partial<PrivateFdInspection>): {
readonly entries: Map<string, PrivateFdEntry>;
readonly parsed: boolean;
readonly discard: ReadonlySet<number>;
};
/** A discarded Windows name may not be open at all (its clear failed for that reason): nothing to close then. */
export declare function closeDiscarded(fd: number, close?: (fd: number) => void): void;
/** True when the launcher declared this channel for the launch, with or without a usable descriptor. */
export declare function privateChannelDeclared(name: string): boolean;
/** True when this launch carried a table at all, even one that does not parse. */
export declare function privateTablePresent(): boolean;
/** True when a table was present but no channel name could be read from it: declared, unavailable. */
export declare function privateFdTableUnparseable(): boolean;
/** Claim once. The caller owns disposal of the socket or both halves of the pipe pair. */
export declare function takeInheritedPrivateChannel(name: string): Duplex | undefined;
/** Only the intentional next engine hop may take the table and descriptor ownership from this process. */
export declare function takePrivateDescriptors(): PrivateFdForward;
export {};
//# sourceMappingURL=private-fds.d.ts.map