import { type Database } from "./database.js"; /** * EU-only inference (migration 1060). When on, every model call for the * organization's workspaces must run on an EU route. See * docs/organization-tenancy.md. */ export type OrganizationInferenceResidencyState = { organizationId: string; euOnly: boolean; /** 0 until the setting is first changed. */ version: number; updatedAt: string | null; }; /** * Who is changing the setting. Only `browser_person` (a signed-in owner or * admin using the app, never an agent acting for them or an API key) may turn * EU-only off; the database refuses an off change by any other kind. */ export type InferenceResidencyActorKind = "browser_person" | "agent" | "api_key"; export declare class InferenceResidencyChangeRefusedError extends Error { readonly reason: "forbidden" | "version_conflict" | "operation_reused" | "invalid"; constructor(reason: "forbidden" | "version_conflict" | "operation_reused" | "invalid", message: string); } /** The workspace is missing, or is not in the account the caller named. */ export declare class WorkspaceInferenceResidencyUnknownError extends Error { constructor(); } /** The organization's EU-only inference setting. Readable by any member. */ export declare function getOrganizationInferenceResidency(db: Database, accountId: string): Promise; /** * Whether model calls for this workspace must stay in the EU. Today the * answer is the organization's setting, so every workspace of an EU-only * organization, Personal ones included, is EU-only. Callers ask about the * workspace so a per-workspace switch can be added here without changing them. * * The workspace's own account is read in the same scope: a workspace that is * missing, belongs to another account or is hidden from this scope throws * WorkspaceInferenceResidencyUnknownError, as does any failed read. Callers * must never treat an error as "not EU-only". */ export declare function isWorkspaceEuOnly(db: Database, input: { accountId: string; workspaceId: string; }): Promise; /** * `isWorkspaceEuOnly` inside a transaction already scoped to the workspace * (for example the worker's batched execution-input read). Same checks: a * workspace outside the scoped organization is an error, never "not EU-only". */ export declare function isWorkspaceEuOnlyInScope(scopedDb: Database, input: { accountId: string; workspaceId: string; }): Promise; /** * Change the setting through the database's change function, which checks * the actor's live owner/admin membership (or administering organization key) * and refuses turning EU-only off for anyone but an owner or admin person in a * browser. `expectedVersion` must match the current version. An operation id * is bound to its request: an exact replay returns the stored result, a * different request with the same id is refused. */ export declare function updateOrganizationInferenceResidency(db: Database, input: { organizationId: string; actorSubjectId: string; actorKind: InferenceResidencyActorKind; euOnly: boolean; expectedVersion: number; operationId: string; }): Promise;