import { type Settings } from "@opengeni/config"; import { type CodexFetch, type CodexUsagePayload } from "@opengeni/codex"; import { type Database } from "./database.js"; import { type CodexAuthDeps } from "./codex-token-resolver.js"; type AdministratorScope = (db: Database, use: (tx: Database) => Promise) => Promise; /** * An injected core transport must cancel and join its local work for this exact * signal, including any deferred dispatch, before this promise resolves. Native * Fetch already provides abortable fetch/body custody. Arbitrary CodexFetch * callbacks do not, so they fail closed before receiving a bearer. Native fetch * behind the API's request tracing is still native fetch. */ export type OrganizationCodexUsageJoinedFetch = CodexFetch & { abortAndJoin: (signal: AbortSignal) => Promise; }; /** * Administrative usage inspection is independent of inference eligibility. * This path may refresh the exact account's bearer, but never changes quota, * allocation, model exclusions, credit consent, or workspace assignments. */ export declare function readOrganizationCodexUsage(db: Database, settings: Settings, input: { organizationId: string; credentialId: string; signal?: AbortSignal; /** May shorten, never extend, the core admission-plus-request budget. */ requestTimeoutMs?: number; }, withAdministrator: AdministratorScope, fetchImpl?: CodexFetch, refresh?: CodexAuthDeps["refresh"]): Promise; /** * One active-or-not organization-managed Codex connection, by canonical id or * legacy alias, as an organization administrator sees it. Null when the id is * not an organization-managed shared Codex subscription. */ export declare function findOrganizationCodexConnection(db: Database, settings: Settings, input: { organizationId: string; credentialId: string; }, withAdministrator: AdministratorScope): Promise<{ credentialId: string; status: string; } | null>; /** * The bearer of one organization-managed Codex connection (canonical id) for * an organization administrator, with the usage path's staleness refresh under * the same per-connection refresh lock and generation fence. */ export declare function buildOrganizationCodexConnectionTokenResolver(db: Database, settings: Settings, input: { organizationId: string; credentialId: string; }, withAdministrator: AdministratorScope, refresh?: CodexAuthDeps["refresh"]): { getToken: () => Promise; refresh: () => Promise; }; export {};