import { ResourceRef, type SessionRemovedRepository } from "@opengeni/contracts"; import { type Database } from "./database.js"; /** * An agent asked to attach a repository a person removed from the chat. Only * a person (or an API caller) attaches it again. */ export declare class SessionRepositoryRemovedError extends Error { readonly uri: string; constructor(uri: string); } /** * Who asks to attach repositories to a session: an agent attempt, or a person * (a signed-in human, an operator or an API caller acting for the workspace). */ export type RepositoryAttachRequester = "agent" | "person"; /** * Apply a session's repository removal records to a request that attaches * repositories. An agent cannot attach a removed repository; a person * attaching one ends its removal record. */ export declare function admitRequestedRepositories(input: { removedRepositories: readonly SessionRemovedRepository[]; requested: readonly ResourceRef[]; requester: RepositoryAttachRequester; }): { removedRepositories: SessionRemovedRepository[]; changed: boolean; }; /** * The session's current resources, read live for an authority check, or null * when the session is not visible in the workspace. Repository membership is * live authority: a repository removed from the session must stop working on * the next Git or GitHub call, including for turns that captured an older * snapshot. */ export declare function getSessionResourcesForAuthority(db: Database, workspaceId: string, sessionId: string): Promise; /** A session's live repository membership: what it attaches and what a person removed. */ export type SessionRepositoryMembership = { resources: ResourceRef[]; removedRepositories: SessionRemovedRepository[]; }; /** * The session's current resources and removal records, read live for an * authority check, or null when the session is not visible in the workspace. * All my repositories does not limit a chat to its attached repositories, * but a repository a person removed from the chat (or from a parent chat, * which records the removal on its descendants) stays refused there. */ export declare function getSessionRepositoryMembershipForAuthority(db: Database, workspaceId: string, sessionId: string): Promise; /** * Whether a person removed the repository (at any of `uris`, or with this * GitHub repository id, so a rename or transfer does not undo the removal) * from the session and it is not attached again. A removal record that * outlived a re-attach never refuses a repository the session attaches. */ export declare function sessionRepositoryRemoved(membership: SessionRepositoryMembership, repository: { uris: readonly string[]; githubRepositoryId?: string | undefined; }): boolean; /** * Every live descendant of a session (children, their children, ...), * shallower first. Imported read-only sessions are skipped; the walk still * passes through them. Ids only: callers lock each session they change. */ export declare function listSessionDescendantIdsForResourceRemoval(db: Database, workspaceId: string, sessionId: string): Promise; /** * Repositories other sessions in the same sandbox group still attach. Child * sessions share their parent's box by default, so a turn removing a * repository's folder or credential binding keeps whatever another session in * the box still uses. An unreadable stored value contributes nothing. */ export declare function listSandboxGroupRepositoryResources(db: Database, workspaceId: string, sandboxGroupId: string, exceptSessionId: string): Promise; /** * Settle sandbox cleanup for exactly these removals once a turn removed the * repository folders and credential bindings. The removal records stay; a * later removal of the same repository (a new id) stays pending. */ export declare function settleSessionRepositoryCleanup(db: Database, workspaceId: string, sessionId: string, removalIds: readonly string[]): Promise; /** * Record removals on a session that does not attach the repositories (a * descendant that never had them), so an agent there cannot attach them * either. Nothing is left to clean up in its sandbox. A repository the * session attaches meanwhile (a person attached it again) gets no record. */ export declare function recordSessionRemovedRepositories(db: Database, workspaceId: string, sessionId: string, entries: readonly SessionRemovedRepository[]): Promise;