@vite-hub/presets 0.0.0-stage → 0.1.0

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 CHANGED
@@ -1,3 +1,297 @@
1
- # Temporary Holding Version
1
+ # @vite-hub/presets
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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-host`: `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/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.
32
+
33
+ ## Labeller
34
+
35
+ ```ts
36
+ import { labeller } from "@vite-hub/presets/labeller"
37
+ ```
38
+
39
+ See the [Labeller docs](https://vitehub.dev/docs/agents/labeller).
40
+
41
+ ## Workspace preset
42
+
43
+ ```ts
44
+ import workspace from "@vite-hub/presets/workspace"
45
+ ```
46
+
47
+ See the [workspace preset docs](https://vitehub.dev/docs/agents/workspace-preset).
48
+
49
+ ## Babysitter
50
+
51
+ Import `babysitter` from `@vite-hub/presets/babysitter`, or
52
+ `vite-hub/presets/babysitter` in an application. It repairs selected pull
53
+ requests, addresses human and bot review feedback, and parks while checks run.
54
+ Its workflow options are the GitHub Channel `filter`, lifecycle labels, the provider
55
+ `driver`, and the `merge` policy:
56
+
57
+ ```ts
58
+ import { defineAgent } from "@vite-hub/agent"
59
+ import { babysitter } from "@vite-hub/presets/babysitter"
60
+
61
+ export default defineAgent({
62
+ preset: "babysitter",
63
+ presets: { babysitter },
64
+ options: {
65
+ filter: { repository: { allow: ["acme/app"] } },
66
+ lifecycle: {
67
+ labels: { require: ["agent:repair"], deny: ["agent:paused"] },
68
+ },
69
+ driver: "codex",
70
+ merge: false,
71
+ concurrency: 2,
72
+ },
73
+ driver: { model: "your-codex-model" },
74
+ })
75
+ ```
76
+
77
+ `lifecycle.labels.require` admits a pull request when it has at least one listed
78
+ label. `lifecycle.labels.deny` pauses it whenever any listed label is present.
79
+ The same rules apply during discovery and to `opened`, `labeled`, and
80
+ `unlabeled` webhook events, so adding or removing a label can start, stop, or
81
+ resume work. Use `lifecycle.labels` for lifecycle control and `filter.labels`
82
+ for selection, rather than configuring both on one Babysitter.
83
+
84
+ `driver` selects the provider Driver that repairs each checkout: `"codex"` (the
85
+ default) or `"claude-code"`. Set its model and other provider settings with the
86
+ ordinary `driver` field. Model and custom run Drivers cannot repair a checkout.
87
+
88
+ `install` defaults to `true`. This mode requires Git and Corepack in the trusted
89
+ host PATH. Install Corepack separately on Node 25 and newer. The package Node
90
+ engine does not install these host tools. The host installs dependencies from the
91
+ frozen pnpm, npm, or Yarn lockfile before starting the provider. Installers run one
92
+ at a time per host process to bound dependency setup memory. Lifecycle scripts and
93
+ repository package-manager hooks, plugins, and binary delegation stay disabled.
94
+ The package manager must name an official version, rather than a URL. Corepack
95
+ uses the trusted npm registry and ignores checkout environment files. npm must
96
+ be version 7 or newer. A manifest without a package-manager version uses a pinned
97
+ default rather than an ambient executable. Installation failures are recorded in
98
+ `.git/vitehub-install.json`. Invalid installation inputs park the PR until new head
99
+ or comment evidence wakes it. Host and package-manager failures retry after five
100
+ minutes. Set `install: false` for a checkout with no Node dependencies.
101
+ 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`.
102
+ 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.
103
+ 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.
104
+ Validation refreshes generated linked commands in reused input snapshots. A changed or deleted command requires a dependency refresh; tracked commands retain their commit snapshot.
105
+ 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.
106
+ 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
107
+ descriptor is checked. Workspace glob matches must stay inside the checkout after
108
+ symlink resolution. Trusted GitHub release archives use the HTTPS archive path.
109
+ Workers call `commitRepair` with a message and explicit repair paths, then
110
+ `pushRepair`. The host commits because the provider sandbox protects Git metadata. For a
111
+ 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.
113
+ Unattended Codex runs preauthorize only the assigned host tools. Capability checks
114
+ still run on the host, and the native shell keeps its edit sandbox.
115
+
116
+ Direct merges use GitHub's asynchronous API, including native stacks. The inbox
117
+ records the request UUID and waits for GitHub to confirm a merge. Finished owners
118
+ release their queue lease while preserving any unresolved merge attempt. Expired
119
+ 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
+
121
+ `merge` defaults to `false`:
122
+
123
+ | Value | Behavior |
124
+ | --- | --- |
125
+ | `false` | The Babysitter never merges. |
126
+ | `"auto"` | The worker may call `requestAutoMerge`, which requests GitHub native auto-merge. |
127
+ | `"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. |
129
+
130
+ A direct merge needs passing required checks, completed and successful
131
+ current-head checks and statuses, loaded and resolved review threads, a
132
+ non-draft PR, and GitHub's live `mergeable_state: "clean"` on the default
133
+ branch. The merge request pins the head SHA, so a concurrent push makes GitHub
134
+ reject it. `ready({ repository, number, head, snapshot, requiredChecks })` can
135
+ add a policy, such as a required approval check; return `true` or a reason. Any
136
+ other result runs a normal repair pass.
137
+
138
+ After a repair push, the pass may continue for 3 minutes, then ends. The PR
139
+ waits on the pushed head. Later events on a waiting PR start a pass only when
140
+ they need one: new human or bot feedback, a new failing check, a merge conflict,
141
+ or an unresolved review thread. Pending checks, the pushed head's synchronize
142
+ event, and repeated results for failures the pass already saw keep it waiting.
143
+ With `merge: "direct"`, passing required checks also wake it, so the host can
144
+ merge. `reviewChecks` lists check names, such as a review bot's check, that keep
145
+ a PR waiting while they run. A comment-only review with an empty body does not
146
+ wake a waiting PR; its inline comments do. `noFindingsReviews` lists body
147
+ prefixes, such as `"> ✅ No new issues found."`, of comment-only reviews that
148
+ 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
151
+ assessed on later heads, so a direct merge needs a model pass only for new
152
+ feedback. Bot issue comments count by identity, not body. Without required
153
+ checks on the base branch, the newest run of every current-head check must
154
+ finish before a merge.
155
+
156
+ `deferWhilePending` (default `true`) holds a pass while required checks or
157
+ review checks run, unless a failure or conflict already needs repair; the PR
158
+ wakes once the gates stop. `noProgressBudget` (default `3`, `false` disables it)
159
+ stops a head after that many passes without a push or a recorded wait, until the
160
+ head changes or a person comments. `reviewPushBudget` (default `3`, `false`
161
+ disables it) counts review-driven pushes on a PR: pushes from a pass without a
162
+ merge conflict and without a failing check outside `reviewChecks`. After that
163
+ many, bot feedback and failed `reviewChecks` no longer wake a model pass. A
164
+ 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
167
+ `16`, `false` disables it) limits the model passes per PR in a rolling 24
168
+ hours. A PR that reached it parks until its oldest pass is 24 hours old, and
169
+ 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
172
+ dependencies on the host before the model starts: it detects pnpm, npm or
173
+ Yarn from the lockfile and installs frozen, or runs `{ command, args }`. The
174
+ install gets a scrubbed environment and records its result and timing in
175
+ `.git/vitehub-install.json`. On Linux, a detected pnpm install reuses the
176
+ `node_modules` trees through independent copy-on-write copies. The default
177
+ cache directory is used only when its filesystem supports reflinks, because full
178
+ copies cost more than a frozen install from the pnpm store.
179
+ The cache is scoped by repository identity, lockfile, workspace configuration,
180
+ package manifests, `.npmrc` files, patches and Node version. Restored trees are
181
+ verified offline, with one install per cache key at a time. Detected installs
182
+ disable lifecycle and build scripts; custom commands are trusted host configuration.
183
+ `install: { cache: { directory, entries } }` configures the cache on any filesystem, and
184
+ `cache: false` disables it. At startup, the built-in host removes pass
185
+ 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
190
+ dispatch waits for `providerCooldownMs` (five minutes by default), doubling per
191
+ consecutive cooldown up to an hour. The pass waits for the cooldown instead of
192
+ failing and spends no no-progress budget. `modelConcurrency` caps model passes.
193
+ Each owner rechecks the durable deadline before dispatch, including after
194
+ workspace setup. Host merges and stack retargets continue during the cooldown.
195
+ A failed dependency install continues the pass without dependencies unless
196
+ `install.required` is set; `install.concurrency` sets the install slots.
197
+ 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
+
199
+ Colocated `instructions.md` fills the preset's instruction slot without adding
200
+ headings. Explicit `driver.instructions` replaces that slot. Use
201
+ `{ mode: "replace", value: "..." }` to replace the complete instruction document.
202
+
203
+ A discovered Agent that imports the preset runs without more wiring on the Node
204
+ server preset. ViteHub generates a Nitro plugin that starts a process host for
205
+ it: a SQLite PR inbox in Agent State, bounded GitHub discovery of
206
+ `filter.repository.allow`, claims, repair passes, and wake handling. Signed
207
+ GitHub deliveries to `/api/_vitehub/agents/<name>/webhooks/github` feed the
208
+ inbox; they never start the Agent directly. `GET /api/_vitehub/host/drain`
209
+ reports drain status, and `GET /api/_vitehub/host/health` reports each host's
210
+ health and queue. SIGUSR2 starts a drain. The build fails with `AGENT_B0022` on
211
+ hosts that cannot keep a process running, and with `AGENT_B0023` without SQL
212
+ Agent State. Hosts start in production builds, or in development only with
213
+ `VITEHUB_AGENT_PROCESS_HOSTS=1`, so a development server does not repair real
214
+ PRs by accident.
215
+
216
+ The host reads the GitHub App from `env.server.github` or `VITEHUB_GITHUB_APP_ID`,
217
+ `VITEHUB_GITHUB_PRIVATE_KEY` (or `VITEHUB_GITHUB_PRIVATE_KEY_PATH`), and
218
+ `VITEHUB_GITHUB_WEBHOOK_SECRET`. It resolves the App installation of each repository and
219
+ commits as the App's bot. `VITEHUB_GITHUB_INSTALLATION_ID` pins the installation for
220
+ `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.
223
+ A delivery without a configured webhook secret is rejected. Only the commit
224
+ author and committer identity pass to the worker; credentials do not. On its
225
+ first start, the host imports `.vitehub/pull-request-inbox.sqlite` from an
226
+ earlier hand-wired Babysitter once.
227
+
228
+ Pass results and their GitHub status deliveries commit in one inbox transaction.
229
+ The host publishes the saved result through its verified GitHub identity, retries
230
+ failed delivery after restart, and compares delivery versions before clearing an
231
+ entry. Delivery claims are atomic across hosts and expire after five minutes if
232
+ a host stops. Active writers renew their leases until publication settles, even
233
+ when the twenty-second deadline requests cancellation. Up to five publications
234
+ run outside queue reconciliation and remain tracked during process drain.
235
+ Deferred repair heads yield the bounded batch to other PRs. Saved results use
236
+ separate activity run IDs so completed invocations can publish their wait reason.
237
+ Older acknowledgements are backfilled with the corrected activity identity.
238
+ The inbox identifies its own activity by the host's immutable GitHub App ID.
239
+ An App rename cannot turn status updates into new repair feedback. Stored and
240
+ hydrated snapshots exclude those activity comments while retaining ordinary feedback.
241
+ New same-head feedback discards obsolete saved results. Confirmed repair-head and
242
+ closure transitions retain their result. If a writer settles after another host
243
+ replaces its expired lease, the latest settled result is requeued with a fresh
244
+ activity identity. A late saved-status write during an active worker queues a
245
+ running projection bound to that worker's claim. Its correction can publish
246
+ before the pass finishes, while an obsolete claim cannot authorize it.
247
+ GitHub comment writes cannot be fenced: a lease cannot
248
+ revoke an HTTP write already accepted by GitHub. A crashed writer's marker
249
+ expires fifteen minutes after its last delivery lease. Corrective replay stops
250
+ at that deadline. If an expired writer later settles in a live process, the host
251
+ queues the latest status again. An unobserved remote write after the deadline
252
+ can still overwrite the comment. Channels serialize activity publication by PR target before resolving credentials.
253
+ Separate token callbacks and token rotation cannot split that queue. Credential
254
+ resolution and read stages have thirty-second bounds. Caller cancellation can
255
+ shorten them, and a stalled credential or lookup callback releases the local queue
256
+ even when it ignores cancellation. An already-started write requests cancellation
257
+ at the deadline but retains target ordering and its durable delivery lease until
258
+ the actual transport settles. A custom transport that never settles after
259
+ cancellation can hold that target queue. Waiting comments
260
+ include the blocker reason. A confirmed repair result waits for its head webhook
261
+ if that webhook arrives after the pass finishes.
262
+
263
+ Known worker setup failures receive one recovery attempt per Agent `version` and
264
+ PR head. Bump an explicit version with each deployed Agent release. An Agent without
265
+ a version uses the installed package build identity, which changes with package
266
+ source and dependency updates even when preview builds reuse a manifest version.
267
+ Hosts that run package sources compute the same fingerprint at startup. The wake and release marker
268
+ commit together, so restarting the same release cannot repeat the wake. Timed
269
+ retries, check dependencies, and maintainer credential blockers keep their existing
270
+ wake conditions. Health can reuse admission accounting for at most two minutes
271
+ and reports its observation time; dispatch shares a fresh accounting read.
272
+
273
+ Invalid dependency installation inputs park the PR without a timer retry. Correct
274
+ the inputs, then push a new head or comment on the PR to resume. Installer capacity,
275
+ filesystem, and package-manager failures retain a five-minute retry.
276
+
277
+ Each pass uses a disposable provider workspace with unattended edit permission.
278
+ Native permission escalation is denied without prompting; the provider does not run
279
+ in full-access mode. GitHub tokens
280
+ stay on the host. Tools provide PR-bound log reads, repair pushes, comments,
281
+ metadata updates and thread resolution. Unless `merge` is `"auto"`, the worker
282
+ has no merge tool and the host rejects auto-merge operations. With `"auto"`, it
283
+ requests GitHub native auto-merge subject to current PR admission and repository
284
+ checks and reviews. Workers never merge directly or delete branches.
285
+
286
+ Before a repair push, the host durably associates the exact candidate commit with
287
+ its active claim. Check and status webhooks for that commit are retained even when
288
+ they arrive before the source-push and synchronize webhooks. This association does
289
+ not count as a successful push and expires with the claim. A wait after several
290
+ repair pushes retains every verified push receipt, including when host admission
291
+ closes during a provider retry.
292
+ When a candidate becomes the PR head, earlier unpublished candidates stop accepting
293
+ CI evidence. Later pending candidates and separately verified push receipts remain valid.
294
+
295
+ A pass can resolve several addressed review threads without cancelling itself
296
+ when its own resolution webhooks arrive. New comments and external thread reopens
297
+ still revoke further repair operations.