@leitwerk-dev/github 0.3.1 → 0.4.1

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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/capability.ts","../src/provider.ts","../src/external.ts","../src/issue-provider.ts","../src/issue-watcher.ts","../src/poll-report.ts","../src/tools.ts","../src/binding.ts"],"sourcesContent":["import { coreHostCapabilities, type LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { type GitHubIntegration, githubIntegration } from \"./capability.js\";\nimport { GitHubClient, parseGitHubProfiles } from \"./client.js\";\nimport { createGitHubProvider } from \"./provider.js\";\nimport { registerGitHubTools } from \"./tools.js\";\n\n/** @internal */\nconst manifest = {\n\tid: \"github\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n} as const;\n\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseGitHubProfiles(config);\n\t\tconst integration: GitHubIntegration = {\n\t\t\tprofiles: () => [...profiles.keys()],\n\t\t\tclient(profile) {\n\t\t\t\tconst value = profiles.get(profile);\n\t\t\t\tif (!value) throw new Error(`Unknown GitHub profile '${profile}'`);\n\t\t\t\treturn new GitHubClient(value);\n\t\t\t},\n\t\t};\n\t\tsetupGitHubIntegration(api, integration);\n\t},\n};\n\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. @public */\nexport function setupGitHubIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: GitHubIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t} = {},\n) {\n\tapi.provide(githubIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterGitHubTools(api, integration);\n\treturn createGitHubProvider(deps, integration, options);\n}\n\nexport { resolveGitHubProjectBinding } from \"./binding.js\";\nexport type { GitHubIntegration } from \"./capability.js\";\nexport { githubIntegration } from \"./capability.js\";\nexport type {\n\tGitHubCheckSummary,\n\tGitHubGitIdentity,\n\tGitHubIssue,\n\tGitHubPullRequest,\n\tGitHubRepository,\n} from \"./client.js\";\nexport {\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n\tgithubExternal,\n} from \"./external.js\";\nexport { githubIssueWatcherSource } from \"./issue-watcher.js\";\n","import { createCapabilityToken } from \"@leitwerk-dev/process-sdk\";\nimport type { GitHubClient } from \"./client.js\";\n\n/** Public contract shared by HTTP and local adapters. @public */\nexport type GitHubClientLike = Pick<GitHubClient, keyof GitHubClient>;\n\n/** @public */\nexport interface GitHubIntegration {\n\t/** @public */\n\tprofiles?(): readonly string[];\n\t/** @public */\n\tclient(profile: string): GitHubClientLike;\n}\n\n/** @public */\nexport const githubIntegration = createCapabilityToken<GitHubIntegration>(\n\t\"@leitwerk-private/github.integration\",\n);\n","import { conflictEvidence, createConflictReporter } from \"@leitwerk-dev/coding/repository-rebase\";\nimport { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport type { CoreServerSetupDeps } from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport {\n\tdescribeGitHubEvent,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_RELEASE_KIND,\n\ttype GitHubPullRequestSourceConfig,\n} from \"./external.js\";\nimport { createGitHubIssuePolling } from \"./issue-provider.js\";\nimport { githubPollReporter } from \"./poll-report.js\";\n\nfunction parse(value: unknown): GitHubPullRequestSourceConfig | null {\n\tconst config = asUnknownRecord(value) ?? {};\n\tif (\n\t\t[\"profile\", \"owner\", \"repo\", \"headSha\"].some(\n\t\t\t(key) => typeof config[key] !== \"string\" || !(config[key] as string).trim(),\n\t\t) ||\n\t\ttypeof config.prNumber !== \"number\"\n\t)\n\t\treturn null;\n\treturn {\n\t\tprofile: config.profile as string,\n\t\towner: config.owner as string,\n\t\trepo: config.repo as string,\n\t\tprNumber: config.prNumber,\n\t\theadSha: config.headSha as string,\n\t\tlastConflictKey: typeof config.lastConflictKey === \"string\" ? config.lastConflictKey : null,\n\t\tfeedbackCursor: typeof config.feedbackCursor === \"number\" ? config.feedbackCursor : 0,\n\t\tpollInterval: typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\",\n\t\tdisabled: config.disabled === true,\n\t\teventKinds: Array.isArray(config.eventKinds)\n\t\t\t? config.eventKinds.filter(\n\t\t\t\t\t(value): value is \"checks\" | \"feedback\" | \"merged\" | \"closed\" | \"merge_conflict\" =>\n\t\t\t\t\t\t[\"checks\", \"feedback\", \"merged\", \"closed\", \"merge_conflict\"].includes(String(value)),\n\t\t\t\t)\n\t\t\t: undefined,\n\t\tcheckStatuses: Array.isArray(config.checkStatuses)\n\t\t\t? config.checkStatuses.filter((value): value is \"pending\" | \"success\" | \"failure\" =>\n\t\t\t\t\t[\"pending\", \"success\", \"failure\"].includes(String(value)),\n\t\t\t\t)\n\t\t\t: undefined,\n\t};\n}\n\nexport function createGitHubProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitHubIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst due = createPollSchedule();\n\tconst pollIssues = createGitHubIssuePolling(deps, integration, options);\n\tconst reportConflict = createConflictReporter(GITHUB_PR_STATE_KIND);\n\treturn deps.polling.create({\n\t\tid: \"github\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5_000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tconst report = githubPollReporter(deps.externalSources, result);\n\t\t\tawait pollIssues(result);\n\t\t\tawait report.poll(GITHUB_PR_STATE_KIND, async (armed) => {\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tif (!config) {\n\t\t\t\t\tresult.errors.push(`${armed.id}:invalid_config`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (config.disabled) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tconst now = options.now?.() ?? Date.now();\n\t\t\t\tif (!due(key, config.pollInterval, now)) return;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\t\tconst pr = await client.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\t\t\tif (!config.eventKinds || config.eventKinds.includes(\"merge_conflict\")) {\n\t\t\t\t\t\tconst conflict = conflictEvidence(config, pr, \"github\");\n\t\t\t\t\t\t// GitHub's PR base SHA can lag the branch even while its state is behind.\n\t\t\t\t\t\tif (conflict?.reason === \"behind\") {\n\t\t\t\t\t\t\tconst branch = await client.getCommit(config.owner, config.repo, conflict.baseBranch);\n\t\t\t\t\t\t\tconflict.baseSha = branch.sha;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tawait reportConflict(report, armed, conflict, config.lastConflictKey, {\n\t\t\t\t\t\t\t\tsummary: `PR #${pr.number} mergeability: ${pr.mergeable == null ? \"unresolved\" : (pr.mergeable_state ?? String(pr.mergeable))}`,\n\t\t\t\t\t\t\t\tobservedAt: new Date(now).toISOString(),\n\t\t\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${pr.number}`,\n\t\t\t\t\t\t\t\trevision: `${pr.head.sha}:${conflict?.baseSha ?? pr.base.sha}`,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (config.eventKinds?.length === 1) return;\n\t\t\t\t\t}\n\t\t\t\t\tlet event: Record<string, unknown> | null = null;\n\t\t\t\t\tlet mergeKey = \"\";\n\t\t\t\t\tif (pr.merged || pr.state === \"closed\") {\n\t\t\t\t\t\tevent = {\n\t\t\t\t\t\t\tkind: pr.merged ? \"merged\" : \"closed\",\n\t\t\t\t\t\t\tpullRequest: pr,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tmergeKey = `terminal:${pr.number}:${pr.merged}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pr.head.sha !== config.headSha) return;\n\t\t\t\t\t\tconst readsFeedback = !config.eventKinds || config.eventKinds.includes(\"feedback\");\n\t\t\t\t\t\tconst readsChecks = !config.eventKinds || config.eventKinds.includes(\"checks\");\n\t\t\t\t\t\tconst [feedback, checks] = await Promise.all([\n\t\t\t\t\t\t\treadsFeedback\n\t\t\t\t\t\t\t\t? client.listActionablePullRequestFeedback(\n\t\t\t\t\t\t\t\t\t\tconfig.owner,\n\t\t\t\t\t\t\t\t\t\tconfig.repo,\n\t\t\t\t\t\t\t\t\t\tconfig.prNumber,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: Promise.resolve([]),\n\t\t\t\t\t\t\treadsChecks || (deps.externalSources.observe && armed.generation)\n\t\t\t\t\t\t\t\t? client\n\t\t\t\t\t\t\t\t\t\t.getCheckSummary(config.owner, config.repo, config.headSha)\n\t\t\t\t\t\t\t\t\t\t.catch(async (error) => {\n\t\t\t\t\t\t\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\t\t\t\t\t\t\trefreshError:\n\t\t\t\t\t\t\t\t\t\t\t\t\terror instanceof Error ? error.message : \"Checks refresh failed\",\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tif (readsChecks) throw error;\n\t\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: Promise.resolve(null),\n\t\t\t\t\t\t]);\n\t\t\t\t\t\tif (checks && checks.headSha !== config.headSha) return;\n\t\t\t\t\t\tconst refreshed = await client.getPullRequest(\n\t\t\t\t\t\t\tconfig.owner,\n\t\t\t\t\t\t\tconfig.repo,\n\t\t\t\t\t\t\tconfig.prNumber,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trefreshed.state !== \"open\" ||\n\t\t\t\t\t\t\trefreshed.merged ||\n\t\t\t\t\t\t\trefreshed.head.sha !== config.headSha\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (checks && deps.externalSources.observe && armed.generation) {\n\t\t\t\t\t\t\tconst description = describeGitHubEvent({ kind: \"checks\", checks });\n\t\t\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\t\t\tobservation: {\n\t\t\t\t\t\t\t\t\t...description,\n\t\t\t\t\t\t\t\t\tobservedAt: new Date(now).toISOString(),\n\t\t\t\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${config.prNumber}`,\n\t\t\t\t\t\t\t\t\trevision: checks.headSha,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst unseen = feedback.filter(\n\t\t\t\t\t\t\t(item) => item.id > config.feedbackCursor && item.author !== client.profile.botLogin,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (unseen.length) {\n\t\t\t\t\t\t\tconst feedbackCursor = Math.max(...unseen.map((item) => item.id));\n\t\t\t\t\t\t\tevent = { kind: \"feedback\", feedback, feedbackCursor };\n\t\t\t\t\t\t\tmergeKey = `feedback:${feedbackCursor}`;\n\t\t\t\t\t\t} else if (readsChecks && checks && checks.status !== \"pending\") {\n\t\t\t\t\t\t\tevent = { kind: \"checks\", checks };\n\t\t\t\t\t\t\tmergeKey = `checks:${checks.headSha}:${checks.status}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\t!event ||\n\t\t\t\t\t\t(config.eventKinds &&\n\t\t\t\t\t\t\t!config.eventKinds.includes(\n\t\t\t\t\t\t\t\tString(event.kind) as (typeof config.eventKinds)[number],\n\t\t\t\t\t\t\t)) ||\n\t\t\t\t\t\t(event.kind === \"checks\" &&\n\t\t\t\t\t\t\tconfig.checkStatuses &&\n\t\t\t\t\t\t\t!config.checkStatuses.includes(\n\t\t\t\t\t\t\t\t(event.checks as { status: \"pending\" | \"success\" | \"failure\" }).status,\n\t\t\t\t\t\t\t))\n\t\t\t\t\t)\n\t\t\t\t\t\treturn;\n\t\t\t\t\tawait report.fire(armed, event, mergeKey);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\trefreshError: error instanceof Error ? error.message : \"PR refresh failed\",\n\t\t\t\t\t});\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\tawait report.poll(GITHUB_RELEASE_KIND, async (armed) => {\n\t\t\t\tconst config = asUnknownRecord(armed.resolved) ?? {};\n\t\t\t\tif (\n\t\t\t\t\ttypeof config.profile !== \"string\" ||\n\t\t\t\t\ttypeof config.owner !== \"string\" ||\n\t\t\t\t\ttypeof config.repo !== \"string\" ||\n\t\t\t\t\ttypeof config.mergeSha !== \"string\"\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tif (config.disabled === true) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tconst now = options.now?.() ?? Date.now();\n\t\t\t\tif (!due(key, typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\", now))\n\t\t\t\t\treturn;\n\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\tfor (const release of await client.listReleases(config.owner, config.repo)) {\n\t\t\t\t\tif (release.draft || release.prerelease) continue;\n\t\t\t\t\tconst commit = await client.getCommit(config.owner, config.repo, release.tag_name);\n\t\t\t\t\tif (!(await client.isAncestor(config.owner, config.repo, config.mergeSha, commit.sha)))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t{ release, commitSha: commit.sha },\n\t\t\t\t\t\t`${release.id}:${commit.sha}`,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n","import { describeConflict } from \"@leitwerk-dev/coding/repository-rebase\";\nimport {\n\tdefineExternalActionSource,\n\ttype ExternalEventDescription,\n} from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport const GITHUB_PR_STATE_KIND = \"@leitwerk-private/github.pr_state\";\n\n/** @public */\nexport interface GitHubPullRequestSourceConfig {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n\t/** @public */\n\tprNumber: number;\n\t/** @public */\n\theadSha: string;\n\t/** @public */\n\tfeedbackCursor: number;\n\t/** @public */\n\tlastConflictKey?: string | null;\n\t/** @public */\n\tpollInterval?: string;\n\t/** @internal */\n\tdisabled?: boolean;\n\t/** @public */\n\teventKinds?: Array<\"checks\" | \"feedback\" | \"merged\" | \"closed\" | \"merge_conflict\">;\n\t/** @internal */\n\tcheckStatuses?: Array<\"pending\" | \"success\" | \"failure\">;\n}\n\n/** @internal */\nexport const GITHUB_RELEASE_KIND = \"@leitwerk-private/github.release\";\n\n/** @internal */\nexport interface GitHubReleaseSourceConfig {\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\towner: string;\n\t/** @internal */\n\trepo: string;\n\t/** @internal */\n\tmergeSha: string;\n\t/** @internal */\n\tpollInterval?: string;\n\t/** @internal */\n\tdisabled?: boolean;\n}\n\n/** @internal */\nexport function describeGitHubEvent(event: unknown): ExternalEventDescription {\n\tconst value = event as {\n\t\tkind?: string;\n\t\tchecks?: {\n\t\t\theadSha: string;\n\t\t\tstatus: string;\n\t\t\tfailed: Array<{ name: string; url: string | null }>;\n\t\t};\n\t\tpullRequest?: { number: number; merged?: boolean; state?: string };\n\t};\n\tif (value.kind === \"merge_conflict\") return describeConflict(event);\n\tif (value.checks) {\n\t\tconst checks = value.checks;\n\t\treturn {\n\t\t\tsummary: `Checks ${checks.status} on ${checks.headSha}${checks.failed.length ? `: ${checks.failed.map((check) => check.name).join(\", \")}` : \"\"}`,\n\t\t\tlinks: checks.failed.flatMap((check, index) =>\n\t\t\t\tcheck.url\n\t\t\t\t\t? [{ id: `check-${index}`, label: check.name, url: check.url, kind: \"pipeline\" as const }]\n\t\t\t\t\t: [],\n\t\t\t),\n\t\t};\n\t}\n\treturn {\n\t\tsummary:\n\t\t\tvalue.kind === \"merged\" || value.kind === \"closed\" || value.pullRequest\n\t\t\t\t? `PR #${value.pullRequest?.number} ${value.kind ?? (value.pullRequest?.merged ? \"merged\" : \"closed\")}`\n\t\t\t\t: value.kind === \"feedback\"\n\t\t\t\t\t? \"Pull request feedback received\"\n\t\t\t\t\t: \"GitHub event received\",\n\t};\n}\n\n/** @public */\nexport const GITHUB_PR_TERMINAL_KIND = \"@leitwerk-public/github.pr_terminal\";\n/** @public */\nexport const GITHUB_PR_FEEDBACK_KIND = \"@leitwerk-public/github.pr_feedback\";\n/** @public */\nexport const GITHUB_ISSUE_CANCELLED_KIND = \"@leitwerk-public/github.issue_cancelled\";\n\n/** @public */\nexport interface GitHubPullRequestTerminalSourceConfig {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n\t/** @public */\n\tprNumber: number;\n\t/** @public */\n\tpollInterval?: string;\n\t/** @public */\n\tterminalOutcome?: \"merged\" | \"closed\";\n\t/** @internal */\n\tdisabled?: boolean;\n}\n\n/** @public */\nexport interface GitHubFeedbackSourceConfig extends GitHubPullRequestTerminalSourceConfig {\n\t/** @public */\n\tconversationCursor: number;\n\t/** @public */\n\treviewCursor: number;\n\t/** @public */\n\tinlineCursor: number;\n\t/** @public */\n\tquietPeriodMs: number;\n}\n\n/** @public */\nexport interface GitHubIssueCancelledSourceConfig {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\towner: string;\n\t/** @public */\n\trepo: string;\n\t/** @public */\n\tissueNumber: number;\n\t/** @public */\n\ttriggerLabel: string;\n\t/** @public */\n\tpollInterval?: string;\n}\n\n/** @public */\nexport const GITHUB_CHECKS_KIND = \"@leitwerk-public/github.checks\";\n\n/** @public */\nexport const githubExternal = {\n\t/** @public */\n\tchecks: defineExternalActionSource<{\n\t\tafterKey?: string;\n\t\tprofile: string;\n\t\towner: string;\n\t\trepo: string;\n\t\tprNumber: number;\n\t\theadSha: string;\n\t}>({\n\t\tkind: GITHUB_CHECKS_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub Actions failures\",\n\t}),\n\t/** @public */\n\tissueCancelled: defineExternalActionSource<GitHubIssueCancelledSourceConfig>({\n\t\tkind: GITHUB_ISSUE_CANCELLED_KIND,\n\t\tdescribeEvent: () => ({ summary: \"Source issue cancelled\" }),\n\t\tlabel: \"GitHub source issue cancelled\",\n\t\tdescription: \"Fires when the source issue closes or loses its trigger label\",\n\t}),\n\t/** @public */\n\tpullRequestTerminal: defineExternalActionSource<GitHubPullRequestTerminalSourceConfig>({\n\t\tkind: GITHUB_PR_TERMINAL_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub pull request merged or closed\",\n\t\tdescription: \"Fires when the tracked pull request reaches a terminal state\",\n\t}),\n\t/** @public */\n\tpullRequestFeedback: defineExternalActionSource<GitHubFeedbackSourceConfig>({\n\t\tkind: GITHUB_PR_FEEDBACK_KIND,\n\t\tdescribeEvent: () => ({ summary: \"Pull request feedback received\" }),\n\t\tlabel: \"GitHub pull request feedback\",\n\t\tdescription: \"Fires after unseen human feedback has been quiet long enough to batch\",\n\t}),\n\t/** @internal */\n\treleaseContaining: defineExternalActionSource<GitHubReleaseSourceConfig>({\n\t\tkind: GITHUB_RELEASE_KIND,\n\t\tlabel: \"Published GitHub release\",\n\t\tdescription: \"Fires when a published release contains the tracked merge commit\",\n\t}),\n\t/** @public */\n\tpullRequestState: defineExternalActionSource<GitHubPullRequestSourceConfig>({\n\t\tkind: GITHUB_PR_STATE_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub pull request state\",\n\t\tdescription: \"Fires for failed or successful checks, review feedback, and terminal PR state\",\n\t}),\n};\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\ttype ExternalSourceArmingLike,\n\tmatchesRepository as matchesConfiguredRepository,\n\tparseRepositoryFeedbackConfig as parseFeedbackConfig,\n\tparseRepositoryIssueCancelledConfig as parseIssueCancelledConfig,\n\tparseRepositoryPullRequestConfig as parsePrConfig,\n\ttype RegisteredProcessWatcherLike,\n\trepositoryFeedbackBatch,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, type emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport type { GitHubIssue, GitHubRepository } from \"./client.js\";\nimport {\n\tdescribeGitHubEvent,\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n} from \"./external.js\";\nimport {\n\ttype GitHubIssueWatcherConfig,\n\ttype GitHubIssueWatcherEvent,\n\tgithubIssueWatcherSource,\n} from \"./issue-watcher.js\";\nimport { githubPollReporter } from \"./poll-report.js\";\n\nfunction hasLabel(issue: GitHubIssue, label: string): boolean {\n\treturn issue.labels.some((candidate) => candidate.name === label);\n}\n\nfunction externalId(repo: GitHubRepository, issue: GitHubIssue): string {\n\treturn `github:${repo.full_name}#${issue.number}`;\n}\n\nexport { matchesConfiguredRepository };\n\nexport function createGitHubIssuePolling(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitHubIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst now = options.now ?? Date.now;\n\tconst due = createPollSchedule(now);\n\n\tasync function discover(\n\t\twatcher: RegisteredProcessWatcherLike<GitHubIssueWatcherConfig, GitHubIssueWatcherEvent>,\n\t\tresult: ReturnType<typeof emptyPollResult>,\n\t) {\n\t\tconst config = watcher.config;\n\t\tconst client = integration.client(config.profile);\n\t\tfor (const repo of await client.listRepositories()) {\n\t\t\tif (!matchesConfiguredRepository(config, repo)) continue;\n\t\t\tfor (const issue of await client.listOpenIssues(repo.owner.login, repo.name)) {\n\t\t\t\tif (!hasLabel(issue, config.labels.trigger) || hasLabel(issue, config.labels.done))\n\t\t\t\t\tcontinue;\n\t\t\t\tconst id = externalId(repo, issue);\n\t\t\t\ttry {\n\t\t\t\t\tif (deps.processes.listAll().some((process) => process.externalId === id)) {\n\t\t\t\t\t\tresult.skipped.push(id);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst authorized = await client.authorizedTrigger(\n\t\t\t\t\t\trepo.owner.login,\n\t\t\t\t\t\trepo.name,\n\t\t\t\t\t\tissue.number,\n\t\t\t\t\t\tconfig.labels.trigger,\n\t\t\t\t\t\tconfig.labels.done,\n\t\t\t\t\t);\n\t\t\t\t\tif (!authorized) {\n\t\t\t\t\t\tresult.skipped.push(`${id}:unauthorized`);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst event: GitHubIssueWatcherEvent = {\n\t\t\t\t\t\tprofile: config.profile,\n\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\tissue: authorized.issue,\n\t\t\t\t\t\tauthorization: {\n\t\t\t\t\t\t\tactor: authorized.actor,\n\t\t\t\t\t\t\teventId: authorized.eventId,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels: config.labels,\n\t\t\t\t\t};\n\n\t\t\t\t\tconst guardedWatcher = {\n\t\t\t\t\t\t...watcher,\n\t\t\t\t\t\tasync resolveLaunchAttempt(...args: Parameters<typeof watcher.resolveLaunchAttempt>) {\n\t\t\t\t\t\t\tconst attempt = await watcher.resolveLaunchAttempt(...args);\n\t\t\t\t\t\t\tif (!attempt) return null;\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...attempt,\n\t\t\t\t\t\t\t\tpreparationChecks: [\n\t\t\t\t\t\t\t\t\t...attempt.preparationChecks,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"github-trigger-authorization\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Check GitHub trigger authorization\",\n\t\t\t\t\t\t\t\t\t\tasync run() {\n\t\t\t\t\t\t\t\t\t\t\tconst rechecked = await client.authorizedTrigger(\n\t\t\t\t\t\t\t\t\t\t\t\trepo.owner.login,\n\t\t\t\t\t\t\t\t\t\t\t\trepo.name,\n\t\t\t\t\t\t\t\t\t\t\t\tissue.number,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig.labels.trigger,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig.labels.done,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t!rechecked ||\n\t\t\t\t\t\t\t\t\t\t\t\trechecked.eventId !== authorized.eventId ||\n\t\t\t\t\t\t\t\t\t\t\t\trechecked.actor !== authorized.actor\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"GitHub trigger authorization changed before launch\");\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst launched = await deps.launchRuns.startWatcher(guardedWatcher, event, {\n\t\t\t\t\t\tidempotencyKey: id,\n\t\t\t\t\t});\n\t\t\t\t\tif (launched.error) result.errors.push(`${id}:launch_failed:${launched.error}`);\n\t\t\t\t\telse if (launched.process) result.created.push(id);\n\t\t\t\t\telse result.skipped.push(id);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresult.errors.push(\n\t\t\t\t\t\t`${id}:${error instanceof Error ? error.message : \"discovery_failed\"}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync function pollExternal(result: ReturnType<typeof emptyPollResult>) {\n\t\tconst report = githubPollReporter(deps.externalSources, result);\n\t\tconst terminalArmings = deps.externalSources.listArmed(GITHUB_PR_TERMINAL_KIND);\n\t\tconst terminalInstances = new Set<string>();\n\t\tasync function poll<C extends { pollInterval?: string; disabled?: boolean }>(\n\t\t\tkind: string,\n\t\t\tparse: (value: unknown) => C | null,\n\t\t\tread: (config: C, armed: ExternalSourceArmingLike) => Promise<void>,\n\t\t) {\n\t\t\tconst armings =\n\t\t\t\tkind === GITHUB_PR_TERMINAL_KIND ? terminalArmings : deps.externalSources.listArmed(kind);\n\t\t\tfor (const armed of armings) {\n\t\t\t\tif (kind !== GITHUB_PR_TERMINAL_KIND && terminalInstances.has(armed.instanceId)) continue;\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tif (!config || !due(key, config.pollInterval ?? \"30s\") || config.disabled) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait read(config, armed);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\trefreshError: error instanceof Error ? error.message : \"GitHub refresh failed\",\n\t\t\t\t\t});\n\t\t\t\t\tconst fallback = kind === GITHUB_CHECKS_KIND ? \"checks_failed\" : \"poll_failed\";\n\t\t\t\t\tresult.errors.push(`${armed.id}:${error instanceof Error ? error.message : fallback}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tawait poll(GITHUB_PR_TERMINAL_KIND, parsePrConfig, async (config, armed) => {\n\t\t\tconst pr = await integration\n\t\t\t\t.client(config.profile)\n\t\t\t\t.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\tif (!pr.merged && pr.state !== \"closed\") return;\n\t\t\tif (!report.isCurrent(GITHUB_PR_TERMINAL_KIND, armed)) return;\n\t\t\tterminalInstances.add(armed.instanceId);\n\t\t\tconst outcome = pr.merged ? \"merged\" : \"closed\";\n\t\t\tif (config.terminalOutcome && config.terminalOutcome !== outcome) return;\n\t\t\tawait report.fire(armed, { pullRequest: pr }, `${pr.number}:${outcome}`);\n\t\t});\n\n\t\tawait poll(\n\t\t\tGITHUB_CHECKS_KIND,\n\t\t\t(value) => ({ pollInterval: \"30s\", config: asUnknownRecord(value) ?? {} }),\n\t\t\tasync ({ config }, armed) => {\n\t\t\t\tconst client = integration.client(String(config.profile));\n\t\t\t\tconst pr = await client.getPullRequest(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tNumber(config.prNumber),\n\t\t\t\t);\n\t\t\t\tif (pr.state !== \"open\" || pr.head.sha !== config.headSha) return;\n\t\t\t\tconst checks = await client.getCheckSummary(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tString(config.headSha),\n\t\t\t\t);\n\t\t\t\tif (checks.headSha !== config.headSha) return;\n\t\t\t\tconst refreshed = await client.getPullRequest(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tNumber(config.prNumber),\n\t\t\t\t);\n\t\t\t\tif (refreshed.state !== \"open\" || refreshed.merged || refreshed.head.sha !== checks.headSha)\n\t\t\t\t\treturn;\n\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\tobservation: {\n\t\t\t\t\t\t...describeGitHubEvent({ checks }),\n\t\t\t\t\t\tobservedAt: new Date(now()).toISOString(),\n\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${config.prNumber}`,\n\t\t\t\t\t\trevision: checks.headSha,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (checks.status !== \"failure\") return;\n\t\t\t\tconst evidenceKey = `${checks.headSha}:${checks.failed.map((run) => run.url).join(\":\")}`;\n\t\t\t\tif (config.afterKey === evidenceKey) return;\n\t\t\t\tawait report.fire(armed, { checks }, evidenceKey);\n\t\t\t},\n\t\t);\n\n\t\tawait poll(GITHUB_ISSUE_CANCELLED_KIND, parseIssueCancelledConfig, async (config, armed) => {\n\t\t\tconst issue = await integration\n\t\t\t\t.client(config.profile)\n\t\t\t\t.getIssue(config.owner, config.repo, config.issueNumber);\n\t\t\tconst reason =\n\t\t\t\tissue.state === \"closed\"\n\t\t\t\t\t? \"issue_closed\"\n\t\t\t\t\t: hasLabel(issue, config.triggerLabel)\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: \"trigger_label_removed\";\n\t\t\tif (!reason) return;\n\t\t\t// A merge may close the issue between terminal polls. Preserve terminal\n\t\t\t// reconciliation instead of treating that close as cancellation.\n\t\t\tconst terminal = terminalArmings\n\t\t\t\t.filter((candidate) => candidate.instanceId === armed.instanceId)\n\t\t\t\t.map((candidate) => parsePrConfig(candidate.resolved))\n\t\t\t\t.find((candidate) => candidate && !candidate.disabled);\n\t\t\tif (terminal) {\n\t\t\t\tconst pr = await integration\n\t\t\t\t\t.client(terminal.profile)\n\t\t\t\t\t.getPullRequest(terminal.owner, terminal.repo, terminal.prNumber);\n\t\t\t\tif (pr.merged || pr.state === \"closed\") {\n\t\t\t\t\tterminalInstances.add(armed.instanceId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait report.fire(armed, { issue, reason }, `${issue.number}:${reason}`);\n\t\t});\n\t\tawait poll(GITHUB_PR_FEEDBACK_KIND, parseFeedbackConfig, async (config, armed) => {\n\t\t\tconst client = integration.client(config.profile);\n\t\t\tconst pr = await client.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\tif (pr.merged || pr.state !== \"open\") return;\n\t\t\tconst unseen = (\n\t\t\t\tawait client.listActionablePullRequestFeedback(config.owner, config.repo, config.prNumber)\n\t\t\t).filter((item) => item.id > config[`${item.kind}Cursor`]);\n\n\t\t\tconst batch = repositoryFeedbackBatch(unseen, config, now());\n\t\t\tif (batch) await report.fire(armed, batch.event, batch.mergeKey);\n\t\t});\n\t}\n\n\treturn async (result: ReturnType<typeof emptyPollResult>) => {\n\t\tconst watchers = deps.processWatchers?.listBySource(githubIssueWatcherSource) ?? [];\n\t\tfor (const watcher of watchers) {\n\t\t\tif (\n\t\t\t\t!watcher.enabled ||\n\t\t\t\t!due(`${watcher.processId}:${watcher.watcherId}`, watcher.config.pollInterval)\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\ttry {\n\t\t\t\tawait discover(watcher, result);\n\t\t\t} catch (error) {\n\t\t\t\tresult.errors.push(\n\t\t\t\t\t`${watcher.processId}:${watcher.watcherId}:${error instanceof Error ? error.message : \"discovery_failed\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tawait pollExternal(result);\n\t};\n}\n","import {\n\tdefineProcessWatcherSource,\n\tparseRepositoryIssueWatcherConfig,\n\tpresentRepositoryIssueWatcherConfig,\n\ttype RepositoryIssueWatcherConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitHubIssue, GitHubRepository } from \"./client.js\";\n\n/** @public */\nexport interface GitHubIssueWatcherConfig extends RepositoryIssueWatcherConfig {}\n\n/** @public */\nexport interface GitHubIssueWatcherEvent {\n\t/** @public */\n\tauthorization: {\n\t\t/** @internal */\n\t\tactor: string;\n\t\t/** @internal */\n\t\teventId: number;\n\t};\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\trepository: GitHubRepository;\n\t/** @public */\n\tissue: GitHubIssue;\n\t/** @public */\n\tlabels: {\n\t\t/** @public */\n\t\ttrigger: string;\n\t\t/** @public */\n\t\tdone: string;\n\t};\n}\n\n/** @public */\nexport const githubIssueWatcherSource = defineProcessWatcherSource<\n\tGitHubIssueWatcherConfig,\n\tGitHubIssueWatcherEvent\n>({\n\tid: \"@leitwerk-public/github.issue\",\n\tlabel: \"GitHub issue\",\n\tparseConfig: (raw) => parseRepositoryIssueWatcherConfig(raw, \"github_issue\", true),\n\tpresentConfig: presentRepositoryIssueWatcherConfig,\n});\n","import {\n\tcreateExternalSourcePollReporter,\n\ttype ExternalSourceServiceLike,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n\tGITHUB_RELEASE_KIND,\n} from \"./external.js\";\n\nexport function githubPollReporter(\n\tsources: ExternalSourceServiceLike,\n\tresult: { created: string[]; errors: string[] },\n) {\n\treturn createExternalSourcePollReporter(sources, result, {\n\t\tforwardGeneration: true,\n\t\tcurrentKinds: [\n\t\t\tGITHUB_CHECKS_KIND,\n\t\t\tGITHUB_PR_STATE_KIND,\n\t\t\tGITHUB_PR_TERMINAL_KIND,\n\t\t\tGITHUB_PR_FEEDBACK_KIND,\n\t\t\tGITHUB_ISSUE_CANCELLED_KIND,\n\t\t\tGITHUB_RELEASE_KIND,\n\t\t],\n\t});\n}\n","import {\n\texistingObject,\n\ttype IntegrationToolExecutionContext,\n\tmatchesPatch,\n\tnumberArg,\n\tobjectArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitHubProjectBinding } from \"./binding.js\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport { assertGitHubRepository } from \"./client.js\";\n\nconst object = (value: unknown) => objectArg(value, \"Expected an object\");\n\nexport function registerGitHubTools(api: ServerExtensionAPI, integration: GitHubIntegration) {\n\tconst target = (ctx: IntegrationToolExecutionContext) => {\n\t\tconst binding = resolveGitHubProjectBinding(ctx);\n\t\tassertGitHubRepository(\n\t\t\tintegration.client(binding.profile).profile,\n\t\t\tbinding.owner,\n\t\t\tbinding.repo,\n\t\t);\n\t\treturn binding;\n\t};\n\tapi.tool({\n\t\tname: \"github_resolve_git_identity\",\n\t\tdescription: \"Resolve the configured GitHub Git identity\",\n\t\tparameters: projectParameters(),\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration.client(t.profile).resolveGitIdentity(t.profile);\n\t\t},\n\t});\n\tfor (const name of [\n\t\t\"github_ensure_label\",\n\t\t\"github_update_issue\",\n\t\t\"github_add_issue_comment\",\n\t\t\"github_add_pull_request_feedback_reaction\",\n\t\t\"github_reply_to_pull_request_feedback\",\n\t\t\"github_add_pull_request_comment\",\n\t\t\"github_update_pull_request\",\n\t] as const) {\n\t\tconst pullRequest =\n\t\t\tname === \"github_add_pull_request_comment\" || name === \"github_update_pull_request\";\n\t\tconst update = name === \"github_update_issue\" || name === \"github_update_pull_request\";\n\t\tapi.tool({\n\t\t\tname,\n\t\t\tdescription: pullRequest\n\t\t\t\t? update\n\t\t\t\t\t? \"Update a GitHub pull request\"\n\t\t\t\t\t: \"Comment on a GitHub pull request\"\n\t\t\t\t: \"Reconcile GitHub delivery in the current process project\",\n\t\t\tparameters: pullRequest\n\t\t\t\t? projectParameters(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\t\t\t...(update\n\t\t\t\t\t\t\t\t? { patch: { type: \"object\" } }\n\t\t\t\t\t\t\t\t: { body: { type: \"string\" }, writeKey: { type: \"string\" } }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[\"pullRequestNumber\", update ? \"patch\" : \"body\"],\n\t\t\t\t\t)\n\t\t\t\t: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tprojectKey: { type: \"string\" },\n\t\t\t\t\t\t\tissueNumber: { type: \"integer\" },\n\t\t\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\t\t\tname: { type: \"string\" },\n\t\t\t\t\t\t\tpatch: { type: \"object\" },\n\t\t\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\t\t\tfeedbackKind: { type: \"string\" },\n\t\t\t\t\t\t\tfeedbackId: { type: \"integer\" },\n\t\t\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"projectKey\"],\n\t\t\t\t\t},\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst input = object(args);\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\tconst key =\n\t\t\t\t\t!(pullRequest && update) && typeof input.writeKey === \"string\"\n\t\t\t\t\t\t? stringArg(input, \"writeKey\")\n\t\t\t\t\t\t: ctx.idempotencyKey;\n\t\t\t\tconst signal = pullRequest ? ctx.signal : undefined;\n\t\t\t\tconst marker = `<!-- leitwerk-write:${ctx.process.id}:${key} -->`;\n\t\t\t\tconst issueNumber = () =>\n\t\t\t\t\tnumberArg(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tpullRequest || input.issueNumber == null ? \"pullRequestNumber\" : \"issueNumber\",\n\t\t\t\t\t);\n\t\t\t\tconst findComment = async () => {\n\t\t\t\t\tconst replies =\n\t\t\t\t\t\tname === \"github_reply_to_pull_request_feedback\"\n\t\t\t\t\t\t\t? await client.listFeedbackReplies(\n\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await client.listIssueComments(t.owner, t.repo, issueNumber(), signal);\n\t\t\t\t\treturn (\n\t\t\t\t\t\treplies.find(\n\t\t\t\t\t\t\t(comment) =>\n\t\t\t\t\t\t\t\tString(comment.body).includes(marker) &&\n\t\t\t\t\t\t\t\t(name !== \"github_reply_to_pull_request_feedback\" ||\n\t\t\t\t\t\t\t\t\tinput.feedbackKind !== \"inline\" ||\n\t\t\t\t\t\t\t\t\tobject(comment).in_reply_to_id === numberArg(input, \"feedbackId\")),\n\t\t\t\t\t\t) ?? null\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst result = await ctx.externalWrites.ensure(\n\t\t\t\t\t{\n\t\t\t\t\t\twriteType: pullRequest ? (update ? \"github.update_pr\" : \"github.comment\") : name,\n\t\t\t\t\t\tdedupKey: key,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async (phase): Promise<object | null> =>\n\t\t\t\t\t\t\texistingObject(async () => {\n\t\t\t\t\t\t\t\tif (name === \"github_ensure_label\")\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t(await client.listLabels(t.owner, t.repo)).find(\n\t\t\t\t\t\t\t\t\t\t\t(label) => label.name === stringArg(input, \"name\"),\n\t\t\t\t\t\t\t\t\t\t) ?? null\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t\tconst current = await client[pullRequest ? \"getPullRequest\" : \"getIssue\"](\n\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn current &&\n\t\t\t\t\t\t\t\t\t\t(phase === \"already_recorded\" || matchesPatch(current, object(input.patch)))\n\t\t\t\t\t\t\t\t\t\t? current\n\t\t\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (name === \"github_add_pull_request_feedback_reaction\")\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tawait client.listFeedbackReactions(\n\t\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t).find(\n\t\t\t\t\t\t\t\t\t\t\t(reaction) =>\n\t\t\t\t\t\t\t\t\t\t\t\treaction.content === \"eyes\" &&\n\t\t\t\t\t\t\t\t\t\t\t\treaction.user.login.toLowerCase() === client.profile.botLogin.toLowerCase(),\n\t\t\t\t\t\t\t\t\t\t) ?? null\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn findComment();\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\texecute: async (): Promise<object> => {\n\t\t\t\t\t\t\tif (name === \"github_ensure_label\")\n\t\t\t\t\t\t\t\treturn client.createLabel(t.owner, t.repo, stringArg(input, \"name\"));\n\t\t\t\t\t\t\tif (update)\n\t\t\t\t\t\t\t\treturn pullRequest\n\t\t\t\t\t\t\t\t\t? object(\n\t\t\t\t\t\t\t\t\t\t\tawait client.updatePullRequest(\n\t\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\t\t\tobject(input.patch),\n\t\t\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: client.updateIssue(t.owner, t.repo, issueNumber(), object(input.patch));\n\t\t\t\t\t\t\tif (name === \"github_add_pull_request_feedback_reaction\")\n\t\t\t\t\t\t\t\treturn object(\n\t\t\t\t\t\t\t\t\tawait client.addFeedbackReaction(\n\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst body = `${stringArg(input, \"body\")}\\n\\n${marker}`;\n\t\t\t\t\t\t\treturn object(\n\t\t\t\t\t\t\t\tawait (name === \"github_add_issue_comment\" || pullRequest\n\t\t\t\t\t\t\t\t\t? client.addIssueComment(t.owner, t.repo, issueNumber(), body, signal)\n\t\t\t\t\t\t\t\t\t: client.replyFeedback(\n\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\t\t\t\t)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoMetadata: (value) =>\n\t\t\t\t\t\t\tpullRequest\n\t\t\t\t\t\t\t\t? { owner: t.owner, repo: t.repo, pullRequestNumber: issueNumber() }\n\t\t\t\t\t\t\t\t: { value },\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (name === \"github_ensure_label\") return { name: stringArg(input, \"name\") };\n\t\t\t\treturn result;\n\t\t\t},\n\t\t});\n\t}\n\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_ensure_pull_request\",\n\t\tdescription: \"Create a GitHub pull request unless the branch pair already has one\",\n\t\tparameters: projectParameters({\n\t\t\ttitle: { type: \"string\" },\n\t\t\tbody: { type: \"string\" },\n\t\t\thead: { type: \"string\" },\n\t\t\tbase: { type: \"string\" },\n\t\t}),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst head = stringArg(input, \"head\");\n\t\t\tconst base = stringArg(input, \"base\");\n\t\t\tif (head !== ctx.project?.workBranch || base !== ctx.project?.baseBranch)\n\t\t\t\tthrow new Error(\"Pull request branches must match the process project\");\n\t\t\tconst find = async () =>\n\t\t\t\t(await client.listPullRequests(t.owner, t.repo, \"all\")).find(\n\t\t\t\t\t(candidate) => candidate.head.ref === head && candidate.base.ref === base,\n\t\t\t\t) ?? null;\n\t\t\treturn ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"github.ensure_pr\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: () => existingObject(find),\n\t\t\t\t\texecute: () =>\n\t\t\t\t\t\tclient.createPullRequest(t.owner, t.repo, {\n\t\t\t\t\t\t\ttitle: stringArg(input, \"title\"),\n\t\t\t\t\t\t\tbody: stringArg(input, \"body\"),\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\tbase,\n\t\t\t\t\t\t}),\n\t\t\t\t\ttoMetadata: (pr) => ({ number: pr.number, url: pr.html_url }),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t});\n\tfor (const [name, description, numberName, method] of [\n\t\t[\n\t\t\t\"github_get_issue\",\n\t\t\t\"Read a GitHub issue in the current process project\",\n\t\t\t\"issueNumber\",\n\t\t\t\"getIssue\",\n\t\t],\n\t\t[\n\t\t\t\"github_get_pull_request\",\n\t\t\t\"Read a GitHub pull request in the current process project\",\n\t\t\t\"pullRequestNumber\",\n\t\t\t\"getPullRequest\",\n\t\t],\n\t\t[\n\t\t\t\"github_list_pull_request_feedback\",\n\t\t\t\"Read GitHub pull request conversation, reviews, and inline comments\",\n\t\t\t\"pullRequestNumber\",\n\t\t\t\"listActionablePullRequestFeedback\",\n\t\t],\n\t] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tparameters: projectParameters({ [numberName]: { type: \"integer\" } }),\n\t\t\tasync execute(ctx, input) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\treturn integration\n\t\t\t\t\t.client(t.profile)\n\t\t\t\t\t[method](t.owner, t.repo, numberArg(input, numberName), ctx.signal);\n\t\t\t},\n\t\t});\n\t}\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_get_ci_diagnostics\",\n\t\tdescription:\n\t\t\t\"Read failed check annotations and bounded Actions logs for the current request revision\",\n\t\tparameters: projectParameters(\n\t\t\t{ pullRequestNumber: { type: \"integer\" }, headSha: { type: \"string\" } },\n\t\t\t[\"pullRequestNumber\", \"headSha\"],\n\t\t),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst number = numberArg(input, \"pullRequestNumber\");\n\t\t\tconst pr = await client.getPullRequest(t.owner, t.repo, number, ctx.signal);\n\t\t\tif (pr.head.ref !== ctx.project?.workBranch || pr.base.ref !== ctx.project.baseBranch)\n\t\t\t\tthrow new Error(\"Pull request does not belong to the process branches\");\n\t\t\treturn client.getCiDiagnostics(\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tnumber,\n\t\t\t\tstringArg(input, \"headSha\"),\n\t\t\t\tctx.signal,\n\t\t\t);\n\t\t},\n\t});\n\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_get_checks\",\n\t\tdescription: \"Read GitHub Actions check runs for a commit\",\n\t\tparameters: projectParameters({ headSha: { type: \"string\" } }),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration\n\t\t\t\t.client(t.profile)\n\t\t\t\t.getCheckSummary(t.owner, t.repo, stringArg(input, \"headSha\"));\n\t\t},\n\t});\n}\n","import { resolveRepositoryProjectBinding } from \"@leitwerk-dev/process-sdk\";\n\nexport type { RepositoryProjectBinding as GitHubProjectBinding } from \"@leitwerk-dev/process-sdk\";\n/** @public */\nexport const resolveGitHubProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"github\");\n"],"mappings":";;;;;;;AAAA,SAAS,4BAA0D;;;ACAnE,SAAS,6BAA6B;AAe/B,IAAM,oBAAoB;AAAA,EAChC;AACD;;;ACjBA,SAAS,kBAAkB,8B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;AAAA,EACA,YAAY,KAAK,QAAQ;AACxB,UAAM,WAAW,oBAAoB,MAAM;AAC3C,UAAM,cAAiC;AAAA,MACtC,UAAU,MAAM,CAAC,GAAG,SAAS,KAAK,CAAC;AAAA,MACnC,OAAO,SAAS;AACf,cAAM,QAAQ,SAAS,IAAI,OAAO;AAClC,YAAI,CAAC,MAAO,OAAM,IAAI,MAAM,2BAA2B,OAAO,GAAG;AACjE,eAAO,IAAI,aAAa,KAAK;AAAA,MAC9B;AAAA,IACD;AACA,2BAAuB,KAAK,WAAW;AAAA,EACxC;AACD;AAEA,IAAO,gBAAQ;AAGR,SAAS,uBACf,KACA,aACA,UAGI,CAAC,GACJ;AACD,MAAI,QAAQ,mBAAmB,WAAW;AAC1C,QAAM,OAAO,IAAI,IAAI,qBAAqB,WAAW;AACrD,MAAI,CAAC,QAAQ,MAAM,QAAQ,IAAI,EAAG;AAClC,sBAAoB,KAAK,WAAW;AACpC,SAAO,qBAAqB,MAAM,aAAa,OAAO;AACvD;","names":["asUnknownRecord","createPollSchedule","parse","asUnknownRecord","value","createPollSchedule"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/capability.ts","../src/provider.ts","../src/external.ts","../src/issue-provider.ts","../src/issue-watcher.ts","../src/poll-report.ts","../src/ticket-creation.ts","../src/tools.ts","../src/binding.ts"],"sourcesContent":["import {\n\tcoreHostCapabilities,\n\ttype LeitwerkExtensionModule,\n\tparseTicketCreationConfig,\n\trepositorySettingsIdentity,\n\tscopedSettingsCapability,\n\ttype TicketCreationConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport { type GitHubIntegration, githubIntegration } from \"./capability.js\";\nimport { GitHubClient, parseGitHubProfiles } from \"./client.js\";\nimport { createGitHubProvider } from \"./provider.js\";\nimport { registerGitHubTicketCreation } from \"./ticket-creation.js\";\nimport { registerGitHubTools } from \"./tools.js\";\n\n/** @internal */\nconst manifest = {\n\tid: \"github\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n} as const;\n\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseGitHubProfiles(config);\n\t\tconst settings = api.get(scopedSettingsCapability);\n\t\tif (settings && !Array.isArray(settings))\n\t\t\tsettings.registerDiscovery(\"repository\", async () => {\n\t\t\t\tconst subjects = [];\n\t\t\t\tfor (const profile of profiles.values()) {\n\t\t\t\t\tfor (const repo of await new GitHubClient(profile).listRepositories()) {\n\t\t\t\t\t\tif (repo.id === undefined) continue;\n\t\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\t\tscopeType: \"repository\",\n\t\t\t\t\t\t\tidentity: repositorySettingsIdentity(repo.html_url, repo.id),\n\t\t\t\t\t\t\tlabel: repo.full_name,\n\t\t\t\t\t\t\taliases: [repo.ssh_url, ...(repo.clone_url ? [repo.clone_url] : [])],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn subjects;\n\t\t\t});\n\t\tconst integration: GitHubIntegration = {\n\t\t\tprofiles: () => [...profiles.keys()],\n\t\t\tclient(profile) {\n\t\t\t\tconst value = profiles.get(profile);\n\t\t\t\tif (!value) throw new Error(`Unknown GitHub profile '${profile}'`);\n\t\t\t\treturn new GitHubClient(value);\n\t\t\t},\n\t\t};\n\t\tsetupGitHubIntegration(api, integration, {\n\t\t\tticketCreation: parseTicketCreationConfig(config, \"GitHub\"),\n\t\t});\n\t},\n};\n\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. @public */\nexport function setupGitHubIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: GitHubIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tticketCreation?: TicketCreationConfig;\n\t} = {},\n) {\n\tapi.provide(githubIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterGitHubTools(api, integration);\n\tregisterGitHubTicketCreation(\n\t\tapi,\n\t\tintegration,\n\t\toptions.ticketCreation ?? { enabled: false, defaultLabels: [] },\n\t);\n\treturn createGitHubProvider(deps, integration, options);\n}\n\nexport { resolveGitHubProjectBinding } from \"./binding.js\";\nexport type { GitHubIntegration } from \"./capability.js\";\nexport { githubIntegration } from \"./capability.js\";\nexport type {\n\tGitHubCheckSummary,\n\tGitHubGitIdentity,\n\tGitHubIssue,\n\tGitHubPullRequest,\n\tGitHubRepository,\n} from \"./client.js\";\nexport {\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n\tgithubExternal,\n} from \"./external.js\";\nexport { githubIssueWatcherSource } from \"./issue-watcher.js\";\n","import { createCapabilityToken } from \"@leitwerk-dev/process-sdk\";\nimport type { GitHubClient } from \"./client.js\";\n\n/** Public contract shared by HTTP and local adapters. @public */\nexport type GitHubClientLike = Pick<GitHubClient, keyof GitHubClient>;\n\n/** @public */\nexport interface GitHubIntegration {\n\t/** @public */\n\tprofiles?(): readonly string[];\n\t/** @public */\n\tclient(profile: string): GitHubClientLike;\n}\n\n/** @public */\nexport const githubIntegration = createCapabilityToken<GitHubIntegration>(\n\t\"@leitwerk-private/github.integration\",\n);\n","import { conflictEvidence, createConflictReporter } from \"@leitwerk-dev/coding/repository-rebase\";\nimport { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport type { CoreServerSetupDeps } from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport {\n\tdescribeGitHubEvent,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_RELEASE_KIND,\n\ttype GitHubPullRequestSourceConfig,\n} from \"./external.js\";\nimport { createGitHubIssuePolling } from \"./issue-provider.js\";\nimport { githubPollReporter } from \"./poll-report.js\";\n\nfunction parse(value: unknown): GitHubPullRequestSourceConfig | null {\n\tconst config = asUnknownRecord(value) ?? {};\n\tif (\n\t\t[\"profile\", \"owner\", \"repo\", \"headSha\"].some(\n\t\t\t(key) => typeof config[key] !== \"string\" || !(config[key] as string).trim(),\n\t\t) ||\n\t\ttypeof config.prNumber !== \"number\"\n\t)\n\t\treturn null;\n\treturn {\n\t\tprofile: config.profile as string,\n\t\towner: config.owner as string,\n\t\trepo: config.repo as string,\n\t\tprNumber: config.prNumber,\n\t\theadSha: config.headSha as string,\n\t\tlastConflictKey: typeof config.lastConflictKey === \"string\" ? config.lastConflictKey : null,\n\t\tfeedbackCursor: typeof config.feedbackCursor === \"number\" ? config.feedbackCursor : 0,\n\t\tpollInterval: typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\",\n\t\tdisabled: config.disabled === true,\n\t\teventKinds: Array.isArray(config.eventKinds)\n\t\t\t? config.eventKinds.filter(\n\t\t\t\t\t(value): value is \"checks\" | \"feedback\" | \"merged\" | \"closed\" | \"merge_conflict\" =>\n\t\t\t\t\t\t[\"checks\", \"feedback\", \"merged\", \"closed\", \"merge_conflict\"].includes(String(value)),\n\t\t\t\t)\n\t\t\t: undefined,\n\t\tcheckStatuses: Array.isArray(config.checkStatuses)\n\t\t\t? config.checkStatuses.filter((value): value is \"pending\" | \"success\" | \"failure\" =>\n\t\t\t\t\t[\"pending\", \"success\", \"failure\"].includes(String(value)),\n\t\t\t\t)\n\t\t\t: undefined,\n\t};\n}\n\nexport function createGitHubProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitHubIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst due = createPollSchedule();\n\tconst pollIssues = createGitHubIssuePolling(deps, integration, options);\n\tconst reportConflict = createConflictReporter(GITHUB_PR_STATE_KIND);\n\treturn deps.polling.create({\n\t\tid: \"github\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5_000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tconst report = githubPollReporter(deps.externalSources, result);\n\t\t\tawait pollIssues(result);\n\t\t\tawait report.poll(GITHUB_PR_STATE_KIND, async (armed) => {\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tif (!config) {\n\t\t\t\t\tresult.errors.push(`${armed.id}:invalid_config`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (config.disabled) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tconst now = options.now?.() ?? Date.now();\n\t\t\t\tif (!due(key, config.pollInterval, now)) return;\n\t\t\t\ttry {\n\t\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\t\tconst pr = await client.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\t\t\tif (!config.eventKinds || config.eventKinds.includes(\"merge_conflict\")) {\n\t\t\t\t\t\tconst conflict = conflictEvidence(config, pr, \"github\");\n\t\t\t\t\t\t// GitHub's PR base SHA can lag the branch even while its state is behind.\n\t\t\t\t\t\tif (conflict?.reason === \"behind\") {\n\t\t\t\t\t\t\tconst branch = await client.getCommit(config.owner, config.repo, conflict.baseBranch);\n\t\t\t\t\t\t\tconflict.baseSha = branch.sha;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tawait reportConflict(report, armed, conflict, config.lastConflictKey, {\n\t\t\t\t\t\t\t\tsummary: `PR #${pr.number} mergeability: ${pr.mergeable == null ? \"unresolved\" : (pr.mergeable_state ?? String(pr.mergeable))}`,\n\t\t\t\t\t\t\t\tobservedAt: new Date(now).toISOString(),\n\t\t\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${pr.number}`,\n\t\t\t\t\t\t\t\trevision: `${pr.head.sha}:${conflict?.baseSha ?? pr.base.sha}`,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (config.eventKinds?.length === 1) return;\n\t\t\t\t\t}\n\t\t\t\t\tlet event: Record<string, unknown> | null = null;\n\t\t\t\t\tlet mergeKey = \"\";\n\t\t\t\t\tif (pr.merged || pr.state === \"closed\") {\n\t\t\t\t\t\tevent = {\n\t\t\t\t\t\t\tkind: pr.merged ? \"merged\" : \"closed\",\n\t\t\t\t\t\t\tpullRequest: pr,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tmergeKey = `terminal:${pr.number}:${pr.merged}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (pr.head.sha !== config.headSha) return;\n\t\t\t\t\t\tconst readsFeedback = !config.eventKinds || config.eventKinds.includes(\"feedback\");\n\t\t\t\t\t\tconst readsChecks = !config.eventKinds || config.eventKinds.includes(\"checks\");\n\t\t\t\t\t\tconst [feedback, checks] = await Promise.all([\n\t\t\t\t\t\t\treadsFeedback\n\t\t\t\t\t\t\t\t? client.listActionablePullRequestFeedback(\n\t\t\t\t\t\t\t\t\t\tconfig.owner,\n\t\t\t\t\t\t\t\t\t\tconfig.repo,\n\t\t\t\t\t\t\t\t\t\tconfig.prNumber,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t: Promise.resolve([]),\n\t\t\t\t\t\t\treadsChecks || (deps.externalSources.observe && armed.generation)\n\t\t\t\t\t\t\t\t? client\n\t\t\t\t\t\t\t\t\t\t.getCheckSummary(config.owner, config.repo, config.headSha)\n\t\t\t\t\t\t\t\t\t\t.catch(async (error) => {\n\t\t\t\t\t\t\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\t\t\t\t\t\t\trefreshError:\n\t\t\t\t\t\t\t\t\t\t\t\t\terror instanceof Error ? error.message : \"Checks refresh failed\",\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\tif (readsChecks) throw error;\n\t\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: Promise.resolve(null),\n\t\t\t\t\t\t]);\n\t\t\t\t\t\tif (checks && checks.headSha !== config.headSha) return;\n\t\t\t\t\t\tconst refreshed = await client.getPullRequest(\n\t\t\t\t\t\t\tconfig.owner,\n\t\t\t\t\t\t\tconfig.repo,\n\t\t\t\t\t\t\tconfig.prNumber,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trefreshed.state !== \"open\" ||\n\t\t\t\t\t\t\trefreshed.merged ||\n\t\t\t\t\t\t\trefreshed.head.sha !== config.headSha\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\tif (checks && deps.externalSources.observe && armed.generation) {\n\t\t\t\t\t\t\tconst description = describeGitHubEvent({ kind: \"checks\", checks });\n\t\t\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\t\t\tobservation: {\n\t\t\t\t\t\t\t\t\t...description,\n\t\t\t\t\t\t\t\t\tobservedAt: new Date(now).toISOString(),\n\t\t\t\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${config.prNumber}`,\n\t\t\t\t\t\t\t\t\trevision: checks.headSha,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst unseen = feedback.filter(\n\t\t\t\t\t\t\t(item) => item.id > config.feedbackCursor && item.author !== client.profile.botLogin,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (unseen.length) {\n\t\t\t\t\t\t\tconst feedbackCursor = Math.max(...unseen.map((item) => item.id));\n\t\t\t\t\t\t\tevent = { kind: \"feedback\", feedback, feedbackCursor };\n\t\t\t\t\t\t\tmergeKey = `feedback:${feedbackCursor}`;\n\t\t\t\t\t\t} else if (readsChecks && checks && checks.status !== \"pending\") {\n\t\t\t\t\t\t\tevent = { kind: \"checks\", checks };\n\t\t\t\t\t\t\tmergeKey = `checks:${checks.headSha}:${checks.status}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\t!event ||\n\t\t\t\t\t\t(config.eventKinds &&\n\t\t\t\t\t\t\t!config.eventKinds.includes(\n\t\t\t\t\t\t\t\tString(event.kind) as (typeof config.eventKinds)[number],\n\t\t\t\t\t\t\t)) ||\n\t\t\t\t\t\t(event.kind === \"checks\" &&\n\t\t\t\t\t\t\tconfig.checkStatuses &&\n\t\t\t\t\t\t\t!config.checkStatuses.includes(\n\t\t\t\t\t\t\t\t(event.checks as { status: \"pending\" | \"success\" | \"failure\" }).status,\n\t\t\t\t\t\t\t))\n\t\t\t\t\t)\n\t\t\t\t\t\treturn;\n\t\t\t\t\tawait report.fire(armed, event, mergeKey);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\trefreshError: error instanceof Error ? error.message : \"PR refresh failed\",\n\t\t\t\t\t});\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t});\n\t\t\tawait report.poll(GITHUB_RELEASE_KIND, async (armed) => {\n\t\t\t\tconst config = asUnknownRecord(armed.resolved) ?? {};\n\t\t\t\tif (\n\t\t\t\t\ttypeof config.profile !== \"string\" ||\n\t\t\t\t\ttypeof config.owner !== \"string\" ||\n\t\t\t\t\ttypeof config.repo !== \"string\" ||\n\t\t\t\t\ttypeof config.mergeSha !== \"string\"\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tif (config.disabled === true) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tconst now = options.now?.() ?? Date.now();\n\t\t\t\tif (!due(key, typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\", now))\n\t\t\t\t\treturn;\n\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\tfor (const release of await client.listReleases(config.owner, config.repo)) {\n\t\t\t\t\tif (release.draft || release.prerelease) continue;\n\t\t\t\t\tconst commit = await client.getCommit(config.owner, config.repo, release.tag_name);\n\t\t\t\t\tif (!(await client.isAncestor(config.owner, config.repo, config.mergeSha, commit.sha)))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t{ release, commitSha: commit.sha },\n\t\t\t\t\t\t`${release.id}:${commit.sha}`,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n","import { describeConflict } from \"@leitwerk-dev/coding/repository-rebase\";\nimport {\n\tdefineExternalActionSource,\n\ttype ExternalEventDescription,\n\ttype RepositoryFeedbackSourceConfig,\n\ttype RepositoryIssueCancelledSourceConfig,\n\ttype RepositoryPullRequestSourceConfig,\n} from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport const GITHUB_PR_STATE_KIND = \"@leitwerk-private/github.pr_state\";\n\n/** @public */\nexport interface GitHubPullRequestSourceConfig\n\textends Omit<GitHubPullRequestTerminalSourceConfig, \"terminalOutcome\" | \"disabled\"> {\n\t/** @public */\n\theadSha: string;\n\t/** @public */\n\tfeedbackCursor: number;\n\t/** @public */\n\tlastConflictKey?: string | null;\n\t/** @internal */\n\tdisabled?: boolean;\n\t/** @public */\n\teventKinds?: Array<\"checks\" | \"feedback\" | \"merged\" | \"closed\" | \"merge_conflict\">;\n\t/** @internal */\n\tcheckStatuses?: Array<\"pending\" | \"success\" | \"failure\">;\n}\n\n/** @internal */\nexport const GITHUB_RELEASE_KIND = \"@leitwerk-private/github.release\";\n\n/** @internal */\nexport interface GitHubReleaseSourceConfig {\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\towner: string;\n\t/** @internal */\n\trepo: string;\n\t/** @internal */\n\tmergeSha: string;\n\t/** @internal */\n\tpollInterval?: string;\n\t/** @internal */\n\tdisabled?: boolean;\n}\n\n/** @internal */\nexport function describeGitHubEvent(event: unknown): ExternalEventDescription {\n\tconst value = event as {\n\t\tkind?: string;\n\t\tchecks?: {\n\t\t\theadSha: string;\n\t\t\tstatus: string;\n\t\t\tfailed: Array<{ name: string; url: string | null }>;\n\t\t};\n\t\tpullRequest?: { number: number; merged?: boolean; state?: string };\n\t};\n\tif (value.kind === \"merge_conflict\") return describeConflict(event);\n\tif (value.checks) {\n\t\tconst checks = value.checks;\n\t\treturn {\n\t\t\tsummary: `Checks ${checks.status} on ${checks.headSha}${checks.failed.length ? `: ${checks.failed.map((check) => check.name).join(\", \")}` : \"\"}`,\n\t\t\tlinks: checks.failed.flatMap((check, index) =>\n\t\t\t\tcheck.url\n\t\t\t\t\t? [{ id: `check-${index}`, label: check.name, url: check.url, kind: \"pipeline\" as const }]\n\t\t\t\t\t: [],\n\t\t\t),\n\t\t};\n\t}\n\treturn {\n\t\tsummary:\n\t\t\tvalue.kind === \"merged\" || value.kind === \"closed\" || value.pullRequest\n\t\t\t\t? `PR #${value.pullRequest?.number} ${value.kind ?? (value.pullRequest?.merged ? \"merged\" : \"closed\")}`\n\t\t\t\t: value.kind === \"feedback\"\n\t\t\t\t\t? \"Pull request feedback received\"\n\t\t\t\t\t: \"GitHub event received\",\n\t};\n}\n\n/** @public */\nexport const GITHUB_PR_TERMINAL_KIND = \"@leitwerk-public/github.pr_terminal\";\n/** @public */\nexport const GITHUB_PR_FEEDBACK_KIND = \"@leitwerk-public/github.pr_feedback\";\n/** @public */\nexport const GITHUB_ISSUE_CANCELLED_KIND = \"@leitwerk-public/github.issue_cancelled\";\n\n/** @public */\nexport interface GitHubPullRequestTerminalSourceConfig\n\textends Pick<RepositoryPullRequestSourceConfig, \"profile\" | \"owner\" | \"repo\" | \"prNumber\">,\n\t\tPartial<\n\t\t\tPick<RepositoryPullRequestSourceConfig, \"pollInterval\" | \"terminalOutcome\" | \"disabled\">\n\t\t> {}\n\n/** @public */\nexport interface GitHubFeedbackSourceConfig\n\textends GitHubPullRequestTerminalSourceConfig,\n\t\tOmit<RepositoryFeedbackSourceConfig, keyof RepositoryPullRequestSourceConfig> {}\n\n/** @public */\nexport interface GitHubIssueCancelledSourceConfig\n\textends Omit<RepositoryIssueCancelledSourceConfig, \"pollInterval\">,\n\t\tPartial<Pick<RepositoryIssueCancelledSourceConfig, \"pollInterval\">> {}\n\n/** @public */\nexport const GITHUB_CHECKS_KIND = \"@leitwerk-public/github.checks\";\n\n/** @public */\nexport const githubExternal = {\n\t/** @public */\n\tchecks: defineExternalActionSource<{\n\t\tafterKey?: string;\n\t\tprofile: string;\n\t\towner: string;\n\t\trepo: string;\n\t\tprNumber: number;\n\t\theadSha: string;\n\t}>({\n\t\tkind: GITHUB_CHECKS_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub Actions failures\",\n\t}),\n\t/** @public */\n\tissueCancelled: defineExternalActionSource<GitHubIssueCancelledSourceConfig>({\n\t\tkind: GITHUB_ISSUE_CANCELLED_KIND,\n\t\tdescribeEvent: () => ({ summary: \"Source issue cancelled\" }),\n\t\tlabel: \"GitHub source issue cancelled\",\n\t\tdescription: \"Fires when the source issue closes or loses its trigger label\",\n\t}),\n\t/** @public */\n\tpullRequestTerminal: defineExternalActionSource<GitHubPullRequestTerminalSourceConfig>({\n\t\tkind: GITHUB_PR_TERMINAL_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub pull request merged or closed\",\n\t\tdescription: \"Fires when the tracked pull request reaches a terminal state\",\n\t}),\n\t/** @public */\n\tpullRequestFeedback: defineExternalActionSource<GitHubFeedbackSourceConfig>({\n\t\tkind: GITHUB_PR_FEEDBACK_KIND,\n\t\tdescribeEvent: () => ({ summary: \"Pull request feedback received\" }),\n\t\tlabel: \"GitHub pull request feedback\",\n\t\tdescription: \"Fires after unseen human feedback has been quiet long enough to batch\",\n\t}),\n\t/** @internal */\n\treleaseContaining: defineExternalActionSource<GitHubReleaseSourceConfig>({\n\t\tkind: GITHUB_RELEASE_KIND,\n\t\tlabel: \"Published GitHub release\",\n\t\tdescription: \"Fires when a published release contains the tracked merge commit\",\n\t}),\n\t/** @public */\n\tpullRequestState: defineExternalActionSource<GitHubPullRequestSourceConfig>({\n\t\tkind: GITHUB_PR_STATE_KIND,\n\t\tdescribeEvent: describeGitHubEvent,\n\t\tlabel: \"GitHub pull request state\",\n\t\tdescription: \"Fires for failed or successful checks, review feedback, and terminal PR state\",\n\t}),\n};\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\ttype ExternalSourceArmingLike,\n\tmatchesRepository as matchesConfiguredRepository,\n\tparseRepositoryFeedbackConfig as parseFeedbackConfig,\n\tparseRepositoryIssueCancelledConfig as parseIssueCancelledConfig,\n\tparseRepositoryPullRequestConfig as parsePrConfig,\n\ttype RegisteredProcessWatcherLike,\n\trepositoryFeedbackBatch,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, type emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport type { GitHubIssue, GitHubRepository } from \"./client.js\";\nimport {\n\tdescribeGitHubEvent,\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n} from \"./external.js\";\nimport {\n\ttype GitHubIssueWatcherConfig,\n\ttype GitHubIssueWatcherEvent,\n\tgithubIssueWatcherSource,\n} from \"./issue-watcher.js\";\nimport { githubPollReporter } from \"./poll-report.js\";\n\nfunction hasLabel(issue: GitHubIssue, label: string): boolean {\n\treturn issue.labels.some((candidate) => candidate.name === label);\n}\n\nfunction externalId(repo: GitHubRepository, issue: GitHubIssue): string {\n\treturn `github:${repo.full_name}#${issue.number}`;\n}\n\nexport { matchesConfiguredRepository };\n\nexport function createGitHubIssuePolling(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitHubIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst now = options.now ?? Date.now;\n\tconst due = createPollSchedule(now);\n\n\tasync function discover(\n\t\twatcher: RegisteredProcessWatcherLike<GitHubIssueWatcherConfig, GitHubIssueWatcherEvent>,\n\t\tresult: ReturnType<typeof emptyPollResult>,\n\t) {\n\t\tconst config = watcher.config;\n\t\tconst client = integration.client(config.profile);\n\t\tfor (const repo of await client.listRepositories()) {\n\t\t\tif (!matchesConfiguredRepository(config, repo)) continue;\n\t\t\tfor (const issue of await client.listOpenIssues(repo.owner.login, repo.name)) {\n\t\t\t\tif (!hasLabel(issue, config.labels.trigger) || hasLabel(issue, config.labels.done))\n\t\t\t\t\tcontinue;\n\t\t\t\tconst id = externalId(repo, issue);\n\t\t\t\ttry {\n\t\t\t\t\tif (deps.processes.listAll().some((process) => process.externalId === id)) {\n\t\t\t\t\t\tresult.skipped.push(id);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst authorized = await client.authorizedTrigger(\n\t\t\t\t\t\trepo.owner.login,\n\t\t\t\t\t\trepo.name,\n\t\t\t\t\t\tissue.number,\n\t\t\t\t\t\tconfig.labels.trigger,\n\t\t\t\t\t\tconfig.labels.done,\n\t\t\t\t\t);\n\t\t\t\t\tif (!authorized) {\n\t\t\t\t\t\tresult.skipped.push(`${id}:unauthorized`);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst event: GitHubIssueWatcherEvent = {\n\t\t\t\t\t\tprofile: config.profile,\n\t\t\t\t\t\trepository: repo,\n\t\t\t\t\t\tissue: authorized.issue,\n\t\t\t\t\t\tauthorization: {\n\t\t\t\t\t\t\tactor: authorized.actor,\n\t\t\t\t\t\t\teventId: authorized.eventId,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlabels: config.labels,\n\t\t\t\t\t};\n\n\t\t\t\t\tconst guardedWatcher = {\n\t\t\t\t\t\t...watcher,\n\t\t\t\t\t\tasync resolveLaunchAttempt(...args: Parameters<typeof watcher.resolveLaunchAttempt>) {\n\t\t\t\t\t\t\tconst attempt = await watcher.resolveLaunchAttempt(...args);\n\t\t\t\t\t\t\tif (!attempt) return null;\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t...attempt,\n\t\t\t\t\t\t\t\tpreparationChecks: [\n\t\t\t\t\t\t\t\t\t...attempt.preparationChecks,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"github-trigger-authorization\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Check GitHub trigger authorization\",\n\t\t\t\t\t\t\t\t\t\tasync run() {\n\t\t\t\t\t\t\t\t\t\t\tconst rechecked = await client.authorizedTrigger(\n\t\t\t\t\t\t\t\t\t\t\t\trepo.owner.login,\n\t\t\t\t\t\t\t\t\t\t\t\trepo.name,\n\t\t\t\t\t\t\t\t\t\t\t\tissue.number,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig.labels.trigger,\n\t\t\t\t\t\t\t\t\t\t\t\tconfig.labels.done,\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t!rechecked ||\n\t\t\t\t\t\t\t\t\t\t\t\trechecked.eventId !== authorized.eventId ||\n\t\t\t\t\t\t\t\t\t\t\t\trechecked.actor !== authorized.actor\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\tthrow new Error(\"GitHub trigger authorization changed before launch\");\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst launched = await deps.launchRuns.startWatcher(guardedWatcher, event, {\n\t\t\t\t\t\tidempotencyKey: id,\n\t\t\t\t\t});\n\t\t\t\t\tif (launched.error) result.errors.push(`${id}:launch_failed:${launched.error}`);\n\t\t\t\t\telse if (launched.process) result.created.push(id);\n\t\t\t\t\telse result.skipped.push(id);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresult.errors.push(\n\t\t\t\t\t\t`${id}:${error instanceof Error ? error.message : \"discovery_failed\"}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tasync function pollExternal(result: ReturnType<typeof emptyPollResult>) {\n\t\tconst report = githubPollReporter(deps.externalSources, result);\n\t\tconst terminalArmings = deps.externalSources.listArmed(GITHUB_PR_TERMINAL_KIND);\n\t\tconst terminalInstances = new Set<string>();\n\t\tasync function poll<C extends { pollInterval?: string; disabled?: boolean }>(\n\t\t\tkind: string,\n\t\t\tparse: (value: unknown) => C | null,\n\t\t\tread: (config: C, armed: ExternalSourceArmingLike) => Promise<void>,\n\t\t) {\n\t\t\tconst armings =\n\t\t\t\tkind === GITHUB_PR_TERMINAL_KIND ? terminalArmings : deps.externalSources.listArmed(kind);\n\t\t\tfor (const armed of armings) {\n\t\t\t\tif (kind !== GITHUB_PR_TERMINAL_KIND && terminalInstances.has(armed.instanceId)) continue;\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tif (!config || !due(key, config.pollInterval ?? \"30s\") || config.disabled) continue;\n\t\t\t\ttry {\n\t\t\t\t\tawait read(config, armed);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\trefreshError: error instanceof Error ? error.message : \"GitHub refresh failed\",\n\t\t\t\t\t});\n\t\t\t\t\tconst fallback = kind === GITHUB_CHECKS_KIND ? \"checks_failed\" : \"poll_failed\";\n\t\t\t\t\tresult.errors.push(`${armed.id}:${error instanceof Error ? error.message : fallback}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tawait poll(GITHUB_PR_TERMINAL_KIND, parsePrConfig, async (config, armed) => {\n\t\t\tconst pr = await integration\n\t\t\t\t.client(config.profile)\n\t\t\t\t.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\tif (!pr.merged && pr.state !== \"closed\") return;\n\t\t\tif (!report.isCurrent(GITHUB_PR_TERMINAL_KIND, armed)) return;\n\t\t\tterminalInstances.add(armed.instanceId);\n\t\t\tconst outcome = pr.merged ? \"merged\" : \"closed\";\n\t\t\tif (config.terminalOutcome && config.terminalOutcome !== outcome) return;\n\t\t\tawait report.fire(armed, { pullRequest: pr }, `${pr.number}:${outcome}`);\n\t\t});\n\n\t\tawait poll(\n\t\t\tGITHUB_CHECKS_KIND,\n\t\t\t(value) => ({ pollInterval: \"30s\", config: asUnknownRecord(value) ?? {} }),\n\t\t\tasync ({ config }, armed) => {\n\t\t\t\tconst client = integration.client(String(config.profile));\n\t\t\t\tconst pr = await client.getPullRequest(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tNumber(config.prNumber),\n\t\t\t\t);\n\t\t\t\tif (pr.state !== \"open\" || pr.head.sha !== config.headSha) return;\n\t\t\t\tconst checks = await client.getCheckSummary(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tString(config.headSha),\n\t\t\t\t);\n\t\t\t\tif (checks.headSha !== config.headSha) return;\n\t\t\t\tconst refreshed = await client.getPullRequest(\n\t\t\t\t\tString(config.owner),\n\t\t\t\t\tString(config.repo),\n\t\t\t\t\tNumber(config.prNumber),\n\t\t\t\t);\n\t\t\t\tif (refreshed.state !== \"open\" || refreshed.merged || refreshed.head.sha !== checks.headSha)\n\t\t\t\t\treturn;\n\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\tobservation: {\n\t\t\t\t\t\t...describeGitHubEvent({ checks }),\n\t\t\t\t\t\tobservedAt: new Date(now()).toISOString(),\n\t\t\t\t\t\tsubject: `${config.owner}/${config.repo}#${config.prNumber}`,\n\t\t\t\t\t\trevision: checks.headSha,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (checks.status !== \"failure\") return;\n\t\t\t\tconst evidenceKey = `${checks.headSha}:${checks.failed.map((run) => run.url).join(\":\")}`;\n\t\t\t\tif (config.afterKey === evidenceKey) return;\n\t\t\t\tawait report.fire(armed, { checks }, evidenceKey);\n\t\t\t},\n\t\t);\n\n\t\tawait poll(GITHUB_ISSUE_CANCELLED_KIND, parseIssueCancelledConfig, async (config, armed) => {\n\t\t\tconst issue = await integration\n\t\t\t\t.client(config.profile)\n\t\t\t\t.getIssue(config.owner, config.repo, config.issueNumber);\n\t\t\tconst reason =\n\t\t\t\tissue.state === \"closed\"\n\t\t\t\t\t? \"issue_closed\"\n\t\t\t\t\t: hasLabel(issue, config.triggerLabel)\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: \"trigger_label_removed\";\n\t\t\tif (!reason) return;\n\t\t\t// A merge may close the issue between terminal polls. Preserve terminal\n\t\t\t// reconciliation instead of treating that close as cancellation.\n\t\t\tconst terminal = terminalArmings\n\t\t\t\t.filter((candidate) => candidate.instanceId === armed.instanceId)\n\t\t\t\t.map((candidate) => parsePrConfig(candidate.resolved))\n\t\t\t\t.find((candidate) => candidate && !candidate.disabled);\n\t\t\tif (terminal) {\n\t\t\t\tconst pr = await integration\n\t\t\t\t\t.client(terminal.profile)\n\t\t\t\t\t.getPullRequest(terminal.owner, terminal.repo, terminal.prNumber);\n\t\t\t\tif (pr.merged || pr.state === \"closed\") {\n\t\t\t\t\tterminalInstances.add(armed.instanceId);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait report.fire(armed, { issue, reason }, `${issue.number}:${reason}`);\n\t\t});\n\t\tawait poll(GITHUB_PR_FEEDBACK_KIND, parseFeedbackConfig, async (config, armed) => {\n\t\t\tconst client = integration.client(config.profile);\n\t\t\tconst pr = await client.getPullRequest(config.owner, config.repo, config.prNumber);\n\t\t\tif (pr.merged || pr.state !== \"open\") return;\n\t\t\tconst unseen = (\n\t\t\t\tawait client.listActionablePullRequestFeedback(config.owner, config.repo, config.prNumber)\n\t\t\t).filter((item) => item.id > config[`${item.kind}Cursor`]);\n\n\t\t\tconst batch = repositoryFeedbackBatch(unseen, config, now());\n\t\t\tif (batch) await report.fire(armed, batch.event, batch.mergeKey);\n\t\t});\n\t}\n\n\treturn async (result: ReturnType<typeof emptyPollResult>) => {\n\t\tconst watchers = deps.processWatchers?.listBySource(githubIssueWatcherSource) ?? [];\n\t\tfor (const watcher of watchers) {\n\t\t\tif (\n\t\t\t\t!watcher.enabled ||\n\t\t\t\t!due(`${watcher.processId}:${watcher.watcherId}`, watcher.config.pollInterval)\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\ttry {\n\t\t\t\tawait discover(watcher, result);\n\t\t\t} catch (error) {\n\t\t\t\tresult.errors.push(\n\t\t\t\t\t`${watcher.processId}:${watcher.watcherId}:${error instanceof Error ? error.message : \"discovery_failed\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tawait pollExternal(result);\n\t};\n}\n","import {\n\tdefineProcessWatcherSource,\n\tparseRepositoryIssueWatcherConfig,\n\tpresentRepositoryIssueWatcherConfig,\n\ttype RepositoryIssueWatcherConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitHubIssue, GitHubRepository } from \"./client.js\";\n\n/** @public */\nexport interface GitHubIssueWatcherConfig extends RepositoryIssueWatcherConfig {}\n\n/** @public */\nexport interface GitHubIssueWatcherEvent {\n\t/** @public */\n\tauthorization: {\n\t\t/** @internal */\n\t\tactor: string;\n\t\t/** @internal */\n\t\teventId: number;\n\t};\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\trepository: GitHubRepository;\n\t/** @public */\n\tissue: GitHubIssue;\n\t/** @public */\n\tlabels: {\n\t\t/** @public */\n\t\ttrigger: string;\n\t\t/** @public */\n\t\tdone: string;\n\t};\n}\n\n/** @public */\nexport const githubIssueWatcherSource = defineProcessWatcherSource<\n\tGitHubIssueWatcherConfig,\n\tGitHubIssueWatcherEvent\n>({\n\tid: \"@leitwerk-public/github.issue\",\n\tlabel: \"GitHub issue\",\n\tparseConfig: (raw) => parseRepositoryIssueWatcherConfig(raw, \"github_issue\", true),\n\tpresentConfig: presentRepositoryIssueWatcherConfig,\n});\n","import {\n\tcreateExternalSourcePollReporter,\n\ttype ExternalSourceServiceLike,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tGITHUB_CHECKS_KIND,\n\tGITHUB_ISSUE_CANCELLED_KIND,\n\tGITHUB_PR_FEEDBACK_KIND,\n\tGITHUB_PR_STATE_KIND,\n\tGITHUB_PR_TERMINAL_KIND,\n\tGITHUB_RELEASE_KIND,\n} from \"./external.js\";\n\nexport function githubPollReporter(\n\tsources: ExternalSourceServiceLike,\n\tresult: { created: string[]; errors: string[] },\n) {\n\treturn createExternalSourcePollReporter(sources, result, {\n\t\tforwardGeneration: true,\n\t\tcurrentKinds: [\n\t\t\tGITHUB_CHECKS_KIND,\n\t\t\tGITHUB_PR_STATE_KIND,\n\t\t\tGITHUB_PR_TERMINAL_KIND,\n\t\t\tGITHUB_PR_FEEDBACK_KIND,\n\t\t\tGITHUB_ISSUE_CANCELLED_KIND,\n\t\t\tGITHUB_RELEASE_KIND,\n\t\t],\n\t});\n}\n","import {\n\tlistTicketDestinations,\n\tmarkdownTicketCreationDefinition,\n\tnumberArg,\n\tobjectArg,\n\tparseTicketDestinationId,\n\ttype ServerExtensionAPI,\n\tstringArg,\n\ttype TicketCreationConfig,\n\ttype TicketCreationDestinationProvider,\n\ttype TicketCreationDestinationSnapshot,\n\tticketDestinationId,\n\tticketLabelNames,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport { assertGitHubRepository, type GitHubRepository } from \"./client.js\";\n\nfunction destinationData(snapshot: TicketCreationDestinationSnapshot) {\n\tconst data = objectArg(snapshot.data);\n\treturn {\n\t\tprofile: stringArg(data, \"profile\"),\n\t\tbaseUrl: stringArg(data, \"baseUrl\"),\n\t\trepositoryId: numberArg(data, \"repositoryId\"),\n\t\towner: stringArg(data, \"owner\"),\n\t\trepo: stringArg(data, \"repo\"),\n\t\tdefaultLabels: ticketLabelNames(data.defaultLabels),\n\t};\n}\n\nfunction available(repository: GitHubRepository): boolean {\n\treturn !!repository.id && !repository.archived && repository.has_issues;\n}\n\n/** @internal */\nexport function registerGitHubTicketCreation(\n\tapi: ServerExtensionAPI,\n\tintegration: GitHubIntegration,\n\tconfig: TicketCreationConfig,\n): void {\n\tif (!config.enabled) return;\n\tconst summary = (profile: string, repository: GitHubRepository) => ({\n\t\tid: ticketDestinationId(profile, repository.id ?? 0),\n\t\tdisplayName: repository.full_name,\n\t\tgroup: `${profile} · ${new URL(integration.client(profile).profile.apiBaseUrl).hostname}`,\n\t\tdescription: config.defaultLabels.length\n\t\t\t? `Default labels: ${config.defaultLabels.join(\", \")}`\n\t\t\t: \"No default labels\",\n\t});\n\tconst validateDestination = async (\n\t\tsnapshot: TicketCreationDestinationSnapshot,\n\t\tsignal?: AbortSignal,\n\t) => {\n\t\tconst data = destinationData(snapshot);\n\t\tconst client = integration.client(data.profile);\n\t\tif (client.profile.apiBaseUrl !== data.baseUrl)\n\t\t\tthrow new Error(\"GitHub profile installation changed\");\n\t\tassertGitHubRepository(client.profile, data.owner, data.repo);\n\t\tconst repository = await client.getRepositoryById(data.repositoryId, signal);\n\t\tif (\n\t\t\t!available(repository) ||\n\t\t\trepository.owner.login !== data.owner ||\n\t\t\trepository.name !== data.repo\n\t\t)\n\t\t\tthrow new Error(\"The selected GitHub repository changed; choose the destination again\");\n\t};\n\tconst destinations: TicketCreationDestinationProvider = {\n\t\tlist() {\n\t\t\treturn listTicketDestinations(\"GitHub\", integration.profiles?.() ?? [], async (profile) =>\n\t\t\t\t(await integration.client(profile).listRepositories())\n\t\t\t\t\t.filter(available)\n\t\t\t\t\t.map((repository) => summary(profile, repository)),\n\t\t\t);\n\t\t},\n\t\tasync resolve({ destinationId }) {\n\t\t\tconst { profile, resourceId } = parseTicketDestinationId(destinationId);\n\t\t\tconst client = integration.client(profile);\n\t\t\tconst repository = await client.getRepositoryById(Number(resourceId));\n\t\t\tif (!available(repository))\n\t\t\t\tthrow new Error(\"The selected GitHub repository cannot accept issues\");\n\t\t\tconst labels = await client.listLabels(repository.owner.login, repository.name);\n\t\t\treturn {\n\t\t\t\tsummary: summary(profile, repository),\n\t\t\t\tdata: {\n\t\t\t\t\tprofile,\n\t\t\t\t\tbaseUrl: client.profile.apiBaseUrl,\n\t\t\t\t\trepositoryId: repository.id,\n\t\t\t\t\towner: repository.owner.login,\n\t\t\t\t\trepo: repository.name,\n\t\t\t\t\tdefaultLabels: config.defaultLabels,\n\t\t\t\t},\n\t\t\t\tagentContext: `Create an issue in ${repository.full_name}. Existing optional labels: ${labels.map((label) => label.name).join(\", \") || \"none\"}.`,\n\t\t\t};\n\t\t},\n\t\tvalidate: validateDestination,\n\t};\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_create_issue\",\n\t\tdescription: \"Create one issue in the selected GitHub repository\",\n\t\t...markdownTicketCreationDefinition(\"GitHub\", destinations),\n\t\tasync execute(ctx, args) {\n\t\t\tif (!ctx.ticketDestination) throw new Error(\"A GitHub ticket destination is required\");\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tawait validateDestination(ctx.ticketDestination, ctx.signal);\n\t\t\tctx.signal.throwIfAborted();\n\t\t\tconst target = destinationData(ctx.ticketDestination);\n\t\t\tconst client = integration.client(target.profile);\n\t\t\tconst title = stringArg(args, \"title\");\n\t\t\tconst body = stringArg(args, \"body\");\n\t\t\tconst requestedLabels = ticketLabelNames(args.labels);\n\t\t\tconst labels = await client.listLabels(target.owner, target.repo, ctx.signal);\n\t\t\tconst unknown = requestedLabels.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t!target.defaultLabels.includes(name) && !labels.some((label) => label.name === name),\n\t\t\t);\n\t\t\tif (unknown.length) throw new Error(`Unknown GitHub labels: ${unknown.join(\", \")}`);\n\t\t\tfor (const name of target.defaultLabels) {\n\t\t\t\tctx.signal.throwIfAborted();\n\t\t\t\tawait ctx.externalWrites.ensure(\n\t\t\t\t\t{ writeType: \"github.ensure_label\", dedupKey: `${ctx.idempotencyKey}:label:${name}` },\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t\t(await client.listLabels(target.owner, target.repo, ctx.signal)).find(\n\t\t\t\t\t\t\t\t(label) => label.name === name,\n\t\t\t\t\t\t\t) ?? null,\n\t\t\t\t\t\texecute: () => {\n\t\t\t\t\t\t\tctx.signal.throwIfAborted();\n\t\t\t\t\t\t\treturn client.createLabel(target.owner, target.repo, name, ctx.signal);\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoMetadata: (label) => ({ id: label.id, name: label.name }),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst marker = `<!-- leitwerk-ticket-write:${ctx.idempotencyKey} -->`;\n\t\t\tconst issue = await ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"github.create_issue\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t(await client.listIssues(target.owner, target.repo, ctx.signal)).find((issue) =>\n\t\t\t\t\t\t\tissue.body?.includes(marker),\n\t\t\t\t\t\t) ?? null,\n\t\t\t\t\texecute: () => {\n\t\t\t\t\t\tctx.signal.throwIfAborted();\n\t\t\t\t\t\treturn client.createIssue(\n\t\t\t\t\t\t\ttarget.owner,\n\t\t\t\t\t\t\ttarget.repo,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\t\tbody: `${body}\\n\\n${marker}`,\n\t\t\t\t\t\t\t\tlabels: [...new Set([...target.defaultLabels, ...requestedLabels])],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\ttoMetadata: (issue) => ({ number: issue.number, url: issue.html_url }),\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\texternalId: `${target.owner}/${target.repo}#${issue.number}`,\n\t\t\t\turl: issue.html_url,\n\t\t\t\tresult: issue,\n\t\t\t};\n\t\t},\n\t});\n}\n","import {\n\texistingObject,\n\ttype IntegrationToolExecutionContext,\n\tmatchesPatch,\n\tnumberArg,\n\tobjectArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveGitHubProjectBinding } from \"./binding.js\";\nimport type { GitHubIntegration } from \"./capability.js\";\nimport { assertGitHubRepository } from \"./client.js\";\n\nconst object = (value: unknown) => objectArg(value, \"Expected an object\");\n\nexport function registerGitHubTools(api: ServerExtensionAPI, integration: GitHubIntegration) {\n\tconst target = (ctx: IntegrationToolExecutionContext) => {\n\t\tconst binding = resolveGitHubProjectBinding(ctx);\n\t\tassertGitHubRepository(\n\t\t\tintegration.client(binding.profile).profile,\n\t\t\tbinding.owner,\n\t\t\tbinding.repo,\n\t\t);\n\t\treturn binding;\n\t};\n\tapi.tool({\n\t\tname: \"github_resolve_git_identity\",\n\t\tdescription: \"Resolve the configured GitHub Git identity\",\n\t\tparameters: projectParameters(),\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration.client(t.profile).resolveGitIdentity(t.profile);\n\t\t},\n\t});\n\tfor (const name of [\n\t\t\"github_ensure_label\",\n\t\t\"github_update_issue\",\n\t\t\"github_add_issue_comment\",\n\t\t\"github_add_pull_request_feedback_reaction\",\n\t\t\"github_reply_to_pull_request_feedback\",\n\t\t\"github_add_pull_request_comment\",\n\t\t\"github_update_pull_request\",\n\t] as const) {\n\t\tconst pullRequest =\n\t\t\tname === \"github_add_pull_request_comment\" || name === \"github_update_pull_request\";\n\t\tconst update = name === \"github_update_issue\" || name === \"github_update_pull_request\";\n\t\tapi.tool({\n\t\t\tname,\n\t\t\tdescription: pullRequest\n\t\t\t\t? update\n\t\t\t\t\t? \"Update a GitHub pull request\"\n\t\t\t\t\t: \"Comment on a GitHub pull request\"\n\t\t\t\t: \"Reconcile GitHub delivery in the current process project\",\n\t\t\tparameters: pullRequest\n\t\t\t\t? projectParameters(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\t\t\t...(update\n\t\t\t\t\t\t\t\t? { patch: { type: \"object\" } }\n\t\t\t\t\t\t\t\t: { body: { type: \"string\" }, writeKey: { type: \"string\" } }),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[\"pullRequestNumber\", update ? \"patch\" : \"body\"],\n\t\t\t\t\t)\n\t\t\t\t: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tprojectKey: { type: \"string\" },\n\t\t\t\t\t\t\tissueNumber: { type: \"integer\" },\n\t\t\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\t\t\tname: { type: \"string\" },\n\t\t\t\t\t\t\tpatch: { type: \"object\" },\n\t\t\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\t\t\tfeedbackKind: { type: \"string\" },\n\t\t\t\t\t\t\tfeedbackId: { type: \"integer\" },\n\t\t\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"projectKey\"],\n\t\t\t\t\t},\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst input = object(args);\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\tconst key =\n\t\t\t\t\t!(pullRequest && update) && typeof input.writeKey === \"string\"\n\t\t\t\t\t\t? stringArg(input, \"writeKey\")\n\t\t\t\t\t\t: ctx.idempotencyKey;\n\t\t\t\tconst signal = pullRequest ? ctx.signal : undefined;\n\t\t\t\tconst marker = `<!-- leitwerk-write:${ctx.process.id}:${key} -->`;\n\t\t\t\tconst issueNumber = () =>\n\t\t\t\t\tnumberArg(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tpullRequest || input.issueNumber == null ? \"pullRequestNumber\" : \"issueNumber\",\n\t\t\t\t\t);\n\t\t\t\tconst findComment = async () => {\n\t\t\t\t\tconst replies =\n\t\t\t\t\t\tname === \"github_reply_to_pull_request_feedback\"\n\t\t\t\t\t\t\t? await client.listFeedbackReplies(\n\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: await client.listIssueComments(t.owner, t.repo, issueNumber(), signal);\n\t\t\t\t\treturn (\n\t\t\t\t\t\treplies.find(\n\t\t\t\t\t\t\t(comment) =>\n\t\t\t\t\t\t\t\tString(comment.body).includes(marker) &&\n\t\t\t\t\t\t\t\t(name !== \"github_reply_to_pull_request_feedback\" ||\n\t\t\t\t\t\t\t\t\tinput.feedbackKind !== \"inline\" ||\n\t\t\t\t\t\t\t\t\tobject(comment).in_reply_to_id === numberArg(input, \"feedbackId\")),\n\t\t\t\t\t\t) ?? null\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tconst result = await ctx.externalWrites.ensure(\n\t\t\t\t\t{\n\t\t\t\t\t\twriteType: pullRequest ? (update ? \"github.update_pr\" : \"github.comment\") : name,\n\t\t\t\t\t\tdedupKey: key,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async (phase): Promise<object | null> =>\n\t\t\t\t\t\t\texistingObject(async () => {\n\t\t\t\t\t\t\t\tif (name === \"github_ensure_label\")\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t(await client.listLabels(t.owner, t.repo)).find(\n\t\t\t\t\t\t\t\t\t\t\t(label) => label.name === stringArg(input, \"name\"),\n\t\t\t\t\t\t\t\t\t\t) ?? null\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (update) {\n\t\t\t\t\t\t\t\t\tconst current = await client[pullRequest ? \"getPullRequest\" : \"getIssue\"](\n\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\treturn current &&\n\t\t\t\t\t\t\t\t\t\t(phase === \"already_recorded\" || matchesPatch(current, object(input.patch)))\n\t\t\t\t\t\t\t\t\t\t? current\n\t\t\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (name === \"github_add_pull_request_feedback_reaction\")\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tawait client.listFeedbackReactions(\n\t\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t).find(\n\t\t\t\t\t\t\t\t\t\t\t(reaction) =>\n\t\t\t\t\t\t\t\t\t\t\t\treaction.content === \"eyes\" &&\n\t\t\t\t\t\t\t\t\t\t\t\treaction.user.login.toLowerCase() === client.profile.botLogin.toLowerCase(),\n\t\t\t\t\t\t\t\t\t\t) ?? null\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn findComment();\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\texecute: async (): Promise<object> => {\n\t\t\t\t\t\t\tif (name === \"github_ensure_label\")\n\t\t\t\t\t\t\t\treturn client.createLabel(t.owner, t.repo, stringArg(input, \"name\"));\n\t\t\t\t\t\t\tif (update)\n\t\t\t\t\t\t\t\treturn pullRequest\n\t\t\t\t\t\t\t\t\t? object(\n\t\t\t\t\t\t\t\t\t\t\tawait client.updatePullRequest(\n\t\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\t\t\tobject(input.patch),\n\t\t\t\t\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: client.updateIssue(t.owner, t.repo, issueNumber(), object(input.patch));\n\t\t\t\t\t\t\tif (name === \"github_add_pull_request_feedback_reaction\")\n\t\t\t\t\t\t\t\treturn object(\n\t\t\t\t\t\t\t\t\tawait client.addFeedbackReaction(\n\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst body = `${stringArg(input, \"body\")}\\n\\n${marker}`;\n\t\t\t\t\t\t\treturn object(\n\t\t\t\t\t\t\t\tawait (name === \"github_add_issue_comment\" || pullRequest\n\t\t\t\t\t\t\t\t\t? client.addIssueComment(t.owner, t.repo, issueNumber(), body, signal)\n\t\t\t\t\t\t\t\t\t: client.replyFeedback(\n\t\t\t\t\t\t\t\t\t\t\tt.owner,\n\t\t\t\t\t\t\t\t\t\t\tt.repo,\n\t\t\t\t\t\t\t\t\t\t\tissueNumber(),\n\t\t\t\t\t\t\t\t\t\t\tstringArg(input, \"feedbackKind\"),\n\t\t\t\t\t\t\t\t\t\t\tnumberArg(input, \"feedbackId\"),\n\t\t\t\t\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\t\t\t\t)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoMetadata: (value) =>\n\t\t\t\t\t\t\tpullRequest\n\t\t\t\t\t\t\t\t? { owner: t.owner, repo: t.repo, pullRequestNumber: issueNumber() }\n\t\t\t\t\t\t\t\t: { value },\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tif (name === \"github_ensure_label\") return { name: stringArg(input, \"name\") };\n\t\t\t\treturn result;\n\t\t\t},\n\t\t});\n\t}\n\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_ensure_pull_request\",\n\t\tdescription: \"Create a GitHub pull request unless the branch pair already has one\",\n\t\tparameters: projectParameters({\n\t\t\ttitle: { type: \"string\" },\n\t\t\tbody: { type: \"string\" },\n\t\t\thead: { type: \"string\" },\n\t\t\tbase: { type: \"string\" },\n\t\t}),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst head = stringArg(input, \"head\");\n\t\t\tconst base = stringArg(input, \"base\");\n\t\t\tif (head !== ctx.project?.workBranch || base !== ctx.project?.baseBranch)\n\t\t\t\tthrow new Error(\"Pull request branches must match the process project\");\n\t\t\tconst find = async () =>\n\t\t\t\t(await client.listPullRequests(t.owner, t.repo, \"all\")).find(\n\t\t\t\t\t(candidate) => candidate.head.ref === head && candidate.base.ref === base,\n\t\t\t\t) ?? null;\n\t\t\treturn ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"github.ensure_pr\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: () => existingObject(find),\n\t\t\t\t\texecute: () =>\n\t\t\t\t\t\tclient.createPullRequest(t.owner, t.repo, {\n\t\t\t\t\t\t\ttitle: stringArg(input, \"title\"),\n\t\t\t\t\t\t\tbody: stringArg(input, \"body\"),\n\t\t\t\t\t\t\thead,\n\t\t\t\t\t\t\tbase,\n\t\t\t\t\t\t}),\n\t\t\t\t\ttoMetadata: (pr) => ({ number: pr.number, url: pr.html_url }),\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t});\n\tfor (const [name, description, numberName, method] of [\n\t\t[\n\t\t\t\"github_get_issue\",\n\t\t\t\"Read a GitHub issue in the current process project\",\n\t\t\t\"issueNumber\",\n\t\t\t\"getIssue\",\n\t\t],\n\t\t[\n\t\t\t\"github_get_pull_request\",\n\t\t\t\"Read a GitHub pull request in the current process project\",\n\t\t\t\"pullRequestNumber\",\n\t\t\t\"getPullRequest\",\n\t\t],\n\t\t[\n\t\t\t\"github_list_pull_request_feedback\",\n\t\t\t\"Read GitHub pull request conversation, reviews, and inline comments\",\n\t\t\t\"pullRequestNumber\",\n\t\t\t\"listActionablePullRequestFeedback\",\n\t\t],\n\t] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tparameters: projectParameters({ [numberName]: { type: \"integer\" } }),\n\t\t\tasync execute(ctx, input) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\treturn integration\n\t\t\t\t\t.client(t.profile)\n\t\t\t\t\t[method](t.owner, t.repo, numberArg(input, numberName), ctx.signal);\n\t\t\t},\n\t\t});\n\t}\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_get_ci_diagnostics\",\n\t\tdescription:\n\t\t\t\"Read failed check annotations and bounded Actions logs for the current request revision\",\n\t\tparameters: projectParameters(\n\t\t\t{ pullRequestNumber: { type: \"integer\" }, headSha: { type: \"string\" } },\n\t\t\t[\"pullRequestNumber\", \"headSha\"],\n\t\t),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst number = numberArg(input, \"pullRequestNumber\");\n\t\t\tconst pr = await client.getPullRequest(t.owner, t.repo, number, ctx.signal);\n\t\t\tif (pr.head.ref !== ctx.project?.workBranch || pr.base.ref !== ctx.project.baseBranch)\n\t\t\t\tthrow new Error(\"Pull request does not belong to the process branches\");\n\t\t\treturn client.getCiDiagnostics(\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tnumber,\n\t\t\t\tstringArg(input, \"headSha\"),\n\t\t\t\tctx.signal,\n\t\t\t);\n\t\t},\n\t});\n\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"github_get_checks\",\n\t\tdescription: \"Read GitHub Actions check runs for a commit\",\n\t\tparameters: projectParameters({ headSha: { type: \"string\" } }),\n\t\tasync execute(ctx, input) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration\n\t\t\t\t.client(t.profile)\n\t\t\t\t.getCheckSummary(t.owner, t.repo, stringArg(input, \"headSha\"));\n\t\t},\n\t});\n}\n","import { resolveRepositoryProjectBinding } from \"@leitwerk-dev/process-sdk\";\n\nexport type { RepositoryProjectBinding as GitHubProjectBinding } from \"@leitwerk-dev/process-sdk\";\n/** @public */\nexport const resolveGitHubProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"github\");\n"],"mappings":";;;;;;;AAAA;AAAA,EACC;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;;;ACPP,SAAS,6BAA6B;AAe/B,IAAM,oBAAoB;AAAA,EAChC;AACD;;;ACjBA,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,sBAAAC,qBAAoB,uBAAuB;;;ACHpD,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,OAKM;AAGA,IAAM,uBAAuB;AAoB7B,IAAM,sBAAsB;AAmB5B,SAAS,oBAAoB,OAA0C;AAC7E,QAAM,QAAQ;AASd,MAAI,MAAM,SAAS,iBAAkB,QAAO,iBAAiB,KAAK;AAClE,MAAI,MAAM,QAAQ;AACjB,UAAM,SAAS,MAAM;AACrB,WAAO;AAAA,MACN,SAAS,UAAU,OAAO,MAAM,OAAO,OAAO,OAAO,GAAG,OAAO,OAAO,SAAS,KAAK,OAAO,OAAO,IAAI,CAAC,UAAU,MAAM,IAAI,EAAE,KAAK,IAAI,CAAC,KAAK,EAAE;AAAA,MAC9I,OAAO,OAAO,OAAO;A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A,EACF;AACD;AAEA,IAAO,gBAAQ;AAGR,SAAS,uBACf,KACA,aACA,UAKI,CAAC,GACJ;AACD,MAAI,QAAQ,mBAAmB,WAAW;AAC1C,QAAM,OAAO,IAAI,IAAI,qBAAqB,WAAW;AACrD,MAAI,CAAC,QAAQ,MAAM,QAAQ,IAAI,EAAG;AAClC,sBAAoB,KAAK,WAAW;AACpC;AAAA,IACC;AAAA,IACA;AAAA,IACA,QAAQ,kBAAkB,EAAE,SAAS,OAAO,eAAe,CAAC,EAAE;AAAA,EAC/D;AACA,SAAO,qBAAqB,MAAM,aAAa,OAAO;AACvD;","names":["asUnknownRecord","createPollSchedule","parse","asUnknownRecord","value","createPollSchedule","issue","numberArg","objectArg","stringArg","objectArg","stringArg","numberArg"]}
@@ -61,7 +61,7 @@ export declare function toolFixture(): Promise<{
61
61
  readonly dedupKey: string;
62
62
  readonly metadata?: unknown;
63
63
  }[];
64
- callTool: (name: string, args: Record<string, unknown>, fixture?: ExtensionToolFixture) => Promise<unknown>;
64
+ callTool: (name: string, args: Record<string, unknown>, fixture?: ExtensionToolFixture, reportProgress?: (report: import("@leitwerk-dev/domain").TurnProgressReport) => void) => Promise<unknown>;
65
65
  emit(type: string, event: unknown): Promise<void>;
66
66
  close: () => Promise<void>;
67
67
  process<TParams, TState>(definition: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<TParams, TState>, initial?: import("@leitwerk-dev/test-support/process").ExtensionProcessFixture<TParams, TState>): {
@@ -76,6 +76,10 @@ export declare function toolFixture(): Promise<{
76
76
  } | {
77
77
  readonly ok: true;
78
78
  readonly launchConfig: {
79
+ readonly primaryRepositoryKey?: string | undefined;
80
+ readonly settingsContext?: {
81
+ readonly [x: string]: string;
82
+ } | undefined;
79
83
  readonly processId: string;
80
84
  readonly params: import("@leitwerk-dev/test-support/process").TestObservation<TParams>;
81
85
  readonly startTurnId?: (import("@leitwerk-dev/domain").TurnId | null) | undefined;
@@ -97,6 +101,11 @@ export declare function toolFixture(): Promise<{
97
101
  } | undefined;
98
102
  readonly skillIds?: readonly string[] | undefined;
99
103
  readonly projects?: readonly {
104
+ readonly settingsRepository?: {
105
+ readonly origin: string;
106
+ readonly repositoryId: string | number;
107
+ readonly aliases?: readonly string[] | undefined;
108
+ } | undefined;
100
109
  readonly key: string;
101
110
  readonly repoLocator: string;
102
111
  readonly baseBranch: string;
@@ -113,6 +122,10 @@ export declare function toolFixture(): Promise<{
113
122
  readonly [x: string]: unknown;
114
123
  }>;
115
124
  resolveWatcherLaunch(id: string, event: unknown, config: unknown): Promise<{
125
+ readonly primaryRepositoryKey?: string | undefined;
126
+ readonly settingsContext?: {
127
+ readonly [x: string]: string;
128
+ } | undefined;
116
129
  readonly processId: string;
117
130
  readonly params: import("@leitwerk-dev/test-support/process").TestObservation<TParams>;
118
131
  readonly startTurnId?: (import("@leitwerk-dev/domain").TurnId | null) | undefined;
@@ -134,6 +147,11 @@ export declare function toolFixture(): Promise<{
134
147
  } | undefined;
135
148
  readonly skillIds?: readonly string[] | undefined;
136
149
  readonly projects?: readonly {
150
+ readonly settingsRepository?: {
151
+ readonly origin: string;
152
+ readonly repositoryId: string | number;
153
+ readonly aliases?: readonly string[] | undefined;
154
+ } | undefined;
137
155
  readonly key: string;
138
156
  readonly repoLocator: string;
139
157
  readonly baseBranch: string;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-fixture.d.ts","sourceRoot":"","sources":["../../src/testing/tool-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,oBAAoB,EACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,wBAAgB,gBAAgB,CAAC,EAAE,SAAM,GAAG,oBAAoB,CAe/D;AAED,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,qGAAqG;AACrG,wBAAsB,WAAW;;;cAEF,MAAM;;;gBACJ,MAAM;eAAS,MAAM;cAAQ,MAAM;;;;gBAE/B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C;;;kBAL3lX,MAAM,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;GAIpD"}
package/dist/testing.d.ts CHANGED
@@ -123,7 +123,7 @@ export declare class LocalGitHubAdapter extends LocalForgeStore<LocalGitHubState
123
123
  /** @public */
124
124
  setMembership(login: string, member: boolean): void;
125
125
  /** @public */
126
- failNextResponse(operation: "comment" | "reply" | "reaction" | "issue" | "label"): void;
126
+ failNextResponse(operation: "comment" | "reply" | "reaction" | "issue" | "label" | "create-issue"): void;
127
127
  private lostResponse;
128
128
  /** @public */
129
129
  createIssue(repo: LocalGitHubRepository, input: {
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAEjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EACX,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAEhB,iBAAiB,EACjB,aAAa,EACb,MAAM,aAAa,CAAC;AAGrB,cAAc;AACd,UAAU,qBAAqB;IAC9B,cAAc;IACd,UAAU,EAAE,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;IAC5D,cAAc;IACd,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,cAAc;IACd,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC/C,cAAc;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC3C,cAAc;IACd,QA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CAAC,EAAE,MAAM,CAAC;KAChB;IAiBF,cAAc;IACd,aAAa,CACZ,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,UAAO;IAkBf,cAAc;IACd,YAAY,CACX,IAAI,EAAE,qBAAqB,EAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAChC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GAAG,IAAI;IAUtB,cAAc;IACd,MAAM,IAAI,gBAAgB;CAwN1B"}
package/dist/testing.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  actionableFeedback,
3
3
  assertGitHubRepository,
4
4
  authorizedTrigger
5
- } from "./chunk-PNHJ5QZ6.js";
5
+ } from "./chunk-FDDQQGXI.js";
6
6
 
7
7
  // src/testing.ts
8
8
  import { LocalForgeStore } from "@leitwerk-dev/test-support/local-git";
@@ -123,7 +123,7 @@ var LocalGitHubAdapter = class extends LocalForgeStore {
123
123
  title: input.title,
124
124
  body: input.body ?? "",
125
125
  state: "open",
126
- html_url: `${this.options.baseUrl}/__local#issue-${number}`,
126
+ html_url: `${this.options.baseUrl}/__local/github/receipts/${repo.repository.id}/${number}`,
127
127
  updated_at: this.timestamp(),
128
128
  user: { login: input.author ?? "developer" },
129
129
  labels: []
@@ -173,6 +173,23 @@ var LocalGitHubAdapter = class extends LocalForgeStore {
173
173
  };
174
174
  const client = {
175
175
  profile,
176
+ getRepositoryById: async (id) => {
177
+ const found = this.state.repositories.find((entry) => entry.repository.id === id);
178
+ if (!found) throw new Error("Unknown local GitHub repository");
179
+ return {
180
+ ...repo(found.repository.owner.login, found.repository.name).repository,
181
+ archived: false,
182
+ has_issues: true
183
+ };
184
+ },
185
+ listIssues: async (owner, name) => structuredClone(repo(owner, name).issues),
186
+ createIssue: async (owner, name, input) => {
187
+ const issue = this.createIssue(repo(owner, name), input);
188
+ issue.labels = input.labels.map((label) => ({ id: this.id(), name: label }));
189
+ this.save();
190
+ this.lostResponse("create-issue");
191
+ return structuredClone(issue);
192
+ },
176
193
  listRepositories: async () => this.state.repositories.map((r) => ({ ...r.repository, archived: false, has_issues: true })).filter(
177
194
  (r) => !profile.allowedOrganization || r.owner.login.toLowerCase() === profile.allowedOrganization.toLowerCase()
178
195
  ),