export declare class JxaError extends Error { readonly context: string; constructor(message: string, context: string); } /** * Apple Event timed out (`errAETimeout`, error -1712). * * This is the Tahoe-era runtime regression: macOS 26's stricter Apple * Events validation drops unverified internal IPC replies, causing the * JXA evaluation context to block synchronously. The runner detects this * and retries with exponential backoff before surfacing the error. * * If you see this error, Mail.app may need a restart, or the operation * may be too large for a single Apple Event (try paginating). */ export declare class JxaTimeoutError extends JxaError { readonly attempts: number; constructor(message: string, context: string, attempts: number); } /** * The target application process was not found (`procNotFound`, error -600). * * Common on macOS 26 Tahoe after the first call when Mail.app has been idle. * The runner retries with backoff. If retries fail, ensure Mail.app is * running and the orchestrator has Automation permission. */ export declare class JxaProcNotFoundError extends JxaError { readonly attempts: number; constructor(message: string, context: string, attempts: number); } /** * Detect whether a raw error string indicates a retryable JXA condition. * Centralised so {@link runJxaString}, {@link runAppleScript}, and tests * all use the same detector. * * Patterns covered: * - `errAETimeout` / -1712 / "Apple event timed out" → `timeout` * - `procNotFound` / -600 / "application isn't running" → `procNotFound` * * Other timeouts (Node-level `ETIMEDOUT`, generic "timed out") are also * classified as `timeout` so a hung osascript subprocess is retried. */ export declare function classifyJxaError(rawError: string): { retryable: boolean; type: "timeout" | "procNotFound" | null; }; export interface RunOptions { /** Timeout in milliseconds. Default: 120_000. */ timeout?: number; /** Arguments passed to the JXA script via environment variables. */ args?: Record; /** Max stdout buffer in bytes. Default: 10MB. Scales dynamically for large requests. */ maxBuffer?: number; /** * Directory containing JXA scripts. Required for {@link runJxaFile}. * * Each adapter package owns its own JXA scripts and passes its directory * here. Typically the adapter creates a thin wrapper that bakes its * directory in once. */ jxaDir?: string; } /** Compute max buffer size based on expected message count. ~2KB per summary, 2x headroom. */ export declare function computeMaxBuffer(limit: number): number; /** * Escape a string for safe embedding inside AppleScript double-quoted strings. * Escapes in correct order to prevent double-escaping. */ export declare function escapeForAppleScript(s: string): string; /** * Safely parse JSON from JXA output. Wraps errors with context. */ export declare function safeJsonParse(raw: string, context: string): T; /** * Execute a JXA script file and return its stdout as a string. * Scripts receive arguments via environment variables prefixed with `MCP_`. */ export declare function runJxaFile(scriptName: string, options?: RunOptions): Promise; /** * Execute an inline JXA string and return its stdout. * * Uses a temp file instead of `-e` to avoid shell escaping issues with * large scripts or env var values containing special characters (@, =, +). * * Wrapped in the Tahoe watchdog ({@link runWithWatchdog}): retryable JXA * errors (`errAETimeout`, `procNotFound`, generic process timeouts) are * automatically retried with exponential backoff; final failures throw * typed {@link JxaTimeoutError} or {@link JxaProcNotFoundError}. */ export declare function runJxaString(script: string, options?: RunOptions): Promise; /** * Execute an AppleScript string (fallback for operations not yet ported to JXA). * * Wrapped in the Tahoe watchdog like {@link runJxaString}: retryable * errors are auto-retried; final failures throw typed errors. */ export declare function runAppleScript(script: string, options?: RunOptions): Promise; //# sourceMappingURL=runner.d.ts.map