import { AppendArchivedSessionEventsRequest, ImportArchivedSessionRequest, type ArchivedSessionImportEvent, type Session, type SessionEvent, type TurnInitiator, type TurnInitiatorContext, type Permission, type AccessGrant, type FileAsset } from "@opengeni/contracts"; import { type Database } from "./database.js"; type ArchivedImportDependencies = { createSessionWithIdempotencyKeyResult: (db: Database, input: { accountId: string; workspaceId: string; subjectId: string; visibility: "user_private" | "workspace_shared"; createIdempotencyKey: string; initialMessage: string; resources: never[]; skills: never[]; tools: never[]; metadata: Record; createdBy: TurnInitiator; createdByContext?: TurnInitiatorContext; model: string; reasoningEffort: "low"; latencyMode: "standard"; sandboxBackend: "none"; firstPartyMcpTools: never[]; firstPartyMcpPermissions: never[]; archivedImport: true; beforeCreateCommit: (tx: Database, sessionId: string, context?: { created: boolean; }) => Promise; }) => Promise<{ denied: false; created: boolean; session: { id: string; }; } | { denied: true; }>; getFilesForSubject: (db: Database, input: { accountId: string; workspaceId: string; subjectId: string | null; fileIds: readonly string[]; }) => Promise; getSession: (db: Database, workspaceId: string, sessionId: string) => Promise; getWorkspaceGrant: (db: Database, subjectId: string, workspaceId: string) => Promise; isCreateConflict: (error: unknown) => boolean; isCreateUnavailable: (error: unknown) => boolean; }; /** Bind canonical session/file helpers at the root composition, never by * importing that barrel back into a reexported leaf. No permissive defaults. */ export declare function createArchivedSessionImportPersistence(dependencies: ArchivedImportDependencies): { importArchivedSession: (db: Database, input: Parameters[1]) => Promise<{ session: Session; importId: string; created: boolean; nextOffset: number; events: SessionEvent[]; }>; appendArchivedSessionEvents: (db: Database, input: Parameters[1]) => Promise<{ sessionId: string; importId: string; nextOffset: number; replayed: boolean; events: SessionEvent[]; }>; }; export type ArchivedSessionImportErrorCode = "SESSION_IMPORT_CONFLICT" | "SESSION_IMPORT_OFFSET_CONFLICT" | "SESSION_IMPORT_NOT_FOUND" | "SESSION_IMPORT_INVALID_FILE" | "SESSION_IMPORTED_READ_ONLY"; export declare class ArchivedSessionImportError extends Error { readonly code: ArchivedSessionImportErrorCode; readonly name = "ArchivedSessionImportError"; constructor(code: ArchivedSessionImportErrorCode); } export declare function assertSessionIsNotImported(session: Pick): void; export declare function canonicalArchivedSessionImportHash(value: unknown): string; type ImportScope = { accountId: string; workspaceId: string; subjectId: string; /** Set only from verified request ownership, never from a payload label. */ fileOwnerSubjectId: string | null; requireLiveSubject?: boolean; apiKeyId?: string; requiredPermission?: Permission; beforeCommit?: (tx: Database) => Promise; }; /** JSON is already bounded by the contract; inspect nested resources as well as * the usual top-level attachment refs. Never accept another workspace's file, * even when its personal-file ACL happens to allow the importing human. */ export declare function archivedSessionImportFileIds(events: readonly ArchivedSessionImportEvent[]): string[]; declare function importArchivedSession(db: Database, input: ImportScope & { payload: ImportArchivedSessionRequest; createdBy: TurnInitiator; createdByContext?: TurnInitiatorContext; }, dependencies: ArchivedImportDependencies): Promise<{ session: Session; importId: string; created: boolean; nextOffset: number; events: SessionEvent[]; }>; declare function appendArchivedSessionEvents(db: Database, input: ImportScope & { importId: string; payload: AppendArchivedSessionEventsRequest; /** A host authorization decision may happen before locking, but its target * and mutable database authority are verified again after the prefix. */ sessionId: string; }, dependencies: ArchivedImportDependencies): Promise<{ sessionId: string; importId: string; nextOffset: number; replayed: boolean; events: SessionEvent[]; }>; /** Scoped lookup only. Core authorizes the resolved target; another importer * never receives a session identity just because its shared timeline is visible. */ export declare function getArchivedSessionImportId(db: Database, workspaceId: string, subjectId: string, importId: string): Promise; export {};