import type { SessionEvent } from "@opengeni/contracts"; import type { Database } from "./database.js"; import { type SubscriptionCoreAdministration, type SubscriptionCoreAllocatorResult, type SubscriptionCoreExtraCreditsResult, type SubscriptionCoreWake } from "./subscription-core/administration.js"; import type { CodexAccountStatus, CodexRotationSettings, WorkspaceCodexSubscriptionMode, WorkspaceCodexSubscriptionSource } from "./codex-account-types.js"; export { SubscriptionCoreCodexSourceRefusedError } from "./subscription-core-codex-errors.js"; /** A wake the caller delivers after its mutation committed. */ export type SubscriptionCoreCodexWake = SubscriptionCoreWake; /** * @deprecated Use chooseSubscriptionCoreSessionAccount with provider: "codex". * The retained endpoint maps its single legacy receipt inside the neutral * transaction. It has no separate binding writer or authority decision. */ export declare function pinSubscriptionCoreSessionCodexAccount(db: Database, input: { accountId: string; workspaceId: string; sessionId: string; connectionId: string | null; subjectId: string; }): Promise<{ result: { changed: boolean; appliedTo: "waiting_turn" | "next_turn"; events: SessionEvent[]; }; wake: SubscriptionCoreCodexWake | null; }>; export type SubscriptionCoreCodexWorkspaceProjection = { accounts: CodexAccountStatus[]; rotation: CodexRotationSettings; source: WorkspaceCodexSubscriptionSource; /** The viewer's own personal connections among `accounts` (Personal workspace only). */ personalAccountIds?: string[]; }; /** * The workspace's Codex account pool, rotation and source in the legacy * shapes. Requires the workspace RLS context on `tx`. Only shared * subscription connections in the workspace's scope are listed; an * administrator's wider visibility is filtered explicitly. */ export declare function projectSubscriptionCoreCodexWorkspace(tx: Database, input: { accountId: string; workspaceId: string; }): Promise; export declare function getSubscriptionCoreCodexWorkspaceProjection(db: Database, input: { accountId: string; workspaceId: string; /** * The viewing person. In their own Personal workspace their personal * Codex connections are listed with the workspace pool (M3 PR 3b). */ viewerSubjectId?: string | null; }): Promise; /** * The viewing person's own personal Codex connections in the legacy account * shape (no credential material), through the owner-only reader. Requires the * workspace RLS context on `tx`; sets the subject. Empty for anyone else, for * a workspace the person may not use, or without an enabled cutover. */ export declare function listSubscriptionCoreCodexPersonalAccountsInTransaction(tx: Database, input: { accountId: string; workspaceId: string; subjectId: string; }): Promise; /** * The organization's Codex accounts (every shared connection it * administers, including ones a shared workspace manages) and its rotation, * for an organization administrator. A * non-administrator sees nothing: the connection policy hides every row. */ export declare function getSubscriptionCoreOrganizationCodexProjection(db: Database, input: { organizationId: string; subjectId: string; }): Promise<{ accounts: CodexAccountStatus[]; rotation: CodexRotationSettings; }>; /** * One organization Codex account as the organization route shows it, any * organization account (also one a shared workspace manages), for a route * that just changed it. Null when it is not one or the subject is not an * organization administrator. */ export declare function getSubscriptionCoreOrganizationCodexAccount(db: Database, input: { organizationId: string; subjectId: string; connectionId: string; }): Promise; type Administration = SubscriptionCoreAdministration; export type SubscriptionCoreCodexAllocatorResult = SubscriptionCoreAllocatorResult; /** * New-allocation eligibility of one connection, with the legacy optimistic * concurrency: the same state is idempotent even with a stale version; a * conflicting stale version returns the current one. Organization * administrators and the connection's delegated manager may toggle it. */ export declare function setSubscriptionCoreCodexAllocator(db: Database, input: Administration & { connectionId: string; enabled: boolean; expectedVersion: number; }): Promise<{ result: SubscriptionCoreCodexAllocatorResult; wake: SubscriptionCoreCodexWake | null; }>; export type SubscriptionCoreCodexExtraCreditsResult = SubscriptionCoreExtraCreditsResult; /** * Consent to paid usage beyond the plan for one connection, with the same * optimistic concurrency as the allocator switch. Organization * administrators and the connection's delegated manager may toggle it. */ export declare function setSubscriptionCoreCodexExtraCredits(db: Database, input: Administration & { connectionId: string; enabled: boolean; expectedVersion: number; }): Promise<{ result: SubscriptionCoreCodexExtraCreditsResult; wake: SubscriptionCoreCodexWake | null; }>; /** Rename one connection (label only). Returns null when it is not manageable. */ export declare function renameSubscriptionCoreCodexConnection(db: Database, input: Administration & { connectionId: string; label: string | null; }): Promise; /** * Legacy "activate": the account unpinned sessions prefer. Core: the * primary connection of this workspace (or the organization), keeping the * rotation mode currently in effect there. */ export declare function setSubscriptionCoreCodexPrimary(db: Database, input: Administration & { connectionId: string; }): Promise<{ activated: string | null; wake: SubscriptionCoreCodexWake | null; }>; /** * Legacy rotation toggle: on is `spread`, off is `primary_first` (D-13). A * workspace override carries the effective (inherited) primary, so toggling * rotation never drops the account unpinned sessions prefer. */ export declare function setSubscriptionCoreCodexRotation(db: Database, input: Administration & { rotationEnabled: boolean; }): Promise<{ rotation: CodexRotationSettings | null; wake: SubscriptionCoreCodexWake | null; }>; /** * Legacy workspace source modes as the workspace's Codex provider override: * `disabled` sets `enabled = false`; any other mode removes it (the older * `workspace` and `organization` modes no longer choose connections, D-50). * Connection scope and the model allowlist are never touched. Throws * `SubscriptionCoreCodexSourceRefusedError` when refused. */ export declare function setSubscriptionCoreWorkspaceCodexSource(db: Database, input: { accountId: string; workspaceId: string; subjectId: string; mode: WorkspaceCodexSubscriptionMode; /** The request verified the Personal workspace's owner acting as themselves (1233). */ personalWorkspaceOwnerVerified?: boolean | undefined; }): Promise<{ source: WorkspaceCodexSubscriptionSource; wake: SubscriptionCoreCodexWake; }>;