/**
 * types.ts — AgentInvoker interface + DispatchRequest/Handle/Event/Result.
 *
 * Defines the common contract that every headless coding-agent adapter must
 * implement (claude-code, codex, aider).  Push-dispatch owns the lifecycle;
 * invokers just spawn and stream.
 */
export type InvokerId = 'claude-code' | 'codex' | 'aider' | 'cursor';
export interface ContextPack {
    goal: string;
    memories: Array<{
        id: string;
        content: string;
        tier: string;
        priority: number;
    }>;
    files: string[];
    crGraphContext: string | null;
    repoRoot: string;
    repoName: string;
}
export interface DispatchRequest {
    goal: string;
    contextPack: ContextPack;
    specialistId: string;
    operativeId: string;
    budgetCapUsd: number;
    workingDir: string;
    timeoutMs?: number;
    runId: string;
}
export interface DispatchHandle {
    runId: string;
    pid: number;
    events: AsyncIterable<DispatchEvent>;
    cancel(): Promise<void>;
    result: Promise<DispatchResult>;
}
export type DispatchEvent = {
    kind: 'progress';
    step: number;
    total: number;
    message: string;
} | {
    kind: 'stdout';
    chunk: string;
} | {
    kind: 'stderr';
    chunk: string;
} | {
    kind: 'tool-call';
    toolName: string;
    args: unknown;
} | {
    kind: 'tool-result';
    toolName: string;
    result: unknown;
} | {
    kind: 'file-change';
    path: string;
    before: string;
    after: string;
} | {
    kind: 'token-usage';
    prompt: number;
    completion: number;
} | {
    kind: 'done';
    exitCode: number;
} | {
    kind: 'error';
    error: string;
};
export interface DispatchResult {
    success: boolean;
    exitCode: number;
    tokensUsed: {
        prompt: number;
        completion: number;
    };
    costUsd: number;
    filesChanged: string[];
    diff: string;
    summary: string;
    memoriesFormed: number;
    durationMs: number;
}
export interface AgentInvoker {
    readonly id: InvokerId;
    readonly label: string;
    /** Returns true if the binary is in PATH and at an acceptable version. */
    isAvailable(): Promise<boolean>;
    /** Returns the version string (e.g. "1.2.3") or null if unavailable. */
    getVersion(): Promise<string | null>;
    /** Spawns the headless agent and returns a DispatchHandle immediately. */
    dispatch(req: DispatchRequest): Promise<DispatchHandle>;
}
export interface AvailabilityStatus {
    id: InvokerId;
    label: string;
    available: boolean;
    version: string | null;
    checkedAt: number;
}
