/** * Role-based LLM executor — Phase 4 W2 mini-prototype. * * Issues a single text-completion call for a logical role * (`consolidation`, `extraction`, `derivation`, `hygiene`, `judgement`) and * returns the normalized response. Internally: * * 1. {@link resolveLLMForRole}(role) — picks provider + model + credential * from the standard config chain (roles → default → daemon → fallback). * 2. {@link deriveApiWire}(provider, authType) — stamps the wire protocol + * implied base URL for the resolved pair (E9 · T11745). * 3. {@link ModelRunner.buildTransportFromCredential} — the single SSoT * factory builds the exact transport for ANY provider (anthropic incl. the * OAuth beta header, kimi-code, openai-OAuth/codex, OpenAI-compat) from the * descriptor data alone — no per-provider branching here. * * Replaces the hardcoded `fetch('https://api.anthropic.com/v1/messages')` * in {@link memory/sleep-consolidation.ts} and {@link memory/observer-reflector.ts} * so the brain layer respects per-role provider config and the T9261 Phase 3 * unified credential/transport stack. * * This is intentionally narrow: text-only, no tools, no streaming, no batch. * The full {@link LlmExecutor} (W2, with multi-turn sessions, tool routing, * caching, and rotation) is a separate epic — this helper just unblocks the * brain's dream/compression layer in the meantime. * * @module llm/role-executor * @task T9320 * @epic T9261 T-LLM-CRED-CENTRALIZATION * @see ADR-072 §Type lock-in */ import type { RoleName } from '@cleocode/contracts'; import type { NormalizedUsage } from '@cleocode/contracts/llm/normalized-response.js'; import type { ModelTransport } from './types-config.js'; /** * Test-only: clear the role-failure warning latch so a fresh test run starts * from a clean slate. Production callers MUST NOT use this. * * @internal * @task T11617 */ export declare function _resetRoleWarnLatchForTests(): void; /** * Options accepted by {@link executeForRole}. * * Every field is optional — callers that want defaults can pass `{}`. */ export interface ExecuteForRoleOptions { /** * Absolute path to the project root. Forwarded to * {@link resolveLLMForRole} for tier-5 (project-config) credential lookup. */ projectRoot?: string; /** Maximum tokens to generate. Default {@link DEFAULT_MAX_TOKENS}. */ maxTokens?: number; /** Optional abort signal forwarded to the SDK fetch. */ signal?: AbortSignal; /** Optional model override — bypasses the role-resolved model. */ modelOverride?: string; /** Sampling temperature in 0.0–1.0 range. Default left to the transport. */ temperature?: number; } /** * Successful result of {@link executeForRole}. * * `null` is returned when no credential is configured or the transport call * fails — callers MUST handle the null path as a no-op (graceful degradation * preserves the previous structural-fallback behaviour in sleep-consolidation * and observer-reflector). */ export interface ExecuteForRoleResult { /** Assistant text content (may be the empty string but never null). */ content: string; /** Token usage reported by the provider. */ usage: NormalizedUsage; /** Provider transport identifier that was selected. */ provider: ModelTransport; /** Model identifier as reported by the provider response. */ model: string; } /** * Execute a single text-completion call for the given semantic role. * * Returns `null` on graceful-degradation paths: * - No credential resolved for the configured provider. * - Transport `complete()` throws (network error, 4xx, 5xx, abort). * * Errors are scrubbed via the same `console.warn` pattern the legacy * call-sites used, so log discipline is unchanged. * * @param role - Semantic role declared by the caller. * @param systemPrompt - System instruction for the LLM. * @param userContent - User message content. * @param opts - Optional max tokens, abort signal, model override. * @returns Normalized result or `null` on no-credential / transport error. * * @task T9320 */ export declare function executeForRole(role: RoleName, systemPrompt: string, userContent: string, opts?: ExecuteForRoleOptions): Promise; //# sourceMappingURL=role-executor.d.ts.map