@vite-hub/presets 0.0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,415 @@
1
+ # @vite-hub/presets
2
+
3
+ [![npm version](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=%40vite-hub%2Fpresets&icon=npm)](https://npmx.dev/package/@vite-hub/presets)
4
+ [![npm downloads](https://comark-ui.onmax.me/badge.svg?source=npm-downloads&package=%40vite-hub%2Fpresets&period=month&icon=npm)](https://npmx.dev/package/@vite-hub/presets)
5
+ [![license](https://comark-ui.onmax.me/badge.svg?label=license&value=Apache-2.0)](https://github.com/vite-hub/vitehub/blob/main/LICENSE)
6
+ [![docs](https://comark-ui.onmax.me/badge.svg?label=docs&value=vitehub.dev)](https://vitehub.dev/docs)
7
+
8
+ `@vite-hub/presets` contains ready-made Agents that are built from ViteHub
9
+ primitives. Each preset is a subpath. The package depends on
10
+ [`@vite-hub/agent`](../agent/README.md); the Agent package does not know these presets.
11
+
12
+ Most applications use the `vite-hub/presets/*` imports of the `vite-hub` framework distribution.
13
+
14
+ | Import | Preset |
15
+ | --- | --- |
16
+ | `@vite-hub/presets/babysitter` | Repairs selected pull requests and merges them when the policy allows it. |
17
+ | `@vite-hub/presets/babysitter/server` | The Babysitter runtime for a custom process host. |
18
+ | `@vite-hub/presets/labeller` | Labels Gmail messages with ordered rules, then a constrained Jev choice. |
19
+ | `@vite-hub/presets/workspace` | Reads mounted Sources and cites files at their verified GitHub revision. |
20
+
21
+ ## Primitives that the presets use
22
+
23
+ - `@vite-hub/agent/process`: `withAgentProcessHost()` attaches the Babysitter host.
24
+ The `vitehub.agent` field of this package.json tells the Vite plugin which subpaths
25
+ attach a process host or select a provider Driver.
26
+ - `@vite-hub/agent/channels`: `channelEnv()` and `channelEnvValue()` read the Server Env of a
27
+ built-in Channel, and `channelMessageContextKey` reads the Channel message in `intercept`.
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()`.
31
+
32
+ ## Labeller
33
+
34
+ ```ts
35
+ import { labeller } from "@vite-hub/presets/labeller"
36
+ ```
37
+
38
+ See the [Labeller docs](https://vitehub.dev/docs/agents/labeller).
39
+
40
+ ## Workspace preset
41
+
42
+ ```ts
43
+ import workspace from "@vite-hub/presets/workspace"
44
+ ```
45
+
46
+ See the [workspace preset docs](https://vitehub.dev/docs/agents/workspace-preset).
47
+
48
+ ## Babysitter
49
+
50
+ Import `babysitter` from `@vite-hub/presets/babysitter`, or
51
+ `vite-hub/presets/babysitter` in an application. It repairs selected pull
52
+ requests, addresses human and bot review feedback, and parks while checks run.
53
+ Its workflow options are the GitHub Channel `filter`, lifecycle labels, the provider
54
+ `driver`, and the `merge` policy:
55
+
56
+ ```ts
57
+ import { defineAgent } from "@vite-hub/agent"
58
+ import { babysitter } from "@vite-hub/presets/babysitter"
59
+
60
+ export default defineAgent({
61
+ extends: babysitter,
62
+ options: {
63
+ filter: { repository: { allow: ["acme/app"] } },
64
+ lifecycle: {
65
+ labels: { require: ["agent:repair"], deny: ["agent:paused"] },
66
+ },
67
+ driver: "codex",
68
+ merge: false,
69
+ concurrency: 2,
70
+ },
71
+ driver: { model: "your-codex-model" },
72
+ })
73
+ ```
74
+
75
+ `lifecycle.labels.require` admits a pull request when it has at least one listed
76
+ label. `lifecycle.labels.deny` pauses it whenever any listed label is present.
77
+ The same rules apply during discovery and to `opened`, `labeled`, and
78
+ `unlabeled` webhook events, so adding or removing a label can start, stop, or
79
+ resume work. Use `lifecycle.labels` for lifecycle control and `filter.labels`
80
+ for selection, rather than configuring both on one Babysitter.
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
+
98
+ `driver` selects the provider Driver that repairs each checkout: `"codex"` (the
99
+ default) or `"claude-code"`. Set its model and other provider settings with the
100
+ ordinary `driver` field. Model and custom run Drivers cannot repair a checkout.
101
+
102
+ `install` defaults to `true`. This mode requires Git and Corepack in the trusted
103
+ host PATH. Install Corepack separately on Node 25 and newer. The package Node
104
+ engine does not install these host tools. The host installs dependencies from the
105
+ frozen pnpm, npm, or Yarn lockfile before starting the provider. Installers run one
106
+ at a time per host process to bound dependency setup memory. Lifecycle scripts and
107
+ repository package-manager hooks, plugins, and binary delegation stay disabled.
108
+ The package manager must name an official version, rather than a URL. Corepack
109
+ uses the trusted npm registry and ignores checkout environment files. npm must
110
+ be version 7 or newer. A manifest without a package-manager version uses a pinned
111
+ default rather than an ambient executable. Installation failures are recorded in
112
+ `.git/vitehub-install.json`. Invalid installation inputs park the PR until new head
113
+ or comment evidence wakes it. Host and package-manager failures retry after five
114
+ minutes. Set `install: false` for a checkout with no Node dependencies.
115
+ Dependency manifests and lockfiles are checked for local sources that escape the checkout, including encoded paths and symlinks. Project `.npmrc` and pnpm workspace configuration accept dependency declarations, peer and hoisting settings, and build allowlists. Other settings, including filesystem locations and package-manager extensions, are rejected before host installation. Supported configuration is fingerprinted so changes require a dependency refresh. npm accepts either `package-lock.json` or `npm-shrinkwrap.json`, and the boolean lockfile-shaping settings `legacy-peer-deps` and `install-links`.
116
+ Validation follows configured workspace patterns and referenced local packages; unrelated nested projects are excluded. pnpm workspaces without a root manifest use the pinned pnpm default. Executable fetch protocols such as Yarn `exec:`, Git dependencies that prepare remote projects, and unsupported source protocols are rejected before Corepack runs. Use registry packages or HTTPS archives instead, or set `install: false` when dependencies must be prepared in the provider sandbox.
117
+ Local package source files, archives, and patch files contribute their contents and executable mode to the dependency fingerprint. Local package source trees require regular files and directories; installed modules and Git metadata are excluded. Host installation reads a validated snapshot inside protected Git metadata, so provider writes cannot alter package-manager configuration or dependency sources after validation. The package-manager cache has its own CommonJS scope even in an ESM checkout. The host reconciles generated dependency outputs and rejects a refresh if the live dependency inputs changed. Workspace links continue to point to the live checkout.
118
+ Validation refreshes generated linked commands in reused input snapshots. A changed or deleted command requires a dependency refresh; tracked commands retain their commit snapshot.
119
+ Refresh reconciles all managed outputs. Switching to Yarn PnP removes obsolete root and workspace `node_modules`; switching away removes generated `.pnp.*` and Yarn cache state while preserving Yarn source configuration. Provider quota cooldowns pause model dispatch until their recorded deadline. Host merges and stack retargets continue during that cooldown.
120
+ Yarn `~/` patch selectors resolve from the project root after decoding. Other local patch selectors are rejected because Yarn can resolve them inside a parent package filesystem. Each grouped lockfile
121
+ descriptor is checked. Workspace glob matches must stay inside the checkout after
122
+ symlink resolution. Trusted GitHub release archives use the HTTPS archive path.
123
+ Workers call `commitRepair` with a message and explicit repair paths, then
124
+ `pushRepair`. The host commits because the provider sandbox protects Git metadata. For a
125
+ conflicting PR, the host first prepares a merge against the exact base commit.
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.
127
+ Unattended Codex runs preauthorize only the assigned host tools. Capability checks
128
+ still run on the host, and the native shell keeps its edit sandbox.
129
+
130
+ Direct merges use GitHub's asynchronous API, including native stacks. The inbox
131
+ records the request UUID and waits for GitHub to confirm a merge. Finished owners
132
+ release their queue lease while preserving any unresolved merge attempt. Expired
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.
134
+
135
+ `merge` defaults to `"direct"`:
136
+
137
+ | Value | Behavior |
138
+ | --- | --- |
139
+ | `false` | The Babysitter never merges. |
140
+ | `"auto"` | The worker may call `requestAutoMerge`, which requests GitHub native auto-merge. |
141
+ | `"direct"` | Before a model pass, the host squash-merges a PR that is ready. |
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`). |
143
+
144
+ A direct merge needs passing required checks, completed and successful
145
+ current-head checks and statuses, loaded and resolved review threads, a
146
+ non-draft PR, and GitHub's live `mergeable_state: "clean"` on the default
147
+ branch. The merge request pins the head SHA, so a concurrent push makes GitHub
148
+ reject it. `ready({ repository, number, head, snapshot, requiredChecks })` can
149
+ add a policy, such as a required approval check; return `true` or a reason. Any
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.
187
+
188
+ After a repair push, the pass may continue for 3 minutes, then ends. The PR
189
+ waits on the pushed head. Later events on a waiting PR start a pass only when
190
+ they need one: new human or bot feedback, a new failing check, a merge conflict,
191
+ or an unresolved review thread. Pending checks, the pushed head's synchronize
192
+ event, and repeated results for failures the pass already saw keep it waiting.
193
+ With `merge: "direct"`, passing required checks also wake it, so the host can
194
+ merge. `reviewChecks` lists check names, such as a review bot's check, that keep
195
+ a PR waiting while they run. A comment-only review with an empty body does not
196
+ wake a waiting PR; its inline comments do. `noFindingsReviews` lists body
197
+ prefixes, such as `"> ✅ No new issues found."`, of comment-only reviews that
198
+ report no findings; these do not wake it either. `ignoreFeedbackAuthors` lists
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
203
+ assessed on later heads, so a direct merge needs a model pass only for new
204
+ feedback. Bot issue comments count by identity, not body. Without required
205
+ checks on the base branch, the newest run of every current-head check must
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.
210
+
211
+ `deferWhilePending` (default `true`) holds a pass while required checks or
212
+ review checks run, unless a failure or conflict already needs repair; the PR
213
+ wakes once the gates stop. `noProgressBudget` (default `3`, `false` disables it)
214
+ stops a head after that many passes without a push or a recorded wait, until the
215
+ head changes or a person comments. `reviewPushBudget` (default `3`, `false`
216
+ disables it) counts review-driven pushes on a PR: pushes from a pass without a
217
+ merge conflict and without a failing check outside `reviewChecks`. After that
218
+ many, bot feedback and failed `reviewChecks` no longer wake a model pass. A
219
+ person's feedback, another failing check, a conflict or a head that someone else
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
231
+ `16`, `false` disables it) limits the model passes per PR in a rolling 24
232
+ hours. A PR that reached it parks until its oldest pass is 24 hours old, and
233
+ health lists it with `resumeAt`. A person's new feedback, the first failing
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
241
+ dependencies on the host before the model starts: it detects pnpm, npm or
242
+ Yarn from the lockfile and installs frozen, or runs `{ command, args }`. The
243
+ install gets a scrubbed environment and records its result and timing in
244
+ `.git/vitehub-install.json`. On Linux, a detected pnpm install reuses the
245
+ `node_modules` trees through independent copy-on-write copies. The default
246
+ cache directory is used only when its filesystem supports reflinks, because full
247
+ copies cost more than a frozen install from the pnpm store.
248
+ The cache is scoped by repository identity, lockfile, workspace configuration,
249
+ package manifests, `.npmrc` files, patches and Node version. Restored trees are
250
+ verified offline, with one install per cache key at a time. Detected installs
251
+ disable lifecycle and build scripts; custom commands are trusted host configuration.
252
+ `install: { cache: { directory, entries } }` configures the cache on any filesystem, and
253
+ `cache: false` disables it. At startup, the built-in host removes pass
254
+ workspaces from an earlier process when its temporary directory is inside the
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
265
+ dispatch waits for `providerCooldownMs` (five minutes by default), doubling per
266
+ consecutive cooldown up to an hour. The pass waits for the cooldown instead of
267
+ failing and spends no no-progress budget. `modelConcurrency` caps model passes.
268
+ Each owner rechecks the durable deadline before dispatch, including after
269
+ workspace setup. Host merges and stack retargets continue during the cooldown.
270
+ A failed dependency install continues the pass without dependencies unless
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.
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.
285
+
286
+ Colocated `instructions.md` fills the preset's instruction slot without adding
287
+ headings. Explicit `driver.instructions` replaces that slot. Use
288
+ `{ mode: "replace", value: "..." }` to replace the complete instruction document.
289
+
290
+ A discovered Agent that imports the preset runs without more wiring on the Node
291
+ server preset. ViteHub generates a Nitro plugin that starts a process host for
292
+ it: a SQLite PR inbox in Agent State, bounded GitHub discovery of
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
298
+ GitHub deliveries to `/api/_vitehub/agents/<name>/webhooks/github` feed the
299
+ inbox; they never start the Agent directly. `GET /api/_vitehub/host/drain`
300
+ reports drain status, and `GET /api/_vitehub/host/health` reports each host's
301
+ health and queue. SIGUSR2 starts a drain. The build fails with `AGENT_B0022` on
302
+ hosts that cannot keep a process running, and with `AGENT_B0023` without SQL
303
+ Agent State. Hosts start in production builds, or in development only with
304
+ `VITEHUB_AGENT_PROCESS_HOSTS=1`, so a development server does not repair real
305
+ PRs by accident.
306
+
307
+ The host reads the GitHub App from `env.server.github` or `VITEHUB_GITHUB_APP_ID`,
308
+ `VITEHUB_GITHUB_PRIVATE_KEY` (or `VITEHUB_GITHUB_PRIVATE_KEY_PATH`), and
309
+ `VITEHUB_GITHUB_WEBHOOK_SECRET`. It resolves the App installation of each repository and
310
+ commits as the App's bot. `VITEHUB_GITHUB_INSTALLATION_ID` pins the installation for
311
+ `VITEHUB_GITHUB_APP_OWNER`. `VITEHUB_GITHUB_APP_INSTALLATIONS` accepts a JSON object mapping 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`.
314
+ A delivery without a configured webhook secret is rejected. Only the commit
315
+ author and committer identity pass to the worker; credentials do not. On its
316
+ first start, the host imports `.vitehub/pull-request-inbox.sqlite` from an
317
+ earlier hand-wired Babysitter once.
318
+
319
+ Pass results and their GitHub status deliveries commit in one inbox transaction.
320
+ The host publishes the saved result through its verified GitHub identity, retries
321
+ failed delivery after restart, and compares delivery versions before clearing an
322
+ entry. Delivery claims are atomic across hosts and expire after five minutes if
323
+ a host stops. Active writers renew their leases until publication settles, even
324
+ when the twenty-second deadline requests cancellation. Up to five publications
325
+ run outside queue reconciliation and remain tracked during process drain.
326
+ Deferred repair heads yield the bounded batch to other PRs. Saved results use
327
+ separate activity run IDs so completed invocations can publish their wait reason.
328
+ Older acknowledgements are backfilled with the corrected activity identity.
329
+ The inbox identifies its own activity by the host's immutable GitHub App ID.
330
+ An App rename cannot turn status updates into new repair feedback. Stored and
331
+ hydrated snapshots exclude those activity comments while retaining ordinary feedback.
332
+ New same-head feedback discards obsolete saved results. Confirmed repair-head and
333
+ closure transitions retain their result. If a writer settles after another host
334
+ replaces its expired lease, the latest settled result is requeued with a fresh
335
+ activity identity. A late saved-status write during an active worker queues a
336
+ running projection bound to that worker's claim. Its correction can publish
337
+ before the pass finishes, while an obsolete claim cannot authorize it.
338
+ GitHub comment writes cannot be fenced: a lease cannot
339
+ revoke an HTTP write already accepted by GitHub. A crashed writer's marker
340
+ expires fifteen minutes after its last delivery lease. Corrective replay stops
341
+ at that deadline. If an expired writer later settles in a live process, the host
342
+ queues the latest status again. An unobserved remote write after the deadline
343
+ can still overwrite the comment. Channels serialize activity publication by PR target before resolving credentials.
344
+ Separate token callbacks and token rotation cannot split that queue. Credential
345
+ resolution and read stages have thirty-second bounds. Caller cancellation can
346
+ shorten them, and a stalled credential or lookup callback releases the local queue
347
+ even when it ignores cancellation. An already-started write requests cancellation
348
+ at the deadline but retains target ordering and its durable delivery lease until
349
+ the actual transport settles. A custom transport that never settles after
350
+ cancellation can hold that target queue. Waiting comments
351
+ include the blocker reason. A confirmed repair result waits for its head webhook
352
+ if that webhook arrives after the pass finishes.
353
+
354
+ Known worker setup failures receive one recovery attempt per Agent `version` and
355
+ PR head. Bump an explicit version with each deployed Agent release. An Agent without
356
+ a version uses the installed package build identity, which changes with package
357
+ source and dependency updates even when preview builds reuse a manifest version.
358
+ Hosts that run package sources compute the same fingerprint at startup. The wake and release marker
359
+ commit together, so restarting the same release cannot repeat the wake. Timed
360
+ retries, check dependencies, and maintainer credential blockers keep their existing
361
+ wake conditions. Health can reuse admission accounting for at most two minutes
362
+ and reports its observation time; dispatch shares a fresh accounting read.
363
+
364
+ Invalid dependency installation inputs park the PR without a timer retry. Correct
365
+ the inputs, then push a new head or comment on the PR to resume. Installer capacity,
366
+ filesystem, and package-manager failures retain a five-minute retry.
367
+
368
+ Each pass uses a disposable provider workspace with unattended edit permission.
369
+ Native permission escalation is denied without prompting; the provider does not run
370
+ in full-access mode. GitHub tokens
371
+ stay on the host. Tools provide PR-bound log reads, repair pushes, comments,
372
+ metadata updates and thread resolution. Unless `merge` is `"auto"`, the worker
373
+ has no merge tool and the host rejects auto-merge operations. With `"auto"`, it
374
+ requests GitHub native auto-merge subject to current PR admission and repository
375
+ checks and reviews. Workers never merge directly or delete branches.
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
+
382
+ Before a repair push, the host durably associates the exact candidate commit with
383
+ its active claim. Check and status webhooks for that commit are retained even when
384
+ they arrive before the source-push and synchronize webhooks. This association does
385
+ not count as a successful push and expires with the claim. A wait after several
386
+ repair pushes retains every verified push receipt, including when host admission
387
+ closes during a provider retry.
388
+ When a candidate becomes the PR head, earlier unpublished candidates stop accepting
389
+ CI evidence. Later pending candidates and separately verified push receipts remain valid.
390
+
391
+ A pass can resolve several addressed review threads without cancelling itself
392
+ when its own resolution webhooks arrive. New comments and external thread reopens
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.