/** * Shared utilities for LLM commands. * Consolidates duplicate patterns from flows.ts, interactions.ts, annotate.ts, etc. */ import type { Command } from '@oclif/core'; /** * Safely extract error message from unknown error type. * Replaces the duplicated `error instanceof Error ? error.message : String(error)` pattern. */ export declare function getErrorMessage(error: unknown): string; /** * Calculate percentage with safety for division by zero. */ export declare function calculatePercentage(value: number, total: number, decimals?: number): number; /** * Create a lookup map from an array using a key function. */ export declare function createLookup(items: T[], keyFn: (item: T) => K): Map; /** * Create a multi-value lookup map (groupBy) from an array. */ export declare function groupBy(items: T[], keyFn: (item: T) => K): Map; /** * LLM request/response logging utilities. */ export interface LlmLogOptions { showRequests: boolean; showResponses: boolean; isJson: boolean; } /** * Display LLM request details if enabled. */ export declare function logLlmRequest(command: Command, methodName: string, systemPrompt: string, userPrompt: string, options: LlmLogOptions): void; /** * Display LLM response details if enabled. */ export declare function logLlmResponse(command: Command, methodName: string, response: string, options: LlmLogOptions): void; /** * Log a warning message (for both JSON and non-JSON modes). */ export declare function logWarning(command: Command, message: string, isJson: boolean): void; /** * Log an error message (for both JSON and non-JSON modes). */ export declare function logError(command: Command, message: string, hint: string | null, isJson: boolean): void; /** * Log a step header for non-JSON output. */ export declare function logStep(command: Command, step: number, title: string, isJson: boolean): void; /** * Log verbose progress message. */ export declare function logVerbose(command: Command, message: string, verbose: boolean, isJson: boolean): void; /** * Log a section header. */ export declare function logSection(command: Command, title: string, isJson: boolean): void; /** * Batch processing helper - processes items in batches with progress reporting. */ export interface BatchProcessOptions { items: T[]; batchSize: number; processBatch: (batch: T[], batchIndex: number) => Promise; onBatchComplete?: (results: R[], batchIndex: number, totalBatches: number) => void; onBatchError?: (error: unknown, batch: T[], batchIndex: number) => R[] | null; } export declare function processBatches(options: BatchProcessOptions): Promise; export interface CompleteWithLoggingOptions { model: string; systemPrompt: string; userPrompt: string; temperature?: number; maxTokens?: number; command: Command; isJson: boolean; iteration?: { current: number; max: number; }; } export declare function completeWithLogging(options: CompleteWithLoggingOptions): Promise; /** * Generate a unique slug from a name, handling duplicates. */ export declare function generateUniqueSlug(baseName: string, usedSlugs: Set): string; //# sourceMappingURL=llm-utils.d.ts.map