/** * ExecResult factory functions for cleaner code. * * These helpers reduce verbosity and improve readability when * constructing ExecResult objects throughout the interpreter. */ import type { ExecResult, Observation } from "../../types.js"; import type { InterpreterContext } from "../types.js"; /** * A successful result with no output. * Use this for commands that succeed silently. */ export declare const OK: ExecResult; /** * Create a successful result with optional stdout. * * @param stdout - Output to include (default: "") * @param observations - Optional failure metadata * @returns ExecResult with exitCode 0 */ export declare function success(stdout?: string, observations?: Observation[]): ExecResult; /** * Create a failure result with stderr message. * * @param stderr - Error message to include * @param exitCode - Exit code (default: 1) * @param observations - Optional failure metadata * @returns ExecResult with the specified exitCode */ export declare function failure(stderr: string, exitCode?: number, observations?: Observation[]): ExecResult; /** * Create a result with all fields specified. * * @param stdout - Standard output * @param stderr - Standard error * @param exitCode - Exit code * @param observations - Optional failure metadata * @returns ExecResult with all fields */ export declare function result(stdout: string, stderr: string, exitCode: number, observations?: Observation[]): ExecResult; /** * Convert a boolean test result to an ExecResult. * Useful for test/conditional commands where true = exit 0, false = exit 1. * * @param passed - Boolean test result * @returns ExecResult with exitCode 0 if passed, 1 otherwise */ export declare function testResult(passed: boolean): ExecResult; /** * Throw an ExecutionLimitError for execution limits (recursion, iterations, commands). * * @param message - Error message describing the limit exceeded * @param limitType - Type of limit exceeded * @param stdout - Accumulated stdout to include * @param stderr - Accumulated stderr to include * @throws ExecutionLimitError always */ export declare function throwExecutionLimit(message: string, limitType: "recursion" | "iterations" | "commands" | "string_length" | "glob_operations" | "substitution_depth" | "output_size" | "file_descriptors" | "memory" | "cpu_time" | "network_traffic" | "sub_agents", stdout?: string, stderr?: string): never; /** * Check file descriptor count against the limit before adding a new one. * Throws ExecutionLimitError if the limit would be exceeded. */ export declare function checkFdLimit(ctx: InterpreterContext): void; /** * Stable machine-readable codes for source-emitted observations. * These are deliberately POSIX/errno-flavored so agents can switch on a * stable identifier instead of parsing English stderr. */ export interface ObservationCodes { readonly COMMAND_NOT_FOUND: "CMD_NOT_FOUND"; readonly FILE_NOT_FOUND: "ENOENT"; readonly DIRECTORY_NOT_FOUND: "ENOENT_DIR"; readonly PERMISSION_DENIED: "EACCES"; readonly IS_A_DIRECTORY: "EISDIR"; readonly NOT_A_DIRECTORY: "ENOTDIR"; readonly LIMIT_EXCEEDED: "ELIMIT"; readonly SECURITY_VIOLATION: "ESEC"; readonly SYNTAX_ERROR: "ESYNTAX"; } export declare const OBSERVATION_CODES: ObservationCodes; /** * Observation factory helpers. * * These produce well-formed, high-confidence {@link Observation} objects at * the SOURCE of a typed failure — where the interpreter/command actually KNOWS * the cause (command resolution, fs ops, permission checks) rather than where * AgTrace regex-scrapes English stderr after the fact. * * Every source-emitted observation carries: * - a stable machine `code` (see {@link OBSERVATION_CODES}) * - a `confidence` of 1.0 (the source is authoritative about its own failure) * * All factories return frozen, immutable objects (new objects, never mutated). */ export declare const obs: { commandNotFound(command: string, suggestions?: string[]): Observation; fileNotFound(path: string, command?: string): Observation; directoryNotFound(path: string, command?: string): Observation; isADirectory(path: string, command?: string): Observation; notADirectory(path: string, command?: string): Observation; permissionDenied(path: string, command?: string): Observation; };