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