/** * Approval for each agent use of chosen secrets (0952). Rules say which items * and fields need the acting person's approval; request rows record one * blocked use and, once decided, the grant it became. Nothing here holds or * reads a value. Reach to the items themselves stays with the vault routines: * callers check it before changing rules. */ import { type SecretUseApprovalDecision, type SecretUseApprovalRequestView, type SecretUseApprovalTarget, type SecretUseGrantScope } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; type Scope = { accountId: string; workspaceId: string; }; export type SecretApprovalRuleRow = { itemId: string; fieldKey: string; }; export type SecretUseApprovalRow = typeof schema.secretUseApprovals.$inferSelect; /** The rules for these items: `fieldKey` is empty for the whole item. */ export declare function listSecretApprovalRules(db: Database, scope: Scope, itemIds: readonly string[]): Promise; /** * Replace one item's rules: `item` marks every field, `fieldKeys` single * fields. Unchanged rules keep their author and time. */ export declare function setSecretApprovalRules(db: Database, scope: Scope, input: { itemId: string; vaultId: string; item: boolean; fieldKeys: readonly string[]; subjectId: string; }): Promise; /** * The grants a run acting for `approverSubjectId` in `sessionId` may use: its * chat's once and chat grants, and the person's time-window grants in the * workspace. Callers match targets. */ export declare function listUsableSecretUseGrants(db: Database, scope: Scope, input: { sessionId: string; approverSubjectId: string; now?: Date; }): Promise; /** * Record a blocked use for the person to decide. An identical use still * pending in the same chat is returned instead of a new request, however old, * so the person is asked about it once; identical concurrent uses serialize * on the chat and approver. */ export declare function requestSecretUseApproval(db: Database, scope: Scope, input: { sessionId: string; approverSubjectId: string; targets: readonly SecretUseApprovalTarget[]; surface: string; toolName: string; destination: string | null; now?: Date; }): Promise; /** Mark once grants used. Returns the ids this call used; a raced grant is missing. */ export declare function useSecretUseOnceGrants(db: Database, scope: Scope, input: { ids: readonly string[]; now?: Date; }): Promise; export declare function secretUseApprovalView(row: SecretUseApprovalRow): SecretUseApprovalRequestView; /** * Requests bound to cards in one chat, read inside the caller's transaction * (already in the chat's workspace scope). */ export declare function secretUseApprovalsForSessionTx(tx: Database, input: { workspaceId: string; sessionId: string; ids: readonly string[]; }): Promise>; export declare function secretUseGrantExpiry(scope: SecretUseGrantScope, now: Date): Date | null; /** * Apply the person's answer to a pending request inside the response * transaction. An already decided request keeps its first decision. */ export declare function decideSecretUseApprovalTx(tx: Database, input: { workspaceId: string; sessionId: string; approvalId: string; decision: SecretUseApprovalDecision; subjectId: string; now: Date; }): Promise; /** Grants in force in this workspace that cover any field of one item. */ export declare function listSecretUseGrantsForItem(db: Database, scope: Scope, input: { itemId: string; now?: Date; }): Promise; /** Revoke one grant in force that covers the item. Returns whether one was revoked. */ export declare function revokeSecretUseGrant(db: Database, scope: Scope, input: { grantId: string; itemId: string; subjectId: string; now?: Date; }): Promise; export {};