baa-conductor


baa-conductor / apps / codexd / src
im_wower  ·  2026-03-22

node-shims.d.ts

  1declare function setTimeout(callback: () => void, delay?: number): unknown;
  2declare function clearTimeout(handle: unknown): void;
  3declare function setInterval(callback: () => void, delay?: number): unknown;
  4declare function clearInterval(handle: unknown): void;
  5
  6declare class Buffer extends Uint8Array {
  7  static alloc(size: number): Buffer;
  8  static allocUnsafe(size: number): Buffer;
  9  static concat(chunks: readonly Uint8Array[]): Buffer;
 10  static from(value: string, encoding?: string): Buffer;
 11  copy(target: Uint8Array, targetStart?: number): number;
 12  readBigUInt64BE(offset?: number): bigint;
 13  readUInt16BE(offset?: number): number;
 14  subarray(start?: number, end?: number): Buffer;
 15  toString(encoding?: string): string;
 16  writeBigUInt64BE(value: bigint, offset?: number): number;
 17  writeUInt16BE(value: number, offset?: number): number;
 18}
 19
 20declare const process: {
 21  argv: string[];
 22  cwd(): string;
 23  env: Record<string, string | undefined>;
 24  execPath: string;
 25  exitCode?: number;
 26  off?(event: string, listener: () => void): unknown;
 27  on?(event: string, listener: () => void): unknown;
 28  pid?: number;
 29};
 30
 31declare module "node:child_process" {
 32  export interface SpawnOptions {
 33    cwd?: string;
 34    env?: Record<string, string | undefined>;
 35    stdio?: readonly string[] | string;
 36  }
 37
 38  export interface WritableStreamLike {
 39    end(chunk?: string | Uint8Array): unknown;
 40    write(chunk: string | Uint8Array): boolean;
 41  }
 42
 43  export interface ReadableStreamLike {
 44    on(event: "data", listener: (chunk: string | Uint8Array) => void): this;
 45    on(event: "end", listener: () => void): this;
 46    on(event: "error", listener: (error: Error) => void): this;
 47    setEncoding?(encoding: string): this;
 48  }
 49
 50  export interface ChildProcess {
 51    pid?: number;
 52    stdin?: WritableStreamLike;
 53    stderr?: ReadableStreamLike;
 54    stdout?: ReadableStreamLike;
 55    kill(signal?: string): boolean;
 56    on(event: "error", listener: (error: Error) => void): this;
 57    on(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
 58    on(event: "spawn", listener: () => void): this;
 59    once(event: "error", listener: (error: Error) => void): this;
 60    once(event: "exit", listener: (code: number | null, signal: string | null) => void): this;
 61    once(event: "spawn", listener: () => void): this;
 62  }
 63
 64  export function spawn(command: string, args?: readonly string[], options?: SpawnOptions): ChildProcess;
 65}
 66
 67declare module "node:crypto" {
 68  export function createHash(
 69    algorithm: string
 70  ): {
 71    digest(encoding: string): string;
 72    update(value: string): { digest(encoding: string): string };
 73  };
 74
 75  export function randomUUID(): string;
 76}
 77
 78declare module "node:fs/promises" {
 79  export function access(path: string): Promise<void>;
 80  export function appendFile(path: string, data: string, encoding: string): Promise<void>;
 81  export function mkdir(path: string, options?: { recursive?: boolean }): Promise<void>;
 82  export function readFile(path: string, encoding: string): Promise<string>;
 83  export function writeFile(path: string, data: string, encoding: string): Promise<void>;
 84}
 85
 86declare module "node:path" {
 87  export function join(...paths: string[]): string;
 88  export function resolve(...paths: string[]): string;
 89}
 90
 91declare module "node:net" {
 92  export interface AddressInfo {
 93    address: string;
 94    family: string;
 95    port: number;
 96  }
 97
 98  export interface Socket {
 99    destroy(error?: Error): this;
100    destroySoon?(): void;
101    end(chunk?: string | Uint8Array): this;
102    on(event: "close", listener: () => void): this;
103    on(event: "data", listener: (chunk: Buffer) => void): this;
104    on(event: "end", listener: () => void): this;
105    on(event: "error", listener: (error: Error) => void): this;
106    setNoDelay(noDelay?: boolean): this;
107    write(chunk: string | Uint8Array): boolean;
108  }
109}
110
111declare module "node:http" {
112  import type { AddressInfo } from "node:net";
113
114  export interface IncomingMessage {
115    headers: Record<string, string | string[] | undefined>;
116    method?: string;
117    on?(event: "data", listener: (chunk: string | Uint8Array) => void): this;
118    on?(event: "end", listener: () => void): this;
119    on?(event: "error", listener: (error: Error) => void): this;
120    setEncoding?(encoding: string): void;
121    url?: string;
122  }
123
124  export interface ServerResponse<Request extends IncomingMessage = IncomingMessage> {
125    end(chunk?: string): void;
126    setHeader(name: string, value: string): this;
127    statusCode: number;
128  }
129
130  export interface Server {
131    address(): AddressInfo | string | null;
132    close(callback?: (error?: Error) => void): this;
133    closeAllConnections?(): void;
134    listen(options: { host: string; port: number }): this;
135    on(
136      event: "upgrade",
137      listener: (request: IncomingMessage, socket: import("node:net").Socket, head: Buffer) => void
138    ): this;
139    off(event: "error", listener: (error: Error) => void): this;
140    off(event: "listening", listener: () => void): this;
141    once(event: "error", listener: (error: Error) => void): this;
142    once(event: "listening", listener: () => void): this;
143  }
144
145  export function createServer(
146    handler: (request: IncomingMessage, response: ServerResponse<IncomingMessage>) => void
147  ): Server;
148}