import type { ToolSpec } from "@sema-agent/core"; /** * Read-only repository tools backed by a Git host (Gitea) HTTP API — NOT a clone/shell on the runner. * * The agent reads a repo just-in-time (tree → read file → PR diff) through scoped function tools; the * read token lives only in this server-side client (never in the model/sandbox), and tools are bound * to exactly the repo the task was given. This is the lightweight path for code review (read + reason); * running tests/linters would need a sandboxed ExecutionEnv (a deliberate future extension, not here). */ export interface RepoCoords { owner: string; repo: string; } /** Parse `owner/name` or a repo URL (e.g. https://git.example.com/some-org/some-repo.git). */ export declare function parseRepo(input: string): RepoCoords; import type { GitApiKind } from "../git-api-kind.js"; export { GIT_API_KINDS, isGitApiKind, type GitApiKind } from "../git-api-kind.js"; /** The read-only surface the repo tools are built over — one implementation per Git-host dialect. */ export interface RepoReadClient { defaultBranch(coords: RepoCoords): Promise; tree(coords: RepoCoords, ref: string): Promise; readFile(coords: RepoCoords, path: string, ref: string): Promise; pullDiff(coords: RepoCoords, index: number): Promise; } export declare function createRepoClient(kind: GitApiKind, baseUrl: string, token?: string, fetchImpl?: typeof fetch): RepoReadClient; /** Thin read-only Gitea API client. Built once at startup; bound to a repo per task. */ export declare class GiteaClient implements RepoReadClient { private readonly baseUrl; private readonly token?; private readonly fetchImpl; constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch); private api; defaultBranch({ owner, repo }: RepoCoords): Promise; tree(coords: RepoCoords, ref: string): Promise; readFile(coords: RepoCoords, path: string, ref: string): Promise; pullDiff(coords: RepoCoords, index: number): Promise; } /** * Thin read-only GitHub (github.com / GHE) API client — same four-call surface as `GiteaClient`. * * Dialect differences (each one is why `GiteaClient` alone 404s against GitHub): * - base URL is the API root itself (`https://api.github.com`, GHE `https://ghe.example/api/v3`) — * no `/api/v1` prefix is appended; * - auth is `Authorization: Bearer ` (Gitea uses `token `); * - a PR's unified diff comes from `/pulls/{n}` via `Accept: application/vnd.github.v3.diff` * (Gitea uses a `.diff` URL suffix); * - the tree API has no `per_page` cap — GitHub returns up to its own limit and reports overflow via * `truncated`; we additionally cap client-side at MAX_TREE_ENTRIES so the model-facing bound is the * same for both dialects. */ export declare class GitHubClient implements RepoReadClient { private readonly baseUrl; private readonly token?; private readonly fetchImpl; constructor(baseUrl: string, token?: string | undefined, fetchImpl?: typeof fetch); private api; defaultBranch({ owner, repo }: RepoCoords): Promise; tree(coords: RepoCoords, ref: string): Promise; readFile(coords: RepoCoords, path: string, ref: string): Promise; pullDiff(coords: RepoCoords, index: number): Promise; } /** Build the read-only repo tool set bound to one repo (cheap per-task closure; the client is shared). */ export declare function repoToolsFor(client: RepoReadClient, coords: RepoCoords): ToolSpec[]; //# sourceMappingURL=repo-tools.d.ts.map