/** * State tracker - tracks state changes during workflow execution. * * This module provides functionality to: * - Classify tools by their state role (reader, writer, both) * - Identify probe tools that can capture state * - Take state snapshots before/after workflow steps * - Detect state changes between snapshots * - Infer dependencies between workflow steps * * RELIABILITY: All probe tool calls have timeouts to prevent indefinite hangs. */ import type { MCPClient } from '../transport/mcp-client.js'; import type { MCPTool } from '../transport/types.js'; import type { LLMClient } from '../llm/client.js'; import type { ToolStateInfo, StateSnapshot, StateChange, StateDependency, WorkflowStateTracking, StateTrackingOptions, WorkflowStepResult } from './types.js'; /** * Timeout configuration for state tracking operations. */ export interface StateTrackerTimeoutConfig { /** Timeout for state snapshot operations in ms */ snapshotTimeout?: number; /** Timeout for individual probe tool calls in ms */ probeTimeout?: number; } /** * State tracker for workflow execution. */ export declare class StateTracker { private client; private tools; private options; private logger; private toolClassifications; private probeTools; private snapshotTimeout; private probeTimeout; constructor(client: MCPClient, tools: MCPTool[], _llm?: LLMClient, options?: StateTrackingOptions, timeoutConfig?: StateTrackerTimeoutConfig); /** * Classify all tools by their state role. */ private classifyTools; /** * Classify a single tool by analyzing its name and description. */ private classifyTool; /** * Infer state types from tool description. */ private inferStateTypes; /** * Get the classification for a specific tool. */ getToolInfo(toolName: string): ToolStateInfo | undefined; /** * Get all tool classifications. */ getAllToolInfo(): ToolStateInfo[]; /** * Get available probe tools. */ getProbeTools(): string[]; /** * Take a state snapshot using available probe tools. * * RELIABILITY: Each probe tool call has an individual timeout to prevent hangs. * The entire snapshot operation also has a total timeout. * * @param afterStepIndex - The step index this snapshot was taken after * @param snapshotTimeoutMs - Optional total timeout for the snapshot operation (overrides configured timeout) */ takeSnapshot(afterStepIndex: number, snapshotTimeoutMs?: number): Promise; /** * Extract content from a tool call result. */ private extractContent; /** * Generate a hash for state data. */ private hashState; /** * Compare two snapshots and identify changes. */ compareSnapshots(before: StateSnapshot, after: StateSnapshot, causedByStep: number): StateChange[]; /** * Infer dependencies between workflow steps based on state changes and tool roles. */ inferDependencies(stepResults: WorkflowStepResult[]): StateDependency[]; /** * Verify dependencies using state snapshots. */ verifyDependencies(dependencies: StateDependency[], _snapshots: StateSnapshot[], changes: StateChange[]): StateDependency[]; /** * Generate a summary of state tracking results. */ generateSummary(tracking: WorkflowStateTracking): Promise; } //# sourceMappingURL=state-tracker.d.ts.map