@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.
@@ -0,0 +1,419 @@
1
+ import { T as AutomatedReviewClass, i as BabysitterAdmissionPause, l as GitHubRequiredCheckState, r as BabysitterAdmissionOptions, s as Snapshot, t as BabysitterWarmWorkspaces } from "./pr-workspaces-CjX3PSqM.js";
2
+ import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentSandboxDefinition, BuiltInAgentDriverName, ConfiguredAgentDefinition } from "@vite-hub/agent";
3
+ import { GitHubPullRequestFilter } from "@vite-hub/agent/channels";
4
+ import { Diagnostic } from "nostics";
5
+ //#region src/babysitter/result.d.ts
6
+ interface BabysitterResultDiagnostic {
7
+ code: "invalid-wait" | "invalid-wake" | "invalid-reviewed-head" | "invalid-check-head";
8
+ field: string;
9
+ }
10
+ /**
11
+ * Provider output is an untrusted boundary. Keep the required disposition, but
12
+ * normalize optional coordination fields so an invalid wait hint cannot discard
13
+ * an otherwise useful park/retry result (older models frequently omit `kind`).
14
+ */
15
+ declare function createBabysitterPassResultSchema(report?: (diagnostic: BabysitterResultDiagnostic) => void): {
16
+ "~standard": {
17
+ version: 1;
18
+ vendor: string;
19
+ validate(value: unknown): {
20
+ value: BabysitterPassResult;
21
+ } | {
22
+ issues: Array<{
23
+ message: string;
24
+ }>;
25
+ };
26
+ };
27
+ };
28
+ //#endregion
29
+ //#region src/babysitter/merge.d.ts
30
+ type BabysitterMergeMethod = "squash" | "merge" | "rebase";
31
+ interface BabysitterMergeReadinessInput {
32
+ repository: string;
33
+ number: number;
34
+ /** The head SHA that the merge will require. */
35
+ head: string;
36
+ snapshot: Snapshot;
37
+ requiredChecks: GitHubRequiredCheckState;
38
+ }
39
+ /** Return `true` to allow the merge, or a reason that sends the PR to a normal pass. */
40
+ type BabysitterMergeReady = (input: BabysitterMergeReadinessInput) => true | string | Promise<true | string>;
41
+ /**
42
+ * - `false`: never merge.
43
+ * - `"auto"`: the worker may request GitHub native auto-merge.
44
+ * - `"direct"`: the host merges a ready PR before any model pass, with the `"approved-if-outside"` gate.
45
+ * - `{ strategy: "direct", ready }`: a direct merge with another gate. `ready` is a
46
+ * {@link BabysitterMergeReady} callback or `"approved-if-outside"`, the default: a PR whose author
47
+ * is not an owner, member or collaborator of the repository merges only after a reviewer with write
48
+ * access approves its current head, and while no such reviewer's latest review requests changes.
49
+ * A push after the approval needs a new one. `ready: () => true` merges every ready PR.
50
+ * `trustedAuthors` lets more authors through the default gate, such as dependency bots.
51
+ */
52
+ type BabysitterMerge = false | "auto" | "direct" | {
53
+ strategy: "direct";
54
+ method?: BabysitterMergeMethod;
55
+ ready?: BabysitterMergeReady | "approved-if-outside";
56
+ /**
57
+ * Logins whose PRs the `"approved-if-outside"` gate merges without an approval, like an author with
58
+ * write access, such as `renovate[bot]`. Write a bot with its `[bot]` suffix: an entry with it matches
59
+ * only a bot account, and one without it matches only a user. Not allowed with a `ready` callback.
60
+ */
61
+ trustedAuthors?: readonly string[];
62
+ /**
63
+ * Required checks, by repository (`owner/name`), that the host may merge past when they fail only
64
+ * because the same check fails the same way on the base branch tip. The merge bypasses branch
65
+ * rules, so the GitHub App must be allowed to bypass them, and every other rule must be satisfied.
66
+ */
67
+ bypassInheritedChecks?: Record<string, readonly string[]>;
68
+ /**
69
+ * Logins whose reviewed drafts the host marks ready for review. Only drafts whose head
70
+ * branch is in the repository itself qualify, so a fork's draft stays a draft.
71
+ */
72
+ markDraftsReady?: readonly string[];
73
+ /**
74
+ * Merge a ready pull request into its parent's branch when its base is the head branch of another
75
+ * open pull request in the same repository, so the stack lands with the parent. Default `true`.
76
+ */
77
+ foldStacks?: boolean;
78
+ };
79
+ //#endregion
80
+ //#region src/babysitter/main-repair.d.ts
81
+ /**
82
+ * Opens a pull request that repairs the default branch when one of its watched workflows fails. PR
83
+ * checks often run only fast suites while the full suites run on the default branch, so pull requests
84
+ * that each pass can break it together. The repair PR's head branch starts with
85
+ * `mainRepairBranchPrefix`, so the queue claims it first.
86
+ */
87
+ interface BabysitterMainRepair {
88
+ /** GitHub Actions workflow names to watch on the default branch, such as `["ci"]`. */
89
+ workflows: string[];
90
+ /** Repositories to watch, as `owner/name`. Defaults to every repository the Babysitter serves. */
91
+ repositories?: string[];
92
+ /**
93
+ * Minutes after which a running job of a watched push run on the default branch counts as stuck;
94
+ * its run is force-cancelled so later runs can start. `false` never cancels. Defaults to 90.
95
+ */
96
+ stuckJobMinutes?: number | false;
97
+ }
98
+ //#endregion
99
+ //#region src/babysitter/placement.d.ts
100
+ /**
101
+ * Thrown by `placement.place()` when no host can take the pass now. The pull request waits
102
+ * `retryAfterMs` and is claimed again, without a failure or a no-progress strike.
103
+ */
104
+ export declare class BabysitterPlacementCapacityError extends Diagnostic {
105
+ readonly retryAfterMs: number;
106
+ constructor(reason: string, retryAfterMs?: number);
107
+ }
108
+ //#endregion
109
+ //#region src/babysitter.d.ts
110
+ export interface BabysitterLifecycleLabels {
111
+ /** At least one of these labels must be present for the PR to be eligible. */
112
+ require?: readonly string[];
113
+ /** Any of these labels suppresses the PR, even when a required label is present. */
114
+ deny?: readonly string[];
115
+ }
116
+ export interface BabysitterLifecycleOptions {
117
+ labels?: BabysitterLifecycleLabels;
118
+ }
119
+ /** Where one pass runs. A pass without a Sandbox uses the host checkout and the configured `sandbox`. */
120
+ export interface BabysitterPlacementLease {
121
+ /** Sandbox for this pass, for example a custom runtime on another host. */
122
+ sandbox?: AgentSandboxDefinition;
123
+ /** Called once when the pass finishes, fails or is cancelled. */
124
+ release(): void;
125
+ }
126
+ /** Chooses a host for each pass before the Babysitter installs dependencies on this one. */
127
+ export interface BabysitterPlacement {
128
+ /** Throw `BabysitterPlacementCapacityError` when no host can take the pass now; the PR waits and is claimed again. */
129
+ place(pullRequest: {
130
+ repository: string;
131
+ number: number;
132
+ }): BabysitterPlacementLease | Promise<BabysitterPlacementLease>;
133
+ /** Passes currently placed on other hosts. They hold a concurrency slot but no local memory. */
134
+ remoteActive?(): number;
135
+ /**
136
+ * Slots that hosts admit now, counting passes already running. A reconcile claims at most this
137
+ * many PRs minus the active owners, so it never claims work that `place` must turn away.
138
+ */
139
+ admitted?(): number | Promise<number>;
140
+ }
141
+ /** Where the Babysitter reports its state on each PR. Both need a verified GitHub App identity. */
142
+ export interface BabysitterStatusOptions {
143
+ /** Keep the activity comment on the PR up to date. Defaults to `true`. */
144
+ comment?: boolean;
145
+ /**
146
+ * Mirror the state as a check run named `babysitter` on the PR head: queued, in progress, neutral
147
+ * while waiting, success when done and failure when a pass failed. Its details link opens the
148
+ * Console session. Needs the App's `checks: write` permission; a repository that answers 403 is
149
+ * reported once and skipped. The Babysitter leaves this check out of its own CI and merge decisions,
150
+ * so do not make it a required check. Defaults to `true`.
151
+ */
152
+ checkRun?: boolean;
153
+ }
154
+ export interface BabysitterOptions {
155
+ /** Process admission policy. Concurrency remains the preset hard maximum. */
156
+ capacity?: Pick<import("@vite-hub/agent/process").ProcessAgentCapacityOptions, "memory" | "cpu" | "fallbackConcurrency">;
157
+ /**
158
+ * Places each pass on this host or in a Sandbox before host dependency installation. Sandbox passes
159
+ * skip the host install; the Sandbox installs through `refreshDependencies` when it provides one.
160
+ */
161
+ placement?: BabysitterPlacement;
162
+ /**
163
+ * Select PRs with the same rules as the GitHub Channel, with two differences. A PR passes when it
164
+ * matches either `author.allow` or `authorAssociation.allow`; a match on either deny list rejects it.
165
+ * Logins match case-insensitively and in either bot spelling, so `renovate[bot]` also matches `renovate`.
166
+ * Without `repository.allow`, the Babysitter serves every repository that its GitHub App installations
167
+ * can access, except archived ones and those in `repository.deny`, so installing the App on a repository enrolls it.
168
+ * Without `author` or `authorAssociation` rules, only PRs whose author is an owner, member or collaborator are selected.
169
+ */
170
+ filter: GitHubPullRequestFilter;
171
+ /**
172
+ * Additional lifecycle admission rules. Use labels to pause or resume a PR without changing the filter.
173
+ * Without these labels or `filter.labels`, a PR labelled `babysitter:skip` is skipped. `{ labels: {} }` turns that off.
174
+ */
175
+ lifecycle: BabysitterLifecycleOptions;
176
+ /** Provider Driver that repairs each PR in its checkout. Defaults to `"codex"`. Set the model with `driver.model`. */
177
+ driver: BuiltInAgentDriverName;
178
+ /**
179
+ * Merge policy. Defaults to `"direct"`. `false` never merges, and `"auto"` lets the worker request
180
+ * GitHub native auto-merge. `"direct"` merges a ready PR into its default branch before any model
181
+ * pass, and holds a PR from someone without write access until a reviewer with write access approves
182
+ * its current head. Pass `{ strategy: "direct", ready }` with another callback to change that gate.
183
+ */
184
+ merge: BabysitterMerge;
185
+ /**
186
+ * Check names whose pending run means a review is in progress, such as a review bot's check.
187
+ * A parked PR keeps waiting while one runs. Defaults to none.
188
+ */
189
+ reviewChecks: string[];
190
+ /**
191
+ * Body prefixes of comment-only reviews that report no findings, such as a review bot's
192
+ * `"> ✅ No new issues found."`. These reviews do not wake a parked PR. Defaults to none.
193
+ */
194
+ noFindingsReviews: string[];
195
+ /**
196
+ * Logins whose comments and reviews never need an assessment. Their items do not block a direct
197
+ * merge or wake a waiting PR. Defaults to the deployment preview bots `pkg-pr-new[bot]`,
198
+ * `vercel[bot]`, `cloudflare-workers-and-pages[bot]` and `netlify[bot]`. A list replaces them.
199
+ */
200
+ ignoreFeedbackAuthors: string[];
201
+ /**
202
+ * Passes on one head that may end without a push or a recorded wait before the PR stops until its
203
+ * head changes or a person comments. `false` disables the budget. Defaults to 3.
204
+ */
205
+ noProgressBudget: number | false;
206
+ /**
207
+ * Review-driven pushes on one PR after which bot feedback and failed `reviewChecks` no longer wake a
208
+ * model pass. A push is review-driven when its pass had no merge conflict and no failing check outside
209
+ * `reviewChecks`. A person's comment or review, another failing check, a conflict or a head that
210
+ * someone else pushed still start a pass. The PR then merges on its required checks or parks with
211
+ * the reason. `false` disables the budget. Defaults to 3.
212
+ */
213
+ reviewPushBudget: number | false;
214
+ /**
215
+ * Heads in a row whose automated review has no valid finding above P2 before automated review settles
216
+ * as if `reviewPushBudget` were spent. Each pass reports the highest class (P0 to P3) in the
217
+ * automated reviews of its head; a P0 or P1 starts the count again. Needs `reviewPushBudget`.
218
+ * `false` disables it. Defaults to `false`.
219
+ */
220
+ minorReviewRounds: number | false;
221
+ /**
222
+ * Review-driven pushes after which each pass is asked to fix a recurring class of review finding at
223
+ * its root instead of patching one more case, or to decline the remaining minor cases. `false`
224
+ * disables it. Defaults to `false`.
225
+ */
226
+ reviewConvergencePushes: number | false;
227
+ /**
228
+ * Unresolved review threads with only bot comments stop blocking a direct merge and stop waking a
229
+ * waiting PR once a pass assessed their comments. A new bot comment still needs a pass, and a thread
230
+ * with a person's comment still blocks. Defaults to `false`; such threads then stop blocking only
231
+ * once automated review settles.
232
+ */
233
+ ignoreAssessedBotThreads: boolean;
234
+ /**
235
+ * Model passes on one PR in a rolling 24 hours. After that many, the PR parks until the oldest pass
236
+ * is 24 hours old; its result and the health route show that time. A person's comment or review, the
237
+ * first failing required check on a head, a merge conflict, and one assessment of a head whose required
238
+ * checks pass still start a pass, and count. A pass that the provider fails within 10 minutes does not
239
+ * count. `false` disables the budget. Defaults to 16.
240
+ */
241
+ dailyPassBudget: number | false;
242
+ /**
243
+ * Repair pushes on one PR in a rolling 24 hours. Past it, `pushRepair` refuses a push until the
244
+ * oldest is 24 hours old, and a pass that could only push parks until then. A conflict repair still
245
+ * pushes, and a PR whose required checks fail may push once every two hours. `false` disables the
246
+ * budget. Defaults to `false`.
247
+ */
248
+ dailyPushBudget: number | false;
249
+ /**
250
+ * PR labels that put a PR first in the claim order, after main repairs. A labelled PR is exempt from
251
+ * `dailyPassBudget` and `dailyPushBudget`; checks, reviews and merge gates still apply. Matched
252
+ * case-insensitively. Defaults to none.
253
+ */
254
+ priorityLabels: string[];
255
+ /**
256
+ * Head branch prefix of PRs that repair the base branch, such as `"repair-main-"`. These PRs are
257
+ * claimed before every other PR, and `noProgressBudget` never stops them. Defaults to none.
258
+ */
259
+ mainRepairBranchPrefix?: string;
260
+ /**
261
+ * Open a PR that repairs the default branch when one of `workflows` fails on it. The check runs every
262
+ * 10 minutes per repository, and at once when a failed push run of a watched workflow is delivered.
263
+ * The PR starts with an empty commit on a branch named `mainRepairBranchPrefix` and the red commit's
264
+ * short SHA, so the queue claims it first. One repair PR is open at a time, and a red commit gets
265
+ * one repair branch. Running jobs of watched push runs older than `stuckJobMinutes` are force-cancelled
266
+ * first. Needs `mainRepairBranchPrefix`. Defaults to `false`.
267
+ */
268
+ mainRepair: BabysitterMainRepair | false;
269
+ /**
270
+ * Wait for running required checks and review checks before a pass, unless a failure or conflict
271
+ * already needs repair. One pass then handles CI and review results together. Defaults to `true`.
272
+ */
273
+ deferWhilePending: boolean;
274
+ /**
275
+ * Install dependencies on the host before the provider starts. `true` detects pnpm, npm or
276
+ * Yarn from the lockfile and installs it frozen. A command overrides the detection. A detected pnpm
277
+ * install reuses the trees of earlier passes. A failed install does not stop the pass unless
278
+ * `required` is set. Defaults to `true`.
279
+ */
280
+ install: BabysitterInstall;
281
+ /** Rerun failed GitHub Actions runs once before a model pass repairs them. Defaults to `true`. */
282
+ ciRecovery: boolean;
283
+ /**
284
+ * Keep one workspace per open PR under `<dataDir>/pr-workspaces` instead of cloning, copying and
285
+ * installing for every pass. A pass on the head the previous pass pushed or left, after a pass that
286
+ * finished, on a clean tree, keeps node_modules and build caches and skips a current install. Any
287
+ * other pass empties the workspace and checks the head out again. Entries go when the PR closes,
288
+ * after `idleDays` without a pass, and least recently used first above `budgetGb` or below
289
+ * `minFreePercent` free disk. `resumeThreads` also continues the previous pass's provider thread.
290
+ * Passes placed in a Sandbox keep using their own workspace. Defaults to `false`.
291
+ */
292
+ warmWorkspaces: boolean | BabysitterWarmWorkspaces;
293
+ /**
294
+ * Repair a PR whose base is another open PR's branch in parallel with its parent: checks, conflicts
295
+ * and feedback. It never merges into the parent's branch and waits for the parent once its reviewed
296
+ * head has nothing left to repair. Requires `merge: "direct"`. Defaults to `false`, which leaves a
297
+ * stack child unclaimed until its parent merges.
298
+ */
299
+ repairStackChildren: boolean;
300
+ /**
301
+ * Model passes that run at the same time. Set it to what the provider accounts can serve; host
302
+ * work such as merges and stack retargets still uses `concurrency`. Defaults to `concurrency`.
303
+ */
304
+ modelConcurrency?: number;
305
+ /**
306
+ * Retries of a provider rate limit, 10 seconds apart, before the pass opens the provider cooldown.
307
+ * Set `0` when the provider already retries, as Codex does. Defaults to 3.
308
+ */
309
+ providerRetries: number;
310
+ /**
311
+ * First cooldown after a pass runs out of provider rate-limit retries. Model passes pause; host work
312
+ * continues. Each further cooldown doubles, up to one hour, and halves model concurrency. A
313
+ * success 30 minutes after the last cooldown removes one step. Defaults to 300000 (five minutes).
314
+ */
315
+ providerCooldownMs: number;
316
+ /** GitHub logins the worker may notify through its explicit mention capability. Defaults to none. */
317
+ mentionAllowlist: string[];
318
+ /** PRs repaired at the same time. Defaults to 1. */
319
+ concurrency: number;
320
+ /**
321
+ * Token budgets, a free-space guard and custom checks that gate model passes. A spent limit
322
+ * stops model passes; direct merges and recorded waits continue. Defaults to no token limit
323
+ * and 4096 MiB of free temporary space.
324
+ */
325
+ admission: BabysitterAdmissionOptions;
326
+ /** How the Babysitter reports its state on the PR. Defaults to `{ comment: true, checkRun: true }`. */
327
+ status: BabysitterStatusOptions;
328
+ }
329
+ /**
330
+ * Dependency install before each pass. `true` detects the package manager from the lockfile;
331
+ * `false` skips the install.
332
+ */
333
+ export type BabysitterInstall = boolean | {
334
+ /** Install command. Defaults to the package manager detected from the lockfile. */
335
+ command?: string;
336
+ args?: string[];
337
+ /**
338
+ * Reuse the node_modules trees of a detected pnpm install across passes with the same lockfile,
339
+ * using independent copy-on-write copies on Linux. `directory` defaults to `BABYSITTER_INSTALL_CACHE` or
340
+ * `<tmpdir>/vitehub-install-cache` and must share a filesystem with the pass workspaces. The default
341
+ * directory is used only when it supports reflinks; a configured `directory` is used on any filesystem.
342
+ * `entries` defaults to `BABYSITTER_INSTALL_CACHE_ENTRIES` or 8. `false` disables the cache.
343
+ */
344
+ cache?: false | {
345
+ directory?: string;
346
+ entries?: number;
347
+ };
348
+ /**
349
+ * Detected installs that run at the same time across passes. A pass waits up to ten minutes for a
350
+ * free slot and keeps its checkout while it waits. Defaults to 2.
351
+ */
352
+ concurrency?: number;
353
+ /**
354
+ * `false` continues a pass without dependencies when the install fails: the model reads the
355
+ * failure in `.git/vitehub-install.json`, repairs the PR's lockfile or manifests or relies on hosted
356
+ * CI, and commits without local dependency verification. `true` parks the PR on the failure until
357
+ * its inputs change. Defaults to `false`.
358
+ */
359
+ required?: boolean;
360
+ /**
361
+ * `refreshDependencies` calls per pass. Further calls return a tool error that tells the model to
362
+ * commit its dependency fixes and let hosted CI validate them. Retryable install failures do not
363
+ * count. Defaults to no limit.
364
+ */
365
+ refreshes?: number;
366
+ };
367
+ export type BabysitterPassWake = {
368
+ kind: "checks";
369
+ repository: string;
370
+ headSha: string;
371
+ } | {
372
+ kind: "pull-request";
373
+ repository: string;
374
+ number: number;
375
+ };
376
+ export type BabysitterPassWait = {
377
+ kind: "checks";
378
+ headSha: string;
379
+ } | {
380
+ kind: "external";
381
+ reason: string;
382
+ wake?: BabysitterPassWake;
383
+ };
384
+ export interface BabysitterPassResult {
385
+ disposition: "park" | "retry";
386
+ text: string;
387
+ /** Structured external dependency. The host never interprets result prose as control flow. */
388
+ wait?: BabysitterPassWait;
389
+ /** Current HEAD whose full feedback and failed checks were inspected and addressed. */
390
+ reviewedHead?: string;
391
+ /** Legacy explicit check checkpoint, accepted while existing provider output migrates. */
392
+ waitForChecksHead?: string;
393
+ /** Highest class of valid finding in the automated reviews of the head the pass started on. Read with `minorReviewRounds`. */
394
+ automatedReview?: AutomatedReviewClass;
395
+ }
396
+ export declare const babysitterPassResultSchema: ReturnType<typeof createBabysitterPassResultSchema>;
397
+ /** A repair workflow. Connections, provider settings and host resources stay in the application. */
398
+ type BabysitterDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvoker, AgentInvocationContextValues, BabysitterPassResult> & {
399
+ reviewChecks: string[];
400
+ noFindingsReviews: string[];
401
+ ignoreFeedbackAuthors: string[];
402
+ noProgressBudget: number | false;
403
+ reviewPushBudget: number | false;
404
+ dailyPassBudget: number | false;
405
+ deferWhilePending: boolean;
406
+ install: BabysitterInstall;
407
+ mentionAllowlist: string[];
408
+ lifecycle: BabysitterLifecycleOptions;
409
+ };
410
+ export type BabysitterAgent = ConfiguredAgentDefinition<BabysitterOptions, BabysitterDefinition>;
411
+ /**
412
+ * Combines explicit lifecycle labels with the shared GitHub PR filter. A filter without author rules
413
+ * selects only PRs from people with write access, and one without label rules skips PRs labelled
414
+ * `babysitter:skip`.
415
+ */
416
+ export declare function resolveBabysitterLifecycleFilter(configured: GitHubPullRequestFilter, lifecycle: BabysitterLifecycleOptions | undefined): GitHubPullRequestFilter;
417
+ export declare const babysitter: BabysitterAgent;
418
+ //#endregion
419
+ export type { AutomatedReviewClass, BabysitterAdmissionOptions, BabysitterAdmissionPause, BabysitterMainRepair, BabysitterMerge, BabysitterMergeMethod, BabysitterMergeReadinessInput, BabysitterMergeReady, BabysitterWarmWorkspaces };
@@ -0,0 +1,2 @@
1
+ import { i as BabysitterPlacementCapacityError, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter, t as babysitter } from "./babysitter-C71pgjkv.js";
2
+ export { BabysitterPlacementCapacityError, babysitter, babysitterPassResultSchema, resolveBabysitterLifecycleFilter };