@vite-hub/presets 0.1.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,260 @@
1
- import { AgentRunActivity } from "@vite-hub/agent";
2
- import { GitHubPullRequestFilter } from "@vite-hub/agent/channels";
1
+ import { AgentChannelDefinition, AgentRunActivity } from "@vite-hub/agent";
3
2
  import "valibot";
4
- import { SqliteAgentStateExtension } from "@vite-hub/agent/state/sqlite";
3
+ import { GitHubAppDelivery, GitHubAppRepository, GitHubProvider } from "@vite-hub/forge";
4
+ import { GitHubChannelOptions, GitHubPullRequestFilter } from "@vite-hub/agent/channels";
5
+ import { SqliteAgentStateExtension } from "@vite-hub/agent/state";
6
+ //#region src/babysitter/inbox/budgets.d.ts
7
+ interface ProviderBudget {
8
+ generation: string;
9
+ maxRetries: number;
10
+ nextAttempt: number;
11
+ succeededThrough: number;
12
+ pending: number[];
13
+ failures: number[];
14
+ resetReason?: string;
15
+ }
16
+ type ProviderAttempt = {
17
+ provider: string;
18
+ generation: string;
19
+ attempt: number;
20
+ };
21
+ type ProviderAttemptOutcome = "success" | "retryable-failure" | "other-failure";
22
+ /** New evidence that gives an exhausted head one more pass, once per head. */
23
+ type ProgressGrant = "conflict" | "bot-feedback";
24
+ /** `exhaustedAt` is when the head spent its budget. After `progressCooldownMs` it gets one more pass. */
25
+ interface ProgressBudget {
26
+ head: string;
27
+ limit: number;
28
+ count: number;
29
+ exhausted: boolean;
30
+ evidence?: string;
31
+ creditedEvidence: string[];
32
+ resetReason?: string;
33
+ grants?: ProgressGrant[];
34
+ exhaustedAt?: number;
35
+ }
36
+ /**
37
+ * The host verifies progress from GitHub/provider state, never from Agent prose. `reviewDriven` marks a
38
+ * push whose pass had no merge conflict and no failing check outside the review checks; the host
39
+ * decides it from the claimed snapshot.
40
+ */
41
+ type ProgressOutcome = {
42
+ kind: "no-progress";
43
+ } | {
44
+ kind: "verified";
45
+ evidence: string;
46
+ reviewDriven?: boolean;
47
+ };
48
+ /**
49
+ * Review-driven pushes on one PR, over its whole life. `heads` lists the heads that this worker pushed
50
+ * and, once the budget is spent, the heads that already got a model pass. A head outside it was moved
51
+ * by someone else. `minorHeads` lists the heads in a row whose automated review a pass classed with
52
+ * nothing above P2.
53
+ */
54
+ interface ReviewPushBudget {
55
+ count: number;
56
+ heads: string[];
57
+ minorHeads?: string[];
58
+ }
59
+ /** The highest class of valid automated review finding that a pass reported for the head it started on. */
60
+ type AutomatedReviewClass = "P0" | "P1" | "P2" | "P3" | "none";
61
+ /**
62
+ * Model passes on one PR in the last 24 hours. `passes` holds the time each pass started the model.
63
+ * `human` is the generation of the last person's feedback that a pass saw. `exemptions` lists the
64
+ * exemptions already used, so each applies once.
65
+ */
66
+ interface DailyPassBudget {
67
+ passes: number[];
68
+ human?: number;
69
+ exemptions: string[];
70
+ }
71
+ interface InboxBudgets {
72
+ providerRetries?: number;
73
+ noProgress?: number;
74
+ reviewPushes?: number;
75
+ minorReviewRounds?: number;
76
+ dailyPasses?: number;
77
+ }
78
+ //#endregion
79
+ //#region src/github/checkout.d.ts
80
+ /** Why a persistent provider workspace was kept or emptied. */
81
+ type GitHubWorkspaceReuse = "warm" | "cold" | "dirty" | "missing-metadata" | (string & {});
82
+ //#endregion
83
+ //#region src/github/repair.d.ts
84
+ interface GitHubRepairCommit {
85
+ message: string;
86
+ paths: string[];
87
+ /** Files where a base merge intentionally keeps the PR's version over a base change, each with the reason. */
88
+ baseOverrides?: Array<{
89
+ path: string;
90
+ reason: string;
91
+ }>;
92
+ }
93
+ //#endregion
94
+ //#region src/github/host.d.ts
95
+ type GitHubHostSecret = string | {
96
+ unseal: () => string;
97
+ };
98
+ interface GitHubHostCredentials {
99
+ appId?: number | string;
100
+ installationId?: number | string;
101
+ owner?: string;
102
+ privateKey?: GitHubHostSecret;
103
+ token?: GitHubHostSecret;
104
+ }
105
+ interface GitHubHostCredentialContext {
106
+ /** Repository whose GitHub credentials are needed; omitted for unscoped access. */
107
+ repository?: string;
108
+ signal: AbortSignal;
109
+ }
110
+ interface GitHubHostOptions {
111
+ credentials: (context: GitHubHostCredentialContext) => GitHubHostCredentials | Promise<GitHubHostCredentials>;
112
+ /** A `fetch` for Forge requests, for tests and runtimes without a global one. */
113
+ fetch?: typeof fetch;
114
+ identity?: {
115
+ appId?: number;
116
+ email?: string;
117
+ login?: string;
118
+ };
119
+ maxBuffer?: number;
120
+ /** Forge request timeout in milliseconds. Default 60000. */
121
+ timeout?: number;
122
+ userAgent?: string;
123
+ /**
124
+ * `false` stops Forge providers from revalidating repeated GETs with `If-None-Match`. Default: on. Entries are
125
+ * kept per App installation, so they survive the hourly token rotation, or per token without an App.
126
+ */
127
+ conditionalRequests?: boolean;
128
+ }
129
+ interface GitHubHostAccess {
130
+ /**
131
+ * Environment for `gh` and `git`: `GH_TOKEN`, `GITHUB_TOKEN`, and the commit identity. With a `repository`,
132
+ * it also has the Git credentials for that repository in `GIT_CONFIG_KEY_<n>` and `GIT_CONFIG_VALUE_<n>`.
133
+ */
134
+ env: Record<string, string>;
135
+ token: string;
136
+ }
137
+ interface GitHubHostPullRequest {
138
+ headRef?: string;
139
+ headRepository?: string;
140
+ headSha: string;
141
+ number: number;
142
+ repository: string;
143
+ }
144
+ interface GitHubHostCheckout extends GitHubHostAccess {
145
+ path: string;
146
+ /**
147
+ * Restore source instruction files only before the provider injects its instructions. For the
148
+ * `persistent.work` directory, `reuse` keeps its ignored files when the tracked tree matches the
149
+ * head, and the result says whether it did. `complete` checks the whole head out into another
150
+ * directory the caller owns, the way the `persistent.work` directory is prepared.
151
+ */
152
+ prepareWorkspace(target: string, options?: {
153
+ restoreInstructions?: boolean;
154
+ reuse?: boolean;
155
+ reason?: string;
156
+ complete?: boolean;
157
+ }): Promise<{
158
+ reused: boolean;
159
+ reason: GitHubWorkspaceReuse;
160
+ } | void>;
161
+ commitRepair(target: string, input: GitHubRepairCommit, options?: {
162
+ verifyDependencies?: boolean;
163
+ }): Promise<string>;
164
+ push(target?: string, options?: {
165
+ signal?: AbortSignal;
166
+ beforePush?: (head?: string) => void | Promise<void>;
167
+ afterPush?: (head: string) => void | Promise<void>;
168
+ }): Promise<string>;
169
+ signal: AbortSignal;
170
+ }
171
+ interface GitHubHostCheckoutOptions {
172
+ signal?: AbortSignal;
173
+ timeout?: number;
174
+ /**
175
+ * Keep the host clone in `checkout` after the callback and fetch into it next time instead of
176
+ * cloning. `work` is the provider workspace that `prepareWorkspace` keeps between calls.
177
+ */
178
+ persistent?: {
179
+ checkout: string;
180
+ work: string;
181
+ };
182
+ }
183
+ interface GitHubHostForgeOptions extends GitHubHostCheckoutOptions {
184
+ /** Repository whose credentials the provider uses; omitted for unscoped access. */
185
+ repository?: string;
186
+ }
187
+ interface GitHubHostAccessOptions extends GitHubHostCheckoutOptions {
188
+ fallback?: boolean;
189
+ refresh?: boolean;
190
+ /** Mint a new App installation token when the cached one expires within this many milliseconds. */
191
+ minLifetime?: number;
192
+ repository?: string;
193
+ }
194
+ /** A GitHub rate limit that the response headers of this host's Forge requests reported. */
195
+ interface GitHubHostRateLimit {
196
+ /** The GitHub rate limit resource, for example `core` or `graphql`. */
197
+ resource: string;
198
+ limit: number;
199
+ remaining: number;
200
+ resetAt: number;
201
+ checkedAt: number;
202
+ }
203
+ interface GitHubHost {
204
+ channel(options?: Omit<GitHubChannelOptions, "app">): AgentChannelDefinition;
205
+ /** Return the verified login configured for this host, when available. */
206
+ identity(): string | undefined;
207
+ /** Immutable GitHub App ID for managed activity ownership. */
208
+ appId?(): number | undefined;
209
+ /** Resolve credentials and Git binding for the current checkout callback. */
210
+ environment(): Promise<Record<string, string>>;
211
+ access(input?: GitHubHostAccessOptions): Promise<GitHubHostAccess>;
212
+ /**
213
+ * A `forges` GitHub provider with the repository's credentials. It has every Forge verb and `graphql()`.
214
+ * Create one for each operation: installation tokens expire after one hour.
215
+ */
216
+ forge(input?: GitHubHostForgeOptions): Promise<GitHubProvider>;
217
+ /** The most constrained rate limit that recent Forge responses reported, or undefined before the first response. */
218
+ rateLimit(): GitHubHostRateLimit | undefined;
219
+ withPullRequestCheckout<T>(pullRequest: GitHubHostPullRequest, run: (checkout: GitHubHostCheckout) => Promise<T>, options?: GitHubHostCheckoutOptions): Promise<T>;
220
+ }
221
+ interface GitHubAppEnvironment {
222
+ appId: number;
223
+ privateKey: string;
224
+ /** Fixed installation of `owner`, which it needs. Repositories of other owners use `installations` or discovery. */
225
+ installationId?: number;
226
+ /** Repository owner of `installationId`. */
227
+ owner?: string;
228
+ /** Explicit installation IDs by repository owner. */
229
+ installations?: Record<string, number>;
230
+ /** Fallback token for repositories without an App installation. */
231
+ token?: string;
232
+ userAgent?: string;
233
+ }
234
+ /**
235
+ * GitHub App credentials for `createGitHubHost()` that resolve the installation of each
236
+ * repository from the App, and the App's bot identity for commits. Results are cached.
237
+ */
238
+ declare function createGitHubAppCredentials(app: GitHubAppEnvironment): {
239
+ credentials(context: GitHubHostCredentialContext): Promise<GitHubHostCredentials>;
240
+ /** Every repository that the App's installations can access. */
241
+ repositories: (signal?: AbortSignal) => Promise<GitHubAppRepository[]>;
242
+ /** Failed App webhook deliveries since `since` that no later attempt delivered, oldest first. */
243
+ failedDeliveries: (since: number, signal?: AbortSignal) => Promise<GitHubAppDelivery[]>;
244
+ /** Sends one App webhook delivery again. */
245
+ redeliver: (id: string, signal?: AbortSignal) => Promise<void>;
246
+ /** The App bot's login and noreply email, used as the commit author. */
247
+ identity(): Promise<{
248
+ appId: number;
249
+ login: string;
250
+ email: string;
251
+ }>;
252
+ };
253
+ declare function createGitHubHost(options: GitHubHostOptions): GitHubHost;
254
+ //#endregion
255
+ //#region src/github/required-checks.d.ts
256
+ type GitHubRequiredCheckState = "pending" | "failed" | "passed" | "unknown";
257
+ //#endregion
5
258
  //#region src/babysitter/inbox/types.d.ts
6
259
  interface GitHubActor {
7
260
  login?: string;
@@ -101,7 +354,8 @@ interface GitHubEvidence extends GitHubTimestamps {
101
354
  commit_id?: string;
102
355
  original_commit_id?: string;
103
356
  commit?: {
104
- oid: string;
357
+ [key: string]: unknown;
358
+ oid?: string;
105
359
  } | null;
106
360
  pull_request_review_id?: number;
107
361
  in_reply_to_id?: number;
@@ -135,72 +389,6 @@ interface GitHubReviewThread {
135
389
  resolutionObservedAt?: string;
136
390
  }
137
391
  //#endregion
138
- //#region src/babysitter/inbox/budgets.d.ts
139
- interface ProviderBudget {
140
- generation: string;
141
- maxRetries: number;
142
- nextAttempt: number;
143
- succeededThrough: number;
144
- pending: number[];
145
- failures: number[];
146
- resetReason?: string;
147
- }
148
- type ProviderAttempt = {
149
- provider: string;
150
- generation: string;
151
- attempt: number;
152
- };
153
- type ProviderAttemptOutcome = "success" | "retryable-failure" | "other-failure";
154
- /** New evidence that gives an exhausted head one more pass, once per head. */
155
- type ProgressGrant = "conflict" | "bot-feedback";
156
- interface ProgressBudget {
157
- head: string;
158
- limit: number;
159
- count: number;
160
- exhausted: boolean;
161
- evidence?: string;
162
- creditedEvidence: string[];
163
- resetReason?: string;
164
- grants?: ProgressGrant[];
165
- }
166
- /**
167
- * The host verifies progress from GitHub/provider state, never from Agent prose. `reviewDriven` marks a
168
- * push whose pass had no merge conflict and no failing check outside the review checks; the host
169
- * decides it from the claimed snapshot.
170
- */
171
- type ProgressOutcome = {
172
- kind: "no-progress";
173
- } | {
174
- kind: "verified";
175
- evidence: string;
176
- reviewDriven?: boolean;
177
- };
178
- /**
179
- * Review-driven pushes on one PR, over its whole life. `heads` lists the heads that this worker pushed
180
- * and, once the budget is spent, the heads that already got a model pass. A head outside it was moved
181
- * by someone else.
182
- */
183
- interface ReviewPushBudget {
184
- count: number;
185
- heads: string[];
186
- }
187
- /**
188
- * Model passes on one PR in the last 24 hours. `passes` holds the time each pass started the model.
189
- * `human` is the generation of the last person's feedback that a pass saw. `exemptions` lists the
190
- * exemptions already used, so each applies once.
191
- */
192
- interface DailyPassBudget {
193
- passes: number[];
194
- human?: number;
195
- exemptions: string[];
196
- }
197
- interface InboxBudgets {
198
- providerRetries?: number;
199
- noProgress?: number;
200
- reviewPushes?: number;
201
- dailyPasses?: number;
202
- }
203
- //#endregion
204
392
  //#region src/babysitter/inbox/wait-state.d.ts
205
393
  type PullRequestWake = {
206
394
  kind: "checks";
@@ -233,7 +421,7 @@ type PullRequestWait = {
233
421
  //#region src/babysitter/inbox/storage.d.ts
234
422
  /**
235
423
  * SQL access for the PR inbox. `agentState.extension("babysitter")` from
236
- * `@vite-hub/agent/state/sqlite` satisfies it and keeps the inbox in the Agent State database.
424
+ * `@vite-hub/agent/state` satisfies it and keeps the inbox in the Agent State database.
237
425
  */
238
426
  interface PullRequestInboxStorage extends Pick<SqliteAgentStateExtension, "execute" | "tablePrefix" | "transaction"> {
239
427
  close?: () => Promise<void>;
@@ -301,6 +489,8 @@ type Snapshot = {
301
489
  heads: string[];
302
490
  };
303
491
  threadReopens?: Record<string, number>;
492
+ /** Authenticated outcome replies, including IDs used by thread-only reads. */
493
+ ownedReviewCommentIds?: string[];
304
494
  hydrated: boolean;
305
495
  refresh: boolean;
306
496
  feedbackRefresh: boolean;
@@ -357,6 +547,8 @@ type Claim = {
357
547
  runId?: string;
358
548
  startedAt?: number;
359
549
  activity?: AgentRunActivity;
550
+ /** The pass's class of the automated review of the claimed head. `finish()` records it with `budgets.minorReviewRounds`. */
551
+ automatedReview?: AutomatedReviewClass;
360
552
  };
361
553
  type DirectMergeAttempt = {
362
554
  token: string;
@@ -366,6 +558,7 @@ type DirectMergeAttempt = {
366
558
  startedAt: number;
367
559
  asynchronous?: boolean;
368
560
  enqueued?: boolean;
561
+ foldInto?: number;
369
562
  };
370
563
  interface PullRequestInboxOptions {
371
564
  /** A private `node:sqlite` file. Use `storage` instead to keep the inbox in the Agent State database. */
@@ -374,12 +567,19 @@ interface PullRequestInboxOptions {
374
567
  storage?: PullRequestInboxStorage;
375
568
  /** Separates inboxes that share one storage, for example one per Agent. */
376
569
  scope?: string;
377
- repositories: readonly string[];
570
+ /** The served repositories, or a function that returns the current lowercase list on each read. */
571
+ repositories: readonly string[] | (() => readonly string[]);
378
572
  filter?: GitHubPullRequestFilter;
379
573
  clock?: () => number;
380
574
  activityAuthors?: readonly string[];
381
575
  activityAppId?: number;
382
576
  budgets?: InboxBudgets;
577
+ /** Labels that put a PR first in the claim order after main repairs. Matched case-insensitively. */
578
+ priorityLabels?: readonly string[];
579
+ /** Head branch prefix of PRs that repair the base branch. They are claimed first and never exhaust `budgets.noProgress`. */
580
+ mainRepairBranchPrefix?: string;
581
+ /** Claim a PR whose base is another open PR's branch. By default it waits until its parent merges. */
582
+ claimStackChildren?: boolean;
383
583
  /**
384
584
  * Called once per process for each stored PR row that fails validation. The inbox skips such a row
385
585
  * in claims, summaries and wait evaluation, so one bad row cannot stop the queue or its health.
@@ -402,15 +602,18 @@ declare class PullRequestInbox {
402
602
  private scope;
403
603
  private ready?;
404
604
  private tables;
405
- private repositories;
605
+ private repositoryList;
406
606
  private clock;
407
607
  private filter?;
408
608
  private activityAuthors;
409
609
  private activityAppId?;
410
610
  private budgets;
611
+ private priorityLabels;
612
+ private mainRepairBranchPrefix?;
613
+ private claimStackChildren;
411
614
  private invalidRow?;
412
615
  private reportedRows;
413
- constructor({ path, storage, scope, repositories, filter, clock, budgets, activityAuthors, activityAppId, invalidRow }: PullRequestInboxOptions);
616
+ constructor({ path, storage, scope, repositories, filter, clock, budgets, activityAuthors, activityAppId, priorityLabels, mainRepairBranchPrefix, claimStackChildren, invalidRow }: PullRequestInboxOptions);
414
617
  close(): Promise<void>;
415
618
  private init;
416
619
  private transaction;
@@ -418,9 +621,12 @@ declare class PullRequestInbox {
418
621
  /** Parses one stored row. An invalid row is reported once and skipped by queue-wide reads. */
419
622
  private parseRow;
420
623
  private reportInvalidRow;
624
+ private get repositories();
421
625
  private repositoryFilter;
422
626
  private ownsComment;
423
627
  private isActivityComment;
628
+ private isOutcomeComment;
629
+ private cleanReviewComments;
424
630
  private cleanSnapshot;
425
631
  private getIn;
426
632
  /** A snapshot for a queue-wide scan. An invalid row is reported and skipped. */
@@ -437,8 +643,8 @@ declare class PullRequestInbox {
437
643
  metaNumber(key: string): Promise<number | undefined>;
438
644
  /** Metadata entries whose keys start with `prefix`. */
439
645
  metaEntries(prefix: string): Promise<Array<[string, unknown]>>;
440
- deleteMeta(key: string): Promise<void>;
441
- setMeta(key: string, value: unknown): Promise<void>;
646
+ deleteMeta(key: string, signal?: AbortSignal): Promise<void>;
647
+ setMeta(key: string, value: unknown, signal?: AbortSignal): Promise<void>;
442
648
  private enqueueStatusResult;
443
649
  private statusWritersIn;
444
650
  private settleStatusWriterIn;
@@ -456,13 +662,21 @@ declare class PullRequestInbox {
456
662
  reconcileSettledStatusWriter(observed: StatusDelivery): Promise<boolean>;
457
663
  private reconcileStatusWriterIn;
458
664
  /** Upgrade historical waiting results without synthetic webhooks or model passes. */
459
- backfillStatusDeliveries(): Promise<void>;
665
+ backfillStatusDeliveries(signal?: AbortSignal): Promise<void>;
460
666
  recordWorkerBlocker(observed: Snapshot, revision: string): Promise<void>;
461
667
  /** Wake and persist its release marker atomically, so restart cannot repeat the wake. */
462
668
  wakeForWorkerRelease(observed: Snapshot, revision: string, evidenceKey: string): Promise<boolean>;
463
669
  private directMergeKey;
464
- /** Atomically records that a claim has started an irreversible merge request. */
465
- beginDirectMerge(claim: Claim, head: string, asynchronous?: boolean): Promise<boolean>;
670
+ private stackFoldKey;
671
+ /** The stacked pull request whose merge into this pull request's branch has an unknown outcome. */
672
+ private foldingChildIn;
673
+ foldingChild(repository: string, parent: number): Promise<number | undefined>;
674
+ /**
675
+ * Atomically records that a claim has started an irreversible merge request. With `foldInto`, the merge
676
+ * targets that open parent's branch. A parent with a merge in flight refuses the fold, and a parent with
677
+ * a fold in flight refuses its own merge, so a fold never lands on a branch that already merged.
678
+ */
679
+ beginDirectMerge(claim: Claim, head: string, asynchronous?: boolean, foldInto?: number): Promise<boolean>;
466
680
  directMergeAttempt(repository: string, number: number): Promise<DirectMergeAttempt | undefined>;
467
681
  /** Preserve a final enqueued result. */
468
682
  recordDirectMergeEnqueued(repository: string, number: number, token: string): Promise<boolean>;
@@ -476,17 +690,22 @@ declare class PullRequestInbox {
476
690
  resetProgressBudget(repository: string, number: number, head: string, reason: string): Promise<boolean>;
477
691
  private dirty;
478
692
  private updatePr;
693
+ /** Whether the PR carries one of `priorityLabels`. */
694
+ isPriority(pr: GitHubPullRequestRecord | null | undefined): boolean;
695
+ /** Whether the PR's head branch starts with `mainRepairBranchPrefix`. */
696
+ isMainRepair(pr: GitHubPullRequestRecord | null | undefined): boolean;
479
697
  eligible(repository: string, pr: GitHubPullRequestRecord | null): boolean;
480
- seed(repository: string, value: unknown): Promise<Snapshot>;
481
- ingest(id: string, event: string, value: unknown): Promise<GitHubInboxDeliveryResult>;
698
+ seed(repository: string, value: unknown, signal?: AbortSignal): Promise<Snapshot>;
699
+ ingest(id: string, event: string, value: unknown, signal?: AbortSignal): Promise<GitHubInboxDeliveryResult>;
482
700
  /** Leases up to `limit` eligible PRs. `skip` leaves a candidate unclaimed for this call. */
483
701
  claim(limit: number, options?: {
484
702
  only?: (snapshot: Snapshot) => boolean;
485
703
  skip?: (snapshot: Snapshot) => boolean;
486
704
  includeBlocked?: boolean;
705
+ signal?: AbortSignal;
487
706
  }): Promise<Claim[]>;
488
707
  hydrate(claim: Claim, patch: SnapshotPatch): Promise<boolean>;
489
- refreshThreads(observed: Snapshot, threads: GitHubReviewThread[]): Promise<boolean>;
708
+ refreshThreads(observed: Snapshot, threads: GitHubReviewThread[], signal?: AbortSignal): Promise<boolean>;
490
709
  /** Retain a worker's verified thread resolution even when its webhook is missing. */
491
710
  recordThreadResolution(claim: Claim, id: string, observed: Snapshot): Promise<boolean>;
492
711
  /** Retain CI for an exact candidate before its source-push webhook arrives. This is not a publication receipt. */
@@ -497,7 +716,12 @@ declare class PullRequestInbox {
497
716
  * Records that a claimed pass started the model, with the exemption that let it run past
498
717
  * `budgets.dailyPasses`. It changes no evidence, so the claim stays current.
499
718
  */
500
- recordModelPass(claim: Claim, exemption?: string): Promise<boolean>;
719
+ recordModelPass(claim: Claim, exemption?: string): Promise<number | false>;
720
+ /**
721
+ * Gives back the pass that `recordModelPass` counted at `at`, and its exemption, when the provider
722
+ * failed the pass before it did any work. It changes no evidence, so the claim stays current.
723
+ */
724
+ releaseModelPass(claim: Claim, at: number, exemption?: string): Promise<boolean>;
501
725
  /** Checks the durable claim fence immediately before an irreversible provider action. */
502
726
  isClaimCurrent(claim: Claim): Promise<boolean>;
503
727
  /**
@@ -535,17 +759,18 @@ declare class PullRequestInbox {
535
759
  /** Waiting PRs that received events since the host last evaluated their wait. */
536
760
  waitsToEvaluate(includeExternal?: boolean, includeIdle?: boolean): Promise<Snapshot[]>;
537
761
  /** Records that the host evaluated a wait's new events and the wait still holds. */
538
- acknowledgeWait(observed: Snapshot): Promise<boolean>;
762
+ acknowledgeWait(observed: Snapshot, signal?: AbortSignal): Promise<boolean>;
539
763
  /** Re-evaluate structured evidence outside an Agent invocation before calling this method. */
540
764
  wake(observed: Snapshot, evidenceKey: string, options?: {
541
765
  recovery?: boolean;
766
+ signal?: AbortSignal;
542
767
  }): Promise<boolean>;
543
768
  /**
544
769
  * Frees every lease in this scope at startup and returns how many were held. Call it only when one
545
770
  * process owns the scope: a pass cannot survive a restart, so its lease only delays the PR.
546
771
  */
547
772
  releaseLeases(): Promise<number>;
548
- recoverLeases(): Promise<void>;
773
+ recoverLeases(signal?: AbortSignal): Promise<void>;
549
774
  summary(): Promise<GitHubInboxSummary[]>;
550
775
  /** The open, unleased PR that a reconciliation probe checked longest ago, with that probe time. */
551
776
  nextProbe(): Promise<{
@@ -565,9 +790,10 @@ declare class PullRequestInbox {
565
790
  deliveries: number;
566
791
  }>;
567
792
  /** Drops delivery payloads after `payloadMs` and delivery IDs after `idMs`. Recent IDs still deduplicate redeliveries. */
568
- pruneDeliveries({ payloadMs, idMs }?: {
793
+ pruneDeliveries({ payloadMs, idMs, signal }?: {
569
794
  payloadMs?: number;
570
795
  idMs?: number;
796
+ signal?: AbortSignal;
571
797
  }): Promise<void>;
572
798
  }
573
799
  //#endregion
@@ -601,7 +827,7 @@ interface BabysitterAdmissionOptions {
601
827
  * Extra check before each claim, for example a provider quota. Return a pause to stop model
602
828
  * passes, or `undefined` to continue. An error is reported in health and does not pause.
603
829
  */
604
- check?: () => BabysitterAdmissionPause | undefined | Promise<BabysitterAdmissionPause | undefined>;
830
+ check?: (signal?: AbortSignal) => BabysitterAdmissionPause | undefined | Promise<BabysitterAdmissionPause | undefined>;
605
831
  }
606
832
  /** Token limits are best-effort retained-journal thresholds, not billing caps. */
607
833
  interface BabysitterAdmissionLimits {
@@ -636,4 +862,65 @@ interface BabysitterAdmissionResult {
636
862
  limits: BabysitterAdmissionLimits;
637
863
  }
638
864
  //#endregion
639
- export { Snapshot as a, PullRequestInbox as i, BabysitterAdmissionPause as n, PullRequestInboxStorage as o, BabysitterAdmissionResult as r, BabysitterAdmissionOptions as t };
865
+ //#region src/babysitter/pr-workspaces.d.ts
866
+ /** Keep one workspace per open PR between passes. See `BabysitterOptions.warmWorkspaces`. */
867
+ interface BabysitterWarmWorkspaces {
868
+ /**
869
+ * Continue the previous pass's provider thread when this pass starts in a warm workspace on the
870
+ * same base commit and release, after a pass that pushed or recorded a wait. Defaults to `false`.
871
+ */
872
+ resumeThreads?: boolean;
873
+ /** Disk the kept workspaces may use, in GiB. Least recently used entries go first. Defaults to 60. */
874
+ budgetGb?: number;
875
+ /** Days without a pass after which a PR's workspace is removed. Defaults to 7. */
876
+ idleDays?: number;
877
+ /** Free space, in percent of the filesystem, below which least recently used entries go. Defaults to 15. */
878
+ minFreePercent?: number;
879
+ /** Minutes between sweeps of terminal, idle and over-budget entries. `0` sweeps only at startup. Defaults to 60. */
880
+ sweepMinutes?: number;
881
+ }
882
+ /** What a pass left in its PR workspace. The next pass decides from it whether to keep the tree. */
883
+ interface PullRequestWorkspaceRecord {
884
+ /** The head the workspace holds: the pass's push, or the head it started on. */
885
+ head: string;
886
+ /** The base commit the pass started on. */
887
+ base?: string;
888
+ /** The pass finished without an error, so its tree and installed dependencies are complete. */
889
+ ok: boolean;
890
+ /** The pass pushed or recorded a wait, so its provider thread may continue. */
891
+ resumable?: boolean;
892
+ release?: string;
893
+ /** The provider thread suffix the pass ran in. */
894
+ session?: string;
895
+ outcome?: string;
896
+ }
897
+ interface PullRequestWorkspaceEntry {
898
+ /** The trusted host clone. */
899
+ checkout: string;
900
+ /** The provider workspace, used as `driver.cwd`. */
901
+ work: string;
902
+ /** Whether a provider workspace existed before this pass. */
903
+ existed: boolean;
904
+ previous?: PullRequestWorkspaceRecord;
905
+ record(result: PullRequestWorkspaceRecord): Promise<void>;
906
+ release(): Promise<void>;
907
+ }
908
+ type PullRequestWorkspaceStatus = "open" | "terminal" | "unknown";
909
+ interface PullRequestWorkspaces {
910
+ root: string;
911
+ resumeThreads: boolean;
912
+ sweepMs: number;
913
+ /** Locks the PR's entry for one pass. A pass that ends without `record()` leaves a failed record. */
914
+ acquire(repository: string, number: number, signal?: AbortSignal): Promise<PullRequestWorkspaceEntry>;
915
+ /** Removes terminal, unknown and idle entries, then least recently used ones while over budget or low on disk. */
916
+ sweep(status: (repository: string, number: number) => Promise<PullRequestWorkspaceStatus>): Promise<{
917
+ removed: {
918
+ name: string;
919
+ reason: string;
920
+ }[];
921
+ keptBytes: number;
922
+ kept: number;
923
+ }>;
924
+ }
925
+ //#endregion
926
+ export { createGitHubAppCredentials as C, GitHubHostSecret as S, AutomatedReviewClass as T, GitHubHostCredentials as _, BabysitterAdmissionResult as a, GitHubHostPullRequest as b, PullRequestInboxStorage as c, GitHubHost as d, GitHubHostAccess as f, GitHubHostCredentialContext as g, GitHubHostCheckoutOptions as h, BabysitterAdmissionPause as i, GitHubRequiredCheckState as l, GitHubHostCheckout as m, PullRequestWorkspaces as n, PullRequestInbox as o, GitHubHostAccessOptions as p, BabysitterAdmissionOptions as r, Snapshot as s, BabysitterWarmWorkspaces as t, GitHubAppEnvironment as u, GitHubHostForgeOptions as v, createGitHubHost as w, GitHubHostRateLimit as x, GitHubHostOptions as y };