// session-context.ts — Per-session context using AsyncLocalStorage.
// Enables multi-tenant hosted mode where each session can have its own license key.
import { AsyncLocalStorage } from 'node:async_hooks';
const sessionStore = new AsyncLocalStorage();
/**
 * Run a callback within a session context.
 * All code executed inside (including async) can read the session via getSessionContext().
 */
export function runWithSessionContext(ctx, fn) {
    return sessionStore.run(ctx, fn);
}
/**
 * Get the current session context (if running inside runWithSessionContext).
 * Returns undefined for stdio transport or outside session scope.
 */
export function getSessionContext() {
    return sessionStore.getStore();
}
//# sourceMappingURL=session-context.js.map