import { GitObjectStore } from './objects.js'; import type { GitRefs } from './refs.js'; export declare const ZERO_SHA: string; export declare const FLUSH: Uint8Array; export declare function pktLine(s: string | Uint8Array): Uint8Array; /** Pkt-lines up to and including the first flush; `rest` is what follows (a pack, on push). */ export declare function readPktLines(bytes: Uint8Array): { lines: string[]; rest: Uint8Array; }; /** Every pkt-line in the body across all flushes (stateless clients batch haves between flushes); `rest` follows the first flush. */ export declare function readAllPktLines(bytes: Uint8Array): { lines: string[]; rest: Uint8Array; }; export type Service = 'git-upload-pack' | 'git-receive-pack'; /** `GET info/refs?service=`: the ref advertisement, HEAD first as a symref. */ export declare function advertisement(service: Service, refs: GitRefs): Uint8Array; /** The pack of every object `wants` reach that the `haves` the store holds do not: what a push sends (a client's * send-pack, smart-http-client.ts). */ export declare function packObjects(store: GitObjectStore, wants: string[], haves: string[]): Promise; /** `POST git-upload-pack`: wants and haves in, NAK and (once `done`) the pack out. A request with `deepen ` is shallow: * its answer opens with the shallow-update section (`shallow ` for each boundary commit, `unshallow ` for a * commit the client held shallow whose parents it now receives, then a flush), and its pack stops at the boundary. */ export declare function uploadPack(body: Uint8Array, store: GitObjectStore): Promise; export type RefCommand = { old: string; new: string; name: string; /** false when `new` does not descend from `old` (a force push); true for creates, deletes and fast-forwards. */ fastForward: boolean; }; /** Bounded ancestry walk: is `ancestor` reachable from `sha` through parents? */ export declare function isAncestor(store: GitObjectStore, ancestor: string, sha: string, limit?: number): Promise; export type PushPolicy = (cmd: RefCommand) => string | null | Promise; /** `POST git-receive-pack`: commands and a pack in, refs updated under `policy`, report-status out. */ export declare function receivePack(body: Uint8Array, store: GitObjectStore, refs: GitRefs, policy?: PushPolicy): Promise<{ response: Uint8Array; applied: RefCommand[]; }>; export type GitRepo = { store: GitObjectStore; refs: GitRefs; policy?: PushPolicy; onPush?: (applied: RefCommand[]) => void | Promise; }; /** Route one request under a repo: returns null when the path is not a smart-HTTP endpoint. */ export declare function serveSmartHttp(req: Request, repo: GitRepo, tailPath: string): Promise; /** The POST half of `serveSmartHttp` for a caller that already holds the body: a push pack is * the size of the repository, so re-wrapping it in a Request only to read it back is a full copy. */ export declare function serveSmartHttpPost(body: Uint8Array, contentEncoding: string, repo: GitRepo, tailPath: 'git-upload-pack' | 'git-receive-pack'): Promise;