UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

64 lines 1.78 kB
/** * In-memory log storage for querying */ import { MAX_LOG_ENTRIES } from '../../../../constants.js'; import { aggregateLogEntries } from '../aggregation/aggregator.js'; import { executeQuery } from '../query/query-engine.js'; import { CircularBuffer } from './circular-buffer.js'; import { IndexManager } from './index-manager.js'; /** * In-memory log storage for querying (in production, this would connect to a log database) */ export class LogStorage { buffer; indexManager; constructor(maxEntries = MAX_LOG_ENTRIES) { this.buffer = new CircularBuffer(maxEntries); this.indexManager = new IndexManager(); } /** * Add a log entry - O(1) instead of O(n) */ addEntry(entry) { // Add to circular buffer and get removed entry if any const removed = this.buffer.add(entry); // Update indexes if (removed) { this.indexManager.updateIndexes(removed, false); } this.indexManager.updateIndexes(entry, true); } /** * Query log entries */ query(query) { const entries = this.buffer.getAll(); const totalCount = this.buffer.getCount(); return executeQuery(entries, query, totalCount); } /** * Aggregate log entries */ aggregate(options) { const entries = this.buffer.getAll(); return aggregateLogEntries(entries, options); } /** * Get entry count */ getEntryCount() { return this.buffer.getCount(); } /** * Clear all entries */ clear() { this.buffer.clear(); this.indexManager.clear(); } } /** * Global log storage instance */ export const globalLogStorage = new LogStorage(); //# sourceMappingURL=log-storage.js.map