UNPKG

erosolar-cli

Version:

Unified AI agent framework for the command line - Multi-provider support with schema-driven tools, code intelligence, and transparent reasoning

121 lines 4.33 kB
/** * Comprehensive test utilities for tool validation and AI flow testing * Provides type-safe testing patterns for erosolar-cli software engineering */ import type { ToolCallRequest, ToolResponse, JSONSchemaObject, Result, ToolSuccessResponse, ToolErrorResponse, ToolWarningResponse } from './types.js'; import { validateToolPreconditions, validateAIFlowPatterns } from './toolPreconditions.js'; /** * Test utilities for tool validation and AI flow testing */ export declare namespace ToolTestUtils { /** * Creates a mock tool call for testing */ function createMockToolCall(name: string, args?: Record<string, unknown>): ToolCallRequest; /** * Creates a mock successful tool response */ function createMockSuccessResponse(content: string, metadata?: ToolSuccessResponse['metadata']): ToolSuccessResponse; /** * Creates a mock error tool response */ function createMockErrorResponse(code: string, message: string, recoverable?: boolean): ToolErrorResponse; /** * Creates a mock warning tool response */ function createMockWarningResponse(content: string, warnings: ToolWarningResponse['warnings']): ToolWarningResponse; /** * Validates tool arguments against schema with detailed error reporting */ function validateToolArgs(toolName: string, schema: JSONSchemaObject | undefined, args: Record<string, unknown>): Result<void, string[]>; /** * Tests AI flow patterns with tool history simulation */ function testAIFlowPatterns(toolName: string, args: Record<string, unknown>, toolHistory: Array<{ toolName: string; args: Record<string, unknown>; timestamp: number; }>): { preflightWarnings: ReturnType<typeof validateToolPreconditions>; aiFlowWarnings: ReturnType<typeof validateAIFlowPatterns>; }; /** * Type-safe assertion for tool responses */ function assertToolSuccess(response: ToolResponse): asserts response is ToolSuccessResponse; /** * Type-safe assertion for tool errors */ function assertToolError(response: ToolResponse): asserts response is ToolErrorResponse; /** * Type-safe assertion for tool warnings */ function assertToolWarning(response: ToolResponse): asserts response is ToolWarningResponse; /** * Creates a test suite for tool validation */ function createToolTestSuite(toolName: string, schema: JSONSchemaObject | undefined): { /** * Test valid arguments */ testValidArgs(args: Record<string, unknown>): void; /** * Test invalid arguments */ testInvalidArgs(args: Record<string, unknown>, expectedErrors: string[]): void; /** * Test required arguments */ testRequiredArgs(requiredArgs: string[]): void; }; /** * Performance testing utilities */ namespace Performance { /** * Measures tool execution time */ function measureExecutionTime<T>(fn: () => Promise<T> | T): Promise<{ result: T; executionTime: number; }>; /** * Runs performance benchmark */ function benchmark(fn: () => Promise<unknown> | unknown, iterations?: number): Promise<{ averageTime: number; minTime: number; maxTime: number; totalTime: number; }>; } /** * AI flow testing utilities */ namespace AIFlow { /** * Simulates a complete AI flow with tool history */ function simulateAIFlow(flow: Array<{ toolName: string; args: Record<string, unknown>; }>): Array<{ toolName: string; args: Record<string, unknown>; warnings: ReturnType<typeof validateAIFlowPatterns>; }>; /** * Tests for common AI flow anti-patterns */ function detectAntiPatterns(flow: Array<{ toolName: string; args: Record<string, unknown>; }>): { sequentialReads: boolean; editWithoutRead: boolean; multipleValidations: boolean; inefficientGitOps: boolean; }; } } //# sourceMappingURL=testUtils.d.ts.map