import type { ProjectStore } from "../store/project-store.js";
import type { GuardedProjectMutationOutcome, ProjectResourceLink, ProjectResourceLinkInput } from "../types/workspace.js";
export declare const PROJECT_CONTACT_RESOURCE_LINK_TYPE: {
    readonly authority: "contacts";
    readonly source_package: "@hasna/contacts";
    readonly target_kind: "contact";
    readonly locator_kind: "external_uuid";
    readonly scope: "resource";
};
export declare const PROJECT_CONTACT_LINK_STEPS: {
    readonly contactsMembership: "contacts-membership";
    readonly projectsResourceLink: "projects-resource-link";
};
export interface ContactProjectMembershipSnapshot {
    contact_id: string;
    project_id: string;
    linked: boolean;
    version: string;
}
export interface ContactProjectMembershipMutationResult {
    outcome: Extract<GuardedProjectMutationOutcome, "accepted" | "duplicate_of_accepted">;
    operation_id: string;
    step_id: string;
    before: ContactProjectMembershipSnapshot;
    after: ContactProjectMembershipSnapshot;
    receipt_id: string;
}
export interface ContactProjectMembershipListResult {
    project_id: string;
    contact_ids: string[];
    complete: true;
    membership_revision: string;
}
export interface ContactProjectMembershipMutationInput {
    contact_id: string;
    project_id: string;
    operation_id: string;
    step_id: string;
    expected_version: string;
}
export interface ContactProjectMembershipAuthority {
    readonly service_instance: string;
    readMembership(input: {
        contact_id: string;
        project_id: string;
    }): Promise<ContactProjectMembershipSnapshot>;
    listProjectMemberships(input: {
        project_id: string;
        max_items: number;
    }): Promise<ContactProjectMembershipListResult>;
    attach(input: ContactProjectMembershipMutationInput): Promise<ContactProjectMembershipMutationResult>;
    detach(input: ContactProjectMembershipMutationInput): Promise<ContactProjectMembershipMutationResult>;
}
export interface ProjectContactLinkDependencies {
    projects: Pick<ProjectStore, "readProjectResourceLinks" | "mutateProjectResourceLinks" | "rollbackProjectResourceLinks">;
    contacts: ContactProjectMembershipAuthority;
}
export interface ProjectContactLinkBounds {
    project_id: string;
    max_items: number;
    response_byte_limit: number;
    time_budget_ms: number;
}
export interface ProjectContactLinkMutationInput extends ProjectContactLinkBounds {
    contact_id: string;
    operation_id: string;
    labels?: ProjectResourceLinkInput["labels"];
    agent_id?: string;
    source?: "cli" | "mcp" | "agent" | "migration" | "system";
    command?: string;
}
export interface ProjectContactLinkEvidence {
    system: "contacts" | "projects";
    step_id: string;
    outcome: string;
    receipt_id: string | null;
    compensated: boolean;
}
export interface ProjectContactLinkMutationOutput {
    ok: true;
    outcome: "accepted" | "duplicate_of_accepted";
    authority: "contacts";
    project_id: string;
    contact_id: string;
    membership: ContactProjectMembershipSnapshot;
    project_link: ProjectResourceLink | null;
    evidence: ProjectContactLinkEvidence[];
}
export interface ProjectContactLinkListOutput {
    ok: true;
    authority: "contacts";
    project_id: string;
    membership_revision: string;
    project_revision: string;
    contact_ids: string[];
    synchronized_contact_ids: string[];
    missing_project_link_contact_ids: string[];
    stale_project_link_contact_ids: string[];
    project_links: ProjectResourceLink[];
}
export type ProjectContactLinkErrorCode = "PROJECT_CONTACT_LINK_CONTACTS_WRITE_FAILED" | "PROJECT_CONTACT_LINK_PROJECT_WRITE_FAILED" | "PROJECT_CONTACT_LINK_PROJECT_WRITE_FAILED_COMPENSATED" | "PROJECT_CONTACT_LINK_PARTIAL_FAILURE";
export declare class ProjectContactLinkOperationError extends Error {
    readonly code: ProjectContactLinkErrorCode;
    readonly stage: string;
    readonly compensated: boolean;
    readonly cause: unknown;
    readonly compensation_error: unknown;
    constructor(input: {
        code: ProjectContactLinkErrorCode;
        stage: string;
        compensated: boolean;
        cause: unknown;
        compensation_error?: unknown;
    });
}
export declare function projectContactResourceLink(serviceInstance: string, contactId: string, labels?: ProjectResourceLinkInput["labels"]): ProjectResourceLinkInput;
export declare function listProjectContacts(dependencies: ProjectContactLinkDependencies, input: ProjectContactLinkBounds): Promise<ProjectContactLinkListOutput>;
export declare function attachProjectContact(dependencies: ProjectContactLinkDependencies, input: ProjectContactLinkMutationInput): Promise<ProjectContactLinkMutationOutput>;
export declare function detachProjectContact(dependencies: ProjectContactLinkDependencies, input: ProjectContactLinkMutationInput): Promise<ProjectContactLinkMutationOutput>;
//# sourceMappingURL=project-contact-links.d.ts.map