@peopl-health/nexus 4.4.2 → 4.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +17 -0
- package/lib/index.js +2 -0
- package/lib/utils/MapCache.js +3 -3
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -445,6 +445,23 @@ declare module '@peopl-health/nexus' {
|
|
|
445
445
|
handlePendingFunctionCalls(assistant: any, conversationMessages: any[], toolMetadata?: any): Promise<{ outputs: any[]; toolsExecuted: any[] }>;
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
export interface MapCacheOptions {
|
|
449
|
+
maxSize?: number;
|
|
450
|
+
ttl?: number | null;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export class MapCache<V = any> {
|
|
454
|
+
constructor(options?: MapCacheOptions);
|
|
455
|
+
get(key: any): V | undefined;
|
|
456
|
+
getEntry(key: any): { value: V; timestamp: number } | null;
|
|
457
|
+
set(key: any, value: V): void;
|
|
458
|
+
has(key: any): boolean;
|
|
459
|
+
delete(key: any): void;
|
|
460
|
+
clear(): void;
|
|
461
|
+
readonly size: number;
|
|
462
|
+
entries(): Array<[string, V]>;
|
|
463
|
+
}
|
|
464
|
+
|
|
448
465
|
export interface SessionEndResult {
|
|
449
466
|
summary: any | null;
|
|
450
467
|
memoriesCreated: number;
|
package/lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@ const { EvalProvider } = require('./eval/EvalProvider');
|
|
|
21
21
|
const { registerTool, hasTool, getToolSchemas, clearRegistry } = require('./services/toolRegistryService');
|
|
22
22
|
const { DefaultMemoryManager } = require('./memory/DefaultMemoryManager');
|
|
23
23
|
const { EnhancedMemoryManager } = require('./memory/EnhancedMemoryManager');
|
|
24
|
+
const MapCache = require('./utils/MapCache');
|
|
24
25
|
|
|
25
26
|
class Nexus {
|
|
26
27
|
constructor(config = {}) {
|
|
@@ -227,4 +228,5 @@ module.exports = {
|
|
|
227
228
|
clearRegistry,
|
|
228
229
|
DefaultMemoryManager,
|
|
229
230
|
EnhancedMemoryManager,
|
|
231
|
+
MapCache,
|
|
230
232
|
};
|
package/lib/utils/MapCache.js
CHANGED
|
@@ -8,17 +8,17 @@ class MapCache {
|
|
|
8
8
|
get(key) {
|
|
9
9
|
const k = String(key);
|
|
10
10
|
const entry = this._cache.get(k);
|
|
11
|
-
if (!entry) return
|
|
11
|
+
if (!entry) return undefined;
|
|
12
12
|
if (this._ttl && (Date.now() - entry.timestamp >= this._ttl)) {
|
|
13
13
|
this._cache.delete(k);
|
|
14
|
-
return
|
|
14
|
+
return undefined;
|
|
15
15
|
}
|
|
16
16
|
return entry.value;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
getEntry(key) {
|
|
20
20
|
const k = String(key);
|
|
21
|
-
return this._cache.get(k) ||
|
|
21
|
+
return this._cache.get(k) || undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
set(key, value) {
|