import type { AssistantMessage } from "@earendil-works/pi-ai/compat";
import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts";
export declare function _isRetryableError(this: AgentSession, message: AssistantMessage): boolean;
/**
 * For GitHub Copilot Gemini, reconstruct flattened tool-call arguments
 * (for example `edits[0].newText`) into the nested arrays/objects Gemini
 * produced before the assistant message is persisted, so saved transcripts
 * never carry the flattened CAPI wire shape and replays loaded from disk match
 * the structure Gemini signed. In-place, gated to Copilot Gemini, and a no-op
 * for well-formed arguments or any other provider/model. The outbound replay
 * normalizer still heals already-persisted (legacy) sessions on the wire.
 */
export declare function _normalizePersistedGeminiToolArgs(this: AgentSession, message: AssistantMessage): void;
/**
 * Detect a degenerate empty completion: the provider ended the stream with no
 * usable content and zero output tokens. Seen with github-copilot Gemini models
 * that emit finish_reason "stop" (or a tool-use stop) with an empty content array
 * and 0 output tokens, leaving the turn dead instead of producing the next step.
 *
 * These are treated as retryable so the harness re-issues the request rather than
 * silently stopping mid-task. Guarded tightly (no text, no tool call, no thinking,
 * and output === 0) so legitimate non-empty turns are never matched.
 *
 * Intentionally provider-agnostic (not gated to Copilot Gemini): a degenerate
 * empty turn is a transient failure for any provider. It is bounded by
 * `maxRetries` and falls through to normal handling on exhaustion.
 */
export declare function _isEmptyCompletion(this: AgentSession, message: AssistantMessage): boolean;
export declare function _isSafetyRefusal(this: AgentSession, message: AssistantMessage): boolean;
/**
 * Handle retryable errors with exponential backoff.
 * @returns true if retry was initiated, false if max retries exceeded or disabled
 */
export declare function _trySwitchToFallbackModel(this: AgentSession, message: AssistantMessage): Promise<boolean>;
export declare function _handleRetryableError(this: AgentSession, message: AssistantMessage): Promise<boolean>;
/**
 * Cancel in-progress retry.
 */
export declare function abortRetry(this: AgentSession): void;
/**
 * Wait for any in-progress retry to complete.
 * Returns immediately if no retry is in progress.
 */
export declare function waitForRetry(this: AgentSession): Promise<void>;
/** Whether auto-retry is currently in progress */
export declare function setAutoRetryEnabled(this: AgentSession, enabled: boolean): void;
/**
 * Execute a bash command.
 * Adds result to agent context and session.
 * @param command The bash command to execute
 * @param onChunk Optional streaming callback for output
 * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix)
 * @param options.operations Custom BashOperations for remote execution
 */
export declare const agentSessionRetryMethods: {
    _isRetryableError: typeof _isRetryableError;
    _normalizePersistedGeminiToolArgs: typeof _normalizePersistedGeminiToolArgs;
    _isEmptyCompletion: typeof _isEmptyCompletion;
    _isSafetyRefusal: typeof _isSafetyRefusal;
    _handleRetryableError: typeof _handleRetryableError;
    _trySwitchToFallbackModel: typeof _trySwitchToFallbackModel;
    abortRetry: typeof abortRetry;
    waitForRetry: typeof waitForRetry;
    setAutoRetryEnabled: typeof setAutoRetryEnabled;
};
//# sourceMappingURL=agent-session-retry.d.ts.map