/** * AI call with automatic retry on stale/invalid session. * * Extracted from conversationLoop.ts for single-responsibility: * this module handles only the AI call + retry logic. */ import type { ProviderType } from '../../infra/providers/index.js'; import { getProvider } from '../../infra/providers/index.js'; import type { ImageAttachmentReference } from '../../shared/types/image-attachments.js'; import type { InternalAgentIsolation, StreamCallback } from '../../shared/types/provider.js'; import type { McpServerConfig, PermissionMode, StepProviderOptions } from '../../core/models/index.js'; /** Result from a single AI call */ export interface CallAIResult { content: string; sessionId?: string; success: boolean; /** Run confirmed by a successful `takt_get_run` MCP call in this turn. */ referenceRunSlug?: string; } /** Initialized session context for conversation loops */ export interface SessionContext { provider: ReturnType; providerType: ProviderType; model: string | undefined; lang: 'en' | 'ja'; personaName: string; sessionId: string | undefined; providerOptions?: StepProviderOptions; /** MCP servers available to this conversation. */ mcpServers?: Record; /** Internal identity for the TAKT-generated read-only task-state servers. */ taskStateMcpServers?: Record; permissionMode?: PermissionMode; /** Free-form per-call effort override selected in the interactive TUI. */ effort?: string; /** Do not hide an invalid temporary override behind an automatic retry. */ disableSessionRetry?: boolean; } interface CallAIWithRetryOptions { imageAttachments?: ImageAttachmentReference[]; /** Receives what a terminal caller would have printed alongside the answer. */ onNotice?: (message: string) => void; permissionMode?: PermissionMode; internalAgentIsolation?: InternalAgentIsolation; outputMode?: 'terminal' | 'silent'; abortSignal?: AbortSignal; /** * Persist a returned session ID for later resume. Defaults to true. * * A predicate is evaluated once the provider has answered, so a caller whose * turn can be superseded — the TUI interrupts one and starts the next — can * refuse to write the session of a turn nobody is waiting for any more. */ persistSession?: boolean | (() => boolean); /** Stream observer for callers that render the response themselves (`outputMode: 'silent'`). */ onStream?: StreamCallback; } /** * Call AI with automatic retry on stale/invalid session. * * On session failure, clears sessionId and retries once without session. * Updates sessionId and persists it on success. */ export declare function callAIWithRetry(prompt: string, systemPrompt: string, allowedTools: string[], cwd: string, ctx: SessionContext, options?: CallAIWithRetryOptions): Promise<{ result: CallAIResult | null; sessionId: string | undefined; /** * Why there is no result. A terminal caller reads it off the screen, but a * silent one (the Ink TUI) has no screen to read — without this the failure * would reach the user as "the assistant returned no response". */ error?: string; }>; export {}; //# sourceMappingURL=aiCaller.d.ts.map