@anuma/sdk 2.3.1 → 2.4.1
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/dist/expo/{chunk-SF5AYTXH.mjs → chunk-UOUJUZM4.mjs} +229 -35
- package/dist/expo/index.cjs +310 -44
- package/dist/expo/index.d.mts +212 -10
- package/dist/expo/index.d.ts +212 -10
- package/dist/expo/index.mjs +78 -9
- package/dist/expo/{recall-PCKDVF3U.mjs → recall-HI7VO3VM.mjs} +1 -1
- package/dist/react/{chunk-JUDJVX66.mjs → chunk-IYDQBFS2.mjs} +229 -35
- package/dist/react/index.cjs +306 -43
- package/dist/react/index.d.mts +219 -10
- package/dist/react/index.d.ts +219 -10
- package/dist/react/index.mjs +74 -8
- package/dist/react/{recall-DSJSBDR4.mjs → recall-G3CS444F.mjs} +1 -1
- package/dist/server/{chunk-3AWYZRTS.mjs → chunk-3MLG7SUH.mjs} +229 -35
- package/dist/server/index.cjs +299 -42
- package/dist/server/index.d.mts +219 -10
- package/dist/server/index.d.ts +219 -10
- package/dist/server/index.mjs +67 -7
- package/dist/server/{recall-EWMI64SA.mjs → recall-MJHGXMHZ.mjs} +1 -1
- package/package.json +1 -1
package/dist/expo/index.mjs
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
DEFAULT_MIN_CONTENT_LENGTH,
|
|
7
7
|
DEFAULT_VAULT_CACHE_SIZE,
|
|
8
8
|
ENTITY_KINDS,
|
|
9
|
+
LRUCache,
|
|
10
|
+
RerankerUnavailableError,
|
|
9
11
|
chunkAndEmbedAllMessages,
|
|
10
12
|
chunkAndEmbedMessage,
|
|
11
13
|
chunkText,
|
|
@@ -58,6 +60,7 @@ import {
|
|
|
58
60
|
getVaultMemoryOp,
|
|
59
61
|
hasEncryptionKey,
|
|
60
62
|
isEncrypted,
|
|
63
|
+
isRerankerAvailable,
|
|
61
64
|
linkMemoryEntitiesOp,
|
|
62
65
|
makeSyntheticStoredConversation,
|
|
63
66
|
makeSyntheticStoredMessage,
|
|
@@ -83,7 +86,7 @@ import {
|
|
|
83
86
|
upsertMessageOp,
|
|
84
87
|
useEncryption,
|
|
85
88
|
vaultMemoryToStored
|
|
86
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-UOUJUZM4.mjs";
|
|
87
90
|
import {
|
|
88
91
|
PII_PATTERNS,
|
|
89
92
|
PiiRedactor,
|
|
@@ -6384,6 +6387,23 @@ function parseLocalCalendarDay(year, month, day) {
|
|
|
6384
6387
|
}
|
|
6385
6388
|
|
|
6386
6389
|
// src/lib/memory/autoExtractWorker.ts
|
|
6390
|
+
function createPlatformCursorStore(storage, keyPrefix = "anuma:mem:xcursor:") {
|
|
6391
|
+
return {
|
|
6392
|
+
get(conversationId) {
|
|
6393
|
+
try {
|
|
6394
|
+
return storage.getItem(keyPrefix + conversationId) ?? void 0;
|
|
6395
|
+
} catch {
|
|
6396
|
+
return void 0;
|
|
6397
|
+
}
|
|
6398
|
+
},
|
|
6399
|
+
set(conversationId, messageId) {
|
|
6400
|
+
try {
|
|
6401
|
+
storage.setItem(keyPrefix + conversationId, messageId);
|
|
6402
|
+
} catch {
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
};
|
|
6406
|
+
}
|
|
6387
6407
|
var DEFAULT_WINDOW_SIZE = 6;
|
|
6388
6408
|
var DEFAULT_MAX_WINDOW_SIZE = 20;
|
|
6389
6409
|
var CONTEXT_OVERLAP = 2;
|
|
@@ -6403,12 +6423,24 @@ function createAutoExtractor(options) {
|
|
|
6403
6423
|
let inflight = 0;
|
|
6404
6424
|
let disposed = false;
|
|
6405
6425
|
const conversations = /* @__PURE__ */ new Map();
|
|
6426
|
+
const cursorStore = options.cursorStore;
|
|
6427
|
+
const hydrate = (state, conversationId) => {
|
|
6428
|
+
if (state.hydrated) return;
|
|
6429
|
+
state.hydrated = true;
|
|
6430
|
+
if (!cursorStore || conversationId === void 0 || state.watermark !== void 0) return;
|
|
6431
|
+
try {
|
|
6432
|
+
const persisted = cursorStore.get(conversationId);
|
|
6433
|
+
if (persisted) state.watermark = persisted;
|
|
6434
|
+
} catch {
|
|
6435
|
+
}
|
|
6436
|
+
};
|
|
6406
6437
|
const stateFor = (conversationId) => {
|
|
6407
6438
|
let state = conversations.get(conversationId);
|
|
6408
6439
|
if (!state) {
|
|
6409
6440
|
if (conversations.size >= maxTrackedConversations) evictOldestIdle(conversationId);
|
|
6410
6441
|
state = {};
|
|
6411
6442
|
conversations.set(conversationId, state);
|
|
6443
|
+
hydrate(state, conversationId);
|
|
6412
6444
|
}
|
|
6413
6445
|
return state;
|
|
6414
6446
|
};
|
|
@@ -6421,10 +6453,12 @@ function createAutoExtractor(options) {
|
|
|
6421
6453
|
}
|
|
6422
6454
|
};
|
|
6423
6455
|
function computeWindow(messages, conversationId) {
|
|
6424
|
-
const lastId =
|
|
6456
|
+
const lastId = stateFor(conversationId).watermark;
|
|
6425
6457
|
const idx = lastId === void 0 ? -1 : messages.findIndex((m) => m.id === lastId);
|
|
6426
|
-
if (idx === -1)
|
|
6427
|
-
|
|
6458
|
+
if (idx === -1) {
|
|
6459
|
+
return { window: messages.slice(-windowSize), contiguous: messages.length <= windowSize };
|
|
6460
|
+
}
|
|
6461
|
+
if (idx >= messages.length - 1) return { window: [], contiguous: true };
|
|
6428
6462
|
const start = Math.max(0, idx + 1 - CONTEXT_OVERLAP);
|
|
6429
6463
|
let window = messages.slice(start);
|
|
6430
6464
|
if (window.length > maxWindowSize) {
|
|
@@ -6433,8 +6467,21 @@ function createAutoExtractor(options) {
|
|
|
6433
6467
|
);
|
|
6434
6468
|
window = window.slice(0, maxWindowSize);
|
|
6435
6469
|
}
|
|
6436
|
-
return window;
|
|
6470
|
+
return { window, contiguous: true };
|
|
6437
6471
|
}
|
|
6472
|
+
const persistCursor = (conversationId, messages, advancedToId, contiguous) => {
|
|
6473
|
+
if (!cursorStore || conversationId === void 0 || !contiguous) return;
|
|
6474
|
+
try {
|
|
6475
|
+
const stored = cursorStore.get(conversationId);
|
|
6476
|
+
if (stored && stored !== advancedToId) {
|
|
6477
|
+
const storedIdx = messages.findIndex((m) => m.id === stored);
|
|
6478
|
+
const newIdx = messages.findIndex((m) => m.id === advancedToId);
|
|
6479
|
+
if (storedIdx !== -1 && newIdx !== -1 && storedIdx >= newIdx) return;
|
|
6480
|
+
}
|
|
6481
|
+
cursorStore.set(conversationId, advancedToId);
|
|
6482
|
+
} catch {
|
|
6483
|
+
}
|
|
6484
|
+
};
|
|
6438
6485
|
const consolidateBaseUrl = options.consolidate?.baseUrl ?? options.extract.baseUrl;
|
|
6439
6486
|
const consolidateOptions = options.consolidate ? {
|
|
6440
6487
|
...options.extract.apiKey !== void 0 && { apiKey: options.extract.apiKey },
|
|
@@ -6480,7 +6527,7 @@ function createAutoExtractor(options) {
|
|
|
6480
6527
|
return dispatch(messages, conversationId);
|
|
6481
6528
|
}
|
|
6482
6529
|
function dispatch(messages, conversationId) {
|
|
6483
|
-
const window = computeWindow(messages, conversationId);
|
|
6530
|
+
const { window, contiguous } = computeWindow(messages, conversationId);
|
|
6484
6531
|
if (window.length === 0) {
|
|
6485
6532
|
options.onSkipped?.({ reason: "no-new-content", conversationId });
|
|
6486
6533
|
drainPending();
|
|
@@ -6505,7 +6552,9 @@ function createAutoExtractor(options) {
|
|
|
6505
6552
|
}
|
|
6506
6553
|
}
|
|
6507
6554
|
);
|
|
6508
|
-
|
|
6555
|
+
const advancedTo = window[window.length - 1].id;
|
|
6556
|
+
stateFor(conversationId).watermark = advancedTo;
|
|
6557
|
+
persistCursor(conversationId, messages, advancedTo, contiguous);
|
|
6509
6558
|
for (let i = 0; i < results.length; i++) {
|
|
6510
6559
|
if (results[i].action === "suppressed") continue;
|
|
6511
6560
|
options.onMemoryExtracted?.({
|
|
@@ -6552,6 +6601,12 @@ function createAutoExtractor(options) {
|
|
|
6552
6601
|
};
|
|
6553
6602
|
}
|
|
6554
6603
|
|
|
6604
|
+
// src/lib/memory/chunkVectorCache.ts
|
|
6605
|
+
var DEFAULT_CHUNK_CACHE_SIZE = 5e3;
|
|
6606
|
+
function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
|
|
6607
|
+
return new LRUCache(maxSize);
|
|
6608
|
+
}
|
|
6609
|
+
|
|
6555
6610
|
// src/lib/memory/recallTool.ts
|
|
6556
6611
|
var RECALL_TOOL_NAME = "recall_memory";
|
|
6557
6612
|
var RECALL_MAX_LIMIT = 50;
|
|
@@ -8163,6 +8218,13 @@ function useChatStorage(options) {
|
|
|
8163
8218
|
[vaultCtx]
|
|
8164
8219
|
);
|
|
8165
8220
|
const vaultEmbeddingCacheRef = useRef4(createVaultEmbeddingCache());
|
|
8221
|
+
const chunkVectorCacheRef = useRef4(createChunkVectorCache());
|
|
8222
|
+
useEffect4(() => {
|
|
8223
|
+
return onClearAllEncryptionState(() => {
|
|
8224
|
+
vaultEmbeddingCacheRef.current.clear();
|
|
8225
|
+
chunkVectorCacheRef.current.clear();
|
|
8226
|
+
});
|
|
8227
|
+
}, []);
|
|
8166
8228
|
const createRecallTool2 = useCallback4(
|
|
8167
8229
|
(toolOptions, callbacks) => {
|
|
8168
8230
|
if (!getToken) {
|
|
@@ -8179,7 +8241,8 @@ function useChatStorage(options) {
|
|
|
8179
8241
|
model: embeddingModel,
|
|
8180
8242
|
maskInput: maskEmbeddingInput
|
|
8181
8243
|
},
|
|
8182
|
-
vaultCache: vaultEmbeddingCacheRef.current
|
|
8244
|
+
vaultCache: vaultEmbeddingCacheRef.current,
|
|
8245
|
+
chunkCache: chunkVectorCacheRef.current
|
|
8183
8246
|
// entityCtx is intentionally omitted on Expo for now — the
|
|
8184
8247
|
// W5 graph lane is a no-op without it (recall falls through
|
|
8185
8248
|
// to fact + chunk lanes). Wire it up when the Expo client
|
|
@@ -8221,7 +8284,8 @@ function useChatStorage(options) {
|
|
|
8221
8284
|
model: embeddingModel,
|
|
8222
8285
|
maskInput: maskEmbeddingInput
|
|
8223
8286
|
},
|
|
8224
|
-
vaultCache: vaultEmbeddingCacheRef.current
|
|
8287
|
+
vaultCache: vaultEmbeddingCacheRef.current,
|
|
8288
|
+
chunkCache: chunkVectorCacheRef.current
|
|
8225
8289
|
},
|
|
8226
8290
|
resolvedOptions
|
|
8227
8291
|
);
|
|
@@ -11541,6 +11605,7 @@ export {
|
|
|
11541
11605
|
Message as ChatMessage,
|
|
11542
11606
|
ConversationMemory as ConversationMemoryModel,
|
|
11543
11607
|
DEFAULT_CACHE_EXPIRATION_MS,
|
|
11608
|
+
DEFAULT_CHUNK_CACHE_SIZE,
|
|
11544
11609
|
DEFAULT_CHUNK_OVERLAP,
|
|
11545
11610
|
DEFAULT_CHUNK_SIZE,
|
|
11546
11611
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
@@ -11554,6 +11619,7 @@ export {
|
|
|
11554
11619
|
QueueManager,
|
|
11555
11620
|
RECALL_MAX_LIMIT,
|
|
11556
11621
|
RECALL_TOOL_NAME,
|
|
11622
|
+
RerankerUnavailableError,
|
|
11557
11623
|
SDK_SCHEMA_VERSION,
|
|
11558
11624
|
STREAM_RESUMABLE_HEADER,
|
|
11559
11625
|
VaultFolder as StoredVaultFolderModel,
|
|
@@ -11586,11 +11652,13 @@ export {
|
|
|
11586
11652
|
conversationMemoryToStored,
|
|
11587
11653
|
cosineInt8,
|
|
11588
11654
|
createAutoExtractor,
|
|
11655
|
+
createChunkVectorCache,
|
|
11589
11656
|
createCryptoPricePreProcessor,
|
|
11590
11657
|
createMemoryEngineTool,
|
|
11591
11658
|
createMemoryVaultSearchTool,
|
|
11592
11659
|
createMemoryVaultTool,
|
|
11593
11660
|
createNotionTools,
|
|
11661
|
+
createPlatformCursorStore,
|
|
11594
11662
|
createRecallTool,
|
|
11595
11663
|
createStockPricePreProcessor,
|
|
11596
11664
|
createStreamingDeAnonymizer,
|
|
@@ -11634,6 +11702,7 @@ export {
|
|
|
11634
11702
|
getVaultMemoryOp,
|
|
11635
11703
|
hasEncryptionKey,
|
|
11636
11704
|
isPiiRedactor,
|
|
11705
|
+
isRerankerAvailable,
|
|
11637
11706
|
moveMemoriesToFolderOp,
|
|
11638
11707
|
noopLogger,
|
|
11639
11708
|
onKeyAvailable,
|