import type { DerivedTaxonomy, WizardResult } from "@onenomad/przm-cortex-core"; /** * Atomic multi-file config mutation for Cortex. * * Every enable/configure/disable operation on a module boils down to * edits in three files: * * config/cortex.local.yaml — adapters/providers/memory/etc. * .env — secrets * config/projects.local.yaml — taxonomy (may expand to people/engagements) * * Each file gets the tmp-then-rename atomic write pattern so a crash * mid-write never leaves a corrupted half-file behind. The service is * shared by the CLI runner and (later) the dashboard's server actions, * so config mutations take the same path regardless of entry point. */ export interface ConfigMutationOptions { /** Repo root. Used to resolve relative paths for config files + .env. */ repoRoot: string; } /** * Enable a module (adapter, provider, etc.) with the collected wizard * result. Creates cortex.local.yaml from the template if it doesn't * already exist so the operator never starts from a blank file. */ export declare function applyWizardResult(opts: ConfigMutationOptions, result: WizardResult): Promise<{ filesWritten: string[]; }>; /** * Set the default LLM task to a specific provider+model. Writes to * `cortex.local.yaml` so the change survives base-template rewrites. * * Used by the env-driven bootstrap path (`seedLlmProviderFromEnv`) * for per-tenant Cortex Cloud deployments where pyre-web injects * the provider config via env at machine create time. Without this, * a fresh tenant comes up with the bootstrap default model * ("anthropic/claude-haiku-4.5") even when the configured provider * is Azure OpenAI behind the openrouter shim — which would 404 on * any LLM call. Idempotent. */ export declare function setDefaultLlmTask(opts: { repoRoot: string; provider: string; model: string; /** * Apply the same provider+model to these named tasks too. Defaults * to ['default'] only; pass extra task purposes (extract, classify, * summarize, brief, structural, synthesis) when you want them to * route to the same model. */ tasks?: readonly string[]; }): Promise<{ filesWritten: string[]; }>; /** * Set memory.pgvector.useLocalEmbedder. Used by the env-driven * bootstrap to pin embeddings to the local Xenova model when the * configured LLM provider can't do embeddings (Azure chat-only, * Anthropic, etc.). See clients/memory.ts for how this is honored. */ export declare function setUseLocalEmbedder(opts: { repoRoot: string; value: boolean; }): Promise<{ filesWritten: string[]; }>; /** * Flip a module off. Leaves its config in place so re-enabling doesn't * lose settings. Only touches cortex.local.yaml. */ export declare function disableModule(opts: ConfigMutationOptions, moduleId: string, category?: "adapter" | "provider" | "memory" | "toolkit" | "webhook"): Promise; /** * Read a module's current config from cortex.local.yaml (or the template * if the local doesn't exist). Used by `cortex configure` to pre-fill * wizard defaults with the current values. */ export declare function readModuleConfig(opts: ConfigMutationOptions, moduleId: string, category?: "adapter" | "provider" | "memory" | "toolkit" | "webhook"): Promise | undefined>; /** * If `/.local.yaml` doesn't exist, copy the committed * `/.yaml` template to it so the first write has somewhere * to land. Returns the local path either way. */ export declare function ensureLocalCopy(templatePath: string): Promise; /** * Append/update key=value entries in .env. Preserves existing lines and * their order; unknown keys are appended with a section header the first * time a group is added (for readability). * * Exported so the dashboard token CLI can share the same atomic write * path — every place that touches `.env` should go through here. */ export declare function mergeEnv(filePath: string, entries: Record): Promise; /** * Remove keys from a .env file. No-op if a key isn't present. Returns * the set of keys actually removed so callers can report `revoked: 0` * vs `revoked: N` without re-reading the file. */ export declare function removeEnvKeys(filePath: string, keys: ReadonlyArray): Promise; /** * Add missing project slugs to projects.local.yaml. Existing slugs are * left alone — the wizard doesn't overwrite user-curated entries. */ export declare function mergeProjects(filePath: string, projects: DerivedTaxonomy["projects"] & {}): Promise; /** * Add a path to `privateModules` in cortex.local.yaml. Deduplicates * against existing entries. The path written is whatever the caller * passes — typically the CONTAINER-side path (`/root/.cortex/modules/ * `) because cortex reads this file from inside Docker. */ export declare function addPrivateModule(opts: ConfigMutationOptions, modulePath: string): Promise<{ filePath: string; added: boolean; }>; /** * Remove a path from `privateModules`. Returns `removed: false` when * the path wasn't registered — that's not an error, just a no-op. */ export declare function removePrivateModule(opts: ConfigMutationOptions, modulePath: string): Promise<{ filePath: string; removed: boolean; }>; /** * Read the current `privateModules` list from cortex.local.yaml, * falling back to the committed template. Returns `[]` when the key * is missing or malformed. */ export declare function listPrivateModulesFromConfig(opts: ConfigMutationOptions): Promise; /** * Persist the live custom-memory-type set back to cortex.yaml's * `taxonomy.customTypes` stanza. The MemoryTypeRegistry's `persist` * callback points here, so an auto-add at ingest time survives a * restart and an operator's UI edit lands in the same place. * * Takes the explicit config path (not just repoRoot) because we want * to write into the workspace's cortex.yaml, not the committed * template. The boot path wires its own resolved path. */ export declare function persistCustomTypes(configPath: string, types: Array<{ slug: string; label?: string | undefined; description?: string | undefined; source: "config" | "auto"; }>): Promise; //# sourceMappingURL=config-mutation.d.ts.map