@vite-hub/presets 0.3.1 → 0.5.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/README.md +44 -14
- package/dist/babysitter/server.d.ts +35 -4
- package/dist/babysitter/server.js +1 -1
- package/dist/{babysitter-C71pgjkv.js → babysitter-B5C0KLRl.js} +158 -50
- package/dist/babysitter.d.ts +24 -2
- package/dist/babysitter.js +1 -1
- package/dist/{error-diagnostics-BTBW9sZx.js → error-diagnostics-o3pHscWs.js} +5 -1
- package/dist/{host-Dsi6saqi.js → host-gF2JTvw8.js} +123 -95
- package/dist/labeller.d.ts +6 -2
- package/dist/labeller.js +2 -1
- package/dist/{pr-workspaces-CjX3PSqM.d.ts → pr-workspaces-QjQyRB6g.d.ts} +108 -25
- package/dist/{server-CIgjUG63.js → server-Bj5_Uf_Y.js} +1235 -301
- package/package.json +9 -9
|
@@ -107,15 +107,21 @@ interface GitHubHostCredentialContext {
|
|
|
107
107
|
repository?: string;
|
|
108
108
|
signal: AbortSignal;
|
|
109
109
|
}
|
|
110
|
+
/** The GitHub user or App bot that commits and comments for the host. */
|
|
111
|
+
interface GitHubHostIdentity {
|
|
112
|
+
appId?: number;
|
|
113
|
+
email?: string;
|
|
114
|
+
login?: string;
|
|
115
|
+
}
|
|
110
116
|
interface GitHubHostOptions {
|
|
111
117
|
credentials: (context: GitHubHostCredentialContext) => GitHubHostCredentials | Promise<GitHubHostCredentials>;
|
|
112
118
|
/** A `fetch` for Forge requests, for tests and runtimes without a global one. */
|
|
113
119
|
fetch?: typeof fetch;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Commit author and comment owner. Default: the GitHub App bot of the App credentials, such as
|
|
122
|
+
* `my-app[bot]` with its noreply email. Set it for a token without an App.
|
|
123
|
+
*/
|
|
124
|
+
identity?: GitHubHostIdentity;
|
|
119
125
|
maxBuffer?: number;
|
|
120
126
|
/** Forge request timeout in milliseconds. Default 60000. */
|
|
121
127
|
timeout?: number;
|
|
@@ -135,6 +141,8 @@ interface GitHubHostAccess {
|
|
|
135
141
|
token: string;
|
|
136
142
|
}
|
|
137
143
|
interface GitHubHostPullRequest {
|
|
144
|
+
/** Base branch. With it, `push()` tells `beforePush` whether every new commit outside the base is the host's. */
|
|
145
|
+
baseRef?: string;
|
|
138
146
|
headRef?: string;
|
|
139
147
|
headRepository?: string;
|
|
140
148
|
headSha: string;
|
|
@@ -163,11 +171,21 @@ interface GitHubHostCheckout extends GitHubHostAccess {
|
|
|
163
171
|
}): Promise<string>;
|
|
164
172
|
push(target?: string, options?: {
|
|
165
173
|
signal?: AbortSignal;
|
|
166
|
-
beforePush?: (head?: string) => void | Promise<void>;
|
|
174
|
+
beforePush?: (head?: string, lineage?: GitHubHostPushLineage) => void | Promise<void>;
|
|
167
175
|
afterPush?: (head: string) => void | Promise<void>;
|
|
168
176
|
}): Promise<string>;
|
|
169
177
|
signal: AbortSignal;
|
|
170
178
|
}
|
|
179
|
+
/** How a pushed head relates to the head it replaces. */
|
|
180
|
+
interface GitHubHostPushLineage {
|
|
181
|
+
/** The pull request head that the push replaces. The pushed head descends from it. */
|
|
182
|
+
parent: string;
|
|
183
|
+
/**
|
|
184
|
+
* Every commit that the push adds, apart from commits on the base branch, is one that `commitRepair()`
|
|
185
|
+
* made in this checkout. A provider that fetches and merges someone else's commits makes this `false`.
|
|
186
|
+
*/
|
|
187
|
+
hostOnly: boolean;
|
|
188
|
+
}
|
|
171
189
|
interface GitHubHostCheckoutOptions {
|
|
172
190
|
signal?: AbortSignal;
|
|
173
191
|
timeout?: number;
|
|
@@ -190,6 +208,12 @@ interface GitHubHostAccessOptions extends GitHubHostCheckoutOptions {
|
|
|
190
208
|
/** Mint a new App installation token when the cached one expires within this many milliseconds. */
|
|
191
209
|
minLifetime?: number;
|
|
192
210
|
repository?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Repository whose App installation mints the token, when it is not `repository`. Git still sends the
|
|
213
|
+
* token only to `repository`. A fork without the App uses its base repository's installation, whose
|
|
214
|
+
* token may push to the fork's branch while its author allows edits by maintainers.
|
|
215
|
+
*/
|
|
216
|
+
installationRepository?: string;
|
|
193
217
|
}
|
|
194
218
|
/** A GitHub rate limit that the response headers of this host's Forge requests reported. */
|
|
195
219
|
interface GitHubHostRateLimit {
|
|
@@ -244,11 +268,7 @@ declare function createGitHubAppCredentials(app: GitHubAppEnvironment): {
|
|
|
244
268
|
/** Sends one App webhook delivery again. */
|
|
245
269
|
redeliver: (id: string, signal?: AbortSignal) => Promise<void>;
|
|
246
270
|
/** 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
|
-
}>;
|
|
271
|
+
identity(): Promise<Required<GitHubHostIdentity>>;
|
|
252
272
|
};
|
|
253
273
|
declare function createGitHubHost(options: GitHubHostOptions): GitHubHost;
|
|
254
274
|
//#endregion
|
|
@@ -458,6 +478,13 @@ interface StatusDelivery {
|
|
|
458
478
|
};
|
|
459
479
|
}
|
|
460
480
|
//#endregion
|
|
481
|
+
//#region src/babysitter/approval.d.ts
|
|
482
|
+
/** A head that the host pushed, with the head it replaced. Only heads whose new commits are all the host's own are recorded. */
|
|
483
|
+
interface HostHead {
|
|
484
|
+
head: string;
|
|
485
|
+
parent: string;
|
|
486
|
+
}
|
|
487
|
+
//#endregion
|
|
461
488
|
//#region src/babysitter/inbox/store.d.ts
|
|
462
489
|
type Snapshot = {
|
|
463
490
|
repository: string;
|
|
@@ -488,6 +515,10 @@ type Snapshot = {
|
|
|
488
515
|
token: string;
|
|
489
516
|
heads: string[];
|
|
490
517
|
};
|
|
518
|
+
/** Heads the host pushed whose new commits are all its own, oldest first. An approval carries over along them. */
|
|
519
|
+
hostHeads?: HostHead[];
|
|
520
|
+
/** Heads the host asked GitHub to update with the base. The host's own `synchronize` from one adds a `hostHeads` entry. */
|
|
521
|
+
hostUpdates?: string[];
|
|
491
522
|
threadReopens?: Record<string, number>;
|
|
492
523
|
/** Authenticated outcome replies, including IDs used by thread-only reads. */
|
|
493
524
|
ownedReviewCommentIds?: string[];
|
|
@@ -570,6 +601,16 @@ interface PullRequestInboxOptions {
|
|
|
570
601
|
/** The served repositories, or a function that returns the current lowercase list on each read. */
|
|
571
602
|
repositories: readonly string[] | (() => readonly string[]);
|
|
572
603
|
filter?: GitHubPullRequestFilter;
|
|
604
|
+
/**
|
|
605
|
+
* Also admit an open PR that `filter`'s author rules leave out while a reviewer with write access
|
|
606
|
+
* approves its current head, or a head the host built on the approved one. Every other rule still applies.
|
|
607
|
+
*/
|
|
608
|
+
admitApproved?: boolean;
|
|
609
|
+
/**
|
|
610
|
+
* The time in Unix milliseconds, for tests. By default a shared `storage` inbox follows the clock of its database:
|
|
611
|
+
* it reads that clock at most every 30 seconds and counts elapsed time from there, so servers with different host
|
|
612
|
+
* clocks agree when a lease expires. A private `path` inbox has one host and uses `Date.now`.
|
|
613
|
+
*/
|
|
573
614
|
clock?: () => number;
|
|
574
615
|
activityAuthors?: readonly string[];
|
|
575
616
|
activityAppId?: number;
|
|
@@ -604,7 +645,11 @@ declare class PullRequestInbox {
|
|
|
604
645
|
private tables;
|
|
605
646
|
private repositoryList;
|
|
606
647
|
private clock;
|
|
648
|
+
private usesDatabaseClock;
|
|
649
|
+
private clockSample?;
|
|
607
650
|
private filter?;
|
|
651
|
+
/** Whether a maintainer's approval admits an author the filter leaves out. */
|
|
652
|
+
readonly admitApproved: boolean;
|
|
608
653
|
private activityAuthors;
|
|
609
654
|
private activityAppId?;
|
|
610
655
|
private budgets;
|
|
@@ -613,9 +658,12 @@ declare class PullRequestInbox {
|
|
|
613
658
|
private claimStackChildren;
|
|
614
659
|
private invalidRow?;
|
|
615
660
|
private reportedRows;
|
|
616
|
-
constructor({ path, storage, scope, repositories, filter, clock, budgets, activityAuthors, activityAppId, priorityLabels, mainRepairBranchPrefix, claimStackChildren, invalidRow }: PullRequestInboxOptions);
|
|
661
|
+
constructor({ path, storage, scope, repositories, filter, admitApproved, clock, budgets, activityAuthors, activityAppId, priorityLabels, mainRepairBranchPrefix, claimStackChildren, invalidRow }: PullRequestInboxOptions);
|
|
617
662
|
close(): Promise<void>;
|
|
618
663
|
private init;
|
|
664
|
+
/** The current time on the inbox clock. Compare lease ends from the inbox with it, not with `Date.now()`. */
|
|
665
|
+
now(): number;
|
|
666
|
+
private syncClock;
|
|
619
667
|
private transaction;
|
|
620
668
|
private read;
|
|
621
669
|
/** Parses one stored row. An invalid row is reported once and skipped by queue-wide reads. */
|
|
@@ -643,8 +691,8 @@ declare class PullRequestInbox {
|
|
|
643
691
|
metaNumber(key: string): Promise<number | undefined>;
|
|
644
692
|
/** Metadata entries whose keys start with `prefix`. */
|
|
645
693
|
metaEntries(prefix: string): Promise<Array<[string, unknown]>>;
|
|
646
|
-
deleteMeta(key: string): Promise<void>;
|
|
647
|
-
setMeta(key: string, value: unknown): Promise<void>;
|
|
694
|
+
deleteMeta(key: string, signal?: AbortSignal): Promise<void>;
|
|
695
|
+
setMeta(key: string, value: unknown, signal?: AbortSignal): Promise<void>;
|
|
648
696
|
private enqueueStatusResult;
|
|
649
697
|
private statusWritersIn;
|
|
650
698
|
private settleStatusWriterIn;
|
|
@@ -662,7 +710,7 @@ declare class PullRequestInbox {
|
|
|
662
710
|
reconcileSettledStatusWriter(observed: StatusDelivery): Promise<boolean>;
|
|
663
711
|
private reconcileStatusWriterIn;
|
|
664
712
|
/** Upgrade historical waiting results without synthetic webhooks or model passes. */
|
|
665
|
-
backfillStatusDeliveries(): Promise<void>;
|
|
713
|
+
backfillStatusDeliveries(signal?: AbortSignal): Promise<void>;
|
|
666
714
|
recordWorkerBlocker(observed: Snapshot, revision: string): Promise<void>;
|
|
667
715
|
/** Wake and persist its release marker atomically, so restart cannot repeat the wake. */
|
|
668
716
|
wakeForWorkerRelease(observed: Snapshot, revision: string, evidenceKey: string): Promise<boolean>;
|
|
@@ -670,6 +718,11 @@ declare class PullRequestInbox {
|
|
|
670
718
|
private stackFoldKey;
|
|
671
719
|
/** The stacked pull request whose merge into this pull request's branch has an unknown outcome. */
|
|
672
720
|
private foldingChildIn;
|
|
721
|
+
/**
|
|
722
|
+
* A closed child's fold has a known outcome, and its pending-merge path never runs again to clear it.
|
|
723
|
+
* Retire the attempt with the parent's slot, so a reopened child must win the slot again before it folds.
|
|
724
|
+
*/
|
|
725
|
+
private retireFoldIn;
|
|
673
726
|
foldingChild(repository: string, parent: number): Promise<number | undefined>;
|
|
674
727
|
/**
|
|
675
728
|
* Atomically records that a claim has started an irreversible merge request. With `foldInto`, the merge
|
|
@@ -694,21 +747,49 @@ declare class PullRequestInbox {
|
|
|
694
747
|
isPriority(pr: GitHubPullRequestRecord | null | undefined): boolean;
|
|
695
748
|
/** Whether the PR's head branch starts with `mainRepairBranchPrefix`. */
|
|
696
749
|
isMainRepair(pr: GitHubPullRequestRecord | null | undefined): boolean;
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
750
|
+
/**
|
|
751
|
+
* Whether the runtime acts on `pr`. With `admitApproved`, a maintainer's approval of the head in
|
|
752
|
+
* `snapshot` admits an author the filter leaves out. `writers` holds the reviewers whose write
|
|
753
|
+
* permission the caller verified; without it, the review's association stands in, which only the
|
|
754
|
+
* inbox's own bookkeeping relies on before a pass checks again.
|
|
755
|
+
*/
|
|
756
|
+
eligible(repository: string, pr: GitHubPullRequestRecord | null, snapshot?: Pick<Snapshot, "reviews" | "hostHeads">, writers?: ReadonlySet<string>): boolean;
|
|
757
|
+
seed(repository: string, value: unknown, signal?: AbortSignal): Promise<Snapshot>;
|
|
758
|
+
ingest(id: string, event: string, value: unknown, signal?: AbortSignal): Promise<GitHubInboxDeliveryResult>;
|
|
700
759
|
/** Leases up to `limit` eligible PRs. `skip` leaves a candidate unclaimed for this call. */
|
|
701
760
|
claim(limit: number, options?: {
|
|
702
761
|
only?: (snapshot: Snapshot) => boolean;
|
|
703
762
|
skip?: (snapshot: Snapshot) => boolean;
|
|
704
763
|
includeBlocked?: boolean;
|
|
764
|
+
signal?: AbortSignal;
|
|
705
765
|
}): Promise<Claim[]>;
|
|
706
766
|
hydrate(claim: Claim, patch: SnapshotPatch): Promise<boolean>;
|
|
707
|
-
refreshThreads(observed: Snapshot, threads: GitHubReviewThread[]): Promise<boolean>;
|
|
767
|
+
refreshThreads(observed: Snapshot, threads: GitHubReviewThread[], signal?: AbortSignal): Promise<boolean>;
|
|
708
768
|
/** Retain a worker's verified thread resolution even when its webhook is missing. */
|
|
709
769
|
recordThreadResolution(claim: Claim, id: string, observed: Snapshot): Promise<boolean>;
|
|
710
|
-
/**
|
|
711
|
-
|
|
770
|
+
/**
|
|
771
|
+
* Retain CI for an exact candidate before its source-push webhook arrives. This is not a publication receipt.
|
|
772
|
+
* With `lineage.hostOnly`, it also records the head as the host's own work on `lineage.parent`, so an
|
|
773
|
+
* approval of that parent carries over to it.
|
|
774
|
+
*/
|
|
775
|
+
registerProspectivePush(claim: Claim, head: string, lineage?: {
|
|
776
|
+
parent: string;
|
|
777
|
+
hostOnly: boolean;
|
|
778
|
+
}): Promise<boolean>;
|
|
779
|
+
/**
|
|
780
|
+
* Records that the host asks GitHub to update the PR's branch from `from` with its base, before it sends
|
|
781
|
+
* the request. GitHub writes the merge commit and the response carries no SHA, so the `synchronize`
|
|
782
|
+
* delivery that the host's own identity sends from `from` records the new head as the host's work. A
|
|
783
|
+
* merges API call returns the commit: pass it as `head` to record it at once. Anything but a full commit
|
|
784
|
+
* SHA records nothing, so the approval does not carry over.
|
|
785
|
+
*/
|
|
786
|
+
registerHostUpdate(repository: string, number: number, from: string, head?: string): Promise<void>;
|
|
787
|
+
private addHostHead;
|
|
788
|
+
/**
|
|
789
|
+
* A webhook head move ends every pending update. Only the host's own move from a registered head carries an
|
|
790
|
+
* approval. A probe's synthetic `synchronize` has no `before` and leaves the updates for the webhook.
|
|
791
|
+
*/
|
|
792
|
+
private settleHostUpdate;
|
|
712
793
|
release(claim: Claim): Promise<boolean>;
|
|
713
794
|
renew(claim: Claim, leaseUntil: number): Promise<boolean>;
|
|
714
795
|
/**
|
|
@@ -758,17 +839,18 @@ declare class PullRequestInbox {
|
|
|
758
839
|
/** Waiting PRs that received events since the host last evaluated their wait. */
|
|
759
840
|
waitsToEvaluate(includeExternal?: boolean, includeIdle?: boolean): Promise<Snapshot[]>;
|
|
760
841
|
/** Records that the host evaluated a wait's new events and the wait still holds. */
|
|
761
|
-
acknowledgeWait(observed: Snapshot): Promise<boolean>;
|
|
842
|
+
acknowledgeWait(observed: Snapshot, signal?: AbortSignal): Promise<boolean>;
|
|
762
843
|
/** Re-evaluate structured evidence outside an Agent invocation before calling this method. */
|
|
763
844
|
wake(observed: Snapshot, evidenceKey: string, options?: {
|
|
764
845
|
recovery?: boolean;
|
|
846
|
+
signal?: AbortSignal;
|
|
765
847
|
}): Promise<boolean>;
|
|
766
848
|
/**
|
|
767
849
|
* Frees every lease in this scope at startup and returns how many were held. Call it only when one
|
|
768
850
|
* process owns the scope: a pass cannot survive a restart, so its lease only delays the PR.
|
|
769
851
|
*/
|
|
770
852
|
releaseLeases(): Promise<number>;
|
|
771
|
-
recoverLeases(): Promise<void>;
|
|
853
|
+
recoverLeases(signal?: AbortSignal): Promise<void>;
|
|
772
854
|
summary(): Promise<GitHubInboxSummary[]>;
|
|
773
855
|
/** The open, unleased PR that a reconciliation probe checked longest ago, with that probe time. */
|
|
774
856
|
nextProbe(): Promise<{
|
|
@@ -788,9 +870,10 @@ declare class PullRequestInbox {
|
|
|
788
870
|
deliveries: number;
|
|
789
871
|
}>;
|
|
790
872
|
/** Drops delivery payloads after `payloadMs` and delivery IDs after `idMs`. Recent IDs still deduplicate redeliveries. */
|
|
791
|
-
pruneDeliveries({ payloadMs, idMs }?: {
|
|
873
|
+
pruneDeliveries({ payloadMs, idMs, signal }?: {
|
|
792
874
|
payloadMs?: number;
|
|
793
875
|
idMs?: number;
|
|
876
|
+
signal?: AbortSignal;
|
|
794
877
|
}): Promise<void>;
|
|
795
878
|
}
|
|
796
879
|
//#endregion
|
|
@@ -824,7 +907,7 @@ interface BabysitterAdmissionOptions {
|
|
|
824
907
|
* Extra check before each claim, for example a provider quota. Return a pause to stop model
|
|
825
908
|
* passes, or `undefined` to continue. An error is reported in health and does not pause.
|
|
826
909
|
*/
|
|
827
|
-
check?: () => BabysitterAdmissionPause | undefined | Promise<BabysitterAdmissionPause | undefined>;
|
|
910
|
+
check?: (signal?: AbortSignal) => BabysitterAdmissionPause | undefined | Promise<BabysitterAdmissionPause | undefined>;
|
|
828
911
|
}
|
|
829
912
|
/** Token limits are best-effort retained-journal thresholds, not billing caps. */
|
|
830
913
|
interface BabysitterAdmissionLimits {
|