/**
 * Terminal-error recording for the agentic loops.
 *
 * Error chunks are deferred until every recovery avenue (model retries, error
 * processors, fallback models) is exhausted, and `buildMessagesFromChunks`
 * turns an error chunk into no parts at all. A turn that produced no normal
 * output therefore created no assistant message, so the failed turn vanished
 * from thread history: only the orphan-guard-blocked user message remained.
 *
 * This helper runs only at the loops' established terminal-error decision
 * point and appends a first-class `error` part — analogous to the stored
 * `step-start` part — to the assistant record of the failed attempt, creating
 * a normal error-only assistant message when the attempt produced nothing.
 * Because that message is a real assistant record, the failed turn forms a
 * persistable pair with its user message through the ordinary memory path.
 *
 * Only `{ name, message }` is persisted, plus `statusCode`, a bounded
 * `responseBody`, the provider `requestId`, the `modelId` the request named,
 * every provider code and the innermost `reason` for provider failures —
 * without those, an `APICallError` whose message is just "Bad Request" cannot
 * be diagnosed or classified after the fact. The rest of the request body,
 * stack traces, causes, other custom fields and
 * custom `toJSON` output stay on the runtime error surfaces (stream chunk,
 * `onError`, `result.error`); thread history has to be deterministic and
 * JSON-safe.
 */
import type { MastraDBMessage, MastraErrorPart, MessageList } from '../../agent/message-list/index.js';
/**
 * Reduce an unknown terminal error to the JSON-safe identity that gets stored.
 * Never mutates the supplied error and never invokes `toJSON`, so a hostile or
 * circular error object cannot change what lands in history — or break it.
 */
export declare function toPersistedErrorIdentity(error: unknown): MastraErrorPart['error'];
export type RecordTerminalErrorMessageArgs = {
    messageList: MessageList;
    /**
     * Materialization id of the failed attempt — the id its partial output was
     * stored under before error processors ran.
     */
    attemptId?: string;
    /**
     * Active response id after error processors ran. An error processor may have
     * rotated it, in which case it no longer matches `attemptId`.
     */
    activeId?: string;
    error: unknown;
};
/**
 * Record a terminal failure as an `error` part on the failed attempt's
 * assistant message, creating that message when the attempt produced no
 * output. Returns the message carrying the part, or undefined when there was
 * no assistant record to attach it to and none could be created.
 */
export declare function recordTerminalErrorMessage({ messageList, attemptId, activeId, error, }: RecordTerminalErrorMessageArgs): MastraDBMessage | undefined;
//# sourceMappingURL=record-terminal-error-message.d.ts.map