import type { MountedMastraCode } from '@mastra/code-sdk'; import { RequestContext } from '@mastra/core/request-context'; import type { IntegrationSubscription } from '../storage/domains/integrations/base.js'; /** The Factory session row fields a woken session has to run as. */ export type FactorySessionOwner = { userId: string; orgId: string; }; export interface SubscriptionSessionLookup { sessions: { getBySessionId(sessionId: string): Promise; }; } /** * Bring the session that owns a subscribed thread online so a provider event * can be delivered to it. Provider-neutral: GitHub and GitLab subscriptions * carry the same session binding and differ only in their target data. */ export type SubscriptionSessionRow = IntegrationSubscription<{ projectRepositoryId: string; subscribedByUserId?: string | null; }>; /** * The request context a provider-triggered run executes under: the user who * subscribed the thread, in the subscription's organization. A webhook carries * no signed-in user and tenant credential resolution fails closed without one, * so a woken run would otherwise stop before it could persist or answer the * notification. The subscription row already names that user, so delivery * costs no extra read; an older row without one falls back to the Factory * session's owner, the identity used when a session is recreated for delivery. */ export declare function subscriptionRunContext(subscription: SubscriptionSessionRow, sourceControl: SubscriptionSessionLookup | undefined): Promise; /** * Attach the Factory session's owner, in its organization, to the request * context of a run that has no inbound request (a notification or peer-signal * wake), and prime that tenant's credentials. The live session's `ownerId` * isn't used: sessions opened from the browser or Slack are owned by the * controller id, not a user. Leaves the context alone when `sessionId` names no * Factory session or its org is unresolved, so credential resolution fails * closed. */ export declare function prepareSessionRunContext(requestContext: RequestContext, sessionId: string, sourceControl: SubscriptionSessionLookup, options?: { expectedOrgId?: string; }): Promise<'prepared' | 'session-not-found' | 'organization-unresolved' | 'organization-mismatch'>; export declare function resolveSubscriptionSession(controller: MountedMastraCode['controller'], subscription: SubscriptionSessionRow, options: { label: string; sourceControl?: SubscriptionSessionLookup; }): Promise | undefined>; //# sourceMappingURL=subscription-session.d.ts.map