(toolName: string, args: any, result: string)
| 53 | } |
| 54 | |
| 55 | set(toolName: string, args: any, result: string): void { |
| 56 | if (typeof result !== 'string') return; |
| 57 | const size = result.length; |
| 58 | if (size > this.maxBytesPerEntry) return; |
| 59 | if (this.totalBytes + size > this.maxTotalBytes) this.evictOldest(); |
| 60 | if (this.cache.size >= this.maxEntries) this.evictOldest(); |
| 61 | const key = this.keyFor(toolName, args); |
| 62 | this.cache.set(key, { result, size, hits: 0 }); |
| 63 | this.totalBytes += size; |
| 64 | } |
| 65 | |
| 66 | private evictOldest(): void { |
| 67 | const first = this.cache.keys().next(); |
no test coverage detected