/** * Recovery strategy for a denied or failed agent action. */ export type RecoveryStrategy = 'retry_narrower' | 'retry_backoff' | 'escalate_human' | 'escalate_operator' | 'degrade_scope' | 'degrade_autonomy' | 'substitute_tool' | 'terminate' | 'quarantine' | 'ignore'; /** * Condition that triggers a specific recovery strategy. */ export interface RecoveryTrigger { /** What kind of failure triggers this recovery */ failureType: 'scope_denied' | 'budget_exceeded' | 'merchant_blocked' | 'passport_expired' | 'delegation_revoked' | 'tool_error' | 'tool_timeout' | 'rate_limited' | 'human_denied' | 'policy_violation' | 'behavioral_drift' | 'unknown'; /** Optional: only trigger if consecutive failure count exceeds this */ afterConsecutiveFailures?: number; /** Optional: only trigger if failure occurs within this time window (ISO 8601 duration) */ withinWindow?: string; } /** * A single recovery rule: when trigger matches, apply strategy. */ export interface RecoveryRule { /** Human-readable name for this rule */ name: string; /** When this rule activates */ trigger: RecoveryTrigger; /** What to do when triggered */ strategy: RecoveryStrategy; /** For retry strategies: max attempts before falling through to next rule */ maxRetries?: number; /** For retry_backoff: initial delay in milliseconds */ initialBackoffMs?: number; /** For degrade_scope: which scopes to remove */ scopesToRemove?: string[]; /** For escalate_human: context message for the human */ escalationMessage?: string; /** For substitute_tool: alternative tool identifier */ alternativeTool?: string; /** Priority (lower = evaluated first). Default: 100 */ priority?: number; } /** * Complete recovery policy for an agent or delegation. * Evaluated top-down by priority. First matching rule wins. */ export interface RecoveryPolicy { /** Policy identifier */ policyId: string; /** Policy version (for auditability) */ version: string; /** Rules evaluated in priority order */ rules: RecoveryRule[]; /** Default strategy if no rule matches */ defaultStrategy: RecoveryStrategy; /** Max total recovery attempts across all rules before hard stop */ maxTotalAttempts: number; /** If true, every recovery action produces a signed receipt */ auditRecoveryActions: boolean; } /** * Record of a recovery action taken. Signed and appended to audit trail. */ export interface RecoveryEvent { eventId: string; timestamp: string; agentId: string; delegationId: string; /** The original action that failed */ failedAction: string; /** What went wrong */ failureType: RecoveryTrigger['failureType']; /** Error detail from the original failure */ failureDetail: string; /** Which rule matched */ matchedRule: string; /** What recovery strategy was applied */ strategyApplied: RecoveryStrategy; /** Attempt number (1-indexed) */ attemptNumber: number; /** Whether recovery succeeded */ recoverySucceeded: boolean; /** If recovery produced a new action, its receipt ID */ recoveryReceiptId?: string; } //# sourceMappingURL=recovery.d.ts.map