Files
automaker/libs/utils/src/index.ts
Shirone aac59c2b3a feat(ui): enhance WebSocket event handling and polling logic
- Introduced a new `useEventRecency` hook to track the recency of WebSocket events, allowing for conditional polling based on event activity.
- Updated `AgentInfoPanel` to utilize the new hook, adjusting polling intervals based on WebSocket activity.
- Implemented debounced invalidation for auto mode events to optimize query updates during rapid event streams.
- Added utility functions for managing event recency checks in various query hooks, improving overall responsiveness and reducing unnecessary polling.
- Introduced debounce and throttle utilities for better control over function execution rates.

This enhancement improves the application's performance by reducing polling when real-time updates are available, ensuring a more efficient use of resources.
2026-01-21 14:57:26 +01:00

117 lines
2.3 KiB
TypeScript

/**
* @automaker/utils
* Shared utility functions for AutoMaker
*/
// Error handling
export {
isAbortError,
isCancellationError,
isAuthenticationError,
isRateLimitError,
isQuotaExhaustedError,
extractRetryAfter,
classifyError,
getUserFriendlyErrorMessage,
getErrorMessage,
} from './error-handler.js';
// Conversation utilities
export {
extractTextFromContent,
normalizeContentBlocks,
formatHistoryAsText,
convertHistoryToMessages,
} from './conversation-utils.js';
// Image handling
export {
getMimeTypeForImage,
readImageAsBase64,
convertImagesToContentBlocks,
formatImagePathsForPrompt,
} from './image-handler.js';
// Prompt building
export {
buildPromptWithImages,
type PromptContent,
type PromptWithImages,
} from './prompt-builder.js';
// Logger
export {
createLogger,
getLogLevel,
setLogLevel,
setColorsEnabled,
setTimestampsEnabled,
LogLevel,
type Logger,
} from './logger.js';
// File system utilities
export { mkdirSafe, existsSafe } from './fs-utils.js';
// Atomic file operations
export {
atomicWriteJson,
readJsonFile,
updateJsonAtomically,
readJsonWithRecovery,
rotateBackups,
logRecoveryWarning,
DEFAULT_BACKUP_COUNT,
type AtomicWriteOptions,
type ReadJsonRecoveryResult,
type ReadJsonRecoveryOptions,
} from './atomic-writer.js';
// Path utilities
export { normalizePath, pathsEqual } from './path-utils.js';
// Context file loading
export {
loadContextFiles,
getContextFilesSummary,
type ContextMetadata,
type ContextFileInfo,
type ContextFilesResult,
type ContextFsModule,
type LoadContextFilesOptions,
type MemoryFileInfo,
type TaskContext,
} from './context-loader.js';
// Memory loading
export {
loadRelevantMemory,
initializeMemoryFolder,
appendLearning,
recordMemoryUsage,
getMemoryDir,
parseFrontmatter,
serializeFrontmatter,
extractTerms,
calculateUsageScore,
countMatches,
incrementUsageStat,
formatLearning,
type MemoryFsModule,
type MemoryMetadata,
type MemoryFile,
type MemoryLoadResult,
type UsageStats,
type LearningEntry,
type SimpleMemoryFile,
} from './memory-loader.js';
// Debounce and throttle utilities
export {
debounce,
throttle,
type DebounceOptions,
type ThrottleOptions,
type DebouncedFunction,
} from './debounce.js';