/** * Persistent global settings stored in the app data directory as settings.json. * This file persists onboarding state AND user preferences (model choices, yolo, etc.) * so they carry across threads and restarts. */ import type { MastraBrowser } from '@mastra/core/browser'; import type { LSPConfig } from '@mastra/core/workspace'; /** A saved custom pack — user-defined model selections for each mode. */ export interface CustomPack { name: string; models: Record; createdAt: string; } /** A saved custom provider for OpenAI-compatible endpoints. */ export interface CustomProviderSetting { name: string; url: string; apiKey?: string; models: string[]; } /** Storage backend type. */ export type StorageBackend = 'libsql' | 'pg'; /** LibSQL-specific storage settings. */ export interface LibSQLStorageSettings { url?: string; authToken?: string; } /** PostgreSQL-specific storage settings. */ export interface PgStorageSettings { connectionString?: string; host?: string; port?: number; database?: string; user?: string; password?: string; schemaName?: string; disableInit?: boolean; skipDefaultIndexes?: boolean; } /** Storage configuration persisted in global settings. */ export interface StorageSettings { /** Which backend to use. Default: 'libsql'. */ backend: StorageBackend; /** LibSQL-specific config (used when backend is 'libsql'). */ libsql: LibSQLStorageSettings; /** PostgreSQL-specific config (used when backend is 'pg'). */ pg: PgStorageSettings; } /** Memory gateway provider key used in AuthStorage. */ export declare const MEMORY_GATEWAY_PROVIDER = "mastra-gateway"; /** Default gateway URL. */ export declare const MEMORY_GATEWAY_DEFAULT_URL = "https://gateway-api.mastra.ai"; /** Valid persisted thinking level values. */ export type ThinkingLevelSetting = 'off' | 'low' | 'medium' | 'high' | 'xhigh'; /** Browser provider type. */ export type BrowserProvider = 'stagehand' | 'agent-browser'; /** Stagehand environment type. */ export type StagehandEnv = 'LOCAL' | 'BROWSERBASE'; /** Stagehand-specific browser settings. */ export interface StagehandSettings { env: StagehandEnv; apiKey?: string; projectId?: string; /** Whether to preserve the user data directory after the browser closes. */ preserveUserDataDir?: boolean; } /** AgentBrowser-specific browser settings. */ export interface AgentBrowserSettings { /** Path to a Playwright storage state file (JSON) containing cookies and localStorage. */ storageState?: string; } /** Browser configuration persisted in global settings. */ export interface BrowserSettings { /** Whether browser automation is enabled. */ enabled: boolean; /** Which browser provider to use. */ provider: BrowserProvider; /** Whether to run headless (no visible browser window). */ headless: boolean; /** Browser viewport dimensions. */ viewport?: { width: number; height: number; }; /** CDP URL for connecting to an existing browser. */ cdpUrl?: string; /** Path to a Chrome/Chromium user data directory (profile). */ profile?: string; /** Path to the browser executable to use. */ executablePath?: string; /** Browser scope — 'shared' (all threads share one browser) or 'thread' (each thread gets its own). */ scope?: 'shared' | 'thread'; /** Stagehand-specific settings. */ stagehand?: StagehandSettings; /** AgentBrowser-specific settings. */ agentBrowser?: AgentBrowserSettings; } export interface GlobalSettings { onboarding: { completedAt: string | null; skippedAt: string | null; version: number; modePackId: string | null; omPackId: string | null; quietModePreferenceSelected: boolean; }; models: { /** * Active model pack ID. Built-in packs use their id directly ("anthropic", * "openai"). Custom packs use "custom:". * When set, models are resolved from the pack at startup so pack updates * (e.g. new model versions) apply automatically. * Cleared when the user manually overrides via /models (falls back to modeDefaults). */ activeModelPackId: string | null; /** Explicit per-mode overrides — used when no activeModelPackId is set. */ modeDefaults: Record; /** * Active OM pack ID (e.g. "gemini", "anthropic", "custom"). * When set, the OM model is resolved from the pack at startup so pack * updates (e.g. new model versions) apply automatically. * Cleared when the user manually overrides via /om (falls back to omModelOverride). */ activeOmPackId: string | null; /** * Shared OM model override — used for both observer and reflector when a * role-specific override is not set. Kept for back-compat with older settings * files and set by onboarding when the user picks a custom OM pack. */ omModelOverride: string | null; /** * Explicit Observer model override — takes precedence over `omModelOverride` * when set. Written by `/om` when the observer model is changed independently. */ observerModelOverride: string | null; /** * Explicit Reflector model override — takes precedence over `omModelOverride` * when set. Written by `/om` when the reflector model is changed independently. */ reflectorModelOverride: string | null; /** Default OM observation threshold used for new threads unless overridden per-thread. */ omObservationThreshold: number | null; /** Default OM reflection threshold used for new threads unless overridden per-thread. */ omReflectionThreshold: number | null; /** * Whether observations and reflections use the terse caveman-style instruction. * `null` means inherit the built-in default (currently `false` — caveman is * opt-in via `/om` settings). Used as the default for new threads unless * overridden per-thread. */ omCavemanObservations: boolean | null; /** * Whether Observational Memory forwards image/file attachment parts to the * Observer LLM. `null` ⇒ inherit built-in default ('auto'). 'auto' checks * model capabilities; true/false forces the setting. */ omObserveAttachments: 'auto' | boolean | null; /** Per-agent-type subagent model overrides (e.g. { explore: "openai/gpt-5.1-codex-mini" }) */ subagentModels: Record; /** Default judge model for /goal. */ goalJudgeModel: string | null; /** Default max attempts for /goal. */ goalMaxTurns: number | null; }; preferences: { yolo: boolean | null; theme: 'auto' | 'dark' | 'light'; /** Default reasoning effort level used for all threads/models unless overridden in-session. */ thinkingLevel: ThinkingLevelSetting; /** When true, components like subagent output collapse to compact summaries on completion. */ quietMode: boolean; /** Maximum quiet-mode detail preview lines for compact tool calls. Set to 0 to hide previews. */ quietModeMaxToolPreviewLines: number; }; storage: StorageSettings; customModelPacks: CustomPack[]; customProviders: CustomProviderSetting[]; modelUseCounts: Record; updateDismissedVersion: string | null; memoryGateway: { baseUrl?: string; }; lsp?: LSPConfig; browser: BrowserSettings; signals: SignalSettings; observability: ObservabilitySettings; } export interface SignalSettings { /** Opt into local Unix socket PubSub for cross-process signal routing. */ unixSocketPubSub: boolean; } export interface ObservabilityResourceConfig { /** Cloud project ID for this resource */ projectId: string; /** When this config was created */ configuredAt: string; } export interface ObservabilitySettings { /** Per-resource cloud project configs, keyed by resourceId */ resources: Record; /** Whether to store traces locally in DuckDB. Off by default to avoid disk usage. */ localTracing: boolean; } /** Auth key prefix for observability tokens stored per-resource in auth.json */ export declare const OBSERVABILITY_AUTH_PREFIX = "observability:"; export declare const STORAGE_DEFAULTS: StorageSettings; export declare function getSettingsPath(): string; export declare function getCustomProviderId(name: string): string; export declare function toCustomProviderModelId(providerName: string, modelName: string): string; export declare function parseCustomProviders(rawProviders: unknown): CustomProviderSetting[]; export declare function migrateLegacyVariedPack(settings: GlobalSettings): boolean; export declare function loadSettings(filePath?: string): GlobalSettings; export declare const THREAD_ACTIVE_MODEL_PACK_ID_KEY = "activeModelPackId"; export interface ThreadSettings { activeModelPackId: string | null; modeModelIds: Record; } export declare function parseThreadSettings(metadata: Record | undefined): ThreadSettings; /** * Resolve active model pack id for the current thread. * * Priority: * 1) explicit thread metadata activeModelPackId * 2) inferred from thread modeModelId_* values * 3) global settings.models.activeModelPackId */ export declare function resolveThreadActiveModelPackId(settings: GlobalSettings, builtinPacks: Array<{ id: string; models: Record; }>, metadata: Record | undefined): string | null; /** * Resolve effective per-mode model defaults. * * If `activeModelPackId` is set, looks up the pack (built-in or custom) and * returns its models. Falls back to the explicit `modeDefaults` map. * * @param settings The loaded global settings. * @param builtinPacks Built-in packs for the current provider access * (from `getAvailableModePacks`). Pass `[]` if unavailable. */ export declare function resolveModelDefaults(settings: GlobalSettings, builtinPacks: Array<{ id: string; models: Record; }>): Record; /** * Resolve the effective model ID for one of the two OM roles. * * Lookup order: * 1. The role-specific override (`observerModelOverride` / * `reflectorModelOverride`) if set. * 2. If `activeOmPackId` points at a built-in pack, that pack's model. * 3. The shared `omModelOverride` fallback. * * @param settings The loaded global settings. * @param role Which OM role to resolve (`'observer'` or `'reflector'`). * @param builtinOmPacks Built-in OM packs for the current provider access * (from `getAvailableOmPacks`). Pass `[]` if unavailable. */ export declare function resolveOmRoleModel(settings: GlobalSettings, role: 'observer' | 'reflector', builtinOmPacks: Array<{ id: string; modelId: string; }>): string | null; /** * @deprecated Use `resolveOmRoleModel(settings, 'observer' | 'reflector', ...)`. * Equivalent to resolving the observer role (existing callers set both observer * and reflector to the same value). */ export declare function resolveOmModel(settings: GlobalSettings, builtinOmPacks: Array<{ id: string; modelId: string; }>): string | null; export declare function saveSettings(settings: GlobalSettings, filePath?: string): void; /** * Check which provider last used a profile directory. * Returns the provider name if the marker exists, undefined otherwise. */ export declare function getProfileProvider(profilePath: string): BrowserProvider | undefined; /** * Write the provider marker to a profile directory. * Creates the directory if it doesn't exist. */ export declare function setProfileProvider(profilePath: string, provider: BrowserProvider): void; /** * Check if a profile has a provider mismatch. * Returns the existing provider if there's a mismatch, undefined otherwise. */ export declare function checkProfileProviderMismatch(profilePath: string | undefined, targetProvider: BrowserProvider): BrowserProvider | undefined; /** * Create a browser instance from settings. * Shared by startup (main.ts) and live reconfiguration (/browser command). * Returns undefined if browser is disabled. */ export declare function createBrowserFromSettings(settings: BrowserSettings): Promise; //# sourceMappingURL=settings.d.ts.map