/** * @fileoverview TaskChatContextBuilder — constructs the `additionInfo` * block that gets prefixed onto every user message sent from the * task-detail chat panel. * * v2.5 REQ-3: every query the user types in the task detail page is * wrapped with a structured task context block so the LLM knows which * task it's helping with (id, title, status, priority, worktree, recent * operations). The block is rendered as plain-text markdown (cheap for * the LLM to parse) with a clear separator so the assistant can split * "context" from "user question" reliably. * * Long descriptions are truncated to `maxDescriptionChars` (default * 2000) with a hint pointing the user back to the full task detail * page; this prevents token blow-ups on verbose tasks while still * giving the LLM enough to reason about. * * SessionId is deterministic: `task-${taskId}`. The ChatProcessManager * uses this id verbatim so reloading the page (and coming back hours * later) lands the user on the same SQLite-backed session that * `roy-agent act` owns. */ export interface RecentOperation { id: number; sequence: number; milestoneType: string; title: string; description?: string; processDescription?: string; timestamp?: string; sessionShort?: string; } export interface TaskChatContextInput { taskId: number; title: string; /** Free-form description; may be very long — truncation handled internally. */ description?: string; status: string; priority: string; /** Optional git worktree path the task is running in. */ worktree?: string; /** Recent operations (newest first is the canonical order). */ recentOperations: RecentOperation[]; /** Override the truncation cap. Default 2000 chars. */ maxDescriptionChars?: number; } export interface TaskChatContextOptions { /** Override the truncation cap (chars). Default 2000. */ maxDescriptionChars?: number; } /** * Builds the `additionInfo` block that gets prepended to every user * message in the task-detail chat. Pure / synchronous — does not touch * the filesystem or network. */ export declare class TaskChatContextBuilder { static readonly DEFAULT_MAX_DESCRIPTION_CHARS = 2000; readonly taskId: number; readonly title: string; readonly description: string; readonly status: string; readonly priority: string; readonly worktree: string; readonly recentOperations: RecentOperation[]; readonly maxDescriptionChars: number; readonly truncated: boolean; readonly originalDescriptionLength: number; constructor(input: TaskChatContextInput); /** * Deterministic per-task session id. Same taskId → same id, always. * The id is what `roy-agent act -s ` keys off of; the SQLite * session survives reloads. */ static buildSessionId(taskId: number): string; /** * Render the additionInfo block as a plain-text markdown section * that the LLM can easily parse. Always ends with a clear "User * question follows" separator so the assistant can reliably split * context from query. */ buildAdditionInfo(): string; /** * Build the final message body that gets handed to `roy-agent act * -s `. Wraps the user's raw query with the additionInfo * block. */ wrapMessage(userMessage: string): string; /** * Convenience: the sessionId for this task. Equivalent to * `TaskChatContextBuilder.buildSessionId(taskId)`. */ sessionId(): string; } //# sourceMappingURL=task-chat-context-builder.d.ts.map