/** * The seam between the platform-neutral SDK core (`src/index.ts`) and the * runtime it runs on. `src/platform/bun.ts` and `src/platform/burger.ts` * export exactly the same names with these types; `package.json#imports` * selects one through the `#platform` specifier (`burger` export condition * → Burger, everything else → Bun). `src/platform/conformance.ts` fails * `tsc` if the two drift apart. */ export interface NodeAppCtx { socket: string | undefined; logDir: string | undefined; dataDir: string | undefined; } export interface AppMemorySample { heap_used_kb: number; heap_total_kb: number; external_kb?: number; heap_capacity_kb?: number; } /** Callbacks the SDK core registers on the host connection. */ export interface HostConnectionHandlers { /** The connection is open; `endpoint` is a human-readable description for logs. */ onConnected(endpoint: string): void; /** One inbound IPC frame, already parsed into a plain object. */ onFrame(frame: unknown): Promise; /** A frame could not be parsed, or its handler threw. */ onFrameError(error: unknown): void; /** The connection failed. */ onError(error: Error): void; /** The connection closed normally. */ onClose(): void; } export interface HostConnection { /** Write one frame. */ send(frame: object): void; /** Write one frame and resolve once the runtime has accepted the bytes. */ sendAndFlush(frame: object): Promise; /** Stop delivering inbound frames that have not been delivered yet (lease drain). */ stopAccepting(): void; /** Close the connection. */ end(): void; } /** The subset of `AsyncLocalStorage` the SDK core uses. */ export interface InvocationContextStore { run(store: T, fn: () => R): R; getStore(): T | undefined; }