@leitwerk-dev/gitlab 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 (43) hide show
  1. package/README.md +45 -5
  2. package/dist/capability.d.ts +5 -1
  3. package/dist/capability.d.ts.map +1 -1
  4. package/dist/chunk-H4JCQNDY.js +1162 -0
  5. package/dist/chunk-H4JCQNDY.js.map +1 -0
  6. package/dist/client.d.ts +230 -3
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/delivery-tools.d.ts +4 -0
  9. package/dist/delivery-tools.d.ts.map +1 -0
  10. package/dist/external.d.ts +80 -5
  11. package/dist/external.d.ts.map +1 -1
  12. package/dist/index.d.ts +13 -14
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +40 -20
  15. package/dist/index.js.map +1 -1
  16. package/dist/issue-watcher.d.ts +42 -0
  17. package/dist/issue-watcher.d.ts.map +1 -0
  18. package/dist/preflight.d.ts +10 -0
  19. package/dist/preflight.d.ts.map +1 -0
  20. package/dist/selection.d.ts +11 -1
  21. package/dist/selection.d.ts.map +1 -1
  22. package/dist/setup.d.ts +11 -0
  23. package/dist/setup.d.ts.map +1 -0
  24. package/dist/testing.d.ts +43 -4
  25. package/dist/testing.d.ts.map +1 -1
  26. package/dist/testing.js +139 -1
  27. package/dist/testing.js.map +1 -1
  28. package/dist/tools.d.ts +35 -4
  29. package/dist/tools.d.ts.map +1 -1
  30. package/package.json +7 -6
  31. package/src/capability.ts +5 -1
  32. package/src/client.ts +392 -20
  33. package/src/delivery-tools.ts +226 -0
  34. package/src/external.ts +200 -8
  35. package/src/index.ts +42 -26
  36. package/src/issue-watcher.ts +152 -0
  37. package/src/preflight.ts +70 -0
  38. package/src/selection.ts +19 -3
  39. package/src/setup.ts +22 -0
  40. package/src/testing.ts +161 -7
  41. package/src/tools.ts +106 -54
  42. package/dist/chunk-5GBBPAG5.js +0 -656
  43. package/dist/chunk-5GBBPAG5.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts","../src/preflight.ts","../src/capability.ts","../src/tools.ts","../src/selection.ts","../src/issue-watcher.ts","../src/external.ts","../src/setup.ts","../src/delivery-tools.ts"],"sourcesContent":["import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport { repositoryHttpsUrl } from \"@leitwerk-dev/process-sdk\";\nimport { preflightGitLabRepository } from \"./preflight.js\";\n\n/** @internal */\nexport interface GitLabProfile {\n\t/** @internal */\n\tbaseUrl: string;\n\t/** @internal */\n\ttoken: string;\n\t/** @internal */\n\tgitIdentity?: {\n\t\t/** @internal */\n\t\tname: string;\n\t\t/** @internal */\n\t\temail: string;\n\t};\n}\n/** @public */\nexport interface GitLabProject {\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tpath_with_namespace: string;\n\t/** @public */\n\thttp_url_to_repo: string;\n\t/** @public */\n\tweb_url: string;\n\t/** @internal */\n\tdefault_branch: string;\n\t/** @public */\n\tarchived?: boolean;\n\t/** @internal */\n\tpermissions?: {\n\t\t/** @internal */\n\t\tproject_access?: {\n\t\t\t/** @internal */\n\t\t\taccess_level: number;\n\t\t} | null;\n\t\t/** @internal */\n\t\tgroup_access?: {\n\t\t\t/** @internal */\n\t\t\taccess_level: number;\n\t\t} | null;\n\t};\n}\n/** @internal */\nexport interface GitLabGroup {\n\t/** @internal */\n\tid: number;\n\t/** @internal */\n\tfull_path: string;\n}\n/** @public */\nexport interface GitLabIssue {\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\tproject_id: number;\n\t/** @public */\n\ttitle: string;\n\t/** @public */\n\tdescription: string | null;\n\t/** @public */\n\tweb_url: string;\n\t/** @public */\n\tstate: string;\n\t/** @public */\n\tlabels: string[];\n}\n/** @public */\nexport interface GitLabMergeRequest {\n\t/** @public */\n\tdetailed_merge_status?: string;\n\t/** @public */\n\thas_conflicts?: boolean;\n\t/** @public */\n\tmerge_status?: string;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\tproject_id: number;\n\t/** @public */\n\tsource_project_id: number;\n\t/** @public */\n\ttarget_project_id: number;\n\t/** @public */\n\ttitle: string;\n\t/** @public */\n\tdescription: string | null;\n\t/** @public */\n\tstate: string;\n\t/** @public */\n\tlabels: string[];\n\t/** @public */\n\tsha: string;\n\t/** @public */\n\tsource_branch: string;\n\t/** @public */\n\ttarget_branch: string;\n\t/** @public */\n\tweb_url: string;\n\t/** @internal */\n\tmerge_commit_sha?: string | null;\n\t/** @internal */\n\tdiff_refs?: {\n\t\t/** @internal */\n\t\tbase_sha: string;\n\t\t/** @internal */\n\t\thead_sha: string;\n\t\t/** @internal */\n\t\tstart_sha: string;\n\t};\n}\n/** @public */\nexport interface GitLabCommit {\n\t/** @public */\n\tid: string;\n\t/** @internal */\n\tparent_ids: string[];\n\t/** @internal */\n\tmessage: string;\n\t/** @internal */\n\tweb_url?: string;\n}\n/** @public */\nexport interface GitLabBranch {\n\t/** @internal */\n\tname: string;\n\t/** @public */\n\tcan_push: boolean;\n\t/** @internal */\n\tprotected: boolean;\n\t/** @public */\n\tcommit: GitLabCommit;\n}\n/** @public */\nexport interface GitLabPipeline {\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tproject_id: number;\n\t/** @public */\n\tsha: string;\n\t/** @public */\n\tref: string;\n\t/** @public */\n\tstatus: string;\n\t/** @internal */\n\tsource?: string;\n\t/** @public */\n\tweb_url: string;\n}\n/** @public */\nexport interface GitLabJob {\n\t/** @internal */\n\tid: number;\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tstatus: string;\n\t/** @public */\n\tweb_url: string;\n\t/** @public */\n\tfailure_reason?: string;\n}\n/** @public */\nexport interface GitLabDiff {\n\t/** @public */\n\told_path: string;\n\t/** @public */\n\tnew_path: string;\n\t/** @public */\n\tdiff: string;\n\t/** @public */\n\tnew_file: boolean;\n\t/** @public */\n\tdeleted_file: boolean;\n\t/** @public */\n\trenamed_file: boolean;\n}\n/** @public */\nexport interface GitLabNote {\n\t/** @internal */\n\tid: number;\n\t/** @public */\n\tbody: string;\n}\n/** @public */\nexport interface GitLabNoteReaction {\n\t/** @public */\n\tid: number;\n\t/** @internal */\n\tname: string;\n\t/** @internal */\n\tuser: {\n\t\t/** @internal */\n\t\tusername: string;\n\t};\n}\n/** @public */\nexport interface GitLabFeedback {\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tdiscussionId: string;\n\t/** @public */\n\tbody: string;\n\t/** @public */\n\tauthor: string;\n\t/** @public */\n\tcreatedAt: string;\n\t/** @public */\n\tpath?: string;\n\t/** @public */\n\tline?: number;\n}\n/** @internal */\nexport interface GitLabDiscussion {\n\t/** @internal */\n\tid: string;\n\t/** @internal */\n\tnotes: (GitLabNote & {\n\t\t/** @internal */\n\t\tsystem: boolean;\n\t\t/** @internal */\n\t\tcreated_at: string;\n\t\t/** @internal */\n\t\tauthor: {\n\t\t\t/** @internal */\n\t\t\tusername: string;\n\t\t\t/** @internal */\n\t\t\tbot?: boolean;\n\t\t};\n\t\t/** @internal */\n\t\tresolved?: boolean;\n\t\t/** @internal */\n\t\tposition?: {\n\t\t\t/** @internal */\n\t\t\tnew_path?: string;\n\t\t\t/** @internal */\n\t\t\told_path?: string;\n\t\t\t/** @internal */\n\t\t\tnew_line?: number;\n\t\t\t/** @internal */\n\t\t\told_line?: number;\n\t\t};\n\t})[];\n}\n/** @public */\nexport interface GitLabIdentity {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\temail: string;\n\t/** @public */\n\tusername: string;\n}\n/** @public */\nexport interface GitLabObservation {\n\t/** @public */\n\tmr: GitLabMergeRequest;\n\t/** @public */\n\tpipeline: GitLabPipeline | null;\n\t/** @public */\n\ttargetHead?: string;\n}\n\n/** @public */\nexport function gitLabMergeabilityPending(mr: GitLabMergeRequest): boolean {\n\treturn [\"checking\", \"unchecked\", \"preparing\"].includes(\n\t\tmr.detailed_merge_status ?? mr.merge_status ?? \"\",\n\t);\n}\n\n/** @public Only actionable Git conflicts/rebase requirements, not approvals or CI gates. */\nexport function gitLabMergeRepairReason(mr: GitLabMergeRequest): \"conflict\" | \"rebase\" | null {\n\tif (gitLabMergeabilityPending(mr)) return null;\n\tif (mr.has_conflicts || mr.detailed_merge_status === \"conflict\") return \"conflict\";\n\treturn mr.detailed_merge_status === \"need_rebase\" ? \"rebase\" : null;\n}\n\n/** @internal */\nexport class GitLabError extends Error {\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly status: number,\n\t\t/** @internal */\n\t\treadonly retryable: boolean,\n\t) {\n\t\tsuper(\n\t\t\t`GitLab request failed (${status || \"network unavailable\"})${retryable ? \"; retryable\" : \"; check profile and project access\"}`,\n\t\t);\n\t}\n}\n/** @internal */\nexport function parseGitLabProfiles(raw: unknown): Map<string, GitLabProfile> {\n\tconst profiles = new Map<string, GitLabProfile>();\n\tfor (const [name, value] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(raw)?.profiles) ?? {},\n\t)) {\n\t\tconst item = asUnknownRecord(value) ?? {};\n\t\tconst baseUrl = typeof item.base_url === \"string\" ? item.base_url.replace(/\\/+$/, \"\") : \"\";\n\t\tconst url = repositoryHttpsUrl(`${baseUrl}/` === \"/\" ? \"\" : `${baseUrl}/repository`);\n\t\tif (url.origin !== baseUrl)\n\t\t\tthrow new Error(`GitLab profile '${name}' requires an HTTPS origin base_url`);\n\t\tconst configuredToken = typeof item.token === \"string\" ? item.token : \"\";\n\t\tconst token = configuredToken.startsWith(\"env:\")\n\t\t\t? (process.env[configuredToken.slice(4)] ?? \"\")\n\t\t\t: configuredToken;\n\t\tif (!token || /[\\r\\n\\0]/.test(token))\n\t\t\tthrow new Error(`GitLab profile '${name}' requires a token`);\n\t\tconst identity = asUnknownRecord(item.git_identity);\n\t\tif (\n\t\t\tidentity &&\n\t\t\t[identity.name, identity.email].some(\n\t\t\t\t(v) => typeof v !== \"string\" || !v.trim() || /[\\r\\n<>]/.test(v),\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`GitLab profile '${name}' requires a valid git_identity name and email`);\n\t\tprofiles.set(name, {\n\t\t\tbaseUrl,\n\t\t\ttoken,\n\t\t\t...(identity\n\t\t\t\t? { gitIdentity: { name: String(identity.name), email: String(identity.email) } }\n\t\t\t\t: {}),\n\t\t});\n\t}\n\treturn profiles;\n}\nconst projectPath = (id: number | string) => `/projects/${encodeURIComponent(id)}`;\nconst mrPath = (id: number, iid: number) => `${projectPath(id)}/merge_requests/${iid}`;\n\n/** GitLab v4 API. Errors deliberately omit response bodies, headers and tokens. */\n/** @public */\nexport class GitLabClient {\n\t/** @public */\n\treadonly baseUrl: string;\n\treadonly #profile: GitLabProfile;\n\treadonly #fetch: typeof fetch;\n\treadonly #sleep: (ms: number) => Promise<unknown>;\n\t/** @internal */\n\tconstructor(\n\t\tprofile: GitLabProfile,\n\t\t/** @public */\n\t\t/** @public */\n\t\toptions: {\n\t\t\t/** @internal */\n\t\t\tfetch?: typeof fetch;\n\t\t\t/** @internal */\n\t\t\tsleep?: (ms: number) => Promise<unknown>;\n\t\t} = {},\n\t) {\n\t\tif (repositoryHttpsUrl(`${profile.baseUrl}/repository`).origin !== profile.baseUrl)\n\t\t\tthrow new Error(\"GitLab requires an HTTPS origin baseUrl\");\n\t\tif (!profile.token || /[\\r\\n\\0]/.test(profile.token))\n\t\t\tthrow new Error(\"GitLab requires a valid token\");\n\t\tthis.#profile = profile;\n\t\tthis.baseUrl = profile.baseUrl;\n\t\tthis.#fetch = options.fetch ?? fetch;\n\t\tthis.#sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n\t}\n\tprivate async response(\n\t\tpath: string,\n\t\tsignal?: AbortSignal,\n\t\tbody?: unknown,\n\t\tmethod?: string,\n\t): Promise<Response> {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\tlet response: Response;\n\t\t\ttry {\n\t\t\t\tresponse = await this.#fetch(`${this.baseUrl}/api/v4${path}`, {\n\t\t\t\t\tmethod: method ?? (body === undefined ? \"GET\" : \"POST\"),\n\t\t\t\t\tredirect: \"error\",\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"PRIVATE-TOKEN\": this.#profile.token,\n\t\t\t\t\t\tAccept: \"application/json\",\n\t\t\t\t\t\t...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n\t\t\t\t\t},\n\t\t\t\t\tsignal: signal\n\t\t\t\t\t\t? AbortSignal.any([signal, AbortSignal.timeout(30_000)])\n\t\t\t\t\t\t: AbortSignal.timeout(30_000),\n\t\t\t\t\t...(body === undefined ? {} : { body: JSON.stringify(body) }),\n\t\t\t\t});\n\t\t\t} catch {\n\t\t\t\tif (signal?.aborted) throw new GitLabError(0, true);\n\t\t\t\tif (body !== undefined || attempt >= 2) throw new GitLabError(0, true);\n\t\t\t\tawait this.#sleep(1_000 * 2 ** attempt);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (response.ok) return response;\n\t\t\tconst retryable =\n\t\t\t\tresponse.status === 429 || response.status >= 500 || response.status === 408;\n\t\t\tawait response.body?.cancel();\n\t\t\tif (!retryable || body !== undefined || attempt >= 2)\n\t\t\t\tthrow new GitLabError(response.status, retryable);\n\t\t\tconst seconds = Number(response.headers.get(\"retry-after\"));\n\t\t\tawait this.#sleep(Math.min(30_000, seconds > 0 ? seconds * 1_000 : 1_000 * 2 ** attempt));\n\t\t}\n\t}\n\tprivate async request<T>(\n\t\tpath: string,\n\t\tsignal?: AbortSignal,\n\t\tbody?: unknown,\n\t\tmethod?: string,\n\t): Promise<T> {\n\t\treturn this.json<T>(await this.response(path, signal, body, method));\n\t}\n\tprivate async json<T>(response: Response): Promise<T> {\n\t\ttry {\n\t\t\treturn (await response.json()) as T;\n\t\t} catch {\n\t\t\tthrow new GitLabError(502, true);\n\t\t}\n\t}\n\tprivate async pages<T>(path: string, signal?: AbortSignal): Promise<T[]> {\n\t\tconst rows: T[] = [];\n\t\tlet page = 1;\n\t\tfor (let n = 0; n < 10_000; n++) {\n\t\t\tconst response = await this.response(\n\t\t\t\t`${path}${path.includes(\"?\") ? \"&\" : \"?\"}per_page=100&page=${page}`,\n\t\t\t\tsignal,\n\t\t\t);\n\t\t\tconst batch = await this.json<T[]>(response);\n\t\t\tif (!Array.isArray(batch)) throw new Error(\"Invalid GitLab list response\");\n\t\t\trows.push(...batch);\n\t\t\tconst next = response.headers.get(\"x-next-page\");\n\t\t\tif (next === \"\" || (next === null && batch.length < 100)) return rows;\n\t\t\tconst nextPage = next === null ? page + 1 : Number(next);\n\t\t\tif (!Number.isInteger(nextPage) || nextPage <= page)\n\t\t\t\tthrow new Error(\"Invalid GitLab pagination\");\n\t\t\tpage = nextPage;\n\t\t}\n\t\tthrow new Error(\"GitLab pagination limit exceeded; discovery incomplete\");\n\t}\n\t/** @public */\n\tlistIssues(id: number, signal?: AbortSignal): Promise<GitLabIssue[]> {\n\t\treturn this.pages(`${projectPath(id)}/issues?state=opened&scope=all`, signal);\n\t}\n\t/** @public */\n\tgetIssue(id: number, iid: number, signal?: AbortSignal): Promise<GitLabIssue> {\n\t\treturn this.request(`${projectPath(id)}/issues/${iid}`, signal);\n\t}\n\t/** @public */\n\tupdateIssue(\n\t\tid: number,\n\t\tiid: number,\n\t\t/** @public */\n\t\t/** @public */\n\t\tpatch: {\n\t\t\t/** @public */\n\t\t\tlabels?: string;\n\t\t\t/** @public */\n\t\t\tstate_event?: \"close\";\n\t\t},\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabIssue> {\n\t\treturn this.request(`${projectPath(id)}/issues/${iid}`, signal, patch, \"PUT\");\n\t}\n\t/** @public */\n\tlistIssueNotes(id: number, iid: number, signal?: AbortSignal): Promise<GitLabNote[]> {\n\t\treturn this.pages(`${projectPath(id)}/issues/${iid}/notes`, signal);\n\t}\n\t/** @public */\n\taddIssueNote(id: number, iid: number, body: string, signal?: AbortSignal): Promise<GitLabNote> {\n\t\treturn this.request(`${projectPath(id)}/issues/${iid}/notes`, signal, { body });\n\t}\n\t/** @public */\n\t/** @public */\n\tlistLabels(\n\t\tid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<\n\t\tArray<{\n\t\t\t/** @public */ name: string;\n\t\t}>\n\t> {\n\t\treturn this.pages(`${projectPath(id)}/labels`, signal);\n\t}\n\t/** @public */\n\t/** @public */\n\tcreateLabel(\n\t\tid: number,\n\t\tname: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @public */ name: string;\n\t}> {\n\t\treturn this.request(`${projectPath(id)}/labels`, signal, { name, color: \"#2da44e\" });\n\t}\n\t/** @public */\n\tlistBranchMergeRequests(\n\t\tid: number,\n\t\tsource: string,\n\t\ttarget: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabMergeRequest[]> {\n\t\treturn this.pages(\n\t\t\t`${projectPath(id)}/merge_requests?state=all&source_branch=${encodeURIComponent(source)}&target_branch=${encodeURIComponent(target)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @public */\n\tcreateMergeRequest(\n\t\tid: number,\n\t\t/** @public */\n\t\t/** @public */\n\t\tinput: {\n\t\t\t/** @public */\n\t\t\ttitle: string;\n\t\t\t/** @public */\n\t\t\tdescription: string;\n\t\t\t/** @public */\n\t\t\tsource_branch: string;\n\t\t\t/** @public */\n\t\t\ttarget_branch: string;\n\t\t},\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabMergeRequest> {\n\t\treturn this.request(`${projectPath(id)}/merge_requests`, signal, {\n\t\t\t...input,\n\t\t\tremove_source_branch: false,\n\t\t});\n\t}\n\t/** @public */\n\tasync preflightRepository(\n\t\tprojectId: number,\n\t\tbaseBranch: string,\n\t\tworkBranch: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<void> {\n\t\tconst project = await this.getProject(projectId, signal);\n\t\tawait preflightGitLabRepository({\n\t\t\turl: project.http_url_to_repo,\n\t\t\torigin: this.baseUrl,\n\t\t\ttoken: this.#profile.token,\n\t\t\tbaseBranch,\n\t\t\tworkBranch,\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @public */\n\tgetProject(id: number | string, signal?: AbortSignal): Promise<GitLabProject> {\n\t\treturn this.request(projectPath(id), signal);\n\t}\n\t/** @internal */\n\tlistProjects(signal?: AbortSignal): Promise<GitLabProject[]> {\n\t\treturn this.pages(\"/projects?archived=false\", signal);\n\t}\n\t/** @internal */\n\tgetGroup(id: number | string, signal?: AbortSignal): Promise<GitLabGroup> {\n\t\treturn this.request(`/groups/${encodeURIComponent(id)}`, signal);\n\t}\n\t/** @internal */\n\tlistGroupProjects(id: number | string, signal?: AbortSignal): Promise<GitLabProject[]> {\n\t\treturn this.pages(\n\t\t\t`/groups/${encodeURIComponent(id)}/projects?include_subgroups=true&with_shared=false&archived=false`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @public */\n\tlistMergeRequests(\n\t\tid: number,\n\t\tlabel: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabMergeRequest[]> {\n\t\treturn this.pages(\n\t\t\t`${projectPath(id)}/merge_requests?state=opened&labels=${encodeURIComponent(label)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\tgetMergeRequest(id: number, iid: number, signal?: AbortSignal): Promise<GitLabMergeRequest> {\n\t\treturn this.request(mrPath(id, iid), signal);\n\t}\n\t/** @public */\n\tgetChanges(id: number, iid: number, signal?: AbortSignal): Promise<GitLabDiff[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/diffs`, signal);\n\t}\n\t/** @public */\n\tgetBranch(id: number, branch: string, signal?: AbortSignal): Promise<GitLabBranch> {\n\t\treturn this.request(\n\t\t\t`${projectPath(id)}/repository/branches/${encodeURIComponent(branch)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\tgetCommit(id: number, sha: string, signal?: AbortSignal): Promise<GitLabCommit> {\n\t\treturn this.request(`${projectPath(id)}/repository/commits/${encodeURIComponent(sha)}`, signal);\n\t}\n\t/** @internal */\n\tlistMergeRequestPipelines(\n\t\tid: number,\n\t\tiid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabPipeline[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/pipelines`, signal);\n\t}\n\t/** @internal */\n\tlistBranchPipelines(\n\t\tid: number,\n\t\tbranch: string,\n\t\tsha: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabPipeline[]> {\n\t\treturn this.pages(\n\t\t\t`${projectPath(id)}/pipelines?ref=${encodeURIComponent(branch)}&sha=${encodeURIComponent(sha)}&source=push`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\tgetPipeline(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabPipeline> {\n\t\treturn this.request(`${projectPath(id)}/pipelines/${pipeline}`, signal);\n\t}\n\t/** @public */\n\tlistFailedJobs(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabJob[]> {\n\t\treturn this.pages(\n\t\t\t`${projectPath(id)}/pipelines/${pipeline}/jobs?scope[]=failed&include_retried=false`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\tlistNotes(id: number, iid: number, signal?: AbortSignal): Promise<GitLabNote[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/notes`, signal);\n\t}\n\t/** @internal */\n\tgetDiscussion(\n\t\tid: number,\n\t\tiid: number,\n\t\tdiscussionId: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabDiscussion> {\n\t\treturn this.request(\n\t\t\t`${mrPath(id, iid)}/discussions/${encodeURIComponent(discussionId)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\treplyToDiscussion(\n\t\tid: number,\n\t\tiid: number,\n\t\tdiscussionId: string,\n\t\tbody: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabNote> {\n\t\treturn this.request(\n\t\t\t`${mrPath(id, iid)}/discussions/${encodeURIComponent(discussionId)}/notes`,\n\t\t\tsignal,\n\t\t\t{ body },\n\t\t);\n\t}\n\t/** @internal */\n\tlistNoteReactions(\n\t\tid: number,\n\t\tiid: number,\n\t\tnoteId: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabNoteReaction[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/notes/${noteId}/award_emoji`, signal);\n\t}\n\t/** @internal */\n\taddNoteReaction(\n\t\tid: number,\n\t\tiid: number,\n\t\tnoteId: number,\n\t\tname: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabNoteReaction> {\n\t\treturn this.request(`${mrPath(id, iid)}/notes/${noteId}/award_emoji`, signal, { name });\n\t}\n\t/** @public */\n\tasync listMergeRequestFeedback(\n\t\tid: number,\n\t\tiid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabFeedback[]> {\n\t\tconst discussions = await this.pages<GitLabDiscussion>(\n\t\t\t`${mrPath(id, iid)}/discussions`,\n\t\t\tsignal,\n\t\t);\n\t\tconst feedback: GitLabFeedback[] = [];\n\t\tfor (const discussion of discussions) {\n\t\t\tfor (const note of discussion.notes) {\n\t\t\t\tif (\n\t\t\t\t\tnote.system ||\n\t\t\t\t\tnote.resolved ||\n\t\t\t\t\tnote.author.bot ||\n\t\t\t\t\t/<!-- leitwerk:gitlab:[a-f0-9]{64} -->/.test(note.body) ||\n\t\t\t\t\t!note.body.trim() ||\n\t\t\t\t\t!Number.isFinite(Date.parse(note.created_at))\n\t\t\t\t)\n\t\t\t\t\tcontinue;\n\t\t\t\tconst position = note.position ?? discussion.notes[0]?.position;\n\t\t\t\tfeedback.push({\n\t\t\t\t\tid: note.id,\n\t\t\t\t\tdiscussionId: discussion.id,\n\t\t\t\t\tbody: note.body,\n\t\t\t\t\tauthor: note.author.username,\n\t\t\t\t\tcreatedAt: note.created_at,\n\t\t\t\t\t...(position\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tpath: position.new_path ?? position.old_path,\n\t\t\t\t\t\t\t\tline: position.new_line ?? position.old_line,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn feedback.sort((a, b) => a.id - b.id);\n\t}\n\t/** @internal */\n\taddNote(id: number, iid: number, body: string, signal?: AbortSignal): Promise<GitLabNote> {\n\t\treturn this.request(`${mrPath(id, iid)}/notes`, signal, { body });\n\t}\n\t/** @public */\n\tasync resolveGitIdentity(signal?: AbortSignal): Promise<GitLabIdentity> {\n\t\tconst user = await this.request<{\n\t\t\tname?: string;\n\t\t\tusername?: string;\n\t\t\temail?: string;\n\t\t\tcommit_email?: string;\n\t\t}>(\"/user\", signal);\n\t\tconst name = this.#profile.gitIdentity?.name ?? user.name;\n\t\tconst email = this.#profile.gitIdentity?.email ?? user.commit_email ?? user.email;\n\t\tif (!user.username || !name?.trim() || !email?.includes(\"@\") || /[\\r\\n<>]/.test(name + email))\n\t\t\tthrow new Error(\n\t\t\t\t\"GitLab bot Git identity is unavailable; configure git_identity on the profile\",\n\t\t\t);\n\t\treturn { name, email, username: user.username };\n\t}\n\t/** @public */\n\tasync getJobTrace(\n\t\tid: number,\n\t\tjob: number,\n\t\tmaxBytes = 65_536,\n\t\tsignal?: AbortSignal,\n\t\t/** @public */\n\t\t/** @public */\n\t): Promise<{\n\t\t/** @public */\n\t\ttext: string;\n\t\t/** @public */\n\t\ttruncated: boolean;\n\t}> {\n\t\tconst limit = Math.min(262_144, Math.max(1, Math.floor(maxBytes) || 65_536));\n\t\tconst response = await this.response(`${projectPath(id)}/jobs/${job}/trace`, signal);\n\t\tconst reader = response.body?.getReader();\n\t\tif (!reader) return { text: \"\", truncated: false };\n\t\tconst chunks: Uint8Array[] = [];\n\t\tlet size = 0;\n\t\tlet truncated = false;\n\t\ttry {\n\t\t\twhile (true) {\n\t\t\t\tconst item = await reader.read();\n\t\t\t\tif (item.done) break;\n\t\t\t\tconst take = Math.min(item.value.length, limit - size);\n\t\t\t\tchunks.push(item.value.slice(0, take));\n\t\t\t\tsize += take;\n\t\t\t\tif (size >= limit) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tawait reader.cancel();\n\t\t}\n\t\treturn { text: Buffer.concat(chunks).toString(\"utf8\"), truncated };\n\t}\n}\n/** @public */\nexport type GitLabClientLike = Pick<\n\tGitLabClient,\n\t| \"listIssues\"\n\t| \"getIssue\"\n\t| \"updateIssue\"\n\t| \"listIssueNotes\"\n\t| \"addIssueNote\"\n\t| \"listLabels\"\n\t| \"createLabel\"\n\t| \"listBranchMergeRequests\"\n\t| \"createMergeRequest\"\n\t| \"preflightRepository\"\n\t| \"addNote\"\n\t| \"addNoteReaction\"\n\t| \"baseUrl\"\n\t| \"getBranch\"\n\t| \"getChanges\"\n\t| \"getCommit\"\n\t| \"getDiscussion\"\n\t| \"getGroup\"\n\t| \"getJobTrace\"\n\t| \"getMergeRequest\"\n\t| \"getPipeline\"\n\t| \"getProject\"\n\t| \"listBranchPipelines\"\n\t| \"listFailedJobs\"\n\t| \"listGroupProjects\"\n\t| \"listMergeRequestFeedback\"\n\t| \"listMergeRequestPipelines\"\n\t| \"listMergeRequests\"\n\t| \"listNoteReactions\"\n\t| \"listNotes\"\n\t| \"listProjects\"\n\t| \"replyToDiscussion\"\n\t| \"resolveGitIdentity\"\n>;\n\n/** A pending current pipeline supersedes every older result. Synthetic merges must contain this source head. */\n/** @public */\nexport async function observeMergeRequest(\n\tclient: GitLabClientLike,\n\tprojectId: number,\n\tiid: number,\n\tsignal?: AbortSignal,\n): Promise<GitLabObservation> {\n\tconst mr = await client.getMergeRequest(projectId, iid, signal);\n\tif (mr.state !== \"opened\") return { mr, pipeline: null };\n\tconst targetHead = (await client.getBranch(mr.target_project_id, mr.target_branch, signal)).commit\n\t\t.id;\n\tconst associated = (await client.listMergeRequestPipelines(projectId, iid, signal)).sort(\n\t\t(a, b) => b.id - a.id,\n\t);\n\tfor (const candidate of associated) {\n\t\tconst id = candidate.project_id ?? projectId;\n\t\tlet matches = candidate.sha === mr.sha;\n\t\tif (\n\t\t\t!matches &&\n\t\t\t(candidate.ref === `refs/merge-requests/${iid}/merge` ||\n\t\t\t\tcandidate.sha === mr.merge_commit_sha)\n\t\t) {\n\t\t\tconst commit = await client.getCommit(id, candidate.sha, signal);\n\t\t\tmatches = commit.parent_ids.includes(mr.sha);\n\t\t}\n\t\tif (matches)\n\t\t\treturn { mr, targetHead, pipeline: await client.getPipeline(id, candidate.id, signal) };\n\t}\n\tconst candidates = await client.listBranchPipelines(\n\t\tmr.source_project_id,\n\t\tmr.source_branch,\n\t\tmr.sha,\n\t\tsignal,\n\t);\n\tconst latest = candidates\n\t\t.filter((p) => p.sha === mr.sha && p.ref === mr.source_branch && p.source === \"push\")\n\t\t.sort((a, b) => b.id - a.id)[0];\n\treturn {\n\t\tmr,\n\t\ttargetHead,\n\t\tpipeline: latest ? await client.getPipeline(mr.source_project_id, latest.id, signal) : null,\n\t};\n}\n","import { execFile } from \"node:child_process\";\nimport { mkdtemp, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { repositoryHttpsUrl } from \"@leitwerk-dev/process-sdk\";\n\nconst exec = promisify(execFile);\n/** Credentials stay in the child environment and never appear in URLs or error output. */\nexport async function preflightGitLabRepository(input: {\n\turl: string;\n\torigin: string;\n\ttoken: string;\n\tbaseBranch: string;\n\tworkBranch: string;\n\tsignal?: AbortSignal;\n}) {\n\tconst url = repositoryHttpsUrl(input.url);\n\tif (url.origin !== input.origin)\n\t\tthrow new Error(\"GitLab repository origin does not match its profile\");\n\tconst directory = await mkdtemp(join(tmpdir(), \"leitwerk-gitlab-preflight-\"));\n\ttry {\n\t\tconst askpass = join(directory, \"askpass\");\n\t\tawait writeFile(\n\t\t\taskpass,\n\t\t\t'#!/bin/sh\\ncase \"$1\" in *Username*) printf \"%s\\\\n\" oauth2;; *) printf \"%s\\\\n\" \"$LEITWERK_GITLAB_PREFLIGHT_TOKEN\";; esac\\n',\n\t\t\t{ mode: 0o700 },\n\t\t);\n\t\tconst env = {\n\t\t\t...process.env,\n\t\t\tGIT_CONFIG_NOSYSTEM: \"1\",\n\t\t\tGIT_CONFIG_GLOBAL: \"/dev/null\",\n\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\tGIT_ASKPASS: askpass,\n\t\t\tLEITWERK_GITLAB_PREFLIGHT_TOKEN: input.token,\n\t\t};\n\t\tconst git = (args: string[]) =>\n\t\t\texec(\"git\", [\"-c\", \"credential.helper=\", \"-c\", \"http.followRedirects=false\", ...args], {\n\t\t\t\tenv,\n\t\t\t\tsignal: input.signal,\n\t\t\t});\n\t\tawait git([\"check-ref-format\", `refs/heads/${input.baseBranch}`]);\n\t\tawait git([\"check-ref-format\", `refs/heads/${input.workBranch}`]);\n\t\tawait git([\"ls-remote\", \"--exit-code\", input.url, `refs/heads/${input.baseBranch}`]);\n\t\tawait git([\"init\", \"--quiet\", directory]);\n\t\tawait git([\n\t\t\t\"-C\",\n\t\t\tdirectory,\n\t\t\t\"fetch\",\n\t\t\t\"--quiet\",\n\t\t\t\"--depth=1\",\n\t\t\tinput.url,\n\t\t\t`refs/heads/${input.baseBranch}`,\n\t\t]);\n\t\tawait git([\n\t\t\t\"-C\",\n\t\t\tdirectory,\n\t\t\t\"push\",\n\t\t\t\"--dry-run\",\n\t\t\tinput.url,\n\t\t\t`FETCH_HEAD:refs/heads/${input.workBranch}`,\n\t\t]);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t\"GitLab HTTPS read/write admission failed; check repository access and write_repository scope\",\n\t\t);\n\t} finally {\n\t\tawait rm(directory, { recursive: true, force: true });\n\t}\n}\n","import {\n\tcreateCapabilityToken,\n\ttype RepositoryCredentialProject,\n\ttype RepositoryCredentialRequirement,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitLabClientLike } from \"./client.js\";\n/** @public */\nexport interface GitLabIntegration {\n\t/** @public */\n\tprofiles(): readonly string[];\n\t/** @public */\n\tclient(profile: string): GitLabClientLike;\n}\n/** @public */\nexport const gitlabIntegration = createCapabilityToken<GitLabIntegration>(\n\t\"@leitwerk-dev/gitlab.integration\",\n);\n/** Internal references are derived from the same profile as API access. @public */\nexport function gitlabRepositoryCredentials(\n\tprofile: string,\n\tprojects: readonly RepositoryCredentialProject[],\n): RepositoryCredentialRequirement[] {\n\treturn projects.map((project) => ({\n\t\tprojectKey: project.key,\n\t\tkind: \"git_https\",\n\t\tcredentialRef: `gitlab:${profile}`,\n\t}));\n}\n","import { createHash } from \"node:crypto\";\nimport type { ExternalWrites } from \"@leitwerk-dev/external-writes\";\n\nimport {\n\ttype IntegrationToolExecutionContext,\n\tnumberArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport { type GitLabClientLike, GitLabError, observeMergeRequest } from \"./client.js\";\n\nasync function existingRemote<T>(read: () => Promise<T>): Promise<T | null> {\n\ttry {\n\t\treturn await read();\n\t} catch (error) {\n\t\tif (error instanceof GitLabError && error.status === 404) return null;\n\t\tthrow error;\n\t}\n}\n/** @public */\nexport function resolveGitLabRepositoryBinding(\n\tctx: Pick<IntegrationToolExecutionContext, \"project\" | \"process\">,\n\t/** @public */\n\t/** @public */\n): {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\tprojectId: number;\n} {\n\tif (!ctx.project || ctx.project.instanceId !== ctx.process.id)\n\t\tthrow new Error(\"An authorized GitLab process project is required\");\n\tconst binding = ctx.project.metadata?.gitlab as\n\t\t| { profile?: unknown; projectId?: unknown }\n\t\t| undefined;\n\tif (\n\t\t!binding ||\n\t\ttypeof binding.profile !== \"string\" ||\n\t\t!binding.profile.trim() ||\n\t\ttypeof binding.projectId !== \"number\" ||\n\t\t!Number.isSafeInteger(binding.projectId) ||\n\t\tbinding.projectId <= 0\n\t)\n\t\tthrow new Error(\"Invalid GitLab project binding\");\n\treturn { profile: binding.profile, projectId: binding.projectId };\n}\n/** @public */\nexport function resolveGitLabBinding(\n\tctx: Pick<IntegrationToolExecutionContext, \"project\" | \"process\">,\n\t/** @public */\n\t/** @public */\n): {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\tprojectId: number;\n\t/** @public */\n\tiid: number;\n} {\n\tconst repository = resolveGitLabRepositoryBinding(ctx);\n\tconst iid = (ctx.project?.metadata?.gitlab as { iid?: unknown })?.iid;\n\tif (typeof iid !== \"number\" || !Number.isSafeInteger(iid) || iid <= 0)\n\t\tthrow new Error(\"Invalid GitLab project binding: a merge request is required\");\n\treturn { ...repository, iid };\n}\n/** @internal */\nexport async function ensureGitLabComment(input: {\n\t/** @internal */\n\tclient: GitLabClientLike;\n\t/** @internal */\n\twrites: ExternalWrites;\n\t/** @internal */\n\tinstanceId: string;\n\t/** @internal */\n\tprojectId: number;\n\t/** @internal */\n\tiid: number;\n\t/** @internal */\n\twriteKey: string;\n\t/** @internal */\n\tbody: string;\n\t/** @internal */\n\tdiscussionId?: string;\n\t/** @internal */\n\tsignal?: AbortSignal;\n\t/** @public */\n\t/** @public */\n}): Promise<{\n\t/** @internal */\n\tmarker: string;\n}> {\n\tconst { client, writes, instanceId, projectId, iid, writeKey, signal } = input;\n\tconst identity = [client.baseUrl, projectId, iid, instanceId, writeKey];\n\tif (input.discussionId) identity.push(input.discussionId);\n\tconst digest = createHash(\"sha256\").update(JSON.stringify(identity)).digest(\"hex\");\n\tconst marker = `<!-- leitwerk:gitlab:${digest} -->`;\n\tconst find = async () => {\n\t\tconst notes = input.discussionId\n\t\t\t? (await client.getDiscussion(projectId, iid, input.discussionId, signal)).notes\n\t\t\t: await client.listNotes(projectId, iid, signal);\n\t\treturn notes.find((note) => note.body.includes(marker));\n\t};\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.comment\", dedupKey: digest },\n\t\t{\n\t\t\treconcile: () => existingRemote(async () => (await find()) ?? null),\n\t\t\texecute: () => {\n\t\t\t\tconst body = `${input.body}\\n\\n${marker}`;\n\t\t\t\treturn input.discussionId\n\t\t\t\t\t? client.replyToDiscussion(projectId, iid, input.discussionId, body, signal)\n\t\t\t\t\t: client.addNote(projectId, iid, body, signal);\n\t\t\t},\n\t\t\ttoMetadata: (note) => ({ projectId, iid, noteId: note.id, marker }),\n\t\t},\n\t);\n\treturn { marker };\n}\n/** @public */\nexport async function ensureGitLabSeenReaction(input: {\n\t/** @public */\n\tclient: GitLabClientLike;\n\t/** @public */\n\twrites: ExternalWrites;\n\t/** @public */\n\tinstanceId: string;\n\t/** @internal */\n\tprojectId: number;\n\t/** @internal */\n\tiid: number;\n\t/** @public */\n\tnoteId: number;\n\t/** @public */\n\tsignal?: AbortSignal;\n}): Promise<void> {\n\tconst { client, writes, instanceId, projectId, iid, noteId, signal } = input;\n\tconst digest = createHash(\"sha256\")\n\t\t.update(JSON.stringify([client.baseUrl, projectId, iid, instanceId, \"eyes\", noteId]))\n\t\t.digest(\"hex\");\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.reaction\", dedupKey: digest },\n\t\t{\n\t\t\treconcile: () =>\n\t\t\t\texistingRemote(async () => {\n\t\t\t\t\tconst identity = await client.resolveGitIdentity(signal);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(await client.listNoteReactions(projectId, iid, noteId, signal)).find(\n\t\t\t\t\t\t\t(reaction) =>\n\t\t\t\t\t\t\t\treaction.name === \"eyes\" && reaction.user.username === identity.username,\n\t\t\t\t\t\t) ?? null\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\texecute: () => client.addNoteReaction(projectId, iid, noteId, \"eyes\", signal),\n\t\t\ttoMetadata: (reaction) => ({ projectId, iid, noteId, reactionId: reaction.id, name: \"eyes\" }),\n\t\t},\n\t);\n}\n/** @internal */\nexport function registerGitLabTools(api: ServerExtensionAPI, integration: GitLabIntegration) {\n\tfor (const [name, description, required] of [\n\t\t[\"gitlab_observe_merge_request\", \"Read the current MR source revision and its latest CI\", []],\n\t\t[\"gitlab_get_changes\", \"Read the MR changes\", []],\n\t\t[\"gitlab_get_identity\", \"Resolve the authenticated GitLab bot Git identity\", []],\n\t\t[\"gitlab_list_failed_jobs\", \"Read failed jobs from an MR-associated pipeline\", [\"pipelineId\"]],\n\t\t[\n\t\t\t\"gitlab_get_job_trace\",\n\t\t\t\"Read a bounded trace from a failed MR pipeline job\",\n\t\t\t[\"pipelineId\", \"jobId\"],\n\t\t],\n\t\t[\"gitlab_comment\", \"Post a retry-safe MR comment\", [\"body\", \"writeKey\"]],\n\t\t[\n\t\t\t\"gitlab_reply\",\n\t\t\t\"Post a retry-safe reply in an MR discussion\",\n\t\t\t[\"body\", \"writeKey\", \"discussionId\"],\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(\n\t\t\t\t{\n\t\t\t\t\tpipelineId: { type: \"integer\" },\n\t\t\t\t\tjobId: { type: \"integer\" },\n\t\t\t\t\tmaxBytes: { type: \"integer\" },\n\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t\tdiscussionId: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\t[...required],\n\t\t\t),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tif (name === \"gitlab_get_identity\")\n\t\t\t\t\treturn integration\n\t\t\t\t\t\t.client(resolveGitLabRepositoryBinding(ctx).profile)\n\t\t\t\t\t\t.resolveGitIdentity(ctx.signal);\n\t\t\t\tconst b = resolveGitLabBinding(ctx);\n\t\t\t\tconst client = integration.client(b.profile);\n\t\t\t\tif (name === \"gitlab_observe_merge_request\")\n\t\t\t\t\treturn observeMergeRequest(client, b.projectId, b.iid, ctx.signal);\n\t\t\t\tif (name === \"gitlab_get_changes\") return client.getChanges(b.projectId, b.iid, ctx.signal);\n\t\t\t\tif (name === \"gitlab_comment\" || name === \"gitlab_reply\")\n\t\t\t\t\treturn ensureGitLabComment({\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\t\t\tinstanceId: ctx.process.id,\n\t\t\t\t\t\tprojectId: b.projectId,\n\t\t\t\t\t\tiid: b.iid,\n\t\t\t\t\t\twriteKey: stringArg(args, \"writeKey\"),\n\t\t\t\t\t\tbody: stringArg(args, \"body\"),\n\t\t\t\t\t\t...(name === \"gitlab_reply\" ? { discussionId: stringArg(args, \"discussionId\") } : {}),\n\t\t\t\t\t\tsignal: ctx.signal,\n\t\t\t\t\t});\n\t\t\t\tconst observation = await observeMergeRequest(client, b.projectId, b.iid, ctx.signal);\n\t\t\t\tif (!observation.pipeline || observation.pipeline.id !== numberArg(args, \"pipelineId\"))\n\t\t\t\t\tthrow new Error(\"Pipeline is not current for the authorized MR\");\n\t\t\t\tconst jobs = await client.listFailedJobs(\n\t\t\t\t\tobservation.pipeline.project_id,\n\t\t\t\t\tobservation.pipeline.id,\n\t\t\t\t\tctx.signal,\n\t\t\t\t);\n\t\t\t\tif (name === \"gitlab_list_failed_jobs\") return jobs;\n\t\t\t\tconst job = jobs.find((job) => job.id === numberArg(args, \"jobId\"));\n\t\t\t\tif (!job) throw new Error(\"Job is not a failed job of the authorized MR pipeline\");\n\t\t\t\treturn client.getJobTrace(\n\t\t\t\t\tobservation.pipeline.project_id,\n\t\t\t\t\tjob.id,\n\t\t\t\t\ttypeof args.maxBytes === \"number\" ? args.maxBytes : undefined,\n\t\t\t\t\tctx.signal,\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\t}\n}\n","import type { GitLabClientLike, GitLabProject } from \"./client.js\";\n/** @public */\nexport interface GitLabSelection {\n\t/** @public */\n\tprojects: {\n\t\t/** @public */\n\t\tinclude: readonly string[];\n\t\t/** @internal */\n\t\texclude: readonly string[];\n\t};\n\t/** @public */\n\tgroups: {\n\t\t/** @public */\n\t\tinclude: readonly string[];\n\t\t/** @internal */\n\t\texclude: readonly string[];\n\t};\n\t/** @internal */\n\tallAccessible: boolean;\n}\n/** @public */\nexport function parseGitLabSelection(raw: Record<string, unknown>): GitLabSelection {\n\tconst list = (value: unknown): string[] => {\n\t\tif (value === undefined) return [];\n\t\tif (\n\t\t\t!Array.isArray(value) ||\n\t\t\tvalue.some(\n\t\t\t\t(v) =>\n\t\t\t\t\ttypeof v !== \"string\" ||\n\t\t\t\t\t!/^[a-zA-Z0-9_.-]+(?:\\/[a-zA-Z0-9_.-]+)*$/.test(v) ||\n\t\t\t\t\tv.split(\"/\").some((p: string) => p === \".\" || p === \"..\"),\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"GitLab selectors require exact namespace paths\");\n\t\treturn [...new Set(value as string[])];\n\t};\n\tconst pair = (value: unknown) => {\n\t\tif (value !== undefined && (!value || typeof value !== \"object\" || Array.isArray(value)))\n\t\t\tthrow new Error(\"GitLab selectors must be objects\");\n\t\tconst item = value as Record<string, unknown> | undefined;\n\t\treturn { include: list(item?.include), exclude: list(item?.exclude) };\n\t};\n\tif (raw.all_accessible !== undefined && typeof raw.all_accessible !== \"boolean\")\n\t\tthrow new Error(\"all_accessible must be a boolean\");\n\tconst parsed = {\n\t\tprojects: pair(raw.projects),\n\t\tgroups: pair(raw.groups),\n\t\tallAccessible: raw.all_accessible === true,\n\t};\n\tif (!parsed.allAccessible && !parsed.projects.include.length && !parsed.groups.include.length)\n\t\tthrow new Error(\"GitLab requires explicit project/group includes or all_accessible: true\");\n\treturn parsed;\n}\n/** @internal */\nexport function projectExcluded(selection: GitLabSelection, name: string): boolean {\n\treturn (\n\t\tselection.projects.exclude.includes(name) ||\n\t\tselection.groups.exclude.some((group) => name.startsWith(`${group}/`))\n\t);\n}\n/** Include union, subgroup expansion, exclusion precedence, stable-ID deduplication. @public */\nexport async function selectGitLabProjects(\n\tclient: GitLabClientLike,\n\tselection: GitLabSelection,\n): Promise<GitLabProject[]> {\n\tconst candidates: GitLabProject[] = selection.allAccessible ? await client.listProjects() : [];\n\tfor (const name of selection.projects.include) candidates.push(await client.getProject(name));\n\tfor (const group of selection.groups.include)\n\t\tcandidates.push(...(await client.listGroupProjects(group)));\n\treturn [\n\t\t...new Map(\n\t\t\tcandidates\n\t\t\t\t.filter((p) => !p.archived && !projectExcluded(selection, p.path_with_namespace))\n\t\t\t\t.map((p) => [p.id, p]),\n\t\t).values(),\n\t];\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\tdefineProcessWatcherSource,\n\tparseProcessWatcherLaunchModelConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport { type emptyPollResult, parseDurationMs } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport type { GitLabIssue, GitLabProject } from \"./client.js\";\nimport { type GitLabSelection, parseGitLabSelection, selectGitLabProjects } from \"./selection.js\";\n/** @public */\nexport interface GitLabIssueWatcherConfig extends GitLabSelection {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\tpollInterval: string;\n\t/** @public */\n\t/** @public */\n\tlabels: {\n\t\t/** @public */ trigger: string /** @public */;\n\t\t/** @public */\n\t\tdone: string;\n\t};\n}\n/** @public */\nexport interface GitLabIssueWatcherEvent {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\trepository: GitLabProject;\n\t/** @public */\n\tissue: GitLabIssue;\n\t/** @public */\n\t/** @public */\n\tlabels: {\n\t\t/** @public */ trigger: string /** @public */;\n\t\t/** @public */\n\t\tdone: string;\n\t};\n}\n/** @public */\nexport const gitlabIssueExternalId = (origin: string, projectId: number, iid: number) =>\n\t`gitlab:${origin}:${projectId}#${iid}`;\n/** @public */\nexport const gitlabIssueWatcherSource = defineProcessWatcherSource<\n\tGitLabIssueWatcherConfig,\n\tGitLabIssueWatcherEvent\n>({\n\tid: \"@leitwerk-dev/gitlab.issue\",\n\tlabel: \"GitLab issue\",\n\tparseConfig(raw) {\n\t\tconst c = asUnknownRecord(raw);\n\t\tif (!c || typeof c.enabled !== \"boolean\") throw new Error(\"GitLab watcher requires enabled\");\n\t\tconst text = (value: unknown, name: string) => {\n\t\t\tif (typeof value !== \"string\" || !value.trim())\n\t\t\t\tthrow new Error(`GitLab watcher requires ${name}`);\n\t\t\treturn value.trim();\n\t\t};\n\t\tconst labels = asUnknownRecord(c.labels) ?? {};\n\t\tconst trigger = text(labels.trigger, \"labels.trigger\");\n\t\tconst done = text(labels.done, \"labels.done\");\n\t\tif (trigger === done || trigger.includes(\",\") || done.includes(\",\"))\n\t\t\tthrow new Error(\"GitLab trigger/done labels must be distinct and contain no comma\");\n\t\tconst pollInterval = text(c.poll_interval ?? \"30s\", \"poll_interval\");\n\t\tif (parseDurationMs(pollInterval, -1) <= 0) throw new Error(\"Invalid GitLab polling interval\");\n\t\treturn {\n\t\t\tenabled: c.enabled,\n\t\t\tconfig: {\n\t\t\t\t...parseGitLabSelection(c),\n\t\t\t\tprofile: text(c.profile, \"profile\"),\n\t\t\t\tpollInterval,\n\t\t\t\tlabels: { trigger, done },\n\t\t\t},\n\t\t\tlaunchModelConfig: parseProcessWatcherLaunchModelConfig(c.launch),\n\t\t};\n\t},\n\tpresentConfig(c) {\n\t\treturn {\n\t\t\ttargetSummary: `Profile ${c.profile} · trigger ${c.labels.trigger}`,\n\t\t\tdetails: [\n\t\t\t\t{ label: \"Projects\", value: c.projects.include.join(\", \") || \"selected groups\" },\n\t\t\t\t{ label: \"Groups\", value: c.groups.include.join(\", \") || \"none\" },\n\t\t\t],\n\t\t};\n\t},\n});\n/** @public */\nexport function createGitLabIssueDiscovery(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitLabIntegration,\n\tnow: () => number,\n) {\n\tconst due = new Map<string, number>();\n\treturn async (result: ReturnType<typeof emptyPollResult>) => {\n\t\tfor (const watcher of deps.processWatchers?.listBySource(gitlabIssueWatcherSource) ?? []) {\n\t\t\tif (!watcher.enabled) continue;\n\t\t\tconst key = `${watcher.processId}:${watcher.watcherId}`;\n\t\t\tconst c = watcher.config;\n\t\t\tif ((due.get(key) ?? 0) > now()) continue;\n\t\t\tdue.set(key, now() + parseDurationMs(c.pollInterval, 30000));\n\t\t\tconst client = integration.client(c.profile);\n\t\t\tfor (const repository of await selectGitLabProjects(client, c))\n\t\t\t\tfor (const issue of await client.listIssues(repository.id)) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tissue.state !== \"opened\" ||\n\t\t\t\t\t\t!issue.labels.includes(c.labels.trigger) ||\n\t\t\t\t\t\tissue.labels.includes(c.labels.done)\n\t\t\t\t\t)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tconst id = gitlabIssueExternalId(client.baseUrl, repository.id, issue.iid);\n\t\t\t\t\tif (deps.processes.listAll().some((p) => p.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 guarded = {\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: \"gitlab-issue-eligibility\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"Recheck GitLab source issue\",\n\t\t\t\t\t\t\t\t\t\tasync run() {\n\t\t\t\t\t\t\t\t\t\t\tconst fresh = await client.getIssue(repository.id, issue.iid);\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\tfresh.state !== \"opened\" ||\n\t\t\t\t\t\t\t\t\t\t\t\t!fresh.labels.includes(c.labels.trigger) ||\n\t\t\t\t\t\t\t\t\t\t\t\tfresh.labels.includes(c.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\t\tthrow new Error(\"GitLab source issue eligibility 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(\n\t\t\t\t\t\tguarded,\n\t\t\t\t\t\t{ profile: c.profile, repository, issue, labels: c.labels },\n\t\t\t\t\t\t{ idempotencyKey: id },\n\t\t\t\t\t);\n\t\t\t\t\tif (launched.error) result.errors.push(`${id}:launch_failed`);\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}\n\t\t}\n\t};\n}\n","import {\n\ttype CoreServerSetupDeps,\n\tcreateExternalSourcePollReporter,\n\ttype ExternalActionSource,\n\ttype ExternalSourceArmingLike,\n} from \"@leitwerk-dev/process-sdk\";\nimport { type ConflictEvidence, conflictKey } from \"@leitwerk-dev/repository-rebase\";\nimport { emptyPollResult, parseDurationMs } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport { type GitLabFeedback, type GitLabObservation, observeMergeRequest } from \"./client.js\";\nimport { createGitLabIssueDiscovery } from \"./issue-watcher.js\";\n/** @public */\nexport interface GitLabDeliveryObservation extends GitLabObservation {\n\t/** @public */\n\tobservationKey?: string;\n\t/** @public */\n\tfeedback?: GitLabFeedback[];\n\t/** @public */\n\tconflict?: ConflictEvidence;\n}\n/** @public */\nexport const GITLAB_ISSUE_CANCELLED_KIND = \"@leitwerk-dev/gitlab.issue-cancelled\";\n/** @public */\nexport interface GitLabIssueCancelledConfig {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\tprojectId: number;\n\t/** @public */\n\tissueIid: number;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\ttriggerLabel: string;\n\t/** @public */\n\tpollInterval?: string;\n}\n/** @internal */\nexport const GITLAB_MR_KIND = \"@leitwerk-dev/gitlab.merge-request\";\n/** @public */\nexport interface GitLabSourceConfig {\n\t/** @public */\n\tprofile: string;\n\t/** @public */\n\tprojectId: number;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\tpollInterval?: string;\n\t/** @public */\n\tafterKey?: string;\n\t/** Optional timer also wakes retry work when GitLab facts have not changed. */\n\t/** @public */\n\twakeAt?: number;\n\t/** @public */\n\tdelivery?: {\n\t\t/** @public */\n\t\theadSha: string;\n\t\t/** @public */\n\t\towner: string;\n\t\t/** @public */\n\t\trepo: string;\n\t\t/** @public */\n\t\theadBranch: string;\n\t\t/** @public */\n\t\tbaseBranch: string;\n\t\t/** @public */\n\t\tlastConflictKey?: string | null;\n\t};\n\t/** @public */\n\t/** @public */\n\tfeedback?: {\n\t\t/** @public */\n\t\tafterId: number;\n\t\t/** @public */\n\t\tsince?: string;\n\t\t/** @public */\n\t\tquietPeriodMs: number;\n\t};\n}\n/** A trailing quiet period survives restarts because it uses the newest unseen note's timestamp. */\n/** @public */\nexport function pendingGitLabFeedback(\n\titems: GitLabFeedback[],\n\tafterId: number,\n\tsince?: string,\n): GitLabFeedback[] {\n\tconst start = since ? Date.parse(since) : 0;\n\treturn items.filter((item) => item.id > afterId && Date.parse(item.createdAt) >= start);\n}\n/** @public */\nexport function gitLabFeedbackReadyAt(\n\titems: GitLabFeedback[],\n\tquietPeriodMs: number,\n): number | null {\n\treturn items.length\n\t\t? Math.max(...items.map((item) => Date.parse(item.createdAt))) + quietPeriodMs\n\t\t: null;\n}\n/** @public */\nexport const observationKey = ({ mr, pipeline, targetHead }: GitLabObservation): string =>\n\tJSON.stringify([\n\t\tmr.state,\n\t\tmr.sha,\n\t\t[...mr.labels].sort(),\n\t\tpipeline?.project_id,\n\t\tpipeline?.id,\n\t\tpipeline?.status,\n\t\tmr.source_project_id,\n\t\tmr.source_branch,\n\t\tmr.target_project_id,\n\t\tmr.target_branch,\n\t\ttargetHead,\n\t\tmr.has_conflicts,\n\t\tmr.merge_status,\n\t\tmr.detailed_merge_status,\n\t]);\n/** @public */\nexport const gitlabExternal = {\n\t/** @public */\n\tissueCancelled<P, S>(\n\t\t/** @public */\n\t\t/** @public */\n\t\tresolve: (ctx: {\n\t\t\t/** @public */\n\t\t\tparams: P;\n\t\t\t/** @public */\n\t\t\tstate: S;\n\t\t}) => GitLabIssueCancelledConfig,\n\t): ExternalActionSource<P, S, unknown> {\n\t\treturn {\n\t\t\tkind: GITLAB_ISSUE_CANCELLED_KIND,\n\t\t\tlabel: \"GitLab source issue cancelled\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n\t/** @public */\n\tmergeRequest<P, S>(\n\t\t/** @public */\n\t\t/** @public */\n\t\tresolve: (ctx: {\n\t\t\t/** @public */\n\t\t\tparams: P;\n\t\t\t/** @public */\n\t\t\tstate: S;\n\t\t}) => GitLabSourceConfig,\n\t): ExternalActionSource<P, S, GitLabDeliveryObservation> {\n\t\treturn {\n\t\t\tkind: GITLAB_MR_KIND,\n\t\t\tlabel: \"GitLab merge request\",\n\t\t\tdescription: \"Observe MR state, current source head and revision-correlated CI\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n};\n/** @internal */\nexport function createGitLabProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitLabIntegration,\n\t/** @public */\n\t/** @public */\n\toptions: {\n\t\t/** @internal */ now?: () => number;\n\t} = {},\n) {\n\tconst schedule = new Map<string, { at: number; failures: number }>();\n\tconst now = options.now ?? Date.now;\n\tconst discover = createGitLabIssueDiscovery(deps, integration, now);\n\treturn deps.polling.create({\n\t\tid: \"gitlab\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\ttry {\n\t\t\t\tawait discover(result);\n\t\t\t} catch (error) {\n\t\t\t\tresult.errors.push(error instanceof Error ? error.message : \"GitLab discovery failed\");\n\t\t\t}\n\t\t\tconst reporter = createExternalSourcePollReporter(deps.externalSources, result, {\n\t\t\t\tforwardGeneration: true,\n\t\t\t});\n\t\t\tconst current = (armed: ExternalSourceArmingLike) =>\n\t\t\t\t[GITLAB_MR_KIND, GITLAB_ISSUE_CANCELLED_KIND].some((kind) =>\n\t\t\t\t\treporter.isCurrent(kind, armed),\n\t\t\t\t);\n\t\t\tconst report = {\n\t\t\t\t...reporter,\n\t\t\t\tfire(armed: ExternalSourceArmingLike, event: Record<string, unknown>, mergeKey: string) {\n\t\t\t\t\treturn current(armed) ? reporter.fire(armed, event, mergeKey) : Promise.resolve(false);\n\t\t\t\t},\n\t\t\t\tobserve(armed: ExternalSourceArmingLike, input: Parameters<typeof reporter.observe>[1]) {\n\t\t\t\t\tif (current(armed)) return reporter.observe(armed, input);\n\t\t\t\t},\n\t\t\t};\n\t\t\tawait report.poll(GITLAB_MR_KIND, async (armed) => {\n\t\t\t\tconst c = armed.resolved as unknown as GitLabSourceConfig;\n\t\t\t\tif (\n\t\t\t\t\t!c ||\n\t\t\t\t\ttypeof c.profile !== \"string\" ||\n\t\t\t\t\t!Number.isInteger(c.projectId) ||\n\t\t\t\t\t!Number.isInteger(c.iid)\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(\"Invalid GitLab external source\");\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tconst previous = schedule.get(key);\n\t\t\t\tif (previous && previous.at > now()) return;\n\t\t\t\ttry {\n\t\t\t\t\tconst observation = await observeMergeRequest(\n\t\t\t\t\t\tintegration.client(c.profile),\n\t\t\t\t\t\tc.projectId,\n\t\t\t\t\t\tc.iid,\n\t\t\t\t\t);\n\t\t\t\t\tlet conflict: ConflictEvidence | undefined;\n\t\t\t\t\tconst client = integration.client(c.profile);\n\t\t\t\t\tif (\n\t\t\t\t\t\tc.delivery &&\n\t\t\t\t\t\tobservation.mr.state === \"opened\" &&\n\t\t\t\t\t\tobservation.mr.sha === c.delivery.headSha &&\n\t\t\t\t\t\t(observation.mr.has_conflicts === true ||\n\t\t\t\t\t\t\tobservation.mr.detailed_merge_status === \"conflict\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst mr = observation.mr;\n\t\t\t\t\t\tconst d = c.delivery;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tmr.source_project_id !== c.projectId ||\n\t\t\t\t\t\t\tmr.target_project_id !== c.projectId ||\n\t\t\t\t\t\t\tmr.source_branch !== d.headBranch ||\n\t\t\t\t\t\t\tmr.target_branch !== d.baseBranch\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tthrow new Error(\"GitLab merge request branches changed\");\n\t\t\t\t\t\tconst base = await client.getBranch(c.projectId, d.baseBranch);\n\t\t\t\t\t\tconst evidence: ConflictEvidence = {\n\t\t\t\t\t\t\towner: d.owner,\n\t\t\t\t\t\t\trepo: d.repo,\n\t\t\t\t\t\t\tprNumber: c.iid,\n\t\t\t\t\t\t\theadBranch: d.headBranch,\n\t\t\t\t\t\t\tbaseBranch: d.baseBranch,\n\t\t\t\t\t\t\theadSha: mr.sha,\n\t\t\t\t\t\t\tbaseSha: base.commit.id,\n\t\t\t\t\t\t\turl: mr.web_url,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (conflictKey(evidence) !== d.lastConflictKey) conflict = evidence;\n\t\t\t\t\t}\n\t\t\t\t\tconst observedKey =\n\t\t\t\t\t\tobservationKey(observation) +\n\t\t\t\t\t\t(c.delivery ? `:${conflict ? conflictKey(conflict) : \"\"}` : \"\");\n\t\t\t\t\tconst feedback =\n\t\t\t\t\t\tc.feedback && observation.mr.state === \"opened\"\n\t\t\t\t\t\t\t? pendingGitLabFeedback(\n\t\t\t\t\t\t\t\t\tawait integration.client(c.profile).listMergeRequestFeedback(c.projectId, c.iid),\n\t\t\t\t\t\t\t\t\tc.feedback.afterId,\n\t\t\t\t\t\t\t\t\tc.feedback.since,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\tconst feedbackReadyAt = gitLabFeedbackReadyAt(\n\t\t\t\t\t\tfeedback,\n\t\t\t\t\t\tc.feedback?.quietPeriodMs ?? 120_000,\n\t\t\t\t\t);\n\t\t\t\t\tconst feedbackReady = feedbackReadyAt !== null && feedbackReadyAt <= now();\n\t\t\t\t\tif (c.delivery) {\n\t\t\t\t\t\tconst fresh = await client.getMergeRequest(c.projectId, c.iid);\n\t\t\t\t\t\tif (fresh.sha !== observation.mr.sha || fresh.state !== observation.mr.state) return;\n\t\t\t\t\t}\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\tobservation: {\n\t\t\t\t\t\t\tsummary: `${observation.mr.state} · ${observation.pipeline?.status ?? \"no current pipeline\"}`,\n\t\t\t\t\t\t\tobservedAt: new Date(now()).toISOString(),\n\t\t\t\t\t\t\tsubject: observation.mr.web_url,\n\t\t\t\t\t\t\trevision: observation.mr.sha,\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\tobservedKey !== c.afterKey ||\n\t\t\t\t\t\tfeedbackReady ||\n\t\t\t\t\t\t(c.wakeAt !== undefined && c.wakeAt <= now())\n\t\t\t\t\t)\n\t\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t...observation,\n\t\t\t\t\t\t\t\t...(c.delivery\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\tobservationKey: observedKey,\n\t\t\t\t\t\t\t\t\t\t\tfeedback: feedbackReady ? feedback : [],\n\t\t\t\t\t\t\t\t\t\t\t...(conflict ? { conflict } : {}),\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},\n\t\t\t\t\t\t\t`${observedKey}:${c.wakeAt ?? \"\"}:${feedbackReady ? feedback.map((item) => item.id).join(\",\") : \"\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t\tschedule.set(key, {\n\t\t\t\t\t\tat: now() + parseDurationMs(c.pollInterval ?? \"30s\", 30000),\n\t\t\t\t\t\tfailures: 0,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst failures = (previous?.failures ?? 0) + 1;\n\t\t\t\t\tschedule.set(key, {\n\t\t\t\t\t\tat: now() + Math.min(300000, 30000 * 2 ** Math.min(failures - 1, 4)),\n\t\t\t\t\t\tfailures,\n\t\t\t\t\t});\n\t\t\t\t\tawait report.observe(armed, {\n\t\t\t\t\t\trefreshError: error instanceof Error ? error.message : \"GitLab observation unavailable\",\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(GITLAB_ISSUE_CANCELLED_KIND, async (armed) => {\n\t\t\t\tconst c = armed.resolved as unknown as GitLabIssueCancelledConfig;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}:${armed.generation ?? \"\"}`;\n\t\t\t\tif ((schedule.get(key)?.at ?? 0) > now()) return;\n\t\t\t\tconst client = integration.client(c.profile);\n\t\t\t\tconst issue = await client.getIssue(c.projectId, c.issueIid);\n\t\t\t\tif (issue.state !== \"opened\" || !issue.labels.includes(c.triggerLabel)) {\n\t\t\t\t\tconst mr = await client.getMergeRequest(c.projectId, c.iid);\n\t\t\t\t\tif (mr.state !== \"opened\") return;\n\t\t\t\t\tawait report.fire(\n\t\t\t\t\t\tarmed,\n\t\t\t\t\t\t{ issue },\n\t\t\t\t\t\t`${issue.iid}:${issue.state}:${issue.labels.includes(c.triggerLabel)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tschedule.set(key, {\n\t\t\t\t\tat: now() + parseDurationMs(c.pollInterval ?? \"30s\", 30000),\n\t\t\t\t\tfailures: 0,\n\t\t\t\t});\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n","import { coreHostCapabilities, type ServerExtensionAPI } from \"@leitwerk-dev/process-sdk\";\nimport { type GitLabIntegration, gitlabIntegration } from \"./capability.js\";\nimport { registerGitLabDeliveryTools } from \"./delivery-tools.js\";\nimport { createGitLabProvider } from \"./external.js\";\nimport { registerGitLabTools } from \"./tools.js\";\n\n/** Register shared tools and polling with an explicit integration. @public */\nexport function setupGitLabIntegration(\n\tapi: ServerExtensionAPI,\n\tintegration: GitLabIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t} = {},\n) {\n\tapi.provide(gitlabIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterGitLabTools(api, integration);\n\tregisterGitLabDeliveryTools(api, integration, deps.projects);\n\treturn createGitLabProvider(deps, integration, options);\n}\n","import { createHash } from \"node:crypto\";\nimport {\n\tnumberArg,\n\ttype ProcessProjectRepoLike,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport {\n\tensureGitLabSeenReaction,\n\tresolveGitLabBinding,\n\tresolveGitLabRepositoryBinding,\n} from \"./tools.js\";\n\nexport function registerGitLabDeliveryTools(\n\tapi: ServerExtensionAPI,\n\tintegration: GitLabIntegration,\n\tprojects: ProcessProjectRepoLike,\n) {\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"gitlab_ensure_merge_request\",\n\t\tdescription: \"Create or reconcile and pin the process merge request\",\n\t\tparameters: projectParameters({ title: { type: \"string\" }, body: { type: \"string\" } }, [\n\t\t\t\"title\",\n\t\t\t\"body\",\n\t\t]),\n\t\tasync execute(ctx, args) {\n\t\t\tconst binding = resolveGitLabRepositoryBinding(ctx);\n\t\t\tconst client = integration.client(binding.profile);\n\t\t\tconst project = projects.getByInstanceAndKey(ctx.process.id, ctx.project?.key ?? \"\");\n\t\t\tif (!project?.workBranch || project.workBranch === project.baseBranch)\n\t\t\t\tthrow new Error(\"A process feature branch is required\");\n\t\t\tconst workBranch = project.workBranch;\n\t\t\tconst identity = {\n\t\t\t\twriteType: \"gitlab.ensure_mr\",\n\t\t\t\tdedupKey: `${binding.projectId}:${project.key}:${workBranch}:${project.baseBranch}`,\n\t\t\t};\n\t\t\tconst marker = `<!-- leitwerk:gitlab:merge-request:${ctx.process.id}:${project.key} -->`;\n\t\t\tconst find = async () =>\n\t\t\t\t(\n\t\t\t\t\tawait client.listBranchMergeRequests(\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\tworkBranch,\n\t\t\t\t\t\tproject.baseBranch,\n\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t)\n\t\t\t\t).find(\n\t\t\t\t\t(mr) =>\n\t\t\t\t\t\tmr.source_project_id === binding.projectId &&\n\t\t\t\t\t\tmr.target_project_id === binding.projectId &&\n\t\t\t\t\t\tmr.source_branch === project.workBranch &&\n\t\t\t\t\t\tmr.target_branch === project.baseBranch &&\n\t\t\t\t\t\tmr.description?.includes(marker),\n\t\t\t\t);\n\t\t\tconst request = await ctx.externalWrites.ensure(identity, {\n\t\t\t\treconcile: async () => (await find()) ?? null,\n\t\t\t\texecute: () =>\n\t\t\t\t\tclient.createMergeRequest(\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: stringArg(args, \"title\"),\n\t\t\t\t\t\t\tdescription: `${stringArg(args, \"body\")}\\n\\n${marker}`,\n\t\t\t\t\t\t\tsource_branch: workBranch,\n\t\t\t\t\t\t\ttarget_branch: project.baseBranch,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t),\n\t\t\t\ttoMetadata: (mr) => ({ iid: mr.iid, url: mr.web_url }),\n\t\t\t});\n\t\t\tconst latest = projects.getByInstanceAndKey(ctx.process.id, project.key);\n\t\t\tif (\n\t\t\t\t!latest ||\n\t\t\t\tlatest.workBranch !== project.workBranch ||\n\t\t\t\tlatest.baseBranch !== project.baseBranch\n\t\t\t)\n\t\t\t\tthrow new Error(\"Process repository binding changed during publication\");\n\t\t\tconst metadata = latest.metadata ?? {};\n\t\t\tconst previous = metadata.gitlab as { iid?: number };\n\t\t\tif (previous.iid && previous.iid !== request.iid)\n\t\t\t\tthrow new Error(\"Process is already bound to another merge request\");\n\t\t\tprojects.update(latest.id, {\n\t\t\t\tmetadata: { ...metadata, gitlab: { ...previous, ...binding, iid: request.iid } },\n\t\t\t\texternalId: String(request.iid),\n\t\t\t\texternalUrl: request.web_url,\n\t\t\t});\n\t\t\treturn request;\n\t\t},\n\t});\n\tapi.tool({\n\t\tname: \"gitlab_list_merge_request_feedback\",\n\t\tdescription: \"Read human discussion feedback on the bound merge request\",\n\t\tparameters: projectParameters(),\n\t\tasync execute(ctx) {\n\t\t\tconst b = resolveGitLabBinding(ctx);\n\t\t\treturn integration.client(b.profile).listMergeRequestFeedback(b.projectId, b.iid, ctx.signal);\n\t\t},\n\t});\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"gitlab_acknowledge_feedback\",\n\t\tdescription: \"Reconcile the bot's seen reaction on bound merge request feedback\",\n\t\tparameters: projectParameters({ noteId: { type: \"integer\" } }, [\"noteId\"]),\n\t\tasync execute(ctx, args) {\n\t\t\tconst b = resolveGitLabBinding(ctx);\n\t\t\tconst client = integration.client(b.profile);\n\t\t\tconst noteId = numberArg(args, \"noteId\");\n\t\t\tif (\n\t\t\t\t!(await client.listMergeRequestFeedback(b.projectId, b.iid, ctx.signal)).some(\n\t\t\t\t\t(n) => n.id === noteId,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new Error(\"Note is not actionable feedback on the bound merge request\");\n\t\t\tawait ensureGitLabSeenReaction({\n\t\t\t\tclient,\n\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\tinstanceId: ctx.process.id,\n\t\t\t\tprojectId: b.projectId,\n\t\t\t\tiid: b.iid,\n\t\t\t\tnoteId,\n\t\t\t\tsignal: ctx.signal,\n\t\t\t});\n\t\t\treturn { ok: true };\n\t\t},\n\t});\n\tfor (const name of [\n\t\t\"gitlab_get_issue\",\n\t\t\"gitlab_add_issue_comment\",\n\t\t\"gitlab_finalize_source_issue\",\n\t] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription: \"Read or reconcile the process source issue\",\n\t\t\tparameters: projectParameters(\n\t\t\t\t{\n\t\t\t\t\tissueNumber: { type: \"integer\" },\n\t\t\t\t\tbody: { type: \"string\" },\n\t\t\t\t\twriteKey: { type: \"string\" },\n\t\t\t\t\tmerged: { type: \"boolean\" },\n\t\t\t\t\ttriggerLabel: { type: \"string\" },\n\t\t\t\t\tdoneLabel: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\t[\"issueNumber\"],\n\t\t\t),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst b = resolveGitLabRepositoryBinding(ctx);\n\t\t\t\tconst client = integration.client(b.profile);\n\t\t\t\tconst iid = numberArg(args, \"issueNumber\");\n\t\t\t\tconst bound = (ctx.project?.metadata?.gitlab as { issueIid?: number })?.issueIid;\n\t\t\t\tif (bound !== iid) throw new Error(\"Issue does not match the process source issue\");\n\t\t\t\tif (name === \"gitlab_get_issue\") return client.getIssue(b.projectId, iid, ctx.signal);\n\t\t\t\tconst key = stringArg(args, \"writeKey\");\n\t\t\t\tconst digest = createHash(\"sha256\")\n\t\t\t\t\t.update(JSON.stringify([client.baseUrl, b.projectId, iid, ctx.process.id, key]))\n\t\t\t\t\t.digest(\"hex\");\n\t\t\t\tif (name === \"gitlab_add_issue_comment\") {\n\t\t\t\t\tconst marker = `<!-- leitwerk:gitlab:issue:${digest} -->`;\n\t\t\t\t\tconst note = await ctx.externalWrites.ensure(\n\t\t\t\t\t\t{ writeType: name, dedupKey: digest },\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t\t\t(await client.listIssueNotes(b.projectId, iid, ctx.signal)).find((n) =>\n\t\t\t\t\t\t\t\t\tn.body.includes(marker),\n\t\t\t\t\t\t\t\t) ?? null,\n\t\t\t\t\t\t\texecute: () =>\n\t\t\t\t\t\t\t\tclient.addIssueNote(\n\t\t\t\t\t\t\t\t\tb.projectId,\n\t\t\t\t\t\t\t\t\tiid,\n\t\t\t\t\t\t\t\t\t`${stringArg(args, \"body\")}\\n\\n${marker}`,\n\t\t\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttoMetadata: (note) => ({ noteId: note.id }),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\treturn { noteId: note.id };\n\t\t\t\t}\n\t\t\t\tconst merged = args.merged === true;\n\t\t\t\tconst trigger = stringArg(args, \"triggerLabel\");\n\t\t\t\tconst done = stringArg(args, \"doneLabel\");\n\t\t\t\tif (merged) {\n\t\t\t\t\tawait ctx.externalWrites.ensure(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twriteType: \"gitlab.ensure_label\",\n\t\t\t\t\t\t\tdedupKey: JSON.stringify([client.baseUrl, b.projectId, done]),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t\t\t(await client.listLabels(b.projectId, ctx.signal)).find((l) => l.name === done) ??\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\texecute: () => client.createLabel(b.projectId, done, ctx.signal),\n\t\t\t\t\t\t\ttoMetadata: (label) => ({ name: label.name }),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait ctx.externalWrites.ensure(\n\t\t\t\t\t{ writeType: name, dedupKey: digest },\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async () => {\n\t\t\t\t\t\t\tconst fresh = await client.getIssue(b.projectId, iid, ctx.signal);\n\t\t\t\t\t\t\treturn !fresh.labels.includes(trigger) &&\n\t\t\t\t\t\t\t\t(!merged || (fresh.state === \"closed\" && fresh.labels.includes(done)))\n\t\t\t\t\t\t\t\t? fresh\n\t\t\t\t\t\t\t\t: null;\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute: async () => {\n\t\t\t\t\t\t\tconst issue = await client.getIssue(b.projectId, iid, ctx.signal);\n\t\t\t\t\t\t\tconst labels = [\n\t\t\t\t\t\t\t\t...new Set([\n\t\t\t\t\t\t\t\t\t...issue.labels.filter((l) => l !== trigger),\n\t\t\t\t\t\t\t\t\t...(merged ? [done] : []),\n\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\treturn client.updateIssue(\n\t\t\t\t\t\t\t\tb.projectId,\n\t\t\t\t\t\t\t\tiid,\n\t\t\t\t\t\t\t\t{ labels: labels.join(\",\"), ...(merged ? { state_event: \"close\" as const } : {}) },\n\t\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttoMetadata: () => ({ issueIid: iid, merged }),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn { issueIid: iid, merged };\n\t\t\t},\n\t\t});\n\t}\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,sBAAAA,2BAA0B;;;ACDnC,SAAS,gBAAgB;AACzB,SAAS,SAAS,IAAI,iBAAiB;AACvC,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAEnC,IAAM,OAAO,UAAU,QAAQ;AAE/B,eAAsB,0BAA0B,OAO7C;AACF,QAAM,MAAM,mBAAmB,MAAM,GAAG;AACxC,MAAI,IAAI,WAAW,MAAM;AACxB,UAAM,IAAI,MAAM,qDAAqD;AACtE,QAAM,YAAY,MAAM,QAAQ,KAAK,OAAO,GAAG,4BAA4B,CAAC;AAC5E,MAAI;AACH,UAAM,UAAU,KAAK,WAAW,SAAS;AACzC,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA,EAAE,MAAM,IAAM;A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AAU,KAAK,OAAO;AAAA,MAChC;AAAA,IACD,CAAC;AAAA,EACF;AACD;;;AD1NO,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,8BAA4B,KAAK,aAAa,KAAK,QAAQ;AAC3D,SAAO,qBAAqB,MAAM,aAAa,OAAO;AACvD;","names":["repositoryHttpsUrl","repositoryHttpsUrl","job","asUnknownRecord","asUnknownRecord","parseDurationMs","parseDurationMs","createHash","numberArg","projectParameters","stringArg","projectParameters","stringArg","numberArg","createHash","note"]}
package/dist/client.d.ts CHANGED
@@ -1,179 +1,406 @@
1
+ /** @internal */
1
2
  export interface GitLabProfile {
3
+ /** @internal */
2
4
  baseUrl: string;
5
+ /** @internal */
3
6
  token: string;
7
+ /** @internal */
4
8
  gitIdentity?: {
9
+ /** @internal */
5
10
  name: string;
11
+ /** @internal */
6
12
  email: string;
7
13
  };
8
14
  }
15
+ /** @public */
9
16
  export interface GitLabProject {
17
+ /** @public */
10
18
  id: number;
19
+ /** @public */
11
20
  path_with_namespace: string;
21
+ /** @public */
12
22
  http_url_to_repo: string;
23
+ /** @public */
13
24
  web_url: string;
25
+ /** @internal */
14
26
  default_branch: string;
27
+ /** @public */
15
28
  archived?: boolean;
29
+ /** @internal */
16
30
  permissions?: {
31
+ /** @internal */
17
32
  project_access?: {
33
+ /** @internal */
18
34
  access_level: number;
19
35
  } | null;
36
+ /** @internal */
20
37
  group_access?: {
38
+ /** @internal */
21
39
  access_level: number;
22
40
  } | null;
23
41
  };
24
42
  }
43
+ /** @internal */
25
44
  export interface GitLabGroup {
45
+ /** @internal */
26
46
  id: number;
47
+ /** @internal */
27
48
  full_path: string;
28
49
  }
50
+ /** @public */
51
+ export interface GitLabIssue {
52
+ /** @public */
53
+ id: number;
54
+ /** @public */
55
+ iid: number;
56
+ /** @public */
57
+ project_id: number;
58
+ /** @public */
59
+ title: string;
60
+ /** @public */
61
+ description: string | null;
62
+ /** @public */
63
+ web_url: string;
64
+ /** @public */
65
+ state: string;
66
+ /** @public */
67
+ labels: string[];
68
+ }
69
+ /** @public */
29
70
  export interface GitLabMergeRequest {
71
+ /** @public */
72
+ detailed_merge_status?: string;
73
+ /** @public */
74
+ has_conflicts?: boolean;
75
+ /** @public */
76
+ merge_status?: string;
77
+ /** @public */
30
78
  iid: number;
79
+ /** @public */
31
80
  project_id: number;
81
+ /** @public */
32
82
  source_project_id: number;
83
+ /** @public */
33
84
  target_project_id: number;
85
+ /** @public */
34
86
  title: string;
87
+ /** @public */
35
88
  description: string | null;
89
+ /** @public */
36
90
  state: string;
91
+ /** @public */
37
92
  labels: string[];
93
+ /** @public */
38
94
  sha: string;
95
+ /** @public */
39
96
  source_branch: string;
97
+ /** @public */
40
98
  target_branch: string;
99
+ /** @public */
41
100
  web_url: string;
101
+ /** @internal */
42
102
  merge_commit_sha?: string | null;
103
+ /** @internal */
43
104
  diff_refs?: {
105
+ /** @internal */
44
106
  base_sha: string;
107
+ /** @internal */
45
108
  head_sha: string;
109
+ /** @internal */
46
110
  start_sha: string;
47
111
  };
48
112
  }
113
+ /** @public */
49
114
  export interface GitLabCommit {
115
+ /** @public */
50
116
  id: string;
117
+ /** @internal */
51
118
  parent_ids: string[];
119
+ /** @internal */
52
120
  message: string;
121
+ /** @internal */
53
122
  web_url?: string;
54
123
  }
124
+ /** @public */
55
125
  export interface GitLabBranch {
126
+ /** @internal */
56
127
  name: string;
128
+ /** @public */
57
129
  can_push: boolean;
130
+ /** @internal */
58
131
  protected: boolean;
132
+ /** @public */
59
133
  commit: GitLabCommit;
60
134
  }
135
+ /** @public */
61
136
  export interface GitLabPipeline {
137
+ /** @public */
62
138
  id: number;
139
+ /** @public */
63
140
  project_id: number;
141
+ /** @public */
64
142
  sha: string;
143
+ /** @public */
65
144
  ref: string;
145
+ /** @public */
66
146
  status: string;
147
+ /** @internal */
67
148
  source?: string;
149
+ /** @public */
68
150
  web_url: string;
69
151
  }
152
+ /** @public */
70
153
  export interface GitLabJob {
154
+ /** @internal */
71
155
  id: number;
156
+ /** @public */
72
157
  name: string;
158
+ /** @internal */
73
159
  status: string;
160
+ /** @public */
74
161
  web_url: string;
162
+ /** @public */
75
163
  failure_reason?: string;
76
164
  }
165
+ /** @public */
77
166
  export interface GitLabDiff {
167
+ /** @public */
78
168
  old_path: string;
169
+ /** @public */
79
170
  new_path: string;
171
+ /** @public */
80
172
  diff: string;
173
+ /** @public */
81
174
  new_file: boolean;
175
+ /** @public */
82
176
  deleted_file: boolean;
177
+ /** @public */
83
178
  renamed_file: boolean;
84
179
  }
180
+ /** @public */
85
181
  export interface GitLabNote {
182
+ /** @internal */
86
183
  id: number;
184
+ /** @public */
87
185
  body: string;
88
186
  }
187
+ /** @public */
89
188
  export interface GitLabNoteReaction {
189
+ /** @public */
90
190
  id: number;
191
+ /** @internal */
91
192
  name: string;
193
+ /** @internal */
92
194
  user: {
195
+ /** @internal */
93
196
  username: string;
94
197
  };
95
198
  }
199
+ /** @public */
96
200
  export interface GitLabFeedback {
201
+ /** @public */
97
202
  id: number;
203
+ /** @public */
98
204
  discussionId: string;
205
+ /** @public */
99
206
  body: string;
207
+ /** @public */
100
208
  author: string;
209
+ /** @public */
101
210
  createdAt: string;
211
+ /** @public */
102
212
  path?: string;
213
+ /** @public */
103
214
  line?: number;
104
215
  }
216
+ /** @internal */
105
217
  export interface GitLabDiscussion {
218
+ /** @internal */
106
219
  id: string;
220
+ /** @internal */
107
221
  notes: (GitLabNote & {
222
+ /** @internal */
108
223
  system: boolean;
224
+ /** @internal */
109
225
  created_at: string;
226
+ /** @internal */
110
227
  author: {
228
+ /** @internal */
111
229
  username: string;
230
+ /** @internal */
112
231
  bot?: boolean;
113
232
  };
233
+ /** @internal */
114
234
  resolved?: boolean;
235
+ /** @internal */
115
236
  position?: {
237
+ /** @internal */
116
238
  new_path?: string;
239
+ /** @internal */
117
240
  old_path?: string;
241
+ /** @internal */
118
242
  new_line?: number;
243
+ /** @internal */
119
244
  old_line?: number;
120
245
  };
121
246
  })[];
122
247
  }
248
+ /** @public */
123
249
  export interface GitLabIdentity {
250
+ /** @public */
124
251
  name: string;
252
+ /** @public */
125
253
  email: string;
254
+ /** @public */
126
255
  username: string;
127
256
  }
257
+ /** @public */
128
258
  export interface GitLabObservation {
259
+ /** @public */
129
260
  mr: GitLabMergeRequest;
261
+ /** @public */
130
262
  pipeline: GitLabPipeline | null;
263
+ /** @public */
264
+ targetHead?: string;
131
265
  }
266
+ /** @public */
267
+ export declare function gitLabMergeabilityPending(mr: GitLabMergeRequest): boolean;
268
+ /** @public Only actionable Git conflicts/rebase requirements, not approvals or CI gates. */
269
+ export declare function gitLabMergeRepairReason(mr: GitLabMergeRequest): "conflict" | "rebase" | null;
270
+ /** @internal */
132
271
  export declare class GitLabError extends Error {
272
+ /** @internal */
133
273
  readonly status: number;
274
+ /** @internal */
134
275
  readonly retryable: boolean;
135
- constructor(status: number, retryable: boolean);
276
+ /** @internal */
277
+ constructor(
278
+ /** @internal */
279
+ status: number,
280
+ /** @internal */
281
+ retryable: boolean);
136
282
  }
283
+ /** @internal */
137
284
  export declare function parseGitLabProfiles(raw: unknown): Map<string, GitLabProfile>;
138
285
  /** GitLab v4 API. Errors deliberately omit response bodies, headers and tokens. */
286
+ /** @public */
139
287
  export declare class GitLabClient {
140
288
  #private;
289
+ /** @public */
141
290
  readonly baseUrl: string;
142
- constructor(profile: GitLabProfile, options?: {
291
+ /** @internal */
292
+ constructor(profile: GitLabProfile,
293
+ /** @public */
294
+ /** @public */
295
+ options?: {
296
+ /** @internal */
143
297
  fetch?: typeof fetch;
298
+ /** @internal */
144
299
  sleep?: (ms: number) => Promise<unknown>;
145
300
  });
146
301
  private response;
147
302
  private request;
148
303
  private json;
149
304
  private pages;
305
+ /** @public */
306
+ listIssues(id: number, signal?: AbortSignal): Promise<GitLabIssue[]>;
307
+ /** @public */
308
+ getIssue(id: number, iid: number, signal?: AbortSignal): Promise<GitLabIssue>;
309
+ /** @public */
310
+ updateIssue(id: number, iid: number,
311
+ /** @public */
312
+ /** @public */
313
+ patch: {
314
+ /** @public */
315
+ labels?: string;
316
+ /** @public */
317
+ state_event?: "close";
318
+ }, signal?: AbortSignal): Promise<GitLabIssue>;
319
+ /** @public */
320
+ listIssueNotes(id: number, iid: number, signal?: AbortSignal): Promise<GitLabNote[]>;
321
+ /** @public */
322
+ addIssueNote(id: number, iid: number, body: string, signal?: AbortSignal): Promise<GitLabNote>;
323
+ /** @public */
324
+ /** @public */
325
+ listLabels(id: number, signal?: AbortSignal): Promise<Array<{
326
+ /** @public */ name: string;
327
+ }>>;
328
+ /** @public */
329
+ /** @public */
330
+ createLabel(id: number, name: string, signal?: AbortSignal): Promise<{
331
+ /** @public */ name: string;
332
+ }>;
333
+ /** @public */
334
+ listBranchMergeRequests(id: number, source: string, target: string, signal?: AbortSignal): Promise<GitLabMergeRequest[]>;
335
+ /** @public */
336
+ createMergeRequest(id: number,
337
+ /** @public */
338
+ /** @public */
339
+ input: {
340
+ /** @public */
341
+ title: string;
342
+ /** @public */
343
+ description: string;
344
+ /** @public */
345
+ source_branch: string;
346
+ /** @public */
347
+ target_branch: string;
348
+ }, signal?: AbortSignal): Promise<GitLabMergeRequest>;
349
+ /** @public */
350
+ preflightRepository(projectId: number, baseBranch: string, workBranch: string, signal?: AbortSignal): Promise<void>;
351
+ /** @public */
150
352
  getProject(id: number | string, signal?: AbortSignal): Promise<GitLabProject>;
353
+ /** @internal */
151
354
  listProjects(signal?: AbortSignal): Promise<GitLabProject[]>;
355
+ /** @internal */
152
356
  getGroup(id: number | string, signal?: AbortSignal): Promise<GitLabGroup>;
357
+ /** @internal */
153
358
  listGroupProjects(id: number | string, signal?: AbortSignal): Promise<GitLabProject[]>;
359
+ /** @public */
154
360
  listMergeRequests(id: number, label: string, signal?: AbortSignal): Promise<GitLabMergeRequest[]>;
361
+ /** @internal */
155
362
  getMergeRequest(id: number, iid: number, signal?: AbortSignal): Promise<GitLabMergeRequest>;
363
+ /** @public */
156
364
  getChanges(id: number, iid: number, signal?: AbortSignal): Promise<GitLabDiff[]>;
365
+ /** @public */
157
366
  getBranch(id: number, branch: string, signal?: AbortSignal): Promise<GitLabBranch>;
367
+ /** @internal */
158
368
  getCommit(id: number, sha: string, signal?: AbortSignal): Promise<GitLabCommit>;
369
+ /** @internal */
159
370
  listMergeRequestPipelines(id: number, iid: number, signal?: AbortSignal): Promise<GitLabPipeline[]>;
371
+ /** @internal */
160
372
  listBranchPipelines(id: number, branch: string, sha: string, signal?: AbortSignal): Promise<GitLabPipeline[]>;
373
+ /** @internal */
161
374
  getPipeline(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabPipeline>;
375
+ /** @public */
162
376
  listFailedJobs(id: number, pipeline: number, signal?: AbortSignal): Promise<GitLabJob[]>;
377
+ /** @internal */
163
378
  listNotes(id: number, iid: number, signal?: AbortSignal): Promise<GitLabNote[]>;
379
+ /** @internal */
164
380
  getDiscussion(id: number, iid: number, discussionId: string, signal?: AbortSignal): Promise<GitLabDiscussion>;
381
+ /** @internal */
165
382
  replyToDiscussion(id: number, iid: number, discussionId: string, body: string, signal?: AbortSignal): Promise<GitLabNote>;
383
+ /** @internal */
166
384
  listNoteReactions(id: number, iid: number, noteId: number, signal?: AbortSignal): Promise<GitLabNoteReaction[]>;
385
+ /** @internal */
167
386
  addNoteReaction(id: number, iid: number, noteId: number, name: string, signal?: AbortSignal): Promise<GitLabNoteReaction>;
387
+ /** @public */
168
388
  listMergeRequestFeedback(id: number, iid: number, signal?: AbortSignal): Promise<GitLabFeedback[]>;
389
+ /** @internal */
169
390
  addNote(id: number, iid: number, body: string, signal?: AbortSignal): Promise<GitLabNote>;
391
+ /** @public */
170
392
  resolveGitIdentity(signal?: AbortSignal): Promise<GitLabIdentity>;
393
+ /** @public */
171
394
  getJobTrace(id: number, job: number, maxBytes?: number, signal?: AbortSignal): Promise<{
395
+ /** @public */
172
396
  text: string;
397
+ /** @public */
173
398
  truncated: boolean;
174
399
  }>;
175
400
  }
176
- export type GitLabClientLike = Pick<GitLabClient, keyof GitLabClient>;
401
+ /** @public */
402
+ export type GitLabClientLike = Pick<GitLabClient, "listIssues" | "getIssue" | "updateIssue" | "listIssueNotes" | "addIssueNote" | "listLabels" | "createLabel" | "listBranchMergeRequests" | "createMergeRequest" | "preflightRepository" | "addNote" | "addNoteReaction" | "baseUrl" | "getBranch" | "getChanges" | "getCommit" | "getDiscussion" | "getGroup" | "getJobTrace" | "getMergeRequest" | "getPipeline" | "getProject" | "listBranchPipelines" | "listFailedJobs" | "listGroupProjects" | "listMergeRequestFeedback" | "listMergeRequestPipelines" | "listMergeRequests" | "listNoteReactions" | "listNotes" | "listProjects" | "replyToDiscussion" | "resolveGitIdentity">;
177
403
  /** A pending current pipeline supersedes every older result. Synthetic merges must contain this source head. */
404
+ /** @public */
178
405
  export declare function observeMergeRequest(client: GitLabClientLike, projectId: number, iid: number, signal?: AbortSignal): Promise<GitLabObservation>;
179
406
  //# sourceMappingURL=client.d.ts.map