@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
71 lines • 3.39 kB
TypeScript
export declare const KEEP_POWER_THROTTLING_ENV = "SENPI_KEEP_POWER_THROTTLING";
/** `PROCESS_INFORMATION_CLASS.ProcessPowerThrottling`. */
export declare const PROCESS_POWER_THROTTLING_CLASS = 4;
export declare const PROCESS_POWER_THROTTLING_CURRENT_VERSION = 1;
export declare const PROCESS_POWER_THROTTLING_EXECUTION_SPEED = 1;
/** `PROCESS_POWER_THROTTLING_STATE`: three ULONGs (Version, ControlMask, StateMask). */
export declare const POWER_THROTTLING_STATE_BYTES = 12;
export declare const PROCESS_SET_INFORMATION = 512;
export declare const PROCESS_QUERY_INFORMATION = 1024;
export interface Kernel32PowerThrottling {
OpenProcess(access: number, inherit: number, pid: number): unknown;
SetProcessInformation(process: unknown, infoClass: number, info: Uint8Array, length: number): number;
GetProcessInformation(process: unknown, infoClass: number, info: Uint8Array, length: number): number;
CloseHandle(handle: unknown): number;
GetLastError(): number;
}
export interface PowerThrottlingState {
controlMask: number;
stateMask: number;
}
export type PowerThrottlingResult = {
ok: true;
} | {
ok: false;
step: string;
win32Error: number;
};
export declare function executionSpeedOptOutState(): Uint8Array;
export declare function disableExecutionSpeedThrottling(kernel: Kernel32PowerThrottling, pid: number): PowerThrottlingResult;
/** Reads the explicit power-throttling policy of `pid`; a process left on automatic reads `ControlMask = 0`. */
export declare function readPowerThrottlingState(kernel: Kernel32PowerThrottling, pid: number): PowerThrottlingState;
/** kernel32's power-throttling calls, or `undefined` off Windows or without `bun:ffi` (never loads FFI elsewhere). */
export declare function loadKernel32PowerThrottling(platform?: NodeJS.Platform): Kernel32PowerThrottling | undefined;
export interface SpawnSurfaces {
childProcessPrototype: {
spawn(...args: unknown[]): unknown;
pid?: number;
};
bun?: {
spawn(...args: unknown[]): {
pid?: number;
};
};
}
export type PowerThrottlingInstall = {
status: "skipped";
reason: "not-windows" | "opted-out" | "no-ffi";
} | {
status: "installed";
self: PowerThrottlingResult;
optOutChild(pid: number): void;
restore(): void;
};
export interface InstallOptions {
platform?: NodeJS.Platform;
env?: NodeJS.ProcessEnv;
pid?: number;
load?: (platform: NodeJS.Platform) => Kernel32PowerThrottling | undefined;
surfaces?: SpawnSurfaces;
}
/**
* Opts this process out of EcoQoS and wraps this realm's launchers so every child gets the same call. A failure for
* one child (it already exited, or it runs at a higher integrity level) leaves that child on Windows' default policy
* and never fails the launch: the spawn result is returned unchanged.
*/
export declare function installWindowsPowerThrottlingOptOut(options?: InstallOptions): PowerThrottlingInstall;
/** The startup entry: installs once per JavaScript realm; later calls return the first result. */
export declare function ensureWindowsPowerThrottlingOptOut(): PowerThrottlingInstall;
/** For a launcher that starts processes outside `node:child_process` and `Bun.spawn` (the Windows breakaway shim). */
export declare function optOutChildPowerThrottling(pid: number): void;
//# sourceMappingURL=windows-power-throttling.d.ts.map