export type StepOutcome = 'ok' | 'error' | 'running' | 'unknown';
export interface SessionStepBase {
    ordinal: number;
    startMs: number;
    durationMs: number;
    /**
     * Whether `durationMs` was measured from a paired result (`false`) or inferred
     * from the next event (`true`). Mandatory — the console must visually
     * distinguish measured from inferred duration.
     */
    durationEstimated: boolean;
    outcome: StepOutcome;
    label: string;
}
export interface ThinkingStep extends SessionStepBase {
    kind: 'thinking';
    lane: 'think';
    outcome: 'ok' | 'running' | 'unknown';
}
export interface ExecutionBase extends SessionStepBase {
    kind: 'execution';
    lane: string;
    callId?: string;
    /** The tool call this execution targets (hook/permission → the guarded call). */
    targetCallId?: string;
}
export type ToolExecutionType = 'bash' | 'edit' | 'write' | 'read' | 'grep' | 'generic';
export interface ToolExecutionBase extends ExecutionBase {
    executionType: ToolExecutionType;
    tool: string;
    result: ExecutionResult;
}
export interface ExecutionResult {
    exitCode?: number;
    statusCode?: number;
    errorCode?: string;
    stdout?: TextPreview;
    stderr?: TextPreview;
    combined?: TextPreview;
}
export interface TextPreview {
    text: string;
    truncated: boolean;
    originalBytes: number;
}
export type BashCategory = 'build' | 'test' | 'git' | 'network' | 'other';
export type BashDanger = 'normal' | 'potentially-destructive' | 'DESTRUCTIVE';
export interface BashAction {
    ordinal: number;
    source: string;
    argv: string[];
    /** false when a dynamic node (substitution/expansion) kept argv incomplete. */
    argvComplete: boolean;
    program?: string;
    categories: BashCategory[];
    danger: BashDanger;
    destructiveOperation?: string;
}
export interface BashExecution extends ToolExecutionBase {
    executionType: 'bash';
    /** Redacted outer command. */
    command: string;
    /** Redacted shell payload after unwrapping `/bin/zsh -lc "…"`. */
    unwrappedCommand: string;
    parseStatus: 'parsed' | 'partial' | 'unparseable';
    parseDiagnostics: string[];
    actions: BashAction[];
}
export type FileOperation = 'create' | 'update' | 'overwrite' | 'delete' | 'rename' | 'unknown';
export interface FileHunk {
    id: string;
    oldStart?: number;
    oldLines?: number;
    newStart?: number;
    newLines?: number;
    addedLines: number;
    removedLines: number;
    beforeHash?: string;
    afterHash?: string;
    before?: TextPreview;
    after?: TextPreview;
    revertedByStep?: number;
}
export interface FileMutation {
    path: string;
    operation: FileOperation;
    hunks: FileHunk[];
    revertedByStep?: number;
}
export interface RevertLink {
    revertedStep: number;
    path: string;
    revertedHunkIds: string[];
}
export interface EditExecution extends ToolExecutionBase {
    executionType: 'edit';
    files: FileMutation[];
    reverts: RevertLink[];
}
export interface WriteExecution extends ToolExecutionBase {
    executionType: 'write';
    files: FileMutation[];
    reverts: RevertLink[];
}
export interface CountResult {
    value: number;
    relation: 'exact' | 'at-least';
}
export interface ReadExecution extends ToolExecutionBase {
    executionType: 'read';
    file: string;
    offset?: number;
    limit?: number;
    returnedLines?: CountResult;
    returnedBytes?: CountResult;
}
export interface GrepExecution extends ToolExecutionBase {
    executionType: 'grep';
    query: string;
    path?: string;
    glob?: string;
    outputMode?: 'content' | 'files' | 'count' | 'unknown';
    hits?: CountResult;
}
export interface GenericToolExecution extends ToolExecutionBase {
    executionType: 'generic';
    input?: TextPreview;
}
/** A permission request/decision — a first-class sibling, NOT a fake tool. */
export interface PermissionExecution extends ExecutionBase {
    executionType: 'permission';
    lane: 'permission';
    requestId?: string;
    permissionKind: 'command' | 'filesystem' | 'network' | 'mcp' | 'other';
    decision: 'approved' | 'denied' | 'cancelled' | 'pending';
    scope?: string;
    reason?: TextPreview;
}
/** A hook firing — a first-class sibling, NOT a fake tool. */
export interface HookExecution extends ExecutionBase {
    executionType: 'hook';
    lane: 'hook';
    hookName?: string;
    hookEvent?: string;
    phase: 'pre' | 'post' | 'session' | 'other';
    decision: 'allowed' | 'blocked' | 'error' | 'unknown';
    result: ExecutionResult;
}
export type SessionStepV2 = ThinkingStep | BashExecution | EditExecution | WriteExecution | ReadExecution | GrepExecution | GenericToolExecution | PermissionExecution | HookExecution;
