import { type BoundRequestOperationAttempt } from "../actions/task-extraction-context.js"; import { type ActionFailureProvenance } from "../types/action-failure.js"; import type { Action, ActionResult, HandlerCallback } from "../types/components.js"; import type { IAgentRuntime } from "../types/runtime.js"; /** Inputs for one isolated handler attempt and its user-facing callback. */ export interface SettleActionHandlerOptions { /** Opaque identity supplied only by the actual host executor. */ operationAttempt?: BoundRequestOperationAttempt; runtime: IAgentRuntime; action: Action; callback?: HandlerCallback; /** Executor-owned observation after normalization, before buffered delivery. */ beforeCallbacks?: (result: ActionResult) => void; invoke: (callback?: HandlerCallback) => unknown | Promise; /** * Retry-owning callers need the original exception. Top-level executors use * a normalized failure result so planner loops can reason about the failure. */ handlerError?: "return-failure" | "rethrow"; } /** Validate a handler result and bind it to the executing action. */ export declare function normalizeActionResult(actionName: string, result: unknown, operationAttempt?: BoundRequestOperationAttempt): ActionResult; /** Build a planner-visible failure while retaining the trusted action identity. */ export declare function actionFailureResult(actionName: string, message: string, extraData?: Record, failureProvenance?: ActionFailureProvenance): ActionResult; /** Preserve Error messages while making non-Error throws planner-visible. */ export declare function stringifyActionError(error: unknown): string; /** * Run one handler with a per-attempt callback buffer. Each invocation owns its * buffer, so a failed retry attempt can never leak callbacks into a later one. */ export declare function settleActionHandler(options: SettleActionHandlerOptions): Promise;