//// // Session storage. 1 browser tab = 1 session import { AsyncLocalStorage } from "async_hooks" export type Session = { taskId?: string sessionId?: string project?: string ws?: any } // Ensure "ALS" lives between bun's hot reloads const g = globalThis as typeof globalThis & { __thread?: AsyncLocalStorage } export const ALS = g.__thread ??= new AsyncLocalStorage() export function getState(): Session | undefined { return ALS.getStore() }