import { type MemorySettingsRecord, type MemorySettingsStorage } from '../storage/domains/memory-settings/base.js'; import type { FactoryProjectsStorage } from '../storage/domains/projects/base.js'; import type { SourceControlStorageHandle } from '../storage/domains/source-control/base.js'; /** Default thresholds mirror the TUI `/om` fallbacks. */ export declare const DEFAULT_OBSERVATION_THRESHOLD = 30000; export declare const DEFAULT_REFLECTION_THRESHOLD = 40000; /** One observational-memory role's read/switch surface. */ interface OMRoleSlice { modelId: () => string | undefined; switchModel: (args: { modelId: string; }) => Promise; } /** * Session-state fields memory-settings hydration writes. The index signatures * mirror `MastraCodeState` so the concrete `Session.state.set(Partial)` * stays assignable to this minimal surface (contravariant parameter check). */ interface OMStateWrites { [key: string]: unknown; [key: `subagentModelId_${string}`]: string | undefined; observationThreshold?: number; reflectionThreshold?: number; observeAttachments?: 'auto' | boolean; factoryOrgId?: string; } /** The slice of a session needed to apply stored observational-memory settings. */ export interface OMConfigurableSession { om: { observer: OMRoleSlice; reflector: OMRoleSlice; }; state: { get: () => Record | undefined; set: (updates: OMStateWrites) => Promise | void; }; } /** * Apply a stored memory-settings row onto a session, so the DB — not whatever * happens to sit in persisted session state (e.g. a stale boot-time seed from * before memory settings moved to the DB) — is what the web surface reads and * what the session's OM actually runs with. The row is authoritative: knobs * without a stored value reset to the built-in defaults. This is the single * application path shared by the settings routes, coordinator hydration, and * the web session boot seed. */ export declare function applyStoredMemorySettings(session: OMConfigurableSession, record: MemorySettingsRecord | null, fallbackOmModelId?: string): Promise; export interface MemorySettingsHydrationSession extends OMConfigurableSession { readonly identity: { getResourceId(): string; }; } export interface MemorySettingsHydrationDependencies { /** GitHub-integration source-control rows — the only creator of web user sessions today. */ sourceControl: { sessions: Pick; }; projects: Pick; memorySettings: Pick; } /** * Seed a freshly created controller session's tenant org and its * observational-memory settings from the owner's source-control row. Registered * as a blocking session-created listener so the seed lands before the caller can * start a run. * * The org seed matters beyond settings. Subconscious knowledge curation scopes * every node and record on `factoryOrgId`; before the SDK refusal guard, * missing it made curation substitute the session owner id. For web chat sessions * that is the agent controller's own id rather than a tenant, so curated * knowledge landed under an org rung no reader ever queries. Same rule as the * start coordinator: the org * comes from the row the session was created from, never improvised from an * owner id. * * Tagged sessions may be coordinator-owned runs or web sessions that only carry * browser-seeded Factory state. This path resolves their source-control row and * reapplies a stored project settings row when one exists. If no project row * exists, it preserves the coordinator's provider-aware fallback. * Sessions without a GitHub source-control row (e.g. chat-only channel sessions) * hydrate through `hydrateFactorySession` with their own resolved tenant. * Best-effort: failures are logged, never thrown. */ export declare function hydrateSessionMemorySettings(session: MemorySettingsHydrationSession, { sourceControl, projects, memorySettings }: MemorySettingsHydrationDependencies): Promise; export {}; //# sourceMappingURL=memory-settings-hydration.d.ts.map