/** * Settings persistence for Photon instances. * * Owns the load → merge → expose-as-Proxy → persist-on-change lifecycle for * `protected settings` declared by photons. Extracted from PhotonLoader so * the loader doesn't have to know about settings paths, the read-only Proxy, * or the auto-generated MCP tool surface. */ import { PhotonTool, type SettingsSchema, type InputProvider, type OutputHandler } from '@portel/photon-core'; type LogFn = (message: string, meta?: Record) => void; interface SettingsToolOptions { outputHandler?: OutputHandler; inputProvider?: InputProvider; } export declare class SettingsPersistence { private readonly baseDir; private readonly log; /** Per-(photon, instance) write chains — see queuePersist. */ private persistTails; constructor(baseDir: string | undefined, log: LogFn); /** * Get the settings persistence path for a photon instance. * Co-located with state: settings.json sits next to state.json inside * the per-instance directory. */ getPath(photonName: string, instanceName: string): string; /** Load persisted settings from disk. Returns {} if the file is missing. */ load(photonName: string, instanceName: string): Promise>; /** Persist settings to disk, creating parent directories as needed. */ persist(photonName: string, instanceName: string, values: Record): Promise; /** * Serialize persists per (photon, instance). settings.json is written * non-atomically, so concurrent writes for the same instance can interleave * or land out of order; chaining them guarantees the last change wins. */ private queuePersist; /** Wait for all queued settings writes for an instance to reach disk. */ flush(photonName: string, instanceName: string): Promise; /** * Inject settings into a photon instance: * - Load persisted values (persisted wins over in-source defaults) * - Replace `instance.settings` with a read-only Proxy * - Stamp the writable backing object plus identity on the instance so the * auto-generated `settings` tool can update it later. */ inject(instance: Record, photonName: string, instanceName: string, schema: SettingsSchema): Promise; /** Generate an MCP tool definition from a SettingsSchema. */ generateTool(schema: SettingsSchema): PhotonTool; /** * Execute the auto-generated settings tool: * - No params → return current settings (eliciting any required-but-unset values) * - Params with values → update those settings, persist, emit change * - Params with explicit undefined on a required prop → trigger elicitation */ execute(instance: Record, parameters: Record | undefined, options?: SettingsToolOptions): Promise>; /** Emit a `settings:changed` event through the photon's emit system. */ private emitChange; } export {}; //# sourceMappingURL=settings-persistence.d.ts.map