import type { WorkOSStore } from './store.js'; import type { WorkOSAgentBlueprint, WorkOSAgentInstance, WorkOSAgentInstanceSession, WorkOSSession } from './entities.js'; /** * Longest `agent_delegated` chain production will mint; every hop persists a session and * the root walk is O(depth), so the cap only closes an unbounded-growth lever. */ export declare const MAX_AGENT_CHAIN_DEPTH = 32; export declare const AGENT_SUBJECT_PROFILE = "ai_agent"; export declare const USER_SUBJECT_PROFILE = "user"; export declare const AGENT_SESSION_SETTING_LIMITS: { readonly max_age_seconds: 31536000; readonly access_token_ttl_seconds: 3600; readonly refresh_token_ttl_seconds: 5184000; }; export declare const DEFAULT_AGENT_SESSION_SETTINGS: { readonly max_age_seconds: 3600; readonly access_token_ttl_seconds: 300; readonly refresh_token_ttl_seconds: 3600; }; /** * A user session still able to back delegation: present, active, and unexpired. Revoked * sessions are deleted by the sessions routes, so absence reads as ended. */ export declare function isUserSessionLive(session: WorkOSSession | undefined, now?: number): session is WorkOSSession; export declare function isOrganizationInvocable(blueprint: WorkOSAgentBlueprint, organizationId: string): boolean; /** * Permission slugs a membership's primary role grants, resolved the same way the * authorization endpoints and user access tokens do so the three never disagree. */ /** Every permission the member's roles grant together, resolved as the authorization endpoints resolve them. */ export declare function membershipPermissionSlugs(ws: WorkOSStore, organizationId: string, roleSlugs: readonly string[]): string[]; /** A blueprint open to everyone, or to at least one of the roles the member holds. */ export declare function isRoleInvocable(blueprint: WorkOSAgentBlueprint, roleSlugs: readonly string[]): boolean; /** Blueprint ceiling narrowed to what the delegating member's roles grant; order follows the ceiling. */ export declare function intersectPermissions(blueprint: WorkOSAgentBlueprint, granted: string[]): string[]; export interface ChainRoot { root: WorkOSAgentInstanceSession; /** Hops between the presented session and its root; 0 for an unchained session. */ depth: number; ancestorRevoked: boolean; } /** * Walk `parent_session_id` provenance to the chain root. Every hop is on the same instance and * an instance's sessions are only ever deleted together, so a missing parent is corrupt * provenance; it is reported as revoked rather than letting the orphan pose as a root. */ export declare function findChainRoot(ws: WorkOSStore, session: WorkOSAgentInstanceSession): ChainRoot; /** * Revoke a session and every descendant chained from it. Only live rows are touched, so the * update hook emits one `agent.instance.session.revoked` per session that was actually live; * already-revoked rows keep their `revoked_at` and already-expired rows stay `expired`, but * both still have their children walked. Returns how many sessions were revoked. */ export declare function revokeAgentSessionTree(ws: WorkOSStore, sessionId: string, revokedAt?: string): number; /** * Tear down an instance the way production does: live sessions are revoked (so their * revocation events fire) before every session row and the instance itself are removed. */ export declare function deleteAgentInstance(ws: WorkOSStore, instance: WorkOSAgentInstance): void; export declare function deleteAgentBlueprint(ws: WorkOSStore, blueprint: WorkOSAgentBlueprint): void; /** Every instance in the organization, autonomous or delegated, goes when the organization does. */ export declare function deleteAgentInstancesForOrganization(ws: WorkOSStore, organizationId: string): void; /** Delegated instances hang off their membership; deleting the membership deletes them. */ export declare function deleteAgentInstancesForMembership(ws: WorkOSStore, membershipId: string): void; /** * Deactivating a membership ends the member's ability to act, so every session on an * instance delegated from it is revoked; the instance itself survives for a reactivation. */ export declare function revokeAgentSessionsForMembership(ws: WorkOSStore, membershipId: string): void; /** * A deleted permission leaves every blueprint ceiling that named it, so no later mint can * grant a slug that no longer exists. Sessions already minted keep their recorded grant. */ export declare function removePermissionFromAgentBlueprints(ws: WorkOSStore, slug: string): void; /** * Agent sessions delegated from a user session die with it. Called when a user session is * revoked; chained sessions record only their parent, so revoking each root cascades. */ export declare function revokeAgentSessionsForUserSession(ws: WorkOSStore, userSessionId: string): void;