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.
57 lines • 2.42 kB
TypeScript
import type { DriverEvent, DriverTurn } from './types.js';
/** The slice of `child_process.spawn` a driver needs. Injectable for tests. */
export type SpawnLike = (command: string, args: readonly string[], options: {
cwd: string;
env: NodeJS.ProcessEnv;
detached?: boolean;
}) => SpawnedProcess;
/** The slice of a spawned process a driver reads. */
export interface SpawnedProcess {
/** OS pid; present for a real child, absent for in-memory test fakes. */
pid?: number | undefined;
stdout: NodeJS.ReadableStream | null;
stderr: NodeJS.ReadableStream | null;
stdin: NodeJS.WritableStream | null;
on(event: 'close', listener: (code: number | null) => void): unknown;
on(event: 'error', listener: (err: Error) => void): unknown;
kill(signal?: NodeJS.Signals): unknown;
}
/**
* The slice of a driver's output parser {@link runAgentCli} drives: fed one line
* at a time, asked for the turn at the end. Each wrapped agent speaks its own
* dialect ({@link StreamJsonParser} for Claude Code, `CodexJsonParser` for
* Codex), but the process handling around it is identical.
*/
export interface AgentCliParser {
/** Fold one line of the agent's output in, and surface anything worth emitting. */
push(line: string): DriverEvent[];
/** The turn the lines added up to. */
result(): DriverTurn;
}
/** How to run one agent-CLI invocation. */
export interface RunAgentCliOptions {
bin: string;
args: string[];
cwd: string;
env: NodeJS.ProcessEnv;
prompt: string;
spawn: SpawnLike;
emit: (event: DriverEvent) => void;
signals: AbortSignal[];
/** The agent's own output dialect. */
parser: AgentCliParser;
/** The agent's name, for error messages. Default `"claude-code"`. */
agent?: string;
}
/**
* Spawn one agent-CLI invocation and resolve with its final turn.
*
* Everything here is about the *process*, not the agent: its own process group
* so an interrupt kills the whole tree rather than orphaning it, a SIGTERM/
* SIGKILL grace window, abort wiring, and a non-zero exit failing the turn even
* when text was streamed first. Only {@link RunAgentCliOptions.parser} knows
* which agent is on the other end — a second agent gets all of this for free
* rather than a second copy of it.
*/
export declare function runAgentCli(opts: RunAgentCliOptions): Promise<DriverTurn>;
//# sourceMappingURL=agent-cli.d.ts.map