export { forkPortableState, checkpointRoots, mergeState, compactState } from "./portable-state-operations.ts"; export type PortableValue = null | undefined | string | number | boolean | bigint | { ref: string; }; export type PortableNode = { kind: "object"; nullPrototype: boolean; properties: Record; } | { kind: "array"; length: number; properties: Record; } | { kind: "map"; entries: [PortableValue, PortableValue][]; } | { kind: "set"; entries: PortableValue[]; } | { kind: "binary"; bytes: Uint8Array; } | { kind: "date"; time: number; } | { kind: "regexp"; source: string; flags: string; lastIndex: number; } | { kind: "view"; constructor: string; buffer: PortableValue; byteOffset: number; length: number; } | { kind: "recipe"; name: string; properties: Record; } | { kind: "checkpoint"; snapshot: string; restore: string; data: PortableValue; } | { kind: "module"; specifier: string; imported: string; attributes?: Record | undefined; }; export interface BindingRecipe { name: string; kind: string; declaration: string; source?: string | undefined; references?: string[] | undefined; module?: { specifier: string; imported: string; attributes?: Record | undefined; } | undefined; hook?: "startup" | "tool_result" | undefined; checkpoint?: { snapshot: string; restore: string; } | undefined; } export interface PortableCapture { state: PortableState; skipped: { name: string; reason: string; }[]; } export declare class CheckpointRestoreError extends Error { readonly bindings: string[]; constructor(message: string, bindings: string[]); } export interface PortableState { version: 1; roots: Record; nodes: Record; bindings: Record; pins: string[]; imports: string[]; } export declare function emptyState(): PortableState; /** IDs survive worker restoration so a mutation of an aliased object has one merge owner. */ export declare class PortableGraph { private readonly realmPrototypes; private readonly realmConstructors; /** Register trusted intrinsics before user code can shadow realm globals. */ registerRealm(intrinsics: Record): void; private create; private hasPrototype; private readonly identities; private readonly recipes; private readonly modules; private checkpoints; private liveOnlyHint; /** Snapshot current values once, before the graph's per-root portability probes. */ prepareCheckpoints(values: Record, bindings: Record): Promise; /** Live execution is unrestricted; durability captures only independently restorable roots. */ capture(values: Record, bindings: Record, pins: string[], imports?: string[]): PortableCapture; registerRecipe(value: unknown, name: string): void; registerModule(value: unknown, specifier: string, imported: string, attributes?: Record): void; encode(values: Record, bindings: Record, pins: string[], imports?: string[]): PortableState; decode(state: PortableState, resolveRecipe: (name: string) => unknown, resolveModule?: (node: Extract) => unknown): { values: Record; restoreCheckpoints(resolve: (name: string) => unknown): Promise; }; } export declare function bindingDependencies(binding: BindingRecipe): string[];