export type JsonValue = null | boolean | number | string | JsonValue[] | {
    [key: string]: JsonValue;
};
export type CredentialType = "api_key" | "oauth" | "token";
export type ApiKeyCredential = {
    type: "api_key";
    provider: string;
    key?: string;
    keyRef?: SecretRef;
    email?: string;
    metadata?: Record<string, string>;
};
export type TokenCredential = {
    type: "token";
    provider: string;
    token?: string;
    tokenRef?: SecretRef;
    expires?: number;
    email?: string;
};
export type OAuthCredential = {
    type: "oauth";
    provider: string;
    access: string;
    refresh: string;
    expires: number;
    clientId?: string;
    email?: string;
    accountId?: string;
    enterpriseUrl?: string;
    projectId?: string;
};
export type SecretRef = {
    source: "env" | "file" | "exec";
    provider: string;
    id: string;
};
export type AuthProfileCredential = ApiKeyCredential | TokenCredential | OAuthCredential;
export type ProfileUsageStats = {
    lastUsed?: number;
    cooldownUntil?: number;
    disabledUntil?: number;
    disabledReason?: string;
    errorCount?: number;
    lastFailureAt?: number;
};
export type AuthProfileStore = {
    version: 1;
    profiles: Record<string, AuthProfileCredential>;
    order?: Record<string, string[]>;
    lastGood?: Record<string, string>;
    usageStats?: Record<string, ProfileUsageStats>;
};
export type RudderConfig = {
    version: 1;
    vcs?: VcsMode;
    defaultBackend: BackendId;
    lastUsedBackend?: BackendId;
    mergeStrategy: MergeStrategy;
    runPolicy: {
        sameCheckout: "single-active";
        concurrentPromptMode: "worktree" | "queue";
        mergeMode: "manual-on-conflict";
    };
    acpx: {
        install: "latest";
    };
    backends: {
        claude?: BackendConfig;
        codex?: BackendConfig;
        acpx?: BackendConfig;
    };
    board?: {
        port?: number;
    };
    orchestrator?: {
        maxParallel: number;
        reviewGate: "auto" | "manual";
        budget?: {
            maxTokens?: number;
        };
    };
};
export declare const DEFAULT_BOARD_PORT = 4774;
export type BackendId = "claude" | "codex" | "acpx";
export type VcsMode = "git" | "jj";
export type EffortLevel = "low" | "medium" | "high" | "xhigh" | "max";
export type RunMode = "execute" | "plan";
export type MergeStrategy = "merge" | "rebase";
export type BackendConfig = {
    profileId?: string;
    model?: string;
    effort?: EffortLevel;
    reasoningEffort?: EffortLevel;
};
export type RunStatus = "created" | "running" | "steering" | "verifying" | "completed" | "failed" | "cancelled" | "merge-conflict" | "merged";
export type UndoEntry = {
    opId: string;
    label: string;
    ts: string;
    runIds: string[];
};
export type NodeStatus = "planned" | "ready" | "running" | "review" | "blocked" | "merged" | "failed";
export type DepType = "hard" | "soft";
export type EdgeType = DepType | "judge";
export type GraphEdge = {
    id: string;
    from: string;
    to: string;
    type: EdgeType;
    why?: string;
    delivered?: boolean;
};
export type TaskNode = {
    id: string;
    title: string;
    prompt: string;
    goal?: string;
    success?: string;
    backend: BackendId;
    model?: string;
    effort?: EffortLevel;
    status: NodeStatus;
    runId?: string;
    worktree?: {
        path: string;
        workspaceName?: string;
    };
    jjChangeId?: string;
    deps: string[];
    lastLine?: string;
    tokens?: {
        input: number;
        output: number;
    };
    reviewState?: "pending" | "approved" | "changes-requested";
    resolverRunId?: string;
    merge?: MergeState;
    supersededBy?: string;
    source: "planner" | "injection";
    createdAt: string;
    updatedAt: string;
};
export type RudderGraph = {
    version: 1;
    repoRoot: string;
    integrationChangeId?: string;
    nodes: Record<string, TaskNode>;
    edges: Record<string, GraphEdge>;
    updatedAt: string;
};
export type PlanEdge = {
    on: string;
    type: EdgeType;
    why?: string;
};
export type PlanNode = {
    id: string;
    title: string;
    prompt: string;
    goal?: string;
    success?: string;
    deps: PlanEdge[];
    backend?: BackendId;
    model?: string;
    effort?: EffortLevel;
    fileScope?: string[];
};
export type PlanDag = {
    nodes: PlanNode[];
    edges: Array<{
        from: string;
        to: string;
        type: EdgeType;
        why?: string;
    }>;
};
export type InferredDep = {
    node: string;
    type: DepType;
};
export type ReconcileResult = {
    node: PlanNode;
    inferredDeps: InferredDep[];
};
export type ResolverContext = {
    mergeChangeId: string;
    parentChangeIds: string[];
    conflictedFiles: string[];
    nodeTitle: string;
    intoTitle: string;
    workspacePath: string;
};
export type RunRecord = {
    id: string;
    status: RunStatus;
    vcs?: VcsMode;
    mode?: RunMode;
    resolverFor?: string;
    resolverRunId?: string;
    tokens?: {
        input: number;
        output: number;
    };
    task: string;
    taskSummary?: string;
    taskSummaryLlm?: boolean;
    backend: BackendId;
    model?: string;
    effort?: EffortLevel;
    createdAt: string;
    updatedAt: string;
    repoRoot: string;
    targetBranch: string;
    baseCommit: string;
    worktree: {
        enabled: boolean;
        path: string;
        branch?: string;
        workspaceName?: string;
        jjChangeId?: string;
    };
    process?: {
        pid?: number;
        startedAt?: string;
        endedAt?: string;
        exitCode?: number | null;
        signal?: NodeJS.Signals | null;
    };
    currentPrompt?: string;
    turns?: Array<{
        ts: string;
        prompt: string;
        source: "user" | "steerer";
    }>;
    lastUserInputAt?: string;
    autoSteer?: {
        count: number;
        max: number;
        waitingSince?: string;
    };
    session?: {
        nativeSessionId?: string;
        acpxSessionId?: string;
        sessionName?: string;
    };
    terminal?: {
        kind: "tmux";
        sessionName: string;
        paneId: string;
        paneTitle?: string;
        logPath?: string;
        launchedAt: string;
    };
    verification?: VerificationResult;
    merge?: MergeState;
    sync?: SyncState;
};
export type MergeState = {
    status: "not-started" | "merged" | "conflict" | "failed";
    attemptedAt?: string;
    targetBranch?: string;
    strategy?: MergeStrategy;
    conflictKind?: "merge" | "rebase";
    conflictedFiles?: string[];
    operationId?: string;
    mergeChangeId?: string;
    error?: string;
};
export type SyncState = {
    status: "not-started" | "synced" | "conflict" | "failed";
    attemptedAt?: string;
    baseBranch?: string;
    conflictedFiles?: string[];
    error?: string;
};
export type RudderEvent = {
    ts: string;
    runId: string;
    nodeId?: string;
    type: "run.created" | "run.started" | "run.continued" | "run.detached" | "steerer.waiting" | "steerer.prompt" | "planner.spec" | "backend.output" | "backend.error" | "backend.exit" | "verifier.result" | "run.completed" | "run.failed" | "run.cancelled" | "merge.result" | "sync.result" | "node.created" | "node.ready" | "node.running" | "node.review" | "node.merged" | "node.blocked" | "node.failed" | "plan.proposed" | "plan.reconciled" | "schedule.tick" | "schedule.launched" | "schedule.softDelivered" | "merge.attempt" | "merge.merged" | "merge.conflict" | "resolver.spawned" | "resolver.resolved";
    message?: string;
    data?: JsonValue;
};
export type RunRequest = {
    run: RunRecord;
    prompt: string;
    contract: string;
};
export type BackendAdapter = {
    id: BackendId;
    verify(): Promise<{
        ok: boolean;
        message: string;
    }>;
    run(request: RunRequest, emit: (event: RudderEvent) => Promise<void>): Promise<number>;
};
export type SpecContract = {
    runId: string;
    task: string;
    goal: string;
    success: string;
    createdAt: string;
    repo: {
        root: string;
        branch: string;
        baseCommit: string;
        status: string[];
    };
    instructionsFiles: Array<{
        path: string;
        content: string;
    }>;
    acceptanceCriteria: string[];
    suggestedTests: string[];
};
export type VerificationResult = {
    satisfied: string[];
    missing: string[];
    notes: string;
    shouldContinue: boolean;
};
export type CloudAuthState = {
    version: 1;
    token: string;
    cloudUrl: string;
    defaultRuntime?: "fly" | "byo-vm";
    byocSshHost?: string;
    accountId?: string;
    email?: string;
    expiresAt?: string;
    updatedAt: string;
};
export type CloudSail = {
    id: string;
    status?: string;
    url?: string;
    branch?: string;
    createdAt?: string;
    updatedAt?: string;
    [key: string]: JsonValue | undefined;
};
export type BoardColumn = "todo" | "running" | "review" | "done";
export type ProjectEntry = {
    slug: string;
    repoRoot: string;
    name: string;
    addedAt: string;
};
export type ProjectsRegistry = {
    version: 1;
    projects: ProjectEntry[];
};
export type ProjectSummary = {
    slug: string;
    name: string;
    repoRoot: string;
    counts: {
        todo: number;
        running: number;
        review: number;
        done: number;
        blocked: number;
        failed: number;
    };
    lastActivityAt: string;
};
export type BoardNode = {
    id: string;
    title: string;
    status: RunStatus;
    column: BoardColumn;
    blocked: boolean;
    backend: BackendId;
    model?: string;
    effort?: EffortLevel;
    lastLine: string | null;
    tokens: {
        input: number;
        output: number;
    } | null;
    deps: {
        hard: string[];
        soft: string[];
    };
    createdAt: string;
    updatedAt: string;
    worktree: {
        path: string;
        workspaceName?: string;
    } | null;
    merge: MergeState | null;
};
export type BoardEdge = {
    from: string;
    to: string;
    kind: "hard" | "soft" | "judge";
};
export type PlanGate = {
    id: string;
    nodeId?: string;
    question: string;
    options?: string[];
    createdAt: string;
};
export type MemoryEntry = {
    text: string;
    owner?: string;
    ts?: string;
};
export type BoardSnapshot = {
    slug: string;
    name: string;
    generatedAt: string;
    nodes: BoardNode[];
    edges: BoardEdge[];
    gates: PlanGate[];
    memory: MemoryEntry[];
};
