@leitwerk-dev/gitlab 0.5.11 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/{chunk-KW4UOHAM.js → chunk-JPPNVWMZ.js} +65 -17
- package/dist/chunk-JPPNVWMZ.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/delivery-tools.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/merge-request-template.d.ts +5 -0
- package/dist/merge-request-template.d.ts.map +1 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/testing.js +3 -3
- package/dist/testing.js.map +1 -1
- package/package.json +7 -7
- package/src/client.ts +2 -0
- package/src/delivery-tools.ts +14 -5
- package/src/merge-request-template.ts +60 -0
- package/src/publication.ts +1 -0
- package/src/testing.ts +2 -2
- package/dist/chunk-KW4UOHAM.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/maintenance-labels.ts","../src/maintenance.ts","../src/repository-catalog.ts","../src/setup.ts","../src/delivery-tools.ts","../src/merge-request-template.ts","../src/ticket-creation.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\tignoredCommentUsers?: readonly 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/** SSH clone URL supplied by GitLab. @public */\n\tssh_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\tissues_enabled?: boolean;\n\t/** @internal */\n\tissues_access_level?: string;\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/** @internal */\nexport interface GitLabDiscussionPosition {\n\t/** @internal */\n\tposition_type: \"text\";\n\t/** @internal */\n\tbase_sha: string;\n\t/** @internal */\n\tstart_sha: string;\n\t/** @internal */\n\thead_sha: string;\n\t/** @internal */\n\told_path: string;\n\t/** @internal */\n\tnew_path: string;\n\t/** @internal */\n\told_line?: number;\n\t/** @internal */\n\tnew_line?: number;\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/** Source head verified against pipeline/merge-result ancestry. @internal */\n\tpipelineSourceHead?: string;\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\tignoredCommentUsers: parseIgnoredCommentUsers(item.ignored_comment_users),\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}\n\nfunction parseIgnoredCommentUsers(raw: unknown): string[] {\n\tif (raw === undefined) return [];\n\tif (!Array.isArray(raw) || raw.some((user) => typeof user !== \"string\"))\n\t\tthrow new Error(\"GitLab ignored_comment_users must be a list of usernames\");\n\tconst users = raw.map((user: string) => user.trim().replace(/^@/, \"\").toLowerCase());\n\tif (users.some((user) => !/^[a-z0-9_.-]+$/.test(user)))\n\t\tthrow new Error(\"GitLab ignored_comment_users requires nonempty GitLab usernames\");\n\treturn [...new Set(users)];\n}\nconst projectPath = (id: number | string) => `/projects/${encodeURIComponent(id)}`;\nconst mrPath = (id: number, iid: number) => `${projectPath(id)}/merge_requests/${iid}`;\n\nfunction nextGitLabPage(response: Response, page: number, count: number, perPage = 100) {\n\tconst next = response.headers.get(\"x-next-page\");\n\tif (next === \"\" || (next === null && count < perPage)) return null;\n\treturn next === null ? page + 1 : Number(next);\n}\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 #ignoredCommentUsers: ReadonlySet<string>;\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\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.#ignoredCommentUsers = new Set(parseIgnoredCommentUsers(profile.ignoredCommentUsers));\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 nextPage = nextGitLabPage(response, page, batch.length);\n\t\t\tif (nextPage === null) return rows;\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(\n\t\tid: number,\n\t\tsignal?: AbortSignal,\n\t\tstate: \"opened\" | \"all\" = \"opened\",\n\t): Promise<GitLabIssue[]> {\n\t\treturn this.pages(`${projectPath(id)}/issues?state=${state}&scope=all`, signal);\n\t}\n\t/** @internal */\n\tcreateIssue(\n\t\tid: number,\n\t\tinput: {\n\t\t\t/** @internal */ title: string;\n\t\t\t/** @internal */ description: string;\n\t\t\t/** @internal */ labels: string;\n\t\t},\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabIssue> {\n\t\treturn this.request(`${projectPath(id)}/issues`, signal, input);\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\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\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\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\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/** Read at most one page of matching repositories. @internal */\n\tsearchProjects(search: string, signal?: AbortSignal): Promise<GitLabProject[]> {\n\t\tconst query = new URLSearchParams({\n\t\t\tarchived: \"false\",\n\t\t\tsearch,\n\t\t\tsearch_namespaces: \"true\",\n\t\t\tper_page: \"100\",\n\t\t\tpage: \"1\",\n\t\t\torder_by: \"path\",\n\t\t\tsort: \"asc\",\n\t\t});\n\t\treturn this.request(`/projects?${query}`, signal);\n\t}\n\t/** @internal */\n\tlistRepositoryTree(\n\t\tid: number,\n\t\tref: string,\n\t\tpath = \"\",\n\t\tsignal?: AbortSignal,\n\t): Promise<\n\t\t{\n\t\t\t/** @internal */\n\t\t\tpath: string;\n\t\t\t/** @internal */\n\t\t\ttype: string;\n\t\t\t/** @internal */\n\t\t\tmode?: string;\n\t\t\t/** @internal */\n\t\t\tid: string;\n\t\t}[]\n\t> {\n\t\treturn this.pages(\n\t\t\t`${projectPath(id)}/repository/tree?ref=${encodeURIComponent(ref)}&path=${encodeURIComponent(path)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** @internal */\n\tgetRepositoryFile(\n\t\tid: number,\n\t\tref: string,\n\t\tpath: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @internal */\n\t\tfile_path: string;\n\t\t/** @internal */\n\t\tcontent: string;\n\t\t/** @internal */\n\t\tencoding: string;\n\t\t/** @internal */\n\t\tlast_commit_id: string;\n\t}> {\n\t\treturn this.request(\n\t\t\t`${projectPath(id)}/repository/files/${encodeURIComponent(path)}?ref=${encodeURIComponent(ref)}`,\n\t\t\tsignal,\n\t\t);\n\t}\n\t/** Project-scoped basic blob search at a full commit, one page per request. @internal */\n\tasync searchRepositoryCode(\n\t\tid: number,\n\t\tref: string,\n\t\tsearch: string,\n\t\tpage = 1,\n\t\tperPage = 20,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @internal */ revision: string;\n\t\t/** @internal */ results: {\n\t\t\t/** @internal */ path: string;\n\t\t\t/** @internal */ snippet: string;\n\t\t\t/** @internal */ startLine: number;\n\t\t}[];\n\t\t/** @internal */ page: number;\n\t\t/** @internal */ nextPage: number | null;\n\t}> {\n\t\tif (!/^[a-f0-9]{40,64}$/i.test(ref)) throw new Error(\"Code search requires a full commit ID\");\n\t\tif (!search.trim()) throw new Error(\"Code search requires a search term\");\n\t\tif (\n\t\t\t!Number.isSafeInteger(page) ||\n\t\t\tpage < 1 ||\n\t\t\t!Number.isSafeInteger(perPage) ||\n\t\t\tperPage < 1 ||\n\t\t\tperPage > 100\n\t\t)\n\t\t\tthrow new Error(\"Invalid GitLab search pagination\");\n\t\tconst query = new URLSearchParams({\n\t\t\tscope: \"blobs\",\n\t\t\tsearch_type: \"basic\",\n\t\t\tref,\n\t\t\tsearch,\n\t\t\tpage: String(page),\n\t\t\tper_page: String(perPage),\n\t\t});\n\t\tconst response = await this.response(`${projectPath(id)}/search?${query}`, signal);\n\t\tconst rows = await this.json<{ path: string; data: string; startline: number }[]>(response);\n\t\tif (\n\t\t\t!Array.isArray(rows) ||\n\t\t\trows.some(\n\t\t\t\t(row) =>\n\t\t\t\t\t!row ||\n\t\t\t\t\ttypeof row.path !== \"string\" ||\n\t\t\t\t\ttypeof row.data !== \"string\" ||\n\t\t\t\t\t!Number.isSafeInteger(row.startline),\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(\"Invalid GitLab code search response\");\n\t\tconst nextPage = nextGitLabPage(response, page, rows.length, perPage);\n\t\tif (nextPage !== null && (!Number.isSafeInteger(nextPage) || nextPage <= page))\n\t\t\tthrow new Error(\"Invalid GitLab pagination\");\n\t\treturn {\n\t\t\trevision: ref,\n\t\t\tresults: rows.map((row) => ({ path: row.path, snippet: row.data, startLine: row.startline })),\n\t\t\tpage,\n\t\t\tnextPage,\n\t\t};\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/** Open MRs matching every comma-separated label; null selects all accessible projects. @public */\n\tlistMergeRequests(\n\t\tid: number | null,\n\t\tlabel: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabMergeRequest[]> {\n\t\tconst path = id === null ? \"/merge_requests\" : `${projectPath(id)}/merge_requests`;\n\t\treturn this.pages(`${path}?state=opened&scope=all&labels=${encodeURIComponent(label)}`, signal);\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/** @internal */\n\tgetMergeRequestApprovals(\n\t\tid: number,\n\t\tiid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @internal */\n\t\tuser_has_approved: boolean;\n\t}> {\n\t\treturn this.request(`${mrPath(id, iid)}/approvals`, signal);\n\t}\n\t/** @internal */\n\tapproveMergeRequest(\n\t\tid: number,\n\t\tiid: number,\n\t\tsha: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @internal */\n\t\tsha: string;\n\t}> {\n\t\treturn this.request(`${mrPath(id, iid)}/approve`, signal, { sha });\n\t}\n\t/** @internal */\n\tunapproveMergeRequest(\n\t\tid: number,\n\t\tiid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<{\n\t\t/** @internal */\n\t\tsha: string;\n\t}> {\n\t\treturn this.request(`${mrPath(id, iid)}/unapprove`, signal, {});\n\t}\n\t/** Read every label transition, including changes between watcher polls. @public */\n\tlistMergeRequestLabelEvents(\n\t\tid: number,\n\t\tiid: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabLabelEvent[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/resource_label_events`, signal);\n\t}\n\t/** Apply label deltas without replacing unrelated labels. @public */\n\tupdateMergeRequestLabels(\n\t\tid: number,\n\t\tiid: number,\n\t\tpatch: {\n\t\t\t/** @public */ add_labels?: string;\n\t\t\t/** @public */ remove_labels?: string;\n\t\t},\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabMergeRequest> {\n\t\treturn this.request(mrPath(id, iid), signal, patch, \"PUT\");\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/** Find shared ancestry without cloning a repository. @public */\n\tgetMergeBase(id: number, refs: readonly string[], signal?: AbortSignal): Promise<GitLabCommit> {\n\t\tconst query = new URLSearchParams();\n\t\tfor (const ref of refs) query.append(\"refs[]\", ref);\n\t\treturn this.request(`${projectPath(id)}/repository/merge_base?${query}`, 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\tlistDiscussions(id: number, iid: number, signal?: AbortSignal): Promise<GitLabDiscussion[]> {\n\t\treturn this.pages(`${mrPath(id, iid)}/discussions`, signal);\n\t}\n\t/** @internal */\n\taddDiscussion(\n\t\tid: number,\n\t\tiid: number,\n\t\tbody: string,\n\t\tposition: GitLabDiscussionPosition,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabDiscussion> {\n\t\treturn this.request(`${mrPath(id, iid)}/discussions`, signal, { body, position });\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\tresolveDiscussion(\n\t\tid: number,\n\t\tiid: number,\n\t\tdiscussionId: string,\n\t\tresolved: boolean,\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\t{ resolved },\n\t\t\t\"PUT\",\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\tthis.#ignoredCommentUsers.has(note.author.username.toLowerCase()) ||\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/** @internal */\n\tupdateNote(\n\t\tid: number,\n\t\tiid: number,\n\t\tnoteId: number,\n\t\tbody: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<GitLabNote> {\n\t\treturn this.request(`${mrPath(id, iid)}/notes/${noteId}`, signal, { body }, \"PUT\");\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): 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 interface GitLabLabelEvent {\n\t/** Monotonically increasing GitLab resource-label event identity. @public */\n\tid: number;\n\t/** @public */\n\taction: \"add\" | \"remove\";\n\t/** @public */\n\tcreated_at: string;\n\t/** Deleted labels may have no name. @public */\n\tlabel: {\n\t\t/** @public */\n\t\tname: string;\n\t} | null;\n}\n/** @public */\nexport type GitLabClientLike = Pick<\n\tGitLabClient,\n\t| \"listIssues\"\n\t| \"createIssue\"\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| \"addDiscussion\"\n\t| \"updateNote\"\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| \"getMergeRequestApprovals\"\n\t| \"approveMergeRequest\"\n\t| \"unapproveMergeRequest\"\n\t| \"listMergeRequestLabelEvents\"\n\t| \"updateMergeRequestLabels\"\n\t| \"getPipeline\"\n\t| \"getProject\"\n\t| \"listBranchPipelines\"\n\t| \"listFailedJobs\"\n\t| \"listGroupProjects\"\n\t| \"listMergeRequestFeedback\"\n\t| \"listDiscussions\"\n\t| \"listMergeRequestPipelines\"\n\t| \"listMergeRequests\"\n\t| \"listNoteReactions\"\n\t| \"listNotes\"\n\t| \"listProjects\"\n\t| \"searchProjects\"\n\t| \"replyToDiscussion\"\n\t| \"resolveDiscussion\"\n\t| \"resolveGitIdentity\"\n> &\n\tPartial<\n\t\tPick<\n\t\t\tGitLabClient,\n\t\t\t\"listRepositoryTree\" | \"getRepositoryFile\" | \"getMergeBase\" | \"searchRepositoryCode\"\n\t\t>\n\t>;\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 {\n\t\t\t\tmr,\n\t\t\t\ttargetHead,\n\t\t\t\tpipeline: await client.getPipeline(id, candidate.id, signal),\n\t\t\t\tpipelineSourceHead: mr.sha,\n\t\t\t};\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\t...(latest ? { pipelineSourceHead: mr.sha } : {}),\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\";\nimport type { GitLabRepositoryCatalog } from \"./repository-catalog.js\";\n/** @public */\nexport interface GitLabIntegration {\n\t/** @public */\n\tprofiles(): readonly string[];\n\t/** @public */\n\tclient(profile: string): GitLabClientLike;\n\t/** Cached repository metadata for Settings, supplied by server setup. @public */\n\treadonly repositoryCatalog?: GitLabRepositoryCatalog;\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\nconst hashIdentity = (identity: readonly unknown[]) =>\n\tcreateHash(\"sha256\").update(JSON.stringify(identity)).digest(\"hex\");\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\tintegration?: GitLabIntegration,\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; origin?: 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\tif (\n\t\tbinding.origin !== undefined &&\n\t\tintegration &&\n\t\tintegration.client(binding.profile).baseUrl !== binding.origin\n\t)\n\t\tthrow new Error(\"GitLab profile installation changed from the pinned repository\");\n\treturn { profile: binding.profile, projectId: binding.projectId };\n}\n/** @public */\nexport function resolveGitLabBinding(\n\tctx: Pick<IntegrationToolExecutionContext, \"project\" | \"process\">,\n\tintegration?: GitLabIntegration,\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, integration);\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/** Stable marker shared by retry-safe comment creation and later updates. @public */\nexport function gitLabCommentMarker(input: {\n\t/** @public */\n\tbaseUrl: string;\n\t/** @public */\n\tprojectId: number;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\twriteKey: string;\n\t/** @public */\n\tdiscussionId?: string;\n}): string {\n\tconst identity: (string | number)[] = [\n\t\tinput.baseUrl,\n\t\tinput.projectId,\n\t\tinput.iid,\n\t\tinput.instanceId,\n\t\tinput.writeKey,\n\t];\n\tif (input.discussionId) identity.push(input.discussionId);\n\treturn `<!-- leitwerk:gitlab:${hashIdentity(identity)} -->`;\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/** Revalidated inside the durable write immediately before mutation. @internal */\n\tbeforeWrite?: () => Promise<void>;\n}): Promise<{\n\t/** @internal */\n\tmarker: string;\n}> {\n\tconst { client, writes, instanceId, projectId, iid, writeKey, signal } = input;\n\tconst marker = gitLabCommentMarker({\n\t\tbaseUrl: client.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\twriteKey,\n\t\tdiscussionId: input.discussionId,\n\t});\n\tconst digest = marker.slice(\"<!-- leitwerk:gitlab:\".length, -4);\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: async () => {\n\t\t\t\tawait input.beforeWrite?.();\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/** Idempotently replace a retry-safe top-level comment while retaining its marker. @public */\nexport async function updateGitLabComment(input: {\n\t/** @public */\n\tclient: GitLabClientLike;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tprojectId: number;\n\t/** @public */\n\tiid: number;\n\t/** @public */\n\twriteKey: string;\n\t/** @public */\n\tbody: string;\n\t/** @public */\n\tsignal?: AbortSignal;\n\t/** @public */\n\tbeforeWrite?: () => Promise<void>;\n}): Promise<{\n\t/** @public */\n\tmarker: string;\n}> {\n\tconst { client, instanceId, projectId, iid, writeKey, body, signal } = input;\n\tconst marker = gitLabCommentMarker({\n\t\tbaseUrl: client.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\twriteKey,\n\t});\n\tconst note = (await client.listNotes(projectId, iid, signal)).find((item) =>\n\t\titem.body.includes(marker),\n\t);\n\tif (!note) throw new Error(\"GitLab comment to update was not found\");\n\tconst next = `${body}\\n\\n${marker}`;\n\tif (note.body !== next) {\n\t\tawait input.beforeWrite?.();\n\t\tawait client.updateNote(projectId, iid, note.id, next, signal);\n\t}\n\treturn { marker };\n}\n/** @internal */\nexport async function ensureGitLabInlineComment(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\tpath: string;\n\t/** @internal */\n\tline: number;\n\t/** @internal */\n\tside: \"new\" | \"old\";\n\t/** @internal */\n\tbaseSha: string;\n\t/** @internal */\n\tstartSha: string;\n\t/** @internal */\n\theadSha: string;\n\t/** @internal */\n\tsignal?: AbortSignal;\n}): Promise<{ marker: string; discussionId: string }> {\n\tconst {\n\t\tclient,\n\t\twrites,\n\t\tinstanceId,\n\t\tprojectId,\n\t\tiid,\n\t\twriteKey,\n\t\tbody,\n\t\tpath,\n\t\tline,\n\t\tside,\n\t\tbaseSha,\n\t\tstartSha,\n\t\theadSha,\n\t\tsignal,\n\t} = input;\n\tconst marker = gitLabCommentMarker({\n\t\tbaseUrl: client.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\twriteKey,\n\t});\n\tconst digest = marker.slice(\"<!-- leitwerk:gitlab:\".length, -4);\n\tconst find = async () => {\n\t\tconst discussions = await client.listDiscussions(projectId, iid, signal);\n\t\treturn discussions.find((discussion) =>\n\t\t\tdiscussion.notes.some((note) => note.body.includes(marker)),\n\t\t);\n\t};\n\tconst diff = (await client.getChanges(projectId, iid, signal)).find((candidate) =>\n\t\tside === \"new\" ? candidate.new_path === path : candidate.old_path === path,\n\t);\n\tif (!diff) throw new Error(\"GitLab inline comment path is not in the merge request diff\");\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.discussion\", dedupKey: digest },\n\t\t{\n\t\t\treconcile: () => existingRemote(async () => (await find()) ?? null),\n\t\t\texecute: () =>\n\t\t\t\tclient.addDiscussion(\n\t\t\t\t\tprojectId,\n\t\t\t\t\tiid,\n\t\t\t\t\t`${body}\\n\\n${marker}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tposition_type: \"text\",\n\t\t\t\t\t\tbase_sha: baseSha,\n\t\t\t\t\t\tstart_sha: startSha,\n\t\t\t\t\t\thead_sha: headSha,\n\t\t\t\t\t\told_path: diff.old_path,\n\t\t\t\t\t\tnew_path: diff.new_path,\n\t\t\t\t\t\t...(side === \"new\" ? { new_line: line } : { old_line: line }),\n\t\t\t\t\t},\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\ttoMetadata: (discussion) => ({\n\t\t\t\tprojectId,\n\t\t\t\tiid,\n\t\t\t\tdiscussionId: discussion.id,\n\t\t\t\tmarker,\n\t\t\t}),\n\t\t},\n\t);\n\tconst discussion = await find();\n\tif (!discussion) throw new Error(\"GitLab inline discussion is unavailable after create\");\n\treturn { marker, discussionId: discussion.id };\n}\n/** @public */\nexport async function ensureGitLabResolveDiscussion(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\twriteKey: string;\n\t/** @public */\n\tdiscussionId: string;\n\t/** @public */\n\tsignal?: AbortSignal;\n}): Promise<{ discussionId: string; resolved: boolean }> {\n\tconst { client, writes, instanceId, projectId, iid, writeKey, discussionId, signal } = input;\n\tconst digest = hashIdentity([\n\t\tclient.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\t\"resolve\",\n\t\twriteKey,\n\t\tdiscussionId,\n\t]);\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.discussion.resolve\", dedupKey: digest },\n\t\t{\n\t\t\treconcile: () =>\n\t\t\t\texistingRemote(async () => {\n\t\t\t\t\tconst discussion = await client.getDiscussion(projectId, iid, discussionId, signal);\n\t\t\t\t\treturn discussion.notes.some((note) => note.resolved) ? discussion : null;\n\t\t\t\t}),\n\t\t\texecute: () => client.resolveDiscussion(projectId, iid, discussionId, true, signal),\n\t\t\ttoMetadata: () => ({ projectId, iid, discussionId, resolved: true }),\n\t\t},\n\t);\n\treturn { discussionId, resolved: true };\n}\n/** @internal */\nexport async function ensureGitLabApproval(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\tsha: string;\n\t/** @internal */\n\tsignal?: AbortSignal;\n}): Promise<{ sha: string; approved: boolean }> {\n\tconst { client, writes, instanceId, projectId, iid, writeKey, sha, signal } = input;\n\tif (!/^[a-f0-9]{40}$/i.test(sha)) throw new Error(\"GitLab approval requires the full source SHA\");\n\tconst current = await client.getMergeRequest(projectId, iid, signal);\n\tif (current.sha !== sha) return { sha, approved: false };\n\tconst digest = hashIdentity([\n\t\tclient.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\t\"approve\",\n\t\twriteKey,\n\t\tsha,\n\t]);\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.approval\", dedupKey: digest },\n\t\t{\n\t\t\treconcile: async () => {\n\t\t\t\tconst head = await client.getMergeRequest(projectId, iid, signal);\n\t\t\t\tconst approvals = await client.getMergeRequestApprovals(projectId, iid, signal);\n\t\t\t\treturn head.sha === sha && approvals.user_has_approved ? { sha } : null;\n\t\t\t},\n\t\t\texecute: () => client.approveMergeRequest(projectId, iid, sha, signal),\n\t\t\ttoMetadata: (approval) => ({ projectId, iid, sha: approval.sha }),\n\t\t},\n\t);\n\treturn { sha, approved: true };\n}\n/** @internal */\nexport async function ensureGitLabUnapproval(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\tsha: string;\n\t/** @internal */\n\tsignal?: AbortSignal;\n}): Promise<{ sha: string; unapproved: boolean }> {\n\tconst { client, writes, instanceId, projectId, iid, writeKey, sha, signal } = input;\n\tif (!/^[a-f0-9]{40}$/i.test(sha))\n\t\tthrow new Error(\"GitLab unapprove requires the full source SHA\");\n\tconst current = await client.getMergeRequest(projectId, iid, signal);\n\tif (current.sha !== sha) return { sha, unapproved: false };\n\tconst digest = hashIdentity([\n\t\tclient.baseUrl,\n\t\tprojectId,\n\t\tiid,\n\t\tinstanceId,\n\t\t\"unapprove\",\n\t\twriteKey,\n\t\tsha,\n\t]);\n\ttry {\n\t\tawait writes.ensure(\n\t\t\t{ writeType: \"gitlab.unapproval\", dedupKey: digest },\n\t\t\t{\n\t\t\t\treconcile: async () => {\n\t\t\t\t\tconst head = await client.getMergeRequest(projectId, iid, signal);\n\t\t\t\t\tconst approvals = await client.getMergeRequestApprovals(projectId, iid, signal);\n\t\t\t\t\treturn head.sha === sha && !approvals.user_has_approved ? { sha } : null;\n\t\t\t\t},\n\t\t\t\texecute: async () => {\n\t\t\t\t\tconst head = await client.getMergeRequest(projectId, iid, signal);\n\t\t\t\t\tif (head.sha !== sha) throw new Error(\"GitLab source SHA is no longer HEAD\");\n\t\t\t\t\treturn client.unapproveMergeRequest(projectId, iid, signal);\n\t\t\t\t},\n\t\t\t\ttoMetadata: (removed) => ({ projectId, iid, sha: removed.sha }),\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tif ((await client.getMergeRequest(projectId, iid, signal)).sha !== sha)\n\t\t\treturn { sha, unapproved: false };\n\t\tthrow error;\n\t}\n\treturn { sha, unapproved: true };\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\t/** @public */\n\tbeforeWrite?: () => Promise<void>;\n}): Promise<void> {\n\tconst { client, writes, instanceId, projectId, iid, noteId, signal } = input;\n\tconst digest = hashIdentity([client.baseUrl, projectId, iid, instanceId, \"eyes\", noteId]);\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: async () => {\n\t\t\t\tawait input.beforeWrite?.();\n\t\t\t\treturn client.addNoteReaction(projectId, iid, noteId, \"eyes\", signal);\n\t\t\t},\n\t\t\ttoMetadata: (reaction) => ({ projectId, iid, noteId, reactionId: reaction.id, name: \"eyes\" }),\n\t\t},\n\t);\n}\n/** @internal */\nexport function registerGitLabTools(\n\tapi: ServerExtensionAPI,\n\tintegration: GitLabIntegration,\n\tbeforeWrite?: (ctx: IntegrationToolExecutionContext) => Promise<void>,\n) {\n\tfor (const name of [\n\t\t\"gitlab_inspect_project\",\n\t\t\"gitlab_repository_tree\",\n\t\t\"gitlab_repository_file\",\n\t\t\"gitlab_code_search\",\n\t] as const)\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription:\n\t\t\t\tname === \"gitlab_code_search\"\n\t\t\t\t\t? \"Search blobs in a bound GitLab repository at a full commit. Follow nextPage until null, then read matching files for complete evidence. Search failure is not an empty result.\"\n\t\t\t\t\t: \"Inspect a bound GitLab repository. Use the returned commit ID as ref for subsequent tree/file reads.\",\n\t\t\tparameters:\n\t\t\t\tname === \"gitlab_code_search\"\n\t\t\t\t\t? projectParameters(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tref: { type: \"string\" },\n\t\t\t\t\t\t\t\tsearch: { type: \"string\" },\n\t\t\t\t\t\t\t\tpage: { type: \"integer\", minimum: 1 },\n\t\t\t\t\t\t\t\tperPage: { type: \"integer\", minimum: 1, maximum: 100 },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[\"ref\", \"search\"],\n\t\t\t\t\t\t)\n\t\t\t\t\t: projectParameters(\n\t\t\t\t\t\t\t{ ref: { type: \"string\" }, path: { type: \"string\" } },\n\t\t\t\t\t\t\tname === \"gitlab_inspect_project\"\n\t\t\t\t\t\t\t\t? []\n\t\t\t\t\t\t\t\t: name === \"gitlab_repository_tree\"\n\t\t\t\t\t\t\t\t\t? [\"ref\"]\n\t\t\t\t\t\t\t\t\t: [\"ref\", \"path\"],\n\t\t\t\t\t\t),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst binding = resolveGitLabRepositoryBinding(ctx, integration);\n\t\t\t\tconst client = integration.client(binding.profile);\n\t\t\t\tif (name === \"gitlab_inspect_project\")\n\t\t\t\t\treturn {\n\t\t\t\t\t\tproject: await client.getProject(binding.projectId, ctx.signal),\n\t\t\t\t\t\tbranch: await client.getBranch(binding.projectId, ctx.project!.baseBranch, ctx.signal),\n\t\t\t\t\t};\n\t\t\t\tconst ref = stringArg(args, \"ref\");\n\t\t\t\tif (!/^[a-f0-9]{40,64}$/i.test(ref))\n\t\t\t\t\tthrow new Error(\"Repository reads require a commit ID returned by inspection\");\n\t\t\t\tif (name === \"gitlab_code_search\") {\n\t\t\t\t\tif (!client.searchRepositoryCode)\n\t\t\t\t\t\tthrow new Error(\"GitLab code search unavailable; no search was performed\");\n\t\t\t\t\treturn client.searchRepositoryCode(\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\tref,\n\t\t\t\t\t\tstringArg(args, \"search\"),\n\t\t\t\t\t\targs.page === undefined ? 1 : numberArg(args, \"page\"),\n\t\t\t\t\t\targs.perPage === undefined ? 20 : numberArg(args, \"perPage\"),\n\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (name === \"gitlab_repository_tree\") {\n\t\t\t\t\tif (!client.listRepositoryTree) throw new Error(\"Repository tree inspection unavailable\");\n\t\t\t\t\treturn client.listRepositoryTree(\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\tref,\n\t\t\t\t\t\ttypeof args.path === \"string\" ? args.path : \"\",\n\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!client.getRepositoryFile) throw new Error(\"Repository file inspection unavailable\");\n\t\t\t\tconst file = await client.getRepositoryFile(\n\t\t\t\t\tbinding.projectId,\n\t\t\t\t\tref,\n\t\t\t\t\tstringArg(args, \"path\"),\n\t\t\t\t\tctx.signal,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\t...file,\n\t\t\t\t\tcontent:\n\t\t\t\t\t\tfile.encoding === \"base64\"\n\t\t\t\t\t\t\t? Buffer.from(file.content, \"base64\").toString(\"utf8\")\n\t\t\t\t\t\t\t: file.content,\n\t\t\t\t\tencoding: \"utf8\",\n\t\t\t\t\trevision: ref,\n\t\t\t\t};\n\t\t\t},\n\t\t});\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[\"gitlab_update_comment\", \"Update a retry-safe MR comment\", [\"body\", \"writeKey\"]],\n\t\t[\n\t\t\t\"gitlab_inline_comment\",\n\t\t\t\"Post a retry-safe MR inline discussion\",\n\t\t\t[\"body\", \"writeKey\", \"path\", \"line\", \"side\", \"baseSha\", \"startSha\", \"headSha\"],\n\t\t],\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\t[\n\t\t\t\"gitlab_resolve_discussion\",\n\t\t\t\"Resolve a retry-safe MR inline discussion\",\n\t\t\t[\"writeKey\", \"discussionId\"],\n\t\t],\n\t\t[\n\t\t\t\"gitlab_approve_merge_request\",\n\t\t\t\"Approve the bound MR at an exact source SHA\",\n\t\t\t[\"writeKey\", \"sha\"],\n\t\t],\n\t\t[\n\t\t\t\"gitlab_unapprove_merge_request\",\n\t\t\t\"Remove the bot approval while the reviewed source SHA is still HEAD\",\n\t\t\t[\"writeKey\", \"sha\"],\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\tpath: { type: \"string\" },\n\t\t\t\t\tline: { type: \"integer\" },\n\t\t\t\t\tside: { type: \"string\" },\n\t\t\t\t\tbaseSha: { type: \"string\" },\n\t\t\t\t\tstartSha: { type: \"string\" },\n\t\t\t\t\theadSha: { type: \"string\" },\n\t\t\t\t\tsha: { 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, integration).profile)\n\t\t\t\t\t\t.resolveGitIdentity(ctx.signal);\n\t\t\t\tconst b = resolveGitLabBinding(ctx, integration);\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\tconst writeContext = {\n\t\t\t\t\tclient,\n\t\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\t\tinstanceId: ctx.process.id,\n\t\t\t\t\tprojectId: b.projectId,\n\t\t\t\t\tiid: b.iid,\n\t\t\t\t\tsignal: ctx.signal,\n\t\t\t\t};\n\t\t\t\tif (name === \"gitlab_update_comment\")\n\t\t\t\t\treturn updateGitLabComment({\n\t\t\t\t\t\t...writeContext,\n\t\t\t\t\t\tbeforeWrite: beforeWrite ? () => beforeWrite(ctx) : undefined,\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});\n\t\t\t\tif (name === \"gitlab_inline_comment\") {\n\t\t\t\t\tconst side = stringArg(args, \"side\");\n\t\t\t\t\tif (side !== \"new\" && side !== \"old\")\n\t\t\t\t\t\tthrow new Error(\"GitLab inline comment side must be new or old\");\n\t\t\t\t\treturn ensureGitLabInlineComment({\n\t\t\t\t\t\t...writeContext,\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\tpath: stringArg(args, \"path\"),\n\t\t\t\t\t\tline: numberArg(args, \"line\"),\n\t\t\t\t\t\tside,\n\t\t\t\t\t\tbaseSha: stringArg(args, \"baseSha\"),\n\t\t\t\t\t\tstartSha: stringArg(args, \"startSha\"),\n\t\t\t\t\t\theadSha: stringArg(args, \"headSha\"),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (name === \"gitlab_comment\" || name === \"gitlab_reply\")\n\t\t\t\t\treturn ensureGitLabComment({\n\t\t\t\t\t\t...writeContext,\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});\n\t\t\t\tif (name === \"gitlab_resolve_discussion\")\n\t\t\t\t\treturn ensureGitLabResolveDiscussion({\n\t\t\t\t\t\t...writeContext,\n\t\t\t\t\t\twriteKey: stringArg(args, \"writeKey\"),\n\t\t\t\t\t\tdiscussionId: stringArg(args, \"discussionId\"),\n\t\t\t\t\t});\n\t\t\t\tif (name === \"gitlab_approve_merge_request\")\n\t\t\t\t\treturn ensureGitLabApproval({\n\t\t\t\t\t\t...writeContext,\n\t\t\t\t\t\twriteKey: stringArg(args, \"writeKey\"),\n\t\t\t\t\t\tsha: stringArg(args, \"sha\"),\n\t\t\t\t\t});\n\t\t\t\tif (name === \"gitlab_unapprove_merge_request\")\n\t\t\t\t\treturn ensureGitLabUnapproval({\n\t\t\t\t\t\t...writeContext,\n\t\t\t\t\t\twriteKey: stringArg(args, \"writeKey\"),\n\t\t\t\t\t\tsha: stringArg(args, \"sha\"),\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 */ gitSshProfile?: string;\n\t/** @public */\n\tpollInterval: string;\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 */ gitSshProfile?: string;\n\t/** @public */\n\trepository: GitLabProject;\n\t/** @public */\n\tissue: GitLabIssue;\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\t...(typeof c.git_ssh_profile === \"string\" ? { gitSshProfile: c.git_ssh_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\tconst eligible = (issue: GitLabIssue) =>\n\t\t\t\tissue.state === \"opened\" &&\n\t\t\t\tissue.labels.includes(c.labels.trigger) &&\n\t\t\t\t!issue.labels.includes(c.labels.done);\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 (!eligible(issue)) continue;\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 (!eligible(fresh))\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{\n\t\t\t\t\t\t\tprofile: c.profile,\n\t\t\t\t\t\t\tgitSshProfile: c.gitSshProfile,\n\t\t\t\t\t\t\trepository,\n\t\t\t\t\t\t\tissue,\n\t\t\t\t\t\t\tlabels: c.labels,\n\t\t\t\t\t\t},\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 { type ConflictEvidence, conflictKey } from \"@leitwerk-dev/coding/repository-rebase\";\nimport {\n\ttype CoreServerSetupDeps,\n\tcreateExternalSourcePollReporter,\n\ttype ExternalActionSource,\n\ttype ExternalSourceArmingLike,\n} from \"@leitwerk-dev/process-sdk\";\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\n/** @public */\nexport interface GitLabDeliveryObservation extends GitLabObservation {\n\t/** @public */\n\tprojectKey?: string;\n\t/** Target ancestry suppresses stale conflict/rebase reports after publication. @public */\n\ttargetIntegrated?: boolean;\n\n\t/** @public */\n\tobservationKey?: string;\n\n\t/** @public */\n\tfeedback?: GitLabFeedback[];\n\n\t/** @public */\n\tconflict?: ConflictEvidence;\n}\n\n/** @public */\nexport const GITLAB_ISSUE_CANCELLED_KIND = \"@leitwerk-dev/gitlab.issue-cancelled\";\n\n/** @public */\nexport interface GitLabIssueCancelledConfig {\n\t/** Pinned provider installation. @public */\n\torigin?: string;\n\t/** @public */\n\tprofile: string;\n\n\t/** @public */\n\tprojectId: number;\n\n\t/** @public */\n\tissueIid: number;\n\n\t/** @public */\n\tiid: number;\n\n\t/** @public */\n\ttriggerLabel: string;\n\n\t/** @public */\n\tpollInterval?: string;\n}\n\n/** @internal */\nexport const GITLAB_MR_KIND = \"@leitwerk-dev/gitlab.merge-request\";\n\n/** @public */\nexport interface GitLabSourceConfig {\n\t/** Pinned provider installation. @public */\n\torigin?: string;\n\t/** @public */\n\tprofile: string;\n\n\t/** @public */\n\tprojectId: number;\n\n\t/** @public */\n\tiid: number;\n\n\t/** @public */\n\tpollInterval?: string;\n\n\t/** @public */\n\tafterKey?: string;\n\t/** Optional timer also wakes retry work when GitLab facts have not changed. */\n\n\t/** @public */\n\twakeAt?: number;\n\n\t/** @public */\n\tdelivery?: {\n\t\t/** @public */\n\t\theadSha: string;\n\n\t\t/** @public */\n\t\towner: string;\n\n\t\t/** @public */\n\t\trepo: string;\n\n\t\t/** @public */\n\t\theadBranch: string;\n\n\t\t/** @public */\n\t\tbaseBranch: string;\n\n\t\t/** @public */\n\t\tlastConflictKey?: string | null;\n\t};\n\t/** @public */\n\tfeedback?: {\n\t\t/** @public */\n\t\tafterId: number;\n\n\t\t/** @public */\n\t\tsince?: string;\n\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\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\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\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\n/** @public */\nexport const gitlabExternal = {\n\t/** Observe coordinated repositories with the same revision and feedback policy. @public */\n\tmergeRequests<P, S>(\n\t\tresolve: (ctx: {\n\t\t\t/** @internal */\n\t\t\tparams: P;\n\t\t\t/** @internal */\n\t\t\tstate: S;\n\t\t}) => {\n\t\t\t/** @internal */\n\t\t\trepositories: (GitLabSourceConfig & {\n\t\t\t\t/** @internal */\n\t\t\t\tprojectKey: string;\n\t\t\t})[];\n\t\t},\n\t): ExternalActionSource<P, S, GitLabDeliveryObservation> {\n\t\treturn {\n\t\t\tkind: GITLAB_MR_KIND,\n\t\t\tlabel: \"GitLab merge requests\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n\n\t/** @public */\n\tissueCancelled<P, S>(\n\t\t/** @public */\n\t\tresolve: (ctx: {\n\t\t\t/** @public */\n\t\t\tparams: P;\n\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\n\t/** @public */\n\tmergeRequest<P, S>(\n\t\t/** @public */\n\t\tresolve: (ctx: {\n\t\t\t/** @public */\n\t\t\tparams: P;\n\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\n/** @internal */\nexport function createGitLabProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitLabIntegration,\n\t/** @public */\n\toptions: {\n\t\t/** @internal */\n\t\tnow?: () => 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 report = createExternalSourcePollReporter(deps.externalSources, result, {\n\t\t\t\tforwardGeneration: true,\n\t\t\t\tcurrentKinds: [GITLAB_MR_KIND, GITLAB_ISSUE_CANCELLED_KIND],\n\t\t\t});\n\t\t\tconst pollRepository = async (\n\t\t\t\tarmed: ExternalSourceArmingLike,\n\t\t\t\tc: GitLabSourceConfig & { projectKey?: string },\n\t\t\t) => {\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 ?? \"\"}:${c.projectKey ?? \"\"}`;\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\tif (c.origin && integration.client(c.profile).baseUrl !== c.origin)\n\t\t\t\t\t\tthrow new Error(\"GitLab observation installation changed\");\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.projectKey ? { projectKey: c.projectKey } : {}),\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`${c.projectKey ?? \"\"}:${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_MR_KIND, async (armed) => {\n\t\t\t\tconst config = armed.resolved as unknown as GitLabSourceConfig & {\n\t\t\t\t\trepositories?: (GitLabSourceConfig & { projectKey: string })[];\n\t\t\t\t};\n\t\t\t\tfor (const source of config.repositories ?? [config]) {\n\t\t\t\t\tif (!report.isCurrent(GITLAB_MR_KIND, armed)) break;\n\t\t\t\t\tawait pollRepository(armed, source);\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\tif (c.origin && client.baseUrl !== c.origin)\n\t\t\t\t\tthrow new Error(\"GitLab source issue installation changed\");\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 type { ExternalWrites } from \"@leitwerk-dev/external-writes\";\nimport {\n\ttype GitLabClientLike,\n\tGitLabError,\n\ttype GitLabLabelEvent,\n\ttype GitLabMergeRequest,\n} from \"./client.js\";\n\n/** @public */\nexport const GITLAB_ACTIVE_LABEL = \"leitwerk-active\";\n/** @public */\nexport const GITLAB_DONE_LABEL = \"leitwerk-done\";\n/** @public */\nexport interface GitLabLabelState {\n\t/** @public */ mr: GitLabMergeRequest;\n\t/** @public */ events: GitLabLabelEvent[];\n}\n/** Read transitions before the current labels so remove/re-add cannot hide cancellation. @public */\nexport async function readGitLabLabels(\n\tclient: GitLabClientLike,\n\tprojectId: number,\n\tiid: number,\n\tsignal?: AbortSignal,\n): Promise<GitLabLabelState> {\n\tconst events = await client.listMergeRequestLabelEvents(projectId, iid, signal);\n\tconst mr = await client.getMergeRequest(projectId, iid, signal);\n\treturn { mr, events: events.sort((a, b) => a.id - b.id) };\n}\n/** A missing label endpoint alone does not establish deletion; project access must still work. @internal */\nexport async function readMaintainedGitLabLabels(\n\tclient: GitLabClientLike,\n\tprojectId: number,\n\tiid: number,\n\tsignal?: AbortSignal,\n): Promise<GitLabLabelState | null> {\n\ttry {\n\t\treturn await readGitLabLabels(client, projectId, iid, signal);\n\t} catch (error) {\n\t\tif (!(error instanceof GitLabError) || error.status !== 404) throw error;\n\t\ttry {\n\t\t\tawait client.getMergeRequest(projectId, iid, signal);\n\t\t} catch (mrError) {\n\t\t\tif (!(mrError instanceof GitLabError) || mrError.status !== 404) throw mrError;\n\t\t\tawait client.getProject(projectId, signal);\n\t\t\treturn null;\n\t\t}\n\t\tthrow error;\n\t}\n}\n/** @public */\nexport function gitLabActivationStatus(\n\tafter: number,\n\tlabels: GitLabLabelState,\n): \"pending\" | \"active\" | \"removed\" {\n\tconst events = labels.events.filter(\n\t\t(event) => event.label?.name === GITLAB_ACTIVE_LABEL && event.id > after,\n\t);\n\tif (events.some((event) => event.action === \"remove\")) return \"removed\";\n\tif (!events.length) return \"pending\";\n\treturn labels.mr.labels.includes(GITLAB_ACTIVE_LABEL) ? \"active\" : \"removed\";\n}\n/** All label updates preserve unrelated labels and reconcile uncertain writes. @internal */\nexport async function ensureGitLabMaintenanceLabels(input: {\n\tclient: GitLabClientLike;\n\twrites: ExternalWrites;\n\tprojectId: number;\n\tiid: number;\n\twriteKey: string;\n\tafter: number;\n\tstatus: \"active\" | \"merged\" | \"closed\" | \"stopped\";\n\tguard(): Promise<boolean>;\n\tsignal?: AbortSignal;\n}): Promise<void> {\n\tconst { client, writes, projectId, iid, status, after, signal } = input;\n\tconst settled = async () => {\n\t\tconst labels = await readGitLabLabels(client, projectId, iid, signal);\n\t\tif (!(await input.guard())) throw new Error(\"GitLab label write superseded\");\n\t\tif (status === \"active\")\n\t\t\treturn (\n\t\t\t\tlabels.mr.state !== \"opened\" ||\n\t\t\t\tgitLabActivationStatus(after, labels) === \"removed\" ||\n\t\t\t\t(labels.mr.labels.includes(GITLAB_ACTIVE_LABEL) &&\n\t\t\t\t\t!labels.mr.labels.includes(GITLAB_DONE_LABEL))\n\t\t\t);\n\t\t// An operator's newer activation belongs to a future process.\n\t\tconst active = labels.events.filter(\n\t\t\t(event) => event.label?.name === GITLAB_ACTIVE_LABEL && event.id > after,\n\t\t);\n\t\tif (\n\t\t\tactive.some(\n\t\t\t\t(event, index) =>\n\t\t\t\t\tevent.action === \"add\" &&\n\t\t\t\t\tactive.slice(0, index).some((before) => before.action === \"remove\"),\n\t\t\t)\n\t\t)\n\t\t\treturn true;\n\t\treturn (\n\t\t\t!labels.mr.labels.includes(GITLAB_ACTIVE_LABEL) &&\n\t\t\t(status !== \"merged\" ||\n\t\t\t\tlabels.mr.labels.includes(GITLAB_DONE_LABEL) ||\n\t\t\t\tlabels.events.some(\n\t\t\t\t\t(event) =>\n\t\t\t\t\t\tevent.id > after && event.label?.name === GITLAB_DONE_LABEL && event.action === \"add\",\n\t\t\t\t))\n\t\t);\n\t};\n\tawait writes.ensure(\n\t\t{ writeType: \"gitlab.mr_labels\", dedupKey: input.writeKey },\n\t\t{\n\t\t\treconcile: async (phase) => (phase === \"already_recorded\" || (await settled()) ? true : null),\n\t\t\texecute: async () => {\n\t\t\t\tif (await settled()) return true;\n\t\t\t\tawait client.updateMergeRequestLabels(\n\t\t\t\t\tprojectId,\n\t\t\t\t\tiid,\n\t\t\t\t\tstatus === \"active\"\n\t\t\t\t\t\t? { add_labels: GITLAB_ACTIVE_LABEL, remove_labels: GITLAB_DONE_LABEL }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t...(status === \"merged\" ? { add_labels: GITLAB_DONE_LABEL } : {}),\n\t\t\t\t\t\t\t\tremove_labels: GITLAB_ACTIVE_LABEL,\n\t\t\t\t\t\t\t},\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\ttoMetadata: () => ({ projectId, iid, status }),\n\t\t},\n\t);\n}\n","import { asUnknownRecord, type ProcessInstance, type ProcessProject } from \"@leitwerk-dev/domain\";\nimport type { ExternalWrites } from \"@leitwerk-dev/external-writes\";\nimport {\n\tbindExternalWrites,\n\ttype ExternalWriteLogRepoLike,\n} from \"@leitwerk-dev/external-writes/internal\";\nimport {\n\ttype Codec,\n\ttype CoreServerSetupDeps,\n\tcreateCapabilityToken,\n\ttype ExternalActionSource,\n\ttype ProcessObservationUpdate,\n\ttype ServerExtensionAPI,\n} from \"@leitwerk-dev/process-sdk\";\nimport { emptyPollResult, parseDurationMs } from \"@leitwerk-dev/watcher-utils\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport { type GitLabFeedback, type GitLabObservation, observeMergeRequest } from \"./client.js\";\nimport {\n\ttype GitLabDeliveryObservation,\n\tgitLabFeedbackReadyAt,\n\tobservationKey,\n\tpendingGitLabFeedback,\n} from \"./external.js\";\nimport {\n\tensureGitLabMaintenanceLabels,\n\tGITLAB_ACTIVE_LABEL,\n\tgitLabActivationStatus,\n\treadGitLabLabels,\n\treadMaintainedGitLabLabels,\n} from \"./maintenance-labels.js\";\nimport { ensureGitLabComment, ensureGitLabSeenReaction, resolveGitLabBinding } from \"./tools.js\";\n\n/** @public */\nexport const GITLAB_MAINTAINED_KIND = \"@leitwerk-dev/gitlab.maintained\";\n/** Source for edges declared by a maintained process; no polling code belongs in the process. @public */\nexport function gitlabMaintenanceSource<P, S>(): ExternalActionSource<\n\tP,\n\tS,\n\tGitLabMaintenanceEvent<S>\n> {\n\treturn {\n\t\tkind: GITLAB_MAINTAINED_KIND,\n\t\tlabel: \"GitLab MR maintenance\",\n\t\tconfig: {},\n\t\tinputMode: \"none\",\n\t\tresolve: ({ params, state, projects }) => ({ params, state, projects }),\n\t};\n}\n/** @public */\nexport interface GitLabMaintenanceEvent<S> {\n\t/** @public */\n\tstate: S;\n}\n/** @public */\nexport interface GitLabMaintainedBinding {\n\t/** Process repository key. @public */ projectKey: string;\n\t/** @public */ profile: string;\n\t/** @public */ projectId: number;\n\t/** @public */ iid: number;\n\t/** Pinned installation. @public */ origin?: string;\n}\n/** @public */\nexport interface GitLabMaintenanceSettings {\n\t/** Consumed cursor; advance only after publication or a no-change result. @public */ cursor?: number;\n\t/** @public */ since?: string;\n\t/** @public */ quietPeriodMs?: number;\n\t/** @public */ pollInterval?: string;\n\t/** Original activation boundary, when adopting a receipt. @public */ activationAfter?: number;\n\t/** Existing activation receipt key, retained on upgrade. @public */ activationWriteKey?: string;\n}\n/** @public */\nexport interface GitLabMaintenanceContext<P, S> {\n\t/** @public */ readonly process: ProcessInstance;\n\t/** @public */ readonly projects: readonly ProcessProject[];\n\t/** @public */ readonly params: P;\n\t/** @public */ readonly state: S;\n\t/** @public */ readonly now: number;\n\t/** @public */ readonly signal: AbortSignal;\n\t/** @public */ readonly externalWrites: ExternalWrites;\n\t/** Project-bound operations on the server, using the durable external-write log. @public */\n\tcallIntegrationTool(name: string, args: Record<string, unknown>): Promise<unknown>;\n}\n/** @public */\nexport interface GitLabMaintenanceDecision<S> {\n\t/** @public */ state: S;\n\t/** External action identity declared by the process. @public */ action?: string;\n\t/** Process-specific event fields supplied to its external edge. @public */ event?: Record<\n\t\tstring,\n\t\tunknown\n\t>;\n}\n/** @public */\nexport interface GitLabMaintenanceMessage {\n\t/** @public */ writeKey: string;\n\t/** @public */ body: string;\n\t/** @public */ discussionId?: string;\n}\n/** @public */\nexport interface GitLabMaintainedProcess<\n\tP,\n\tS,\n\tO extends GitLabObservation = GitLabDeliveryObservation,\n> {\n\t/** @public */ processId: string;\n\t/** @public */ paramsCodec: Codec<P>;\n\t/** @public */ stateCodec: Codec<S>;\n\t/** Defaults to gitlabMaintenanceSource. @public */ sourceKind?: string;\n\t/** Defaults to each project's GitLab metadata. @public */ bindings?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t): readonly GitLabMaintainedBinding[];\n\t/** @public */ settings?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): GitLabMaintenanceSettings;\n\t/** Optional process-specific admission and diagnostic reads. @public */ assess?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): Promise<O>;\n\t/** Process-specific routing/scope admission for work, reactions and replies. @public */\n\teligible?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t\tobservation: O,\n\t): boolean;\n\t/** Recheck process-specific write authorization before mutations. @public */\n\tcanWrite?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): Promise<boolean>;\n\t/** @deprecated Startup recovery uses the server's fixed budget. @public */\n\tretry?: GitLabMaintenanceRetry;\n\t/** Pure repair policy; shared maintenance supplies settled feedback and observations. @public */\n\tobserve(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t\tobservation: O & GitLabDeliveryObservation,\n\t): GitLabMaintenanceDecision<S>;\n\t/** Persist a stopped binding in business results. @public */ stopped?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): S;\n\t/** Persist merge/closure in business results. @public */ terminal?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t\tobservation: GitLabObservation,\n\t): S;\n\t/** Existing gated business position used when in-flight work is superseded. @public */ idleTurnId: string;\n\t/** Binding for the selected repair or operator decision; unrelated idle work stays selected. @public */\n\tcurrentBinding?(ctx: GitLabMaintenanceContext<P, S>): string | undefined;\n\t/** Durable replies/exhaustion messages; mechanical delivery stays in the shared server. @public */ messages?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): readonly GitLabMaintenanceMessage[];\n\t/** Clear an acknowledged no-change or published batch. Called only after all messages are durable. @public */ settled?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\tbinding: GitLabMaintainedBinding,\n\t): S;\n\t/** Optional cancellation of the source request, checked during running work and operator waits. @public */\n\tcancelled?(ctx: GitLabMaintenanceContext<P, S>): Promise<boolean>;\n\t/** Pure completion policy; ownership ends before remote completion writes. @public */\n\tcompletion?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\trecords: Readonly<Record<string, GitLabMaintenanceRecord>>,\n\t): \"completed\" | \"aborted\" | undefined;\n\t/** Durable terminal writes; retried after completion without allocating a worker. @public */\n\tcomplete?(\n\t\tctx: GitLabMaintenanceContext<P, S>,\n\t\trecords: Readonly<Record<string, GitLabMaintenanceRecord>>,\n\t): Promise<void>;\n}\n/** @public */\nexport interface GitLabMaintenanceRetry {\n\t/** @deprecated Ignored; the server allows three unaccepted starts per episode. @public */\n\tmaxAttempts: number;\n}\n/** Durable activation and observation, kept separately from worker-owned outcome snapshots. @public */\nexport interface GitLabMaintenanceRecord {\n\t/** @public */ binding: GitLabMaintainedBinding;\n\t/** @public */ after: number;\n\t/** @public */ status: \"active\" | \"stopped\" | \"merged\" | \"closed\" | \"deleted\";\n\t/** @public */ cursor: number;\n\t/** @public */ pendingFeedback: GitLabFeedback[];\n\t/** @public */ observation?: GitLabDeliveryObservation;\n\t/** @public */ refreshError?: string;\n}\n/** @public */\nexport interface GitLabMaintenance {\n\t/** @public */ register<P, S, O extends GitLabObservation>(\n\t\tpolicy: GitLabMaintainedProcess<P, S, O>,\n\t): void;\n\t/** Recheck remote ownership immediately before publication, replies or reactions. @public */\n\tassertOwnership(instanceId: string, projectKey: string, signal?: AbortSignal): Promise<void>;\n\t/** @public */ ownsProcess(processId: string): boolean;\n}\n/** @public */\nexport const gitlabMaintenance = createCapabilityToken<GitLabMaintenance>(\n\t\"@leitwerk-dev/gitlab.maintenance\",\n);\n/** Register a typed process policy through the existing capability registry. @public */\nexport function registerGitLabMaintainedProcess<P, S, O extends GitLabObservation>(\n\tapi: ServerExtensionAPI,\n\tpolicy: GitLabMaintainedProcess<P, S, O>,\n): void {\n\tconst service = api.require(gitlabMaintenance);\n\tif (Array.isArray(service)) throw new Error(\"GitLab maintenance must be singular\");\n\tservice.register(policy);\n}\n/** @internal */\nexport const maintenanceRecords = (\n\tprocess: ProcessInstance,\n): Record<string, GitLabMaintenanceRecord> =>\n\t(asUnknownRecord(process.metadata?.gitlabMaintenance) ?? {}) as Record<\n\t\tstring,\n\t\tGitLabMaintenanceRecord\n\t>;\n\n/** One server service owns all registered processes, including running work and operator waits. @internal */\nexport function createGitLabMaintenance(\n\tapi: ServerExtensionAPI,\n\tdeps: CoreServerSetupDeps,\n\tintegration: GitLabIntegration,\n\tnow: () => number = Date.now,\n): GitLabMaintenance & {\n\t/** @internal */\n\tpoll(): Promise<ReturnType<typeof emptyPollResult>>;\n} {\n\tconst policies = new Map<string, GitLabMaintainedProcess<unknown, unknown>>();\n\tconst due = new Map<string, { at: number; failures: number; inputs: string }>();\n\tconst completionDue = new Map<string, { at: number; failures: number }>();\n\tconst workKey = (process: ProcessInstance) =>\n\t\tJSON.stringify([\n\t\t\tprocess.paramsJson,\n\t\t\tprocess.stateJson,\n\t\t\tprocess.planRevision,\n\t\t\tprocess.selectedTurnId,\n\t\t\tprocess.lifecycleStatus,\n\t\t\tprocess.currentExecution,\n\t\t]);\n\tconst repo = deps.externalWrites as ExternalWriteLogRepoLike;\n\tconst observe = (expected: ProcessInstance, update: Omit<ProcessObservationUpdate, \"expected\">) =>\n\t\tdeps.commands.applyProcessObservation(expected.id, { expected, ...update });\n\tconst context = (\n\t\tprocess: ProcessInstance,\n\t\tpolicy: GitLabMaintainedProcess<unknown, unknown>,\n\t): GitLabMaintenanceContext<unknown, unknown> => ({\n\t\tprocess,\n\t\tprojects: deps.projects.listByInstance(process.id),\n\t\tparams: policy.paramsCodec.parse(JSON.parse(process.paramsJson ?? \"null\")),\n\t\tstate: policy.stateCodec.parse(JSON.parse(process.stateJson ?? \"null\")),\n\t\tnow: now(),\n\t\tsignal: AbortSignal.timeout(30_000),\n\t\texternalWrites: bindExternalWrites(repo, process.id),\n\t\tcallIntegrationTool: (name, args) => {\n\t\t\tif (!deps.callIntegrationTool)\n\t\t\t\tthrow new Error(\"Server maintenance operations are unavailable\");\n\t\t\treturn deps.callIntegrationTool(\n\t\t\t\tprocess,\n\t\t\t\tString(args.projectKey ?? \"repo\"),\n\t\t\t\tname,\n\t\t\t\targs,\n\t\t\t\tAbortSignal.timeout(30_000),\n\t\t\t);\n\t\t},\n\t});\n\tconst bindings = (\n\t\tctx: GitLabMaintenanceContext<unknown, unknown>,\n\t\tpolicy: GitLabMaintainedProcess<unknown, unknown>,\n\t) =>\n\t\tpolicy.bindings?.(ctx) ??\n\t\tctx.projects.flatMap((project) => {\n\t\t\tif (!asUnknownRecord(project.metadata?.gitlab)?.iid) return [];\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tprojectKey: project.key,\n\t\t\t\t\t...resolveGitLabBinding({ process: ctx.process, project }, integration),\n\t\t\t\t\torigin: asUnknownRecord(project.metadata?.gitlab)?.origin as string | undefined,\n\t\t\t\t},\n\t\t\t];\n\t\t});\n\tconst completionStatus = (\n\t\tctx: GitLabMaintenanceContext<unknown, unknown>,\n\t\tpolicy: GitLabMaintainedProcess<unknown, unknown>,\n\t\trecords: Record<string, GitLabMaintenanceRecord>,\n\t) => {\n\t\tif (Object.values(records).some((record) => record.status === \"deleted\"))\n\t\t\treturn \"aborted\" as const;\n\t\tif (policy.completion) return policy.completion(ctx, records);\n\t\treturn bindings(ctx, policy).every(\n\t\t\t(binding) => records[binding.projectKey] && records[binding.projectKey].status !== \"active\",\n\t\t)\n\t\t\t? Object.values(records).some((record) => record.status === \"merged\")\n\t\t\t\t? (\"completed\" as const)\n\t\t\t\t: (\"aborted\" as const)\n\t\t\t: undefined;\n\t};\n\tconst live = (process: ProcessInstance) =>\n\t\t![\"completed\", \"aborted\"].includes(process.lifecycleStatus);\n\tconst unchangedWork = (fresh: ProcessInstance, expected: ProcessInstance) =>\n\t\tworkKey(fresh) === workKey(expected);\n\tconst same = (expected: ProcessInstance) => {\n\t\tconst fresh = deps.processes.getById(expected.id);\n\t\treturn (\n\t\t\t!!fresh &&\n\t\t\tunchangedWork(fresh, expected) &&\n\t\t\tJSON.stringify(fresh.metadata?.gitlabMaintenance) ===\n\t\t\t\tJSON.stringify(expected.metadata?.gitlabMaintenance)\n\t\t);\n\t};\n\tconst scheduleNext = (\n\t\tkey: string,\n\t\tprocess: ProcessInstance,\n\t\tsettings: GitLabMaintenanceSettings,\n\t) =>\n\t\tdue.set(key, {\n\t\t\tat: now() + parseDurationMs(settings.pollInterval ?? \"30s\", 30_000),\n\t\t\tfailures: 0,\n\t\t\tinputs: workKey(deps.processes.getById(process.id) ?? process),\n\t\t});\n\tconst service: GitLabMaintenance = {\n\t\tregister(policy) {\n\t\t\tif (\n\t\t\t\tpolicy.retry &&\n\t\t\t\t(!Number.isInteger(policy.retry.maxAttempts) || policy.retry.maxAttempts < 0)\n\t\t\t)\n\t\t\t\tthrow new Error(\"GitLab maintenance retries must be a nonnegative integer\");\n\t\t\tif (policies.has(policy.processId))\n\t\t\t\tthrow new Error(`Duplicate GitLab maintenance policy '${policy.processId}'`);\n\t\t\tpolicies.set(\n\t\t\t\tpolicy.processId,\n\t\t\t\tpolicy as unknown as GitLabMaintainedProcess<unknown, unknown>,\n\t\t\t);\n\t\t},\n\t\townsProcess: (processId) => policies.has(processId),\n\t\tasync assertOwnership(instanceId, projectKey, signal) {\n\t\t\tlet process = deps.processes.getById(instanceId);\n\t\t\tif (!process || !live(process)) throw new Error(\"GitLab maintenance ownership ended\");\n\t\t\tconst policy = policies.get(process.processId);\n\t\t\tif (!policy) return;\n\t\t\tlet ctx = context(process, policy);\n\t\t\tconst binding = bindings(ctx, policy).find((item) => item.projectKey === projectKey);\n\t\t\tif (!binding) return; // Initial publication has not created its MR yet.\n\t\t\tlet record = maintenanceRecords(process)[projectKey];\n\t\t\tif (record && record.status !== \"active\")\n\t\t\t\tthrow new Error(\"GitLab maintenance ownership ended\");\n\t\t\tconst client = integration.client(binding.profile);\n\t\t\tif (binding.origin && binding.origin !== client.baseUrl)\n\t\t\t\tthrow new Error(\"GitLab installation changed\");\n\t\t\tlet labels = await readGitLabLabels(client, binding.projectId, binding.iid, signal);\n\t\t\tconst settings = policy.settings?.(ctx, binding) ?? {};\n\t\t\tconst activationKey =\n\t\t\t\tsettings.activationWriteKey ?? `gitlab:active:${process.id}:${projectKey}:${binding.iid}`;\n\t\t\tif (!record) {\n\t\t\t\tif (repo.hasDedupKey(activationKey) && !labels.mr.labels.includes(GITLAB_ACTIVE_LABEL))\n\t\t\t\t\tthrow new Error(\"GitLab maintenance ownership ended\");\n\t\t\t\trecord = {\n\t\t\t\t\tbinding,\n\t\t\t\t\tafter: settings.activationAfter ?? labels.events.at(-1)?.id ?? 0,\n\t\t\t\t\tstatus: \"active\",\n\t\t\t\t\tcursor: settings.cursor ?? 0,\n\t\t\t\t\tpendingFeedback: [],\n\t\t\t\t};\n\t\t\t\tconst saved = await observe(process, {\n\t\t\t\t\tprojectsJson: JSON.stringify(ctx.projects),\n\t\t\t\t\tmetadata: { gitlabMaintenance: { ...maintenanceRecords(process), [projectKey]: record } },\n\t\t\t\t\tpreserveUpdatedAt: true,\n\t\t\t\t});\n\t\t\t\tif (!saved.ok) throw new Error(\"GitLab maintenance ownership changed\");\n\t\t\t\tprocess = deps.processes.getById(instanceId);\n\t\t\t\tif (!process || !live(process)) throw new Error(\"GitLab maintenance ownership ended\");\n\t\t\t\tconst adopted = process;\n\t\t\t\tawait ensureGitLabMaintenanceLabels({\n\t\t\t\t\tclient,\n\t\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\t\tprojectId: binding.projectId,\n\t\t\t\t\tiid: binding.iid,\n\t\t\t\t\tafter: record.after,\n\t\t\t\t\tstatus: \"active\",\n\t\t\t\t\twriteKey: activationKey,\n\t\t\t\t\tguard: async () => same(adopted),\n\t\t\t\t\tsignal,\n\t\t\t\t});\n\t\t\t\tlabels = await readGitLabLabels(client, binding.projectId, binding.iid, signal);\n\t\t\t\tctx = context(process, policy);\n\t\t\t}\n\t\t\tconst after = record.after;\n\t\t\tif (\n\t\t\t\t!same(process) ||\n\t\t\t\tlabels.mr.state !== \"opened\" ||\n\t\t\t\tgitLabActivationStatus(after, labels) === \"removed\" ||\n\t\t\t\t!labels.mr.labels.includes(GITLAB_ACTIVE_LABEL)\n\t\t\t)\n\t\t\t\tthrow new Error(\"GitLab maintenance ownership ended\");\n\t\t\tif (policy.canWrite && !(await policy.canWrite(ctx, binding)))\n\t\t\t\tthrow new Error(\"GitLab maintenance writes are suspended by process policy\");\n\t\t},\n\t};\n\tapi.provide(gitlabMaintenance, service);\n\tconst polling = deps.polling.create({\n\t\tid: \"gitlab-maintenance\",\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\tfor (const snapshot of deps.processes.listAll()) {\n\t\t\t\tconst policy = policies.get(snapshot.processId);\n\t\t\t\tif (!policy) continue;\n\t\t\t\tlet ctx = context(snapshot, policy);\n\t\t\t\tfor (const binding of bindings(ctx, policy)) {\n\t\t\t\t\tconst key = `${snapshot.id}:${binding.projectKey}`;\n\t\t\t\t\tconst previous = due.get(key);\n\t\t\t\t\tif (previous && previous.at > now() && previous.inputs === workKey(snapshot)) continue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst process = deps.processes.getById(snapshot.id);\n\t\t\t\t\t\tif (!process) continue;\n\t\t\t\t\t\tctx = context(process, policy);\n\t\t\t\t\t\tconst settings = policy.settings?.(ctx, binding) ?? {};\n\t\t\t\t\t\tconst known = maintenanceRecords(process)[binding.projectKey];\n\t\t\t\t\t\tif (known?.status === \"deleted\") continue;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tknown &&\n\t\t\t\t\t\t\tknown.status !== \"active\" &&\n\t\t\t\t\t\t\tprocess.metadata?.gitlabMaintenanceCompleted &&\n\t\t\t\t\t\t\trepo.hasDedupKey(\n\t\t\t\t\t\t\t\t`gitlab:${known.status}:${process.id}:${binding.projectKey}:${binding.iid}`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tconst client = integration.client(binding.profile);\n\t\t\t\t\t\tif (binding.origin && client.baseUrl !== binding.origin)\n\t\t\t\t\t\t\tthrow new Error(\"GitLab installation changed\");\n\t\t\t\t\t\tconst labels = await readMaintainedGitLabLabels(\n\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\t\tbinding.iid,\n\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst records = structuredClone(maintenanceRecords(process));\n\t\t\t\t\t\tlet record = records[binding.projectKey];\n\t\t\t\t\t\tif (record && JSON.stringify(record.binding) !== JSON.stringify(binding))\n\t\t\t\t\t\t\tthrow new Error(\"Maintained MR binding changed\");\n\t\t\t\t\t\tif (!record)\n\t\t\t\t\t\t\trecord = records[binding.projectKey] = {\n\t\t\t\t\t\t\t\tbinding,\n\t\t\t\t\t\t\t\tafter: settings.activationAfter ?? labels?.events.at(-1)?.id ?? 0,\n\t\t\t\t\t\t\t\tstatus: \"active\",\n\t\t\t\t\t\t\t\tcursor: settings.cursor ?? 0,\n\t\t\t\t\t\t\t\tpendingFeedback: [],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\trecord.cursor = Math.max(record.cursor, settings.cursor ?? 0);\n\t\t\t\t\t\tconst activationKey =\n\t\t\t\t\t\t\tsettings.activationWriteKey ??\n\t\t\t\t\t\t\t`gitlab:active:${process.id}:${binding.projectKey}:${binding.iid}`;\n\t\t\t\t\t\tlet stopped = false;\n\t\t\t\t\t\tlet state = ctx.state;\n\t\t\t\t\t\tif (!labels) {\n\t\t\t\t\t\t\trecord.status = \"deleted\";\n\t\t\t\t\t\t\trecord.pendingFeedback = [];\n\t\t\t\t\t\t\tdelete record.observation;\n\t\t\t\t\t\t\tstate = policy.stopped?.(ctx, binding) ?? state;\n\t\t\t\t\t\t\tstopped = true;\n\t\t\t\t\t\t} else if (record.status === \"active\") {\n\t\t\t\t\t\t\tif (labels.mr.state !== \"opened\") {\n\t\t\t\t\t\t\t\trecord.status = labels.mr.state === \"merged\" ? \"merged\" : \"closed\";\n\t\t\t\t\t\t\t\tstate = policy.terminal?.(ctx, binding, { mr: labels.mr, pipeline: null }) ?? state;\n\t\t\t\t\t\t\t\tstopped = true;\n\t\t\t\t\t\t\t\t// Recovery does not need a living worker or an enabled discovery watcher.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t!live(process) ||\n\t\t\t\t\t\t\t\tgitLabActivationStatus(record.after, labels) === \"removed\" ||\n\t\t\t\t\t\t\t\t(repo.hasDedupKey(activationKey) && !labels.mr.labels.includes(GITLAB_ACTIVE_LABEL))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\trecord.status = \"stopped\";\n\t\t\t\t\t\t\t\tstate = policy.stopped?.(ctx, binding) ?? state;\n\t\t\t\t\t\t\t\tstopped = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdelete record.refreshError;\n\t\t\t\t\t\tconst terminalStatus =\n\t\t\t\t\t\t\tstopped && live(process)\n\t\t\t\t\t\t\t\t? completionStatus({ ...ctx, state }, policy, records)\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tconst saved = await observe(process, {\n\t\t\t\t\t\t\tprojectsJson: JSON.stringify(ctx.projects),\n\t\t\t\t\t\t\tmetadata: { gitlabMaintenance: records },\n\t\t\t\t\t\t\t...(state !== ctx.state ? { state } : {}),\n\t\t\t\t\t\t\t...(terminalStatus ? { lifecycleStatus: terminalStatus } : {}),\n\t\t\t\t\t\t\t...(stopped &&\n\t\t\t\t\t\t\t!terminalStatus &&\n\t\t\t\t\t\t\tlive(process) &&\n\t\t\t\t\t\t\t(process.currentExecution ||\n\t\t\t\t\t\t\t\t(process.selectedTurnId !== policy.idleTurnId &&\n\t\t\t\t\t\t\t\t\t(!policy.currentBinding || policy.currentBinding(ctx) === binding.projectKey)))\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\tinterrupt: {\n\t\t\t\t\t\t\t\t\t\t\tturnId: policy.idleTurnId,\n\t\t\t\t\t\t\t\t\t\t\treason: \"MR maintenance ownership ended\",\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\tpreserveUpdatedAt: !stopped,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!saved.ok) continue;\n\t\t\t\t\t\tlet fresh = deps.processes.getById(process.id);\n\t\t\t\t\t\tif (!fresh) continue;\n\t\t\t\t\t\t// A deleted MR has no labels, discussions or publication to reconcile.\n\t\t\t\t\t\tif (record.status === \"deleted\") continue;\n\t\t\t\t\t\tconst remoteWriteContext = <T extends object>(payload: T) => ({\n\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\t\t\t\tinstanceId: process.id,\n\t\t\t\t\t\t\tprojectId: binding.projectId,\n\t\t\t\t\t\t\tiid: binding.iid,\n\t\t\t\t\t\t\t...payload,\n\t\t\t\t\t\t\tsignal: ctx.signal,\n\t\t\t\t\t\t\tbeforeWrite: () =>\n\t\t\t\t\t\t\t\tservice.assertOwnership(fresh?.id ?? \"\", binding.projectKey, ctx.signal),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait ensureGitLabMaintenanceLabels({\n\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\twrites: ctx.externalWrites,\n\t\t\t\t\t\t\tprojectId: binding.projectId,\n\t\t\t\t\t\t\tiid: binding.iid,\n\t\t\t\t\t\t\tafter: record.after,\n\t\t\t\t\t\t\tstatus: record.status,\n\t\t\t\t\t\t\twriteKey:\n\t\t\t\t\t\t\t\trecord.status === \"active\"\n\t\t\t\t\t\t\t\t\t? activationKey\n\t\t\t\t\t\t\t\t\t: `gitlab:${record.status}:${process.id}:${binding.projectKey}:${binding.iid}`,\n\t\t\t\t\t\t\tguard: async () => same(fresh as ProcessInstance),\n\t\t\t\t\t\t\tsignal: ctx.signal,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!live(fresh) || record.status !== \"active\") {\n\t\t\t\t\t\t\tscheduleNext(key, process, settings);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tctx = context(fresh, policy);\n\t\t\t\t\t\tconst observation = policy.assess\n\t\t\t\t\t\t\t? await policy.assess(ctx, binding)\n\t\t\t\t\t\t\t: await observeMergeRequest(client, binding.projectId, binding.iid, ctx.signal);\n\t\t\t\t\t\tconst eligible = policy.eligible?.(ctx, binding, observation) ?? true;\n\t\t\t\t\t\tconst feedback = eligible\n\t\t\t\t\t\t\t? pendingGitLabFeedback(\n\t\t\t\t\t\t\t\t\t\"feedback\" in observation\n\t\t\t\t\t\t\t\t\t\t? ((observation.feedback as GitLabFeedback[]) ?? [])\n\t\t\t\t\t\t\t\t\t\t: await client.listMergeRequestFeedback(\n\t\t\t\t\t\t\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\t\t\t\t\t\t\tbinding.iid,\n\t\t\t\t\t\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tMath.max(record.cursor, settings.cursor ?? 0),\n\t\t\t\t\t\t\t\t\tsettings.since,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\t\tfor (const note of feedback) {\n\t\t\t\t\t\t\tawait service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);\n\t\t\t\t\t\t\tawait ensureGitLabSeenReaction(remoteWriteContext({ noteId: note.id }));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst ready = gitLabFeedbackReadyAt(feedback, settings.quietPeriodMs ?? 120_000);\n\t\t\t\t\t\tconst targetIntegrated =\n\t\t\t\t\t\t\tobservation.targetHead &&\n\t\t\t\t\t\t\tclient.getMergeBase &&\n\t\t\t\t\t\t\tobservation.mr.source_project_id === observation.mr.target_project_id &&\n\t\t\t\t\t\t\t(observation.mr.has_conflicts ||\n\t\t\t\t\t\t\t\t[\"conflict\", \"need_rebase\"].includes(observation.mr.detailed_merge_status ?? \"\"))\n\t\t\t\t\t\t\t\t? (\n\t\t\t\t\t\t\t\t\t\tawait client.getMergeBase(\n\t\t\t\t\t\t\t\t\t\t\tobservation.mr.source_project_id,\n\t\t\t\t\t\t\t\t\t\t\t[observation.mr.sha, observation.targetHead],\n\t\t\t\t\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t).id === observation.targetHead\n\t\t\t\t\t\t\t\t: false;\n\t\t\t\t\t\tconst observed = {\n\t\t\t\t\t\t\t...observation,\n\t\t\t\t\t\t\ttargetIntegrated,\n\t\t\t\t\t\t\tprojectKey: binding.projectKey,\n\t\t\t\t\t\t\tobservationKey: observationKey(observation),\n\t\t\t\t\t\t\tfeedback: ready !== null && ready <= now() ? feedback : [],\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst decision = policy.observe(ctx, binding, observed);\n\t\t\t\t\t\trecord.observation = observed;\n\t\t\t\t\t\trecord.pendingFeedback = feedback;\n\t\t\t\t\t\tconst observedRecords = { ...maintenanceRecords(fresh), [binding.projectKey]: record };\n\t\t\t\t\t\tconst updated = await observe(fresh, {\n\t\t\t\t\t\t\tprojectsJson: JSON.stringify(ctx.projects),\n\t\t\t\t\t\t\tmetadata: { gitlabMaintenance: observedRecords },\n\t\t\t\t\t\t\t...(!fresh.currentExecution && decision.state !== ctx.state && !decision.action\n\t\t\t\t\t\t\t\t? { state: decision.state }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\tpreserveUpdatedAt: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!updated.ok) continue;\n\t\t\t\t\t\tfresh = deps.processes.getById(process.id);\n\t\t\t\t\t\tif (!fresh) continue;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\teligible &&\n\t\t\t\t\t\t\tdecision.action &&\n\t\t\t\t\t\t\tfresh.lifecycleStatus === \"waiting\" &&\n\t\t\t\t\t\t\tunchangedWork(fresh, ctx.process)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst armed = deps.externalSources\n\t\t\t\t\t\t\t\t.listArmed(policy.sourceKind ?? GITLAB_MAINTAINED_KIND)\n\t\t\t\t\t\t\t\t.find(\n\t\t\t\t\t\t\t\t\t(item) =>\n\t\t\t\t\t\t\t\t\t\titem.instanceId === process.id && item.externalActionId === decision.action,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (armed) {\n\t\t\t\t\t\t\t\tawait service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);\n\t\t\t\t\t\t\t\tconst fired = await deps.externalSources.fire({\n\t\t\t\t\t\t\t\t\tinstanceId: fresh.id,\n\t\t\t\t\t\t\t\t\tarmingId: armed.id,\n\t\t\t\t\t\t\t\t\tgeneration: armed.generation,\n\t\t\t\t\t\t\t\t\tevent: { ...decision.event, state: decision.state },\n\t\t\t\t\t\t\t\t\tmergeKey: `${binding.projectKey}:${observed.observationKey}:${feedback.map((note) => note.id)}`,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (!fired.ok) continue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfresh = deps.processes.getById(process.id);\n\t\t\t\t\t\tif (!fresh || !live(fresh)) continue;\n\t\t\t\t\t\tctx = context(fresh, policy);\n\t\t\t\t\t\tfor (const message of eligible ? (policy.messages?.(ctx, binding) ?? []) : []) {\n\t\t\t\t\t\t\tawait service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);\n\t\t\t\t\t\t\tawait ensureGitLabComment(remoteWriteContext(message));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst settledState = eligible\n\t\t\t\t\t\t\t? (policy.settled?.(ctx, binding) ?? ctx.state)\n\t\t\t\t\t\t\t: ctx.state;\n\t\t\t\t\t\tif (!fresh.currentExecution && settledState !== ctx.state)\n\t\t\t\t\t\t\tawait observe(fresh, { state: settledState });\n\t\t\t\t\t\tfresh = deps.processes.getById(process.id);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfresh &&\n\t\t\t\t\t\t\teligible &&\n\t\t\t\t\t\t\tfresh.lifecycleStatus === \"error\" &&\n\t\t\t\t\t\t\tfresh.currentExecution?.kind === \"worker_start\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tawait service.assertOwnership(fresh.id, binding.projectKey, ctx.signal);\n\t\t\t\t\t\t\tawait deps.commands.retryStartupAutomatically(fresh.id, fresh.currentExecution.id);\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tfresh?.lifecycleStatus === \"waiting\" &&\n\t\t\t\t\t\t\t!fresh.currentExecution &&\n\t\t\t\t\t\t\tfresh.selectedTurnId === policy.idleTurnId &&\n\t\t\t\t\t\t\tfresh.metadata?.gitlabMaintenanceRetry\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tawait observe(fresh, {\n\t\t\t\t\t\t\t\tmetadata: { gitlabMaintenanceRetry: null },\n\t\t\t\t\t\t\t\tpreserveUpdatedAt: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tscheduleNext(key, process, settings);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\terror instanceof Error ? error.message : \"GitLab maintenance unavailable\";\n\t\t\t\t\t\tconst failures = (previous?.failures ?? 0) + 1;\n\t\t\t\t\t\tdue.set(key, {\n\t\t\t\t\t\t\tat: now() + Math.min(300_000, 30_000 * 2 ** Math.min(failures - 1, 4)),\n\t\t\t\t\t\t\tfailures,\n\t\t\t\t\t\t\tinputs: workKey(deps.processes.getById(snapshot.id) ?? snapshot),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst fresh = deps.processes.getById(snapshot.id);\n\t\t\t\t\t\tif (fresh) {\n\t\t\t\t\t\t\tconst records = structuredClone(maintenanceRecords(fresh));\n\t\t\t\t\t\t\tif (records[binding.projectKey]) {\n\t\t\t\t\t\t\t\trecords[binding.projectKey].refreshError = message;\n\t\t\t\t\t\t\t\tawait observe(fresh, { metadata: { gitlabMaintenance: records } });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult.errors.push(`${key}:${message}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tlet current = deps.processes.getById(snapshot.id);\n\t\t\t\tif (\n\t\t\t\t\tcurrent &&\n\t\t\t\t\t!current.metadata?.gitlabMaintenanceCompleted &&\n\t\t\t\t\tbindings(context(current, policy), policy).length\n\t\t\t\t) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx = context(current, policy);\n\t\t\t\t\t\tconst records = maintenanceRecords(current);\n\t\t\t\t\t\tconst schedule = completionDue.get(current.id);\n\t\t\t\t\t\tconst pureStatus = completionStatus(ctx, policy, records);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tschedule &&\n\t\t\t\t\t\t\tschedule.at > now() &&\n\t\t\t\t\t\t\t(schedule.failures > 0 || (!pureStatus && live(current)))\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tconst status =\n\t\t\t\t\t\t\tpureStatus ??\n\t\t\t\t\t\t\t(live(current) && (await policy.cancelled?.(ctx)) ? \"aborted\" : undefined);\n\t\t\t\t\t\tif (status && live(current)) {\n\t\t\t\t\t\t\tconst ended = await observe(current, { lifecycleStatus: status });\n\t\t\t\t\t\t\tif (!ended.ok) continue;\n\t\t\t\t\t\t\tcurrent = deps.processes.getById(current.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (current && (status || !live(current))) {\n\t\t\t\t\t\t\tawait policy.complete?.(context(current, policy), maintenanceRecords(current));\n\t\t\t\t\t\t\tawait observe(current, {\n\t\t\t\t\t\t\t\tmetadata: { gitlabMaintenanceCompleted: true },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcompletionDue.set(snapshot.id, { at: now() + 30_000, failures: 0 });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst failures = (completionDue.get(snapshot.id)?.failures ?? 0) + 1;\n\t\t\t\t\t\tcompletionDue.set(snapshot.id, {\n\t\t\t\t\t\t\tat: now() + Math.min(300_000, 30_000 * 2 ** Math.min(failures - 1, 4)),\n\t\t\t\t\t\t\tfailures,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresult.errors.push(\n\t\t\t\t\t\t\t`${snapshot.id}:${error instanceof Error ? error.message : \"Completion delivery unavailable\"}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t});\n\treturn { ...service, /** @internal */ poll: () => polling.poll() };\n}\n","import type { GitLabIntegration } from \"./capability.js\";\nimport type { GitLabProject } from \"./client.js\";\n\n/** Server-owned repository metadata for Settings. @public */\nexport interface GitLabRepositoryCatalog {\n\t/** Reuse the last successful scan, loading it once when empty. @public */\n\tlist(profile: string): Promise<readonly GitLabProject[]>;\n\t/** Search a cached scan or one remote page; repeated queries share cached results. @public */\n\tsearch(profile: string, query: string): Promise<readonly GitLabProject[]>;\n\t/** Read known metadata without making a remote request. @public */\n\tpeek(profile: string, projectId: number): GitLabProject | undefined;\n\t/** Replace the catalog only after a complete successful scan. @public */\n\trefresh(profile: string): Promise<readonly GitLabProject[]>;\n}\n\n/** @internal */\nexport function createGitLabRepositoryCatalog(\n\tintegration: GitLabIntegration,\n): GitLabRepositoryCatalog {\n\tconst profiles = new Map<\n\t\tstring,\n\t\t{\n\t\t\torigin: string;\n\t\t\tprojects?: readonly GitLabProject[];\n\t\t\tpending?: Promise<readonly GitLabProject[]>;\n\t\t\tknown: Map<number, GitLabProject>;\n\t\t\tsearches: Map<string, Promise<readonly GitLabProject[]>>;\n\t\t}\n\t>();\n\tfunction entry(profile: string) {\n\t\tconst client = integration.client(profile);\n\t\tlet cached = profiles.get(profile);\n\t\tif (!cached || cached.origin !== client.baseUrl) {\n\t\t\tcached = { origin: client.baseUrl, known: new Map(), searches: new Map() };\n\t\t\tprofiles.set(profile, cached);\n\t\t}\n\t\treturn { client, cached };\n\t}\n\tasync function refresh(profile: string) {\n\t\tconst { client, cached } = entry(profile);\n\t\tif (cached.pending) return cached.pending;\n\t\tconst scan = Promise.resolve()\n\t\t\t.then(() => client.listProjects())\n\t\t\t.then((projects) => {\n\t\t\t\tcached.projects = structuredClone(projects);\n\t\t\t\tcached.searches.clear();\n\t\t\t\tcached.known.clear();\n\t\t\t\treturn cached.projects;\n\t\t\t});\n\t\tcached.pending = scan;\n\t\ttry {\n\t\t\treturn await scan;\n\t\t} finally {\n\t\t\tcached.pending = undefined;\n\t\t}\n\t}\n\treturn {\n\t\tasync search(profile, text) {\n\t\t\tconst query = text.trim().toLowerCase();\n\t\t\tif (query.length < 2) return [];\n\t\t\tconst { client, cached } = entry(profile);\n\t\t\tif (cached.projects)\n\t\t\t\treturn cached.projects\n\t\t\t\t\t.filter((project) => project.path_with_namespace.toLowerCase().includes(query))\n\t\t\t\t\t.slice(0, 100);\n\t\t\tconst result = cached.searches.get(query);\n\t\t\tif (result) return result;\n\t\t\tconst scan = Promise.resolve()\n\t\t\t\t.then(() => client.searchProjects(query))\n\t\t\t\t.then((projects) => {\n\t\t\t\t\tconst snapshot = structuredClone(projects);\n\t\t\t\t\tif (cached.searches.get(query) === scan)\n\t\t\t\t\t\tfor (const project of snapshot) cached.known.set(project.id, project);\n\t\t\t\t\treturn snapshot;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tif (cached.searches.get(query) === scan) cached.searches.delete(query);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\tcached.searches.set(query, scan);\n\t\t\treturn scan;\n\t\t},\n\t\tpeek(profile, projectId) {\n\t\t\tconst { cached } = entry(profile);\n\t\t\treturn cached.projects\n\t\t\t\t? cached.projects.find((project) => project.id === projectId)\n\t\t\t\t: cached.known.get(projectId);\n\t\t},\n\t\tasync list(profile) {\n\t\t\treturn entry(profile).cached.projects ?? refresh(profile);\n\t\t},\n\t\trefresh,\n\t};\n}\n","import {\n\tcoreHostCapabilities,\n\ttype IntegrationToolExecutionContext,\n\trepositorySettingsIdentity,\n\ttype ServerExtensionAPI,\n\tscopedSettingsCapability,\n\ttype TicketCreationConfig,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { PollResult } from \"@leitwerk-dev/watcher-utils\";\nimport { type GitLabIntegration, gitlabIntegration } from \"./capability.js\";\nimport { registerGitLabDeliveryTools } from \"./delivery-tools.js\";\nimport { createGitLabProvider } from \"./external.js\";\nimport { createGitLabMaintenance } from \"./maintenance.js\";\nimport { createGitLabRepositoryCatalog } from \"./repository-catalog.js\";\nimport { registerGitLabTicketCreation } from \"./ticket-creation.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\t/** @internal */\n\t\tticketCreation?: TicketCreationConfig;\n\t} = {},\n):\n\t| {\n\t\t\t/** @public */\n\t\t\tpoll(): Promise<PollResult>;\n\t\t\t/** @internal */\n\t\t\tmaintenance: ReturnType<typeof createGitLabMaintenance>;\n\t }\n\t| undefined {\n\tconst catalog = integration.repositoryCatalog ?? createGitLabRepositoryCatalog(integration);\n\tapi.provide(gitlabIntegration, {\n\t\tprofiles: () => integration.profiles(),\n\t\tclient: (profile) => integration.client(profile),\n\t\trepositoryCatalog: catalog,\n\t});\n\tconst settings = api.get(scopedSettingsCapability);\n\tif (settings && !Array.isArray(settings))\n\t\tsettings.registerDiscovery(\"repository\", async () => {\n\t\t\tconst subjects = [];\n\t\t\tfor (const profile of integration.profiles()) {\n\t\t\t\tconst client = integration.client(profile);\n\t\t\t\tfor (const project of await catalog.refresh(profile))\n\t\t\t\t\tsubjects.push({\n\t\t\t\t\t\tscopeType: \"repository\",\n\t\t\t\t\t\tidentity: repositorySettingsIdentity(client.baseUrl, project.id),\n\t\t\t\t\t\tlabel: project.path_with_namespace,\n\t\t\t\t\t\taliases: [\n\t\t\t\t\t\t\tproject.http_url_to_repo,\n\t\t\t\t\t\t\t...(project.ssh_url_to_repo ? [project.ssh_url_to_repo] : []),\n\t\t\t\t\t\t],\n\t\t\t\t\t});\n\t\t\t}\n\t\t\treturn subjects;\n\t\t});\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tconst maintenance = createGitLabMaintenance(api, deps, integration, options.now);\n\tconst assertOwnership = async (ctx: IntegrationToolExecutionContext) => {\n\t\tif (maintenance.ownsProcess(ctx.process.processId))\n\t\t\tawait maintenance.assertOwnership(ctx.process.id, ctx.project?.key ?? \"repo\", ctx.signal);\n\t};\n\tconst guardedWrites = new Set([\n\t\t\"gitlab_ensure_merge_request\",\n\t\t\"gitlab_comment\",\n\t\t\"gitlab_reply\",\n\t\t\"gitlab_inline_comment\",\n\t\t\"gitlab_resolve_discussion\",\n\t\t\"gitlab_acknowledge_feedback\",\n\t]);\n\tconst guardedApi: ServerExtensionAPI = {\n\t\t...api,\n\t\ttool(definition) {\n\t\t\tapi.tool({\n\t\t\t\t...definition,\n\t\t\t\tasync execute(ctx, args) {\n\t\t\t\t\tconst guarded =\n\t\t\t\t\t\tmaintenance.ownsProcess(ctx.process.processId) && guardedWrites.has(definition.name);\n\t\t\t\t\tif (guarded || definition.name === \"gitlab_update_comment\") await assertOwnership(ctx);\n\t\t\t\t\tconst result = await definition.execute(\n\t\t\t\t\t\tguarded\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t\texternalWrites: {\n\t\t\t\t\t\t\t\t\t\t...ctx.externalWrites,\n\t\t\t\t\t\t\t\t\t\tensure: (identity, operation) =>\n\t\t\t\t\t\t\t\t\t\t\tctx.externalWrites.ensure(identity, {\n\t\t\t\t\t\t\t\t\t\t\t\t...operation,\n\t\t\t\t\t\t\t\t\t\t\t\texecute: async () => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tawait assertOwnership(ctx);\n\t\t\t\t\t\t\t\t\t\t\t\t\treturn operation.execute();\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\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: ctx,\n\t\t\t\t\t\targs,\n\t\t\t\t\t);\n\t\t\t\t\tif (definition.name === \"gitlab_ensure_merge_request\") await assertOwnership(ctx);\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t});\n\t\t},\n\t};\n\tregisterGitLabTools(guardedApi, integration, assertOwnership);\n\tregisterGitLabTicketCreation(\n\t\tapi,\n\t\tintegration,\n\t\toptions.ticketCreation ?? { enabled: false, defaultLabels: [] },\n\t);\n\tregisterGitLabDeliveryTools(guardedApi, integration, deps.projects);\n\tapi.tool({\n\t\tname: \"gitlab_assert_maintenance\",\n\t\tdescription: \"Recheck MR maintenance ownership before Git publication\",\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\tawait assertOwnership(ctx);\n\t\t\treturn { ok: true };\n\t\t},\n\t});\n\treturn { ...createGitLabProvider(deps, integration, options), /** @internal */ maintenance };\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 { mergeRequestBody } from \"./merge-request-template.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, integration);\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: async () => {\n\t\t\t\t\tconst title = stringArg(args, \"title\");\n\t\t\t\t\tconst body = await mergeRequestBody(\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\tstringArg(args, \"body\"),\n\t\t\t\t\t\tctx,\n\t\t\t\t\t);\n\t\t\t\t\treturn client.createMergeRequest(\n\t\t\t\t\t\tbinding.projectId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle,\n\t\t\t\t\t\t\tdescription: `${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\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, integration);\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, integration);\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, integration);\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","import type { IntegrationToolExecutionContext } from \"@leitwerk-dev/process-sdk\";\nimport type { GitLabClientLike } from \"./client.js\";\n\nconst directory = \".gitlab/merge_request_templates\";\n\n/** @internal */\nexport async function mergeRequestBody(\n\tclient: Pick<\n\t\tGitLabClientLike,\n\t\t\"getProject\" | \"getBranch\" | \"listRepositoryTree\" | \"getRepositoryFile\"\n\t>,\n\tprojectId: number,\n\tbody: string,\n\tctx: Pick<IntegrationToolExecutionContext, \"signal\" | \"reportProgress\">,\n): Promise<string> {\n\tif (!client.getRepositoryFile || !client.listRepositoryTree)\n\t\tthrow new Error(\"GitLab repository template lookup is unavailable\");\n\n\tconst { default_branch: branch } = await client.getProject(projectId, ctx.signal);\n\tif (!branch) throw new Error(\"GitLab repository has no default branch for template lookup\");\n\tconst { commit } = await client.getBranch(projectId, branch, ctx.signal);\n\tconst list = client.listRepositoryTree.bind(client, projectId, commit.id);\n\t// Check parent trees explicitly: a 404 alone also means an inaccessible ref or repository.\n\tconst hasTree = (entries: Awaited<ReturnType<typeof list>>, path: string) =>\n\t\tentries.some((entry) => entry.type === \"tree\" && entry.path === path);\n\tif (\n\t\t!hasTree(await list(\"\", ctx.signal), \".gitlab\") ||\n\t\t!hasTree(await list(\".gitlab\", ctx.signal), directory)\n\t)\n\t\treturn body;\n\n\tconst candidates = (await list(directory, ctx.signal)).filter(\n\t\t({ path, type, mode }) =>\n\t\t\ttype === \"blob\" &&\n\t\t\tmode !== \"120000\" &&\n\t\t\tpath.startsWith(`${directory}/`) &&\n\t\t\t/^[^/\\r\\n\\0]+\\.md$/i.test(path.slice(directory.length + 1)),\n\t);\n\tconst template =\n\t\tcandidates.find(({ path }) => path === `${directory}/Default.md`) ??\n\t\t(candidates.length === 1 ? candidates[0] : undefined);\n\tif (!template) {\n\t\tif (candidates.length > 1)\n\t\t\tctx.reportProgress({\n\t\t\t\ttitle: \"Creating GitLab merge request without a template\",\n\t\t\t\tsummary: \"Multiple repository templates exist and none is Default.md.\",\n\t\t\t\tsteps: [],\n\t\t\t});\n\t\treturn body;\n\t}\n\tconst file = await client.getRepositoryFile(projectId, commit.id, template.path, ctx.signal);\n\tif (file.file_path !== template.path || file.encoding !== \"base64\")\n\t\tthrow new Error(\"Invalid GitLab merge request template response\");\n\tconst markdown = new TextDecoder(\"utf-8\", { fatal: true }).decode(\n\t\tBuffer.from(file.content, \"base64\"),\n\t);\n\t// Templates are Markdown, not authority to execute GitLab quick actions as the bot.\n\tconst description = markdown.replace(/^(\\s*)\\/(?=[a-z])/gim, \"$1\\\\/\").trimEnd();\n\treturn description ? `${description}\\n\\n${body}` : body;\n}\n","import {\n\tlistTicketDestinations,\n\tmarkdownTicketCreationDefinition,\n\tnumberArg,\n\tobjectArg,\n\tparseTicketDestinationId,\n\ttype ServerExtensionAPI,\n\tstringArg,\n\ttype TicketCreationConfig,\n\ttype TicketCreationDestinationProvider,\n\ttype TicketCreationDestinationSnapshot,\n\tticketDestinationId,\n\tticketLabelNames,\n} from \"@leitwerk-dev/process-sdk\";\nimport type { GitLabIntegration } from \"./capability.js\";\nimport type { GitLabProject } from \"./client.js\";\n\nfunction available(project: GitLabProject): boolean {\n\treturn (\n\t\t!project.archived &&\n\t\tproject.issues_enabled !== false &&\n\t\tproject.issues_access_level !== \"disabled\"\n\t);\n}\n\nfunction destinationData(snapshot: TicketCreationDestinationSnapshot) {\n\tconst data = objectArg(snapshot.data);\n\treturn {\n\t\tprofile: stringArg(data, \"profile\"),\n\t\tbaseUrl: stringArg(data, \"baseUrl\"),\n\t\tprojectId: numberArg(data, \"projectId\"),\n\t\tpath: stringArg(data, \"path\"),\n\t\tdefaultLabels: ticketLabelNames(data.defaultLabels),\n\t};\n}\n\n/** @internal */\nexport function registerGitLabTicketCreation(\n\tapi: ServerExtensionAPI,\n\tintegration: GitLabIntegration,\n\tconfig: TicketCreationConfig,\n): void {\n\tif (!config.enabled) return;\n\tconst summary = (profile: string, project: GitLabProject) => ({\n\t\tid: ticketDestinationId(profile, project.id),\n\t\tdisplayName: project.path_with_namespace,\n\t\tgroup: `${profile} · ${new URL(integration.client(profile).baseUrl).hostname}`,\n\t\tdescription: config.defaultLabels.length\n\t\t\t? `Default labels: ${config.defaultLabels.join(\", \")}`\n\t\t\t: \"No default labels\",\n\t});\n\tconst destinations: TicketCreationDestinationProvider = {\n\t\tlist() {\n\t\t\treturn listTicketDestinations(\"GitLab\", integration.profiles(), async (profile) =>\n\t\t\t\t(await integration.client(profile).listProjects())\n\t\t\t\t\t.filter(available)\n\t\t\t\t\t.map((project) => summary(profile, project)),\n\t\t\t);\n\t\t},\n\t\tasync resolve({ destinationId }) {\n\t\t\tconst { profile, resourceId } = parseTicketDestinationId(destinationId);\n\t\t\tconst client = integration.client(profile);\n\t\t\tconst project = await client.getProject(Number(resourceId));\n\t\t\tif (!available(project)) throw new Error(\"The selected GitLab project cannot accept issues\");\n\t\t\tconst labels = await client.listLabels(project.id);\n\t\t\treturn {\n\t\t\t\tsummary: summary(profile, project),\n\t\t\t\tdata: {\n\t\t\t\t\tprofile,\n\t\t\t\t\tbaseUrl: client.baseUrl,\n\t\t\t\t\tprojectId: project.id,\n\t\t\t\t\tpath: project.path_with_namespace,\n\t\t\t\t\tdefaultLabels: config.defaultLabels,\n\t\t\t\t},\n\t\t\t\tagentContext: `Create an issue in ${project.path_with_namespace}. Existing optional labels: ${labels.map((label) => label.name).join(\", \") || \"none\"}.`,\n\t\t\t};\n\t\t},\n\t\tasync validate(snapshot) {\n\t\t\tconst data = destinationData(snapshot);\n\t\t\tconst client = integration.client(data.profile);\n\t\t\tif (client.baseUrl !== data.baseUrl) throw new Error(\"GitLab profile installation changed\");\n\t\t\tconst project = await client.getProject(data.projectId);\n\t\t\tif (!available(project) || project.path_with_namespace !== data.path)\n\t\t\t\tthrow new Error(\"The selected GitLab project changed; choose the destination again\");\n\t\t},\n\t};\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"gitlab_create_issue\",\n\t\tdescription: \"Create one issue in the selected GitLab project\",\n\t\t...markdownTicketCreationDefinition(\"GitLab\", destinations, \"description\"),\n\t\tasync execute(ctx, args) {\n\t\t\tif (!ctx.ticketDestination) throw new Error(\"A GitLab ticket destination is required\");\n\t\t\tawait destinations.validate(ctx.ticketDestination);\n\t\t\tconst target = destinationData(ctx.ticketDestination);\n\t\t\tconst client = integration.client(target.profile);\n\t\t\tconst title = stringArg(args, \"title\");\n\t\t\tconst description = stringArg(args, \"description\");\n\t\t\tconst requestedLabels = ticketLabelNames(args.labels);\n\t\t\tconst names = [...new Set([...target.defaultLabels, ...requestedLabels])];\n\t\t\tif (names.some((name) => name.includes(\",\")))\n\t\t\t\tthrow new Error(\"GitLab label names cannot contain commas\");\n\t\t\tconst labels = await client.listLabels(target.projectId, ctx.signal);\n\t\t\tconst unknown = requestedLabels.filter(\n\t\t\t\t(name) =>\n\t\t\t\t\t!target.defaultLabels.includes(name) && !labels.some((label) => label.name === name),\n\t\t\t);\n\t\t\tif (unknown.length) throw new Error(`Unknown GitLab labels: ${unknown.join(\", \")}`);\n\t\t\tfor (const name of target.defaultLabels) {\n\t\t\t\tawait ctx.externalWrites.ensure(\n\t\t\t\t\t{ writeType: \"gitlab.ensure_label\", dedupKey: `${ctx.idempotencyKey}:label:${name}` },\n\t\t\t\t\t{\n\t\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t\t(await client.listLabels(target.projectId, ctx.signal)).find(\n\t\t\t\t\t\t\t\t(label) => label.name === name,\n\t\t\t\t\t\t\t) ?? null,\n\t\t\t\t\t\texecute: () => client.createLabel(target.projectId, name, ctx.signal),\n\t\t\t\t\t\ttoMetadata: (label) => ({ name: label.name }),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst marker = `<!-- leitwerk-ticket-write:${ctx.idempotencyKey} -->`;\n\t\t\tconst issue = await ctx.externalWrites.ensure(\n\t\t\t\t{ writeType: \"gitlab.create_issue\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t{\n\t\t\t\t\treconcile: async () =>\n\t\t\t\t\t\t(await client.listIssues(target.projectId, ctx.signal, \"all\")).find((issue) =>\n\t\t\t\t\t\t\tissue.description?.includes(marker),\n\t\t\t\t\t\t) ?? null,\n\t\t\t\t\texecute: () =>\n\t\t\t\t\t\tclient.createIssue(\n\t\t\t\t\t\t\ttarget.projectId,\n\t\t\t\t\t\t\t{ title, description: `${description}\\n\\n${marker}`, labels: names.join(\",\") },\n\t\t\t\t\t\t\tctx.signal,\n\t\t\t\t\t\t),\n\t\t\t\t\ttoMetadata: (issue) => ({\n\t\t\t\t\t\tprojectId: issue.project_id,\n\t\t\t\t\t\tiid: issue.iid,\n\t\t\t\t\t\turl: issue.web_url,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn { externalId: `${target.path}#${issue.iid}`, url: issue.web_url, result: issue };\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,QAAMC,aAAY,MAAM,QAAQ,KAAK,OAAO,GAAG,4BAA4B,CAAC;AAC5E,MAAI;AACH,UAAM,UAAU,KAAKA,YAAW,SAAS;AACzC,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA,EAAE,MAAM,IAAM;AAAA,IACf;AACA,UAAM,MAAM;AAAA,MACX,GAAG,QAAQ;AAAA,MACX,qBAAqB;AAAA,MACrB,mBAAmB;AAAA,MACnB,qBAAqB;AAAA,MACrB,aAAa;AAAA,MACb,iCAAiC,MAAM;AAAA,IACxC;AACA,UAAM,MAAM,CAAC,SACZ,KAAK,OAAO,CAAC,MAAM,sBAAsB,MAAM,8BAA8B,GAAG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P,QAAQ,CAAC,UAAU,cAClB,IAAI,eAAe,OAAO,UAAU;AAAA,kBACnC,GAAG;AAAA,kBACH,SAAS,YAAY;AACpB,0BAAM,gBAAgB,GAAG;AACzB,2BAAO,UAAU,QAAQ;AAAA,kBAC1B;AAAA,gBACD,CAAC;AAAA,cACH;AAAA,YACD,IACC;AAAA,YACH;AAAA,UACD;AACA,cAAI,WAAW,SAAS,8BAA+B,OAAM,gBAAgB,GAAG;AAChF,iBAAO;AAAA,QACR;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AACA,sBAAoB,YAAY,aAAa,eAAe;AAC5D;AAAA,IACC;AAAA,IACA;AAAA,IACA,QAAQ,kBAAkB,EAAE,SAAS,OAAO,eAAe,CAAC,EAAE;AAAA,EAC/D;AACA,8BAA4B,YAAY,aAAa,KAAK,QAAQ;AAClE,MAAI,KAAK;AAAA,IACR,MAAM;AAAA,IACN,aAAa;AAAA,IACb,YAAY;AAAA,MACX,MAAM;AAAA,MACN,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,EAAE;AAAA,MAC7C,UAAU,CAAC,YAAY;AAAA,IACxB;AAAA,IACA,MAAM,QAAQ,KAAK;AAClB,YAAM,gBAAgB,GAAG;AACzB,aAAO,EAAE,IAAI,KAAK;AAAA,IACnB;AAAA,EACD,CAAC;AACD,SAAO;AAAA,IAAE,GAAG,qBAAqB,MAAM,aAAa,OAAO;AAAA;AAAA,IAAoB;AAAA,EAAY;AAC5F;","names":["repositoryHttpsUrl","directory","repositoryHttpsUrl","discussion","job","asUnknownRecord","asUnknownRecord","parseDurationMs","parseDurationMs","asUnknownRecord","createCapabilityToken","emptyPollResult","parseDurationMs","createCapabilityToken","process","asUnknownRecord","parseDurationMs","emptyPollResult","createHash","numberArg","projectParameters","stringArg","projectParameters","stringArg","numberArg","createHash","note","numberArg","stringArg","issue"]}
|