The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as Schema from "effect/Schema"; |
| 3 | import type * as Stream from "effect/Stream"; |
| 4 | import type { |
| 5 | PullRequestStackMembership, |
| 6 | PullRequestAction, |
| 7 | PullRequestStackHead, |
| 8 | PullRequestActor, |
| 9 | PullRequestReferenceCandidate, |
| 10 | PullRequestReferenceSigil, |
| 11 | PullRequestBaseComparison, |
| 12 | PullRequestCapabilities, |
| 13 | PullRequestChecksState, |
| 14 | PullRequestCheck, |
| 15 | PullRequestChecks, |
| 16 | PullRequestComment, |
| 17 | PullRequestFileViewed, |
| 18 | PullRequestCommit, |
| 19 | PullRequestInvolvement, |
| 20 | PullRequestLabel, |
| 21 | PullRequestListFilters, |
| 22 | PullRequestListState, |
| 23 | PullRequestMergeCapabilities, |
| 24 | PullRequestMergeMethod, |
| 25 | PullRequestMergeQueueRemoval, |
| 26 | PullRequestMergeability, |
| 27 | PullRequestOmittedFileStat, |
| 28 | PullRequestReaction, |
| 29 | PullRequestReactionContent, |
| 30 | PullRequestReviewCommentDraft, |
| 31 | PullRequestReviewDecision, |
| 32 | PullRequestOverviewThread, |
| 33 | PullRequestReviewThread, |
| 34 | PullRequestThreadCommentsResult, |
| 35 | PullRequestReviewVerdict, |
| 36 | PullRequestReviewerCandidateList, |
| 37 | PullRequestReviewerKind, |
| 38 | PullRequestLabelCandidateList, |
| 39 | PullRequestState, |
| 40 | PullRequestPreview, |
| 41 | PullRequestUpdateMethod, |
| 42 | PullRequestViewerPermissions, |
| 43 | SourceControlProviderKind, |
| 44 | } from "@t3tools/contracts"; |
| 45 | import { SourceControlProviderKind as SourceControlProviderKindSchema } from "@t3tools/contracts"; |
| 46 | |
| 47 | export class PullRequestProviderError extends Schema.TaggedError<PullRequestProviderError>()( |
| 48 | "PullRequestProviderError", |
| 49 | { |
| 50 | provider: SourceControlProviderKindSchema, |
| 51 | operation: Schema.String, |
| 52 | reason: Schema.Literals([ |
| 53 | "missing-tool", |
| 54 | "unauthenticated", |
| 55 | "forbidden", |
| 56 | "rate-limited", |
| 57 | "not-found", |
| 58 | "failed", |
| 59 | ]), |
| 60 | detail: Schema.String, |
| 61 | retryAt: Schema.optional(Schema.Number), |
| 62 | /** |
| 63 | * Why the host would not return a repository and what to change, in the reader's terms. |
| 64 | * Shown beside that repository in the list; `detail` is about the failed call instead. |
| 65 | */ |
| 66 | accessHint: Schema.optional(Schema.String), |
| 67 | cause: Schema.optional(Schema.Defect()), |
| 68 | }, |
| 69 | ) { |
| 70 | override get message(): string { |
| 71 | return `${this.provider} failed in ${this.operation}: ${this.detail}`; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | export interface ProviderChangeRequestWatchFingerprint { |
| 76 | readonly status: string; |
| 77 | readonly remarks: string; |
| 78 | /** True when `status` changes with every check and mergeability change, so pending work needs no detail read. */ |
| 79 | readonly coversDetail?: boolean; |
| 80 | } |
| 81 | |
| 82 | export interface PullRequestProviderFailure { |
| 83 | readonly reason: PullRequestProviderError["reason"]; |
| 84 | readonly retryAt?: number | undefined; |
| 85 | readonly accessHint?: string | undefined; |
| 86 | } |
| 87 | |
| 88 | export interface ProviderChangeRequest { |
| 89 | readonly stack?: PullRequestStackMembership; |
| 90 | readonly number: number; |
| 91 | readonly title: string; |
| 92 | readonly url: string; |
| 93 | readonly author: PullRequestActor | null; |
| 94 | readonly headBranch: string; |
| 95 | readonly headRepositoryNameWithOwner?: string | null; |
| 96 | readonly baseBranch: string; |
| 97 | readonly state: PullRequestState; |
| 98 | readonly isDraft: boolean; |
| 99 | readonly mergeability: PullRequestMergeability; |
| 100 | readonly rebaseRequired?: boolean | undefined; |
| 101 | readonly additions: number; |
| 102 | readonly deletions: number; |
| 103 | readonly createdAt: string; |
| 104 | readonly closedAt?: string | null; |
| 105 | readonly mergedAt?: string | null; |
| 106 | readonly updatedAt: string; |
| 107 | readonly reviewRequestLogins: ReadonlyArray<string>; |
| 108 | readonly labels: ReadonlyArray<PullRequestLabel>; |
| 109 | readonly reviewDecision?: PullRequestReviewDecision | null | undefined; |
| 110 | readonly checksState?: PullRequestChecksState | null | undefined; |
| 111 | } |
| 112 | |
| 113 | export interface ProviderChangeRequestSummary { |
| 114 | readonly number: number; |
| 115 | readonly title: string; |
| 116 | readonly url: string; |
| 117 | readonly headBranch: string; |
| 118 | readonly baseBranch: string; |
| 119 | readonly state: PullRequestState; |
| 120 | readonly isDraft?: boolean; |
| 121 | readonly closedAt?: string | null; |
| 122 | readonly mergedAt?: string | null; |
| 123 | readonly updatedAt: string; |
| 124 | readonly author?: PullRequestActor | null | undefined; |
| 125 | readonly additions?: number | undefined; |
| 126 | readonly deletions?: number | undefined; |
| 127 | readonly changedFiles?: number | undefined; |
| 128 | readonly reviewDecision?: PullRequestReviewDecision | null | undefined; |
| 129 | readonly checksState?: PullRequestChecksState | null | undefined; |
| 130 | readonly mergeability?: PullRequestMergeability | undefined; |
| 131 | readonly rebaseRequired?: boolean | undefined; |
| 132 | /** Null means no stack; absent means not requested. */ |
| 133 | readonly stack?: PullRequestStackMembership | null | undefined; |
| 134 | readonly headSha?: string | undefined; |
| 135 | /** Absent means the read did not report auto-merge state, not that it is off. */ |
| 136 | readonly autoMergeEnabled?: boolean | undefined; |
| 137 | readonly autoMergeMethod?: PullRequestMergeMethod | undefined; |
| 138 | } |
| 139 | |
| 140 | export interface ProviderChangeRequestStackLayer { |
| 141 | readonly title?: string; |
| 142 | readonly isDraft?: boolean; |
| 143 | readonly headSha?: string; |
| 144 | readonly number: number; |
| 145 | readonly headBranch: string; |
| 146 | readonly state: PullRequestState; |
| 147 | } |
| 148 | |
| 149 | export interface ProviderChangeRequestStack { |
| 150 | readonly id: string; |
| 151 | readonly number: number; |
| 152 | readonly url: string; |
| 153 | readonly base: string; |
| 154 | readonly layers: ReadonlyArray<ProviderChangeRequestStackLayer>; |
| 155 | } |
| 156 | |
| 157 | export interface ProviderChangeRequestPage { |
| 158 | readonly items: ReadonlyArray<ProviderChangeRequest>; |
| 159 | readonly truncated: boolean; |
| 160 | /** Offset-paged hosts must include malformed raw rows in their advance count. */ |
| 161 | readonly cursorAdvance?: number; |
| 162 | /** |
| 163 | * Where a host that can only page from the top carries on: an opaque position past the last |
| 164 | * row delivered, handed back as the cursor's `resumeAfter`. Unlike a count of rows it survives |
| 165 | * rows above it closing between reads. |
| 166 | */ |
| 167 | readonly resumeAfter?: string; |
| 168 | readonly continues: boolean; |
| 169 | } |
| 170 | |
| 171 | export interface ProviderListCursor { |
| 172 | /** Inclusive boundary: equal-time rows can span pages and must not be skipped. */ |
| 173 | readonly updatedBefore: string; |
| 174 | readonly delivered: number; |
| 175 | /** |
| 176 | * Rows already handed over at `updatedBefore`. Timestamp-paged hosts can exclude these before |
| 177 | * applying their limit so a full page of tied updates does not repeat the same prefix. |
| 178 | */ |
| 179 | readonly seenAt?: ReadonlyArray<number> | undefined; |
| 180 | readonly resumeAfter?: string | undefined; |
| 181 | } |
| 182 | |
| 183 | /** One search spans several repositories, so the rows seen at the boundary name theirs. */ |
| 184 | export interface ProviderAcrossListCursor extends Omit<ProviderListCursor, "seenAt"> { |
| 185 | readonly seenAt?: ReadonlyArray<ProviderRepositoryNumber> | undefined; |
| 186 | } |
| 187 | |
| 188 | export interface ProviderRepositoryNumber { |
| 189 | readonly repository: string; |
| 190 | readonly number: number; |
| 191 | } |
| 192 | |
| 193 | export interface ProviderBatchedChangeRequest extends ProviderChangeRequest { |
| 194 | readonly repository: string; |
| 195 | } |
| 196 | |
| 197 | export interface ProviderBatchedChangeRequestPage { |
| 198 | readonly items: ReadonlyArray<ProviderBatchedChangeRequest>; |
| 199 | readonly truncated: boolean; |
| 200 | /** |
| 201 | * Repositories asked about that the page cannot vouch for: its silence about them may be an |
| 202 | * omission rather than an empty answer, so the caller reads each on its own. |
| 203 | */ |
| 204 | readonly unresolved?: ReadonlyArray<string>; |
| 205 | } |
| 206 | |
| 207 | /** A check as the change request's checks name it; the host finds its log or run from the URL. */ |
| 208 | export interface ProviderCheckReference { |
| 209 | readonly name: string; |
| 210 | readonly url: string | null; |
| 211 | } |
| 212 | |
| 213 | export interface ProviderCheckLog { |
| 214 | readonly name: string; |
| 215 | readonly url: string | null; |
| 216 | /** Null when the host holds no log for this check; `detail` says why. */ |
| 217 | readonly log: string | null; |
| 218 | readonly truncated: boolean; |
| 219 | readonly detail: string | null; |
| 220 | } |
| 221 | |
| 222 | export interface ProviderCheckRerun { |
| 223 | readonly name: string; |
| 224 | readonly rerun: boolean; |
| 225 | readonly detail: string | null; |
| 226 | } |
| 227 | |
| 228 | /** The job id of a GitHub Actions check run, from its run link or its job link. */ |
| 229 | export function gitHubActionsJobId(url: string | null): string | null { |
| 230 | if (url === null) return null; |
| 231 | return ( |
| 232 | /\/runs\/\d+\/jobs?\/(\d+)(?:[/?#]|$)/.exec(url)?.[1] ?? |
| 233 | /^https:\/\/[^/]+\/[^/]+\/[^/]+\/runs\/(\d+)(?:[/?#]|$)/.exec(url)?.[1] ?? |
| 234 | null |
| 235 | ); |
| 236 | } |
| 237 | |
| 238 | /** Keeps one minified or progress-bar line from filling the agent's context. */ |
| 239 | const LOG_TAIL_MAX_CHARS = 32_000; |
| 240 | |
| 241 | /** The last `lines` lines of a log, where a failure usually is. */ |
| 242 | export function tailLogLines( |
| 243 | text: string, |
| 244 | lines: number, |
| 245 | ): { readonly log: string; readonly truncated: boolean } { |
| 246 | const all = text.replace(/\n$/, "").split("\n"); |
| 247 | const log = all.slice(-lines).join("\n"); |
| 248 | return log.length > LOG_TAIL_MAX_CHARS |
| 249 | ? { log: log.slice(-LOG_TAIL_MAX_CHARS), truncated: true } |
| 250 | : { log, truncated: all.length > lines }; |
| 251 | } |
| 252 | |
| 253 | export interface ProviderChangeRequestStat { |
| 254 | readonly repository: string; |
| 255 | readonly number: number; |
| 256 | readonly additions: number; |
| 257 | readonly deletions: number; |
| 258 | } |
| 259 | |
| 260 | export interface ProviderChangeRequestDetail extends ProviderChangeRequest { |
| 261 | readonly maintainerCanModify?: boolean; |
| 262 | readonly headSha?: string | null; |
| 263 | readonly body: string; |
| 264 | readonly changedFiles: number; |
| 265 | readonly mergedAt: string | null; |
| 266 | readonly mergeCommitSha?: string | null; |
| 267 | readonly mergedBy?: PullRequestActor | null; |
| 268 | readonly closedAt: string | null; |
| 269 | readonly reviewers: ReadonlyArray<PullRequestActor>; |
| 270 | readonly checks: ReadonlyArray<PullRequestCheck>; |
| 271 | readonly mergeCapabilities: PullRequestMergeCapabilities; |
| 272 | readonly viewerPermissions: PullRequestViewerPermissions; |
| 273 | readonly baseComparison?: PullRequestBaseComparison; |
| 274 | readonly behindBy?: number; |
| 275 | readonly autoMergeEnabled?: boolean; |
| 276 | readonly autoMergeMethod?: PullRequestMergeMethod; |
| 277 | readonly workflowApprovalsRequired?: number; |
| 278 | readonly mergeQueueRemoval?: PullRequestMergeQueueRemoval; |
| 279 | } |
| 280 | |
| 281 | export interface ProviderChangeRequestActivity { |
| 282 | readonly author?: PullRequestActor | null; |
| 283 | readonly reviewers?: ReadonlyArray<PullRequestActor>; |
| 284 | readonly comments: ReadonlyArray<PullRequestComment>; |
| 285 | readonly commentCount: number; |
| 286 | readonly commentsTruncated: boolean; |
| 287 | readonly reviewThreadsTruncated?: boolean; |
| 288 | readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>; |
| 289 | readonly overviewThreads?: ReadonlyArray<PullRequestOverviewThread>; |
| 290 | readonly commits: ReadonlyArray<PullRequestCommit>; |
| 291 | readonly reactions?: ReadonlyArray<PullRequestReaction>; |
| 292 | } |
| 293 | |
| 294 | export interface ProviderDiffSlice { |
| 295 | readonly patch: string; |
| 296 | /** Content was omitted within this slice. */ |
| 297 | readonly truncated: boolean; |
| 298 | readonly nextCursor: string | null; |
| 299 | readonly omittedFileStats?: ReadonlyArray<PullRequestOmittedFileStat>; |
| 300 | readonly withheldFilesReadable?: boolean; |
| 301 | } |
| 302 | |
| 303 | export interface ProviderDiffFileContents { |
| 304 | readonly oldContents: string; |
| 305 | readonly newContents: string; |
| 306 | } |
| 307 | |
| 308 | export interface ProviderDiffFilePaths { |
| 309 | readonly files: ReadonlyArray<{ readonly oldPath: string; readonly newPath: string }>; |
| 310 | readonly nextCursor: string | null; |
| 311 | } |
| 312 | |
| 313 | export interface ProviderFilesViewed { |
| 314 | readonly files: ReadonlyArray<PullRequestFileViewed>; |
| 315 | /** More files exist; missing entries are unknown, not "unviewed". */ |
| 316 | readonly truncated: boolean; |
| 317 | } |
| 318 | |
| 319 | export interface ProviderFileStats { |
| 320 | readonly files: ReadonlyArray<{ |
| 321 | readonly path: string; |
| 322 | readonly additions: number; |
| 323 | readonly deletions: number; |
| 324 | }>; |
| 325 | /** The host has more files than were read. */ |
| 326 | readonly truncated: boolean; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Opaque strings, compared only against one another, where the empty string is the answer for a |
| 331 | * file the change request deletes rather than a gap. A path is absent only where the read could |
| 332 | * not say, so a provider converts its host's own absences on the way here. |
| 333 | */ |
| 334 | export interface ProviderFileRevisions { |
| 335 | readonly revisions: ReadonlyMap<string, string>; |
| 336 | /** All revisions were read and can be reused for other paths. */ |
| 337 | readonly complete?: boolean; |
| 338 | } |
| 339 | |
| 340 | export interface ProviderFilterOptionPage<A> { |
| 341 | readonly items: ReadonlyArray<A>; |
| 342 | readonly truncated: boolean; |
| 343 | } |
| 344 | |
| 345 | export interface ProviderRepositoryRef { |
| 346 | readonly cwd: string; |
| 347 | readonly repository: string; |
| 348 | readonly host: string; |
| 349 | } |
| 350 | |
| 351 | export interface PullRequestProviderApi { |
| 352 | readonly withVerifiedCredential?: <A, E, R>( |
| 353 | /** `repository` lets a host pick the credential that can reach it. */ |
| 354 | input: { readonly cwd: string; readonly host: string; readonly repository?: string }, |
| 355 | use: (identity: { |
| 356 | readonly accountId: string; |
| 357 | readonly viewer: string; |
| 358 | readonly credentialFingerprint: string; |
| 359 | }) => Effect.Effect<A, E, R>, |
| 360 | ) => Effect.Effect<A, E | PullRequestProviderError, R>; |
| 361 | readonly getRoutingIdentity?: (input: { |
| 362 | readonly cwd: string; |
| 363 | readonly host: string; |
| 364 | }) => Effect.Effect< |
| 365 | { readonly accountId: string; readonly viewer: string }, |
| 366 | PullRequestProviderError |
| 367 | >; |
| 368 | readonly kind: SourceControlProviderKind; |
| 369 | readonly capabilities: PullRequestCapabilities; |
| 370 | /** |
| 371 | * What a reader is told when this host cannot be read on the server: `missing` for no tool or |
| 372 | * credential, `unauthenticated` for one the host refused. Absent means a generic sentence. |
| 373 | */ |
| 374 | readonly unavailableRequirement?: { |
| 375 | readonly missing: string; |
| 376 | readonly unauthenticated: string; |
| 377 | }; |
| 378 | readonly mergeMessageRewrite?: (message: string) => string; |
| 379 | /** Use matching checkout keys instead of `owner/name`. */ |
| 380 | readonly repositoryKey?: (input: { readonly canonicalKey: string }) => string; |
| 381 | /** |
| 382 | * Names the repository in every request and authenticates by host, so a change request on the |
| 383 | * definition's `publicHost` can be read from a project with no checkout of its repository. |
| 384 | */ |
| 385 | readonly readsPublicHostWithoutCheckout?: boolean; |
| 386 | /** Concurrent summary reads share requests, so callers may keep many in flight. */ |
| 387 | readonly batchesReads?: boolean; |
| 388 | /** |
| 389 | * Absent means every host detected as this kind is read. A host it refuses is listed as one that |
| 390 | * cannot be browsed here, and nothing is sent for it. |
| 391 | */ |
| 392 | readonly servesHost?: (host: string) => boolean; |
| 393 | |
| 394 | readonly getViewer: (input: { |
| 395 | readonly cwd: string; |
| 396 | readonly host?: string; |
| 397 | }) => Effect.Effect<string, PullRequestProviderError>; |
| 398 | |
| 399 | readonly listChangeRequests: ( |
| 400 | input: ProviderRepositoryRef & { |
| 401 | readonly state: PullRequestListState; |
| 402 | readonly involvement: PullRequestInvolvement; |
| 403 | readonly viewer: string; |
| 404 | readonly limit: number; |
| 405 | /** Hosts may ignore unsupported search; the caller filters returned rows. */ |
| 406 | readonly query?: string | undefined; |
| 407 | readonly cursor?: ProviderListCursor | undefined; |
| 408 | /** The caller applies any filters the host ignores. */ |
| 409 | readonly filters?: PullRequestListFilters | undefined; |
| 410 | }, |
| 411 | ) => Effect.Effect<ProviderChangeRequestPage, PullRequestProviderError>; |
| 412 | |
| 413 | /** Newest `limit` rows total across repositories, under one cursor boundary. */ |
| 414 | readonly listChangeRequestsAcross?: (input: { |
| 415 | readonly cwd: string; |
| 416 | readonly host: string; |
| 417 | readonly repositories: ReadonlyArray<string>; |
| 418 | readonly state: PullRequestListState; |
| 419 | readonly involvement: PullRequestInvolvement; |
| 420 | readonly viewer: string; |
| 421 | readonly limit: number; |
| 422 | readonly query?: string | undefined; |
| 423 | readonly cursor?: ProviderAcrossListCursor | undefined; |
| 424 | readonly filters?: PullRequestListFilters | undefined; |
| 425 | }) => Effect.Effect<ProviderBatchedChangeRequestPage, PullRequestProviderError>; |
| 426 | |
| 427 | readonly listChangeRequestStats?: (input: { |
| 428 | readonly cwd: string; |
| 429 | readonly host: string; |
| 430 | readonly changeRequests: ReadonlyArray<{ |
| 431 | readonly repository: string; |
| 432 | readonly number: number; |
| 433 | }>; |
| 434 | }) => Effect.Effect<ReadonlyArray<ProviderChangeRequestStat>, PullRequestProviderError>; |
| 435 | |
| 436 | readonly getChangeRequestChecks?: ( |
| 437 | input: ProviderRepositoryRef & { readonly number: number }, |
| 438 | ) => Effect.Effect<Pick<PullRequestChecks, "state" | "checks">, PullRequestProviderError>; |
| 439 | |
| 440 | readonly getChangeRequest: ( |
| 441 | input: ProviderRepositoryRef & { readonly number: number }, |
| 442 | ) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>; |
| 443 | |
| 444 | /** |
| 445 | * For a provider that holds change request reads of its own: called when the service drops its |
| 446 | * reads, so a refresh or a finished turn reaches the host. No scope forgets everything; a scope |
| 447 | * without a number forgets the repository's change requests. |
| 448 | */ |
| 449 | readonly forgetChangeRequestReads?: (scope?: { |
| 450 | readonly repository: string; |
| 451 | readonly number?: number; |
| 452 | }) => Effect.Effect<void>; |
| 453 | |
| 454 | readonly getChangeRequestPreview?: ( |
| 455 | input: ProviderRepositoryRef & { readonly number: number }, |
| 456 | ) => Effect.Effect< |
| 457 | Omit<PullRequestPreview, "projectId" | "repository">, |
| 458 | PullRequestProviderError |
| 459 | >; |
| 460 | |
| 461 | readonly getChangeRequestSummary?: ( |
| 462 | input: ProviderRepositoryRef & { readonly number: number }, |
| 463 | ) => Effect.Effect<ProviderChangeRequestSummary, PullRequestProviderError>; |
| 464 | |
| 465 | /** Null means unknown; an absent method requires full watch reads. */ |
| 466 | readonly getChangeRequestWatchFingerprint?: ( |
| 467 | input: ProviderRepositoryRef & { readonly number: number }, |
| 468 | ) => Effect.Effect<ProviderChangeRequestWatchFingerprint | null, PullRequestProviderError>; |
| 469 | |
| 470 | /** |
| 471 | * Emits whenever the host says the change request may have changed, and once on connecting. |
| 472 | * Ends where the host or account offers no such feed; readers then rely on polling alone. |
| 473 | */ |
| 474 | readonly changeRequestEvents?: ( |
| 475 | input: ProviderRepositoryRef & { readonly number: number }, |
| 476 | ) => Stream.Stream<void>; |
| 477 | |
| 478 | readonly getChangeRequestStack?: ( |
| 479 | input: ProviderRepositoryRef & { readonly includeDetails?: boolean; readonly number: number }, |
| 480 | ) => Effect.Effect<ProviderChangeRequestStack | null, PullRequestProviderError>; |
| 481 | |
| 482 | readonly getChangeRequestActivity: ( |
| 483 | input: ProviderRepositoryRef & { readonly number: number }, |
| 484 | ) => Effect.Effect<ProviderChangeRequestActivity, PullRequestProviderError>; |
| 485 | |
| 486 | readonly getReviewThreadComments?: ( |
| 487 | input: ProviderRepositoryRef & { |
| 488 | readonly number: number; |
| 489 | readonly threadId: string; |
| 490 | readonly cursor: string; |
| 491 | }, |
| 492 | ) => Effect.Effect<PullRequestThreadCommentsResult, PullRequestProviderError>; |
| 493 | |
| 494 | /** Read fresh before writes; client permissions may be stale or bypassed. */ |
| 495 | readonly getViewerPermissions: ( |
| 496 | input: ProviderRepositoryRef & { |
| 497 | readonly number: number; |
| 498 | readonly includeUpdateBranch?: boolean; |
| 499 | }, |
| 500 | ) => Effect.Effect<PullRequestViewerPermissions, PullRequestProviderError>; |
| 501 | |
| 502 | readonly getDiff: ( |
| 503 | input: ProviderRepositoryRef & { |
| 504 | readonly number: number; |
| 505 | readonly cursor?: string | undefined; |
| 506 | readonly commit?: string | undefined; |
| 507 | readonly path?: string | undefined; |
| 508 | }, |
| 509 | ) => Effect.Effect<ProviderDiffSlice, PullRequestProviderError>; |
| 510 | |
| 511 | /** Exact changed path pairs, including renames, without fetching patch contents. */ |
| 512 | readonly getDiffFilePaths?: ( |
| 513 | input: ProviderRepositoryRef & { |
| 514 | readonly number: number; |
| 515 | readonly cursor?: string | undefined; |
| 516 | readonly commit?: string | undefined; |
| 517 | }, |
| 518 | ) => Effect.Effect<ProviderDiffFilePaths, PullRequestProviderError>; |
| 519 | |
| 520 | readonly getDiffFileContents?: ( |
| 521 | input: ProviderRepositoryRef & { |
| 522 | readonly number: number; |
| 523 | readonly commit?: string | undefined; |
| 524 | readonly changeType: "change" | "rename-pure" | "rename-changed" | "new" | "deleted"; |
| 525 | readonly oldPath: string; |
| 526 | readonly newPath: string; |
| 527 | }, |
| 528 | ) => Effect.Effect<ProviderDiffFileContents, PullRequestProviderError>; |
| 529 | |
| 530 | readonly getFilesViewed?: ( |
| 531 | input: ProviderRepositoryRef & { readonly number: number }, |
| 532 | ) => Effect.Effect<ProviderFilesViewed, PullRequestProviderError>; |
| 533 | |
| 534 | /** Line counts for every changed file. Optional: a host without one shows no breakdown. */ |
| 535 | readonly getFileStats?: ( |
| 536 | input: ProviderRepositoryRef & { readonly number: number }, |
| 537 | ) => Effect.Effect<ProviderFileStats, PullRequestProviderError>; |
| 538 | |
| 539 | /** |
| 540 | * A host with no bulk form is still owed one round trip for the batch rather than one per |
| 541 | * file, since the point of gathering presses is that the host is asked once. |
| 542 | */ |
| 543 | readonly setFilesViewed?: ( |
| 544 | input: ProviderRepositoryRef & { |
| 545 | readonly number: number; |
| 546 | readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>; |
| 547 | }, |
| 548 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 549 | |
| 550 | /** Required for `environment` viewed marks to invalidate them after changes. */ |
| 551 | readonly getFileRevisions?: ( |
| 552 | input: ProviderRepositoryRef & { |
| 553 | readonly number: number; |
| 554 | readonly paths: ReadonlyArray<string>; |
| 555 | }, |
| 556 | ) => Effect.Effect<ProviderFileRevisions, PullRequestProviderError>; |
| 557 | |
| 558 | /** Returns the change request as the host's reply left it, or void when the reply lacks it. */ |
| 559 | readonly runAction: ( |
| 560 | input: ProviderRepositoryRef & { |
| 561 | readonly number: number; |
| 562 | readonly action: PullRequestAction; |
| 563 | readonly stackNumber?: number; |
| 564 | readonly expectedStackHeads?: ReadonlyArray<PullRequestStackHead>; |
| 565 | /** Hosts that can pin a merge to a head commit do; the caller has already checked it. */ |
| 566 | readonly expectedHeadSha?: string; |
| 567 | readonly removeAgentCreditsOnMerge?: boolean; |
| 568 | readonly mergeMethod?: PullRequestMergeMethod; |
| 569 | readonly updateMethod?: PullRequestUpdateMethod; |
| 570 | }, |
| 571 | ) => Effect.Effect<ProviderChangeRequestSummary | void, PullRequestProviderError>; |
| 572 | |
| 573 | /** Tails of the named checks' logs. A check the host holds no log for gets a `detail`. */ |
| 574 | readonly getCheckLogs?: ( |
| 575 | input: ProviderRepositoryRef & { |
| 576 | readonly checks: ReadonlyArray<ProviderCheckReference>; |
| 577 | readonly tailLines: number; |
| 578 | }, |
| 579 | ) => Effect.Effect<ReadonlyArray<ProviderCheckLog>, PullRequestProviderError>; |
| 580 | |
| 581 | /** Re-runs the named checks' jobs. A check the host cannot re-run gets a `detail`. */ |
| 582 | readonly rerunChecks?: ( |
| 583 | input: ProviderRepositoryRef & { readonly checks: ReadonlyArray<ProviderCheckReference> }, |
| 584 | ) => Effect.Effect<ReadonlyArray<ProviderCheckRerun>, PullRequestProviderError>; |
| 585 | |
| 586 | /** Requires edit capability and at least one field. */ |
| 587 | readonly updateChangeRequest?: ( |
| 588 | input: ProviderRepositoryRef & { |
| 589 | readonly maintainerCanModify?: boolean | undefined; |
| 590 | readonly number: number; |
| 591 | readonly title?: string | undefined; |
| 592 | readonly body?: string | undefined; |
| 593 | }, |
| 594 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 595 | |
| 596 | readonly comment: ( |
| 597 | input: ProviderRepositoryRef & { readonly number: number; readonly body: string }, |
| 598 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 599 | |
| 600 | readonly updateComment?: ( |
| 601 | input: ProviderRepositoryRef & { |
| 602 | readonly number: number; |
| 603 | readonly commentId: string; |
| 604 | readonly kind: "issue-comment" | "review-comment"; |
| 605 | readonly body: string; |
| 606 | }, |
| 607 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 608 | |
| 609 | readonly submitReview: ( |
| 610 | input: ProviderRepositoryRef & { |
| 611 | readonly number: number; |
| 612 | readonly verdict: PullRequestReviewVerdict; |
| 613 | readonly body: string; |
| 614 | readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>; |
| 615 | }, |
| 616 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 617 | |
| 618 | /** Exclude the author using host-specific account identities. */ |
| 619 | readonly listReviewerCandidates: ( |
| 620 | input: ProviderRepositoryRef & { |
| 621 | readonly number: number; |
| 622 | /** Asks the host to search past its first page of candidates. */ |
| 623 | readonly query?: string | undefined; |
| 624 | }, |
| 625 | ) => Effect.Effect<PullRequestReviewerCandidateList, PullRequestProviderError>; |
| 626 | |
| 627 | readonly setReviewerRequest: ( |
| 628 | input: ProviderRepositoryRef & { |
| 629 | readonly number: number; |
| 630 | readonly reviewers: ReadonlyArray<{ |
| 631 | readonly id: string; |
| 632 | readonly kind: PullRequestReviewerKind; |
| 633 | }>; |
| 634 | readonly requested: boolean; |
| 635 | }, |
| 636 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 637 | |
| 638 | readonly listLabelCandidates?: ( |
| 639 | input: ProviderRepositoryRef & { readonly number: number }, |
| 640 | ) => Effect.Effect<PullRequestLabelCandidateList, PullRequestProviderError>; |
| 641 | |
| 642 | /** |
| 643 | * The labels a repository offers, for narrowing a listing by. `query` narrows by name as far as |
| 644 | * the host can; the caller still matches the answer against it. |
| 645 | */ |
| 646 | readonly listRepositoryLabels?: ( |
| 647 | input: ProviderRepositoryRef & { readonly query?: string | undefined }, |
| 648 | ) => Effect.Effect<ProviderFilterOptionPage<PullRequestLabel>, PullRequestProviderError>; |
| 649 | |
| 650 | /** |
| 651 | * People who could have opened a change request in the repository, for narrowing a listing by |
| 652 | * author. A host that can only search its whole user base answers from that. |
| 653 | */ |
| 654 | readonly searchRepositoryAuthors?: ( |
| 655 | input: ProviderRepositoryRef & { readonly query?: string | undefined }, |
| 656 | ) => Effect.Effect<ProviderFilterOptionPage<PullRequestActor>, PullRequestProviderError>; |
| 657 | |
| 658 | /** |
| 659 | * Issues and change requests a composer can reference, recently updated first. A numeric |
| 660 | * `query` also finds that number exactly; other text matches titles as far as the host can. |
| 661 | */ |
| 662 | readonly searchRepositoryReferences?: ( |
| 663 | input: ProviderRepositoryRef & { |
| 664 | readonly query?: string | undefined; |
| 665 | readonly sigil?: PullRequestReferenceSigil | undefined; |
| 666 | }, |
| 667 | ) => Effect.Effect< |
| 668 | ProviderFilterOptionPage<PullRequestReferenceCandidate>, |
| 669 | PullRequestProviderError |
| 670 | >; |
| 671 | |
| 672 | readonly setLabels?: ( |
| 673 | input: ProviderRepositoryRef & { |
| 674 | readonly number: number; |
| 675 | readonly labels: ReadonlyArray<string>; |
| 676 | readonly applied: boolean; |
| 677 | }, |
| 678 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 679 | |
| 680 | readonly replyToThread: ( |
| 681 | input: ProviderRepositoryRef & { |
| 682 | readonly number: number; |
| 683 | readonly threadId: string; |
| 684 | readonly body: string; |
| 685 | }, |
| 686 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 687 | |
| 688 | /** `subjectId` is the conversation's remark ID; absent targets the change request description. */ |
| 689 | readonly setReaction: ( |
| 690 | input: ProviderRepositoryRef & { |
| 691 | readonly number: number; |
| 692 | readonly subjectId?: string | undefined; |
| 693 | readonly content: PullRequestReactionContent; |
| 694 | readonly reacted: boolean; |
| 695 | }, |
| 696 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 697 | |
| 698 | readonly setThreadResolution: ( |
| 699 | input: ProviderRepositoryRef & { |
| 700 | readonly number: number; |
| 701 | readonly threadId: string; |
| 702 | readonly resolved: boolean; |
| 703 | }, |
| 704 | ) => Effect.Effect<void, PullRequestProviderError>; |
| 705 | } |