/** * Tool Response Helpers * Functions for modifying tool responses with pre/post content */ import type { PortFailureInfo, PendingStartupFailureInfo } from './server-manager.js'; import type { Connection } from './connection-manager.js'; /** * Tool response content item */ export interface ContentItem { type: string; text?: string; [key: string]: unknown; } /** * Click action metadata */ export interface ClickActionMeta { selector: string; preClickUrl: string; postClickUrl: string; navigationOccurred: boolean; hasClickHandler: boolean; domChanges: { mutationCount: number; added: number; removed: number; shown: number; hidden: number; } | null; } /** * Type action metadata */ export interface TypeActionMeta { selector: string; text: string; actualValue: string; } /** * Navigate action metadata */ export interface NavigateActionMeta { url: string; title: string; action: string; } /** * Console tool metadata */ export interface ConsoleToolMeta { totalCount: number; matchCount?: number; errorCount?: number; warnCount?: number; /** Number of messages that were truncated */ truncatedCount?: number; /** Total estimated tokens for all full messages */ totalTokens?: number; } /** * Network tool metadata */ export interface NetworkToolMeta { totalCount: number; matchCount?: number; } /** * Root metadata structure for tool responses * This provides structured data for programmatic use (validation, replay) * while keeping text content free to evolve for human/LLM display */ export interface ToolResponseMeta { tool: string; action?: string; timestamp: number; click?: ClickActionMeta; type?: TypeActionMeta; navigate?: NavigateActionMeta; console?: ConsoleToolMeta; network?: NetworkToolMeta; } /** * Tool response structure */ export interface ToolResponse { content: ContentItem[]; isError?: boolean; /** Structured metadata for programmatic use (validation, replay). Decoupled from text output. */ _meta?: ToolResponseMeta; } /** * Blocking response - prevents tool execution */ export interface BlockingResponse { blocked: true; response: ToolResponse; } /** * Non-blocking response - allows tool execution with optional modifications */ export interface NonBlockingResponse { blocked: false; prefix: string; markAsError: boolean; } export type PreExecutionResult = BlockingResponse | NonBlockingResponse; /** * Check for port failures and determine pre-execution behavior */ export declare function checkPortFailures(failedPorts: PortFailureInfo[], toolName: string): PreExecutionResult; /** * Check for blocking bugs from recordings * Only allows the 'acknowledge' action in the issues tool */ export declare function checkBugBlocking(toolName: string, toolArgs?: Record): Promise; /** * Information about a paused breakpoint */ export interface BreakpointPauseInfo { reference: string; location?: { url: string; lineNumber: number; }; } /** * Check for breakpoint pauses and determine pre-execution behavior * Similar to checkPortFailures, but for breakpoint blocking */ export declare function checkBreakpointPause(connections: Connection[], toolName: string): PreExecutionResult; /** * Check for pending startup failures and determine pre-execution behavior * Blocks tools when servers have failed to start (timeout or died) and not acknowledged */ export declare function checkPendingStartups(failures: PendingStartupFailureInfo[], toolName: string): PreExecutionResult; /** * Prepend text to the first text content item in a response */ export declare function prependToResponse(response: ToolResponse, prefix: string): void; /** * Append text to the last text content item in a response */ export declare function appendToResponse(response: ToolResponse, suffix: string): void; /** * Status line item for post-response status */ export interface StatusLineItem { label: string; value: string; } /** * Build status lines suffix from items */ export declare function buildStatusSuffix(items: StatusLineItem[]): string; //# sourceMappingURL=tool-response.d.ts.map