import type { SmolConfig } from "smoltalk"; import type { AgencyConfig } from "../config/config.js"; import type { StatelogConfig } from "../statelogClient.js"; import type { LogLevel } from "../logger.js"; import type { MemoryConfig } from "./memory/types.js"; import type { TraceConfig } from "./trace/types.js"; export type RuntimeContextConstructorArgs = { statelogConfig: StatelogConfig; smoltalkDefaults: Partial; maxToolResultChars?: number; maxToolSchemaChars?: number; providerModules?: string[]; dirname: string; maxRestores?: number; maxCallDepth?: number; failurePropagation?: "off" | "warn" | "on"; budget?: { maxCost?: number; maxTimeMs?: number; }; traceConfig?: TraceConfig; verbose?: boolean; memory?: MemoryConfig; logLevel?: LogLevel; }; export declare function setRuntimeConfigOverrides(overrides: Partial | undefined): void; export declare function getRuntimeConfigOverrides(): Partial | undefined; /** * Run `fn` with `overrides` installed as the active runtime config overrides, * restoring whatever was set before when `fn` settles. * * A host that serves many compiled modules from one process uses this to bind * per-module log/observability config at the moment it imports that module: the * overrides are read by the `RuntimeContext` constructor, which runs while the * module is importing, so the import must happen inside `fn`. The overrides only * need to differ per module (not per request), because they are frozen into that * module's `RuntimeContext` at import and every later invocation derives from it. * * The overrides live in a single process-global, so a host serving concurrently * MUST serialize its imports (e.g. behind a mutex) — otherwise two overlapping * `withRuntimeConfigOverrides` scopes would read each other's values. This helper * does not lock; it only pairs set with restore. */ export declare function withRuntimeConfigOverrides(overrides: Partial | undefined, fn: () => Promise): Promise; /** * Apply runtime config overrides — a `Partial` — onto the args * used to construct a `RuntimeContext`. This is THE single runtime merge; it * serves two transports: * • subprocess IPC: the parent forwards `configOverrides` in the spawn * message (`setRuntimeConfigOverrides` sets the active value). * • bundled agents / packed bundles: `AGENCY_CONFIG_OVERRIDES` in the env * (`lib/config/config.ts` `readConfigOverrides`), passed explicitly by the caller. * * Fields honored (others are ignored — the runtime has its own pathways): * • `log.*` + `observability` → statelogConfig * • `traceFile` / `traceDir` → traceConfig (the `trace` boolean is only a * marker set alongside them by applyCliFlags; the file/dir drive output). * An override always wins over the baked traceConfig: a supplied `traceDir` * clears any baked `traceFile` (which `resolveTraceFilePath` would otherwise * prefer), so a per-run `--trace` dir actually takes effect. * • `client.providerModules` → merged with baked modules (subprocess loads * the same custom/local providers; de-duped at load time). * • `maxCallDepth` → inherit the parent's runaway-recursion ceiling. * • `failurePropagation` → inherit the parent's failure-propagation mode. * • `budget` → the root spend/time cap; the config shape (`maxTime` as a * duration string) is resolved to `{ maxCost, maxTimeMs }` here. This is how * a host (statelog) sets a served agent's per-agent spend limit. * • `client.defaultModel` and `client.defaultProvider` → the model and its * provider, by `defaultRoute`: a model named alone clears the baked * provider, as the code generator would have. * • `client.apiKey` and `client.baseUrl` → merged per provider over the baked * ones. * • `client.logLevel` and `client.openRouter` → replace the baked ones. * • `client.maxToolResultChars` and `client.maxToolSchemaChars` → the tool * caps. * • `checkpoints.maxRestores` → the restore cap. * * Other `client` paths are not applied: `client.statelog` and * `client.llamaCpp` are baked only, and the rest (`modelAliases`, `modelsDir`, * and so on) are read from the config file at runtime by the code that needs * them. All three entry points (the env variable, the IPC message, and * `withRuntimeConfigOverrides`) get every field above, since they share this * function. */ export declare function applyRuntimeConfigOverridesToContextArgs(args: RuntimeContextConstructorArgs, overrides?: Partial | undefined): RuntimeContextConstructorArgs;