import { execFile } from "node:child_process"; import type { Grader, GraderInput, GraderMetadata, GraderResult } from "../../index.js"; import { type Duration } from "../../utils/duration.js"; export interface Config { /** * The program to run. Ex: python, javascript, bash. */ program: string; /** * Command line arguments for the program. */ args?: string[]; /** * Optional subdirectory under the preserved workspace to use as the cwd. * Either slash style is accepted and normalized to the current platform. */ sub_path?: string; /** * Run the program using a shell, instead of using exec. * Default: false */ shell?: boolean; /** * The maximum duration the process can run before being terminated. * Requires a unit suffix (e.g. "1m", "90s", "500ms"). * Default: 1m (60 seconds) */ timeout?: Duration; /** * Additional environment variables to pass to the subprocess. * Merged with the process environment. EVALUATE_WORKSPACE and * EVALUATE_GRADER_INPUT are always set by the grader and cannot be specified. */ env?: Record; } export type Metadata = Omit & { exit_code?: unknown; signal?: unknown; stdout?: unknown; stderr?: unknown; error?: unknown; [key: string]: unknown; }; /** * Makes it possible to write a grader as an external script/program. * * We set two environment variables that let you load up all the state you need for your grader: * - EVALUATE_WORKSPACE: * - EVALUATE_GRADER_INPUT: * * Your grader can then return status back in two ways: * - Exit code based - exit with a 0 (passed) or a non-zero exit code (failed). * NOTE: You must not print anything to stdout. You can print to stderr. * * - GraderResult JSON text - in this mode you output a serialized GraderResult model to stdout. * NOTE: You can't use stdout for any other printing. You can print to stderr. */ export declare class ProgramGrader implements Grader { metadata: GraderMetadata; execFileAsync: typeof execFile.__promisify__; /** * `program ./check.sh` — derived from `program` only. This grader's config * also carries `env`, which can hold credentials, and names reach reports * and the analytics store, so that key is deliberately never used. * * The program path itself reaches those artifacts, up to the 20-cluster cap * (ellipsis included), * which travel further than the eval spec. Pass secrets via `env`, not in * the program path. */ defaultName(config: Record): string; grade(input: GraderInput): Promise; graderResultForError(config: Config, err: unknown): GraderResult; } //# sourceMappingURL=program-grader.d.ts.map