import type http from "node:http"; import type { CheckoutRecord } from "@kenkaiiii/gg-engine/internal/core/checkout-record.js"; import { type BranchRow } from "./git-branches.js"; /** What the branch routes need from their window session. */ export interface BranchRouteContext { /** The folder this window reads git state from. */ gitDir: () => string; /** A run, worker or autopilot turn is in progress. */ isBusy: () => boolean; /** Goal windows cannot move into a worktree: their folder is the goal's. */ canMove: () => boolean; /** This window's conversation file, so a moved window resumes it. */ sessionPath: () => string | null; /** Who else uses the checkout rooted at `root`, or null. */ sharedWith: (root: string) => Promise; worktreesRoot: string; /** The branch changed in place: update the footer and tell the agent. */ onSwitched: (branch: string, previous: string | null) => void; /** Tell the agent, once it resumes in `sessionPath`, where it moved. */ queueMoveNote: (sessionPath: string, note: string) => void; /** Remember the conversation's branch so resuming it reopens that branch. */ recordCheckout: (record: CheckoutRecord) => Promise; /** A worktree was just made: run its setup once a window opens in it. */ queueSetup: (worktreePath: string) => Promise; /** How many windows (this one included) work in the checkout rooted at `root`. */ windowsIn: (root: string) => Promise; /** Whether another window on the checkout rooted at `root` is working. */ othersBusyIn: (root: string) => Promise; /** Wait briefly for a worktree's setup to exit; true while it still runs. */ setupRunningIn: (worktreePath: string) => Promise; /** A commit message for `diff`, on the window's active model. */ writeCommitMessage: (diff: string) => Promise<{ subject: string; body: string; }>; /** The user committed, pushed or pulled from the Git panel: tell the agent. */ onShipped: (note: string) => void; /** The Git panel opened a pull request: give it a card. */ onPrOpened: (url: string) => void; } export interface BranchesResponse { current: string | null; branches: BranchRow[]; /** Other windows using this checkout; picking a branch then opens a worktree. */ sharedWith: string | null; /** Why switching is unavailable right now, or null. */ locked: string | null; /** The command a new worktree runs first, or null. */ setup: string | null; } export declare function handleBranchRoutes(ctx: BranchRouteContext, req: http.IncomingMessage, res: http.ServerResponse, url: string, method: string): boolean;