@vite-hub/presets 0.1.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,15 +20,14 @@ Most applications use the `vite-hub/presets/*` imports of the `vite-hub` framewo
20
20
 
21
21
  ## Primitives that the presets use
22
22
 
23
- - `@vite-hub/agent/process-host`: `withAgentProcessHost()` attaches the Babysitter host.
23
+ - `@vite-hub/agent/process`: `withAgentProcessHost()` attaches the Babysitter host.
24
24
  The `vitehub.agent` field of this package.json tells the Vite plugin which subpaths
25
25
  attach a process host or select a provider Driver.
26
26
  - `@vite-hub/agent/channels`: `channelEnv()` and `channelEnvValue()` read the Server Env of a
27
27
  built-in Channel, and `channelMessageContextKey` reads the Channel message in `intercept`.
28
- - `@vite-hub/agent/server/github`: the GitHub host, pull request operations, dependency
29
- installation, and repair helpers.
30
- - `@vite-hub/agent/server/internal`: the Babysitter worker still reads Agent layer metadata
31
- and the active provider Sandbox through this internal entry.
28
+ - `@vite-hub/agent`: the Babysitter worker builds its Agent from the configured one with
29
+ `agentSettings()`, removes the host GitHub token with `withoutForgeAccess()`, and reaches the
30
+ provider Sandbox with `activeProviderSandbox()`.
32
31
 
33
32
  ## Labeller
34
33
 
@@ -59,8 +58,7 @@ import { defineAgent } from "@vite-hub/agent"
59
58
  import { babysitter } from "@vite-hub/presets/babysitter"
60
59
 
61
60
  export default defineAgent({
62
- preset: "babysitter",
63
- presets: { babysitter },
61
+ extends: babysitter,
64
62
  options: {
65
63
  filter: { repository: { allow: ["acme/app"] } },
66
64
  lifecycle: {
@@ -81,6 +79,22 @@ The same rules apply during discovery and to `opened`, `labeled`, and
81
79
  resume work. Use `lifecycle.labels` for lifecycle control and `filter.labels`
82
80
  for selection, rather than configuring both on one Babysitter.
83
81
 
82
+ With only `filter.repository.allow`, the Babysitter serves pull requests whose
83
+ author is an owner, member, or collaborator, skips those labelled
84
+ `babysitter:skip`, and merges ready ones directly. A direct merge holds a pull
85
+ request from someone without write access until a maintainer approves its head.
86
+ Any `filter.author` or `filter.authorAssociation` rule replaces the author
87
+ default, `lifecycle.labels` or `filter.labels` replace the label, and
88
+ `merge: false` turns merging off.
89
+
90
+ `filter.authorAssociation` selects authors by their GitHub `author_association`,
91
+ such as `{ allow: ["OWNER", "MEMBER", "COLLABORATOR"] }`. A pull request passes
92
+ when its author matches `filter.author.allow` or `filter.authorAssociation.allow`,
93
+ and a match on either deny list excludes it. Bots usually report `NONE`, so list
94
+ them in `filter.author`. Logins match without case and in either bot spelling,
95
+ so `renovate[bot]` also matches the GraphQL login `renovate`; this also applies
96
+ to `filter.actor` and `ignoreFeedbackAuthors`.
97
+
84
98
  `driver` selects the provider Driver that repairs each checkout: `"codex"` (the
85
99
  default) or `"claude-code"`. Set its model and other provider settings with the
86
100
  ordinary `driver` field. Model and custom run Drivers cannot repair a checkout.
@@ -109,7 +123,7 @@ symlink resolution. Trusted GitHub release archives use the HTTPS archive path.
109
123
  Workers call `commitRepair` with a message and explicit repair paths, then
110
124
  `pushRepair`. The host commits because the provider sandbox protects Git metadata. For a
111
125
  conflicting PR, the host first prepares a merge against the exact base commit.
112
- Installation runs after merge preparation. The worker resolves dependency conflicts and calls `refreshDependencies` before validation, then commits through the same tool. Changing dependency inputs requires another refresh and validation before committing.
126
+ Installation runs after merge preparation. The worker resolves dependency conflicts and calls `refreshDependencies` before validation, then commits through the same tool. Changing dependency inputs requires another refresh and validation before committing. `commitRepair` rejects a base merge whose result undoes changes the base made since the PR branched: lines the base added that the result lacks, or lines the base removed that it brings back. Lockfiles are exempt because the host regenerates them. When the PR deliberately replaces such a change, the worker passes the file in `baseOverrides` with a reason, and the merge commit message lists it.
113
127
  Unattended Codex runs preauthorize only the assigned host tools. Capability checks
114
128
  still run on the host, and the native shell keeps its edit sandbox.
115
129
 
@@ -118,14 +132,14 @@ records the request UUID and waits for GitHub to confirm a merge. Finished owner
118
132
  release their queue lease while preserving any unresolved merge attempt. Expired
119
133
  GitHub request results re-enter the current head's normal merge gates. An enqueued request retains its fence until the PR closes, merges, or changes head: queue absence and removal timeline commits do not identify the accepted request safely.
120
134
 
121
- `merge` defaults to `false`:
135
+ `merge` defaults to `"direct"`:
122
136
 
123
137
  | Value | Behavior |
124
138
  | --- | --- |
125
139
  | `false` | The Babysitter never merges. |
126
140
  | `"auto"` | The worker may call `requestAutoMerge`, which requests GitHub native auto-merge. |
127
141
  | `"direct"` | Before a model pass, the host squash-merges a PR that is ready. |
128
- | `{ strategy: "direct", method, ready }` | Direct merge with `"squash"`, `"merge"`, or `"rebase"`, and an optional `ready` hook. |
142
+ | `{ strategy: "direct", method, ready, trustedAuthors, markDraftsReady, bypassInheritedChecks, foldStacks }` | Direct merge with `"squash"`, `"merge"`, or `"rebase"`, an optional `ready` hook, optional trusted authors, optional draft authors, optional required checks to merge past when they only repeat the base's failure, and stack folding (default `true`). |
129
143
 
130
144
  A direct merge needs passing required checks, completed and successful
131
145
  current-head checks and statuses, loaded and resolved review threads, a
@@ -133,7 +147,43 @@ non-draft PR, and GitHub's live `mergeable_state: "clean"` on the default
133
147
  branch. The merge request pins the head SHA, so a concurrent push makes GitHub
134
148
  reject it. `ready({ repository, number, head, snapshot, requiredChecks })` can
135
149
  add a policy, such as a required approval check; return `true` or a reason. Any
136
- other result runs a normal repair pass.
150
+ other result runs a normal repair pass. `ready: "approved-if-outside"` merges a
151
+ PR from an author without write access only after a reviewer with write access
152
+ approves its current head and no such reviewer's latest review requests changes.
153
+ `trustedAuthors`, such as `["renovate[bot]"]`, lets those authors through that
154
+ gate without an approval. A bot entry needs its `[bot]` suffix and matches only a
155
+ bot account.
156
+
157
+ A PR that is only `behind` a base requiring up-to-date branches, or whose base
158
+ changed its files after its checks ran, gets a branch update instead of a merge
159
+ or a model pass. A head that already contains the base tip needs no update. When
160
+ GitHub refuses `update-branch`, as it does for some stacked PRs, the host merges
161
+ the base into a same-repository head branch through `POST /repos/{owner}/{repo}/merges`
162
+ after checking that the head did not move.
163
+
164
+ PRs whose head branch starts with `mainRepairBranchPrefix` still get a repair pass when their failure repeats the base.
165
+
166
+ Before a model pass, the host compares the logs of failing GitHub Actions jobs
167
+ with the same jobs on the base branch tip. A failing required check whose step
168
+ fails there too, and whose output names no failure the base lacks, is the
169
+ base's failure. When every failing required check is the base's, or stopped on a
170
+ runner or network error, the PR waits without a pass, retries every 15 minutes,
171
+ and is retested once the base passes; a runner or network error gets one branch
172
+ update. `bypassInheritedChecks` (off by default), such as
173
+ `{ "acme/app": ["ci"] }`, lets the host merge past those required checks. It
174
+ rereads the checks, the base tip, branch protection, rulesets, reviews and
175
+ threads first, and refuses when any other rule is unknown or unmet. The merge
176
+ sets GitHub's `bypass_rules`, so the GitHub App must be allowed to bypass the
177
+ branch rules. A required check that never reported, 10 minutes after the head's
178
+ checks finished, gets a branch update or an Actions rerun once per head every
179
+ six hours.
180
+
181
+ `markDraftsReady` lists GitHub logins, such as maintainers and their bots, whose
182
+ drafts should merge. Off by default. When a pass has reviewed a draft's head, no
183
+ required check failed, and the head branch is in the repository itself, the host
184
+ marks the draft ready for review. The `ready_for_review` event wakes the PR and
185
+ starts workflows that skip drafts. A fork's draft and an unlisted author's draft
186
+ stay drafts.
137
187
 
138
188
  After a repair push, the pass may continue for 3 minutes, then ends. The PR
139
189
  waits on the pushed head. Later events on a waiting PR start a pass only when
@@ -146,12 +196,17 @@ a PR waiting while they run. A comment-only review with an empty body does not
146
196
  wake a waiting PR; its inline comments do. `noFindingsReviews` lists body
147
197
  prefixes, such as `"> ✅ No new issues found."`, of comment-only reviews that
148
198
  report no findings; these do not wake it either. `ignoreFeedbackAuthors` lists
149
- logins, such as deployment preview bots, whose comments and reviews never need an
150
- assessment. Feedback that a pass assessed or answered with a repair push stays
199
+ logins whose comments and reviews never need an assessment. It defaults to the
200
+ deployment preview bots `pkg-pr-new[bot]`, `vercel[bot]`,
201
+ `cloudflare-workers-and-pages[bot]` and `netlify[bot]`; a list replaces them, and
202
+ `[...babysitter.options.ignoreFeedbackAuthors, "review-bot[bot]"]` extends them. Feedback that a pass assessed or answered with a repair push stays
151
203
  assessed on later heads, so a direct merge needs a model pass only for new
152
204
  feedback. Bot issue comments count by identity, not body. Without required
153
205
  checks on the base branch, the newest run of every current-head check must
154
- finish before a merge.
206
+ finish before a merge, and a failing GitHub Actions check outside
207
+ `reviewChecks` blocks it. A cancelled run does not replace a finished run of the
208
+ same check. A pass that assessed the current head and all its feedback lets
209
+ failing `reviewChecks` alone merge.
155
210
 
156
211
  `deferWhilePending` (default `true`) holds a pass while required checks or
157
212
  review checks run, unless a failure or conflict already needs repair; the PR
@@ -162,13 +217,27 @@ disables it) counts review-driven pushes on a PR: pushes from a pass without a
162
217
  merge conflict and without a failing check outside `reviewChecks`. After that
163
218
  many, bot feedback and failed `reviewChecks` no longer wake a model pass. A
164
219
  person's feedback, another failing check, a conflict or a head that someone else
165
- pushed still do. The PR then merges on its required checks or parks with the
166
- reason, which health lists under `queue.parked`. `dailyPassBudget` (default
220
+ pushed still do, and so does a bot finding that its reviewer labeled P0 or P1,
221
+ until the PR made twice that many review-driven pushes. A worker never declines
222
+ a P0 or P1, and when it declines a finding its reviewer labeled P0 or P1, the
223
+ thread stays open and the PR waits for a person. The PR then merges on its required checks or parks with the
224
+ reason, which health lists under `queue.parked`. `minorReviewRounds` (default
225
+ `false`) spends that budget once that many heads in a row had no automated
226
+ finding above P2; each pass reports the class in `automatedReview`.
227
+ `reviewConvergencePushes` (default `false`) asks each pass from that many
228
+ review-driven pushes on to fix a recurring finding class at its root.
229
+ `ignoreAssessedBotThreads` (default `false`) stops assessed bot-only review
230
+ threads from blocking a direct merge or waking the PR. `dailyPassBudget` (default
167
231
  `16`, `false` disables it) limits the model passes per PR in a rolling 24
168
232
  hours. A PR that reached it parks until its oldest pass is 24 hours old, and
169
233
  health lists it with `resumeAt`. A person's new feedback, the first failing
170
- required check on a head and a conflict on an otherwise ready PR still start a
171
- pass. `install` (default `true`) installs
234
+ required check on a head, any conflict and a head whose required checks pass
235
+ still start a pass. `dailyPushBudget` (default `false`) limits repair pushes per
236
+ PR in a rolling 24 hours; past it, only a conflict repair pushes, and a PR whose
237
+ required checks fail pushes once every two hours. `priorityLabels` (default none)
238
+ put a labelled PR first in the queue and exempt it from both daily budgets.
239
+ `mainRepairBranchPrefix` (default none) puts PRs from those head branches before
240
+ every other PR and exempts them from `noProgressBudget`. `install` (default `true`) installs
172
241
  dependencies on the host before the model starts: it detects pnpm, npm or
173
242
  Yarn from the lockfile and installs frozen, or runs `{ command, args }`. The
174
243
  install gets a scrubbed environment and records its result and timing in
@@ -183,10 +252,16 @@ disable lifecycle and build scripts; custom commands are trusted host configurat
183
252
  `install: { cache: { directory, entries } }` configures the cache on any filesystem, and
184
253
  `cache: false` disables it. At startup, the built-in host removes pass
185
254
  workspaces from an earlier process when its temporary directory is inside the
186
- service directory. Claims take reviewed heads first, then heads whose checks all
187
- passed, then stack parents. A restart releases the claims of the previous process.
188
- A stacked PR whose parent merged into the default branch is retargeted to the
189
- default branch. A provider rate limit is retried three times; after that, model
255
+ service directory. Claims take main repairs and priority-labelled PRs first, then reviewed heads,
256
+ then heads whose checks all passed, then stack parents. A restart releases the claims of the previous process.
257
+ With `merge.foldStacks` (default `true`), a ready stacked PR whose base is the
258
+ branch of one open PR in the same repository merges into that branch with a merge
259
+ commit, so the stack lands with its parent, and the host emits `babysitter.stack.folded`.
260
+ A fold and the parent's own merge never run at the same time. Other stacked PRs
261
+ wait: a stacked PR whose parent merged into the default branch is retargeted to the
262
+ default branch. With `merge: "direct"`, `repairStackChildren: true` (default `false`)
263
+ repairs a child's checks, conflicts and feedback alongside its open parent, and the
264
+ child waits for it once its reviewed head has nothing left to repair. A provider rate limit is retried `providerRetries` times (default `3`); after that, model
190
265
  dispatch waits for `providerCooldownMs` (five minutes by default), doubling per
191
266
  consecutive cooldown up to an hour. The pass waits for the cooldown instead of
192
267
  failing and spends no no-progress budget. `modelConcurrency` caps model passes.
@@ -194,6 +269,18 @@ Each owner rechecks the durable deadline before dispatch, including after
194
269
  workspace setup. Host merges and stack retargets continue during the cooldown.
195
270
  A failed dependency install continues the pass without dependencies unless
196
271
  `install.required` is set; `install.concurrency` sets the install slots.
272
+ `warmWorkspaces` (default `false`) keeps one workspace per open PR in
273
+ `<dataDir>/pr-workspaces`. A pass on the head the previous pass pushed or left,
274
+ after a pass that finished, on a clean tree, keeps `node_modules` and build
275
+ caches and skips a current install; any other pass empties the workspace and
276
+ checks the head out again. The host clone is fetched instead of cloned. Entries
277
+ go when the PR closes, after `idleDays` (7) without a pass, and least recently
278
+ used first above `budgetGb` (60) or below `minFreePercent` (15) free disk.
279
+ `warmWorkspaces: { resumeThreads: true }` also continues the previous pass's
280
+ provider thread when that pass pushed or recorded a wait on the same base and
281
+ release. The host stores only that session in `provider-sessions.sqlite`: it
282
+ deletes the session of every pass that cannot be resumed, and the last one when
283
+ the PR's workspace goes. Without `resumeThreads`, it stores no provider session.
197
284
  While the built-in resource guard pauses model passes for a spent token budget, low temporary space or exhausted proxy accounts, host work continues. A token budget of `0` stops every claim.
198
285
 
199
286
  Colocated `instructions.md` fills the preset's instruction slot without adding
@@ -203,7 +290,11 @@ headings. Explicit `driver.instructions` replaces that slot. Use
203
290
  A discovered Agent that imports the preset runs without more wiring on the Node
204
291
  server preset. ViteHub generates a Nitro plugin that starts a process host for
205
292
  it: a SQLite PR inbox in Agent State, bounded GitHub discovery of
206
- `filter.repository.allow`, claims, repair passes, and wake handling. Signed
293
+ `filter.repository.allow` (or, without it, of every repository the GitHub App
294
+ installations can access, except archived ones and `filter.repository.deny`),
295
+ claims, repair passes, and wake handling. Installing the App on a repository
296
+ enrolls it; `installation` and `installation_repositories` webhooks update the
297
+ list at once, and the host lists the installations again every 10 minutes. Signed
207
298
  GitHub deliveries to `/api/_vitehub/agents/<name>/webhooks/github` feed the
208
299
  inbox; they never start the Agent directly. `GET /api/_vitehub/host/drain`
209
300
  reports drain status, and `GET /api/_vitehub/host/health` reports each host's
@@ -218,8 +309,8 @@ The host reads the GitHub App from `env.server.github` or `VITEHUB_GITHUB_APP_ID
218
309
  `VITEHUB_GITHUB_WEBHOOK_SECRET`. It resolves the App installation of each repository and
219
310
  commits as the App's bot. `VITEHUB_GITHUB_INSTALLATION_ID` pins the installation for
220
311
  `VITEHUB_GITHUB_APP_OWNER`. `VITEHUB_GITHUB_APP_INSTALLATIONS` accepts a JSON object mapping owner
221
- names to installation IDs. Other owners resolve their own installation. The host
222
- ignores an environment installation ID without an owner.
312
+ names to installation IDs. Other owners resolve their own installation. An
313
+ installation ID without an owner fails at startup with `FORGE_INVALID_ENV`.
223
314
  A delivery without a configured webhook secret is rejected. Only the commit
224
315
  author and committer identity pass to the worker; credentials do not. On its
225
316
  first start, the host imports `.vitehub/pull-request-inbox.sqlite` from an
@@ -283,6 +374,11 @@ has no merge tool and the host rejects auto-merge operations. With `"auto"`, it
283
374
  requests GitHub native auto-merge subject to current PR admission and repository
284
375
  checks and reviews. Workers never merge directly or delete branches.
285
376
 
377
+ CI logs reach the worker without color codes or fetch branch listings, capped at
378
+ the last 4 MB of each failed job. Preloaded evidence and `readCheckLogs` return a
379
+ failure-focused excerpt; `readCheckLogs` also takes `tailLines` or
380
+ `startLine`/`endLine` for up to 1,000 lines the excerpt omitted.
381
+
286
382
  Before a repair push, the host durably associates the exact candidate commit with
287
383
  its active claim. Check and status webhooks for that commit are retained even when
288
384
  they arrive before the source-push and synchronize webhooks. This association does
@@ -295,3 +391,25 @@ CI evidence. Later pending candidates and separately verified push receipts rema
295
391
  A pass can resolve several addressed review threads without cancelling itself
296
392
  when its own resolution webhooks arrive. New comments and external thread reopens
297
393
  still revoke further repair operations.
394
+
395
+ ## Babysitter GitHub host
396
+
397
+ `createGitHubHost()` from `@vite-hub/presets/babysitter/server` is the GitHub host that `createBabysitterRuntime()` takes. Use it to resolve GitHub App or fallback credentials, call GitHub through `@vite-hub/forge`, and run against an exact pull-request head in a temporary checkout. `withPullRequestCheckout()` uses Git over HTTPS, fetches the source branch directly, verifies the requested head, and removes the checkout contents after success, failure, cancellation, or timeout. Cleanup is best effort and preserves the callback result or error if filesystem discovery or deletion fails. Cleanup retains an empty temporary directory because removing its pathname could delete a concurrent replacement. Checkout and push operations need Git but do not need the GitHub CLI. Include `headRepository` and `headRef` to make an ordinary `git push` target the pull request's source branch. The callback keeps base repository access for reads from `origin`; use its `push()` after long-running work so the host resolves fresh source repository credentials before pushing. Push checks that the repair descends from the last verified head and uses a lease to reject a changed source branch. It returns the pushed SHA and advances the lease for later pushes in the same callback. Pass the Agent Invocation's abort signal and use the callback signal for work inside the checkout:
398
+
399
+ ```ts fragment
400
+ await github.withPullRequestCheckout(pullRequest, async ({ env, path, push, signal }) => {
401
+ await runAgent({ cwd: path, env, signal })
402
+ await push()
403
+ }, { signal: invocation.abortSignal, timeout: 60_000 })
404
+ ```
405
+
406
+ For a provider that materializes a separate working directory, call `checkout.prepareWorkspace(cwd)` from the provider launch hook, then `checkout.push(cwd)` from the host after reviewing the result. The host imports the exact commit without credentials and pushes it from the original trusted clone, so provider Git configuration cannot control the authenticated push. Preparation copies the independent PR clone's Git history and push destination, removes old target metadata and saved credential/header configuration, and leaves the original clone unchanged. These helpers apply only to prepared GitHub PR checkouts; other workspace types do not receive Git metadata. Keep host credentials out of the provider environment when push authority belongs to the host.
407
+
408
+ `access()` and `forge()` accept the same `signal` and `timeout` controls. Pass them whenever the operation belongs to an Agent Invocation so credential resolution and token refresh stop on cancellation. `forge({ repository })` returns a `forges` GitHub provider with that repository's credentials, with every Forge verb and `graphql()`. Create one for each operation, because installation tokens expire after one hour. Import `forges` errors such as `RateLimitedError` from `@vite-hub/forge`, so that `instanceof` matches the bundled classes. `rateLimit()` returns the most constrained GitHub rate limit that recent Forge responses reported, or undefined before the first response. Set `timeout` on `createGitHubHost()` to change the 60-second Forge request limit. Providers from `forge()` revalidate repeated GETs with `If-None-Match`; an unchanged response comes back as a `304` that GitHub does not count against the rate limit. Entries are kept per App installation, so they outlast token rotation. Set `conditionalRequests: false` on `createGitHubHost()` to turn this off. The `credentials` callback receives the target `repository` and scoped `signal`. Select that repository's App installation in the callback and pass the signal to secret-manager or network requests. `host.channel()` also resolves credentials for each activity or delivery target repository. Unscoped `access()` calls omit `repository`, so the callback should supply its default credentials. `access({ minLifetime })` mints a new App installation token when the cached one expires within that many milliseconds. `host.channel()` passes it for Provider Driver runs. `access({ repository })` returns Git credentials for that repository only, in `GIT_CONFIG_KEY_<n>` and `GIT_CONFIG_VALUE_<n>`. An unscoped `env` has `GH_TOKEN` but no Git credentials.
409
+
410
+ `host.channel({ activity: true })` is a github() Channel whose `app.token` comes from `host.access({ repository })`. It shares the host's credentials, login, and immutable App ID, and it gives its Agent forge access. App-owned activity keeps the original managed comment across App renames and process restarts. Each publication edits that comment once; historical duplicates are left alone.
411
+ A provider `env` resolver can call `host.environment()` inside
412
+ `withPullRequestCheckout()`. The environment binds to that callback's checkout,
413
+ including concurrent callbacks. Await the entire agent run before returning.
414
+ Use `defineAgent({ extends: agent, name, workspace })` to bind the workspace
415
+ without rebuilding driver configuration.
@@ -1,7 +1,24 @@
1
- import { i as PullRequestInbox, o as PullRequestInboxStorage, r as BabysitterAdmissionResult } from "../admission-DBJdt-CX.js";
1
+ import { C as createGitHubAppCredentials, S as GitHubHostSecret, _ as GitHubHostCredentials, a as BabysitterAdmissionResult, b as GitHubHostPullRequest, c as PullRequestInboxStorage, d as GitHubHost, f as GitHubHostAccess, g as GitHubHostCredentialContext, h as GitHubHostCheckoutOptions, m as GitHubHostCheckout, n as PullRequestWorkspaces, o as PullRequestInbox, p as GitHubHostAccessOptions, u as GitHubAppEnvironment, v as GitHubHostForgeOptions, w as createGitHubHost, x as GitHubHostRateLimit, y as GitHubHostOptions } from "../pr-workspaces-CjX3PSqM.js";
2
2
  import { AgentInput } from "@vite-hub/agent";
3
- import { GitHubHost } from "@vite-hub/agent/server/github";
4
- import { ProcessReconcilerRunContext } from "@vite-hub/runtime/node";
3
+ import { GitHubAppRepository } from "@vite-hub/forge";
4
+ import { ProcessReconcilerRunContext } from "@vite-hub/runtime/internal/node";
5
+ //#region src/babysitter/repositories.d.ts
6
+ /** The repositories that one Babysitter serves, as lowercase `owner/name`. */
7
+ interface BabysitterRepositories {
8
+ /** `"allow"` for `filter.repository.allow`, `"installations"` for every repository the GitHub App can access. */
9
+ readonly source: "allow" | "installations";
10
+ /** The list without a GitHub read. */
11
+ known(): readonly string[];
12
+ /** The list, read again from the App installations when it is stale. A failed read keeps the last list and rejects. */
13
+ current(): Promise<readonly string[]>;
14
+ /**
15
+ * Notes a signed delivery. Installation events update the list and make it stale. An event from a
16
+ * repository the list does not have yet adds it, because GitHub sends only events of installed repositories.
17
+ * Returns whether the list changed.
18
+ */
19
+ observe(event: string, payload: unknown): boolean;
20
+ }
21
+ //#endregion
5
22
  //#region src/babysitter/server.d.ts
6
23
  export interface BabysitterRuntimeOptions {
7
24
  agent: AgentInput;
@@ -14,7 +31,11 @@ export interface BabysitterRuntimeOptions {
14
31
  inboxStorage?: PullRequestInboxStorage;
15
32
  /** Separates this Agent's inbox in shared storage. Defaults to the Agent name. */
16
33
  inboxScope?: string;
17
- repositories: string[];
34
+ /**
35
+ * Repositories to discover and serve: a fixed list, or a source such as every repository of the
36
+ * GitHub App installations, which each reconcile reads again.
37
+ */
38
+ repositories: readonly string[] | BabysitterRepositories;
18
39
  concurrency: number;
19
40
  /** Public Console origin. Defaults to `vitehub({ publicUrl })`. */
20
41
  publicUrl?: string;
@@ -30,17 +51,44 @@ export interface BabysitterRuntimeOptions {
30
51
  /** Delay between live reads while GitHub computes mergeability before a direct merge. Defaults to 3 seconds. */
31
52
  mergeabilityRetryDelayMs?: number;
32
53
  admission?: () => Promise<Pick<BabysitterAdmissionResult, "accepting" | "hostOnly" | "reason" | "retryAt" | "detail">>;
54
+ /**
55
+ * Samples memory and pressure for work that runs like a worker before the model starts, such as the
56
+ * merge and install of a conflicting PR. `active` counts the worker passes and preparations already
57
+ * running; a `concurrency` above it admits one more. Without it, that work is not gated.
58
+ */
59
+ hostCapacity?: (context: {
60
+ active: number;
61
+ signal: AbortSignal;
62
+ }) => Promise<{
63
+ concurrency: number;
64
+ reason?: string;
65
+ }>;
66
+ /** One kept workspace per open PR. Without it, each pass clones and installs into temporary directories. */
67
+ workspaces?: PullRequestWorkspaces;
33
68
  }
69
+ /**
70
+ * GitHub settles most asynchronous merges in seconds, so poll a pending request less often as it ages:
71
+ * after 30 seconds at first, then after as long as it has been pending, at most every five minutes.
72
+ * vite-hub/vitehub#3350 was polled every 30 seconds for 19 hours.
73
+ */
74
+ export declare function pendingMergeRetryAt(startedAt: number, now: number): number;
34
75
  /** Provider quota and rate-limit failures. Cancellation is never a rate limit. */
35
76
  export declare function isProviderRateLimit(error: unknown): boolean;
36
77
  /** Own one durable PR inbox and its repair passes inside a process host. */
37
78
  export interface BabysitterRuntime {
38
79
  inbox: PullRequestInbox;
80
+ /** The repositories this runtime discovers and serves. */
81
+ repositories: BabysitterRepositories;
39
82
  reconcile(reason: string, context: ProcessReconcilerRunContext, accepting?: () => boolean): Promise<void>;
40
83
  workload(): {
41
84
  running: number;
42
85
  };
86
+ /**
87
+ * Makes the next reconcile check the default branch of the delivery's repository when the delivery
88
+ * is a failed push run of a watched workflow there. Returns whether it did.
89
+ */
90
+ observeMainRepair(event: string, payload: unknown): Promise<boolean>;
43
91
  }
44
92
  export declare function createBabysitterRuntime(options: BabysitterRuntimeOptions): BabysitterRuntime;
45
93
  //#endregion
46
- export type { PullRequestInboxStorage };
94
+ export { type GitHubAppEnvironment, type GitHubHost, type GitHubHostAccess, type GitHubHostAccessOptions, type GitHubHostCheckout, type GitHubHostCheckoutOptions, type GitHubHostCredentialContext, type GitHubHostCredentials, type GitHubHostForgeOptions, type GitHubHostOptions, type GitHubHostPullRequest, type GitHubHostRateLimit, type GitHubHostSecret, type PullRequestInboxStorage, createGitHubAppCredentials, createGitHubHost };
@@ -1,2 +1,2 @@
1
- import { n as isProviderRateLimit, t as createBabysitterRuntime } from "../server-DDmyZ98B.js";
2
- export { createBabysitterRuntime, isProviderRateLimit };
1
+ import { n as isProviderRateLimit, o as createGitHubAppCredentials, r as pendingMergeRetryAt, s as createGitHubHost, t as createBabysitterRuntime } from "../server-CIgjUG63.js";
2
+ export { createBabysitterRuntime, createGitHubAppCredentials, createGitHubHost, isProviderRateLimit, pendingMergeRetryAt };