import { type RunMetadataChangeOperation } from "../schemas/common.js"; export type ApplyOperationResult = { newMetadata: Record; unappliedOperations: RunMetadataChangeOperation[]; }; export declare function applyMetadataOperations(currentMetadata: Record, operations: RunMetadataChangeOperation | RunMetadataChangeOperation[]): ApplyOperationResult; /** * Collapses metadata operations to reduce payload size and avoid 413 "Request Entity Too Large" errors. * * When there are many operations queued up (e.g., 10k increment operations), sending them all * individually can result in request payloads exceeding the server's 1MB limit. This function * intelligently combines operations where possible to reduce the payload size: * * - **Increment operations**: Multiple increments on the same key are summed into a single increment * - Example: increment("counter", 1) + increment("counter", 2) → increment("counter", 3) * * - **Set operations**: Multiple sets on the same key keep only the last one (since later sets override earlier ones) * - Example: set("status", "processing") + set("status", "done") → set("status", "done") * * - **Delete operations**: Multiple deletes on the same key keep only one (duplicates are redundant) * - Example: del("temp") + del("temp") → del("temp") * * - **Append, remove, and update operations**: Preserved as-is to maintain correctness since order matters * * @param operations Array of metadata change operations to collapse * @returns Collapsed array with fewer operations that produce the same final result * * @example * ```typescript * const operations = [ * { type: "increment", key: "counter", value: 1 }, * { type: "increment", key: "counter", value: 2 }, * { type: "set", key: "status", value: "processing" }, * { type: "set", key: "status", value: "done" } * ]; * * const collapsed = collapseOperations(operations); * // Result: [ * // { type: "increment", key: "counter", value: 3 }, * // { type: "set", key: "status", value: "done" } * // ] * ``` */ export declare function collapseOperations(operations: RunMetadataChangeOperation[]): RunMetadataChangeOperation[];