import type { ConversationManager } from './conversation.js'; import type { ExecutionPlan } from './execution-plan.js'; import type { CacheHitTracker } from '../providers/cache-strategy.js'; import type { ConfigManager } from '../config/manager.js'; import type { ProviderRegistry } from '../providers/registry.js'; import type { ToolRegistry } from '../tools/registry.js'; import type { ToolCall, ToolResult } from '../types/tools.js'; import type { ContentPart, LLMProvider } from '../providers/interface.js'; import type { HookEvent, HookResult } from '../hooks/types.js'; import type { RuntimeEventBus } from '../runtime/events/index.js'; import { HelperModel } from '../config/helper-model.js'; import type { ModelDefinition } from '../providers/registry.js'; import type { FavoritesStore } from '../providers/favorites.js'; import type { AgentManager } from '../tools/agent/index.js'; import type { ExecutionPlanManager } from './execution-plan.js'; import { type TurnInjectionRecord, type TurnKnowledgeRegistrySource, type TurnCodeIndexSource } from '../agents/turn-knowledge-injection.js'; interface HookDispatcherLike { fire(event: HookEvent): Promise; } type EmitterContext = import('../runtime/emitters/index.js').EmitterContext; export interface OrchestratorTurnLoopContext { readonly conversation: ConversationManager; readonly toolRegistry: ToolRegistry; readonly getSystemPrompt: () => string; readonly getAbortSignal: () => AbortSignal | undefined; readonly hookDispatcher: HookDispatcherLike | null; readonly requestRender: () => void; readonly runtimeBus: RuntimeEventBus | null; readonly agentManager: Pick; readonly configManager: Pick; readonly providerRegistry: Pick; readonly favoritesStore?: Pick | undefined; readonly cacheHitTracker: Pick; readonly helperModel: HelperModel; readonly sessionId: string; readonly preTurnPlan: ExecutionPlan | null; readonly planManager: Pick | null; readonly text: string; readonly content?: ContentPart[] | undefined; readonly turnId: string; readonly emitterContext: (turnId: string) => EmitterContext; readonly executeToolCalls: (turnId: string, calls: ToolCall[]) => Promise; readonly checkContextWindowPreflight: (turnId: string, model: ModelDefinition) => Promise<'ok' | 'compacted' | 'error'>; readonly normalizeUsage: (usage: Awaited>['usage']) => Awaited>['usage']; readonly estimateFreshTurnInputTokens: (currentEstimatedTokens: number, text: string, content?: ContentPart[]) => number; readonly getMessageQueueLength: () => number; readonly isReconciliationEnabled: () => boolean; readonly setPendingToolCalls: (calls: ToolCall[]) => void; readonly setAutoSpawnTimeout: (timeout: ReturnType | null) => void; readonly setStreamingActive: (value: boolean) => void; readonly setStreamingInputTokens: (value: number) => void; readonly addStreamingOutputTokens: (value: number) => void; readonly setLastRequestInputTokens: (value: number) => void; readonly setLastInputTokens: (value: number) => void; readonly markTurnFailed: () => void; /** * The model/provider reported its context window filled (see * isContextOverflowSignal). The orchestrator must compact at the next * opportunity regardless of locally estimated usage, the provider's own * report is authoritative over the estimate. */ readonly noteModelContextWindowWarning: (details: { provider: string; model: string; providerStopReason?: string | undefined; }) => void; readonly usage: { input: number; output: number; cacheRead: number; cacheWrite: number; }; /** * Per-turn passive-injection wiring for the MAIN interactive session, * the sibling of the agent-runner's runAgentTask wiring in agents/orchestrator-runner.ts, * gated on the SAME `agent-passive-knowledge-injection` capability gate (its description * already promised "the EVOLVING main-session conversation" coverage; see * runtime/feature-flags/flags.ts). `memoryRegistry` undefined is a hard no-op, matching * the agent path. Budget/floor default to the same derived defaults * (defaultTurnKnowledgeBudgetTokens / DEFAULT_TURN_KNOWLEDGE_RELEVANCE_FLOOR) when * omitted. */ readonly memoryRegistry?: TurnKnowledgeRegistrySource | undefined; readonly isPassiveKnowledgeInjectionEnabled: () => boolean; readonly passiveKnowledgeInjectionBudgetTokens?: number | undefined; readonly passiveKnowledgeInjectionRelevanceFloor?: number | undefined; /** * Stage B, repo code index for the main session's per-turn injection. Undefined is a * hard no-op. `isPassiveCodeInjectionEnabled` resolves the combined gate (flag AND setting); * both it and the source must be present for code hits to be considered this turn. */ readonly codeIndex?: TurnCodeIndexSource | undefined; readonly isPassiveCodeInjectionEnabled: () => boolean; /** * The main session has no spawn-time `AgentRecord.knowledgeInjections` baseline, so this * starts empty and grows monotonically for the life of the Orchestrator, no record is * ever surfaced twice across the whole interactive session (mirrors the agent-runner's * knowledgeIdsAlreadySurfaced, but session-lifetime instead of one-agent-run-lifetime). */ readonly getAlreadyInjectedKnowledgeIds: () => readonly string[]; readonly addInjectedKnowledgeIds: (ids: readonly string[]) => void; /** Bounded ring (see recordTurnInjection) backing Orchestrator.getTurnInjections(). */ readonly recordTurnKnowledgeInjection: (record: TurnInjectionRecord) => void; /** Monotonic per-Orchestrator-lifetime sequence number for TurnInjectionRecord.turn. */ readonly nextTurnKnowledgeSequence: () => number; } export declare function executeOrchestratorTurnLoop(context: OrchestratorTurnLoopContext): Promise; export {}; //# sourceMappingURL=orchestrator-turn-loop.d.ts.map