import { type AuthRun as AuthRunValue, type AuthRunListResponse as AuthRunListResponseValue, type AuthRunMutationResponse as AuthRunMutationResponseValue, type CreateInteractionInterventionRequest as CreateInteractionInterventionRequestValue, type CreateNetworkRouteRequest as CreateNetworkRouteRequestValue, type CreateSiteAuthConnectionRequest as CreateSiteAuthConnectionRequestValue, type BrowserExternalAuthResult as BrowserExternalAuthResultValue, type ExternalAuthInteractiveRequest as ExternalAuthInteractiveRequestValue, type ExternalAuthRunRequest as ExternalAuthRunRequestValue, type ExternalAuthRunResponse as ExternalAuthRunResponseValue, type InteractionIntervention as InteractionInterventionValue, type InteractionInterventionListResponse as InteractionInterventionListResponseValue, type InteractionInterventionMutationResponse as InteractionInterventionMutationResponseValue, type NetworkRoute as NetworkRouteValue, type NetworkRouteListResponse as NetworkRouteListResponseValue, type NetworkRouteMutationResponse as NetworkRouteMutationResponseValue, type ReportAuthRunRequest as ReportAuthRunRequestValue, type ResolveInteractionInterventionRequest as ResolveInteractionInterventionRequestValue, type RequestHumanInteractionToolInput as RequestHumanInteractionToolInputValue, type SessionEvent, type SiteAuthAuthority as SiteAuthAuthorityValue, type SiteAuthConnection as SiteAuthConnectionValue, type SiteAuthConnectionListResponse as SiteAuthConnectionListResponseValue, type SiteAuthConnectionMutationResponse as SiteAuthConnectionMutationResponseValue, type StartAuthRunRequest as StartAuthRunRequestValue, type UpdateNetworkRouteRequest as UpdateNetworkRouteRequestValue, type UpdateSiteAuthConnectionRequest as UpdateSiteAuthConnectionRequestValue, type VerifyAuthRunRequest as VerifyAuthRunRequestValue } from "@opengeni/contracts"; import { type Database } from "./database.js"; import * as schema from "./schema.js"; type ResourceOperationRow = typeof schema.interactionResourceOperations.$inferSelect; type InteractionMutationScope = { accountId: string; workspaceId: string; actorSubjectId: string; }; export declare class InteractionResourceNotFoundError extends Error { readonly name = "InteractionResourceNotFoundError"; } export declare class InteractionResourceConflictError extends Error { readonly name = "InteractionResourceConflictError"; } export declare class InteractionResourceStateError extends Error { readonly name = "InteractionResourceStateError"; } export type SiteAuthMaintenanceClaim = { operationId: string; sessionId: string; accountId: string; workspaceId: string; siteAuthConnectionId: string; connectionVersion: number; action: "health_check" | "repair"; dueAt: Date; claimedAt: Date; name: string; accountLabel: string; loginUrl: string | null; verificationUrlPrefixes: string[]; preferredIdentityId: string | null; preferredPlacement: SiteAuthConnectionValue["preferredPlacement"]; preferredNetworkRouteId: string | null; healthPolicy: SiteAuthConnectionValue["healthPolicy"]; verificationState: SiteAuthConnectionValue["verificationState"]; }; /** Claim a bounded cross-workspace batch. Stale pre-start claims keep the same * operation/session ids, so worker loss repairs one durable dispatch. */ export declare function claimSiteAuthMaintenance(db: Database, input: { claimTimeoutMs: number; limit: number; }): Promise; /** Link the exact hidden maintenance claim to its service-created session in * the caller's create transaction. A false result must abort that transaction. */ export declare function confirmSiteAuthMaintenanceSessionInTransaction(tx: Database, input: { accountId: string; workspaceId: string; siteAuthConnectionId: string; operationId: string; sessionId: string; }): Promise; /** Standalone wrapper retained for exact DB callers and tests. Session creation * uses the in-transaction form so a changed claim cannot leave an empty shell. */ export declare function confirmSiteAuthMaintenanceSession(db: Database, input: Parameters[1]): Promise; /** Release an exact claim that failed before a maintenance session started. */ export declare function deferSiteAuthMaintenance(db: Database, input: { accountId: string; workspaceId: string; siteAuthConnectionId: string; operationId: string; sessionId: string; retryAt: Date; }): Promise; export declare function listNetworkRoutes(db: Database, input: { accountId: string; workspaceId: string; includeArchived?: boolean; }): Promise; export declare function getNetworkRoute(db: Database, input: { accountId: string; workspaceId: string; routeId: string; }): Promise; export declare function createNetworkRoute(db: Database, input: InteractionMutationScope & CreateNetworkRouteRequestValue): Promise; export declare function updateNetworkRoute(db: Database, input: InteractionMutationScope & { routeId: string; } & UpdateNetworkRouteRequestValue): Promise; export declare function listSiteAuthConnections(db: Database, input: { accountId: string; workspaceId: string; includeArchived?: boolean; }): Promise; export declare function getSiteAuthConnection(db: Database, input: { accountId: string; workspaceId: string; siteAuthConnectionId: string; }): Promise; export declare function createSiteAuthConnection(db: Database, input: InteractionMutationScope & CreateSiteAuthConnectionRequestValue): Promise; export declare function updateSiteAuthConnection(db: Database, input: InteractionMutationScope & { siteAuthConnectionId: string; } & UpdateSiteAuthConnectionRequestValue): Promise; type ExternalAuthOperationMetadata = { schemaVersion: 1; authRunVersion: number; authority: Extract; }; export type ExternalAuthPreparation = { run: AuthRunValue; authority: ExternalAuthOperationMetadata["authority"]; operationState: ResourceOperationRow["state"]; response: ExternalAuthRunResponseValue | null; replayed: boolean; }; export declare function listAuthRuns(db: Database, input: { accountId: string; workspaceId: string; browserSessionId?: string; siteAuthConnectionId?: string; includeSettled?: boolean; }): Promise; export declare function getAuthRun(db: Database, input: { accountId: string; workspaceId: string; authRunId: string; }): Promise; export type ExternalAuthInteractiveContext = { run: AuthRunValue; authority: Extract; }; /** Resolve only the durable authority needed to reveal an external provider's * hosted login UI. The hosted URL itself is deliberately never persisted. */ export declare function getExternalAuthInteractiveContext(db: Database, input: InteractionMutationScope & { authRunId: string; } & ExternalAuthInteractiveRequestValue): Promise; export declare function startAuthRun(db: Database, input: InteractionMutationScope & { browserSessionId: string; controllerGeneration: string; /** Trusted attempt provenance supplied by the API grant. */ originatingSessionId?: string | null; } & StartAuthRunRequestValue): Promise; export type SettleSessionMaintenanceResult = { cancelledAuthRuns: number; releasedClaim: boolean; }; /** A terminal-for-now maintenance session cannot leave an AuthRun or its claim * pinned. Interventions settle linked runs first; this covers every other path. */ export declare function settleSessionMaintenanceInTransaction(db: Database, input: { accountId: string; workspaceId: string; sessionId: string; }): Promise; export declare function reportAuthRun(db: Database, input: InteractionMutationScope & { authRunId: string; controllerGeneration: string; } & ReportAuthRunRequestValue): Promise; export declare function getExternalAuthPreparation(db: Database, input: InteractionMutationScope & { authRunId: string; } & ExternalAuthRunRequestValue): Promise; export declare function prepareExternalAuth(db: Database, input: InteractionMutationScope & { authRunId: string; } & ExternalAuthRunRequestValue): Promise; export declare function dispatchExternalAuth(db: Database, input: InteractionMutationScope & { authRunId: string; operationId: string; }): Promise; export declare function completeExternalAuth(db: Database, input: InteractionMutationScope & { authRunId: string; operationId: string; result: BrowserExternalAuthResultValue; target?: { id: string; targetGeneration: string; documentGeneration: string | null; }; intervention?: { originatingSessionId: string; originatingTurnId?: string | null; originatingAttemptId?: string | null; originatingToolOperationId?: string | null; expiresInSeconds: number; }; }): Promise; export declare function verifyAuthRun(db: Database, input: InteractionMutationScope & { authRunId: string; controllerGeneration: string; targetId: string; targetGeneration: string; documentGeneration: string | null; url: string; } & VerifyAuthRunRequestValue): Promise; export declare function listInteractionInterventions(db: Database, input: { accountId: string; workspaceId: string; resourceKind?: "browser_session" | "computer_session"; resourceId?: string; includeSettled?: boolean; }): Promise; export declare function getInteractionIntervention(db: Database, input: { accountId: string; workspaceId: string; interventionId: string; }): Promise; export type AttemptInteractionInterventionRequest = { id: string; operationId: string; accountId: string; workspaceId: string; originatingSessionId: string; originatingTurnId: string; originatingAttemptId: string; toolCallId: string; input: RequestHumanInteractionToolInputValue; /** * The target as the worker read it when the turn paused. It supplies the * generations a request left out; a string says why it could not be read. */ currentTarget?: InteractionRequestCurrentTarget | string; }; export type InteractionRequestCurrentTarget = { controllerGeneration: string; targetGeneration: string; documentGeneration: string | null; }; /** * An interaction_request_human call the pause could not record. `refusal` is * the call's tool result: what happened in plain words and what to do next. * Nothing was written for the call. */ export declare class InteractionRequestRefusedError extends Error { readonly name = "InteractionRequestRefusedError"; get refusal(): string; } /** * Persist one interaction interruption inside the same transaction as its * frozen Agent RunState. This is deliberately transaction-local: callers must * already hold the session/turn/attempt settlement locks and RLS context. * A call that cannot be recorded throws InteractionRequestRefusedError, whose * refusal becomes the call's result; callers run this in a savepoint so the * refusal leaves nothing behind. */ export declare function persistAttemptInteractionInterventionInTransaction(db: Database, raw: AttemptInteractionInterventionRequest): Promise; export declare function getInteractionInterventionApprovalTarget(db: Database, input: { accountId: string; workspaceId: string; interventionId: string; }): Promise<{ sessionId: string; toolCallId: string; } | null>; export declare function getInteractionInterventionResumeForEvent(db: Database, workspaceId: string, sessionId: string, event: Pick): Promise<{ toolCallId: string; intervention: InteractionInterventionValue; } | null>; export declare function createInteractionIntervention(db: Database, input: InteractionMutationScope & CreateInteractionInterventionRequestValue & { originatingSessionId: string; originatingTurnId?: string | null; originatingAttemptId?: string | null; originatingToolOperationId?: string | null; }): Promise; export declare function resolveInteractionInterventionInTransaction(db: Database, input: InteractionMutationScope & { interventionId: string; } & ResolveInteractionInterventionRequestValue): Promise; export declare function resolveInteractionIntervention(db: Database, input: InteractionMutationScope & { interventionId: string; } & ResolveInteractionInterventionRequestValue): Promise; /** * Cancel every still-open intervention created by a logical agent turn when * that turn becomes terminal. The caller already owns the turn-settlement * transaction, so no resource can outlive the terminal session truth. */ export declare function cancelTurnInteractionInterventionsInTransaction(db: Database, input: { accountId: string; workspaceId: string; sessionId: string; turnId: string; }): Promise; export declare function cancelOpenInteractionInterventions(db: Database, input: { accountId: string; workspaceId: string; resourceKind: "browser_session" | "computer_session"; resourceId: string; }): Promise; export {};