import type { InteractiveMode } from '../../core/models/index.js'; import type { WorkflowContext } from '../interactive/interactive-summary-types.js'; import type { RetryRunInfo } from '../interactive/retryMode.js'; import type { RunSessionContext } from '../interactive/runSessionReader.js'; import type { TaskRetryStartOption, TaskRetryStartSelection } from '../tasks/list/taskRetryStartSelection.js'; declare const CHAT_MODES: readonly ["assistant", "grill-me", "persona"]; export type WebChatMode = Extract; export type WebTaskActionKind = 'retry' | 'instruct'; /** Context shown to a dedicated conversation for an existing central task. */ export interface WebTaskActionContext { readonly taskId: string; readonly action: WebTaskActionKind; /** Registered project identity captured when the action conversation starts. */ readonly projectId?: string; readonly stateId?: string; readonly projectDirectory?: string; readonly task: string; readonly workflow: string; /** Initial step from the workflow snapshot used to resolve retry ownership. */ readonly workflowInitialStep?: string; readonly status: string; readonly attempt: number; readonly runIds: readonly string[]; /** Immutable task-generation snapshot captured when the action starts. */ readonly generation?: number; readonly runId?: string; readonly sourceRunId?: string; readonly branch?: string; readonly baseBranch?: string; readonly worktreePath?: string; readonly branchContext?: string; readonly workflowContext?: WorkflowContext; readonly runContext?: RetryRunInfo | null; readonly runSessionContext?: RunSessionContext; readonly previousOrderContent?: string | null; readonly retryNote?: string; readonly retryStartOptions?: { readonly options: readonly TaskRetryStartOption[]; readonly defaultId: string; }; /** Resolution table is process-local and is never sent to the browser. */ readonly retryStartSelections?: readonly { readonly id: string; readonly selection: TaskRetryStartSelection; }[]; readonly failure?: { readonly code: string; readonly message: string; readonly step?: string; readonly lastMessage?: string; }; } export interface WebTaskActionReference { readonly sessionId: string; readonly taskId: string; readonly action: WebTaskActionKind; readonly generation?: number; readonly retryStartOptions?: WebTaskActionContext['retryStartOptions']; } /** Server-side result of reserving a task-action conversation for /go. */ export interface WebTaskActionClaim { /** Process-local capability required to commit or release this reservation. */ readonly reservationToken: string; readonly context: WebTaskActionContext; readonly retrySelection?: TaskRetryStartSelection; /** Exact instruction shown by /go and eligible for final queueing. */ readonly taskActionDraft?: WebTaskActionDraft; } export interface WebTaskActionDraft { readonly task: string; readonly taskActionOptionId?: string; } export interface CreateWebChatRequest { readonly workflow: string; readonly mode: WebChatMode; } export interface WebChatSessionDescription extends CreateWebChatRequest { readonly id: string; readonly intro: string; readonly provider: string; readonly model?: string; readonly taskAction?: WebTaskActionReference; } export type WebChatReply = { readonly kind: 'assistant_response'; readonly content: string; } | { readonly kind: 'task_instruction'; readonly task: string; readonly taskAction?: WebTaskActionReference; readonly taskActionOptionId?: string; } | { readonly kind: 'error'; readonly message: string; }; export interface WebChatService { create(projectDirectory: string, request: CreateWebChatRequest): WebChatSessionDescription; reconfigure(sessionId: string, request: CreateWebChatRequest): WebChatSessionDescription; restart(sessionId: string): WebChatSessionDescription; send(sessionId: string, text: string, onThinking?: (content: string) => void, taskActionOptionId?: string): Promise; /** Start a conversation that can revise an existing central task only. */ createTaskAction?: (projectDirectory: string, context: WebTaskActionContext) => WebChatSessionDescription; /** Validate that a completion belongs to the task-action conversation. */ getTaskActionContext?: (sessionId: string) => WebTaskActionContext | undefined; /** Atomically reserve a task-action conversation for its final queue request. */ claimTaskAction?: (sessionId: string, optionId?: string) => WebTaskActionClaim; /** Return the server-held /go draft awaiting the user's choice. */ getTaskActionDraft?: (sessionId: string) => WebTaskActionDraft | undefined; /** Return a rejected /go draft to the same conversation for further editing. */ continueTaskAction?: (sessionId: string) => WebTaskActionDraft; /** Discard a pending /go draft and close the task-action conversation. */ cancelTaskAction?: (sessionId: string) => void; /** Permanently consume a successful task-action reservation. */ commitTaskAction: (sessionId: string, reservationToken: string) => void; /** Release a failed task-action reservation owned by the caller. */ releaseTaskAction: (sessionId: string, reservationToken: string) => void; } export declare class WebChatInputError extends Error { readonly status: number; constructor(status: number, message: string); } export declare function parseCreateWebChatRequest(value: unknown): CreateWebChatRequest; export declare function parseWebChatMessage(value: unknown): string; export interface WebChatMessageRequest { readonly text: string; readonly taskActionOptionId?: string; } /** Parse the message envelope while keeping the legacy text-only parser. */ export declare function parseWebChatMessageRequest(value: unknown): WebChatMessageRequest; export declare function createWebChatService(): WebChatService; export {}; //# sourceMappingURL=chat.d.ts.map