Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestProvider.ts

668 lines27.8 KB

1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import type {
4 PullRequestStackMembership,
5 PullRequestAction,
6 PullRequestStackHead,
7 PullRequestActor,
8 PullRequestBaseComparison,
9 PullRequestCapabilities,
10 PullRequestChecksState,
11 PullRequestCheck,
12 PullRequestChecks,
13 PullRequestComment,
14 PullRequestFileViewed,
15 PullRequestCommit,
16 PullRequestInvolvement,
17 PullRequestLabel,
18 PullRequestListFilters,
19 PullRequestListState,
20 PullRequestMergeCapabilities,
21 PullRequestMergeMethod,
22 PullRequestMergeability,
23 PullRequestOmittedFileStat,
24 PullRequestReaction,
25 PullRequestReactionContent,
26 PullRequestReviewCommentDraft,
27 PullRequestReviewDecision,
28 PullRequestReviewThread,
29 PullRequestThreadCommentsResult,
30 PullRequestReviewVerdict,
31 PullRequestReviewerCandidateList,
32 PullRequestReviewerKind,
33 PullRequestLabelCandidateList,
34 PullRequestState,
35 PullRequestPreview,
36 PullRequestUpdateMethod,
37 PullRequestViewerPermissions,
38 SourceControlProviderKind,
39} from "@t3tools/contracts";
40import { SourceControlProviderKind as SourceControlProviderKindSchema } from "@t3tools/contracts";
41​
42/**
43 * The one failure shape every provider reports, so the service can decide what a failure means
44 * without knowing which CLI or API produced it.
45 *
46 * `reason` is the part the service acts on: a missing or unauthenticated tool disables the
47 * provider for the whole workspace, a rate limit pauses its host, and anything else is specific
48 * to the request.
49 */
50export class PullRequestProviderError extends Schema.TaggedError<PullRequestProviderError>()(
51 "PullRequestProviderError",
52 {
53 provider: SourceControlProviderKindSchema,
54 operation: Schema.String,
55 reason: Schema.Literals(["missing-tool", "unauthenticated", "rate-limited", "failed"]),
56 detail: Schema.String,
57 retryAt: Schema.optional(Schema.Number),
58 cause: Schema.optional(Schema.Defect()),
59 },
60) {
61 override get message(): string {
62 return `${this.provider} failed in ${this.operation}: ${this.detail}`;
63 }
65​
66export interface PullRequestProviderFailure {
67 readonly reason: PullRequestProviderError["reason"];
68 readonly retryAt?: number | undefined;
70​
71/** A change request as the provider sees it, before the service attaches project context. */
72export interface ProviderChangeRequest {
73 readonly stack?: PullRequestStackMembership;
74 readonly number: number;
75 readonly title: string;
76 readonly url: string;
77 readonly author: PullRequestActor | null;
78 readonly headBranch: string;
79 readonly headRepositoryNameWithOwner?: string | null;
80 readonly baseBranch: string;
81 readonly state: PullRequestState;
82 readonly isDraft: boolean;
83 readonly mergeability: PullRequestMergeability;
84 readonly additions: number;
85 readonly deletions: number;
86 readonly createdAt: string;
87 readonly closedAt?: string | null;
88 readonly mergedAt?: string | null;
89 readonly updatedAt: string;
90 /** Accounts with a review requested. Team-level requests are excluded by each provider. */
91 readonly reviewRequestLogins: ReadonlyArray<string>;
92 readonly labels: ReadonlyArray<PullRequestLabel>;
93 /** Absent from a host that does not summarise its reviews, which is every host but GitHub. */
94 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
95 /** Absent from a host that reports no check rollup on its listings. */
96 readonly checksState?: PullRequestChecksState | null | undefined;
98​
99/** The fields needed to keep a linked thread's pull request status live. */
100export interface ProviderChangeRequestSummary {
101 readonly number: number;
102 readonly title: string;
103 readonly url: string;
104 readonly headBranch: string;
105 readonly baseBranch: string;
106 readonly state: PullRequestState;
107 /** Present when the host says an open pull request is still a draft. */
108 readonly isDraft?: boolean;
109 readonly closedAt?: string | null;
110 readonly mergedAt?: string | null;
111 readonly updatedAt: string;
112 /** Overview fields, present where the host's single read returns them at no extra cost. */
113 readonly author?: PullRequestActor | null | undefined;
114 readonly additions?: number | undefined;
115 readonly deletions?: number | undefined;
116 readonly changedFiles?: number | undefined;
117 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
118 readonly checksState?: PullRequestChecksState | null | undefined;
119 readonly mergeability?: PullRequestMergeability | undefined;
121​
122/** One layer of a host-native stack, bottom to top order is the array's. */
123export interface ProviderChangeRequestStackLayer {
124 readonly title?: string;
125 readonly isDraft?: boolean;
126 readonly headSha?: string;
127 readonly number: number;
128 readonly headBranch: string;
129 readonly state: PullRequestState;
131​
132/**
133 * A host-native stack: an ordered set of change requests the host itself merges and retargets as
134 * a unit. Only GitHub offers one today; the neutral shape lets the sync reactor and the UI stay
135 * ignorant of which host said so.
136 */
137export interface ProviderChangeRequestStack {
138 readonly id: string;
139 readonly number: number;
140 readonly url: string;
141 readonly base: string;
142 readonly layers: ReadonlyArray<ProviderChangeRequestStackLayer>;
144​
145export interface ProviderChangeRequestPage {
146 readonly items: ReadonlyArray<ProviderChangeRequest>;
147 /** True when the host has more rows than the page size asked for. */
148 readonly truncated: boolean;
149 /**
150 * Optional count-based cursor advance. Most hosts advance by the rows delivered after local
151 * de-duplication; an offset-paged host may need to count malformed raw rows it consumed too.
152 */
153 readonly cursorAdvance?: number;
154 /**
155 * This page can be carried on from, so the service may hand the caller a cursor for it. False
156 * where the host answered in an order a cursor means nothing in, which leaves a larger `limit`
157 * as the only way to the rest — what every listing did before there were cursors.
158 */
159 readonly continues: boolean;
161​
162/**
163 * Where a repository's next slice starts, as the provider that has to ask for it needs it. Built
164 * by the service out of the slice it just handed over, so the boundary that decides whether a row
165 * arrives twice or not at all is decided in one place rather than in four.
166 */
167export interface ProviderListCursor {
168 /**
169 * The instant of the oldest row already handed over, checked against a timestamp's shape before
170 * it gets here because it goes into a host's own filter. Asked for inclusively: several rows
171 * share one instant often enough — a bot that touches eight change requests writes one timestamp
172 * on all eight — and asking for strictly older would lose whichever of them the slice ended
173 * before. The service drops the ones it has already sent.
174 */
175 readonly updatedBefore: string;
176 /**
177 * How many provider rows this repository has consumed so far, for a host that carries on by
178 * counting rather than by date. Usually this is the number handed over; malformed raw rows may
179 * count too when the provider reports a `cursorAdvance`.
180 */
181 readonly delivered: number;
183​
184/** One repository's row inside an answer that spans several of them. */
185export interface ProviderBatchedChangeRequest extends ProviderChangeRequest {
186 /** Provider-native identity, exactly as it was asked for, so the caller can file the row. */
187 readonly repository: string;
189​
190/**
191 * One slice of a host read across several repositories at once, newest update first across all
192 * of them. There is no per-repository page here because the host was asked one question: the
193 * caller splits the rows by `repository` and works out where each of them carries on from the
194 * oldest row in the slice, which every repository the slice covers is now read up to.
195 */
196export interface ProviderBatchedChangeRequestPage {
197 readonly items: ReadonlyArray<ProviderBatchedChangeRequest>;
198 /** True when the host has more rows than the slice asked for, for any of the repositories. */
199 readonly truncated: boolean;
201​
202/** The line counts for one change request, which a listing may leave for a second read. */
203export interface ProviderChangeRequestStat {
204 readonly repository: string;
205 readonly number: number;
206 readonly additions: number;
207 readonly deletions: number;
209​
210export interface ProviderChangeRequestDetail extends ProviderChangeRequest {
211 readonly body: string;
212 readonly changedFiles: number;
213 readonly mergedAt: string | null;
214 readonly closedAt: string | null;
215 readonly reviewers: ReadonlyArray<PullRequestActor>;
216 readonly checks: ReadonlyArray<PullRequestCheck>;
217 readonly mergeCapabilities: PullRequestMergeCapabilities;
218 readonly viewerPermissions: PullRequestViewerPermissions;
219 /** Absent from a host that cannot compare the branch with its base, which is most of them. */
220 readonly baseComparison?: PullRequestBaseComparison;
221 readonly behindBy?: number;
222 /** Absent from a host that does not report whether it is armed to merge this on its own. */
223 readonly autoMergeEnabled?: boolean;
224 /** The strategy stored with an armed auto-merge, where the host reports it. */
225 readonly autoMergeMethod?: PullRequestMergeMethod;
226 /** Workflow runs on this head commit that still need a maintainer's approval. */
227 readonly workflowApprovalsRequired?: number;
229​
230/** The conversation-shaped half of a detail, loaded after the core can already render. */
231export interface ProviderChangeRequestActivity {
232 /** An optional richer actor, e.g. after GitHub's GraphQL read supplies an avatar. */
233 readonly author?: PullRequestActor | null;
234 /** Optional because most hosts already report their reviewer list in the core detail. */
235 readonly reviewers?: ReadonlyArray<PullRequestActor>;
236 readonly comments: ReadonlyArray<PullRequestComment>;
237 /**
238 * The host's own count of the conversation, which a bounded read can fall short of. A host
239 * that reports no count of its own answers with what it handed over, which is the same number
240 * once the read went to the end.
241 */
242 readonly commentCount: number;
243 readonly commentsTruncated: boolean;
244 readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>;
245 readonly commits: ReadonlyArray<PullRequestCommit>;
246 /** The change request's own reactions, from a host that has them. */
247 readonly reactions?: ReadonlyArray<PullRequestReaction>;
249​
250export interface ProviderDiffSlice {
251 readonly patch: string;
252 /** Something in this slice could not be shown, as opposed to there being more slices. */
253 readonly truncated: boolean;
254 readonly nextCursor: string | null;
255 /** The host's own counts for the files whose hunks it withheld from this slice. */
256 readonly omittedFileStats?: ReadonlyArray<PullRequestOmittedFileStat>;
258​
259export interface ProviderDiffFileContents {
260 readonly oldContents: string;
261 readonly newContents: string;
263​
264export interface ProviderFilesViewed {
265 readonly files: ReadonlyArray<PullRequestFileViewed>;
266 /** The host has more files than were read, so the ones missing here are not "unviewed". */
267 readonly truncated: boolean;
269​
270/**
271 * What version each of the asked-for files is at, on the change request's head. Opaque strings,
272 * compared only against one another, where the empty string is the answer for a file the change
273 * request deletes rather than a gap. A path is absent only where the read could not say, so a
274 * provider converts its host's own absences on the way here.
275 *
276 * The whole path a version travels, and the three senses of null along it, are in
277 * `docs/internals/pull-request-file-revisions.md`.
278 */
279export interface ProviderFileRevisions {
280 readonly revisions: ReadonlyMap<string, string>;
281 /**
282 * Whether these are every file the change request carries rather than only the paths asked
283 * about. A host with no per-file version reads the whole change to answer for one file, and
284 * saying so is what keeps the next tick, naming a path nothing asked about before, from making
285 * it read the whole change again. False for a read cut short, which cannot speak past the cut.
286 */
287 readonly complete?: boolean;
289​
290export interface ProviderRepositoryRef {
291 readonly cwd: string;
292 /** Provider-native repository identity, e.g. `owner/repo` or `group/subgroup/project`. */
293 readonly repository: string;
294 /**
295 * The host it lives on, which `repository` deliberately leaves out — the same `owner/repo`
296 * exists on github.com and on a GitHub Enterprise install, and only the caller knows which
297 * one a project's remote points at.
298 */
299 readonly host: string;
301​
302/**
303 * One host's change requests. Implementations own their own tool and JSON shapes and hand back
304 * the neutral types above; anything a host cannot do is declared in `capabilities` rather than
305 * failing at call time.
306 */
307export interface PullRequestProviderApi {
308 readonly withVerifiedCredential?: <A, E, R>(
309 input: { readonly cwd: string; readonly host: string },
310 use: (identity: {
311 readonly accountId: string;
312 readonly viewer: string;
313 readonly credentialFingerprint: string;
314 }) => Effect.Effect<A, E, R>,
315 ) => Effect.Effect<A, E | PullRequestProviderError, R>;
316 readonly getRoutingIdentity?: (input: {
317 readonly cwd: string;
318 readonly host: string;
319 }) => Effect.Effect<
320 { readonly accountId: string; readonly viewer: string },
321 PullRequestProviderError
322 >;
323 readonly kind: SourceControlProviderKind;
324 readonly capabilities: PullRequestCapabilities;
325​
326 /** The signed-in account, which is what involvement filtering compares against. */
327 readonly getViewer: (input: {
328 readonly cwd: string;
329 readonly host?: string;
330 }) => Effect.Effect<string, PullRequestProviderError>;
331​
332 readonly listChangeRequests: (
333 input: ProviderRepositoryRef & {
334 readonly state: PullRequestListState;
335 readonly involvement: PullRequestInvolvement;
336 readonly viewer: string;
337 readonly limit: number;
338 /**
339 * Free text to narrow the listing by, as the host understands it. A host with no text
340 * filter of its own ignores it and answers with the page it would have answered with
341 * anyway — the caller narrows what it gets, so an unfiltered page is a wider answer
342 * rather than a wrong one.
343 */
344 readonly query?: string | undefined;
345 /**
346 * Where to carry on from, rather than reading this repository from its newest row. Absent
347 * asks for the first slice, which is every listing that has not been continued.
348 */
349 readonly cursor?: ProviderListCursor | undefined;
350 /**
351 * Further narrowings, which a host applies as far as it can and ignores the rest of —
352 * an unnarrowed page is a wider answer rather than a wrong one, and the caller narrows
353 * what it gets for the fields a row carries.
354 */
355 readonly filters?: PullRequestListFilters | undefined;
356 },
357 ) => Effect.Effect<ProviderChangeRequestPage, PullRequestProviderError>;
358​
359 /**
360 * The same listing for a whole host in one request, for a host that has a search across
361 * repositories. Optional: three of the four hosts here have no such API, and breaking the port
362 * for them to spare GitHub a fan-out would be paying for the fix with everyone else's clarity.
363 * The caller falls back to `listChangeRequests` per repository where this is absent, and where
364 * it fails.
365 *
366 * `limit` is the whole slice rather than a size per repository, because that is the shape of
367 * the answer: the newest `limit` rows across every repository named, which is exactly the rows
368 * a page ordered by update shows.
369 *
370 * `cursor` is one boundary for all of them, so a caller with repositories standing at different
371 * boundaries asks in groups rather than in one call.
372 */
373 readonly listChangeRequestsAcross?: (input: {
374 /** Any checkout on the host, which is what the tool is run in. */
375 readonly cwd: string;
376 readonly host: string;
377 readonly repositories: ReadonlyArray<string>;
378 readonly state: PullRequestListState;
379 readonly involvement: PullRequestInvolvement;
380 readonly viewer: string;
381 readonly limit: number;
382 readonly query?: string | undefined;
383 readonly cursor?: ProviderListCursor | undefined;
384 readonly filters?: PullRequestListFilters | undefined;
385 }) => Effect.Effect<ProviderBatchedChangeRequestPage, PullRequestProviderError>;
386​
387 /**
388 * The line counts for rows a listing has already handed over. Only implemented by a provider
389 * whose listing leaves them out — for everyone else the numbers arrived with the row, and the
390 * caller has nothing to ask for.
391 */
392 readonly listChangeRequestStats?: (input: {
393 readonly cwd: string;
394 readonly host: string;
395 readonly changeRequests: ReadonlyArray<{
396 readonly repository: string;
397 readonly number: number;
398 }>;
399 }) => Effect.Effect<ReadonlyArray<ProviderChangeRequestStat>, PullRequestProviderError>;
400​
401 readonly getChangeRequestChecks?: (
402 input: ProviderRepositoryRef & { readonly number: number },
403 ) => Effect.Effect<PullRequestChecks, PullRequestProviderError>;
404​
405 readonly getChangeRequest: (
406 input: ProviderRepositoryRef & { readonly number: number },
407 ) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>;
408​
409 /** Hosts without a narrow read use their existing detail response for hover cards. */
410 readonly getChangeRequestPreview?: (
411 input: ProviderRepositoryRef & { readonly number: number },
412 ) => Effect.Effect<
413 Omit<PullRequestPreview, "projectId" | "repository">,
414 PullRequestProviderError
415 >;
416​
417 /**
418 * The cheap live fields used by linked threads. Optional because a provider without a narrow
419 * endpoint can fall back to its full detail read at the service boundary.
420 */
421 readonly getChangeRequestSummary?: (
422 input: ProviderRepositoryRef & { readonly number: number },
423 ) => Effect.Effect<ProviderChangeRequestSummary, PullRequestProviderError>;
424​
425 /**
426 * The host-native stack a change request belongs to, or null when it is not stacked. Optional
427 * because most hosts have no such object; the service derives chains from base branches there.
428 */
429 readonly getChangeRequestStack?: (
430 input: ProviderRepositoryRef & { readonly includeDetails?: boolean; readonly number: number },
431 ) => Effect.Effect<ProviderChangeRequestStack | null, PullRequestProviderError>;
432​
433 /** Comments, line threads, and commits, kept off the critical path for the core detail. */
434 readonly getChangeRequestActivity: (
435 input: ProviderRepositoryRef & { readonly number: number },
436 ) => Effect.Effect<ProviderChangeRequestActivity, PullRequestProviderError>;
437​
438 /** One explicit page after a reader asks to continue an unfinished review thread. */
439 readonly getReviewThreadComments?: (
440 input: ProviderRepositoryRef & {
441 readonly number: number;
442 readonly threadId: string;
443 readonly cursor: string;
444 },
445 ) => Effect.Effect<PullRequestThreadCommentsResult, PullRequestProviderError>;
446​
447 /**
448 * The same answer `getChangeRequest` carries, on its own. Asked before anything is written, so
449 * a request that reached the server without going past the page is refused by what the host
450 * says rather than by what the client claimed — and asked freshly, because access granted or
451 * taken away since the page loaded is exactly the case this guards.
452 *
453 * Implementations read the cheapest thing that answers it, which for a host with nothing to say
454 * is no request at all.
455 */
456 readonly getViewerPermissions: (
457 input: ProviderRepositoryRef & {
458 readonly number: number;
459 /** Skip branch comparison when checking permission for an unrelated operation. */
460 readonly includeUpdateBranch?: boolean;
461 },
462 ) => Effect.Effect<PullRequestViewerPermissions, PullRequestProviderError>;
463​
464 /**
465 * One slice of the patch. Only called when `capabilities.diff` is true. A provider that can
466 * serve the whole diff at once answers with `nextCursor: null` and is done; one that pages
467 * hands back whatever it needs to find the next slice.
468 */
469 readonly getDiff: (
470 input: ProviderRepositoryRef & {
471 readonly number: number;
472 readonly cursor?: string | undefined;
473 /** One commit's own changes, rather than everything the change request carries. */
474 readonly commit?: string | undefined;
475 },
476 ) => Effect.Effect<ProviderDiffSlice, PullRequestProviderError>;
477​
478 /**
479 * Full files at the exact revisions the host used for its patch. Optional where the provider
480 * exposes no diff at all; the service refuses expansion there just as it refuses the patch.
481 */
482 readonly getDiffFileContents?: (
483 input: ProviderRepositoryRef & {
484 readonly number: number;
485 readonly commit?: string | undefined;
486 readonly changeType: "change" | "rename-pure" | "rename-changed" | "new" | "deleted";
487 readonly oldPath: string;
488 readonly newPath: string;
489 },
490 ) => Effect.Effect<ProviderDiffFileContents, PullRequestProviderError>;
491​
492 /**
493 * Which files the reader has already cleared. Only called when `capabilities.viewedFiles` is
494 * `"host"`, and read apart from the patch: this moves with every press rather than every push.
495 */
496 readonly getFilesViewed?: (
497 input: ProviderRepositoryRef & { readonly number: number },
498 ) => Effect.Effect<ProviderFilesViewed, PullRequestProviderError>;
499​
500 /**
501 * Clears files, or puts them back. Only called when `capabilities.viewedFiles` is `"host"`.
502 * A host with no bulk form is still owed one round trip for the batch rather than one per file,
503 * since the point of gathering presses is that the host is asked once.
504 */
505 readonly setFilesViewed?: (
506 input: ProviderRepositoryRef & {
507 readonly number: number;
508 readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>;
509 },
510 ) => Effect.Effect<void, PullRequestProviderError>;
511​
512 /**
513 * What version the head has of each of these files. Required of a host whose
514 * `capabilities.viewedFiles` is `"environment"`, and unused by one that keeps the marks itself:
515 * the marks live here, but only the host can say whether what a reader cleared last week is
516 * still what is in front of them. Asked for the marked paths alone, so the cost follows how
517 * much of the change request has been read rather than how large it is.
518 */
519 readonly getFileRevisions?: (
520 input: ProviderRepositoryRef & {
521 readonly number: number;
522 readonly paths: ReadonlyArray<string>;
523 },
524 ) => Effect.Effect<ProviderFileRevisions, PullRequestProviderError>;
525​
526 readonly runAction: (
527 input: ProviderRepositoryRef & {
528 readonly number: number;
529 readonly action: PullRequestAction;
530 readonly stackNumber?: number;
531 readonly expectedStackHeads?: ReadonlyArray<PullRequestStackHead>;
532 /** Meaningful for `merge` and `enable-auto-merge`; absent takes the host's own default. */
533 readonly mergeMethod?: PullRequestMergeMethod;
534 /** Only meaningful for `update-branch`; absent takes the host's own default. */
535 readonly updateMethod?: PullRequestUpdateMethod;
536 },
537 ) => Effect.Effect<void, PullRequestProviderError>;
538​
539 /**
540 * Rewrites the change request's own words. Only called when `capabilities.edit.changeRequest`
541 * is true, and never with both fields absent — the caller refuses that before it gets here,
542 * because a host asked to change nothing answers differently on each of them.
543 */
544 readonly updateChangeRequest?: (
545 input: ProviderRepositoryRef & {
546 readonly number: number;
547 readonly title?: string | undefined;
548 readonly body?: string | undefined;
549 },
550 ) => Effect.Effect<void, PullRequestProviderError>;
551​
552 readonly comment: (
553 input: ProviderRepositoryRef & { readonly number: number; readonly body: string },
554 ) => Effect.Effect<void, PullRequestProviderError>;
555​
556 /**
557 * Rewrites a remark somebody already posted. Only called when `capabilities.edit.comment` is
558 * true, with an id exactly as the conversation carried it.
559 *
560 * Whether this remark is the reader's to rewrite is the host's own answer: no read here can
561 * settle it, since access can be taken away between the conversation being read and the
562 * rewrite being sent, and a host refuses a stranger's remark with a sentence saying so.
563 */
564 readonly updateComment?: (
565 input: ProviderRepositoryRef & {
566 readonly number: number;
567 readonly commentId: string;
568 readonly kind: "issue-comment" | "review-comment";
569 readonly body: string;
570 },
571 ) => Effect.Effect<void, PullRequestProviderError>;
572​
573 /**
574 * Sends a whole review at once. Only called for a verdict the host declared in
575 * `capabilities.review.verdicts`, and with line comments only where it declared
576 * `inlineComment`.
577 */
578 readonly submitReview: (
579 input: ProviderRepositoryRef & {
580 readonly number: number;
581 readonly verdict: PullRequestReviewVerdict;
582 readonly body: string;
583 readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>;
584 },
585 ) => Effect.Effect<void, PullRequestProviderError>;
586​
587 /**
588 * The people this viewer may ask for a review, with whoever has already been asked marked as
589 * such. Only called when `capabilities.reviewers.listCandidates` is true.
590 *
591 * The author is left out by each provider rather than by the caller, because only the provider
592 * knows how the host spells the same person in a candidate list and on a pull request.
593 */
594 readonly listReviewerCandidates: (
595 input: ProviderRepositoryRef & { readonly number: number },
596 ) => Effect.Effect<PullRequestReviewerCandidateList, PullRequestProviderError>;
597​
598 /**
599 * Asks for a review, or takes the request back. Only called when
600 * `capabilities.reviewers.request` is true.
601 *
602 * One call for both directions, because that is what every host does with them: GitHub posts and
603 * deletes the same collection, and GitLab and Bitbucket write the whole reviewer set either way.
604 * Asking again somebody who has already reviewed is a request like any other — which is how a
605 * re-request is made.
606 */
607 readonly setReviewerRequest: (
608 input: ProviderRepositoryRef & {
609 readonly number: number;
610 readonly reviewers: ReadonlyArray<{
611 readonly id: string;
612 readonly kind: PullRequestReviewerKind;
613 }>;
614 readonly requested: boolean;
615 },
616 ) => Effect.Effect<void, PullRequestProviderError>;
617​
618 /**
619 * The repository's labels, with the ones already on the change request marked. Present with
620 * `setLabels` only where `capabilities.labels` is true; the service refuses both without it.
621 */
622 readonly listLabelCandidates?: (
623 input: ProviderRepositoryRef & { readonly number: number },
624 ) => Effect.Effect<PullRequestLabelCandidateList, PullRequestProviderError>;
625​
626 /** Puts labels on the change request, or takes them off. One call for both directions. */
627 readonly setLabels?: (
628 input: ProviderRepositoryRef & {
629 readonly number: number;
630 readonly labels: ReadonlyArray<string>;
631 readonly applied: boolean;
632 },
633 ) => Effect.Effect<void, PullRequestProviderError>;
634​
635 /** Only called when `capabilities.review.reply` is true. */
636 readonly replyToThread: (
637 input: ProviderRepositoryRef & {
638 readonly number: number;
639 readonly threadId: string;
640 readonly body: string;
641 },
642 ) => Effect.Effect<void, PullRequestProviderError>;
643​
644 /**
645 * Adds a reaction, or takes it back. Only called when `capabilities.reactions` is true.
646 *
647 * `subjectId` is a remark's id as the conversation carried it; absent means the change request
648 * itself, whose reactions sit on its description. Whatever a host needs to address either of
649 * them is worked out here, because the id a conversation travels with is the one the reader has.
650 */
651 readonly setReaction: (
652 input: ProviderRepositoryRef & {
653 readonly number: number;
654 readonly subjectId?: string | undefined;
655 readonly content: PullRequestReactionContent;
656 readonly reacted: boolean;
657 },
658 ) => Effect.Effect<void, PullRequestProviderError>;
659​
660 /** Only called when `capabilities.review.resolve` is true. */
661 readonly setThreadResolution: (
662 input: ProviderRepositoryRef & {
663 readonly number: number;
664 readonly threadId: string;
665 readonly resolved: boolean;
666 },
667 ) => Effect.Effect<void, PullRequestProviderError>;