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. An optional `label` * replaces the default "[REDACTED]" marker in logs (stored as the tag value); * absent, the tag stores `true`. Equivalent to `tag(value, "redact", …)`. */ markRedacted(value: unknown, label?: string): void; /** * True when a value is marked for redaction — either the default marker * (`true`) or a custom label string. */ isRedacted(value: unknown): boolean; /** * The marker string to substitute for a redacted value in state logs — the * custom label if one was given, otherwise the default — or `undefined` when * the value is not redacted. The redact tag is read only here and in * `redactContainedStrings`; both statelog serialization paths call these * rather than comparing against one constant. */ redactionReplacement(value: unknown): string | undefined; /** * Scrub redacted string values that appear INSIDE a larger string — an email * body interpolating a presigned URL, a prompt embedding redacted base64. * Exact-match redaction cannot see composition: the composed string is a new * value with no tag, so without this both statelog paths would log the * secret verbatim. Longer secrets are replaced first so a secret containing * another secret cannot partially survive. Returns the scrubbed text, or * `undefined` when the text contains no redacted string. */ redactContainedStrings(text: string): string | undefined; /** * Copy every *primitive* redaction marker from this store into `target`. Used * at fork/race join: a primitive redacted inside a branch (e.g. binary output) * lives only in the branch's cloned store and cannot ride back on the returned * value the way a durable object tag does, so without this the parent would * serialize the branch's returned value for statelog without the tag. Only * redaction metadata moves — never program state — so global isolation is * unaffected (redaction can only hide values from logs, never change what the * program computes). */ copyPrimitiveRedactionsInto(target: GlobalStore): void; /** * 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; }