/** File-content cap (DES-FEEDBACK-002 §3.3): past this, `content` holds the first 512 KB and * `truncated: true` — the studio renders a labeled truncation banner, never a silent amputation. */ export declare const FILE_CONTENT_CAP_BYTES: number; /** Binary sniff window: a NUL byte in the first 8 KB ⇒ `binary: true`, `content: ""` — the studio * falls back to the external-open affordance rather than rendering mojibake. */ export declare const BINARY_SNIFF_BYTES: number; /** Diff output cap (§3.3): past this the diff is cut at 1 MB and `truncated: true`. */ export declare const DIFF_OUTPUT_CAP_BYTES: number; /** `GET /runs/:id/files` 200 body (published as `RunFileContent` in wicked-crew-api-types). */ export interface CappedFileRead { content: string; size: number; truncated: boolean; binary: boolean; } /** The target exists but is not a regular file (directory, socket, …) — the route's 400, distinct * from ENOENT's 404. Serving directory listings is explicitly out of scope (§3.3). */ export declare class NotARegularFileError extends Error { readonly path: string; constructor(path: string, detail?: string); } /** Options for a NO-FOLLOW capped read (the skills store; design v3.5 §3). */ export interface CappedReadOptions { /** Open with `O_NOFOLLOW` where the platform has it: a symlink at the leaf fails the open (ELOOP → `NotARegularFileError`). */ noFollow?: boolean; /** The dev/ino the caller's lstat walk saw: the opened file must be that very entry (the Windows close of the lstat-then-open gap, applied everywhere). */ identity?: { dev: number; ino: number; }; } /** * Read at most `FILE_CONTENT_CAP_BYTES` of `target`. The open-then-fstat order (not stat-then-open) * closes the classic swap race: the size and the bytes come from the SAME open file description. * Callers must have contained `target` already — this function does filesystem work only. */ export declare function readFileCapped(target: string, opts?: CappedReadOptions): Promise; /** `GET /runs/:id/diff` 200 body (published as `RunDiff` in wicked-crew-api-types). */ export interface WorktreeDiff { diff: string; truncated: boolean; /** * Where the diff was read from (wave 6, F-7R2-013; api-types 0.36.0): `worktree` — the live run * worktree (staged + unstaged + untracked, the pre-0.36 answer); `branch` — the run's retained * `wicked/` branch in the REGISTERED repo, diffed against its base, served when the engine * has reaped the worktree (a completed run) so the files view never goes dark at completion. * Absent on a pre-0.36 daemon (which answered 409 for a reaped worktree). */ source?: 'worktree' | 'branch'; /** `source: 'branch'` — the run branch the diff was read from. */ branch?: string; /** `source: 'branch'` — the base commit the branch was diffed against (the engine's recorded * `base_commit` when it has one, else the branch's merge-base with the default branch). */ base?: string; } /** * The BRANCH-sourced diff (wave 6, F-7R2-013): `git diff ` over the REGISTERED repo * root — read-only plumbing, argv array (never a shell string), `GIT_OPTIONAL_LOCKS=0` (this root is * the repo an operator or a deliver may be writing in right now). Used when the run worktree is * gone: the engine keeps the `wicked/` branch (and, since wave 6, records `run_branch` + * `base_commit` on the session), so the run's work stays diffable after the reap. * * `base`: the recorded base commit when the caller has one; else the branch's merge-base with the * repo's default branch (`origin/HEAD` → `origin/main` → `origin/master` → local `main`/`master`). * Returns `null` when the branch does not exist in the repo (nothing was ever committed for the run * — the caller's 409 stands). Throws `UnresolvableDiffBaseError` when no base can be derived. */ export declare function branchDiff(repoRoot: string, branch: string, base: string | null, relPath?: string): Promise; /** How long the untracked-file pass may run before the answer is cut (`truncated: true`, crew#790). */ export declare const UNTRACKED_BUDGET_MS = 8000; /** * A git the DAEMON stopped before it answered — execFile's `timeout` fired and Node killed the child * (`killed: true`). Not the caller's fault and not a broken repo, so the route answers 503 * `diff_busy` and a client retries instead of reading a bare 500 (crew#790). Only that: a git that * died of its own signal (SIGSEGV, SIGABRT, a crashed diff driver) is a real fault and stays a 500 * — telling a client to retry a deterministic crash would hide it (codex on #795). */ export declare function isGitStopped(err: unknown): boolean; /** `?base=merge-base` — the one non-ref literal: diff against `git merge-base * HEAD`, i.e. the run branch's fork point, so committed run work is visible (§8.1). */ export declare const MERGE_BASE_LITERAL = "merge-base"; /** `base` is not a plain ref — a flag, a path, a revision range, a separator. Rejected BEFORE any * git process sees it: the query parameter is a diff baseline, never a command surface (§8.1). */ export declare class InvalidDiffBaseError extends Error { readonly base: string; constructor(base: string); } /** `base` is well-formed but does not resolve to a commit inside the run's repo — containment: * a ref from another repo (or thin air) is a 400, never a git error surfaced as a 500. */ export declare class UnresolvableDiffBaseError extends Error { readonly base: string; constructor(base: string, detail: string); } export declare function isPlainRef(base: string): boolean; /** * The run's worktree diff against `base` (default HEAD) — staged + unstaged in one answer — with * untracked files appended as `git diff --no-index /dev/null ` all-addition hunks (§3.3: a * run's *created* files must diff as additions rather than vanish). `relPath`, when given, narrows * both passes to that one file; it is always a single argv element after `--` (the open-path rule * — no shell string is ever composed). The literal `/dev/null` is git's own cross-platform * null-device spelling (git special-cases it, including on Windows). * * `base` (CREW-UX-1, DES-UX-001 §8.1): the literal `merge-base` diffs from the run branch's fork * point off the default branch — committed run work becomes visible; a plain ref diffs from that * ref, resolved inside this repo first (`resolveDiffBase` — the raw parameter never reaches * `git diff`). Throws `InvalidDiffBaseError` / `UnresolvableDiffBaseError` for the route's 400s. */ export declare function worktreeDiff(workdir: string, relPath?: string, base?: string, opts?: { budgetMs?: number; }): Promise; //# sourceMappingURL=run-files.d.ts.map