import { ToolchainPreset, type EmceptionAPI } from 'emception'; import type { ToolResult } from './tool-runner.js'; import type { WorkerClient } from './worker-client.js'; export interface CompilePaths { /** Source file path inside the VFS (also appears in error messages). */ sourcePath: string; /** Object file path produced by the compile step. */ objectPath: string; /** Final wasm artifact path produced by the link step. */ wasmPath: string; } /** Full preset for a native (clang + wasm-ld) target. */ export interface NativePreset { readonly toolchain: Exclude; readonly bundlesToPreload: string[]; readonly defaultTools: string[]; readonly compiler?: 'clang' | 'clang++' | 'emcc' | 'em++'; readonly flags?: string[]; readonly ldflags?: string[]; readonly defines?: Record; readonly includePaths?: string[]; readonly libPaths?: string[]; readonly libs?: string[]; readonly sources?: string[]; readonly output?: string; readonly env?: Record; readonly compileTool: string; readonly linkTool: string; compileArgv(paths: Pick): string[]; linkArgv(paths: Pick): string[]; } /** Full preset for a Python script target (no compile/link step). */ export interface PythonPreset { readonly toolchain: ToolchainPreset.Python; readonly bundlesToPreload: string[]; readonly defaultTools: string[]; readonly env?: Record; } /** Full preset for a CMake project (no direct clang invocation). */ export interface CMakePreset { readonly toolchain: ToolchainPreset.CMake; readonly bundlesToPreload: string[]; readonly defaultTools: string[]; readonly env?: Record; } /** Unified preset — discriminated by `toolchain`. */ export type Preset = NativePreset | PythonPreset | CMakePreset; export declare const TOOLCHAIN_PRESETS: Record; export type CompilePhase = 'write' | 'compile' | 'link' | 'run'; export interface CompileAndRunOptions { toolchain: ToolchainPreset; /** Source code to compile. Written to `paths.sourcePath` before compiling. */ source: string; /** Optional working dir for each tool invocation. Defaults to dirname(sourcePath). */ cwd?: string; /** Override the default `/home/user/main.{cpp,o,wasm}` paths. */ paths?: Partial; /** Stdin payload for the run step. Sent byte-by-byte, EOF after exhaustion. */ stdin?: string; /** Forwarded to each `api.run` call. */ onStdout?: (text: string) => void; onStderr?: (text: string) => void; /** Lifecycle callback fired before each phase begins. */ onPhase?: (phase: CompilePhase) => void; } export interface CompileAndRunResult { /** Phase that produced the final exit code. */ finalPhase: CompilePhase; /** Exit code of the last tool that ran. Non-zero if compile or link failed. */ exitCode: number; /** Per-phase results, populated as each phase completes. */ compile?: ToolResult; link?: ToolResult; run?: ToolResult; } /** * End-to-end "edit → compile → link → run" cycle on top of the headless * `WorkerClient`. Stops early on compile or link failure. */ export declare function compileAndRun(client: WorkerClient | EmceptionAPI, opts: CompileAndRunOptions): Promise; //# sourceMappingURL=presets.d.ts.map