/** * Application state helpers for use in scripts and actions. * * The session ID determines which user's application state is read/written. * Resolution order: * 1. Per-request context (AsyncLocalStorage) — set by the HTTP handler * 2. AGENT_USER_EMAIL env var — CLI scripts only * * The per-request context is critical in multi-user deployments: the env var * is process-global and gets overwritten by concurrent requests, so it cannot * reliably identify the caller. Only CLI scripts (single-user, no HTTP * context) should fall through to the env var. */ import { type AppStateCompareAndSetOperation } from "./store.js"; export declare function readAppState(key: string): Promise | null>; export declare function writeAppState(key: string, value: Record): Promise; export declare function deleteAppState(key: string): Promise; export declare function compareAndSetAppState(key: string, expectedValue: Record | null, nextValue: Record | null): Promise; export declare function compareAndSetManyAppState(operations: readonly AppStateCompareAndSetOperation[]): Promise; export declare function listAppState(prefix: string): Promise; }>>; export declare function deleteAppStateByPrefix(prefix: string): Promise; /** * Browser tab id for the current request, if the client sent one. Used to * scope ambient UI state (navigation, selection, etc.) so a chat from one tab * reads that tab's state instead of whichever tab wrote the global key last. */ export declare function getCurrentRequestBrowserTabId(): string | null; /** `key:` when a browser tab id is present, otherwise `key`. */ export declare function appStateKeyForBrowserTab(key: string, browserTabId: unknown): string; /** * Read application state scoped to the requesting browser tab. Reads the * tab-scoped key first and (by default) falls back to the global key so * CLI/external agents and pre-scoping clients keep working. */ export declare function readAppStateForCurrentTab(key: string, options?: { fallbackToGlobal?: boolean; }): Promise | null>; /** Write application state scoped to the requesting browser tab. */ export declare function writeAppStateForCurrentTab(key: string, value: Record): Promise; //# sourceMappingURL=script-helpers.d.ts.map