@leitwerk-dev/github 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +40 -0
  2. package/dist/authorization.d.ts +4 -0
  3. package/dist/authorization.d.ts.map +1 -1
  4. package/dist/binding.d.ts +1 -0
  5. package/dist/binding.d.ts.map +1 -1
  6. package/dist/capability.d.ts +6 -1
  7. package/dist/capability.d.ts.map +1 -1
  8. package/dist/{chunk-PVE52UFH.js → chunk-OAOKE6LC.js} +162 -20
  9. package/dist/chunk-OAOKE6LC.js.map +1 -0
  10. package/dist/client.d.ts +143 -8
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/external.d.ts +66 -0
  13. package/dist/external.d.ts.map +1 -1
  14. package/dist/index.d.ts +13 -11
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +160 -168
  17. package/dist/index.js.map +1 -1
  18. package/dist/issue-provider.d.ts.map +1 -1
  19. package/dist/issue-watcher.d.ts +12 -0
  20. package/dist/issue-watcher.d.ts.map +1 -1
  21. package/dist/poll-report.d.ts +2 -18
  22. package/dist/poll-report.d.ts.map +1 -1
  23. package/dist/provider.d.ts +3 -1
  24. package/dist/provider.d.ts.map +1 -1
  25. package/dist/testing/tool-fixture.d.ts +192 -0
  26. package/dist/testing/tool-fixture.d.ts.map +1 -0
  27. package/dist/testing.d.ts +67 -3
  28. package/dist/testing.d.ts.map +1 -1
  29. package/dist/testing.js +46 -4
  30. package/dist/testing.js.map +1 -1
  31. package/dist/tools.d.ts +1 -2
  32. package/dist/tools.d.ts.map +1 -1
  33. package/package.json +6 -7
  34. package/src/authorization.ts +9 -1
  35. package/src/binding.ts +1 -0
  36. package/src/capability.ts +6 -1
  37. package/src/client.ts +315 -28
  38. package/src/external.ts +54 -0
  39. package/src/index.ts +33 -11
  40. package/src/issue-provider.ts +4 -12
  41. package/src/issue-watcher.ts +16 -1
  42. package/src/poll-report.ts +5 -23
  43. package/src/provider.ts +1 -1
  44. package/src/testing/tool-fixture.ts +137 -0
  45. package/src/testing.ts +108 -9
  46. package/src/tools.ts +183 -175
  47. package/dist/chunk-PVE52UFH.js.map +0 -1
package/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 type { ExternalWriteLogRepoLike } from \"@leitwerk-dev/external-writes\";\nimport { 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\nexport const manifest = { id: \"github\", version: \"0.1.9\" } as const;\n\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseGitHubProfiles(config);\n\t\tconst integration: GitHubIntegration = {\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 * from \"./capability.js\";\nexport * from \"./client.js\";\nexport * from \"./external.js\";\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. */\nexport function setupGitHubIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: GitHubIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tapi.provide(githubIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterGitHubTools(api, integration, deps.externalWrites as ExternalWriteLogRepoLike);\n\treturn createGitHubProvider(deps, integration, options);\n}\n\nexport * from \"./binding.js\";\n\nexport * 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. */\nexport type GitHubClientLike = Pick<GitHubClient, keyof GitHubClient>;\n\nexport interface GitHubIntegration {\n\tclient(profile: string): GitHubClientLike;\n}\n\nexport const githubIntegration = createCapabilityToken<GitHubIntegration>(\n\t\"@leitwerk-private/github.integration\",\n);\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport type { CoreServerSetupDeps } from \"@leitwerk-dev/process-sdk\";\nimport { conflictEvidence, createConflictReporter } from \"@leitwerk-dev/repository-rebase\";\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(deps.externalSources, 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 {\n\tdefineExternalActionSource,\n\ttype ExternalEventDescription,\n} from \"@leitwerk-dev/process-sdk\";\nimport { describeConflict } from \"@leitwerk-dev/repository-rebase\";\n\nexport const GITHUB_PR_STATE_KIND = \"@leitwerk-private/github.pr_state\";\n\nexport interface GitHubPullRequestSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tprNumber: number;\n\theadSha: string;\n\tfeedbackCursor: number;\n\tlastConflictKey?: string | null;\n\tpollInterval?: string;\n\tdisabled?: boolean;\n\teventKinds?: Array<\"checks\" | \"feedback\" | \"merged\" | \"closed\" | \"merge_conflict\">;\n\tcheckStatuses?: Array<\"pending\" | \"success\" | \"failure\">;\n}\n\nexport const GITHUB_RELEASE_KIND = \"@leitwerk-private/github.release\";\n\nexport interface GitHubReleaseSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tmergeSha: string;\n\tpollInterval?: string;\n\tdisabled?: boolean;\n}\n\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\nexport const GITHUB_PR_TERMINAL_KIND = \"@leitwerk-public/github.pr_terminal\";\nexport const GITHUB_PR_FEEDBACK_KIND = \"@leitwerk-public/github.pr_feedback\";\nexport const GITHUB_ISSUE_CANCELLED_KIND = \"@leitwerk-public/github.issue_cancelled\";\n\nexport interface GitHubPullRequestTerminalSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tprNumber: number;\n\tpollInterval?: string;\n\tterminalOutcome?: \"merged\" | \"closed\";\n\tdisabled?: boolean;\n}\n\nexport interface GitHubFeedbackSourceConfig extends GitHubPullRequestTerminalSourceConfig {\n\tconversationCursor: number;\n\treviewCursor: number;\n\tinlineCursor: number;\n\tquietPeriodMs: number;\n}\n\nexport interface GitHubIssueCancelledSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tissueNumber: number;\n\ttriggerLabel: string;\n\tpollInterval?: string;\n}\n\nexport const GITHUB_CHECKS_KIND = \"@leitwerk-public/github.checks\";\n\nexport const githubExternal = {\n\tchecks: defineExternalActionSource<{\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\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\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\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\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\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 { sameSubscription } from \"@leitwerk-dev/repository-rebase\";\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 (\n\t\t\t\t!deps.externalSources\n\t\t\t\t\t.listArmed(GITHUB_PR_TERMINAL_KIND)\n\t\t\t\t\t.some((current) => sameSubscription(armed, current))\n\t\t\t)\n\t\t\t\treturn;\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\tawait report.fire(\n\t\t\t\t\tarmed,\n\t\t\t\t\t{ checks },\n\t\t\t\t\t`${checks.headSha}:${checks.failed.map((run) => run.url).join(\":\")}`,\n\t\t\t\t);\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\nexport interface GitHubIssueWatcherConfig extends RepositoryIssueWatcherConfig {}\n\nexport interface GitHubIssueWatcherEvent {\n\tauthorization: { actor: string; eventId: number };\n\tprofile: string;\n\trepository: GitHubRepository;\n\tissue: GitHubIssue;\n\tlabels: {\n\t\ttrigger: string;\n\t\tdone: string;\n\t};\n}\n\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 ExternalSourceArmingLike,\n\ttype ExternalSourceServiceLike,\n} from \"@leitwerk-dev/process-sdk\";\nimport { sameSubscription } from \"@leitwerk-dev/repository-rebase\";\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\tconst report = createExternalSourcePollReporter(sources, result, { forwardGeneration: true });\n\tconst current = (armed: ExternalSourceArmingLike) =>\n\t\t[\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].some((kind) => sources.listArmed(kind).some((value) => sameSubscription(armed, value)));\n\treturn {\n\t\t...report,\n\t\tasync fire(\n\t\t\tarmed: Parameters<typeof report.fire>[0],\n\t\t\tevent: Record<string, unknown>,\n\t\t\tmergeKey: string,\n\t\t) {\n\t\t\tif (!current(armed as ExternalSourceArmingLike)) return false;\n\t\t\treturn report.fire(armed, event, mergeKey);\n\t\t},\n\t\tobserve(\n\t\t\tarmed: Parameters<typeof report.observe>[0],\n\t\t\tinput: Parameters<typeof report.observe>[1],\n\t\t) {\n\t\t\tif (current(armed as ExternalSourceArmingLike)) return report.observe(armed, input);\n\t\t},\n\t};\n}\n","import {\n\tcreateWriteIdentity,\n\ttype ExternalWriteLogRepoLike,\n\tensureWrite,\n\trecordWriteIfMissing,\n} from \"@leitwerk-dev/external-writes\";\nimport {\n\ttype IntegrationToolExecutionContext,\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\nasync function reconcileComment(\n\tcomments: Promise<Array<{ body?: unknown }>>,\n\tmarker: string,\n\tbody: () => string,\n\tpost: (body: string) => Promise<unknown>,\n) {\n\tconst existing = (await comments).find((comment) => String(comment.body).includes(marker));\n\treturn existing ?? post(`${body()}\\n\\n${marker}`);\n}\n\nexport function registerGitHubTools(\n\tapi: ServerExtensionAPI,\n\tintegration: GitHubIntegration,\n\twrites: ExternalWriteLogRepoLike,\n) {\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: {\n\t\t\ttype: \"object\",\n\t\t\tproperties: { projectKey: { type: \"string\" } },\n\t\t\trequired: [\"projectKey\"],\n\t\t},\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] as const) {\n\t\tapi.tool({\n\t\t\tname,\n\t\t\tdescription: \"Reconcile GitHub delivery in the current process project\",\n\t\t\tparameters: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tprojectKey: { type: \"string\" },\n\t\t\t\t\tissueNumber: { type: \"integer\" },\n\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\tname: { type: \"string\" },\n\t\t\t\t\tpatch: { type: \"object\" },\n\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\tfeedbackKind: { type: \"string\" },\n\t\t\t\t\tfeedbackId: { type: \"integer\" },\n\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"projectKey\"],\n\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\ttypeof input.writeKey === \"string\" ? stringArg(input, \"writeKey\") : ctx.idempotencyKey;\n\t\t\t\tconst marker = `<!-- leitwerk-write:${ctx.process.id}:${key} -->`;\n\t\t\t\tlet value: unknown;\n\t\t\t\tconst result = await ensureWrite(\n\t\t\t\t\twrites,\n\t\t\t\t\tctx.process.id,\n\t\t\t\t\tcreateWriteIdentity(name, key),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (name === \"github_ensure_label\")\n\t\t\t\t\t\t\tvalue = await client.ensureLabel(t.owner, t.repo, stringArg(input, \"name\"));\n\t\t\t\t\t\telse if (name === \"github_update_issue\") {\n\t\t\t\t\t\t\tconst issueNumber = numberArg(input, \"issueNumber\");\n\t\t\t\t\t\t\tconst current = await client.getIssue(t.owner, t.repo, issueNumber);\n\t\t\t\t\t\t\tconst patch = object(input.patch);\n\t\t\t\t\t\t\tconst same = Object.entries(patch).every(\n\t\t\t\t\t\t\t\t([key, expected]) =>\n\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\tkey === \"labels\"\n\t\t\t\t\t\t\t\t\t\t\t? current.labels.map((label) => label.name).sort()\n\t\t\t\t\t\t\t\t\t\t\t: object(current)[key],\n\t\t\t\t\t\t\t\t\t) ===\n\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\tkey === \"labels\" && Array.isArray(expected) ? [...expected].sort() : expected,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tvalue = same\n\t\t\t\t\t\t\t\t? current\n\t\t\t\t\t\t\t\t: await client.updateIssue(t.owner, t.repo, issueNumber, patch);\n\t\t\t\t\t\t} else if (name === \"github_add_pull_request_feedback_reaction\") {\n\t\t\t\t\t\t\tconst kind = stringArg(input, \"feedbackKind\");\n\t\t\t\t\t\t\tconst id = numberArg(input, \"feedbackId\");\n\t\t\t\t\t\t\tconst reactions = await client.listFeedbackReactions(t.owner, t.repo, kind, id);\n\t\t\t\t\t\t\tvalue =\n\t\t\t\t\t\t\t\treactions.find(\n\t\t\t\t\t\t\t\t\t(reaction) =>\n\t\t\t\t\t\t\t\t\t\treaction.content === \"eyes\" &&\n\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) ?? (await client.addFeedbackReaction(t.owner, t.repo, kind, id));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst issueNumber = numberArg(\n\t\t\t\t\t\t\t\t{ issueNumber: input.issueNumber ?? input.pullRequestNumber },\n\t\t\t\t\t\t\t\t\"issueNumber\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tvalue = await reconcileComment(\n\t\t\t\t\t\t\t\tname === \"github_reply_to_pull_request_feedback\"\n\t\t\t\t\t\t\t\t\t? client.listFeedbackReplies(\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)\n\t\t\t\t\t\t\t\t\t: client.listIssueComments(t.owner, t.repo, issueNumber),\n\t\t\t\t\t\t\t\tmarker,\n\t\t\t\t\t\t\t\t() => stringArg(input, \"body\"),\n\t\t\t\t\t\t\t\t(body) =>\n\t\t\t\t\t\t\t\t\tname === \"github_add_issue_comment\"\n\t\t\t\t\t\t\t\t\t\t? client.addIssueComment(t.owner, t.repo, issueNumber, body)\n\t\t\t\t\t\t\t\t\t\t: client.replyFeedback(\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\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\tbody,\n\t\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\treturn { value };\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tif (name === \"github_ensure_label\") return { name: stringArg(input, \"name\") };\n\t\t\t\treturn value ?? 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\tlet pr = await find();\n\t\t\tconst identity = createWriteIdentity(\"github.ensure_pr\", ctx.idempotencyKey);\n\t\t\tif (!pr) {\n\t\t\t\ttry {\n\t\t\t\t\tawait ensureWrite(writes, ctx.process.id, identity, async () => {\n\t\t\t\t\t\tpr = await client.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\t\treturn { number: pr.number, url: pr.html_url };\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tpr = await find();\n\t\t\t\t\tif (!pr) throw error;\n\t\t\t\t}\n\t\t\t\tpr ??= await find();\n\t\t\t}\n\t\t\tif (!pr) throw new Error(\"GitHub pull request creation could not be reconciled\");\n\t\t\trecordWriteIfMissing(writes, ctx.process.id, identity, {\n\t\t\t\tnumber: pr.number,\n\t\t\t\turl: pr.html_url,\n\t\t\t});\n\t\t\treturn pr;\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_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\tfor (const definition of [\n\t\t{ name: \"github_add_pull_request_comment\", update: false },\n\t\t{ name: \"github_update_pull_request\", update: true },\n\t] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname: definition.name,\n\t\t\tdescription: definition.update\n\t\t\t\t? \"Update a GitHub pull request\"\n\t\t\t\t: \"Comment on a GitHub pull request\",\n\t\t\tparameters: projectParameters(\n\t\t\t\t{\n\t\t\t\t\tpullRequestNumber: { type: \"integer\" },\n\t\t\t\t\t...(definition.update\n\t\t\t\t\t\t? { patch: { type: \"object\" } }\n\t\t\t\t\t\t: { body: { type: \"string\" }, writeKey: { type: \"string\" } }),\n\t\t\t\t},\n\t\t\t\t[\"pullRequestNumber\", definition.update ? \"patch\" : \"body\"],\n\t\t\t),\n\t\t\tasync execute(ctx, input) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst pr = numberArg(input, \"pullRequestNumber\");\n\t\t\t\tconst key =\n\t\t\t\t\t!definition.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\treturn ensureWrite(\n\t\t\t\t\twrites,\n\t\t\t\t\tctx.process.id,\n\t\t\t\t\tcreateWriteIdentity(definition.update ? \"github.update_pr\" : \"github.comment\", key),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (definition.update)\n\t\t\t\t\t\t\tawait integration\n\t\t\t\t\t\t\t\t.client(t.profile)\n\t\t\t\t\t\t\t\t.updatePullRequest(t.owner, t.repo, pr, object(input.patch), ctx.signal);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\t\t\t\tawait reconcileComment(\n\t\t\t\t\t\t\t\tclient.listIssueComments(t.owner, t.repo, pr, ctx.signal),\n\t\t\t\t\t\t\t\t`<!-- leitwerk-write:${ctx.process.id}:${key} -->`,\n\t\t\t\t\t\t\t\t() => stringArg(input, \"body\"),\n\t\t\t\t\t\t\t\t(body) => client.addIssueComment(t.owner, t.repo, pr, body, ctx.signal),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn { owner: t.owner, repo: t.repo, pullRequestNumber: pr };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t},\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\";\nexport const resolveGitHubProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"github\");\n"],"mappings":";;;;;;;AACA,SAAS,4BAA0D;;;ACDnE,SAAS,6BAA6B;AAU/B,IAAM,oBAAoB;AAAA,EAChC;AACD;;;ACZA,SAAS,mBAAAA,wBAAuB;AAEhC,SAAS,kBAAk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AClC,sBAAoB,KAAK,aAAa,KAAK,cAA0C;AACrF,SAAO,qBAAqB,MAAM,aAAa,OAAO;AACvD;","names":["asUnknownRecord","createPollSchedule","sameSubscription","parse","sameSubscription","asUnknownRecord","value","createPollSchedule","key"]}
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 { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport type { CoreServerSetupDeps } from \"@leitwerk-dev/process-sdk\";\nimport { conflictEvidence, createConflictReporter } from \"@leitwerk-dev/repository-rebase\";\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 {\n\tdefineExternalActionSource,\n\ttype ExternalEventDescription,\n} from \"@leitwerk-dev/process-sdk\";\nimport { describeConflict } from \"@leitwerk-dev/repository-rebase\";\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,mBAAAA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C1C;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 +1 @@
1
- {"version":3,"file":"issue-provider.d.ts","sourceRoot":"","sources":["../src/issue-provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAExB,iBAAiB,IAAI,2BAA2B,EAMhD,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAwBzD,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAEvC,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,IAyNtB,QAAQ,UAAU,CAAC,OAAO,eAAe,CAAC,mBAkBxD"}
1
+ {"version":3,"file":"issue-provider.d.ts","sourceRoot":"","sources":["../src/issue-provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAExB,iBAAiB,IAAI,2BAA2B,EAMhD,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAwBzD,OAAO,EAAE,2BAA2B,EAAE,CAAC;AAEvC,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,IAkNtB,QAAQ,UAAU,CAAC,OAAO,eAAe,CAAC,mBAkBxD"}
@@ -1,19 +1,31 @@
1
1
  import { type RepositoryIssueWatcherConfig } from "@leitwerk-dev/process-sdk";
2
2
  import type { GitHubIssue, GitHubRepository } from "./client.js";
3
+ /** @public */
3
4
  export interface GitHubIssueWatcherConfig extends RepositoryIssueWatcherConfig {
4
5
  }
6
+ /** @public */
5
7
  export interface GitHubIssueWatcherEvent {
8
+ /** @public */
6
9
  authorization: {
10
+ /** @internal */
7
11
  actor: string;
12
+ /** @internal */
8
13
  eventId: number;
9
14
  };
15
+ /** @public */
10
16
  profile: string;
17
+ /** @public */
11
18
  repository: GitHubRepository;
19
+ /** @public */
12
20
  issue: GitHubIssue;
21
+ /** @public */
13
22
  labels: {
23
+ /** @public */
14
24
  trigger: string;
25
+ /** @public */
15
26
  done: string;
16
27
  };
17
28
  }
29
+ /** @public */
18
30
  export declare const githubIssueWatcherSource: import("@leitwerk-dev/process-sdk").ProcessWatcherSource<GitHubIssueWatcherConfig, GitHubIssueWatcherEvent>;
19
31
  //# sourceMappingURL=issue-watcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issue-watcher.d.ts","sourceRoot":"","sources":["../src/issue-watcher.ts"],"names":[],"mappings":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,wBAAwB,6GAQnC,CAAC"}
@@ -1,22 +1,6 @@
1
- import { type ExternalSourceArmingLike, type ExternalSourceServiceLike } from "@leitwerk-dev/process-sdk";
1
+ import { type ExternalSourceServiceLike } from "@leitwerk-dev/process-sdk";
2
2
  export declare function githubPollReporter(sources: ExternalSourceServiceLike, result: {
3
3
  created: string[];
4
4
  errors: string[];
5
- }): {
6
- fire(armed: Parameters<(armed: {
7
- id: string;
8
- instanceId: string;
9
- generation?: string | undefined;
10
- }, event: Record<string, unknown>, mergeKey: string) => Promise<boolean>>[0], event: Record<string, unknown>, mergeKey: string): Promise<boolean>;
11
- observe(armed: Parameters<(armed: {
12
- id: string;
13
- instanceId: string;
14
- generation?: string | undefined;
15
- }, input: Pick<import("@leitwerk-dev/process-sdk").ExternalObservationInput, "observation" | "refreshError">) => Promise<import("@leitwerk-dev/process-sdk").ActionExecutionResultLike> | undefined>[0], input: Parameters<(armed: {
16
- id: string;
17
- instanceId: string;
18
- generation?: string | undefined;
19
- }, input: Pick<import("@leitwerk-dev/process-sdk").ExternalObservationInput, "observation" | "refreshError">) => Promise<import("@leitwerk-dev/process-sdk").ActionExecutionResultLike> | undefined>[1]): Promise<import("@leitwerk-dev/process-sdk").ActionExecutionResultLike> | undefined;
20
- poll(kind: string, read: (armed: ExternalSourceArmingLike) => Promise<void>): Promise<void>;
21
- };
5
+ }): import("@leitwerk-dev/process-sdk").ExternalSourcePollReporter;
22
6
  //# sourceMappingURL=poll-report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"poll-report.d.ts","sourceRoot":"","sources":["../src/poll-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,MAAM,2BAA2B,CAAC;AAWnC,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE;gBAetC,UAAU;;;;6EAAoB,CAAC,CAAC,CAAC,SACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACpB,MAAM;mBAMT,UAAU;;;;wMAAuB,CAAC,CAAC,CAAC,SACpC,UAAU;;;;wMAAuB,CAAC,CAAC,CAAC;;EAK7C"}
1
+ {"version":3,"file":"poll-report.d.ts","sourceRoot":"","sources":["../src/poll-report.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,yBAAyB,EAC9B,MAAM,2BAA2B,CAAC;AAUnC,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,EAClC,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,kEAa/C"}
@@ -2,5 +2,7 @@ import type { CoreServerSetupDeps } from "@leitwerk-dev/process-sdk";
2
2
  import type { GitHubIntegration } from "./capability.js";
3
3
  export declare function createGitHubProvider(deps: CoreServerSetupDeps, integration: GitHubIntegration, options?: {
4
4
  now?: () => number;
5
- }): import("@leitwerk-dev/process-sdk").PollingHandleLike<import("@leitwerk-dev/watcher-utils").PollResult>;
5
+ }): {
6
+ poll(): Promise<import("@leitwerk-dev/watcher-utils").PollResult>;
7
+ };
6
8
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA2CzD,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO,2GAqKpC"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAGrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AA2CzD,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO;;EAqKpC"}
@@ -0,0 +1,192 @@
1
+ import { type ExtensionToolFixture } from "@leitwerk-dev/test-support/process";
2
+ import type { GitHubPullRequest } from "../client.js";
3
+ export declare function toolFixtureInput(id?: string): ExtensionToolFixture;
4
+ export declare const pullRequestArgs: {
5
+ projectKey: string;
6
+ owner: string;
7
+ repo: string;
8
+ profile: string;
9
+ title: string;
10
+ body: string;
11
+ head: string;
12
+ base: string;
13
+ };
14
+ /** Stateful provider boundary, with no Git, filesystem, or network. Unexpected calls fail closed. */
15
+ export declare function toolFixture(): Promise<{
16
+ pulls: GitHubPullRequest[];
17
+ comments: {
18
+ body: string;
19
+ }[];
20
+ requests: {
21
+ method: string;
22
+ owner: string;
23
+ repo: string;
24
+ }[];
25
+ profiles: string[];
26
+ failure: {
27
+ create: "none" | "before" | "after";
28
+ comment: boolean;
29
+ };
30
+ test: {
31
+ listToolDestinations(name: string, actor: import("@leitwerk-dev/domain").Actor): Promise<{
32
+ readonly destinations: readonly {
33
+ readonly id: string;
34
+ readonly displayName: string;
35
+ readonly group?: string | undefined;
36
+ readonly description?: string | undefined;
37
+ }[];
38
+ readonly warnings?: readonly string[] | undefined;
39
+ }>;
40
+ resolveToolDestination(name: string, destinationId: string, actor: import("@leitwerk-dev/domain").Actor): Promise<{
41
+ readonly summary: {
42
+ readonly id: string;
43
+ readonly displayName: string;
44
+ readonly group?: string | undefined;
45
+ readonly description?: string | undefined;
46
+ };
47
+ readonly data: unknown;
48
+ readonly agentContext?: string | undefined;
49
+ }>;
50
+ validateToolDestination(name: string, snapshot: import("@leitwerk-dev/process-sdk").TicketCreationDestinationSnapshot): Promise<void>;
51
+ describeTools(): readonly {
52
+ readonly name: string;
53
+ readonly description: string;
54
+ readonly parameters: {
55
+ readonly [x: string]: unknown;
56
+ };
57
+ }[];
58
+ writeReceipts(): readonly {
59
+ readonly instanceId: string;
60
+ readonly writeType: string;
61
+ readonly dedupKey: string;
62
+ readonly metadata?: unknown;
63
+ }[];
64
+ callTool: (name: string, args: Record<string, unknown>, fixture?: ExtensionToolFixture) => Promise<unknown>;
65
+ emit(type: string, event: unknown): Promise<void>;
66
+ close: () => Promise<void>;
67
+ process<TParams, TState>(definition: import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<TParams, TState>, initial?: import("@leitwerk-dev/test-support/process").ExtensionProcessFixture<TParams, TState>): {
68
+ describe(): import("@leitwerk-dev/test-support/process").TestObservation<import("@leitwerk-dev/test-support/process").ExtensionProcessDescription>;
69
+ resolveLaunch(id: string, input: Record<string, unknown>): Promise<{
70
+ readonly ok: false;
71
+ readonly errors: readonly {
72
+ readonly code: string;
73
+ readonly message: string;
74
+ readonly fieldId?: string | undefined;
75
+ }[];
76
+ } | {
77
+ readonly ok: true;
78
+ readonly launchConfig: {
79
+ readonly processId: string;
80
+ readonly params: import("@leitwerk-dev/test-support/process").TestObservation<TParams>;
81
+ readonly startTurnId?: (import("@leitwerk-dev/domain").TurnId | null) | undefined;
82
+ readonly title?: string | null | undefined;
83
+ readonly titleSourceFields?: readonly {
84
+ readonly label: string;
85
+ readonly value: string;
86
+ }[] | undefined;
87
+ readonly externalId?: string | null | undefined;
88
+ readonly externalUrl?: string | null | undefined;
89
+ readonly metadata?: {
90
+ readonly [x: string]: unknown;
91
+ } | null | undefined;
92
+ readonly defaultModelProfileId?: string | null | undefined;
93
+ readonly turnConfigs?: {
94
+ readonly [x: string]: {
95
+ readonly modelProfileId?: string | null | undefined;
96
+ };
97
+ } | undefined;
98
+ readonly skillIds?: readonly string[] | undefined;
99
+ readonly projects?: readonly {
100
+ readonly key: string;
101
+ readonly repoLocator: string;
102
+ readonly baseBranch: string;
103
+ readonly workBranch?: string | null | undefined;
104
+ readonly externalId?: string | null | undefined;
105
+ readonly externalUrl?: string | null | undefined;
106
+ readonly metadata?: {
107
+ readonly [x: string]: unknown;
108
+ } | null | undefined;
109
+ }[] | undefined;
110
+ };
111
+ }>;
112
+ prepareRelaunch(id: string, previousInput: Record<string, unknown>): Promise<{
113
+ readonly [x: string]: unknown;
114
+ }>;
115
+ resolveWatcherLaunch(id: string, event: unknown, config: unknown): Promise<{
116
+ readonly processId: string;
117
+ readonly params: import("@leitwerk-dev/test-support/process").TestObservation<TParams>;
118
+ readonly startTurnId?: (import("@leitwerk-dev/domain").TurnId | null) | undefined;
119
+ readonly title?: string | null | undefined;
120
+ readonly titleSourceFields?: readonly {
121
+ readonly label: string;
122
+ readonly value: string;
123
+ }[] | undefined;
124
+ readonly externalId?: string | null | undefined;
125
+ readonly externalUrl?: string | null | undefined;
126
+ readonly metadata?: {
127
+ readonly [x: string]: unknown;
128
+ } | null | undefined;
129
+ readonly defaultModelProfileId?: string | null | undefined;
130
+ readonly turnConfigs?: {
131
+ readonly [x: string]: {
132
+ readonly modelProfileId?: string | null | undefined;
133
+ };
134
+ } | undefined;
135
+ readonly skillIds?: readonly string[] | undefined;
136
+ readonly projects?: readonly {
137
+ readonly key: string;
138
+ readonly repoLocator: string;
139
+ readonly baseBranch: string;
140
+ readonly workBranch?: string | null | undefined;
141
+ readonly externalId?: string | null | undefined;
142
+ readonly externalUrl?: string | null | undefined;
143
+ readonly metadata?: {
144
+ readonly [x: string]: unknown;
145
+ } | null | undefined;
146
+ }[] | undefined;
147
+ } | null>;
148
+ evaluateTurn(id: string, options?: {
149
+ responses?: readonly import("@leitwerk-dev/test-support/process").ExtensionTurnResponse[];
150
+ fixture?: import("@leitwerk-dev/test-support/process").ExtensionProcessFixture<TParams, TState>;
151
+ }): Promise<{
152
+ readonly prompts: readonly string[];
153
+ readonly tools: readonly {
154
+ readonly name: string;
155
+ readonly arguments: {
156
+ readonly [x: string]: unknown;
157
+ };
158
+ }[];
159
+ readonly requestedTools: readonly string[];
160
+ readonly progress: readonly {
161
+ readonly title: string;
162
+ readonly summary?: string | undefined;
163
+ readonly steps: readonly {
164
+ readonly id: string;
165
+ readonly label: string;
166
+ readonly status: import("@leitwerk-dev/domain").TurnProgressStepStatus;
167
+ readonly detail?: string | null | undefined;
168
+ }[];
169
+ readonly links?: readonly {
170
+ readonly id: string;
171
+ readonly label: string;
172
+ readonly url: string;
173
+ readonly kind?: "pull_request" | "merge_request" | "commit" | "pipeline" | "other" | undefined;
174
+ }[] | undefined;
175
+ }[];
176
+ readonly completed: readonly {
177
+ readonly outcome: string;
178
+ readonly params?: {
179
+ readonly [x: string]: unknown;
180
+ } | undefined;
181
+ readonly markdown?: string | null | undefined;
182
+ readonly resultSummary?: string | undefined;
183
+ }[];
184
+ readonly parked: readonly (string | undefined)[];
185
+ }>;
186
+ evaluateAction(id: string, input?: Record<string, unknown>, fixture?: import("@leitwerk-dev/test-support/process").ExtensionProcessFixture<TParams, TState>): Promise<import("@leitwerk-dev/test-support/process").TestObservation<import("@leitwerk-dev/test-support/process").ExtensionProcessEffects<TState>>>;
187
+ evaluateOutcome(id: string, outcome: import("@leitwerk-dev/test-support/process").ExtensionTurnResponse, fixture?: import("@leitwerk-dev/test-support/process").ExtensionProcessFixture<TParams, TState>): Promise<import("@leitwerk-dev/test-support/process").TestObservation<import("@leitwerk-dev/test-support/process").ExtensionProcessEffects<TState>>>;
188
+ };
189
+ };
190
+ execute(name: string, args: Record<string, unknown>, fixture?: ExtensionToolFixture): Promise<unknown>;
191
+ }>;
192
+ //# sourceMappingURL=tool-fixture.d.ts.map
@@ -0,0 +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,KA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