@leitwerk-dev/github 0.2.0 → 0.3.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.
Files changed (47) hide show
  1. package/README.md +40 -0
  2. package/dist/authorization.d.ts +4 -0
  3. package/dist/authorization.d.ts.map +1 -1
  4. package/dist/binding.d.ts +1 -0
  5. package/dist/binding.d.ts.map +1 -1
  6. package/dist/capability.d.ts +6 -1
  7. package/dist/capability.d.ts.map +1 -1
  8. package/dist/{chunk-PVE52UFH.js → chunk-OAOKE6LC.js} +162 -20
  9. package/dist/chunk-OAOKE6LC.js.map +1 -0
  10. package/dist/client.d.ts +143 -8
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/external.d.ts +66 -0
  13. package/dist/external.d.ts.map +1 -1
  14. package/dist/index.d.ts +13 -11
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +160 -168
  17. package/dist/index.js.map +1 -1
  18. package/dist/issue-provider.d.ts.map +1 -1
  19. package/dist/issue-watcher.d.ts +12 -0
  20. package/dist/issue-watcher.d.ts.map +1 -1
  21. package/dist/poll-report.d.ts +2 -18
  22. package/dist/poll-report.d.ts.map +1 -1
  23. package/dist/provider.d.ts +3 -1
  24. package/dist/provider.d.ts.map +1 -1
  25. package/dist/testing/tool-fixture.d.ts +192 -0
  26. package/dist/testing/tool-fixture.d.ts.map +1 -0
  27. package/dist/testing.d.ts +67 -3
  28. package/dist/testing.d.ts.map +1 -1
  29. package/dist/testing.js +46 -4
  30. package/dist/testing.js.map +1 -1
  31. package/dist/tools.d.ts +1 -2
  32. package/dist/tools.d.ts.map +1 -1
  33. package/package.json +6 -7
  34. package/src/authorization.ts +9 -1
  35. package/src/binding.ts +1 -0
  36. package/src/capability.ts +6 -1
  37. package/src/client.ts +315 -28
  38. package/src/external.ts +54 -0
  39. package/src/index.ts +33 -11
  40. package/src/issue-provider.ts +4 -12
  41. package/src/issue-watcher.ts +16 -1
  42. package/src/poll-report.ts +5 -23
  43. package/src/provider.ts +1 -1
  44. package/src/testing/tool-fixture.ts +137 -0
  45. package/src/testing.ts +108 -9
  46. package/src/tools.ts +183 -175
  47. package/dist/chunk-PVE52UFH.js.map +0 -1
package/README.md CHANGED
@@ -111,3 +111,43 @@ retrying it. Release-lock selection stays outside this integration.
111
111
  The local adapter supports `createIssue`, `setIssueLabel`, `setMembership`,
112
112
  `editFeedback` and `failNextResponse`. Membership, label events, feedback edits,
113
113
  write outcomes and Git history survive restart.
114
+
115
+ ## Repository change process
116
+
117
+ Load [github-repo-change](../github-repo-change/README.md) to create changes from the
118
+ UI or labeled issues. Server-created integrations enumerate available profiles;
119
+ custom integrations may implement `profiles()` for launcher discovery.
120
+ `github_get_ci_diagnostics` verifies the selected process branches and current PR
121
+ head, then reads failed check annotations and Actions jobs. It returns at most ten
122
+ failed check details and ten failed job logs, with 64 KiB per log and explicit
123
+ truncation. Signed log downloads do not receive the API token. Actions read access
124
+ is required. Existing check-source callers remain compatible; the optional
125
+ `afterKey` suppresses a failure already consumed by a process.
126
+
127
+ Tool authorization and retry edge cases use an in-memory provider boundary.
128
+ The recovery integration exercises real Git and reopens both provider storage and
129
+ SQLite receipts: a lost create response and subsequent restart must retain one PR
130
+ and the same receipt. This verifies local persistence and tool wiring, not live
131
+ GitHub API compatibility.
132
+
133
+ ## API support
134
+
135
+ The following exported declarations are `@public`:
136
+
137
+ - `@leitwerk-dev/github`: `GITHUB_CHECKS_KIND`, `GITHUB_ISSUE_CANCELLED_KIND`, `GITHUB_PR_FEEDBACK_KIND`, `GITHUB_PR_STATE_KIND`, `GITHUB_PR_TERMINAL_KIND`, `GitHubCheckSummary`, `GitHubGitIdentity`, `GitHubIntegration`, `GitHubIssue`, `GitHubPullRequest`, `GitHubRepository`, `default`, `githubExternal`, `githubIntegration`, `githubIssueWatcherSource`, `resolveGitHubProjectBinding`, `setupGitHubIntegration`.
138
+ - `@leitwerk-dev/github/testing`: `LocalGitHubAdapter`, `LocalGitHubOptions`, `LocalGitHubRepository`, `LocalGitHubState`.
139
+
140
+ Members have individual classifications; these exports do not make every member
141
+ public. Both `@public` and `@internal` APIs remain usable and fully typed. Source
142
+ annotations are authoritative; see the [SDK compatibility
143
+ policy](../../docs/process-sdk.md#api-compatibility).
144
+
145
+ ### External-write replay
146
+
147
+ Writes follow the [shared reconciliation contract](../../docs/process-sdk.md#typed-external-writes).
148
+ Pull requests are matched by branch pair; comments and replies use hidden markers
149
+ within their repository and thread. Reaction recovery matches the bot's identity.
150
+ Update recovery compares requested fields, including normalized labels. Logged
151
+ replays return the current object without reapplying the patch.
152
+
153
+ GitHub polling uses the SDK reporter with live GitHub source kinds and generation forwarding. Conflict reporting uses `createConflictReporter(kind)` without creating another remote object.
@@ -1,10 +1,14 @@
1
1
  import type { GitHubClient, GitHubFeedbackItem, GitHubIssue } from "./client.js";
2
2
  type MembershipClient = Pick<GitHubClient, "profile" | "isOrganizationMember">;
3
3
  export declare function authorizedTrigger(client: MembershipClient & Pick<GitHubClient, "getIssue" | "listIssueEvents">, owner: string, repo: string, number: number, trigger: string, done: string): Promise<{
4
+ /** @internal */
4
5
  issue: GitHubIssue & {
6
+ /** @internal */
5
7
  pull_request?: unknown;
6
8
  };
9
+ /** @internal */
7
10
  actor: string;
11
+ /** @internal */
8
12
  eventId: number;
9
13
  } | null>;
10
14
  export declare function actionableFeedback(client: MembershipClient, feedback: GitHubFeedbackItem[]): Promise<GitHubFeedbackItem[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,sBAAsB,CAAC,CAAC;AAE/E,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC7E,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;;uBAQI,OAAO;;;;UAsBvB;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iCAWhG"}
1
+ {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEjF,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,sBAAsB,CAAC,CAAC;AAE/E,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,iBAAiB,CAAC,EAC7E,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM;IA+BX,gBAAgB;;QAvBhB,gBAAgB;uBACD,OAAO;;IAwBtB,gBAAgB;;IAEhB,gBAAgB;;UAGjB;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,iCAWhG"}
package/dist/binding.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
2
2
  export type { RepositoryProjectBinding as GitHubProjectBinding } from "@leitwerk-dev/process-sdk";
3
+ /** @public */
3
4
  export declare const resolveGitHubProjectBinding: (ctx: Parameters<typeof resolveRepositoryProjectBinding>[0]) => import("@leitwerk-dev/process-sdk").RepositoryProjectBinding;
4
5
  //# sourceMappingURL=binding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,YAAY,EAAE,wBAAwB,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAClG,eAAO,MAAM,2BAA2B,GACvC,KAAK,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,iEACR,CAAC"}
1
+ {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,YAAY,EAAE,wBAAwB,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAClG,cAAc;AACd,eAAO,MAAM,2BAA2B,GACvC,KAAK,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,iEACR,CAAC"}
@@ -1,8 +1,13 @@
1
1
  import type { GitHubClient } from "./client.js";
2
- /** Public contract shared by HTTP and local adapters. */
2
+ /** Public contract shared by HTTP and local adapters. @public */
3
3
  export type GitHubClientLike = Pick<GitHubClient, keyof GitHubClient>;
4
+ /** @public */
4
5
  export interface GitHubIntegration {
6
+ /** @public */
7
+ profiles?(): readonly string[];
8
+ /** @public */
5
9
  client(profile: string): GitHubClientLike;
6
10
  }
11
+ /** @public */
7
12
  export declare const githubIntegration: import("@leitwerk-dev/process-sdk").CapabilityToken<GitHubIntegration>;
8
13
  //# sourceMappingURL=capability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,YAAY,CAAC,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AAED,eAAO,MAAM,iBAAiB,wEAE7B,CAAC"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,iEAAiE;AACjE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,YAAY,CAAC,CAAC;AAEtE,cAAc;AACd,MAAM,WAAW,iBAAiB;IACjC,cAAc;IACd,QAAQ,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC;IAC/B,cAAc;IACd,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AAED,cAAc;AACd,eAAO,MAAM,iBAAiB,wEAE7B,CAAC"}
@@ -10,7 +10,14 @@ async function authorizedTrigger(client, owner, repo, number, trigger, done) {
10
10
  ).sort((a, b) => b.id - a.id)[0];
11
11
  if (last?.event !== "labeled" || !last.actor?.login || !await client.isOrganizationMember(last.actor.login))
12
12
  return null;
13
- return { issue, actor: last.actor.login, eventId: last.id };
13
+ return {
14
+ /** @internal */
15
+ issue,
16
+ /** @internal */
17
+ actor: last.actor.login,
18
+ /** @internal */
19
+ eventId: last.id
20
+ };
14
21
  }
15
22
  async function actionableFeedback(client, feedback) {
16
23
  const authorized = [];
@@ -64,6 +71,7 @@ function assertGitHubRepository(profile, owner, repo) {
64
71
  }
65
72
  }
66
73
  var GitHubClient = class extends RepositoryHttpClient {
74
+ /** @internal */
67
75
  constructor(profile) {
68
76
  super("GitHub", profile.apiBaseUrl, {
69
77
  Accept: "application/vnd.github+json",
@@ -73,6 +81,7 @@ var GitHubClient = class extends RepositoryHttpClient {
73
81
  this.profile = profile;
74
82
  }
75
83
  profile;
84
+ /** @internal */
76
85
  response(path, init = {}) {
77
86
  return super.response(path, {
78
87
  ...init,
@@ -80,10 +89,12 @@ var GitHubClient = class extends RepositoryHttpClient {
80
89
  signal: init.signal ?? AbortSignal.timeout(3e4)
81
90
  });
82
91
  }
92
+ /** @internal */
83
93
  repositoryPath(owner, repo) {
84
94
  assertGitHubRepository(this.profile, owner, repo);
85
95
  return super.repositoryPath(owner, repo);
86
96
  }
97
+ /** @internal */
87
98
  async listRepositories() {
88
99
  return (await this.pages(
89
100
  this.profile.allowedOrganization ? `/orgs/${this.profile.allowedOrganization}/repos?type=all` : "/user/repos?affiliation=owner,collaborator,organization_member"
@@ -91,16 +102,17 @@ var GitHubClient = class extends RepositoryHttpClient {
91
102
  (repo) => (!this.profile.allowedOrganization || repo.owner.login.toLowerCase() === this.profile.allowedOrganization.toLowerCase()) && !repo.archived && repo.has_issues
92
103
  );
93
104
  }
105
+ /** @internal */
94
106
  async listOpenIssues(owner, repo) {
95
- return (await this.pages(
96
- `${this.repositoryPath(owner, repo)}/issues?state=open`
97
- )).filter((issue) => !issue.pull_request);
107
+ return (await this.pages(`${this.repositoryPath(owner, repo)}/issues?state=open`)).filter((issue) => !issue.pull_request);
98
108
  }
109
+ /** @internal */
99
110
  listIssueEvents(owner, repo, number) {
100
111
  return this.pages(
101
112
  `${this.repositoryPath(owner, repo)}/issues/${number}/events`
102
113
  );
103
114
  }
115
+ /** @internal */
104
116
  async isOrganizationMember(login) {
105
117
  if (!this.profile.allowedOrganization) return true;
106
118
  if (!/^[a-z0-9-]+$/i.test(login)) return false;
@@ -117,9 +129,11 @@ var GitHubClient = class extends RepositoryHttpClient {
117
129
  throw error;
118
130
  }
119
131
  }
132
+ /** @internal */
120
133
  async authorizedTrigger(owner, repo, number, trigger, done) {
121
134
  return authorizedTrigger(this, owner, repo, number, trigger, done);
122
135
  }
136
+ /** @public */
123
137
  async resolveGitIdentity(profile) {
124
138
  const user = await this.request("/user");
125
139
  if (user.login !== this.profile.botLogin)
@@ -132,21 +146,30 @@ var GitHubClient = class extends RepositoryHttpClient {
132
146
  email: `${user.id}+${user.login}@users.noreply.github.com`
133
147
  };
134
148
  }
149
+ /** @public */
135
150
  updateIssue(owner, repo, number, patch) {
136
151
  return this.request(`${this.repositoryPath(owner, repo)}/issues/${number}`, {
137
152
  method: "PATCH",
138
153
  body: JSON.stringify(patch)
139
154
  });
140
155
  }
141
- async ensureLabel(owner, repo, name) {
142
- const labels = await this.pages(
143
- `${this.repositoryPath(owner, repo)}/labels`
144
- );
145
- return labels.find((label) => label.name === name) ?? this.request(`${this.repositoryPath(owner, repo)}/labels`, {
156
+ /** @internal */
157
+ listLabels(owner, repo) {
158
+ return this.pages(`${this.repositoryPath(owner, repo)}/labels`);
159
+ }
160
+ /** @internal */
161
+ createLabel(owner, repo, name) {
162
+ return this.request(`${this.repositoryPath(owner, repo)}/labels`, {
146
163
  method: "POST",
147
164
  body: JSON.stringify({ name, color: "238636" })
148
165
  });
149
166
  }
167
+ /** @internal */
168
+ async ensureLabel(owner, repo, name) {
169
+ const labels = await this.listLabels(owner, repo);
170
+ return labels.find((label) => label.name === name) ?? this.createLabel(owner, repo, name);
171
+ }
172
+ /** @internal */
150
173
  addFeedbackReaction(owner, repo, kind, id) {
151
174
  const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
152
175
  return this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {
@@ -154,28 +177,28 @@ var GitHubClient = class extends RepositoryHttpClient {
154
177
  body: JSON.stringify({ content: "eyes" })
155
178
  });
156
179
  }
180
+ /** @internal */
157
181
  async replyFeedback(owner, repo, pr, kind, id, body) {
158
182
  if (kind === "inline")
159
- return this.request(
183
+ return this.writeJson(
160
184
  `${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,
161
- {
162
- method: "POST",
163
- body: JSON.stringify({ body })
164
- }
185
+ "POST",
186
+ { body }
165
187
  );
166
188
  return this.addIssueComment(owner, repo, pr, body);
167
189
  }
190
+ /** @internal */
168
191
  getCommit(owner, repo, ref) {
169
- return this.request(
170
- `${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`
171
- );
192
+ return this.request(`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`);
172
193
  }
194
+ /** @public */
173
195
  async isAncestor(owner, repo, ancestor, descendant) {
174
196
  const comparison = await this.request(
175
197
  `${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`
176
198
  );
177
199
  return comparison.status === "identical" || comparison.status === "ahead";
178
200
  }
201
+ /** @public */
179
202
  async listPullRequestFeedback(owner, repo, number, signal) {
180
203
  const prefix = `${this.repositoryPath(owner, repo)}`;
181
204
  const [conversation, reviews, inline] = await Promise.all([
@@ -252,6 +275,7 @@ var GitHubClient = class extends RepositoryHttpClient {
252
275
  }
253
276
  return feedback;
254
277
  }
278
+ /** @public */
255
279
  async getCheckSummary(owner, repo, headSha) {
256
280
  const runs = [];
257
281
  for (let page = 1; ; page++) {
@@ -276,28 +300,146 @@ var GitHubClient = class extends RepositoryHttpClient {
276
300
  };
277
301
  }
278
302
  /** Human feedback checked against current membership; delivery receipts use raw reads. */
303
+ /** @internal */
279
304
  async listActionablePullRequestFeedback(owner, repo, number, signal) {
280
305
  return actionableFeedback(
281
306
  this,
282
307
  await this.listPullRequestFeedback(owner, repo, number, signal)
283
308
  );
284
309
  }
310
+ /** @internal */
285
311
  listFeedbackReplies(owner, repo, pr, kind) {
286
312
  return kind === "inline" ? this.pages(
287
313
  `${this.repositoryPath(owner, repo)}/pulls/${pr}/comments`
288
314
  ) : this.listIssueComments(owner, repo, pr);
289
315
  }
316
+ /** @internal */
290
317
  listFeedbackReactions(owner, repo, kind, id) {
291
318
  if (kind !== "inline" && kind !== "conversation")
292
319
  throw new Error("Reviews do not support reactions");
293
320
  const segment = kind === "inline" ? "pulls/comments" : "issues/comments";
294
- return this.pages(
295
- `${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`
321
+ return this.pages(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`);
322
+ }
323
+ /** @public */
324
+ async getCiDiagnostics(owner, repo, pullRequestNumber, headSha, signal) {
325
+ const pr = await this.getPullRequest(owner, repo, pullRequestNumber, signal);
326
+ if (pr.state !== "open" || pr.merged || pr.head.sha !== headSha)
327
+ throw new Error("CI diagnostics target a stale pull request revision");
328
+ const prefix = this.repositoryPath(owner, repo);
329
+ const checks = [];
330
+ for (let page = 1; ; page++) {
331
+ const batch = await this.request(
332
+ `${prefix}/commits/${encodeURIComponent(headSha)}/check-runs?filter=latest&per_page=100&page=${page}`,
333
+ { signal }
334
+ );
335
+ checks.push(...batch.check_runs);
336
+ if (batch.check_runs.length < 100) break;
337
+ }
338
+ const failed = checks.filter(
339
+ (c) => c.conclusion && !["success", "neutral", "skipped"].includes(c.conclusion)
340
+ );
341
+ const annotations = await Promise.all(
342
+ failed.slice(0, 10).map(async (check) => ({
343
+ /** @public */
344
+ id: check.id,
345
+ /** @public */
346
+ name: check.name,
347
+ /** @public */
348
+ output: check.output,
349
+ /** @public */
350
+ annotations: (await this.pages(`${prefix}/check-runs/${check.id}/annotations`, signal)).slice(0, 100)
351
+ }))
296
352
  );
353
+ const jobs = [];
354
+ for (let page = 1; jobs.length < 10; page++) {
355
+ const runs = await this.request(
356
+ `${prefix}/actions/runs?head_sha=${encodeURIComponent(headSha)}&per_page=100&page=${page}`,
357
+ { signal }
358
+ );
359
+ for (const run of runs.workflow_runs) {
360
+ if (run.head_sha !== headSha || run.head_branch !== pr.head.ref || !run.conclusion || ["success", "neutral", "skipped"].includes(run.conclusion))
361
+ continue;
362
+ for (let jobPage = 1; jobs.length < 10; jobPage++) {
363
+ const batch = await this.request(`${prefix}/actions/runs/${run.id}/jobs?filter=latest&per_page=100&page=${jobPage}`, {
364
+ signal
365
+ });
366
+ for (const job of batch.jobs) {
367
+ if (!job.conclusion || ["success", "neutral", "skipped"].includes(job.conclusion) || jobs.length >= 10)
368
+ continue;
369
+ jobs.push({
370
+ id: job.id,
371
+ name: job.name,
372
+ html_url: job.html_url,
373
+ log: await this.readJobLog(owner, repo, job.id, signal)
374
+ });
375
+ }
376
+ if (batch.jobs.length < 100) break;
377
+ }
378
+ }
379
+ if (runs.workflow_runs.length < 100) break;
380
+ }
381
+ const refreshed = await this.getPullRequest(owner, repo, pullRequestNumber, signal);
382
+ if (refreshed.head.sha !== headSha || refreshed.state !== "open" || refreshed.merged)
383
+ throw new Error("CI diagnostics were superseded");
384
+ return {
385
+ /** @public */
386
+ headSha,
387
+ /** @public */
388
+ checks: annotations,
389
+ /** @public */
390
+ jobs,
391
+ /** @public */
392
+ truncated: failed.length > 10 || jobs.length >= 10
393
+ };
394
+ }
395
+ async readJobLog(owner, repo, job, signal) {
396
+ const timeout = signal ? AbortSignal.any([signal, AbortSignal.timeout(3e4)]) : AbortSignal.timeout(3e4);
397
+ let response = await fetch(
398
+ `${this.profile.apiBaseUrl}${this.repositoryPath(owner, repo)}/actions/jobs/${job}/logs`,
399
+ {
400
+ headers: {
401
+ Authorization: `Bearer ${this.profile.token}`,
402
+ Accept: "application/vnd.github+json"
403
+ },
404
+ redirect: "manual",
405
+ signal: timeout
406
+ }
407
+ );
408
+ if (response.status === 302) {
409
+ const location = new URL(response.headers.get("location") ?? "");
410
+ if (location.protocol !== "https:" || location.username || location.password)
411
+ throw new Error("Invalid GitHub log download URL");
412
+ await response.body?.cancel();
413
+ response = await fetch(location, { redirect: "error", signal: timeout });
414
+ }
415
+ if (!response.ok) throw new IntegrationHttpError(response.status, "GitHub job log unavailable");
416
+ const reader = response.body?.getReader();
417
+ if (!reader) return { text: "", truncated: false };
418
+ const chunks = [];
419
+ let bytes = 0;
420
+ let truncated = false;
421
+ try {
422
+ for (; ; ) {
423
+ const next = await reader.read();
424
+ if (next.done) break;
425
+ const part = next.value.slice(0, 65536 - bytes);
426
+ chunks.push(part);
427
+ bytes += part.length;
428
+ if (bytes === 65536) {
429
+ truncated = true;
430
+ break;
431
+ }
432
+ }
433
+ } finally {
434
+ await reader.cancel();
435
+ }
436
+ return { text: Buffer.concat(chunks).toString("utf8"), truncated };
297
437
  }
438
+ /** @internal */
298
439
  listReleases(owner, repo) {
299
440
  return this.pages(`${this.repositoryPath(owner, repo)}/releases`);
300
441
  }
442
+ /** @public */
301
443
  downloadReleaseAsset(asset) {
302
444
  const url = new URL(asset.url);
303
445
  if (`${url.protocol}//${url.host}` !== this.profile.apiBaseUrl)
@@ -315,4 +457,4 @@ export {
315
457
  assertGitHubRepository,
316
458
  GitHubClient
317
459
  };
318
- //# sourceMappingURL=chunk-PVE52UFH.js.map
460
+ //# sourceMappingURL=chunk-OAOKE6LC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/authorization.ts","../src/client.ts"],"sourcesContent":["import type { GitHubClient, GitHubFeedbackItem, GitHubIssue } from \"./client.js\";\n\ntype MembershipClient = Pick<GitHubClient, \"profile\" | \"isOrganizationMember\">;\n\nexport async function authorizedTrigger(\n\tclient: MembershipClient & Pick<GitHubClient, \"getIssue\" | \"listIssueEvents\">,\n\towner: string,\n\trepo: string,\n\tnumber: number,\n\ttrigger: string,\n\tdone: string,\n) {\n\tif (\n\t\tclient.profile.allowedOrganization &&\n\t\towner.toLowerCase() !== client.profile.allowedOrganization.toLowerCase()\n\t)\n\t\treturn null;\n\tconst issue = (await client.getIssue(owner, repo, number)) as GitHubIssue & {\n\t\t/** @internal */\n\t\tpull_request?: unknown;\n\t};\n\tif (\n\t\tissue.pull_request ||\n\t\tissue.state !== \"open\" ||\n\t\t!issue.labels.some((label) => label.name === trigger) ||\n\t\tissue.labels.some((label) => label.name === done)\n\t)\n\t\treturn null;\n\tconst last = (await client.listIssueEvents(owner, repo, number))\n\t\t.filter(\n\t\t\t(event) =>\n\t\t\t\t(event.event === \"labeled\" || event.event === \"unlabeled\") && event.label?.name === trigger,\n\t\t)\n\t\t.sort((a, b) => b.id - a.id)[0];\n\tif (\n\t\tlast?.event !== \"labeled\" ||\n\t\t!last.actor?.login ||\n\t\t!(await client.isOrganizationMember(last.actor.login))\n\t)\n\t\treturn null;\n\treturn {\n\t\t/** @internal */\n\t\tissue,\n\t\t/** @internal */\n\t\tactor: last.actor.login,\n\t\t/** @internal */\n\t\teventId: last.id,\n\t};\n}\n\nexport async function actionableFeedback(client: MembershipClient, feedback: GitHubFeedbackItem[]) {\n\tconst authorized: GitHubFeedbackItem[] = [];\n\tfor (const item of feedback) {\n\t\tif (\n\t\t\titem.author.toLowerCase() === client.profile.botLogin.toLowerCase() ||\n\t\t\titem.body.includes(\"<!-- leitwerk-write:\")\n\t\t)\n\t\t\tcontinue;\n\t\tif (await client.isOrganizationMember(item.author)) authorized.push(item);\n\t}\n\treturn authorized;\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype RepositoryFeedbackItem as GitHubFeedbackItem,\n\ttype RepositoryIssue as GitHubIssue,\n\ttype RepositoryPullRequest as GitHubPullRequest,\n\tIntegrationHttpError,\n\tnormalizeRepositoryFeedback as normalize,\n\tRepositoryHttpClient,\n} from \"@leitwerk-dev/process-sdk\";\n\nimport { actionableFeedback, authorizedTrigger } from \"./authorization.js\";\n\nexport type { GitHubFeedbackItem, GitHubIssue, GitHubPullRequest };\n\n/** @internal */\ninterface GitHubLabel {\n\t/** @internal */\n\tid: number;\n\t/** @internal */\n\tname: string;\n}\n\n/** @public */\nexport interface GitHubRepository {\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tfull_name: string;\n\t/** @public */\n\t/** @public */\n\towner: {\n\t\t/** @public */\n\t\tlogin: string;\n\t};\n\t/** @public */\n\tssh_url: string;\n\t/** @public */\n\tdefault_branch: string;\n\t/** @internal */\n\thtml_url: string;\n\t/** @internal */\n\tarchived: boolean;\n\t/** @internal */\n\thas_issues: boolean;\n}\n/** @public */\nexport interface GitHubGitIdentity {\n\t/** @internal */\n\tprovider: \"github\";\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\tlogin: string;\n\t/** @public */\n\tname: string;\n\t/** @public */\n\temail: string;\n}\n/** @public */\nexport interface GitHubLabelEvent {\n\t/** @internal */\n\tid: number;\n\t/** @internal */\n\tevent: string;\n\t/** @public */\n\t/** @public */\n\tlabel?: {\n\t\t/** @public */\n\t\tname: string;\n\t};\n\t/** @public */\n\t/** @public */\n\tactor: {\n\t\t/** @public */\n\t\tlogin: string;\n\t} | null;\n}\n\n/** @internal */\nexport interface GitHubProfile {\n\t/** @internal */\n\tapiBaseUrl: string;\n\t/** @internal */\n\ttoken: string;\n\t/** @internal */\n\tbotLogin: string;\n\t/** @internal */\n\tallowedOrganization?: string;\n}\n\n/** @public */\nexport interface GitHubCheckSummary {\n\t/** @public */\n\theadSha: string;\n\t/** @public */\n\tstatus: \"pending\" | \"success\" | \"failure\";\n\t/** @public */\n\ttotal: number;\n\t/** @public */\n\tfailed: Array<{\n\t\t/** @internal */\n\t\tname: string;\n\t\t/** @public */\n\t\tconclusion: string | null;\n\t\t/** @public */\n\t\turl: string | null;\n\t}>;\n}\n\n/** @public */\nexport interface GitHubRelease {\n\t/** @internal */\n\tid: number;\n\t/** @public */\n\ttag_name: string;\n\t/** @internal */\n\ttarget_commitish: string;\n\t/** @internal */\n\tdraft: boolean;\n\t/** @internal */\n\tprerelease: boolean;\n\t/** @internal */\n\thtml_url: string;\n\t/** @public */\n\t/** @public */\n\tassets: Array<{\n\t\t/** @public */\n\t\tname: string;\n\t\t/** @public */\n\t\turl: string;\n\t\t/** @public */\n\t\tbrowser_download_url: string;\n\t}>;\n}\n\n/** @internal */\nexport function parseGitHubProfiles(value: unknown): Map<string, GitHubProfile> {\n\tconst profiles = new Map<string, GitHubProfile>();\n\tfor (const [name, raw] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(value)?.profiles) ?? {},\n\t)) {\n\t\tconst config = asUnknownRecord(raw) ?? {};\n\t\tconst apiBaseUrl =\n\t\t\ttypeof config.api_base_url === \"string\"\n\t\t\t\t? config.api_base_url.replace(/\\/+$/, \"\")\n\t\t\t\t: \"https://api.github.com\";\n\t\tconst token = typeof config.token === \"string\" ? config.token.trim() : \"\";\n\t\tconst botLogin = typeof config.bot_login === \"string\" ? config.bot_login.trim() : \"leitwerk\";\n\t\tif (!/^https:\\/\\//.test(apiBaseUrl))\n\t\t\tthrow new Error(`GitHub profile '${name}' requires an HTTPS api_base_url`);\n\t\tif (!token) throw new Error(`GitHub profile '${name}' requires a token`);\n\t\tif (!botLogin) throw new Error(`GitHub profile '${name}' requires bot_login`);\n\t\tconst allowedOrganization = config.allowed_organization;\n\t\tif (\n\t\t\tallowedOrganization !== undefined &&\n\t\t\t(typeof allowedOrganization !== \"string\" || !/^[a-z0-9-]+$/i.test(allowedOrganization))\n\t\t) {\n\t\t\tthrow new Error(`GitHub profile '${name}' requires a valid allowed_organization`);\n\t\t}\n\t\tprofiles.set(name, {\n\t\t\tapiBaseUrl,\n\t\t\ttoken,\n\t\t\tbotLogin,\n\t\t\t...(typeof allowedOrganization === \"string\"\n\t\t\t\t? { allowedOrganization: allowedOrganization.toLowerCase() }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\treturn profiles;\n}\n\n/** @internal */\nexport function assertGitHubRepository(profile: GitHubProfile, owner: string, repo: string): void {\n\tif (\n\t\t!/^[a-z0-9-]+$/i.test(owner) ||\n\t\t!/^[a-z0-9_.-]+$/i.test(repo) ||\n\t\trepo === \".\" ||\n\t\trepo === \"..\"\n\t) {\n\t\tthrow new Error(\"Invalid GitHub repository\");\n\t}\n\tif (\n\t\tprofile.allowedOrganization &&\n\t\towner.toLowerCase() !== profile.allowedOrganization.toLowerCase()\n\t) {\n\t\tthrow new Error(`GitHub project must belong to ${profile.allowedOrganization}`);\n\t}\n}\n\n/** @public */\nexport class GitHubClient extends RepositoryHttpClient {\n\t/** @internal */\n\tconstructor(/** @internal */ readonly profile: GitHubProfile) {\n\t\tsuper(\"GitHub\", profile.apiBaseUrl, {\n\t\t\tAccept: \"application/vnd.github+json\",\n\t\t\tAuthorization: `Bearer ${profile.token}`,\n\t\t\t\"X-GitHub-Api-Version\": \"2022-11-28\",\n\t\t});\n\t}\n\n\t/** @internal */\n\tprotected override response(path: string, init: RequestInit = {}): Promise<Response> {\n\t\treturn super.response(path, {\n\t\t\t...init,\n\t\t\tredirect: \"error\",\n\t\t\tsignal: init.signal ?? AbortSignal.timeout(30_000),\n\t\t});\n\t}\n\n\t/** @internal */\n\tprotected override repositoryPath(owner: string, repo: string): string {\n\t\tassertGitHubRepository(this.profile, owner, repo);\n\t\treturn super.repositoryPath(owner, repo);\n\t}\n\n\t/** @internal */\n\tasync listRepositories() {\n\t\treturn (\n\t\t\tawait this.pages<GitHubRepository>(\n\t\t\t\tthis.profile.allowedOrganization\n\t\t\t\t\t? `/orgs/${this.profile.allowedOrganization}/repos?type=all`\n\t\t\t\t\t: \"/user/repos?affiliation=owner,collaborator,organization_member\",\n\t\t\t)\n\t\t).filter(\n\t\t\t(repo) =>\n\t\t\t\t(!this.profile.allowedOrganization ||\n\t\t\t\t\trepo.owner.login.toLowerCase() === this.profile.allowedOrganization.toLowerCase()) &&\n\t\t\t\t!repo.archived &&\n\t\t\t\trepo.has_issues,\n\t\t);\n\t}\n\t/** @internal */\n\tasync listOpenIssues(owner: string, repo: string) {\n\t\treturn (\n\t\t\tawait this.pages<\n\t\t\t\tGitHubIssue & {\n\t\t\t\t\t/** @internal */\n\t\t\t\t\tpull_request?: unknown;\n\t\t\t\t}\n\t\t\t>(`${this.repositoryPath(owner, repo)}/issues?state=open`)\n\t\t).filter((issue) => !issue.pull_request);\n\t}\n\t/** @internal */\n\tlistIssueEvents(owner: string, repo: string, number: number) {\n\t\treturn this.pages<GitHubLabelEvent>(\n\t\t\t`${this.repositoryPath(owner, repo)}/issues/${number}/events`,\n\t\t);\n\t}\n\t/** @internal */\n\tasync isOrganizationMember(login: string): Promise<boolean> {\n\t\tif (!this.profile.allowedOrganization) return true;\n\t\tif (!/^[a-z0-9-]+$/i.test(login)) return false;\n\t\ttry {\n\t\t\tconst response = await this.response(\n\t\t\t\t`/orgs/${this.profile.allowedOrganization}/members/${encodeURIComponent(login)}`,\n\t\t\t);\n\t\t\treturn response.status === 204;\n\t\t} catch (error) {\n\t\t\tif (error instanceof IntegrationHttpError) {\n\t\t\t\tif (error.status === 404) return false;\n\t\t\t\tthrow new Error(`GitHub membership check failed with ${error.status}`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\t/** @internal */\n\tasync authorizedTrigger(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\ttrigger: string,\n\t\tdone: string,\n\t) {\n\t\treturn authorizedTrigger(this, owner, repo, number, trigger, done);\n\t}\n\t/** @public */\n\tasync resolveGitIdentity(profile: string): Promise<GitHubGitIdentity> {\n\t\tconst user = await this.request<{ login: string; name: string | null; id: number }>(\"/user\");\n\t\tif (user.login !== this.profile.botLogin)\n\t\t\tthrow new Error(\"GitHub authenticated user does not match bot_login\");\n\t\treturn {\n\t\t\tprovider: \"github\",\n\t\t\tprofile,\n\t\t\tlogin: user.login,\n\t\t\tname: user.name || user.login,\n\t\t\temail: `${user.id}+${user.login}@users.noreply.github.com`,\n\t\t};\n\t}\n\t/** @public */\n\tupdateIssue(owner: string, repo: string, number: number, patch: Record<string, unknown>) {\n\t\treturn this.request<GitHubIssue>(`${this.repositoryPath(owner, repo)}/issues/${number}`, {\n\t\t\tmethod: \"PATCH\",\n\t\t\tbody: JSON.stringify(patch),\n\t\t});\n\t}\n\t/** @internal */\n\tlistLabels(owner: string, repo: string) {\n\t\treturn this.pages<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`);\n\t}\n\t/** @internal */\n\tcreateLabel(owner: string, repo: string, name: string) {\n\t\treturn this.request<GitHubLabel>(`${this.repositoryPath(owner, repo)}/labels`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ name, color: \"238636\" }),\n\t\t});\n\t}\n\t/** @internal */\n\tasync ensureLabel(owner: string, repo: string, name: string) {\n\t\tconst labels = await this.listLabels(owner, repo);\n\t\treturn labels.find((label) => label.name === name) ?? this.createLabel(owner, repo, name);\n\t}\n\t/** @internal */\n\taddFeedbackReaction(owner: string, repo: string, kind: string, id: number) {\n\t\tconst segment = kind === \"inline\" ? \"pulls/comments\" : \"issues/comments\";\n\t\treturn this.request(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ content: \"eyes\" }),\n\t\t});\n\t}\n\t/** @internal */\n\tasync replyFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tpr: number,\n\t\tkind: string,\n\t\tid: number,\n\t\tbody: string,\n\t) {\n\t\tif (kind === \"inline\")\n\t\t\treturn this.writeJson(\n\t\t\t\t`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments/${id}/replies`,\n\t\t\t\t\"POST\",\n\t\t\t\t{ body },\n\t\t\t);\n\t\treturn this.addIssueComment(owner, repo, pr, body);\n\t}\n\n\t/** @internal */\n\tgetCommit(owner: string, repo: string, ref: string) {\n\t\treturn this.request<{\n\t\t\t/** @internal */\n\t\t\tsha: string;\n\t\t}>(`${this.repositoryPath(owner, repo)}/commits/${encodeURIComponent(ref)}`);\n\t}\n\n\t/** @public */\n\tasync isAncestor(owner: string, repo: string, ancestor: string, descendant: string) {\n\t\tconst comparison = await this.request<{ status: string }>(\n\t\t\t`${this.repositoryPath(owner, repo)}/compare/${encodeURIComponent(ancestor)}...${encodeURIComponent(descendant)}`,\n\t\t);\n\t\treturn comparison.status === \"identical\" || comparison.status === \"ahead\";\n\t}\n\n\t/** @public */\n\tasync listPullRequestFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitHubFeedbackItem[]> {\n\t\tconst prefix = `${this.repositoryPath(owner, repo)}`;\n\t\tconst [conversation, reviews, inline] = await Promise.all([\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/issues/${number}/comments`, signal),\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/pulls/${number}/reviews`, signal),\n\t\t\tthis.pages<Record<string, unknown>>(`${prefix}/pulls/${number}/comments`, signal),\n\t\t]);\n\n\t\tconst candidates = [\n\t\t\t...conversation.map((item) => ({ kind: \"conversation\" as const, item })),\n\t\t\t...reviews.map((item) => ({ kind: \"review\" as const, item })),\n\t\t\t...inline.map((item) => ({ kind: \"inline\" as const, item })),\n\t\t];\n\t\tconst feedback: GitHubFeedbackItem[] = [];\n\t\tconst needsProvenance: typeof candidates = [];\n\t\tfor (const candidate of candidates) {\n\t\t\tconst { kind, item } = candidate;\n\t\t\tconst normalized = normalize(kind, item);\n\t\t\tif (!normalized) continue;\n\t\t\tconst createdAt = typeof item.created_at === \"string\" ? Date.parse(item.created_at) : NaN;\n\t\t\tconst updatedAt = typeof item.updated_at === \"string\" ? Date.parse(item.updated_at) : NaN;\n\t\t\tif (\n\t\t\t\t!this.profile.allowedOrganization ||\n\t\t\t\t(kind !== \"review\" && Number.isFinite(createdAt) && createdAt === updatedAt)\n\t\t\t) {\n\t\t\t\tfeedback.push(normalized);\n\t\t\t} else if (typeof item.node_id === \"string\" && item.node_id) {\n\t\t\t\t// REST attributes edited bodies to their original author. Reviews also\n\t\t\t\t// omit edit timestamps, so obtain the body and latest editor together.\n\t\t\t\tneedsProvenance.push(candidate);\n\t\t\t}\n\t\t}\n\t\tfor (let offset = 0; offset < needsProvenance.length; offset += 100) {\n\t\t\tconst batch = needsProvenance.slice(offset, offset + 100);\n\t\t\tconst response = await this.request<{\n\t\t\t\tdata?: { nodes?: Array<Record<string, unknown> | null> };\n\t\t\t\terrors?: unknown[];\n\t\t\t}>(\"/graphql\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tsignal,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tquery: `query LeitwerkFeedbackProvenance($ids: [ID!]!) {\n\t\t\t\t\t\tnodes(ids: $ids) {\n\t\t\t\t\t\t\tid __typename\n\t\t\t\t\t\t\t... on IssueComment { body createdAt lastEditedAt author { login } editor { login } }\n\t\t\t\t\t\t\t... on PullRequestReview { body createdAt submittedAt lastEditedAt author { login } editor { login } }\n\t\t\t\t\t\t\t... on PullRequestReviewComment { body createdAt lastEditedAt author { login } editor { login } path line }\n\t\t\t\t\t\t}\n\t\t\t\t\t}`,\n\t\t\t\t\tvariables: { ids: batch.map(({ item }) => item.node_id) },\n\t\t\t\t}),\n\t\t\t});\n\t\t\tif (response.errors?.length || !Array.isArray(response.data?.nodes)) {\n\t\t\t\tthrow new Error(\"GitHub feedback provenance lookup failed\");\n\t\t\t}\n\t\t\tconst snapshots = new Map(\n\t\t\t\tresponse.data.nodes.filter((node) => node !== null).map((node) => [node.id, node]),\n\t\t\t);\n\t\t\tfor (const { kind, item } of batch) {\n\t\t\t\tconst snapshot = snapshots.get(item.node_id);\n\t\t\t\tconst expectedType = {\n\t\t\t\t\tconversation: \"IssueComment\",\n\t\t\t\t\treview: \"PullRequestReview\",\n\t\t\t\t\tinline: \"PullRequestReviewComment\",\n\t\t\t\t}[kind];\n\t\t\t\tif (!snapshot || snapshot.__typename !== expectedType) continue;\n\t\t\t\tconst publishedAt = kind === \"review\" ? snapshot.submittedAt : snapshot.createdAt;\n\t\t\t\tif (typeof publishedAt !== \"string\" || !Number.isFinite(Date.parse(publishedAt))) continue;\n\t\t\t\tconst editedAt = snapshot.lastEditedAt;\n\t\t\t\tif (editedAt !== null) {\n\t\t\t\t\tif (typeof editedAt !== \"string\" || !Number.isFinite(Date.parse(editedAt))) continue;\n\t\t\t\t\tconst editor = asUnknownRecord(snapshot.editor)?.login;\n\t\t\t\t\tif (typeof editor !== \"string\" || !(await this.isOrganizationMember(editor))) continue;\n\t\t\t\t}\n\t\t\t\tconst normalized = normalize(kind, {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tid: item.id,\n\t\t\t\t\tuser: snapshot.author,\n\t\t\t\t\tcreated_at: editedAt ?? publishedAt,\n\t\t\t\t});\n\t\t\t\tif (normalized) feedback.push(normalized);\n\t\t\t}\n\t\t}\n\t\treturn feedback;\n\t}\n\n\t/** @public */\n\tasync getCheckSummary(owner: string, repo: string, headSha: string): Promise<GitHubCheckSummary> {\n\t\tconst runs: Array<Record<string, unknown>> = [];\n\t\tfor (let page = 1; ; page++) {\n\t\t\tconst response = await this.request<{ check_runs: Array<Record<string, unknown>> }>(\n\t\t\t\t`${this.repositoryPath(owner, repo)}/commits/${headSha}/check-runs?per_page=100&page=${page}`,\n\t\t\t);\n\t\t\truns.push(...response.check_runs);\n\t\t\tif (response.check_runs.length < 100) break;\n\t\t}\n\t\tconst terminalSuccess = new Set([\"success\", \"neutral\", \"skipped\"]);\n\t\tconst failed = runs\n\t\t\t.filter((run) => run.status === \"completed\" && !terminalSuccess.has(String(run.conclusion)))\n\t\t\t.map((run) => ({\n\t\t\t\tname: String(run.name ?? \"unknown\"),\n\t\t\t\tconclusion: typeof run.conclusion === \"string\" ? run.conclusion : null,\n\t\t\t\turl: typeof run.html_url === \"string\" ? run.html_url : null,\n\t\t\t}));\n\t\tconst pending = runs.some((run) => run.status !== \"completed\");\n\t\treturn {\n\t\t\theadSha,\n\t\t\tstatus: failed.length ? \"failure\" : pending || !runs.length ? \"pending\" : \"success\",\n\t\t\ttotal: runs.length,\n\t\t\tfailed,\n\t\t};\n\t}\n\n\t/** Human feedback checked against current membership; delivery receipts use raw reads. */\n\t/** @internal */\n\tasync listActionablePullRequestFeedback(\n\t\towner: string,\n\t\trepo: string,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\treturn actionableFeedback(\n\t\t\tthis,\n\t\t\tawait this.listPullRequestFeedback(owner, repo, number, signal),\n\t\t);\n\t}\n\n\t/** @internal */\n\tlistFeedbackReplies(owner: string, repo: string, pr: number, kind: string) {\n\t\treturn kind === \"inline\"\n\t\t\t? this.pages<Record<string, unknown>>(\n\t\t\t\t\t`${this.repositoryPath(owner, repo)}/pulls/${pr}/comments`,\n\t\t\t\t)\n\t\t\t: this.listIssueComments(owner, repo, pr);\n\t}\n\n\t/** @internal */\n\tlistFeedbackReactions(owner: string, repo: string, kind: string, id: number) {\n\t\tif (kind !== \"inline\" && kind !== \"conversation\")\n\t\t\tthrow new Error(\"Reviews do not support reactions\");\n\t\tconst segment = kind === \"inline\" ? \"pulls/comments\" : \"issues/comments\";\n\t\treturn this.pages<{\n\t\t\t/** @internal */\n\t\t\tid: number;\n\t\t\t/** @internal */\n\t\t\tcontent: string;\n\t\t\t/** @internal */\n\t\t\tuser: {\n\t\t\t\t/** @internal */\n\t\t\t\tlogin: string;\n\t\t\t};\n\t\t}>(`${this.repositoryPath(owner, repo)}/${segment}/${id}/reactions`);\n\t}\n\n\t/** @public */\n\tasync getCiDiagnostics(\n\t\towner: string,\n\t\trepo: string,\n\t\tpullRequestNumber: number,\n\t\theadSha: string,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\tconst pr = await this.getPullRequest(owner, repo, pullRequestNumber, signal);\n\t\tif (pr.state !== \"open\" || pr.merged || pr.head.sha !== headSha)\n\t\t\tthrow new Error(\"CI diagnostics target a stale pull request revision\");\n\t\tconst prefix = this.repositoryPath(owner, repo);\n\t\tconst checks: Array<{\n\t\t\t/** @internal */\n\t\t\tid: number;\n\t\t\tname: string;\n\t\t\tconclusion: string | null;\n\t\t\t/** @public */\n\t\t\t/** @public */\n\t\t\toutput?: {\n\t\t\t\t/** @public */\n\t\t\t\ttitle?: string;\n\t\t\t\t/** @public */\n\t\t\t\tsummary?: string;\n\t\t\t\t/** @public */\n\t\t\t\ttext?: string;\n\t\t\t};\n\t\t}> = [];\n\t\tfor (let page = 1; ; page++) {\n\t\t\tconst batch = await this.request<{ check_runs: typeof checks }>(\n\t\t\t\t`${prefix}/commits/${encodeURIComponent(headSha)}/check-runs?filter=latest&per_page=100&page=${page}`,\n\t\t\t\t{ signal },\n\t\t\t);\n\t\t\tchecks.push(...batch.check_runs);\n\t\t\tif (batch.check_runs.length < 100) break;\n\t\t}\n\t\tconst failed = checks.filter(\n\t\t\t(c) => c.conclusion && ![\"success\", \"neutral\", \"skipped\"].includes(c.conclusion),\n\t\t);\n\t\tconst annotations = await Promise.all(\n\t\t\tfailed.slice(0, 10).map(async (check) => ({\n\t\t\t\t/** @public */\n\t\t\t\tid: check.id,\n\t\t\t\t/** @public */\n\t\t\t\tname: check.name,\n\t\t\t\t/** @public */\n\t\t\t\toutput: check.output,\n\t\t\t\t/** @public */\n\t\t\t\tannotations: (\n\t\t\t\t\tawait this.pages<unknown>(`${prefix}/check-runs/${check.id}/annotations`, signal)\n\t\t\t\t).slice(0, 100),\n\t\t\t})),\n\t\t);\n\t\tconst jobs: Array<{\n\t\t\t/** @public */\n\t\t\tid: number;\n\t\t\t/** @public */\n\t\t\tname: string;\n\t\t\t/** @public */\n\t\t\thtml_url: string;\n\t\t\t/** @public */\n\t\t\t/** @public */\n\t\t\tlog: {\n\t\t\t\t/** @public */\n\t\t\t\ttext: string;\n\t\t\t\t/** @public */\n\t\t\t\ttruncated: boolean;\n\t\t\t};\n\t\t}> = [];\n\t\tfor (let page = 1; jobs.length < 10; page++) {\n\t\t\tconst runs = await this.request<{\n\t\t\t\tworkflow_runs: Array<{\n\t\t\t\t\tid: number;\n\t\t\t\t\thead_sha: string;\n\t\t\t\t\thead_branch: string;\n\t\t\t\t\tconclusion: string | null;\n\t\t\t\t}>;\n\t\t\t}>(\n\t\t\t\t`${prefix}/actions/runs?head_sha=${encodeURIComponent(headSha)}&per_page=100&page=${page}`,\n\t\t\t\t{ signal },\n\t\t\t);\n\t\t\tfor (const run of runs.workflow_runs) {\n\t\t\t\tif (\n\t\t\t\t\trun.head_sha !== headSha ||\n\t\t\t\t\trun.head_branch !== pr.head.ref ||\n\t\t\t\t\t!run.conclusion ||\n\t\t\t\t\t[\"success\", \"neutral\", \"skipped\"].includes(run.conclusion)\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor (let jobPage = 1; jobs.length < 10; jobPage++) {\n\t\t\t\t\tconst batch = await this.request<{\n\t\t\t\t\t\tjobs: Array<{ id: number; name: string; html_url: string; conclusion: string | null }>;\n\t\t\t\t\t}>(`${prefix}/actions/runs/${run.id}/jobs?filter=latest&per_page=100&page=${jobPage}`, {\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t});\n\t\t\t\t\tfor (const job of batch.jobs) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!job.conclusion ||\n\t\t\t\t\t\t\t[\"success\", \"neutral\", \"skipped\"].includes(job.conclusion) ||\n\t\t\t\t\t\t\tjobs.length >= 10\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tjobs.push({\n\t\t\t\t\t\t\tid: job.id,\n\t\t\t\t\t\t\tname: job.name,\n\t\t\t\t\t\t\thtml_url: job.html_url,\n\t\t\t\t\t\t\tlog: await this.readJobLog(owner, repo, job.id, signal),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tif (batch.jobs.length < 100) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (runs.workflow_runs.length < 100) break;\n\t\t}\n\t\tconst refreshed = await this.getPullRequest(owner, repo, pullRequestNumber, signal);\n\t\tif (refreshed.head.sha !== headSha || refreshed.state !== \"open\" || refreshed.merged)\n\t\t\tthrow new Error(\"CI diagnostics were superseded\");\n\t\treturn {\n\t\t\t/** @public */\n\t\t\theadSha,\n\t\t\t/** @public */\n\t\t\tchecks: annotations,\n\t\t\t/** @public */\n\t\t\tjobs,\n\t\t\t/** @public */\n\t\t\ttruncated: failed.length > 10 || jobs.length >= 10,\n\t\t};\n\t}\n\tprivate async readJobLog(\n\t\towner: string,\n\t\trepo: string,\n\t\tjob: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<{ text: string; truncated: boolean }> {\n\t\tconst timeout = signal\n\t\t\t? AbortSignal.any([signal, AbortSignal.timeout(30000)])\n\t\t\t: AbortSignal.timeout(30000);\n\t\tlet response = await fetch(\n\t\t\t`${this.profile.apiBaseUrl}${this.repositoryPath(owner, repo)}/actions/jobs/${job}/logs`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${this.profile.token}`,\n\t\t\t\t\tAccept: \"application/vnd.github+json\",\n\t\t\t\t},\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: timeout,\n\t\t\t},\n\t\t);\n\t\tif (response.status === 302) {\n\t\t\tconst location = new URL(response.headers.get(\"location\") ?? \"\");\n\t\t\tif (location.protocol !== \"https:\" || location.username || location.password)\n\t\t\t\tthrow new Error(\"Invalid GitHub log download URL\");\n\t\t\tawait response.body?.cancel();\n\t\t\t// Signed storage URLs must never receive the GitHub credential.\n\t\t\tresponse = await fetch(location, { redirect: \"error\", signal: timeout });\n\t\t}\n\t\tif (!response.ok) throw new IntegrationHttpError(response.status, \"GitHub job log unavailable\");\n\t\tconst reader = response.body?.getReader();\n\t\tif (!reader) return { text: \"\", truncated: false };\n\t\tconst chunks: Uint8Array[] = [];\n\t\tlet bytes = 0;\n\t\tlet truncated = false;\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst next = await reader.read();\n\t\t\t\tif (next.done) break;\n\t\t\t\tconst part = next.value.slice(0, 65536 - bytes);\n\t\t\t\tchunks.push(part);\n\t\t\t\tbytes += part.length;\n\t\t\t\tif (bytes === 65536) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tawait reader.cancel();\n\t\t}\n\t\treturn { text: Buffer.concat(chunks).toString(\"utf8\"), truncated };\n\t}\n\n\t/** @internal */\n\tlistReleases(owner: string, repo: string) {\n\t\treturn this.pages<GitHubRelease>(`${this.repositoryPath(owner, repo)}/releases`);\n\t}\n\n\t/** @public */\n\tdownloadReleaseAsset(asset: GitHubRelease[\"assets\"][number]): Promise<string> {\n\t\tconst url = new URL(asset.url);\n\t\tif (`${url.protocol}//${url.host}` !== this.profile.apiBaseUrl)\n\t\t\tthrow new Error(\"GitHub release asset URL does not match the configured API origin\");\n\t\treturn this.response(`${url.pathname}${url.search}`, {\n\t\t\theaders: { Accept: \"application/octet-stream\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