/**
 * Helper functions for evented workflow execution.
 */
import { TripWire } from '../../agent/trip-wire.js';
import type { ProcessorArgs } from './workflow-event-processor/index.js';
/**
 * Returns a copy of a serialized request context without the framework-managed
 * bearer token. The token must never be persisted in durable snapshots (it is
 * only valid for the live request), matching DefaultExecutionEngine.serializeRequestContext.
 */
export declare function withoutAuthToken<T extends Record<string, any> | undefined>(requestContext: T): T;
export declare function restoreLiveRequestContext(stored: Record<string, unknown> | undefined, live: Record<string, unknown>): Record<string, unknown>;
/**
 * Marks an error as deterministic (for example a throwing user callback), so the
 * evented processor fails the workflow on the first delivery instead of having
 * the transport redeliver the event and rerun the callback.
 */
export declare function markNonRedeliverable<T extends Error>(error: T): T;
export declare function isNonRedeliverable(error: unknown): boolean;
/**
 * Carries the run to fail when it can differ from the run of the event being handled:
 * a loop condition runs while handling its nested body's `workflow.end`.
 */
export declare class RunFailure extends Error {
    readonly error: Error;
    readonly run: Omit<ProcessorArgs, 'workflow'>;
    constructor(error: Error, run: Omit<ProcessorArgs, 'workflow'>);
}
/**
 * Interface for tripwire chunks in the stream.
 * These chunks are emitted when a processor triggers a tripwire.
 */
export interface TripwireChunk {
    type: 'tripwire';
    payload: {
        reason: string;
        retry?: boolean;
        metadata?: unknown;
        processorId?: string;
    };
}
/**
 * Type guard to check if a chunk is a tripwire chunk.
 * @param chunk - The chunk to check
 * @returns True if the chunk is a TripwireChunk
 */
export declare function isTripwireChunk(chunk: unknown): chunk is TripwireChunk;
/**
 * Creates a TripWire error from a tripwire chunk.
 * @param chunk - The tripwire chunk from the stream
 * @returns A TripWire error instance
 */
export declare function createTripWireFromChunk(chunk: TripwireChunk): TripWire;
/**
 * Extracts text delta from a stream chunk, handling V1 vs V2 differences.
 *
 * V1 (AI SDK v4): Uses `chunk.textDelta` for raw text
 * V2 (AI SDK v5): Uses `chunk.payload.text` for normalized text
 *
 * @param chunk - The stream chunk
 * @param isV2Model - Whether this is a V2 model (uses normalized payload)
 * @returns The text delta string, or undefined if not a text-delta chunk
 */
export declare function getTextDeltaFromChunk(chunk: {
    type: string;
    textDelta?: string;
    payload?: {
        text?: string;
    };
}, isV2Model: boolean): string | undefined;
/**
 * Parameters for resolving the current workflow state.
 */
export interface ResolveStateParams {
    /** State from a step result (highest priority). Uses `any` to accommodate various StepResult types. */
    stepResult?: unknown;
    /** State from all step results */
    stepResults?: {
        __state?: Record<string, unknown>;
    };
    /** State passed directly */
    state?: Record<string, unknown>;
}
/**
 * Resolves the current workflow state from multiple potential sources.
 * Priority order: stepResult.__state > stepResults.__state > state > empty object
 *
 * @param params - The state sources to check
 * @returns The resolved state object
 */
export declare function resolveCurrentState(params: ResolveStateParams): Record<string, unknown>;
//# sourceMappingURL=helpers.d.ts.map