/** * companion-chat-turn-execution.ts * * The two turn-execution helpers used by CompanionChatManager._runTurn, split * out of companion-chat-manager.ts (see CHANGELOG) so the manager stays under * the repo's hand-authored file-size cap while regenerate/edit verbs are added. * These are a pure move: the logic is unchanged, the manager now passes the * dependencies it used to reach through `this`. * * - runToolExhaustionFinalizer: after the tool-call budget is exhausted, run one * more streamed turn that is instructed not to call tools, returning its text. * - executeCompanionToolCalls: execute model-emitted tool calls through the * permission boundary and publish per-call results, degrading honestly when a * registry is present without a permission manager. */ import type { ConversationManager } from '../core/conversation.js'; import type { CompanionChatTurnEvent } from './companion-chat-types.js'; import type { CompanionLLMProvider } from './companion-chat-manager.js'; import type { ToolRegistry } from '../tools/registry.js'; import type { ToolCall, ToolResult } from '../types/tools.js'; import type { PermissionManager } from '../permissions/manager.js'; import type { RuntimeEventBus } from '../runtime/events/index.js'; import type { HookEvent, HookResult } from '../hooks/types.js'; type HookDispatcherLike = { fire(event: HookEvent): Promise; }; /** The minimal session shape the finalizer needs (avoids importing the private InternalSession). */ interface FinalizerSession { readonly meta: { readonly id: string; readonly model: string | null; readonly provider: string | null; readonly systemPrompt: string | null; }; readonly conversation: ConversationManager; } export interface ToolExhaustionFinalizerDeps { readonly provider: CompanionLLMProvider; /** The pre-built finalizer system prompt (kept in the manager alongside its round cap). */ readonly finalizerPrompt: string; } /** * Run a single streamed turn after the per-turn tool-call budget is exhausted, * instructing the model not to call more tools, and return the collected text. */ export declare function runToolExhaustionFinalizer(deps: ToolExhaustionFinalizerDeps, session: FinalizerSession, abortSignal: AbortSignal, turnId: string, publish: (event: CompanionChatTurnEvent) => void): Promise; export interface CompanionToolExecutionDeps { readonly toolRegistry: ToolRegistry | null; readonly permissionManager: PermissionManager | null; readonly hookDispatcher: HookDispatcherLike | null; readonly runtimeBus: RuntimeEventBus | null; } /** * Execute model-emitted tool calls through the permission boundary and publish * each result. Returns [] when no registry is configured; denies every call * honestly (isError result + published event) when a registry exists without a * permission manager. */ export declare function executeCompanionToolCalls(deps: CompanionToolExecutionDeps, toolCalls: ToolCall[], publish: (event: CompanionChatTurnEvent) => void, sessionId: string, turnId: string): Promise; export {}; //# sourceMappingURL=companion-chat-turn-execution.d.ts.map