/** * Per-agent git worktree isolation. When an agent requests `isolation: "worktree"`, * it runs in a throwaway worktree on its own branch so parallel agents can edit the * same files without conflict. Results are NOT auto-merged — the path is surfaced for * the caller to inspect. Falls back to a logged no-op when isolation isn't possible. */ /** * Synchronous precondition probe for worktree isolation: returns true when `cwd` is * inside a git repository (so `createWorktree` would ATTEMPT a real worktree add and * return `isolated: true` on success), false when it is not a git repo (the * guaranteed-fallback path, `isolated: false`). Used to fold the isolation outcome's * precondition into the resume identity (see workflow.ts) so a cached result produced * under the fallback base (run-level `options.tools` retained) cannot replay after the * repo becomes a git repo and isolation actually drops those tools. Best-effort: any * git error returns false, matching createWorktree's fallback branch. */ export declare function isGitRepoForWorktree(cwd: string): boolean; export interface Worktree { /** True when a real worktree was created; false means "ran in the shared tree". */ isolated: boolean; /** cwd the agent should run in (worktree path when isolated, else the base cwd). */ cwd: string; branch?: string; /** Repo root the worktree was added to (for teardown). */ repoRoot?: string; /** Why isolation was skipped, when isolated === false. */ reason?: string; } /** * Resolve the git repository root (toplevel) containing `baseCwd`. Returns * `undefined` when `baseCwd` is not inside a git repository. Used by the * pane-spawn path to compute the caller's subdirectory offset from the repo * root so a manager rooted at a repo subdirectory (e.g. packages/foo) runs * inside that subdir within the herdr worktree — mirroring the plain worktree * path that derives the subpath from `createWorktree`'s resolved repoRoot. */ export declare function resolveRepoRoot(baseCwd: string): Promise; /** * Create an isolated worktree under `/.pi/worktrees/` on branch * `pi/wf/`. The `name` must be deterministic (derived from runId + call index, * never wall-clock) so resume keys stay stable. Returns a no-op Worktree on any failure. */ export declare function createWorktree(baseCwd: string, name: string): Promise; /** Remove a worktree and its branch. Best-effort; safe to call on a no-op Worktree. */ export declare function removeWorktree(wt: Worktree): Promise;