/** * Default LlmSession factory implementation. * * Resolves the correct transport and credential for a role or explicit * provider/credential pair, then wraps them in a {@link ConcreteSession}. * * @module llm/session-factory * @task T9288 * @epic T9261 T-LLM-CRED-CENTRALIZATION * @see ADR-072 §2.2 */ import type { LlmSession, LlmSessionFactory, RetryPolicy, SessionFactoryOptions } from '@cleocode/contracts/llm/interfaces.js'; import type { LlmTransport } from '@cleocode/contracts/llm/normalized-response.js'; import type { ApiMode } from '@cleocode/contracts/llm/provider-id.js'; import type { ResolvedCredential } from '@cleocode/contracts/llm/resolved-credential.js'; import type { ModelTransport } from './types-config.js'; /** * Instantiate the correct {@link LlmTransport} for a provider/credential pair. * * Thin shim over the single SSoT factory {@link ModelRunner.buildTransportFromCredential} * (E9 · T11745). The provider→transport mapping (anthropic / bedrock / gemini / * ollama / codex_responses / chat-completions) now lives in ONE place — this * function delegates so existing callers keep their signature. * * `apiMode` takes precedence over provider name when `'codex_responses'` is * supplied — this allows xAI `grok-*` models to be served via the Responses * API endpoint instead of the default chat-completions path. * * @param provider - Provider identifier. * @param credential - Resolved credential to wire into the transport. * @param apiMode - Optional wire protocol override. When `'codex_responses'`, * constructs a {@link CodexResponsesTransport} regardless of provider name. * @returns The appropriate transport instance. */ declare function transportForProvider(provider: ModelTransport, credential: ResolvedCredential, apiMode?: ApiMode): LlmTransport; /** * Default factory for creating {@link LlmSession} instances. * * Uses the Phase-2 `resolveLLMForRole` resolution chain * (roles → default → daemon → implicit fallback) and wraps the result * in a {@link ConcreteSession} with the correct transport. * * @example * ```ts * const factory = new DefaultLlmSessionFactory(); * const session = await factory.createForRole('consolidation'); * const response = await session.send([{ role: 'user', content: 'Hello' }]); * ``` */ export declare class DefaultLlmSessionFactory implements LlmSessionFactory { private readonly _defaultRetryPolicy; /** * @param opts - Optional factory-level defaults. * @param opts.retryPolicy - Default retry policy applied to all created sessions. */ constructor(opts?: { retryPolicy?: RetryPolicy; }); /** * Creates a session resolved from the given role name. * * Resolution chain: `role → config.llm.roles[role] → config.llm.default * → config.llm.daemon → implicit anthropic/haiku fallback`. * * @param role - CLEO role name (e.g. `'orchestrator'`, `'sentient'`). * @returns A promise resolving to an initialized {@link LlmSession}. * @throws When no credential is available for the resolved provider. */ createForRole(role: string): Promise; /** * Creates a session with the given options. * * When `opts.role` is set, uses `resolveLLMForRole` for provider/credential * resolution. When `opts.providerId` + `opts.model` are set, the caller * must supply a credential via the `create` path. * * @param opts - Session construction options. * @returns A promise resolving to an initialized {@link LlmSession}. * @throws When no credential is available or the provider is unknown. */ create(opts: SessionFactoryOptions): Promise; } /** * Expose `transportForProvider` for unit testing. * * @internal — NOT part of the public API. Exported so the test suite can * assert which transport is instantiated for a given provider/apiMode pair * without going through the full role-resolution chain. */ export { transportForProvider as _transportForProviderForTesting }; //# sourceMappingURL=session-factory.d.ts.map