/** * Default LlmExecutor factory and singleton accessor. * * Wires {@link DefaultLlmSessionFactory} → {@link ConcreteExecutor} for a * given CLEO role, with an optional {@link ContextEngine} for context * compression. Provides a per-process singleton via {@link getLlmExecutor} * for callers that want a cached executor per role. * * @module llm/executor-factory * @task T9291 * @epic T9261 T-LLM-CRED-CENTRALIZATION * @see ADR-072 §2.2 */ import type { ExecutorFactoryOptions, LlmExecutor, LlmExecutorFactory } from '@cleocode/contracts/llm/interfaces.js'; import type { ContextEngine } from '@cleocode/contracts/memory/context-engine.js'; import { listContextEngines } from './context-engines/index.js'; export { listContextEngines }; /** * Default factory for creating {@link LlmExecutor} instances. * * Resolves provider + credential via `DefaultLlmSessionFactory`, wraps the * session in a {@link ConcreteExecutor}, and optionally attaches a * {@link ContextEngine}. When `llm.auxiliaryFallback` is set in the project * config, the resolved chain is automatically passed to every {@link ConcreteExecutor} * so cross-provider fallover works without any call-site changes. * * @example * ```ts * const factory = new DefaultLlmExecutorFactory(); * const executor = await factory.createForRole('consolidation'); * for await (const event of executor.run({ messages: [...] })) { * if (event.kind === 'done') console.log(event.usage); * } * ``` */ export declare class DefaultLlmExecutorFactory implements LlmExecutorFactory { private readonly _sessionFactory; private readonly _contextEngine; /** * @param opts - Optional factory-level configuration. * @param opts.contextEngine - Context engine applied to all created executors. */ constructor(opts?: { contextEngine?: ContextEngine; }); /** * Creates an executor resolved from the given role name. * * Resolution chain delegates to {@link DefaultLlmSessionFactory.createForRole}: * `role → config.llm.roles[role] → config.llm.default → config.llm.daemon * → implicit anthropic/haiku fallback`. * * The resolved executor automatically receives the `llm.auxiliaryFallback` * chain from project config (if set), enabling cross-provider fallover. * * @param role - CLEO role name (e.g. `'orchestrator'`, `'sentient'`). * @returns A promise resolving to an initialized {@link LlmExecutor}. * @throws When no credential is available for the resolved provider. * * @task T9319 — auto-wire auxiliaryFallbackChain from config */ createForRole(role: string): Promise; /** * Creates an executor with the given options. * * When `opts.session` is supplied, wraps it directly. Otherwise delegates * to `sessionFactory.create(opts.sessionOptions)`. * * The resolved executor automatically receives the `llm.auxiliaryFallback` * chain from project config (if set), enabling cross-provider fallover. * * @param opts - Executor construction options. * @returns A promise resolving to an initialized {@link LlmExecutor}. * @throws When neither `session` nor valid session options are supplied. * * @task T9319 — auto-wire auxiliaryFallbackChain from config */ create(opts: ExecutorFactoryOptions): Promise; } /** * Register a {@link ContextEngine} for a given role. * * The registered engine is supplied to all executors created for that role * via {@link getLlmExecutor}. Call before the first {@link getLlmExecutor} * for the role, or call {@link clearLlmExecutorCache} first to invalidate * the cached executor. * * Also registers the engine in the plugin registry under the same name so * it appears in `cleo llm context-engines list`. * * @param role - CLEO role name to bind the engine to. * @param engine - The context engine implementation to register. */ export declare function registerContextEngine(role: string, engine: ContextEngine): void; /** * Returns a cached {@link LlmExecutor} for the given role. * * The first call for a given role creates and caches the executor. Subsequent * calls return the same instance. Use for callers that want a stable executor * across multiple calls without re-resolving credentials per call. * * The executor receives the {@link ContextEngine} registered for this role * (if any) via the {@link _engineRegistry}. The default registry seeds * `'compression'` with a {@link LlmSummarizationEngine}. * * NOTE: The executor's session history accumulates across calls. Callers * that need a fresh conversation should use `new DefaultLlmExecutorFactory() * .createForRole(role)` directly instead. * * @param role - CLEO role name (e.g. `'orchestrator'`, `'compression'`). * @returns A promise resolving to the cached {@link LlmExecutor} for this role. */ export declare function getLlmExecutor(role: string): Promise; /** * Clear the per-role executor cache. * * Useful in tests or when credential rotation requires a fresh session. * * @param role - When provided, clears only the cached executor for this role. * When omitted, clears all cached executors. */ export declare function clearLlmExecutorCache(role?: string): void; //# sourceMappingURL=executor-factory.d.ts.map