@leitwerk-dev/github 0.3.0 → 0.4.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.
@@ -0,0 +1,164 @@
1
+ import {
2
+ listTicketDestinations,
3
+ markdownTicketCreationDefinition,
4
+ numberArg,
5
+ objectArg,
6
+ parseTicketDestinationId,
7
+ type ServerExtensionAPI,
8
+ stringArg,
9
+ type TicketCreationConfig,
10
+ type TicketCreationDestinationProvider,
11
+ type TicketCreationDestinationSnapshot,
12
+ ticketDestinationId,
13
+ ticketLabelNames,
14
+ } from "@leitwerk-dev/process-sdk";
15
+ import type { GitHubIntegration } from "./capability.js";
16
+ import { assertGitHubRepository, type GitHubRepository } from "./client.js";
17
+
18
+ function destinationData(snapshot: TicketCreationDestinationSnapshot) {
19
+ const data = objectArg(snapshot.data);
20
+ return {
21
+ profile: stringArg(data, "profile"),
22
+ baseUrl: stringArg(data, "baseUrl"),
23
+ repositoryId: numberArg(data, "repositoryId"),
24
+ owner: stringArg(data, "owner"),
25
+ repo: stringArg(data, "repo"),
26
+ defaultLabels: ticketLabelNames(data.defaultLabels),
27
+ };
28
+ }
29
+
30
+ function available(repository: GitHubRepository): boolean {
31
+ return !!repository.id && !repository.archived && repository.has_issues;
32
+ }
33
+
34
+ /** @internal */
35
+ export function registerGitHubTicketCreation(
36
+ api: ServerExtensionAPI,
37
+ integration: GitHubIntegration,
38
+ config: TicketCreationConfig,
39
+ ): void {
40
+ if (!config.enabled) return;
41
+ const summary = (profile: string, repository: GitHubRepository) => ({
42
+ id: ticketDestinationId(profile, repository.id ?? 0),
43
+ displayName: repository.full_name,
44
+ group: `${profile} · ${new URL(integration.client(profile).profile.apiBaseUrl).hostname}`,
45
+ description: config.defaultLabels.length
46
+ ? `Default labels: ${config.defaultLabels.join(", ")}`
47
+ : "No default labels",
48
+ });
49
+ const validateDestination = async (
50
+ snapshot: TicketCreationDestinationSnapshot,
51
+ signal?: AbortSignal,
52
+ ) => {
53
+ const data = destinationData(snapshot);
54
+ const client = integration.client(data.profile);
55
+ if (client.profile.apiBaseUrl !== data.baseUrl)
56
+ throw new Error("GitHub profile installation changed");
57
+ assertGitHubRepository(client.profile, data.owner, data.repo);
58
+ const repository = await client.getRepositoryById(data.repositoryId, signal);
59
+ if (
60
+ !available(repository) ||
61
+ repository.owner.login !== data.owner ||
62
+ repository.name !== data.repo
63
+ )
64
+ throw new Error("The selected GitHub repository changed; choose the destination again");
65
+ };
66
+ const destinations: TicketCreationDestinationProvider = {
67
+ list() {
68
+ return listTicketDestinations("GitHub", integration.profiles?.() ?? [], async (profile) =>
69
+ (await integration.client(profile).listRepositories())
70
+ .filter(available)
71
+ .map((repository) => summary(profile, repository)),
72
+ );
73
+ },
74
+ async resolve({ destinationId }) {
75
+ const { profile, resourceId } = parseTicketDestinationId(destinationId);
76
+ const client = integration.client(profile);
77
+ const repository = await client.getRepositoryById(Number(resourceId));
78
+ if (!available(repository))
79
+ throw new Error("The selected GitHub repository cannot accept issues");
80
+ const labels = await client.listLabels(repository.owner.login, repository.name);
81
+ return {
82
+ summary: summary(profile, repository),
83
+ data: {
84
+ profile,
85
+ baseUrl: client.profile.apiBaseUrl,
86
+ repositoryId: repository.id,
87
+ owner: repository.owner.login,
88
+ repo: repository.name,
89
+ defaultLabels: config.defaultLabels,
90
+ },
91
+ agentContext: `Create an issue in ${repository.full_name}. Existing optional labels: ${labels.map((label) => label.name).join(", ") || "none"}.`,
92
+ };
93
+ },
94
+ validate: validateDestination,
95
+ };
96
+ api.tool<Record<string, unknown>>({
97
+ name: "github_create_issue",
98
+ description: "Create one issue in the selected GitHub repository",
99
+ ...markdownTicketCreationDefinition("GitHub", destinations),
100
+ async execute(ctx, args) {
101
+ if (!ctx.ticketDestination) throw new Error("A GitHub ticket destination is required");
102
+ ctx.signal.throwIfAborted();
103
+ await validateDestination(ctx.ticketDestination, ctx.signal);
104
+ ctx.signal.throwIfAborted();
105
+ const target = destinationData(ctx.ticketDestination);
106
+ const client = integration.client(target.profile);
107
+ const title = stringArg(args, "title");
108
+ const body = stringArg(args, "body");
109
+ const requestedLabels = ticketLabelNames(args.labels);
110
+ const labels = await client.listLabels(target.owner, target.repo, ctx.signal);
111
+ const unknown = requestedLabels.filter(
112
+ (name) =>
113
+ !target.defaultLabels.includes(name) && !labels.some((label) => label.name === name),
114
+ );
115
+ if (unknown.length) throw new Error(`Unknown GitHub labels: ${unknown.join(", ")}`);
116
+ for (const name of target.defaultLabels) {
117
+ ctx.signal.throwIfAborted();
118
+ await ctx.externalWrites.ensure(
119
+ { writeType: "github.ensure_label", dedupKey: `${ctx.idempotencyKey}:label:${name}` },
120
+ {
121
+ reconcile: async () =>
122
+ (await client.listLabels(target.owner, target.repo, ctx.signal)).find(
123
+ (label) => label.name === name,
124
+ ) ?? null,
125
+ execute: () => {
126
+ ctx.signal.throwIfAborted();
127
+ return client.createLabel(target.owner, target.repo, name, ctx.signal);
128
+ },
129
+ toMetadata: (label) => ({ id: label.id, name: label.name }),
130
+ },
131
+ );
132
+ }
133
+ const marker = `<!-- leitwerk-ticket-write:${ctx.idempotencyKey} -->`;
134
+ const issue = await ctx.externalWrites.ensure(
135
+ { writeType: "github.create_issue", dedupKey: ctx.idempotencyKey },
136
+ {
137
+ reconcile: async () =>
138
+ (await client.listIssues(target.owner, target.repo, ctx.signal)).find((issue) =>
139
+ issue.body?.includes(marker),
140
+ ) ?? null,
141
+ execute: () => {
142
+ ctx.signal.throwIfAborted();
143
+ return client.createIssue(
144
+ target.owner,
145
+ target.repo,
146
+ {
147
+ title,
148
+ body: `${body}\n\n${marker}`,
149
+ labels: [...new Set([...target.defaultLabels, ...requestedLabels])],
150
+ },
151
+ ctx.signal,
152
+ );
153
+ },
154
+ toMetadata: (issue) => ({ number: issue.number, url: issue.html_url }),
155
+ },
156
+ );
157
+ return {
158
+ externalId: `${target.owner}/${target.repo}#${issue.number}`,
159
+ url: issue.html_url,
160
+ result: issue,
161
+ };
162
+ },
163
+ });
164
+ }
@@ -1 +0,0 @@
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\" },\n\t\t}).then((response) => response.text());\n\t}\n}\n"],"mappings":";AAIA,eAAsB,kBACrB,QACA,OACA,MACA,QACA,SACA,MACC;AACD,MACC,OAAO,QAAQ,uBACf,MAAM,YAAY,MAAM,OAAO,QAAQ,oBAAoB,YAAY;AAEvE,WAAO;AACR,QAAM,QAAS,MAAM,OAAO,SAAS,OAAO,MAAM,MAAM;AAIxD,MACC,MAAM,gBACN,MAAM,UAAU,UAChB,CAAC,MAAM,OAAO,KAAK,CAAC,UAAU,MAAM,SAAS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