import type { RequestContext } from '@mastra/core/request-context'; import type { ApiRoute } from '@mastra/core/server'; import type { MastraWorker } from '@mastra/core/worker'; import type { IntegrationConnection } from '../../capabilities/connection.js'; import type { Intake, IntakeIssueDetail } from '../../capabilities/intake.js'; import type { RouteAuth } from '../../routes/route.js'; import type { IntegrationStorageHandle } from '../../storage/domains/integrations/base.js'; import type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js'; import type { SourceControlStorageHandle } from '../../storage/domains/source-control/base.js'; import type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js'; import { GitLabApiClient } from './api.js'; import type { GitLabEventRules, GitLabRuleOverrides } from './default-rules.js'; import type { GitLabSubscriptionStorage } from './subscriptions.js'; interface GitLabConnectionContext { id: string; label: string | null; api: GitLabApiClient; connection: IntegrationConnection; host: string; webBaseUrl?: string; /** Resolves a fresh provider token for a single brokered git operation. */ repositoryAccessToken?: () => Promise; } interface GitLabSourceReference { /** Present only on legacy v1 ids; authentication is not resource identity. */ connectionId?: string; /** Canonical v2 ids use the GitLab instance host plus immutable project id. */ host?: string; projectId: string; /** Legacy ids carry display metadata; v2 resolves it from GitLab. */ projectPath?: string; } interface GitLabIssueReference extends GitLabSourceReference { issueIid: number; } export interface GitLabMergeRequestReference { version: 1; host: string; projectId: number; mergeRequestIid: number; } export interface GitLabStatusConnection { id: string; integrationId: string; status: 'active' | 'needs_reauth'; accountLabel: string | null; } export declare const GITLAB_TRUSTED_ACCESS_LEVEL = 30; export declare abstract class GitLabIntegrationBase implements FactoryIntegration { #private; readonly id = "gitlab"; readonly rules: GitLabEventRules; constructor(rules?: GitLabRuleOverrides); readonly intake: Intake; readonly versionControl: import("../../capabilities/version-control.js").VersionControl; initialize({ storage, projects, auth, sourceControl, }: { storage?: IntegrationStorageHandle; projects: FactoryProjectsStorage; auth: RouteAuth; sourceControl?: SourceControlStorageHandle; }): void; /** Generic integration persistence (merge-request subscriptions). */ get integrationStorage(): GitLabSubscriptionStorage; /** Source-control rows for this integration; absent when the host runs without them. */ get sourceControlStorage(): SourceControlStorageHandle | undefined; get authEnabled(): boolean; get projects(): FactoryProjectsStorage; resolveOrgId(resourceId: string): Promise; clearCaches(): void; abstract hasActiveConnections(): Promise; abstract authFailureMessage(): string; protected abstract activeContexts(): Promise; protected abstract contextById(connectionId: string): Promise; /** Resolve only a GitLab repository linked to this Factory in this organization. */ getLinkedRepository(input: { orgId: string; factoryProjectId: string; projectRepositoryId: string; }): Promise<{ repository: import("../../storage/domains/source-control/base.js").SourceControlRepository; host: string; } | null>; getProjectMemberAccessLevel(connectionId: string, projectId: string, username: string): Promise; getWorkItemAuthorUsername(connectionId: string, projectId: string, kind: 'issue' | 'merge_request', iid: number): Promise; isProjectMemberTrustedForSource(sourceId: string, username: string): Promise; getIssueForFactoryProject(input: { orgId: string; factoryProjectId: string; issueId: string; }): Promise; /** Platform mode exposes org connections; direct mode returns undefined. */ statusConnections(): Promise; /** Direct mode verifies its configured credential; Platform mode uses connection status. */ verifyStatus(): Promise; protected get webhookSecret(): string | undefined; workers(ctx: IntegrationContext): MastraWorker[]; routes(ctx: IntegrationContext): ApiRoute[]; agentTools(args: { requestContext: RequestContext; }): Promise; sessionTools({ requestContext }: { requestContext: RequestContext; }): IntegrationTools; postToolObserver({ toolContext, requestContext, }: Parameters>[0]): Promise; abstract diagnostics(): Record; /** Prefer the configured direct token over an older Platform installation on the same host. */ resolveActiveConnectionForHost(storedConnectionId: string, host: string): Promise; } export type GitLabAccessTokenType = 'personal' | 'group'; export interface GitLabIntegrationConfig { rules?: GitLabRuleOverrides; accessToken?: string; /** Defaults to `personal`; both token types authenticate identically but have different resource reach. */ accessTokenType?: GitLabAccessTokenType; baseUrl?: string; webhookSecret?: string; fetchImpl?: typeof fetch; } export declare class GitLabIntegration extends GitLabIntegrationBase { #private; constructor(config?: GitLabIntegrationConfig); protected get webhookSecret(): string | undefined; hasActiveConnections(): Promise; verifyStatus(): Promise; authFailureMessage(): string; protected activeContexts(): Promise; protected contextById(connectionId: string): Promise; diagnostics(): Record; } export declare function encodeSourceId(reference: GitLabSourceReference): string; export declare function decodeSourceId(value: string): GitLabSourceReference | null; export declare function encodeIssueReference(reference: GitLabIssueReference): string; export declare function decodeIssueReference(value: string): GitLabIssueReference | null; export declare function decodeMergeRequestReference(value: string): GitLabMergeRequestReference | null; export declare function gitlabConnection(connectionId: string): IntegrationConnection; export declare function normalizeGitLabHost(host: string): string; export {}; //# sourceMappingURL=integration.d.ts.map