import { l as MaintainNotifyConfig, m as AgentprotoConfig, a as MaintainConfig } from './config-Bvuv9HOv.js'; import { WorkspaceEntry } from './workspaces-config.js'; import './spawn-defaults-B0Yi8_MN.js'; import '@agentproto/acp'; import '@agentproto/command-sandbox'; import '@agentproto/policy'; import '@agentproto/sandbox'; import 'zod'; import '@agentproto/model-catalog'; import '@agentproto/auth'; import '@agentproto/delivery'; import '@agentproto/reach'; import '@agentproto/sentinel'; import '@agentproto/cloud-agent'; /** * Repo resolution for repo maintenance, shared by `agentproto maintain --all` * (CLI) and the daemon's `maintain_run` tool: one source of truth for WHICH * repos a maintenance pass covers and for the run defaults read from the * user config's `maintain` section (`~/.agentproto/config.json`). * * Lives in `@agentproto/runtime` because the config schema and `loadConfig` * live here: the CLI already imports `@agentproto/runtime/config`, and the * daemon tool needs it in-process. The module itself is light, Node built-ins * plus the config schema, no daemon machinery; it is exported on its own * subpath (`@agentproto/runtime/maintain-repos`) so the CLI does not load the * runtime's root entry for it. * * Discovery: the worktrees root is laid out `//`, every * `` a linked git worktree whose `.git` is a FILE * (`gitdir:
/.git/worktrees/`). Reading that pointer is the whole * fact needed, no `git` spawn: a dir with no `.git`, or a `.git` DIRECTORY (a * main checkout dropped inside the root), is skipped, not guessed at. */ /** * Normalise a list of extra worktrees roots (from `worktrees.extraRoots` and * `--worktrees-root`): `~/` expands, everything resolves to an absolute path, * blanks are dropped and duplicates collapse, first occurrence wins. */ declare function normalizeExtraRoots(raw: readonly string[] | undefined, home?: string): string[]; /** * The configured worktrees root, same order as the CLI's * `resolveWorktreesRoot`: `AGENTPROTO_WORKTREES_ROOT` env > config * `worktrees.root` > `~/.agentproto/worktrees`. */ declare function configuredWorktreesRoot(config: AgentprotoConfig | undefined, opts?: { env?: NodeJS.ProcessEnv; home?: string; }): string; /** * Discover the main repos behind every worktree under `root`: * for each `//` whose `.git` is a FILE, read * `gitdir:
/.git/worktrees/` and take `
`. Deduped, * realpath'd, sorted for stable output. A missing/unreadable `root` yields * an empty list, not an error. */ declare function discoverWorktreeOwningRepos(root: string): Promise; /** * The main repo root of a linked worktree directory, or `null` when this * directory isn't one: no `.git`, a `.git` DIRECTORY (a main checkout, not * a linked worktree), or an unparseable/unresolvable `gitdir:` pointer. */ declare function mainRepoOfWorktree(worktreePath: string): Promise; /** * Every discovered main repo under the given roots, plus explicit repo roots * (already resolved to main toplevels by the caller), deduped by realpath: * discovery first (sorted), then explicit ones in the order given. */ declare function resolveAllRepos(root: string | readonly string[], explicitRepos?: readonly string[]): Promise; /** * The MAIN repo root of any dir inside a git repo (a linked worktree maps to * its main checkout, the root maintain works on), or `null` outside one. * `--path-format=absolute` keeps `--git-common-dir` absolute even from the * main worktree itself. */ declare function mainRepoRootOf(dir: string): string | null; /** `git rev-parse --show-toplevel` of `dir` (realpath'd), or `null` outside * a repo. A registered workspace counts as a repo only when this equals its * own path: a subdir of a repo is not a repo. */ declare function gitToplevelOf(dir: string): string | null; /** * The config's `maintain` section, validated with the same schema * `config_set` uses. `loadConfig` itself does not validate, so a hand-edited * typo surfaces here, loudly, instead of silently maintaining the wrong set. */ declare function readMaintainConfig(config: AgentprotoConfig | undefined): MaintainConfig; interface ResolveMaintainReposExtra { /** The registered workspaces; default: read `/.agentproto/workspaces.json`. */ workspaces?: readonly WorkspaceEntry[]; /** Dir -> its git toplevel; default {@link gitToplevelOf}. */ resolveToplevel?: (dir: string) => string | null; /** Worktrees root to scan; default {@link configuredWorktreesRoot}. */ worktreesRoot?: string; /** Extra roots to scan on top of config `worktrees.extraRoots` * (the CLI's `--worktrees-root`). Scanned even with `discover: false`: * naming a root is an explicit ask. */ extraRoots?: readonly string[]; /** Explicitly requested repos (CLI `--repo`, tool `repos`): any dir in a * repo, added on top and NOT filtered by `maintain.exclude`. */ repos?: readonly string[]; /** Dir -> main repo root; default {@link mainRepoRootOf}. */ resolveRepoRoot?: (dir: string) => string | null; env?: NodeJS.ProcessEnv; home?: string; } interface ResolvedMaintainRepos { /** Repos to maintain, realpath'd main roots, deduped, stable order: * registered workspaces (registry order), discovered (sorted), then * `maintain.repos`, then explicit ones. */ repos: string[]; /** Entries that could not be used, with the reason (not in a git repo). */ skipped: Array<{ path: string; source: "config" | "explicit" | "exclude" | "workspaces"; reason: string; }>; /** Repos removed by `maintain.exclude`. */ excluded: string[]; /** The roots that were scanned (empty when nothing was discovered). */ scannedRoots: string[]; } /** * The repo list of a `maintain --all` / `maintain_run {all:true}` pass: * `(maintain.workspaces !== false ? every registered workspace * (`agentproto workspace add`) without `ownerApp` whose path is a git * toplevel : none)` + `(maintain.discover !== false ? repos owning a * worktree under worktrees.root + worktrees.extraRoots : none)` + extra * scanned roots + `maintain.repos`, minus `maintain.exclude`, plus the * explicit repos. App workspaces, non-git paths and subdirs of a repo are * ignored. * Every entry is normalised to the realpath of its main repo root, so a dir * inside a repo, a worktree of it and the repo itself all name one repo. * Throws on an invalid `maintain` section (see {@link readMaintainConfig}). */ declare function resolveMaintainRepos(config: AgentprotoConfig | undefined, extra?: ResolveMaintainReposExtra): Promise; /** Per-run options a caller (CLI flags, `maintain_run` inputs) may set. */ interface MaintainRunOptions { applyMerged?: boolean; applyReviewed?: boolean; requireOperatorBelowGuard?: boolean; maxReviews?: number; reviewPreset?: string; notify?: MaintainNotifyConfig; } /** * The `maintain` workflow's `input` for one repo: the caller's options win, * then `maintain.maxReviews` / `reviewPreset` / `notify` from the config, * then the workflow's own defaults (the key is left out). */ declare function maintainWorkflowInput(repo: string, opts: MaintainRunOptions, maintain?: MaintainConfig): Record; export { type MaintainRunOptions, type ResolveMaintainReposExtra, type ResolvedMaintainRepos, configuredWorktreesRoot, discoverWorktreeOwningRepos, gitToplevelOf, mainRepoOfWorktree, mainRepoRootOf, maintainWorkflowInput, normalizeExtraRoots, readMaintainConfig, resolveAllRepos, resolveMaintainRepos };