/**
 * Checkpoint Runtime
 *
 * Provides the runtime functions that are injected into the sandbox
 * as `__checkpoint` namespace. These are called by the transformed code.
 */
import { OperationCheckpointManager, type ProvenanceExtractor, type ProvenanceAttacher, type ProvenanceMetaAttacher } from './operation-checkpoint-manager';
import type { OperationMetadata, CheckpointConfig, CheckpointInfo } from './checkpoint-types';
import type { CacheProvider } from '@mondaydotcomorg/atp-protocol';
export interface CheckpointRuntimeConfig {
    executionId: string;
    cache: CacheProvider;
    config?: CheckpointConfig;
}
/**
 * Extended config with provenance integration
 */
export interface CheckpointRuntimeConfigWithProvenance extends CheckpointRuntimeConfig {
    /**
     * Function to extract provenance metadata from a value
     * Typically: (value) => getProvenance(value)
     */
    provenanceExtractor?: ProvenanceExtractor;
    /**
     * Function to re-attach provenance to a restored value
     * Typically: (value, metadata) => createProvenanceProxy(value, metadata.source, metadata.readers)
     */
    provenanceAttacher?: ProvenanceAttacher;
    /**
     * Function to attach __prov_meta__ to objects before buffering
     * This ensures provenance survives isolated-vm boundary crossing
     */
    provenanceMetaAttacher?: ProvenanceMetaAttacher;
}
/**
 * Initialize the checkpoint runtime for an execution context
 */
export declare function initializeCheckpointRuntime(config: CheckpointRuntimeConfig): void;
/**
 * Initialize the checkpoint runtime with provenance integration
 *
 * When provenance is enabled:
 * - Restricted data is automatically forced to use reference checkpoints
 * - Provenance is re-attached when restoring checkpoints
 * - Security policies continue to work after checkpoint restoration
 */
export declare function initializeCheckpointRuntimeWithProvenance(config: CheckpointRuntimeConfigWithProvenance): void;
/**
 * Configure provenance functions on an existing checkpoint manager
 * Call this if the manager was already initialized without provenance
 */
export declare function configureCheckpointProvenance(provenanceExtractor: ProvenanceExtractor, provenanceAttacher: ProvenanceAttacher): void;
/**
 * Cleanup the checkpoint runtime for an execution
 * @param executionId - Optional execution ID to clean up (uses current if not provided)
 */
export declare function cleanupCheckpointRuntime(executionId?: string): void;
/**
 * Get the checkpoint runtime functions to inject into sandbox
 * These are the functions available as `__checkpoint` in transformed code
 */
export declare function getCheckpointRuntime(): CheckpointSandboxRuntime;
/**
 * The runtime interface exposed in the sandbox
 */
export interface CheckpointSandboxRuntime {
    /**
     * Buffer a result in memory (does NOT persist until flush)
     * Called by transformed code: `__checkpoint.buffer(id, result, metadata)`
     * Note: This is synchronous - no await needed
     */
    buffer: (checkpointId: string, result: unknown, metadata: OperationMetadata) => void;
    /**
     * Restore a value from a checkpoint
     * Called by user code: `__restore.checkpoint(fullId)`
     * @param fullCheckpointId - The full checkpoint ID (format: {executionId}:{shortId})
     *                           The execution ID is parsed from the ID automatically
     */
    restore: (fullCheckpointId: string) => Promise<unknown>;
}
/**
 * Get the current execution's checkpoint manager
 */
export declare function getCurrentCheckpointManager(): OperationCheckpointManager | null;
/**
 * Get checkpoint data for error responses
 * NOTE: This also flushes buffered checkpoints to cache before returning data
 */
export declare function getCheckpointDataForError(): Promise<CheckpointErrorData | null>;
/**
 * Checkpoint data included in error responses
 */
export interface CheckpointErrorData {
    checkpoints: CheckpointInfo[];
    restoreInstructions: string;
    stats: {
        total: number;
        fullSnapshots: number;
        references: number;
        totalSizeBytes: number;
    };
    /**
     * Number of checkpoints with restricted provenance
     * These MUST be restored via __restore.checkpoint()
     */
    restrictedCount?: number;
}
export type { ProvenanceExtractor, ProvenanceAttacher } from './operation-checkpoint-manager.js';
export type { CheckpointProvenanceMetadata, CheckpointProvenanceSnapshot, CheckpointReaderPermissions, CheckpointProvenanceSource } from './checkpoint-types.js';
//# sourceMappingURL=checkpoint-runtime.d.ts.map