@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
42 lines • 1.54 kB
TypeScript
/**
* Unified error handling for browser tools.
*
* All browser tools return errors in this consistent format,
* providing LLM-friendly messages and recovery hints.
*/
/**
* Error codes for browser tool failures.
*
* These codes help agents understand what went wrong
* and whether retry or recovery is possible.
*/
export type ErrorCode = 'stale_ref' | 'element_not_found' | 'element_blocked' | 'element_not_visible' | 'not_focusable' | 'timeout' | 'browser_closed' | 'browser_error';
/**
* Structured error response for browser tool failures.
*
* Provides LLM-friendly error information with optional recovery hints.
*/
export interface BrowserToolError {
/** Always false for error responses */
success: false;
/** Error classification code */
code: ErrorCode;
/** LLM-friendly error description */
message: string;
/** Suggested recovery action (only when actionable) */
recoveryHint?: string;
/** Whether the operation can be retried */
canRetry: boolean;
}
/**
* Creates a structured error response for browser tools.
*
* Sets canRetry based on the error code: true for 'timeout' and 'element_blocked'.
*
* @param code - Error classification code
* @param message - LLM-friendly error description
* @param hint - Optional recovery hint (only when actionable)
* @returns Typed BrowserToolError with canRetry set automatically
*/
export declare function createError(code: ErrorCode, message: string, hint?: string): BrowserToolError;
//# sourceMappingURL=errors.d.ts.map