/** * Shared conversation loop for interactive modes (assistant & persona). * * Extracts the common patterns: * - Provider/session initialization * - Session state display/clear * - Conversation loop (slash commands, AI messaging, /go summary) */ import { SlashCommand } from '../../shared/constants.js'; import { type WorkflowContext, type InteractiveModeResult, type ConversationMessage, type InteractiveSeedInput, type PostSummaryAction } from './interactive.js'; import { type SessionContext } from './aiCaller.js'; import type { PermissionMode } from '../../core/models/index.js'; import type { InteractiveImageAttachment } from './imageAttachments.js'; export { type CallAIResult, type SessionContext, callAIWithRetry } from './aiCaller.js'; export declare function displayAndClearSessionState(cwd: string, lang: 'en' | 'ja'): void; export type { PostSummaryAction } from './interactive.js'; export interface SummaryPromptOptions { readonly history: ConversationMessage[]; readonly hasSession: boolean; readonly lang: 'en' | 'ja'; readonly noTranscriptNote: string; readonly conversationLabel: string; readonly workflowContext?: WorkflowContext; readonly sourceContext?: string; readonly promptContext?: string; readonly formalSpec: boolean; readonly formalSpecComments?: boolean; readonly userNote: string; } export type SummaryPromptBuilder = (options: SummaryPromptOptions) => string; export interface NormalizedSummaryTask { readonly task: string; readonly attachments: readonly InteractiveImageAttachment[]; } export type SummaryTaskNormalizer = (task: string, attachments: readonly InteractiveImageAttachment[]) => NormalizedSummaryTask; export interface ConversationPromptConfiguration { readonly systemPrompt: string; readonly formalSpec: boolean; readonly formalSpecComments?: boolean; readonly modelCheckTimeoutSeconds: number; } /** Strategy for customizing conversation loop behavior */ export interface ConversationStrategy { /** System prompt for AI calls */ systemPrompt: string; /** Resolved formal specification mode for this conversation session. */ formalSpec: boolean; /** Whether formal notation blocks must include natural-language meaning comments. */ formalSpecComments?: boolean; /** Timeout for Quint model checking and Alloy verification stages, in seconds. */ modelCheckTimeoutSeconds: number; /** Resolve prompt configuration after the user selects another session. */ resolveResumedSessionConfiguration?: () => Promise; /** Resolve the prompt again immediately before a regular turn or /go summary. */ resolveCurrentPromptConfiguration?: () => ConversationPromptConfiguration | Promise; /** Use the current conversation system prompt as /go's system prompt. */ useCurrentSystemPromptForSummary?: boolean; /** Allowed tools for AI calls */ allowedTools: string[]; /** Permission mode for AI calls. */ permissionMode?: PermissionMode; /** Transform user message before sending to AI (e.g., policy injection) */ transformPrompt: (userMessage: string, sourceContext?: string) => string; /** Intro message displayed at start */ introMessage: string; /** Custom action selector (optional). If not provided, uses default selectPostSummaryAction. */ selectAction?: (task: string, lang: 'en' | 'ja') => Promise; /** Action selector used for a generated /go proposal. */ selectGoAction?: (task: string, lang: 'en' | 'ja') => Promise; /** Action selector used by /retry. */ selectRetryAction?: (task: string, lang: 'en' | 'ja') => Promise; /** Build a mode-specific /go prompt. */ summaryPromptBuilder?: SummaryPromptBuilder; /** Normalize a generated summary and its attachments before confirmation. */ normalizeSummaryTask?: SummaryTaskNormalizer; /** Offset newly pasted image placeholders after the canonical order's images. */ initialImageAttachmentIndex?: number; /** Previous order.md content for /replay command (retry/instruct only) */ previousOrderContent?: string; /** Enable /retry slash command (retry mode only) */ enableRetryCommand?: boolean; /** Enable /open for a mode that can resolve a target run directory. */ enableOpenCommand?: boolean; /** Explicit slash-command allowlist for modes with a guarded execution path. */ enabledCommands?: readonly SlashCommand[]; /** Enable the `/tell` command. */ enableTellCommand?: boolean; /** Run to use as the initial `/tell` choice. */ initialReferenceRunSlug?: string; /** Capability notice shown before the first user input. */ mcpUnavailableNotice?: string; /** Context prepended to the first regular prompt in this conversation. */ initialPromptContext?: string; /** Task/action content supplied to the first `/verify` generation call. */ formalSpecInitialContext?: string; /** Context prepended to summary prompts. */ summaryPromptContext?: string; /** Include the command source on returned results for task re-execution flows. */ trackResultSource?: boolean; } /** * Run the shared conversation loop. * * Handles: EOF, /accept, /retry, /replay, /go (summary), /cancel, regular AI messaging. * The Strategy object controls system prompt, tool access, and prompt transformation. */ export declare function runConversationLoop(cwd: string, ctx: SessionContext, strategy: ConversationStrategy, workflowContext: WorkflowContext | undefined, initialInput: InteractiveSeedInput | undefined): Promise; //# sourceMappingURL=conversationLoop.d.ts.map