diff --git a/package.json b/package.json index 25fbf6e..fcb7209 100644 --- a/package.json +++ b/package.json @@ -20,17 +20,18 @@ "license": "MIT", "dependencies": { "@fastify/static": "^8.2.0", + "@inquirer/prompts": "^5.0.0", "@musistudio/llms": "^1.0.35", "dotenv": "^16.4.7", "find-process": "^2.0.0", "json5": "^2.2.3", + "lru-cache": "^11.2.2", "minimist": "^1.2.8", "openurl": "^1.1.1", "rotating-file-stream": "^3.2.7", "shell-quote": "^1.8.3", "tiktoken": "^1.0.21", - "uuid": "^11.1.0", - "@inquirer/prompts": "^5.0.0" + "uuid": "^11.1.0" }, "devDependencies": { "@types/node": "^24.0.15", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d34a372..b8bcfef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: json5: specifier: ^2.2.3 version: 2.2.3 + lru-cache: + specifier: ^11.2.2 + version: 11.2.2 minimist: specifier: ^1.2.8 version: 1.2.8 @@ -729,8 +732,8 @@ packages: resolution: {integrity: sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==} engines: {node: '>= 0.6.0'} - lru-cache@11.1.0: - resolution: {integrity: sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==} + lru-cache@11.2.2: + resolution: {integrity: sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==} engines: {node: 20 || >=22} merge2@1.4.1: @@ -1841,7 +1844,7 @@ snapshots: loglevel@1.9.2: {} - lru-cache@11.1.0: {} + lru-cache@11.2.2: {} merge2@1.4.1: {} @@ -1908,7 +1911,7 @@ snapshots: path-scurry@2.0.0: dependencies: - lru-cache: 11.1.0 + lru-cache: 11.2.2 minipass: 7.1.2 picomatch@2.3.1: {} diff --git a/src/agents/image.agent.ts b/src/agents/image.agent.ts index 52162dd..52d34e9 100644 --- a/src/agents/image.agent.ts +++ b/src/agents/image.agent.ts @@ -1,6 +1,6 @@ import {IAgent, ITool} from "./type"; import { createHash } from 'crypto'; -import { LRUCache } from 'lru-cache'; +import * as LRU from 'lru-cache'; interface ImageCacheEntry { source: any; @@ -8,12 +8,13 @@ interface ImageCacheEntry { } class ImageCache { - private cache: LRUCache; + private cache: any; constructor(maxSize = 100) { - this.cache = new LRUCache({ + const CacheClass: any = (LRU as any).LRUCache || (LRU as any); + this.cache = new CacheClass({ max: maxSize, - ttl: 5 * 60 * 1000, + ttl: 5 * 60 * 1000, // 5 minutes }); }