import { type NewSessionDraftOptions as NewSessionDraftOptionsValue, type NewSessionSelectionHistory, type LatencyMode, type ReasoningEffort, type RepositoryResourceRef, type ResourceRef, type ToolRef } from "@opengeni/contracts"; import type { Database } from "./database.js"; import * as schema from "./schema.js"; export type NewSessionDraftRow = typeof schema.newSessionDrafts.$inferSelect; export type NewSessionDraftSnapshot = { text: string; resources: ResourceRef[]; tools: ToolRef[]; toolsProvided: boolean; model: string; reasoningEffort: ReasoningEffort; latencyMode: LatencyMode; options: NewSessionDraftOptionsValue; }; export declare class NewSessionDraftConflictError extends Error { readonly currentRevision: number; readonly name = "NewSessionDraftConflictError"; constructor(currentRevision: number); } export declare class NewSessionDraftAccessError extends Error { readonly name = "NewSessionDraftAccessError"; constructor(); } export declare function newSessionSelectionHistory(row: NewSessionDraftRow): NewSessionSelectionHistory; export declare function newSessionDraftToolsProvided(row: NewSessionDraftRow): boolean; /** * The stored model-policy marker, or undefined for a row written before the * marker existed (or by an older client that did not send it). Callers that * know the deployment default decide what an unmarked row means. */ export declare function newSessionDraftModelProvided(row: NewSessionDraftRow): boolean | undefined; export declare function newSessionDraftSelectedProjectChannelId(row: NewSessionDraftRow): string | null | undefined; export declare function publicNewSessionDraftOptions(row: NewSessionDraftRow): NewSessionDraftOptionsValue; /** Every create option a new-session draft can hold, from the contract itself. */ export declare const NEW_SESSION_DRAFT_OPTION_KEYS: readonly (keyof NewSessionDraftOptionsValue)[]; /** * The form both sides of the exact-draft fence compare. It holds exactly the * contract's draft option keys, read from the saved options or from a create * request alike, so a new draft option is compared without a hand-written * list. Absent, null and empty-object values (an Agent learning override with * nothing overridden) all mean "not set"; arrays are kept even when empty, * because an empty list is a deliberate choice. */ export declare function comparableNewSessionDraftOptions(source: Partial>): NewSessionDraftOptionsValue; export declare function getNewSessionDraftInTransaction(db: Database, input: { workspaceId: string; subjectId: string; lock?: boolean; }): Promise; export declare function saveNewSessionDraftInTransaction(db: Database, input: { accountId: string; workspaceId: string; subjectId: string; expectedRevision: number; text: string; resources: ResourceRef[]; tools: ToolRef[]; toolsProvided: boolean; model: string; reasoningEffort: ReasoningEffort; latencyMode: LatencyMode; /** Omitted by older clients; the row then carries no marker. */ modelProvided?: boolean; selectedProjectChannelId?: string | null; options: NewSessionDraftOptionsValue; /** API-key and delegated service subjects have no workspace-membership row. */ requireWorkspaceMembership?: boolean; /** * May this caller use the owner-only managed personal-workspace exception? * See `PersonalWorkspaceOwnerException` in `@opengeni/db`. Absent means the * historical bare-membership fence, unchanged. */ personalWorkspaceOwnerException?: boolean; }): Promise; export declare function reusableNewSessionRepositoryResource(resource: RepositoryResourceRef): RepositoryResourceRef; export type AcceptedNewSessionSelection = { channelId: string | null; targetSandboxId: string | null; workingDir: string | null; }; export declare function rememberNewSessionSelection(history: NewSessionSelectionHistory, selection: AcceptedNewSessionSelection): NewSessionSelectionHistory; /** * Record a successful create without consuming the editable draft. Realtime * session creation uses this path because it must preserve the actor's pending * text/files for a later ordinary session. The hidden preference update shares * the draft identity lock with saves, and deliberately leaves its OCC revision * unchanged because no browser-editable field changed. */ export declare function rememberNewSessionSelectionInTransaction(db: Database, input: { workspaceId: string; subjectId: string; acceptedSelection: AcceptedNewSessionSelection; }): Promise; /** * After an accepted create, clear the draft it was sent from: replace it with * the next-create safe seed. Send carries its own content and is never refused * because of the draft. The draft is cleared only while it still holds what was * sent: it is still at the revision the sender last saw (`expectedRevision`), * or it holds exactly the sent content (`expectedSnapshot`). A newer draft * saved from another device since then stays as the draft; only the accepted * project and machine choice is remembered. A missing row is a no-op. */ export declare function seedNewSessionDraftInTransaction(db: Database, input: { workspaceId: string; subjectId: string; expectedRevision: number; expectedSnapshot?: NewSessionDraftSnapshot; acceptedSelection?: AcceptedNewSessionSelection; }): Promise; /** @deprecated Kept as a compatibility name for low-level callers. */ export declare const consumeNewSessionDraftInTransaction: typeof seedNewSessionDraftInTransaction;