@vite-hub/presets 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/babysitter/server.d.ts +27 -5
- package/dist/babysitter/server.js +1 -2
- package/dist/{babysitter-DQeA81N0.js → babysitter-BvKD88Nz.js} +91 -52
- package/dist/babysitter.d.ts +14 -11
- package/dist/babysitter.js +1 -2
- package/dist/{error-diagnostics-o3pHscWs.js → error-diagnostics-FZJIIO9X.js} +2 -4
- package/dist/{host-DH0o7xSq.js → host-CJAPkRoP.js} +109 -57
- package/dist/labeller.d.ts +1 -2
- package/dist/labeller.js +2 -3
- package/dist/{pr-workspaces-CMdQ9U15.d.ts → pr-workspaces-CscUp4ts.d.ts} +93 -39
- package/dist/{server-ILDJE5V7.js → server-CpOkw38n.js} +501 -194
- package/dist/workspace.d.ts +0 -2
- package/dist/workspace.js +1 -2
- package/package.json +13 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as isRuntimeRecord, n as hasRuntimeType, t as presetsErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as isRuntimeRecord, n as hasRuntimeType, t as presetsErrorDiagnostics } from "./error-diagnostics-FZJIIO9X.js";
|
|
2
|
+
import { a as budgetParks, c as createGitHubHost, i as babysitterQueueHealth, o as pullRequestThreadId, s as createGitHubAppCredentials, t as createBabysitterRuntime } from "./server-CpOkw38n.js";
|
|
3
|
+
import { d as resolveBabysitterAdmissionLimits, f as sharedBabysitterRead, o as createPullRequestWorkspaces, r as resolveBabysitterLifecycleFilter, u as createBabysitterAdmission } from "./babysitter-BvKD88Nz.js";
|
|
4
4
|
import { defineAgent } from "@vite-hub/agent";
|
|
5
5
|
import { forgeErrorStatus, githubInstallationRouting } from "@vite-hub/forge";
|
|
6
6
|
import { channelEnv } from "@vite-hub/agent/channels";
|
|
@@ -22,8 +22,7 @@ const cleanCheckoutPoolScript = `
|
|
|
22
22
|
await rm(entry, { force: true, recursive: true, maxRetries: 5, retryDelay: 100 });
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
-
|
|
26
|
-
//#region src/babysitter/preflight.ts
|
|
25
|
+
// src/babysitter/preflight.ts
|
|
27
26
|
const execute = promisify(execFile);
|
|
28
27
|
async function validateExecutable(path) {
|
|
29
28
|
await access(path, constants.X_OK);
|
|
@@ -185,8 +184,7 @@ function createBabysitterPreflight(install, checkCommand = async (program, probe
|
|
|
185
184
|
}
|
|
186
185
|
};
|
|
187
186
|
}
|
|
188
|
-
|
|
189
|
-
//#region src/babysitter/repositories.ts
|
|
187
|
+
// src/babysitter/repositories.ts
|
|
190
188
|
/** How long the installation repository list stays fresh without an installation webhook. */
|
|
191
189
|
const installationRepositoriesTtlMs = 6e5;
|
|
192
190
|
const repositoryName = /^[\w.-]+\/[\w.-]+$/;
|
|
@@ -255,8 +253,7 @@ function babysitterRepositories(filter, read, { ttlMs = installationRepositories
|
|
|
255
253
|
}
|
|
256
254
|
};
|
|
257
255
|
}
|
|
258
|
-
|
|
259
|
-
//#region src/babysitter/webhook-redelivery.ts
|
|
256
|
+
// src/babysitter/webhook-redelivery.ts
|
|
260
257
|
/**
|
|
261
258
|
* Progress events that a later event of the same run replaces. A lost `check_run.created` or
|
|
262
259
|
* `workflow_run.in_progress` changes nothing once its `completed` event arrives, and change detection
|
|
@@ -350,8 +347,7 @@ async sweep(signal) {
|
|
|
350
347
|
}
|
|
351
348
|
} };
|
|
352
349
|
}
|
|
353
|
-
|
|
354
|
-
//#region src/babysitter/host.ts
|
|
350
|
+
// src/babysitter/host.ts
|
|
355
351
|
/** Reads a plain or sealed Server Env value. */
|
|
356
352
|
function envString(value) {
|
|
357
353
|
const plain = isRuntimeRecord(value) && hasRuntimeType(value.unseal, "function") ? value.unseal() : value;
|
|
@@ -512,13 +508,12 @@ async function createBabysitterProcessHost(context) {
|
|
|
512
508
|
run: async (reason, run, accepting) => await runtime?.reconcile(reason, run, accepting)
|
|
513
509
|
});
|
|
514
510
|
const preflight = createBabysitterPreflight(agent.options.install ?? true);
|
|
515
|
-
const buildRevision = "
|
|
511
|
+
const buildRevision = "fe995c180e0431214d6624fa86644133bbb7a46e97d1011eaee87cde7a1d063f";
|
|
516
512
|
const admission = createBabysitterAdmission({
|
|
517
513
|
invocations: host.invocations,
|
|
518
514
|
limits: resolveBabysitterAdmissionLimits(agent.options.admission),
|
|
519
515
|
check: async () => (await preflight()).pause ?? await agent.options.admission?.check?.()
|
|
520
516
|
});
|
|
521
|
-
let admissionPrerequisiteSample;
|
|
522
517
|
const warmWorkspaces = agent.options.warmWorkspaces;
|
|
523
518
|
const resumeThreads = typeof warmWorkspaces === "object" && warmWorkspaces.resumeThreads === true;
|
|
524
519
|
const workspaces = warmWorkspaces ? createPullRequestWorkspaces({
|
|
@@ -566,6 +561,20 @@ async function createBabysitterProcessHost(context) {
|
|
|
566
561
|
}
|
|
567
562
|
});
|
|
568
563
|
const inbox = runtime.inbox;
|
|
564
|
+
const schedulerHealth = runtime.scheduler;
|
|
565
|
+
const processHealth = boundedHealthRead(() => host.health());
|
|
566
|
+
const queueHealth = boundedHealthRead(() => inbox.summary());
|
|
567
|
+
const prerequisiteHealth = boundedHealthRead(preflight);
|
|
568
|
+
const skipHealth = boundedHealthRead(async () => ({ lastSkip: await inbox.meta("admission-skipped") }));
|
|
569
|
+
let admissionPrerequisiteSample;
|
|
570
|
+
const admissionHealth = boundedHealthRead(async () => {
|
|
571
|
+
const prerequisites = await preflight();
|
|
572
|
+
if (admissionPrerequisiteSample !== prerequisites.checkedAt) {
|
|
573
|
+
admissionPrerequisiteSample = prerequisites.checkedAt;
|
|
574
|
+
admission.invalidate();
|
|
575
|
+
}
|
|
576
|
+
return await admission.health();
|
|
577
|
+
});
|
|
569
578
|
const swept = await sweepBabysitterWorkspaces();
|
|
570
579
|
const workspaceStatus = async (repository, number) => {
|
|
571
580
|
if (!repositories.known().includes(repository.toLowerCase())) return "unknown";
|
|
@@ -586,6 +595,8 @@ async function createBabysitterProcessHost(context) {
|
|
|
586
595
|
error: host.error
|
|
587
596
|
});
|
|
588
597
|
let redeliverySweep;
|
|
598
|
+
let starting;
|
|
599
|
+
let closing = false;
|
|
589
600
|
return {
|
|
590
601
|
start() {
|
|
591
602
|
registerAgentProcessHostIntake(context.agentName, async ({ deliveryId, event, payload }) => {
|
|
@@ -602,9 +613,10 @@ async function createBabysitterProcessHost(context) {
|
|
|
602
613
|
if (result.updated.length || enrolled || mainRepair || event === "installation" || event === "installation_repositories") host.wake("webhook");
|
|
603
614
|
return Response.json(result, { status: 202 });
|
|
604
615
|
});
|
|
605
|
-
inbox.importLegacyFile(".vitehub/pull-request-inbox.sqlite").catch((error) => host.error("babysitter.legacy-import.failed", error)).then(() => inbox.releaseLeases()).then((released) => {
|
|
616
|
+
starting = inbox.importLegacyFile(".vitehub/pull-request-inbox.sqlite").catch((error) => host.error("babysitter.legacy-import.failed", error)).then(() => closing ? 0 : inbox.releaseLeases()).then((released) => {
|
|
606
617
|
if (released) host.event("babysitter.leases.released", { released });
|
|
607
618
|
}, (error) => host.error("babysitter.leases.release-failed", error)).finally(() => {
|
|
619
|
+
if (closing) return;
|
|
608
620
|
if (swept) host.event("babysitter.workspaces.swept", { removed: swept });
|
|
609
621
|
host.start();
|
|
610
622
|
redeliverySweep = setInterval(() => void redelivery.sweep().catch((error) => host.error("babysitter.webhook.redelivery_failed", error)), 3e5);
|
|
@@ -626,70 +638,110 @@ async function createBabysitterProcessHost(context) {
|
|
|
626
638
|
}, (error) => host.error("babysitter.labels.failed", error));
|
|
627
639
|
},
|
|
628
640
|
async close() {
|
|
641
|
+
closing = true;
|
|
629
642
|
clearInterval(workspaceSweep);
|
|
630
643
|
clearInterval(redeliverySweep);
|
|
631
644
|
registerAgentProcessHostIntake(context.agentName, void 0);
|
|
632
645
|
await host.close();
|
|
646
|
+
await starting;
|
|
633
647
|
await inbox.close();
|
|
634
648
|
},
|
|
635
649
|
wake: (reason) => host.wake(reason),
|
|
636
650
|
status: () => host.status(),
|
|
637
651
|
async health() {
|
|
638
|
-
const health = await
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
const
|
|
646
|
-
const
|
|
652
|
+
const [health, queue, prerequisites, guard, skip] = await Promise.all([
|
|
653
|
+
processHealth(),
|
|
654
|
+
queueHealth(),
|
|
655
|
+
prerequisiteHealth(),
|
|
656
|
+
admissionHealth(),
|
|
657
|
+
skipHealth()
|
|
658
|
+
]);
|
|
659
|
+
const hostStatus = host.status();
|
|
660
|
+
const scheduler = schedulerHealth(hostStatus === "accepting" || hostStatus === "starting");
|
|
661
|
+
const stall = scheduler.status === "stalled" ? scheduler.lastStall : void 0;
|
|
662
|
+
const schedulerDiagnostics = scheduler.status === "ok" ? [] : [{
|
|
663
|
+
label: "Scheduler",
|
|
664
|
+
status: "warning",
|
|
665
|
+
value: stall ? `Stalled at ${stall.step}` : "No reconcile finished",
|
|
666
|
+
detail: stall ? `${stall.count} reconcile(s) in a row waited too long and were stopped${stall.subject ? `, the last on ${stall.subject}` : ""}.` : `The last reconcile finished at ${scheduler.lastFinishedAt ?? "never"}.`
|
|
667
|
+
}];
|
|
668
|
+
const unavailable = [
|
|
669
|
+
!health && "invocation state",
|
|
670
|
+
!queue && "queue",
|
|
671
|
+
!prerequisites && "prerequisites",
|
|
672
|
+
!guard && "admission",
|
|
673
|
+
!skip && "admission history"
|
|
674
|
+
].filter(Boolean);
|
|
675
|
+
const readDiagnostics = unavailable.length ? [{
|
|
676
|
+
label: "Health data",
|
|
677
|
+
status: "warning",
|
|
678
|
+
value: "Unavailable",
|
|
679
|
+
detail: unavailable.join(", ")
|
|
680
|
+
}] : [];
|
|
681
|
+
const lastSkip = skip?.lastSkip;
|
|
647
682
|
return {
|
|
648
683
|
...health,
|
|
649
|
-
status: prerequisites
|
|
650
|
-
diagnostics: [
|
|
684
|
+
status: health?.status === "healthy" && !prerequisites?.pause && !schedulerDiagnostics.length && !unavailable.length ? "healthy" : "degraded",
|
|
685
|
+
diagnostics: [
|
|
686
|
+
...health?.diagnostics ?? [],
|
|
687
|
+
...prerequisites?.diagnostics ?? [],
|
|
688
|
+
...schedulerDiagnostics,
|
|
689
|
+
...readDiagnostics
|
|
690
|
+
],
|
|
691
|
+
scheduler,
|
|
651
692
|
release: agent.version,
|
|
652
693
|
framework: { buildRevision },
|
|
653
694
|
concurrency: agent.options.concurrency,
|
|
654
695
|
repositories: repositories.known(),
|
|
655
696
|
repositorySource: repositories.source,
|
|
656
|
-
queue: {
|
|
697
|
+
...queue ? { queue: {
|
|
657
698
|
...babysitterQueueHealth(queue),
|
|
658
699
|
parked: budgetParks(queue)
|
|
659
|
-
},
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
budget: {
|
|
670
|
-
accounting: guard.accounting,
|
|
671
|
-
observedAt: new Date(guard.observedAt).toISOString(),
|
|
672
|
-
hourly: {
|
|
673
|
-
inputTokens: guard.state.hourlyInputTokens,
|
|
674
|
-
limit: guard.limits.hourlyInputTokens,
|
|
675
|
-
resetsAt: guard.state.windows.hourEnd
|
|
676
|
-
},
|
|
677
|
-
daily: {
|
|
678
|
-
inputTokens: guard.state.dailyInputTokens,
|
|
679
|
-
limit: guard.limits.dailyInputTokens,
|
|
680
|
-
resetsAt: guard.state.windows.dayEnd
|
|
681
|
-
},
|
|
682
|
-
tmp: {
|
|
683
|
-
dir: guard.state.tmpDir,
|
|
684
|
-
freeBytes: guard.state.freeTmpBytes,
|
|
685
|
-
minFreeBytes: guard.limits.minFreeTmpBytes
|
|
700
|
+
} } : {},
|
|
701
|
+
...guard ? {
|
|
702
|
+
admission: {
|
|
703
|
+
accepting: guard.accepting,
|
|
704
|
+
hostOnly: guard.hostOnly,
|
|
705
|
+
reason: guard.reason,
|
|
706
|
+
retryAt: guard.retryAt,
|
|
707
|
+
detail: guard.detail,
|
|
708
|
+
lastSkip,
|
|
709
|
+
history: { lastSkip }
|
|
686
710
|
},
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
711
|
+
budget: {
|
|
712
|
+
accounting: guard.accounting,
|
|
713
|
+
observedAt: new Date(guard.observedAt).toISOString(),
|
|
714
|
+
hourly: {
|
|
715
|
+
inputTokens: guard.state.hourlyInputTokens,
|
|
716
|
+
limit: guard.limits.hourlyInputTokens,
|
|
717
|
+
resetsAt: guard.state.windows.hourEnd
|
|
718
|
+
},
|
|
719
|
+
daily: {
|
|
720
|
+
inputTokens: guard.state.dailyInputTokens,
|
|
721
|
+
limit: guard.limits.dailyInputTokens,
|
|
722
|
+
resetsAt: guard.state.windows.dayEnd
|
|
723
|
+
},
|
|
724
|
+
tmp: {
|
|
725
|
+
dir: guard.state.tmpDir,
|
|
726
|
+
freeBytes: guard.state.freeTmpBytes,
|
|
727
|
+
minFreeBytes: guard.limits.minFreeTmpBytes
|
|
728
|
+
},
|
|
729
|
+
pause: guard.state.pause,
|
|
730
|
+
errors: guard.state.errors
|
|
731
|
+
}
|
|
732
|
+
} : {}
|
|
690
733
|
};
|
|
691
734
|
}
|
|
692
735
|
};
|
|
693
736
|
}
|
|
694
|
-
|
|
737
|
+
function boundedHealthRead(read) {
|
|
738
|
+
let pending;
|
|
739
|
+
return () => pending ??= new Promise((resolve) => {
|
|
740
|
+
const timer = setTimeout(() => resolve(void 0), 1e3);
|
|
741
|
+
Promise.resolve().then(read).then(resolve, () => resolve(void 0)).finally(() => {
|
|
742
|
+
clearTimeout(timer);
|
|
743
|
+
pending = void 0;
|
|
744
|
+
});
|
|
745
|
+
});
|
|
746
|
+
}
|
|
695
747
|
export { createBabysitterProcessHost };
|
package/dist/labeller.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentRuntimeContext, ConfiguredAgentDefinition } from "@vite-hub/agent";
|
|
2
2
|
import { GmailChannel, GmailClient, GmailLabelSettings } from "@vite-hub/agent/channels";
|
|
3
|
-
//#region src/labeller.d.ts
|
|
4
3
|
export interface LabellerLabel extends GmailLabelSettings {}
|
|
5
4
|
export type LabellerPattern = string | readonly string[];
|
|
6
5
|
export interface LabellerRule {
|
|
@@ -94,4 +93,4 @@ export interface CleanupLabellerResult {
|
|
|
94
93
|
* Call it from a daily Schedule: each run continues with the matches that remain.
|
|
95
94
|
*/
|
|
96
95
|
export declare function cleanupLabeller(agent: LabellerAgent, options?: CleanupLabellerOptions): Promise<CleanupLabellerResult>;
|
|
97
|
-
|
|
96
|
+
export {};
|
package/dist/labeller.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as isRuntimeRecord, t as presetsErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { i as isRuntimeRecord, t as presetsErrorDiagnostics } from "./error-diagnostics-FZJIIO9X.js";
|
|
2
2
|
import { defineAgent } from "@vite-hub/agent";
|
|
3
3
|
import { hasRuntimeType, isRuntimeObject } from "@vite-hub/runtime/internal/runtime-type";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
import { channelMessageContextKey, gmail, gmailClient } from "@vite-hub/agent/channels";
|
|
6
6
|
import { ask } from "@vite-hub/gateways";
|
|
7
|
-
|
|
7
|
+
// src/labeller.ts
|
|
8
8
|
const maxBodyLimit = 1e5;
|
|
9
9
|
const maxPatternLength = 256;
|
|
10
10
|
const maxHeaderValueLength = 1e3;
|
|
@@ -286,5 +286,4 @@ async function cleanupLabeller(agent, options = {}) {
|
|
|
286
286
|
rules: results
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
-
//#endregion
|
|
290
289
|
export { cleanupLabeller, labeller };
|
|
@@ -3,7 +3,6 @@ import "valibot";
|
|
|
3
3
|
import { GitHubAppDelivery, GitHubAppRepository, GitHubProvider } from "@vite-hub/forge";
|
|
4
4
|
import { GitHubChannelOptions, GitHubPullRequestFilter } from "@vite-hub/agent/channels";
|
|
5
5
|
import { SqliteAgentStateExtension } from "@vite-hub/agent/state";
|
|
6
|
-
//#region src/babysitter/inbox/budgets.d.ts
|
|
7
6
|
interface ProviderBudget {
|
|
8
7
|
generation: string;
|
|
9
8
|
maxRetries: number;
|
|
@@ -75,12 +74,8 @@ interface InboxBudgets {
|
|
|
75
74
|
minorReviewRounds?: number;
|
|
76
75
|
dailyPasses?: number;
|
|
77
76
|
}
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/github/checkout.d.ts
|
|
80
77
|
/** Why a persistent provider workspace was kept or emptied. */
|
|
81
78
|
type GitHubWorkspaceReuse = "warm" | "cold" | "dirty" | "missing-metadata" | (string & {});
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/github/repair.d.ts
|
|
84
79
|
interface GitHubRepairCommit {
|
|
85
80
|
message: string;
|
|
86
81
|
paths: string[];
|
|
@@ -90,8 +85,6 @@ interface GitHubRepairCommit {
|
|
|
90
85
|
reason: string;
|
|
91
86
|
}>;
|
|
92
87
|
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/github/host.d.ts
|
|
95
88
|
type GitHubHostSecret = string | {
|
|
96
89
|
unseal: () => string;
|
|
97
90
|
};
|
|
@@ -107,15 +100,21 @@ interface GitHubHostCredentialContext {
|
|
|
107
100
|
repository?: string;
|
|
108
101
|
signal: AbortSignal;
|
|
109
102
|
}
|
|
103
|
+
/** The GitHub user or App bot that commits and comments for the host. */
|
|
104
|
+
interface GitHubHostIdentity {
|
|
105
|
+
appId?: number;
|
|
106
|
+
email?: string;
|
|
107
|
+
login?: string;
|
|
108
|
+
}
|
|
110
109
|
interface GitHubHostOptions {
|
|
111
110
|
credentials: (context: GitHubHostCredentialContext) => GitHubHostCredentials | Promise<GitHubHostCredentials>;
|
|
112
111
|
/** A `fetch` for Forge requests, for tests and runtimes without a global one. */
|
|
113
112
|
fetch?: typeof fetch;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Commit author and comment owner. Default: the GitHub App bot of the App credentials, such as
|
|
115
|
+
* `my-app[bot]` with its noreply email. Set it for a token without an App.
|
|
116
|
+
*/
|
|
117
|
+
identity?: GitHubHostIdentity;
|
|
119
118
|
maxBuffer?: number;
|
|
120
119
|
/** Forge request timeout in milliseconds. Default 60000. */
|
|
121
120
|
timeout?: number;
|
|
@@ -135,6 +134,8 @@ interface GitHubHostAccess {
|
|
|
135
134
|
token: string;
|
|
136
135
|
}
|
|
137
136
|
interface GitHubHostPullRequest {
|
|
137
|
+
/** Base branch. With it, `push()` tells `beforePush` whether every new commit outside the base is the host's. */
|
|
138
|
+
baseRef?: string;
|
|
138
139
|
headRef?: string;
|
|
139
140
|
headRepository?: string;
|
|
140
141
|
headSha: string;
|
|
@@ -163,11 +164,21 @@ interface GitHubHostCheckout extends GitHubHostAccess {
|
|
|
163
164
|
}): Promise<string>;
|
|
164
165
|
push(target?: string, options?: {
|
|
165
166
|
signal?: AbortSignal;
|
|
166
|
-
beforePush?: (head?: string) => void | Promise<void>;
|
|
167
|
+
beforePush?: (head?: string, lineage?: GitHubHostPushLineage) => void | Promise<void>;
|
|
167
168
|
afterPush?: (head: string) => void | Promise<void>;
|
|
168
169
|
}): Promise<string>;
|
|
169
170
|
signal: AbortSignal;
|
|
170
171
|
}
|
|
172
|
+
/** How a pushed head relates to the head it replaces. */
|
|
173
|
+
interface GitHubHostPushLineage {
|
|
174
|
+
/** The pull request head that the push replaces. The pushed head descends from it. */
|
|
175
|
+
parent: string;
|
|
176
|
+
/**
|
|
177
|
+
* Every commit that the push adds, apart from commits on the base branch, is one that `commitRepair()`
|
|
178
|
+
* made in this checkout. A provider that fetches and merges someone else's commits makes this `false`.
|
|
179
|
+
*/
|
|
180
|
+
hostOnly: boolean;
|
|
181
|
+
}
|
|
171
182
|
interface GitHubHostCheckoutOptions {
|
|
172
183
|
signal?: AbortSignal;
|
|
173
184
|
timeout?: number;
|
|
@@ -190,6 +201,12 @@ interface GitHubHostAccessOptions extends GitHubHostCheckoutOptions {
|
|
|
190
201
|
/** Mint a new App installation token when the cached one expires within this many milliseconds. */
|
|
191
202
|
minLifetime?: number;
|
|
192
203
|
repository?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Repository whose App installation mints the token, when it is not `repository`. Git still sends the
|
|
206
|
+
* token only to `repository`. A fork without the App uses its base repository's installation, whose
|
|
207
|
+
* token may push to the fork's branch while its author allows edits by maintainers.
|
|
208
|
+
*/
|
|
209
|
+
installationRepository?: string;
|
|
193
210
|
}
|
|
194
211
|
/** A GitHub rate limit that the response headers of this host's Forge requests reported. */
|
|
195
212
|
interface GitHubHostRateLimit {
|
|
@@ -244,18 +261,10 @@ declare function createGitHubAppCredentials(app: GitHubAppEnvironment): {
|
|
|
244
261
|
/** Sends one App webhook delivery again. */
|
|
245
262
|
redeliver: (id: string, signal?: AbortSignal) => Promise<void>;
|
|
246
263
|
/** 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
|
-
}>;
|
|
264
|
+
identity(): Promise<Required<GitHubHostIdentity>>;
|
|
252
265
|
};
|
|
253
266
|
declare function createGitHubHost(options: GitHubHostOptions): GitHubHost;
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/github/required-checks.d.ts
|
|
256
267
|
type GitHubRequiredCheckState = "pending" | "failed" | "passed" | "unknown";
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/babysitter/inbox/types.d.ts
|
|
259
268
|
interface GitHubActor {
|
|
260
269
|
login?: string;
|
|
261
270
|
type?: string;
|
|
@@ -388,8 +397,6 @@ interface GitHubReviewThread {
|
|
|
388
397
|
resolutionSource?: string;
|
|
389
398
|
resolutionObservedAt?: string;
|
|
390
399
|
}
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/babysitter/inbox/wait-state.d.ts
|
|
393
400
|
type PullRequestWake = {
|
|
394
401
|
kind: "checks";
|
|
395
402
|
repository: string;
|
|
@@ -417,8 +424,6 @@ type PullRequestWait = {
|
|
|
417
424
|
defer?: "checks";
|
|
418
425
|
wake?: PullRequestWake;
|
|
419
426
|
};
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/babysitter/inbox/storage.d.ts
|
|
422
427
|
/**
|
|
423
428
|
* SQL access for the PR inbox. `agentState.extension("babysitter")` from
|
|
424
429
|
* `@vite-hub/agent/state` satisfies it and keeps the inbox in the Agent State database.
|
|
@@ -426,8 +431,6 @@ type PullRequestWait = {
|
|
|
426
431
|
interface PullRequestInboxStorage extends Pick<SqliteAgentStateExtension, "execute" | "tablePrefix" | "transaction"> {
|
|
427
432
|
close?: () => Promise<void>;
|
|
428
433
|
}
|
|
429
|
-
//#endregion
|
|
430
|
-
//#region src/babysitter/inbox/status-delivery.d.ts
|
|
431
434
|
interface StatusDelivery {
|
|
432
435
|
version: string;
|
|
433
436
|
contentKey: string;
|
|
@@ -457,8 +460,11 @@ interface StatusDelivery {
|
|
|
457
460
|
summary: string;
|
|
458
461
|
};
|
|
459
462
|
}
|
|
460
|
-
|
|
461
|
-
|
|
463
|
+
/** A head that the host pushed, with the head it replaced. Only heads whose new commits are all the host's own are recorded. */
|
|
464
|
+
interface HostHead {
|
|
465
|
+
head: string;
|
|
466
|
+
parent: string;
|
|
467
|
+
}
|
|
462
468
|
type Snapshot = {
|
|
463
469
|
repository: string;
|
|
464
470
|
number: number;
|
|
@@ -488,6 +494,10 @@ type Snapshot = {
|
|
|
488
494
|
token: string;
|
|
489
495
|
heads: string[];
|
|
490
496
|
};
|
|
497
|
+
/** Heads the host pushed whose new commits are all its own, oldest first. An approval carries over along them. */
|
|
498
|
+
hostHeads?: HostHead[];
|
|
499
|
+
/** Heads the host asked GitHub to update with the base. The host's own `synchronize` from one adds a `hostHeads` entry. */
|
|
500
|
+
hostUpdates?: string[];
|
|
491
501
|
threadReopens?: Record<string, number>;
|
|
492
502
|
/** Authenticated outcome replies, including IDs used by thread-only reads. */
|
|
493
503
|
ownedReviewCommentIds?: string[];
|
|
@@ -570,6 +580,16 @@ interface PullRequestInboxOptions {
|
|
|
570
580
|
/** The served repositories, or a function that returns the current lowercase list on each read. */
|
|
571
581
|
repositories: readonly string[] | (() => readonly string[]);
|
|
572
582
|
filter?: GitHubPullRequestFilter;
|
|
583
|
+
/**
|
|
584
|
+
* Also admit an open PR that `filter`'s author rules leave out while a reviewer with write access
|
|
585
|
+
* approves its current head, or a head the host built on the approved one. Every other rule still applies.
|
|
586
|
+
*/
|
|
587
|
+
admitApproved?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* The time in Unix milliseconds, for tests. By default a shared `storage` inbox follows the clock of its database:
|
|
590
|
+
* it reads that clock at most every 30 seconds and counts elapsed time from there, so servers with different host
|
|
591
|
+
* clocks agree when a lease expires. A private `path` inbox has one host and uses `Date.now`.
|
|
592
|
+
*/
|
|
573
593
|
clock?: () => number;
|
|
574
594
|
activityAuthors?: readonly string[];
|
|
575
595
|
activityAppId?: number;
|
|
@@ -604,7 +624,11 @@ declare class PullRequestInbox {
|
|
|
604
624
|
private tables;
|
|
605
625
|
private repositoryList;
|
|
606
626
|
private clock;
|
|
627
|
+
private usesDatabaseClock;
|
|
628
|
+
private clockSample?;
|
|
607
629
|
private filter?;
|
|
630
|
+
/** Whether a maintainer's approval admits an author the filter leaves out. */
|
|
631
|
+
readonly admitApproved: boolean;
|
|
608
632
|
private activityAuthors;
|
|
609
633
|
private activityAppId?;
|
|
610
634
|
private budgets;
|
|
@@ -613,9 +637,12 @@ declare class PullRequestInbox {
|
|
|
613
637
|
private claimStackChildren;
|
|
614
638
|
private invalidRow?;
|
|
615
639
|
private reportedRows;
|
|
616
|
-
constructor({ path, storage, scope, repositories, filter, clock, budgets, activityAuthors, activityAppId, priorityLabels, mainRepairBranchPrefix, claimStackChildren, invalidRow }: PullRequestInboxOptions);
|
|
640
|
+
constructor({ path, storage, scope, repositories, filter, admitApproved, clock, budgets, activityAuthors, activityAppId, priorityLabels, mainRepairBranchPrefix, claimStackChildren, invalidRow }: PullRequestInboxOptions);
|
|
617
641
|
close(): Promise<void>;
|
|
618
642
|
private init;
|
|
643
|
+
/** The current time on the inbox clock. Compare lease ends from the inbox with it, not with `Date.now()`. */
|
|
644
|
+
now(): number;
|
|
645
|
+
private syncClock;
|
|
619
646
|
private transaction;
|
|
620
647
|
private read;
|
|
621
648
|
/** Parses one stored row. An invalid row is reported once and skipped by queue-wide reads. */
|
|
@@ -670,6 +697,11 @@ declare class PullRequestInbox {
|
|
|
670
697
|
private stackFoldKey;
|
|
671
698
|
/** The stacked pull request whose merge into this pull request's branch has an unknown outcome. */
|
|
672
699
|
private foldingChildIn;
|
|
700
|
+
/**
|
|
701
|
+
* A closed child's fold has a known outcome, and its pending-merge path never runs again to clear it.
|
|
702
|
+
* Retire the attempt with the parent's slot, so a reopened child must win the slot again before it folds.
|
|
703
|
+
*/
|
|
704
|
+
private retireFoldIn;
|
|
673
705
|
foldingChild(repository: string, parent: number): Promise<number | undefined>;
|
|
674
706
|
/**
|
|
675
707
|
* Atomically records that a claim has started an irreversible merge request. With `foldInto`, the merge
|
|
@@ -694,7 +726,13 @@ declare class PullRequestInbox {
|
|
|
694
726
|
isPriority(pr: GitHubPullRequestRecord | null | undefined): boolean;
|
|
695
727
|
/** Whether the PR's head branch starts with `mainRepairBranchPrefix`. */
|
|
696
728
|
isMainRepair(pr: GitHubPullRequestRecord | null | undefined): boolean;
|
|
697
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Whether the runtime acts on `pr`. With `admitApproved`, a maintainer's approval of the head in
|
|
731
|
+
* `snapshot` admits an author the filter leaves out. `writers` holds the reviewers whose write
|
|
732
|
+
* permission the caller verified; without it, the review's association stands in, which only the
|
|
733
|
+
* inbox's own bookkeeping relies on before a pass checks again.
|
|
734
|
+
*/
|
|
735
|
+
eligible(repository: string, pr: GitHubPullRequestRecord | null, snapshot?: Pick<Snapshot, "reviews" | "hostHeads">, writers?: ReadonlySet<string>): boolean;
|
|
698
736
|
seed(repository: string, value: unknown, signal?: AbortSignal): Promise<Snapshot>;
|
|
699
737
|
ingest(id: string, event: string, value: unknown, signal?: AbortSignal): Promise<GitHubInboxDeliveryResult>;
|
|
700
738
|
/** Leases up to `limit` eligible PRs. `skip` leaves a candidate unclaimed for this call. */
|
|
@@ -708,8 +746,29 @@ declare class PullRequestInbox {
|
|
|
708
746
|
refreshThreads(observed: Snapshot, threads: GitHubReviewThread[], signal?: AbortSignal): Promise<boolean>;
|
|
709
747
|
/** Retain a worker's verified thread resolution even when its webhook is missing. */
|
|
710
748
|
recordThreadResolution(claim: Claim, id: string, observed: Snapshot): Promise<boolean>;
|
|
711
|
-
/**
|
|
712
|
-
|
|
749
|
+
/**
|
|
750
|
+
* Retain CI for an exact candidate before its source-push webhook arrives. This is not a publication receipt.
|
|
751
|
+
* With `lineage.hostOnly`, it also records the head as the host's own work on `lineage.parent`, so an
|
|
752
|
+
* approval of that parent carries over to it.
|
|
753
|
+
*/
|
|
754
|
+
registerProspectivePush(claim: Claim, head: string, lineage?: {
|
|
755
|
+
parent: string;
|
|
756
|
+
hostOnly: boolean;
|
|
757
|
+
}): Promise<boolean>;
|
|
758
|
+
/**
|
|
759
|
+
* Records that the host asks GitHub to update the PR's branch from `from` with its base, before it sends
|
|
760
|
+
* the request. GitHub writes the merge commit and the response carries no SHA, so the `synchronize`
|
|
761
|
+
* delivery that the host's own identity sends from `from` records the new head as the host's work. A
|
|
762
|
+
* merges API call returns the commit: pass it as `head` to record it at once. Anything but a full commit
|
|
763
|
+
* SHA records nothing, so the approval does not carry over.
|
|
764
|
+
*/
|
|
765
|
+
registerHostUpdate(repository: string, number: number, from: string, head?: string): Promise<void>;
|
|
766
|
+
private addHostHead;
|
|
767
|
+
/**
|
|
768
|
+
* A webhook head move ends every pending update. Only the host's own move from a registered head carries an
|
|
769
|
+
* approval. A probe's synthetic `synchronize` has no `before` and leaves the updates for the webhook.
|
|
770
|
+
*/
|
|
771
|
+
private settleHostUpdate;
|
|
713
772
|
release(claim: Claim): Promise<boolean>;
|
|
714
773
|
renew(claim: Claim, leaseUntil: number): Promise<boolean>;
|
|
715
774
|
/**
|
|
@@ -796,8 +855,6 @@ declare class PullRequestInbox {
|
|
|
796
855
|
signal?: AbortSignal;
|
|
797
856
|
}): Promise<void>;
|
|
798
857
|
}
|
|
799
|
-
//#endregion
|
|
800
|
-
//#region src/babysitter/admission.d.ts
|
|
801
858
|
/** A reason to stop model passes, returned by `admission.check`. */
|
|
802
859
|
interface BabysitterAdmissionPause {
|
|
803
860
|
/** Short machine-readable reason, such as `"provider-quota"`. */
|
|
@@ -861,8 +918,6 @@ interface BabysitterAdmissionResult {
|
|
|
861
918
|
state: BabysitterAdmissionState;
|
|
862
919
|
limits: BabysitterAdmissionLimits;
|
|
863
920
|
}
|
|
864
|
-
//#endregion
|
|
865
|
-
//#region src/babysitter/pr-workspaces.d.ts
|
|
866
921
|
/** Keep one workspace per open PR between passes. See `BabysitterOptions.warmWorkspaces`. */
|
|
867
922
|
interface BabysitterWarmWorkspaces {
|
|
868
923
|
/**
|
|
@@ -922,5 +977,4 @@ interface PullRequestWorkspaces {
|
|
|
922
977
|
kept: number;
|
|
923
978
|
}>;
|
|
924
979
|
}
|
|
925
|
-
//#endregion
|
|
926
980
|
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 };
|