import { type SQL } from "drizzle-orm"; import { type OrganizationWorkspaceScope } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; export declare class OrganizationApiKeyWorkspaceScopeError extends Error { constructor(); } /** Caller already holds the organization key row lock through commit. */ export declare function organizationApiKeyWorkspaceAllowedSql(accountId: string, workspaceId: string, key: { id: SQL; workspaceScope: SQL; }): SQL; /** Resolve scope only after locking the key: a predicate evaluated while * waiting for that lock could otherwise use a pre-narrowing statement snapshot. */ export declare function organizationApiKeyAllowsWorkspace(tx: Database, key: Pick, workspaceId: string): Promise; export declare function validateOrganizationApiKeyWorkspaceScope(tx: Database, accountId: string, scope: OrganizationWorkspaceScope): Promise; export declare function replaceOrganizationApiKeyWorkspaceScope(tx: Database, accountId: string, apiKeyId: string, scope: OrganizationWorkspaceScope): Promise; export declare function readOrganizationApiKeyWorkspaceScopes(tx: Database, rows: (typeof schema.apiKeys.$inferSelect)[]): Promise>; export declare function organizationApiKeyPolicyProjection(row: typeof schema.apiKeys.$inferSelect, workspaceIds?: string[]): { permissionMode?: never; workspaceScope?: never; policy?: never; } | { permissionMode: "explicit" | "legacy"; workspaceScope: { kind: "all"; } | { kind: "selected"; workspaceIds: string[]; }; policy: { preset: "custom" | "full" | "read_only"; permissions: ("account:admin" | "account:read" | "agents:manage" | "agents:read" | "api_keys:manage" | "artifacts:publish" | "artifacts:read" | "billing:manage" | "billing:read" | "capabilities:manage" | "codemode:call" | "connections:personal" | "connections:read" | "connections:write" | "documents:manage" | "documents:search" | "enrollments:manage" | "enrollments:read" | "environments:manage" | "environments:use" | "files:read" | "files:upload" | "files:write" | "github:manage" | "github:use" | "goals:manage" | "mcp_servers:attach" | "members:manage" | "rigs:manage" | "rigs:use" | "scheduled_tasks:manage" | "scheduled_tasks:run" | "secrets:list" | "secrets:read" | "secrets:use" | "secrets:write" | "sessions:control" | "sessions:create" | "sessions:read" | "stream:acknowledge" | "stream:control" | "stream:view" | "terminal:attach" | "tool_credentials:write" | "usage_allowances:manage" | "variable-sets:attach" | "variable-sets:list" | "variable-sets:manage" | "variable-sets:read" | "variable-sets:use" | "variable-sets:write" | "workspace:admin" | "workspace:create" | "workspace:read")[]; workspaceScope: { kind: "all"; } | { kind: "selected"; workspaceIds: string[]; }; }; };