/** * A {@link @nhtio/adk/batteries/media/contracts!BinaryExecutor} implementation that runs * invocations as local child processes via execa. * * @module @nhtio/adk/batteries/media/engines/execa_executor * * @remarks * The bundled local-process executor. `execa` is an optional peer dependency acquired through * an async resolver (default: a lazy dynamic import) — importing this module pulls nothing; * constructing the executor is what resolves the peer, and only on first `exec`. * * Process execution is a movable seam: anything implementing the `BinaryExecutor` contract — * a remote runner, a sandbox, a container shim — composes into binary engines exactly like * this one. The paired `ScratchWorkspace` must produce paths this executor can open; for the * local-process case, the bundled `fs_workspace` is the natural pair. */ import type { BinaryExecutor } from "../contracts"; /** The slice of execa this executor uses (kept minimal for BYO substitution in tests). */ export interface ExecaLike { (cmd: string, args: readonly string[], options: { timeout?: number; cancelSignal?: AbortSignal; reject: false; stripFinalNewline?: boolean; }): Promise<{ exitCode?: number; stdout?: unknown; stderr?: unknown; failed: boolean; }>; } /** Resolver forms accepted for the execa module. */ export type ExecaResolver = ExecaLike | (() => ExecaLike | { execa: ExecaLike; } | Promise); /** Options for {@link execaExecutor}. */ export interface ExecaExecutorOptions { /** * The execa function or an async resolver for it. Defaults to a lazy dynamic import of the * `execa` package (optional peer). */ execa?: ExecaResolver; /** Default timeout applied when an invocation does not specify one. */ defaultTimeoutMs?: number; } /** * Construct the bundled local-process {@link BinaryExecutor}. * * @param options - The execa resolver and defaults. * @returns A `BinaryExecutor` running invocations as local child processes. */ export declare const execaExecutor: (options?: ExecaExecutorOptions) => BinaryExecutor;