import type { RequestContext } from '@mastra/core/request-context'; import type { FactoryRunBindingAddress, FactoryRunBindingRecord, FactoryRunBindingSessionAddress, WorkItemsStorage } from '../storage/domains/work-items/base.js'; /** Minimal source-control session lookup used to heal recovered session state. */ export interface FactorySessionSourceLookup { getBySessionId(sessionId: string): Promise<{ orgId: string; projectRepositoryId: string | null; baseBranch: string; } | null>; } export declare function getFactorySessionCoordinates(requestContext: RequestContext | undefined): FactoryRunBindingSessionAddress | null; export declare function getFactorySessionAddress(requestContext: RequestContext | undefined): FactoryRunBindingAddress | null; /** * Read the session's factory scoping off controller state: the project whose * shared settings row applies to its runs, plus the org rung that row is keyed * by (`factoryOrgId` is seeded at session start and is authoritative for * downstream identity reads — the owner id is a user, never an org). */ export declare function readFactorySessionScope(requestContext: RequestContext | undefined): { factoryProjectId: string; factoryOrgId?: string; } | null; /** * Read the active run binding for this session when controller state has lost * `factoryProjectId` — a crash-recovered session ("Continue") is recreated with * empty state, so the binding table is the only remaining source of the project * whose shared settings row applies to the run. Read-only, unlike * `resolveFactorySessionAddress`: it neither heals state nor touches source * control, so input processors can call it before any tool has run. */ export declare function findSessionRunBinding(requestContext: RequestContext | undefined, storage: Pick): Promise; export interface FactorySessionAddressResolution { address: FactoryRunBindingAddress; /** Present only when the address was recovered from the binding table. */ binding?: FactoryRunBindingRecord; } /** * Resolve the bound session address, falling back to the active binding row * when the in-memory session state is missing `factoryProjectId` — a server * crash drops controller sessions, and a resumed session ("Continue") is * recreated with empty state, which silently unregistered the transition * tool. On recovery the lost state is healed back onto the session (including * the `untrustedCheckout`/`baseRef` security posture the start coordinator * originally seeded) so later reads resolve directly. */ export declare function resolveFactorySessionAddress(options: { requestContext: RequestContext | undefined; storage: Pick; sessions?: FactorySessionSourceLookup; /** * Resolve through the binding table even when state already carries * `factoryProjectId`, so the row heals the rest of the session state. Prompt * creation uses this: a partially persisted state can keep the project id * while the untrusted-checkout posture is gone, and the direct short-circuit * would take that id as proof the session is intact. */ forceBindingLookup?: boolean; }): Promise; //# sourceMappingURL=binding-context.d.ts.map