/** * Receipt Protocol Helpers * * Utility functions for creating and manipulating receipts. * * @module memory/receipts */ import { Receipt, UncertaintyMarker, ConfidenceLevel, ReversibilityLevel, Outcome, FailureClass } from "./schema.js"; /** * Parameters for creating a receipt */ export interface CreateReceiptParams { action: string; rationale: string; confidence: ConfidenceLevel; reversibility: ReversibilityLevel; outcome?: Outcome; rollbackPath?: string; rollbackTested?: boolean; escalationRequired?: boolean; escalationReason?: string; escalatedTo?: string; agentId?: string; sessionId?: string; frameId?: string; failureClass?: FailureClass; failureDetails?: string; recoverySuggestion?: string; } /** * Create a new receipt with sensible defaults * * @param params - Receipt creation parameters * @returns A valid Receipt object * * @example * ```typescript * const receipt = createReceipt({ * action: 'Implemented token refresh', * rationale: 'Needed to maintain authentication', * confidence: 'medium', * reversibility: 'reversible', * rollbackPath: 'Change LEX_TOKEN_REFRESH_TTL env var' * }); * ``` */ export declare function createReceipt(params: CreateReceiptParams): Receipt; /** * Add an uncertainty marker to an existing receipt * * @param receipt - The receipt to modify * @param marker - The uncertainty marker to add * @returns A new receipt with the marker added * * @example * ```typescript * const updated = markUncertainty(receipt, { * stated: 'Not sure if 80% TTL is optimal', * actionTaken: 'Implemented with 80% TTL, flagged for review', * confidence: 'medium', * mitigations: ['Made configurable via env var'] * }); * ``` */ export declare function markUncertainty(receipt: Receipt, marker: UncertaintyMarker): Receipt; /** * Mark a receipt as requiring escalation * * @param receipt - The receipt to modify * @param reason - Why escalation is needed * @param escalatedTo - Optional: who/what it was escalated to * @returns A new receipt marked for escalation * * @example * ```typescript * const escalated = requireEscalation( * receipt, * 'Cannot determine correct approach without domain expertise', * 'security-team' * ); * ``` */ export declare function requireEscalation(receipt: Receipt, reason: string, escalatedTo?: string): Receipt; /** * Check if a receipt indicates a reversible action * * @param receipt - The receipt to check * @returns True if the action is reversible or partially reversible */ export declare function isReversible(receipt: Receipt): boolean; /** * Check if a receipt has high confidence * * @param receipt - The receipt to check * @returns True if confidence is 'high' */ export declare function hasHighConfidence(receipt: Receipt): boolean; /** * Check if a receipt has uncertainty markers * * @param receipt - The receipt to check * @returns True if there are uncertainty notes */ export declare function hasUncertainty(receipt: Receipt): boolean; /** * Create a failure receipt with automatic recovery suggestion * * Convenience function that creates a receipt with outcome='failure', * automatically generates a recovery suggestion based on the failure class, * and sets confidence to 'low' by default. * * @param params - Failure receipt parameters * @returns A Receipt with failure classification and recovery suggestion * * @example * ```typescript * const receipt = createFailureReceipt({ * action: 'Attempted to process large file', * rationale: 'User requested file processing', * failureClass: 'context_overflow', * failureDetails: 'File exceeded 100MB limit', * reversibility: 'reversible', * }); * console.log(receipt.recoverySuggestion); * // => "Chunk task into smaller units with focused context" * ``` */ export declare function createFailureReceipt(params: Omit & { failureClass: FailureClass; confidence?: ConfidenceLevel; }): Receipt; export { Receipt, UncertaintyMarker, ConfidenceLevel, ReversibilityLevel, Outcome, FailureClass, RECEIPT_SCHEMA_VERSION, Receipt as ReceiptSchema, UncertaintyMarker as UncertaintyMarkerSchema, } from "./schema.js"; export { getRecoverySuggestion, getAllRecoverySuggestions } from "./recovery.js"; export type { RecoverySuggestion } from "./recovery.js";