/**
 * Test Utilities for Orchestration E2E Tests
 *
 * Provides helper functions for waiting, polling, and assertions
 * used across the orchestration test suite.
 *
 * @module
 */
import type { EntityId, ElementId, Task } from '@stoneforge/core';
import type { SessionManager, SessionRecord } from '../runtime/session-manager.js';
import type { OrchestratorAPI } from '../api/index.js';
/**
 * Options for the waitFor polling function
 */
export interface WaitForOptions {
    /** Maximum time to wait in milliseconds (default: 30000) */
    readonly timeout?: number;
    /** Polling interval in milliseconds (default: 1000) */
    readonly interval?: number;
    /** Description for error messages */
    readonly description?: string;
}
/**
 * Result of an assertion check
 */
export interface AssertionResult {
    readonly passed: boolean;
    readonly message: string;
    readonly actual?: unknown;
    readonly expected?: unknown;
}
/**
 * Waits for a condition to become true, polling at regular intervals.
 *
 * @param condition - Async function that returns truthy when condition is met
 * @param options - Wait options
 * @returns The truthy value returned by the condition
 * @throws Error if timeout is reached before condition is met
 *
 * @example
 * ```typescript
 * const task = await waitFor(async () => {
 *   const tasks = await api.listTasks({ status: 'open' });
 *   return tasks.find(t => t.title.includes('health'));
 * }, { timeout: 90000, interval: 2000 });
 * ```
 */
export declare function waitFor<T>(condition: () => Promise<T | null | undefined | false>, options?: WaitForOptions): Promise<T>;
/**
 * Waits for a value to change from its initial state.
 *
 * @param getValue - Function that returns the current value
 * @param initialValue - The initial value to compare against
 * @param options - Wait options
 * @returns The new value after it changes
 */
export declare function waitForChange<T>(getValue: () => Promise<T>, initialValue: T, options?: WaitForOptions): Promise<T>;
/**
 * Waits for multiple conditions to all become true.
 *
 * @param conditions - Array of condition functions
 * @param options - Wait options
 * @returns Array of results from all conditions
 */
export declare function waitForAll<T extends unknown[]>(conditions: {
    [K in keyof T]: () => Promise<T[K] | null | undefined | false>;
}, options?: WaitForOptions): Promise<T>;
/**
 * Sleeps for a specified number of milliseconds.
 */
export declare function sleep(ms: number): Promise<void>;
/**
 * Measures the execution time of an async function.
 *
 * @param fn - Function to measure
 * @returns Object with result and duration in milliseconds
 */
export declare function measure<T>(fn: () => Promise<T>): Promise<{
    result: T;
    durationMs: number;
}>;
/**
 * Creates a timeout promise that rejects after specified milliseconds.
 */
export declare function timeout(ms: number, message?: string): Promise<never>;
/**
 * Races a promise against a timeout.
 *
 * @param promise - The promise to race
 * @param ms - Timeout in milliseconds
 * @param message - Optional timeout error message
 */
export declare function withTimeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
/**
 * Asserts that a value is defined (not null or undefined).
 */
export declare function assertDefined<T>(value: T | null | undefined, name: string): AssertionResult;
/**
 * Asserts that two values are equal.
 */
export declare function assertEqual<T>(actual: T, expected: T, name: string): AssertionResult;
/**
 * Asserts that a string contains a substring.
 */
export declare function assertContains(str: string, substring: string, name: string): AssertionResult;
/**
 * Asserts that a value matches a regular expression.
 */
export declare function assertMatches(str: string, pattern: RegExp, name: string): AssertionResult;
/**
 * Asserts that an array has a specific length.
 */
export declare function assertLength<T>(arr: T[], length: number, name: string): AssertionResult;
/**
 * Asserts that an array contains at least one item.
 */
export declare function assertNotEmpty<T>(arr: T[], name: string): AssertionResult;
/**
 * Asserts that a condition is true.
 */
export declare function assertTrue(condition: boolean, message: string): AssertionResult;
/**
 * Result of a single test
 */
export interface TestResult {
    readonly passed: boolean;
    readonly message: string;
    readonly duration: number;
    readonly details?: Record<string, unknown>;
}
/**
 * Creates a passing test result
 */
export declare function pass(message: string, details?: Record<string, unknown>): TestResult;
/**
 * Creates a failing test result
 */
export declare function fail(message: string, details?: Record<string, unknown>): TestResult;
/**
 * Generates a random string for unique identifiers.
 */
export declare function randomString(length?: number): string;
/**
 * Generates a unique test identifier.
 */
export declare function uniqueId(prefix?: string): string;
/**
 * Options for retry operations
 */
export interface RetryOptions {
    /** Maximum number of attempts (default: 3) */
    readonly maxAttempts?: number;
    /** Delay between attempts in milliseconds (default: 1000) */
    readonly delay?: number;
    /** Whether to use exponential backoff (default: false) */
    readonly exponentialBackoff?: boolean;
    /** Function to determine if error is retryable */
    readonly isRetryable?: (error: Error) => boolean;
}
/**
 * Retries an operation on failure.
 *
 * @param fn - Function to retry
 * @param options - Retry options
 * @returns Result of the function
 */
export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
/**
 * Options for domain-specific wait helpers
 */
export interface DomainWaitOptions {
    readonly timeout?: number;
    readonly interval?: number;
}
/**
 * Waits for a task to reach a specific status.
 */
export declare function waitForTaskStatus(api: OrchestratorAPI, taskId: ElementId, targetStatus: string, opts?: DomainWaitOptions): Promise<Task>;
/**
 * Waits for a task to be assigned to any agent.
 */
export declare function waitForTaskAssignment(api: OrchestratorAPI, taskId: ElementId, opts?: DomainWaitOptions): Promise<Task>;
/**
 * Waits for a session to start for a given agent.
 */
export declare function waitForSessionStart(sessionManager: SessionManager, agentId: EntityId, opts?: DomainWaitOptions): Promise<SessionRecord>;
/**
 * Waits for a session to end (terminate or suspend).
 */
export declare function waitForSessionEnd(sessionManager: SessionManager, sessionId: string, opts?: DomainWaitOptions): Promise<SessionRecord>;
/**
 * Waits for task orchestrator metadata to satisfy a predicate.
 */
export declare function waitForTaskMeta(api: OrchestratorAPI, taskId: ElementId, predicate: (meta: Record<string, unknown>) => boolean, opts?: DomainWaitOptions): Promise<Record<string, unknown>>;
/**
 * Waits for a git commit to appear in a worktree directory.
 * Returns the commit hash of the most recent commit.
 */
export declare function waitForGitCommit(worktreePath: string, opts?: DomainWaitOptions): Promise<string>;
//# sourceMappingURL=test-utils.d.ts.map