UNPKG

@continue-reasoning/mini-agent

Version:

A platform-agnostic AI agent framework for building autonomous AI agents with tool execution capabilities

64 lines 2.2 kB
/** * @fileoverview Utility functions for the AI Agent framework * * This module provides utility functions shared across different implementations, * including type conversions and common transformations needed for different * AI provider APIs. */ /** * Convert Type enum values (OBJECT, NUMBER, STRING) to lowercase for API compatibility * * Different AI providers expect different casing for type values: * - Gemini API expects lowercase (object, number, string) * - OpenAI API expects lowercase (object, number, string) * - Our Type enum uses uppercase (OBJECT, NUMBER, STRING) * * This function recursively converts all type fields to lowercase while preserving * the rest of the object structure. * * @param obj - Object to convert type fields in * @returns Object with type fields converted to lowercase */ export declare function convertTypesToLowercase(obj: any): any; /** * Deep clone an object using JSON serialization * * This is a utility function for creating deep copies of configuration objects * to avoid mutations affecting the original objects. * * @param obj - Object to clone * @returns Deep cloned object */ export declare function deepClone<T>(obj: T): T; /** * Generate a unique ID with optional prefix * * @param prefix - Optional prefix for the ID * @returns Unique ID string */ export declare function generateId(prefix?: string): string; /** * Safe JSON parsing with fallback * * @param jsonString - JSON string to parse * @param fallback - Fallback value if parsing fails * @returns Parsed object or fallback value */ export declare function safeJsonParse<T>(jsonString: string, fallback: T): T; /** * Validate if a string is a valid JSON * * @param str - String to validate * @returns True if valid JSON, false otherwise */ export declare function isValidJson(str: string): boolean; /** * Truncate text to a maximum length with ellipsis * * @param text - Text to truncate * @param maxLength - Maximum length * @param ellipsis - Ellipsis string (default: '...') * @returns Truncated text */ export declare function truncateText(text: string, maxLength: number, ellipsis?: string): string; //# sourceMappingURL=utils.d.ts.map