UNPKG

framework

Version:

The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.

52 lines 2.52 kB
/** * One `execFile`-backed CLI runner, configured per binary. * * `git` and `gh` were each wrapped by hand — the same dynamic import, the same promise * around `execFile`, the same `String(stdout)` — differing only in the binary, the timeout * and how a failure is reported. Those are the parameters; the wrapper is not worth writing * twice, and it was written five times. */ /** Runs a CLI binary in `cwd`, resolving its stdout. Rejects on a non-zero exit. */ export type CliRunner = (args: string[], cwd: string) => Promise<string>; /** * How long one invocation may run: a flat budget, or one derived from the args (#997). * * One binary is not one operation. `git push` talks to a remote and `git worktree add` writes a * whole checkout, while `git rev-parse` reads a file; a single number has to be either too short * for the first two or too long for the third. */ export type CliTimeout = number | ((args: string[]) => number); /** * A CLI killed for outrunning its timeout, as opposed to one the tool itself rejected (#997). * * `execFile` SIGTERMs on timeout, and a killed `git push` usually writes nothing to stderr, so * without this the failure surfaces as a bare "Command failed: git push ..." that reads like a * rejected push. */ export declare class CliTimeoutError extends Error { readonly bin: string; readonly args: string[]; readonly timeoutMs: number; /** Brand, so a value that crossed a module boundary is still recognisable. */ readonly timedOut = true; constructor(bin: string, args: string[], timeoutMs: number); } /** True when a {@link CliRunner} rejection is a timeout kill rather than a non-zero exit (#997). */ export declare function isCliTimeout(err: unknown): err is CliTimeoutError; /** How to invoke one binary. */ export interface CliRunnerOptions { bin: string; /** Kill the process after this long, so a hung CLI cannot hang the caller. */ timeoutMs: CliTimeout; /** Raise the stdout cap for a command whose output can be large (a repo crawl). */ maxBuffer?: number; /** * Reject with the CLI's own stderr rather than the generic exec message. `gh` puts the * useful part there ("not logged in", "no default remote"), and that is exactly what the * dashboard should show instead of a generic failure. */ preferStderr?: boolean; } /** Build a {@link CliRunner} for one binary. */ export declare function cliRunner(opts: CliRunnerOptions): CliRunner; //# sourceMappingURL=cli-exec.d.ts.map