export type GlobalStoreJSON = { store: Record>; initializedModules: string[]; }; export declare class GlobalStore { private store; private initializedModules; private objectTags; private objectTagsPresent; private static readonly VALUE_TAGS_KEY; private static readonly DURABLE_FLAG_KEY; static readonly REDACT_TAG = "redact"; private isRef; private isTaggable; private valueTagMap; private tagsRecordFor; setTag(value: unknown, key: string, val: unknown): void; getTagsFor(value: unknown): Record | undefined; /** Remove a single tag key from a value. No-op if the value has no tags. */ removeTag(value: unknown, key: string): void; /** Remove every tag from a value. */ removeAllTags(value: unknown): void; /** * Mark a value for statelog redaction. Sole *writer* of the redact tag, so * the tag's representation lives in exactly one place. Equivalent to the * user-facing tag(value, "redact", true). */ markRedacted(value: unknown): void; /** * True when a value is marked redact:true. Sole *reader* of the redact tag * (the statelog replacer calls this), so the walker never hard-codes the * tag shape. */ isRedacted(value: unknown): boolean; /** * Cheap "are there any tags at all?" check so statelog can skip installing * a redaction replacer entirely when nothing is tagged (the common case). * Three signals: the in-memory WeakMap bit (branch-local tags; resets on * clone alongside the WeakMap), the serialized durable flag (on-object * tags; rides clone/interrupt round-trips), and the primitive Map's size. */ hasAnyTags(): boolean; /** True when any durable (on-object) tag has been created on or adopted by * this store. Serialized under __internal, so it survives clone/fromJSON. */ hasDurableObjectTagFlag(): boolean; /** Set the durable-object-tag presence flag. Monotonic (never reset — * over-approximating costs one redaction pass, under-approximating leaks); * OR'd into the parent store when a branch settles (see runBatch). */ setDurableObjectTagFlag(): void; get(moduleId: string, varName: string): any; set(moduleId: string, varName: string, value: any): void; isInitialized(moduleId: string): boolean; markInitialized(moduleId: string): void; toJSON(): GlobalStoreJSON; getTokenStats(): any; restoreTokenStats(stats: any): void; static readonly INTERNAL_MODULE = "__internal"; static withTokenStats(): GlobalStore; static tokenStatsFromJSON(json: GlobalStoreJSON): { totalTokens: number; totalCost: number; }; static fromJSON(json: GlobalStoreJSON): GlobalStore; /** * Deep-snapshot copy. Used by `runInBranchAlsFrame` so each fork / * parallel / race branch sees its own GlobalStore: at fork time the * branch starts with the parent's values, then reads/writes inside * the branch only touch the clone; the parent is untouched on * branch completion. * * `initializedModules` is preserved so the branch's module guards * (`!__globals()!.isInitialized(...)`) treat every module the * parent already initialized as still initialized — `__initialize * Globals` is a no-op in branches and inherited values stay intact. * * Implementation: round-trip through `toJSON` / `fromJSON`, which * already handles native types (Maps, Sets, Dates) via the shared * `nativeTypeReplacer` / `nativeTypeReviver`. If a perf hotspot * appears, `Stage 4` in the design doc covers a copy-on-write * variant — but for typical agent programs the clone is microseconds. */ clone(): GlobalStore; }