import { DeserializedJson } from "@trigger.dev/core";
import { ApiRequestOptions, type RunMetadataUpdater, type AsyncIterableStream } from "@trigger.dev/core/v3";
export declare const metadata: {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
    current: typeof currentMetadata;
    get: typeof getMetadataKey;
    save: typeof saveMetadata;
    replace: typeof replaceMetadata;
    stream: typeof stream;
    fetchStream: typeof fetchStream;
    parent: RunMetadataUpdater;
    root: RunMetadataUpdater;
    refresh: typeof refreshMetadata;
};
export type RunMetadata = Record<string, DeserializedJson>;
/**
 * Returns the metadata of the current run if inside a task run.
 * This function allows you to access the entire metadata object for the current run.
 *
 * @returns {RunMetadata | undefined} The current run's metadata or undefined if not in a run context.
 *
 * @example
 * const currentMetadata = metadata.current();
 * console.log(currentMetadata);
 */
declare function currentMetadata(): RunMetadata | undefined;
/**
 * Get a specific key from the metadata of the current run if inside a task run.
 *
 * @param {string} key - The key to retrieve from the metadata.
 * @returns {DeserializedJson | undefined} The value associated with the key, or undefined if not found or not in a run context.
 *
 * @example
 * const user = metadata.get("user");
 * console.log(user.name); // "Eric"
 * console.log(user.id); // "user_1234"
 */
declare function getMetadataKey(key: string): DeserializedJson | undefined;
/**
 * Set a key in the metadata of the current run if inside a task run.
 * This function allows you to update or add a new key-value pair to the run's metadata.
 *
 * @param {string} key - The key to set in the metadata.
 * @param {DeserializedJson} value - The value to associate with the key.
 *
 * @example
 * metadata.set("progress", 0.5);
 */
declare function setMetadataKey(key: string, value: DeserializedJson): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Delete a key from the metadata of the current run if inside a task run.
 *
 * @param {string} key - The key to delete from the metadata.
 *
 * @example
 * metadata.del("progress");
 */
declare function deleteMetadataKey(key: string): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Update the entire metadata object for the current run if inside a task run.
 * This function allows you to replace the entire metadata object with a new one.
 *
 * @param {RunMetadata} metadata - The new metadata object to set for the run.
 * @returns {void}
 *
 * @example
 * metadata.replace({ progress: 0.6, user: { name: "Alice", id: "user_5678" } });
 */
declare function replaceMetadata(metadata: RunMetadata): void;
/**
 * @deprecated Use `metadata.replace()` instead.
 */
declare function saveMetadata(metadata: RunMetadata): void;
/**
 * Increments a numeric value in the metadata of the current run by the specified amount.
 * This function allows you to atomically increment a numeric metadata value.
 *
 * @param {string} key - The key of the numeric value to increment.
 * @param {number} value - The amount to increment the value by.
 *
 * @example
 * metadata.increment("counter", 1); // Increments counter by 1
 * metadata.increment("score", 10); // Increments score by 10
 */
declare function incrementMetadataKey(key: string, value?: number): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Decrements a numeric value in the metadata of the current run by the specified amount.
 * This function allows you to atomically decrement a numeric metadata value.
 *
 * @param {string} key - The key of the numeric value to decrement.
 * @param {number} value - The amount to decrement the value by.
 *
 * @example
 * metadata.decrement("counter", 1); // Decrements counter by 1
 * metadata.decrement("score", 5); // Decrements score by 5
 */
declare function decrementMetadataKey(key: string, value?: number): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Appends a value to an array in the metadata of the current run.
 * If the key doesn't exist, it creates a new array with the value.
 * If the key exists but isn't an array, it converts the existing value to an array.
 *
 * @param {string} key - The key of the array in metadata.
 * @param {DeserializedJson} value - The value to append to the array.
 *
 * @example
 * metadata.append("logs", "User logged in");
 * metadata.append("events", { type: "click", timestamp: Date.now() });
 */
declare function appendMetadataKey(key: string, value: DeserializedJson): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Removes a value from an array in the metadata of the current run.
 *
 * @param {string} key - The key of the array in metadata.
 * @param {DeserializedJson} value - The value to remove from the array.
 *
 * @example
 *
 * metadata.remove("logs", "User logged in");
 * metadata.remove("events", { type: "click", timestamp: Date.now() });
 */
declare function removeMetadataKey(key: string, value: DeserializedJson): {
    set: typeof setMetadataKey;
    del: typeof deleteMetadataKey;
    append: typeof appendMetadataKey;
    remove: typeof removeMetadataKey;
    increment: typeof incrementMetadataKey;
    decrement: typeof decrementMetadataKey;
    flush: typeof flushMetadata;
};
/**
 * Flushes metadata to the Trigger.dev instance
 *
 * @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
 * @returns {Promise<void>} A promise that resolves when the metadata flush operation is complete.
 */
declare function flushMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
/**
 * Refreshes metadata from the Trigger.dev instance
 *
 * @param {ApiRequestOptions} [requestOptions] - Optional request options to customize the API request.
 * @returns {Promise<void>} A promise that resolves when the metadata refresh operation is complete.
 */
declare function refreshMetadata(requestOptions?: ApiRequestOptions): Promise<void>;
/**
 * @deprecated Use `streams.pipe()` instead.
 */
declare function stream<T>(key: string, value: AsyncIterable<T> | ReadableStream<T>, signal?: AbortSignal): Promise<AsyncIterable<T>>;
declare function fetchStream<T>(key: string, signal?: AbortSignal): Promise<AsyncIterableStream<T>>;
export {};
