@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.
@@ -1,4 +1,4 @@
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";
1
+ import { T as AutomatedReviewClass, i as BabysitterAdmissionPause, l as GitHubRequiredCheckState, r as BabysitterAdmissionOptions, s as Snapshot, t as BabysitterWarmWorkspaces } from "./pr-workspaces-QjQyRB6g.js";
2
2
  import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentSandboxDefinition, BuiltInAgentDriverName, ConfiguredAgentDefinition } from "@vite-hub/agent";
3
3
  import { GitHubPullRequestFilter } from "@vite-hub/agent/channels";
4
4
  import { Diagnostic } from "nostics";
@@ -35,6 +35,11 @@ interface BabysitterMergeReadinessInput {
35
35
  head: string;
36
36
  snapshot: Snapshot;
37
37
  requiredChecks: GitHubRequiredCheckState;
38
+ /**
39
+ * Lowercase logins of the reviewers whose write permission the host verified. The built-in gate
40
+ * counts only their approvals; without it, each review's author association stands in.
41
+ */
42
+ writers?: ReadonlySet<string>;
38
43
  }
39
44
  /** Return `true` to allow the merge, or a reason that sends the PR to a normal pass. */
40
45
  type BabysitterMergeReady = (input: BabysitterMergeReadinessInput) => true | string | Promise<true | string>;
@@ -70,6 +75,14 @@ type BabysitterMerge = false | "auto" | "direct" | {
70
75
  * branch is in the repository itself qualify, so a fork's draft stays a draft.
71
76
  */
72
77
  markDraftsReady?: readonly string[];
78
+ /**
79
+ * A branch, by repository (`owner/name`), that receives a fork PR's head when a required check never
80
+ * reported on it, such as `{ "acme/app": "preview/pr-{number}" }`. Checks that run only on pushes to
81
+ * the repository itself, like pkg.pr.new, then report on the head. `{number}` is the PR number. The
82
+ * host pushes only a head that a reviewer with write access approved and whose `.github` folder is the
83
+ * base branch's, because a push runs the pushed commit's workflows with the repository's permissions.
84
+ */
85
+ forkHeadBranches?: Record<string, string>;
73
86
  /**
74
87
  * Merge a ready pull request into its parent's branch when its base is the head branch of another
75
88
  * open pull request in the same repository, so the stack lands with the parent. Default `true`.
@@ -115,6 +128,14 @@ export interface BabysitterLifecycleLabels {
115
128
  }
116
129
  export interface BabysitterLifecycleOptions {
117
130
  labels?: BabysitterLifecycleLabels;
131
+ /**
132
+ * Also select a PR that `filter`'s author allow lists leave out, such as one from an outside
133
+ * contributor, once a reviewer with write access approves its current head. The approval carries
134
+ * over to the heads the Babysitter builds on the approved commit, so it repairs and merges the PR
135
+ * without another review. A push by anyone else drops the PR until the next approval. Deny lists and
136
+ * every other rule still apply. Defaults to `false`.
137
+ */
138
+ approval?: boolean;
118
139
  }
119
140
  /** Where one pass runs. A pass without a Sandbox uses the host checkout and the configured `sandbox`. */
120
141
  export interface BabysitterPlacementLease {
@@ -135,8 +156,9 @@ export interface BabysitterPlacement {
135
156
  /**
136
157
  * Slots that hosts admit now, counting passes already running. A reconcile claims at most this
137
158
  * many PRs minus the active owners, so it never claims work that `place` must turn away.
159
+ * Stop the capacity check and discard a pending shared probe when the signal aborts.
138
160
  */
139
- admitted?(): number | Promise<number>;
161
+ admitted?(signal?: AbortSignal): number | Promise<number>;
140
162
  }
141
163
  /** Where the Babysitter reports its state on each PR. Both need a verified GitHub App identity. */
142
164
  export interface BabysitterStatusOptions {
@@ -1,2 +1,2 @@
1
- import { i as BabysitterPlacementCapacityError, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter, t as babysitter } from "./babysitter-C71pgjkv.js";
1
+ import { i as BabysitterPlacementCapacityError, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter, t as babysitter } from "./babysitter-B5C0KLRl.js";
2
2
  export { BabysitterPlacementCapacityError, babysitter, babysitterPassResultSchema, resolveBabysitterLifecycleFilter };
@@ -13,7 +13,7 @@ function isRuntimeString(value) {
13
13
  //#endregion
14
14
  //#region src/error-diagnostics.ts
15
15
  const presetsErrorDiagnostics = /*#__PURE__*/ defineErrors({
16
- docs: "https://vitehub.dev/docs/agents/diagnostics",
16
+ docs: "https://vitehub.dev/docs/presets/diagnostics",
17
17
  codes: {
18
18
  PRESETS_BABYSITTER_REPOSITORIES_INVALID: {
19
19
  why: "Babysitter filter.repository.allow lists no \"owner/name\" repository.",
@@ -355,6 +355,10 @@ const presetsErrorDiagnostics = /*#__PURE__*/ defineErrors({
355
355
  why: "[vitehub] Babysitter noFindingsReviews cannot contain an empty prefix.",
356
356
  fix: "Remove the empty string from noFindingsReviews in the Babysitter options, or give each entry the text that starts a no-findings review."
357
357
  },
358
+ PRESETS_BABYSITTER_RECONCILE_STALLED: {
359
+ why: ({ step, minutes }) => `The Babysitter reconcile waited ${minutes} minutes in its ${step} step, so the Babysitter stopped it.`,
360
+ fix: "Read the babysitter.reconcile.stalled event: it names the step and the pull request that did not answer. The next reconcile claims work again. If the same step stalls again, find the request or lock in that step that never settles and give it a timeout."
361
+ },
358
362
  PRESETS_BABYSITTER_TOOL_FIELD_INVALID: {
359
363
  why: ({ key, expected }) => `${key} must be ${expected}.`,
360
364
  fix: "Pass the field that the message names as a string in the tool input. Only a body may be empty."
@@ -1,6 +1,6 @@
1
- import { i as isRuntimeRecord, n as hasRuntimeType, t as presetsErrorDiagnostics } from "./error-diagnostics-BTBW9sZx.js";
2
- import { d as resolveBabysitterAdmissionLimits, o as createPullRequestWorkspaces, r as resolveBabysitterLifecycleFilter, u as createBabysitterAdmission } from "./babysitter-C71pgjkv.js";
3
- import { a as pullRequestThreadId, i as budgetParks, o as createGitHubAppCredentials, s as createGitHubHost, t as createBabysitterRuntime } from "./server-CIgjUG63.js";
1
+ import { i as isRuntimeRecord, n as hasRuntimeType, t as presetsErrorDiagnostics } from "./error-diagnostics-o3pHscWs.js";
2
+ import { d as resolveBabysitterAdmissionLimits, f as sharedBabysitterRead, o as createPullRequestWorkspaces, r as resolveBabysitterLifecycleFilter, u as createBabysitterAdmission } from "./babysitter-B5C0KLRl.js";
3
+ import { a as budgetParks, c as createGitHubHost, i as babysitterQueueHealth, o as pullRequestThreadId, s as createGitHubAppCredentials, t as createBabysitterRuntime } from "./server-Bj5_Uf_Y.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";
@@ -186,31 +186,6 @@ function createBabysitterPreflight(install, checkCommand = async (program, probe
186
186
  };
187
187
  }
188
188
  //#endregion
189
- //#region src/babysitter/queue-health.ts
190
- /** Derive bounded operational counters from the durable queue, including scheduled retries. */
191
- function babysitterQueueHealth(items, now = Date.now()) {
192
- const mergedTerminal = (result) => result?.startsWith("Merged ") || result === "Asynchronous merge confirmed by GitHub." || result === "Direct merge outcome reconciled: GitHub reports the pull request merged.";
193
- const ready = items.filter((item) => item.status === "ready" && item.dirty && !item.stackBlocked && item.nextAt <= now);
194
- const waiting = items.filter((item) => item.status === "waiting");
195
- return {
196
- working: items.filter((item) => item.status === "working").length,
197
- ready: ready.length,
198
- scheduled: items.filter((item) => item.status === "ready" && item.dirty && !item.stackBlocked && item.nextAt > now).length,
199
- stackBlocked: items.filter((item) => item.stackBlocked).length,
200
- waiting: waiting.length,
201
- suppressed: items.filter((item) => item.status === "terminal" && item.state === "open" && !mergedTerminal(item.lastResult)).length,
202
- oldestReadyAgeMs: ready.reduce((age, item) => Math.max(age, item.dirtyAt === void 0 ? 0 : now - item.dirtyAt), 0),
203
- blockers: {
204
- checks: waiting.filter((item) => item.wait && item.wait.kind !== "external" && !item.wait.wake).length,
205
- dependency: waiting.filter((item) => item.wait?.wake).length,
206
- manual: waiting.filter((item) => item.wait?.kind === "external" && !item.wait.wake && item.wait.retryAt === void 0).length,
207
- timed: waiting.filter((item) => item.wait?.retryAt !== void 0).length,
208
- installCapacity: waiting.filter((item) => item.wait?.reasonCode === "install-capacity").length,
209
- noProgress: waiting.filter((item) => item.progressBudget?.exhausted && item.progressBudget.head === item.head).length
210
- }
211
- };
212
- }
213
- //#endregion
214
189
  //#region src/babysitter/repositories.ts
215
190
  /** How long the installation repository list stays fresh without an installation webhook. */
216
191
  const installationRepositoriesTtlMs = 6e5;
@@ -239,7 +214,6 @@ function babysitterRepositories(filter, read, { ttlMs = installationRepositories
239
214
  const accepted = (repository) => repositoryName.test(repository) && !deny.has(repository);
240
215
  let repositories = [];
241
216
  let loadedAt;
242
- let refreshing;
243
217
  let installationEvents = 0;
244
218
  const set = (next) => {
245
219
  const sorted = [...new Set(next)].sort();
@@ -247,24 +221,22 @@ function babysitterRepositories(filter, read, { ttlMs = installationRepositories
247
221
  repositories = sorted;
248
222
  return changed;
249
223
  };
250
- const refresh = () => refreshing ??= (async () => {
251
- try {
252
- const events = installationEvents;
253
- const installed = await read();
254
- if (events !== installationEvents) return repositories;
255
- set(installed.filter((item) => !item.archived).map((item) => item.repository.toLowerCase()).filter(accepted));
256
- loadedAt = now();
257
- return repositories;
258
- } finally {
259
- refreshing = void 0;
260
- }
261
- })();
224
+ const refresh = sharedBabysitterRead(async (signal) => {
225
+ const events = installationEvents;
226
+ const installed = await read(signal);
227
+ signal.throwIfAborted();
228
+ if (events !== installationEvents) return repositories;
229
+ set(installed.filter((item) => !item.archived).map((item) => item.repository.toLowerCase()).filter(accepted));
230
+ loadedAt = now();
231
+ return repositories;
232
+ });
262
233
  return {
263
234
  source: "installations",
264
235
  known: () => repositories,
265
- async current() {
236
+ async current(signal) {
237
+ signal?.throwIfAborted();
266
238
  if (loadedAt !== void 0 && now() - loadedAt < ttlMs) return repositories;
267
- return await refresh();
239
+ return await refresh(signal);
268
240
  },
269
241
  observe(event, payload) {
270
242
  if (!isRuntimeRecord(payload)) return false;
@@ -288,8 +260,8 @@ function babysitterRepositories(filter, read, { ttlMs = installationRepositories
288
260
  /**
289
261
  * Progress events that a later event of the same run replaces. A lost `check_run.created` or
290
262
  * `workflow_run.in_progress` changes nothing once its `completed` event arrives, and change detection
291
- * reads running checks anyway. On 2026-11-16 they were 80% of the failed deliveries, and sending them
292
- * first delayed the `completed` events that let a green PR merge.
263
+ * reads running checks anyway. They are most of the failed deliveries, and sending them first delays
264
+ * the `completed` events that let a green PR merge.
293
265
  */
294
266
  const superseded = /* @__PURE__ */ new Set([
295
267
  "check_run.created",
@@ -310,9 +282,8 @@ function priority(name) {
310
282
  }
311
283
  /**
312
284
  * Sends failed GitHub App webhook deliveries again. GitHub does not retry a delivery that timed out
313
- * after 10 seconds or failed. On 2026-11-16 about a third of deliveries timed out while the disk was
314
- * busy, so `check_suite.completed` events got lost and green pull requests waited 30 minutes or more
315
- * for the change detection to find them. The inbox deduplicates by delivery ID, so an event that the
285
+ * after 10 seconds or failed. When the receiver is slow, `check_suite.completed` events get lost and
286
+ * green pull requests wait for the change detection to find them. The inbox deduplicates by delivery ID, so an event that the
316
287
  * receiver stored after GitHub stopped waiting is not processed twice.
317
288
  */
318
289
  function createWebhookRedelivery(options) {
@@ -512,7 +483,7 @@ async function createBabysitterProcessHost(context) {
512
483
  await cleanupLegacyBabysitterCheckouts(context.dataDir);
513
484
  const app = await readGitHubAppEnvironment({}, { webhookSecret: true });
514
485
  const credentials = createGitHubAppCredentials(app);
515
- const repositories = babysitterRepositories(agent.options.filter, () => credentials.repositories());
486
+ const repositories = babysitterRepositories(agent.options.filter, (signal) => credentials.repositories(signal));
516
487
  const identity = await credentials.identity();
517
488
  const github = createGitHubHost({
518
489
  credentials: credentials.credentials,
@@ -541,13 +512,12 @@ async function createBabysitterProcessHost(context) {
541
512
  run: async (reason, run, accepting) => await runtime?.reconcile(reason, run, accepting)
542
513
  });
543
514
  const preflight = createBabysitterPreflight(agent.options.install ?? true);
544
- const buildRevision = "36cb7f3d81a66e753f82ebfb46bda4f9cdcc713a9a7ab3953bc1baa6b2c1bd26";
515
+ const buildRevision = "cc2ab9f972b0945800468710b76d4809a3c6faa1a595c85f117a934b62a37e90";
545
516
  const admission = createBabysitterAdmission({
546
517
  invocations: host.invocations,
547
518
  limits: resolveBabysitterAdmissionLimits(agent.options.admission),
548
519
  check: async () => (await preflight()).pause ?? await agent.options.admission?.check?.()
549
520
  });
550
- let admissionPrerequisiteSample;
551
521
  const warmWorkspaces = agent.options.warmWorkspaces;
552
522
  const resumeThreads = typeof warmWorkspaces === "object" && warmWorkspaces.resumeThreads === true;
553
523
  const workspaces = warmWorkspaces ? createPullRequestWorkspaces({
@@ -576,7 +546,7 @@ async function createBabysitterProcessHost(context) {
576
546
  event: host.event,
577
547
  error: host.error,
578
548
  wake: () => host.wake(),
579
- admission,
549
+ admission: (signal) => admission(void 0, signal),
580
550
  hostCapacity: async ({ active, signal }) => {
581
551
  try {
582
552
  return await hostSample.sample({
@@ -595,6 +565,20 @@ async function createBabysitterProcessHost(context) {
595
565
  }
596
566
  });
597
567
  const inbox = runtime.inbox;
568
+ const schedulerHealth = runtime.scheduler;
569
+ const processHealth = boundedHealthRead(() => host.health());
570
+ const queueHealth = boundedHealthRead(() => inbox.summary());
571
+ const prerequisiteHealth = boundedHealthRead(preflight);
572
+ const skipHealth = boundedHealthRead(async () => ({ lastSkip: await inbox.meta("admission-skipped") }));
573
+ let admissionPrerequisiteSample;
574
+ const admissionHealth = boundedHealthRead(async () => {
575
+ const prerequisites = await preflight();
576
+ if (admissionPrerequisiteSample !== prerequisites.checkedAt) {
577
+ admissionPrerequisiteSample = prerequisites.checkedAt;
578
+ admission.invalidate();
579
+ }
580
+ return await admission.health();
581
+ });
598
582
  const swept = await sweepBabysitterWorkspaces();
599
583
  const workspaceStatus = async (repository, number) => {
600
584
  if (!repositories.known().includes(repository.toLowerCase())) return "unknown";
@@ -615,6 +599,8 @@ async function createBabysitterProcessHost(context) {
615
599
  error: host.error
616
600
  });
617
601
  let redeliverySweep;
602
+ let starting;
603
+ let closing = false;
618
604
  return {
619
605
  start() {
620
606
  registerAgentProcessHostIntake(context.agentName, async ({ deliveryId, event, payload }) => {
@@ -631,9 +617,10 @@ async function createBabysitterProcessHost(context) {
631
617
  if (result.updated.length || enrolled || mainRepair || event === "installation" || event === "installation_repositories") host.wake("webhook");
632
618
  return Response.json(result, { status: 202 });
633
619
  });
634
- inbox.importLegacyFile(".vitehub/pull-request-inbox.sqlite").catch((error) => host.error("babysitter.legacy-import.failed", error)).then(() => inbox.releaseLeases()).then((released) => {
620
+ starting = inbox.importLegacyFile(".vitehub/pull-request-inbox.sqlite").catch((error) => host.error("babysitter.legacy-import.failed", error)).then(() => closing ? 0 : inbox.releaseLeases()).then((released) => {
635
621
  if (released) host.event("babysitter.leases.released", { released });
636
622
  }, (error) => host.error("babysitter.leases.release-failed", error)).finally(() => {
623
+ if (closing) return;
637
624
  if (swept) host.event("babysitter.workspaces.swept", { removed: swept });
638
625
  host.start();
639
626
  redeliverySweep = setInterval(() => void redelivery.sweep().catch((error) => host.error("babysitter.webhook.redelivery_failed", error)), 3e5);
@@ -655,70 +642,111 @@ async function createBabysitterProcessHost(context) {
655
642
  }, (error) => host.error("babysitter.labels.failed", error));
656
643
  },
657
644
  async close() {
645
+ closing = true;
658
646
  clearInterval(workspaceSweep);
659
647
  clearInterval(redeliverySweep);
660
648
  registerAgentProcessHostIntake(context.agentName, void 0);
661
649
  await host.close();
650
+ await starting;
662
651
  await inbox.close();
663
652
  },
664
653
  wake: (reason) => host.wake(reason),
665
654
  status: () => host.status(),
666
655
  async health() {
667
- const health = await host.health();
668
- const queue = await inbox.summary();
669
- const prerequisites = await preflight();
670
- if (admissionPrerequisiteSample !== prerequisites.checkedAt) {
671
- admissionPrerequisiteSample = prerequisites.checkedAt;
672
- admission.invalidate();
673
- }
674
- const guard = await admission.health();
675
- const lastSkip = await inbox.meta("admission-skipped");
656
+ const [health, queue, prerequisites, guard, skip] = await Promise.all([
657
+ processHealth(),
658
+ queueHealth(),
659
+ prerequisiteHealth(),
660
+ admissionHealth(),
661
+ skipHealth()
662
+ ]);
663
+ const hostStatus = host.status();
664
+ const scheduler = schedulerHealth(hostStatus === "accepting" || hostStatus === "starting");
665
+ const stall = scheduler.status === "stalled" ? scheduler.lastStall : void 0;
666
+ const schedulerDiagnostics = scheduler.status === "ok" ? [] : [{
667
+ label: "Scheduler",
668
+ status: "warning",
669
+ value: stall ? `Stalled at ${stall.step}` : "No reconcile finished",
670
+ 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"}.`
671
+ }];
672
+ const unavailable = [
673
+ !health && "invocation state",
674
+ !queue && "queue",
675
+ !prerequisites && "prerequisites",
676
+ !guard && "admission",
677
+ !skip && "admission history"
678
+ ].filter(Boolean);
679
+ const readDiagnostics = unavailable.length ? [{
680
+ label: "Health data",
681
+ status: "warning",
682
+ value: "Unavailable",
683
+ detail: unavailable.join(", ")
684
+ }] : [];
685
+ const lastSkip = skip?.lastSkip;
676
686
  return {
677
687
  ...health,
678
- status: prerequisites.pause ? "degraded" : health.status,
679
- diagnostics: [...health.diagnostics, ...prerequisites.diagnostics],
688
+ status: health?.status === "healthy" && !prerequisites?.pause && !schedulerDiagnostics.length && !unavailable.length ? "healthy" : "degraded",
689
+ diagnostics: [
690
+ ...health?.diagnostics ?? [],
691
+ ...prerequisites?.diagnostics ?? [],
692
+ ...schedulerDiagnostics,
693
+ ...readDiagnostics
694
+ ],
695
+ scheduler,
680
696
  release: agent.version,
681
697
  framework: { buildRevision },
682
698
  concurrency: agent.options.concurrency,
683
699
  repositories: repositories.known(),
684
700
  repositorySource: repositories.source,
685
- queue: {
701
+ ...queue ? { queue: {
686
702
  ...babysitterQueueHealth(queue),
687
703
  parked: budgetParks(queue)
688
- },
689
- admission: {
690
- accepting: guard.accepting,
691
- hostOnly: guard.hostOnly,
692
- reason: guard.reason,
693
- retryAt: guard.retryAt,
694
- detail: guard.detail,
695
- lastSkip,
696
- history: { lastSkip }
697
- },
698
- budget: {
699
- accounting: guard.accounting,
700
- observedAt: new Date(guard.observedAt).toISOString(),
701
- hourly: {
702
- inputTokens: guard.state.hourlyInputTokens,
703
- limit: guard.limits.hourlyInputTokens,
704
- resetsAt: guard.state.windows.hourEnd
704
+ } } : {},
705
+ ...guard ? {
706
+ admission: {
707
+ accepting: guard.accepting,
708
+ hostOnly: guard.hostOnly,
709
+ reason: guard.reason,
710
+ retryAt: guard.retryAt,
711
+ detail: guard.detail,
712
+ lastSkip,
713
+ history: { lastSkip }
705
714
  },
706
- daily: {
707
- inputTokens: guard.state.dailyInputTokens,
708
- limit: guard.limits.dailyInputTokens,
709
- resetsAt: guard.state.windows.dayEnd
710
- },
711
- tmp: {
712
- dir: guard.state.tmpDir,
713
- freeBytes: guard.state.freeTmpBytes,
714
- minFreeBytes: guard.limits.minFreeTmpBytes
715
- },
716
- pause: guard.state.pause,
717
- errors: guard.state.errors
718
- }
715
+ budget: {
716
+ accounting: guard.accounting,
717
+ observedAt: new Date(guard.observedAt).toISOString(),
718
+ hourly: {
719
+ inputTokens: guard.state.hourlyInputTokens,
720
+ limit: guard.limits.hourlyInputTokens,
721
+ resetsAt: guard.state.windows.hourEnd
722
+ },
723
+ daily: {
724
+ inputTokens: guard.state.dailyInputTokens,
725
+ limit: guard.limits.dailyInputTokens,
726
+ resetsAt: guard.state.windows.dayEnd
727
+ },
728
+ tmp: {
729
+ dir: guard.state.tmpDir,
730
+ freeBytes: guard.state.freeTmpBytes,
731
+ minFreeBytes: guard.limits.minFreeTmpBytes
732
+ },
733
+ pause: guard.state.pause,
734
+ errors: guard.state.errors
735
+ }
736
+ } : {}
719
737
  };
720
738
  }
721
739
  };
722
740
  }
741
+ function boundedHealthRead(read) {
742
+ let pending;
743
+ return () => pending ??= new Promise((resolve) => {
744
+ const timer = setTimeout(() => resolve(void 0), 1e3);
745
+ Promise.resolve().then(read).then(resolve, () => resolve(void 0)).finally(() => {
746
+ clearTimeout(timer);
747
+ pending = void 0;
748
+ });
749
+ });
750
+ }
723
751
  //#endregion
724
752
  export { createBabysitterProcessHost };
@@ -1,5 +1,5 @@
1
1
  import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentRuntimeContext, ConfiguredAgentDefinition } from "@vite-hub/agent";
2
- import { GmailClient, GmailLabelSettings } from "@vite-hub/agent/channels";
2
+ import { GmailChannel, GmailClient, GmailLabelSettings } from "@vite-hub/agent/channels";
3
3
  //#region src/labeller.d.ts
4
4
  export interface LabellerLabel extends GmailLabelSettings {}
5
5
  export type LabellerPattern = string | readonly string[];
@@ -64,7 +64,11 @@ type LabellerResult = {
64
64
  };
65
65
  rule?: string;
66
66
  };
67
- type LabellerDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvoker, AgentInvocationContextValues, LabellerResult | LabellerDecision>;
67
+ type LabellerDefinition = AgentDefinition<AgentRuntimeConfig, unknown, AgentInvoker, AgentInvocationContextValues, LabellerResult | LabellerDecision> & {
68
+ readonly channels: {
69
+ readonly gmail: GmailChannel;
70
+ };
71
+ };
68
72
  export type LabellerAgent = ConfiguredAgentDefinition<LabellerOptions, LabellerDefinition>;
69
73
  /** Gmail labelling preset: ordered rules first, then a constrained Jev choice. */
70
74
  export declare const labeller: LabellerAgent;
package/dist/labeller.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as isRuntimeRecord, t as presetsErrorDiagnostics } from "./error-diagnostics-BTBW9sZx.js";
1
+ import { i as isRuntimeRecord, t as presetsErrorDiagnostics } from "./error-diagnostics-o3pHscWs.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";
@@ -178,6 +178,7 @@ const labeller = defineAgent({
178
178
  if (materializingTemplate) {
179
179
  materializingTemplate = false;
180
180
  return defineAgent({
181
+ channels: { gmail: gmail({ dryRun: true }) },
181
182
  driver: { run: () => {
182
183
  throw presetsErrorDiagnostics.PRESETS_LABELLER_LABEL_COUNT_INVALID();
183
184
  } },