@vite-hub/presets 0.1.0 → 0.4.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 +171 -35
- package/dist/babysitter/server.d.ts +59 -6
- package/dist/babysitter/server.js +2 -2
- package/dist/babysitter-DQeA81N0.js +2541 -0
- package/dist/babysitter.d.ts +200 -18
- package/dist/babysitter.js +2 -2
- package/dist/error-diagnostics-o3pHscWs.js +729 -0
- package/dist/host-DH0o7xSq.js +695 -0
- package/dist/labeller.d.ts +47 -3
- package/dist/labeller.js +115 -33
- package/dist/{admission-DBJdt-CX.d.ts → pr-workspaces-CMdQ9U15.d.ts} +375 -88
- package/dist/server-ILDJE5V7.js +12254 -0
- package/dist/workspace.js +2 -5
- package/package.json +17 -18
- package/dist/babysitter-B4D1zeYf.js +0 -715
- package/dist/host-CH0L3VC9.js +0 -438
- package/dist/server-DDmyZ98B.js +0 -6745
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @vite-hub/presets
|
|
2
2
|
|
|
3
|
-
[](https://npmx.dev/package/@vite-hub/presets)
|
|
4
|
+
[](https://npmx.dev/package/@vite-hub/presets)
|
|
5
|
+
[](https://github.com/vite-hub/vitehub/blob/main/LICENSE)
|
|
6
|
+
[](https://vitehub.dev/docs)
|
|
7
7
|
|
|
8
8
|
`@vite-hub/presets` contains ready-made Agents that are built from ViteHub
|
|
9
9
|
primitives. Each preset is a subpath. The package depends on
|
|
10
10
|
[`@vite-hub/agent`](../agent/README.md); the Agent package does not know these presets.
|
|
11
11
|
|
|
12
|
-
Most applications use the `vite-hub/presets/*` imports of the `vite-hub` framework distribution.
|
|
12
|
+
Most applications use the `vite-hub/presets/*` imports of the `vite-hub` framework distribution. User docs: [Agent presets](https://vitehub.dev/docs/presets).
|
|
13
13
|
|
|
14
14
|
| Import | Preset |
|
|
15
15
|
| --- | --- |
|
|
@@ -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
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
|
@@ -36,7 +35,7 @@ Most applications use the `vite-hub/presets/*` imports of the `vite-hub` framewo
|
|
|
36
35
|
import { labeller } from "@vite-hub/presets/labeller"
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
See the [Labeller docs](https://vitehub.dev/docs/
|
|
38
|
+
See the [Labeller docs](https://vitehub.dev/docs/presets/labeller).
|
|
40
39
|
|
|
41
40
|
## Workspace preset
|
|
42
41
|
|
|
@@ -44,7 +43,7 @@ See the [Labeller docs](https://vitehub.dev/docs/agents/labeller).
|
|
|
44
43
|
import workspace from "@vite-hub/presets/workspace"
|
|
45
44
|
```
|
|
46
45
|
|
|
47
|
-
See the [workspace preset docs](https://vitehub.dev/docs/
|
|
46
|
+
See the [workspace preset docs](https://vitehub.dev/docs/presets/workspace).
|
|
48
47
|
|
|
49
48
|
## Babysitter
|
|
50
49
|
|
|
@@ -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
|
-
|
|
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 `
|
|
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"`,
|
|
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,61 @@ 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. GitHub refuses App pushes to a fork,
|
|
163
|
+
so a fork PR whose base changed its files, or that needs a retest on the current
|
|
164
|
+
base, is closed and reopened instead, at most hourly. Its `pull_request` workflows
|
|
165
|
+
then run again on the merge with the current base. GitHub lists no pull request on
|
|
166
|
+
a fork's Actions runs, so the host matches the workflow run to the fork branch and
|
|
167
|
+
head, then uses base branch activity before the run was created. Push runs do not
|
|
168
|
+
count. The host records the close first and recovers an interrupted reopen only
|
|
169
|
+
when its own GitHub identity closed the PR.
|
|
170
|
+
|
|
171
|
+
PRs whose head branch starts with `mainRepairBranchPrefix` still get a repair pass when their failure repeats the base.
|
|
172
|
+
|
|
173
|
+
Before a model pass, the host compares the logs of failing GitHub Actions jobs
|
|
174
|
+
with the same jobs on the base branch tip. A failing required check whose step
|
|
175
|
+
fails there too, and whose output names no failure the base lacks, is the
|
|
176
|
+
base's failure. When every failing required check is the base's, or stopped on a
|
|
177
|
+
runner or network error, the PR waits without a pass, retries every 15 minutes,
|
|
178
|
+
and is retested once the base passes; a runner or network error gets one branch
|
|
179
|
+
update. `bypassInheritedChecks` (off by default), such as
|
|
180
|
+
`{ "acme/app": ["ci"] }`, lets the host merge past those required checks. It
|
|
181
|
+
rereads the checks, the base tip, branch protection, rulesets, reviews and
|
|
182
|
+
threads first, and refuses when any other rule is unknown or unmet. The merge
|
|
183
|
+
sets GitHub's `bypass_rules`, so the GitHub App must be allowed to bypass the
|
|
184
|
+
branch rules. A required check that never reported, 10 minutes after the head's
|
|
185
|
+
checks finished, gets a branch update or an Actions rerun once per head every
|
|
186
|
+
six hours.
|
|
187
|
+
|
|
188
|
+
`forkHeadBranches` (off by default), such as
|
|
189
|
+
`{ "acme/app": "preview/pr-{number}" }`, is for required checks that run only on
|
|
190
|
+
pushes to the repository, like pkg.pr.new. Such a check never reports on a fork
|
|
191
|
+
PR's head. When it is missing, the host pushes the head to that branch, once per
|
|
192
|
+
head. A push runs the workflow files of the pushed commit with the repository's
|
|
193
|
+
permissions, so the host first rereads GitHub and pushes only when a reviewer with
|
|
194
|
+
write access approved that exact head, no change request stands, and any local
|
|
195
|
+
action, reusable workflow, or workflow triggered by pushing or creating that
|
|
196
|
+
branch still matches the live base. It moves and deletes only a
|
|
197
|
+
branch it created, and deletes it once the PR closes.
|
|
198
|
+
|
|
199
|
+
`markDraftsReady` lists GitHub logins, such as maintainers and their bots, whose
|
|
200
|
+
drafts should merge. Off by default. When a pass has reviewed a draft's head, no
|
|
201
|
+
required check failed, and the head branch is in the repository itself, the host
|
|
202
|
+
marks the draft ready for review. The `ready_for_review` event wakes the PR and
|
|
203
|
+
starts workflows that skip drafts. A fork's draft and an unlisted author's draft
|
|
204
|
+
stay drafts.
|
|
137
205
|
|
|
138
206
|
After a repair push, the pass may continue for 3 minutes, then ends. The PR
|
|
139
207
|
waits on the pushed head. Later events on a waiting PR start a pass only when
|
|
@@ -146,12 +214,17 @@ a PR waiting while they run. A comment-only review with an empty body does not
|
|
|
146
214
|
wake a waiting PR; its inline comments do. `noFindingsReviews` lists body
|
|
147
215
|
prefixes, such as `"> ✅ No new issues found."`, of comment-only reviews that
|
|
148
216
|
report no findings; these do not wake it either. `ignoreFeedbackAuthors` lists
|
|
149
|
-
logins
|
|
150
|
-
|
|
217
|
+
logins whose comments and reviews never need an assessment. It defaults to the
|
|
218
|
+
deployment preview bots `pkg-pr-new[bot]`, `vercel[bot]`,
|
|
219
|
+
`cloudflare-workers-and-pages[bot]` and `netlify[bot]`; a list replaces them, and
|
|
220
|
+
`[...babysitter.options.ignoreFeedbackAuthors, "review-bot[bot]"]` extends them. Feedback that a pass assessed or answered with a repair push stays
|
|
151
221
|
assessed on later heads, so a direct merge needs a model pass only for new
|
|
152
222
|
feedback. Bot issue comments count by identity, not body. Without required
|
|
153
223
|
checks on the base branch, the newest run of every current-head check must
|
|
154
|
-
finish before a merge
|
|
224
|
+
finish before a merge, and a failing GitHub Actions check outside
|
|
225
|
+
`reviewChecks` blocks it. A cancelled run does not replace a finished run of the
|
|
226
|
+
same check. A pass that assessed the current head and all its feedback lets
|
|
227
|
+
failing `reviewChecks` alone merge.
|
|
155
228
|
|
|
156
229
|
`deferWhilePending` (default `true`) holds a pass while required checks or
|
|
157
230
|
review checks run, unless a failure or conflict already needs repair; the PR
|
|
@@ -162,13 +235,27 @@ disables it) counts review-driven pushes on a PR: pushes from a pass without a
|
|
|
162
235
|
merge conflict and without a failing check outside `reviewChecks`. After that
|
|
163
236
|
many, bot feedback and failed `reviewChecks` no longer wake a model pass. A
|
|
164
237
|
person's feedback, another failing check, a conflict or a head that someone else
|
|
165
|
-
pushed still do
|
|
166
|
-
|
|
238
|
+
pushed still do, and so does a bot finding that its reviewer labeled P0 or P1,
|
|
239
|
+
until the PR made twice that many review-driven pushes. A worker never declines
|
|
240
|
+
a P0 or P1, and when it declines a finding its reviewer labeled P0 or P1, the
|
|
241
|
+
thread stays open and the PR waits for a person. The PR then merges on its required checks or parks with the
|
|
242
|
+
reason, which health lists under `queue.parked`. `minorReviewRounds` (default
|
|
243
|
+
`false`) spends that budget once that many heads in a row had no automated
|
|
244
|
+
finding above P2; each pass reports the class in `automatedReview`.
|
|
245
|
+
`reviewConvergencePushes` (default `false`) asks each pass from that many
|
|
246
|
+
review-driven pushes on to fix a recurring finding class at its root.
|
|
247
|
+
`ignoreAssessedBotThreads` (default `false`) stops assessed bot-only review
|
|
248
|
+
threads from blocking a direct merge or waking the PR. `dailyPassBudget` (default
|
|
167
249
|
`16`, `false` disables it) limits the model passes per PR in a rolling 24
|
|
168
250
|
hours. A PR that reached it parks until its oldest pass is 24 hours old, and
|
|
169
251
|
health lists it with `resumeAt`. A person's new feedback, the first failing
|
|
170
|
-
required check on a head
|
|
171
|
-
pass. `
|
|
252
|
+
required check on a head, any conflict and a head whose required checks pass
|
|
253
|
+
still start a pass. `dailyPushBudget` (default `false`) limits repair pushes per
|
|
254
|
+
PR in a rolling 24 hours; past it, only a conflict repair pushes, and a PR whose
|
|
255
|
+
required checks fail pushes once every two hours. `priorityLabels` (default none)
|
|
256
|
+
put a labelled PR first in the queue and exempt it from both daily budgets.
|
|
257
|
+
`mainRepairBranchPrefix` (default none) puts PRs from those head branches before
|
|
258
|
+
every other PR and exempts them from `noProgressBudget`. `install` (default `true`) installs
|
|
172
259
|
dependencies on the host before the model starts: it detects pnpm, npm or
|
|
173
260
|
Yarn from the lockfile and installs frozen, or runs `{ command, args }`. The
|
|
174
261
|
install gets a scrubbed environment and records its result and timing in
|
|
@@ -183,10 +270,16 @@ disable lifecycle and build scripts; custom commands are trusted host configurat
|
|
|
183
270
|
`install: { cache: { directory, entries } }` configures the cache on any filesystem, and
|
|
184
271
|
`cache: false` disables it. At startup, the built-in host removes pass
|
|
185
272
|
workspaces from an earlier process when its temporary directory is inside the
|
|
186
|
-
service directory. Claims take
|
|
187
|
-
passed, then stack parents. A restart releases the claims of the previous process.
|
|
188
|
-
|
|
189
|
-
|
|
273
|
+
service directory. Claims take main repairs and priority-labelled PRs first, then reviewed heads,
|
|
274
|
+
then heads whose checks all passed, then stack parents. A restart releases the claims of the previous process.
|
|
275
|
+
With `merge.foldStacks` (default `true`), a ready stacked PR whose base is the
|
|
276
|
+
branch of one open PR in the same repository merges into that branch with a merge
|
|
277
|
+
commit, so the stack lands with its parent, and the host emits `babysitter.stack.folded`.
|
|
278
|
+
A fold and the parent's own merge never run at the same time. Other stacked PRs
|
|
279
|
+
wait: a stacked PR whose parent merged into the default branch is retargeted to the
|
|
280
|
+
default branch. With `merge: "direct"`, `repairStackChildren: true` (default `false`)
|
|
281
|
+
repairs a child's checks, conflicts and feedback alongside its open parent, and the
|
|
282
|
+
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
283
|
dispatch waits for `providerCooldownMs` (five minutes by default), doubling per
|
|
191
284
|
consecutive cooldown up to an hour. The pass waits for the cooldown instead of
|
|
192
285
|
failing and spends no no-progress budget. `modelConcurrency` caps model passes.
|
|
@@ -194,6 +287,18 @@ Each owner rechecks the durable deadline before dispatch, including after
|
|
|
194
287
|
workspace setup. Host merges and stack retargets continue during the cooldown.
|
|
195
288
|
A failed dependency install continues the pass without dependencies unless
|
|
196
289
|
`install.required` is set; `install.concurrency` sets the install slots.
|
|
290
|
+
`warmWorkspaces` (default `false`) keeps one workspace per open PR in
|
|
291
|
+
`<dataDir>/pr-workspaces`. A pass on the head the previous pass pushed or left,
|
|
292
|
+
after a pass that finished, on a clean tree, keeps `node_modules` and build
|
|
293
|
+
caches and skips a current install; any other pass empties the workspace and
|
|
294
|
+
checks the head out again. The host clone is fetched instead of cloned. Entries
|
|
295
|
+
go when the PR closes, after `idleDays` (7) without a pass, and least recently
|
|
296
|
+
used first above `budgetGb` (60) or below `minFreePercent` (15) free disk.
|
|
297
|
+
`warmWorkspaces: { resumeThreads: true }` also continues the previous pass's
|
|
298
|
+
provider thread when that pass pushed or recorded a wait on the same base and
|
|
299
|
+
release. The host stores only that session in `provider-sessions.sqlite`: it
|
|
300
|
+
deletes the session of every pass that cannot be resumed, and the last one when
|
|
301
|
+
the PR's workspace goes. Without `resumeThreads`, it stores no provider session.
|
|
197
302
|
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
303
|
|
|
199
304
|
Colocated `instructions.md` fills the preset's instruction slot without adding
|
|
@@ -203,10 +308,14 @@ headings. Explicit `driver.instructions` replaces that slot. Use
|
|
|
203
308
|
A discovered Agent that imports the preset runs without more wiring on the Node
|
|
204
309
|
server preset. ViteHub generates a Nitro plugin that starts a process host for
|
|
205
310
|
it: a SQLite PR inbox in Agent State, bounded GitHub discovery of
|
|
206
|
-
`filter.repository.allow
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
311
|
+
`filter.repository.allow` (or, without it, of every repository the GitHub App
|
|
312
|
+
installations can access, except archived ones and `filter.repository.deny`),
|
|
313
|
+
claims, repair passes, and wake handling. Installing the App on a repository
|
|
314
|
+
enrolls it; `installation` and `installation_repositories` webhooks update the
|
|
315
|
+
list at once, and the host lists the installations again every 10 minutes. Signed
|
|
316
|
+
GitHub deliveries to `/_vitehub/agents/<name>/webhooks/github` feed the
|
|
317
|
+
inbox; they never start the Agent directly. `GET /_vitehub/host/drain`
|
|
318
|
+
reports drain status, and `GET /_vitehub/host/health` reports each host's
|
|
210
319
|
health and queue. SIGUSR2 starts a drain. The build fails with `AGENT_B0022` on
|
|
211
320
|
hosts that cannot keep a process running, and with `AGENT_B0023` without SQL
|
|
212
321
|
Agent State. Hosts start in production builds, or in development only with
|
|
@@ -218,8 +327,8 @@ The host reads the GitHub App from `env.server.github` or `VITEHUB_GITHUB_APP_ID
|
|
|
218
327
|
`VITEHUB_GITHUB_WEBHOOK_SECRET`. It resolves the App installation of each repository and
|
|
219
328
|
commits as the App's bot. `VITEHUB_GITHUB_INSTALLATION_ID` pins the installation for
|
|
220
329
|
`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.
|
|
222
|
-
|
|
330
|
+
names to installation IDs. Other owners resolve their own installation. An
|
|
331
|
+
installation ID without an owner fails at startup with `FORGE_INVALID_ENV`.
|
|
223
332
|
A delivery without a configured webhook secret is rejected. Only the commit
|
|
224
333
|
author and committer identity pass to the worker; credentials do not. On its
|
|
225
334
|
first start, the host imports `.vitehub/pull-request-inbox.sqlite` from an
|
|
@@ -283,6 +392,11 @@ has no merge tool and the host rejects auto-merge operations. With `"auto"`, it
|
|
|
283
392
|
requests GitHub native auto-merge subject to current PR admission and repository
|
|
284
393
|
checks and reviews. Workers never merge directly or delete branches.
|
|
285
394
|
|
|
395
|
+
CI logs reach the worker without color codes or fetch branch listings, capped at
|
|
396
|
+
the last 4 MB of each failed job. Preloaded evidence and `readCheckLogs` return a
|
|
397
|
+
failure-focused excerpt; `readCheckLogs` also takes `tailLines` or
|
|
398
|
+
`startLine`/`endLine` for up to 1,000 lines the excerpt omitted.
|
|
399
|
+
|
|
286
400
|
Before a repair push, the host durably associates the exact candidate commit with
|
|
287
401
|
its active claim. Check and status webhooks for that commit are retained even when
|
|
288
402
|
they arrive before the source-push and synchronize webhooks. This association does
|
|
@@ -295,3 +409,25 @@ CI evidence. Later pending candidates and separately verified push receipts rema
|
|
|
295
409
|
A pass can resolve several addressed review threads without cancelling itself
|
|
296
410
|
when its own resolution webhooks arrive. New comments and external thread reopens
|
|
297
411
|
still revoke further repair operations.
|
|
412
|
+
|
|
413
|
+
## Babysitter GitHub host
|
|
414
|
+
|
|
415
|
+
`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:
|
|
416
|
+
|
|
417
|
+
```ts fragment
|
|
418
|
+
await github.withPullRequestCheckout(pullRequest, async ({ env, path, push, signal }) => {
|
|
419
|
+
await runAgent({ cwd: path, env, signal })
|
|
420
|
+
await push()
|
|
421
|
+
}, { signal: invocation.abortSignal, timeout: 60_000 })
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
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.
|
|
425
|
+
|
|
426
|
+
`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.
|
|
427
|
+
|
|
428
|
+
`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.
|
|
429
|
+
A provider `env` resolver can call `host.environment()` inside
|
|
430
|
+
`withPullRequestCheckout()`. The environment binds to that callback's checkout,
|
|
431
|
+
including concurrent callbacks. Await the entire agent run before returning.
|
|
432
|
+
Use `defineAgent({ extends: agent, name, workspace })` to bind the workspace
|
|
433
|
+
without rebuilding driver configuration.
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import {
|
|
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-CMdQ9U15.js";
|
|
2
2
|
import { AgentInput } from "@vite-hub/agent";
|
|
3
|
-
import {
|
|
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(signal?: AbortSignal): 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
|
-
|
|
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;
|
|
@@ -29,18 +50,50 @@ export interface BabysitterRuntimeOptions {
|
|
|
29
50
|
providerRetryDelayMs?: number;
|
|
30
51
|
/** Delay between live reads while GitHub computes mergeability before a direct merge. Defaults to 3 seconds. */
|
|
31
52
|
mergeabilityRetryDelayMs?: number;
|
|
32
|
-
admission?: () => Promise<Pick<BabysitterAdmissionResult, "accepting" | "hostOnly" | "reason" | "retryAt" | "detail">>;
|
|
53
|
+
admission?: (signal?: AbortSignal) => 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;
|
|
68
|
+
/**
|
|
69
|
+
* How long one reconcile may wait before the runtime reports `babysitter.reconcile.stalled` and stops
|
|
70
|
+
* it, so the next reconcile can claim work. Defaults to 15 minutes.
|
|
71
|
+
*/
|
|
72
|
+
stallMs?: number;
|
|
33
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* GitHub settles most asynchronous merges in seconds, so poll a pending request less often as it ages:
|
|
76
|
+
* after 30 seconds at first, then after as long as it has been pending, at most every five minutes.
|
|
77
|
+
* A fixed 30-second poll can run for hours on a request that GitHub never settles.
|
|
78
|
+
*/
|
|
79
|
+
export declare function pendingMergeRetryAt(startedAt: number, now: number): number;
|
|
34
80
|
/** Provider quota and rate-limit failures. Cancellation is never a rate limit. */
|
|
35
81
|
export declare function isProviderRateLimit(error: unknown): boolean;
|
|
36
82
|
/** Own one durable PR inbox and its repair passes inside a process host. */
|
|
37
83
|
export interface BabysitterRuntime {
|
|
38
84
|
inbox: PullRequestInbox;
|
|
85
|
+
/** The repositories this runtime discovers and serves. */
|
|
86
|
+
repositories: BabysitterRepositories;
|
|
39
87
|
reconcile(reason: string, context: ProcessReconcilerRunContext, accepting?: () => boolean): Promise<void>;
|
|
40
88
|
workload(): {
|
|
41
89
|
running: number;
|
|
42
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Makes the next reconcile check the default branch of the delivery's repository when the delivery
|
|
93
|
+
* is a failed push run of a watched workflow there. Returns whether it did.
|
|
94
|
+
*/
|
|
95
|
+
observeMainRepair(event: string, payload: unknown): Promise<boolean>;
|
|
43
96
|
}
|
|
44
97
|
export declare function createBabysitterRuntime(options: BabysitterRuntimeOptions): BabysitterRuntime;
|
|
45
98
|
//#endregion
|
|
46
|
-
export type
|
|
99
|
+
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-
|
|
2
|
-
export { createBabysitterRuntime, isProviderRateLimit };
|
|
1
|
+
import { c as createGitHubHost, n as isProviderRateLimit, r as pendingMergeRetryAt, s as createGitHubAppCredentials, t as createBabysitterRuntime } from "../server-ILDJE5V7.js";
|
|
2
|
+
export { createBabysitterRuntime, createGitHubAppCredentials, createGitHubHost, isProviderRateLimit, pendingMergeRetryAt };
|