@anuma/sdk 2.7.0 → 3.0.0

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.
@@ -1308,8 +1308,13 @@ interface EmbeddingOptions {
1308
1308
  * are looked up in this map before calling the API, and new embeddings
1309
1309
  * are stored after generation. Useful when the same texts are embedded
1310
1310
  * repeatedly (e.g., across eval iterations or re-indexing runs).
1311
+ *
1312
+ * Values are stored as `Float32Array` (the embedding model's native
1313
+ * precision) rather than a float64 `number[]`, halving the resident RAM of
1314
+ * the cache with no precision loss. `generateEmbedding(s)` still return
1315
+ * `number[]` at the API boundary, so callers are unaffected.
1311
1316
  */
1312
- cache?: Map<string, number[]>;
1317
+ cache?: Map<string, Float32Array>;
1313
1318
  /** Called after each embedding API call with the token usage from the response. */
1314
1319
  onUsage?: (usage: {
1315
1320
  promptTokens: number;
@@ -3284,6 +3289,32 @@ interface GetMessagesPageOptions {
3284
3289
  */
3285
3290
  limit: number;
3286
3291
  }
3292
+ /** Options for keyset-paginated conversation-list reads ({@link getConversationsPageOp}). */
3293
+ interface GetConversationsPageOptions {
3294
+ /**
3295
+ * Upper-bound `created_at` cursor (epoch ms). Without
3296
+ * `boundaryExcludeUniqueIds` it is EXCLUSIVE: only conversations with
3297
+ * `createdAt < before` are returned. Omit to fetch the newest page.
3298
+ */
3299
+ before?: number;
3300
+ /**
3301
+ * uniqueIds of the rows the caller already holds AT the `before` boundary.
3302
+ * `created_at` is NOT unique (a bulk restore/import writes many rows with the
3303
+ * same timestamp) — with an exclusive cursor, an unseen row sharing the
3304
+ * boundary timestamp would be silently skipped by every page. When provided,
3305
+ * the boundary timestamp is fetched INCLUSIVELY and these known rows are
3306
+ * filtered out, so a boundary-timestamp row is returned exactly once. Mirrors
3307
+ * {@link GetMessagesPageOptions.boundaryExcludeUniqueIds}.
3308
+ */
3309
+ boundaryExcludeUniqueIds?: string[];
3310
+ /**
3311
+ * Maximum rows to return — the NEWEST `limit` rows of the matching range.
3312
+ * Defaults to 200. A non-positive or non-finite value yields an EMPTY page
3313
+ * (never an unbounded read — SQLite treats `LIMIT -1` as "no limit");
3314
+ * fractional values are floored.
3315
+ */
3316
+ limit?: number;
3317
+ }
3287
3318
  /**
3288
3319
  * Lightweight, mostly-undecrypted projection of a message row. Contains just
3289
3320
  * enough for consumers to build the conversation's branch tree (parent/child
@@ -4220,6 +4251,20 @@ interface StorageOperationsContext {
4220
4251
  * for `decryptField` is exactly zero.
4221
4252
  */
4222
4253
  declare function getConversationsLazyOp(ctx: StorageOperationsContext): Promise<LazyStoredConversation[]>;
4254
+ /**
4255
+ * Keyset-paginated, lazy (no-decrypt) variant of {@link getConversationsLazyOp}.
4256
+ *
4257
+ * Returns at most `limit` conversations (newest first by `created_at`), each
4258
+ * with its raw stored title under `encryptedTitle` — pair with
4259
+ * {@link decryptConversationTitle} to decrypt on render. Page through older
4260
+ * threads by passing the oldest loaded `createdAt` as `before` plus the
4261
+ * uniqueIds held at that boundary as `boundaryExcludeUniqueIds`.
4262
+ *
4263
+ * Decrypts nothing and builds no WatermelonDB Model (the never-evicted
4264
+ * RecordCache stays empty — web Pile-2). Sort order, soft-delete filtering,
4265
+ * and the encrypted-title projection all match `getConversationsLazyOp`.
4266
+ */
4267
+ declare function getConversationsPageOp(ctx: StorageOperationsContext, options?: GetConversationsPageOptions): Promise<LazyStoredConversation[]>;
4223
4268
  /**
4224
4269
  * Lazy variant of {@link getConversationsByProjectOp}.
4225
4270
  *
@@ -7401,4 +7446,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
7401
7446
  */
7402
7447
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
7403
7448
 
7404
- export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, supersedeVaultMemoryOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
7449
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, supersedeVaultMemoryOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
@@ -1308,8 +1308,13 @@ interface EmbeddingOptions {
1308
1308
  * are looked up in this map before calling the API, and new embeddings
1309
1309
  * are stored after generation. Useful when the same texts are embedded
1310
1310
  * repeatedly (e.g., across eval iterations or re-indexing runs).
1311
+ *
1312
+ * Values are stored as `Float32Array` (the embedding model's native
1313
+ * precision) rather than a float64 `number[]`, halving the resident RAM of
1314
+ * the cache with no precision loss. `generateEmbedding(s)` still return
1315
+ * `number[]` at the API boundary, so callers are unaffected.
1311
1316
  */
1312
- cache?: Map<string, number[]>;
1317
+ cache?: Map<string, Float32Array>;
1313
1318
  /** Called after each embedding API call with the token usage from the response. */
1314
1319
  onUsage?: (usage: {
1315
1320
  promptTokens: number;
@@ -3284,6 +3289,32 @@ interface GetMessagesPageOptions {
3284
3289
  */
3285
3290
  limit: number;
3286
3291
  }
3292
+ /** Options for keyset-paginated conversation-list reads ({@link getConversationsPageOp}). */
3293
+ interface GetConversationsPageOptions {
3294
+ /**
3295
+ * Upper-bound `created_at` cursor (epoch ms). Without
3296
+ * `boundaryExcludeUniqueIds` it is EXCLUSIVE: only conversations with
3297
+ * `createdAt < before` are returned. Omit to fetch the newest page.
3298
+ */
3299
+ before?: number;
3300
+ /**
3301
+ * uniqueIds of the rows the caller already holds AT the `before` boundary.
3302
+ * `created_at` is NOT unique (a bulk restore/import writes many rows with the
3303
+ * same timestamp) — with an exclusive cursor, an unseen row sharing the
3304
+ * boundary timestamp would be silently skipped by every page. When provided,
3305
+ * the boundary timestamp is fetched INCLUSIVELY and these known rows are
3306
+ * filtered out, so a boundary-timestamp row is returned exactly once. Mirrors
3307
+ * {@link GetMessagesPageOptions.boundaryExcludeUniqueIds}.
3308
+ */
3309
+ boundaryExcludeUniqueIds?: string[];
3310
+ /**
3311
+ * Maximum rows to return — the NEWEST `limit` rows of the matching range.
3312
+ * Defaults to 200. A non-positive or non-finite value yields an EMPTY page
3313
+ * (never an unbounded read — SQLite treats `LIMIT -1` as "no limit");
3314
+ * fractional values are floored.
3315
+ */
3316
+ limit?: number;
3317
+ }
3287
3318
  /**
3288
3319
  * Lightweight, mostly-undecrypted projection of a message row. Contains just
3289
3320
  * enough for consumers to build the conversation's branch tree (parent/child
@@ -4220,6 +4251,20 @@ interface StorageOperationsContext {
4220
4251
  * for `decryptField` is exactly zero.
4221
4252
  */
4222
4253
  declare function getConversationsLazyOp(ctx: StorageOperationsContext): Promise<LazyStoredConversation[]>;
4254
+ /**
4255
+ * Keyset-paginated, lazy (no-decrypt) variant of {@link getConversationsLazyOp}.
4256
+ *
4257
+ * Returns at most `limit` conversations (newest first by `created_at`), each
4258
+ * with its raw stored title under `encryptedTitle` — pair with
4259
+ * {@link decryptConversationTitle} to decrypt on render. Page through older
4260
+ * threads by passing the oldest loaded `createdAt` as `before` plus the
4261
+ * uniqueIds held at that boundary as `boundaryExcludeUniqueIds`.
4262
+ *
4263
+ * Decrypts nothing and builds no WatermelonDB Model (the never-evicted
4264
+ * RecordCache stays empty — web Pile-2). Sort order, soft-delete filtering,
4265
+ * and the encrypted-title projection all match `getConversationsLazyOp`.
4266
+ */
4267
+ declare function getConversationsPageOp(ctx: StorageOperationsContext, options?: GetConversationsPageOptions): Promise<LazyStoredConversation[]>;
4223
4268
  /**
4224
4269
  * Lazy variant of {@link getConversationsByProjectOp}.
4225
4270
  *
@@ -7401,4 +7446,4 @@ declare function refreshNotionAccessToken(params: NotionRefreshTokenParams): Pro
7401
7446
  */
7402
7447
  declare function createNotionTools(getAccessToken: () => string | null, requestNotionAccess: () => Promise<string>): ToolConfig[];
7403
7448
 
7404
- export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, supersedeVaultMemoryOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
7449
+ export { type AutoExtractMessage, type AutoExtractor, type Budget, type CachedChunkVectors, type CachedServerTools, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ChunkVectorCache, type ChunkingOptions, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMessageOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type Logger, LoggerProvider, type LoggerProviderProps, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MessageRedactionResult, type MessageSkeleton, NOTION_OAUTH_CONFIG, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, PII_PATTERNS, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PromptPreProcessor, type PromptPreProcessorContext, type QuantizedEmbedding, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, type VaultEmbeddingCache, type VaultFolderOperationsContext, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, addConversationMemoriesOp, buildNotionAuthUrl, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createNotionTools, createPlatformCursorStore, createRecallTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, deleteAllVaultMemoriesForUserOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, ensureDefaultFoldersOp, exchangeNotionCode, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, hasEncryptionKey, isPiiRedactor, isRerankerAvailable, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, preEmbedVaultMemories, quantizeEmbedding, queueManager, recall, reflect, refreshNotionAccessToken, registerNotionClient, requestEncryptionKey, resolvePiiRedactor, resumeStream, retain, sdkMigrations, sdkModelClasses, sdkSchema, searchVaultMemories, setLogger, shouldChunkMessage, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, supersedeVaultMemoryOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, xhrTransport };
@@ -51,6 +51,7 @@ import {
51
51
  getConversationsByProjectLazyOp,
52
52
  getConversationsLazyOp,
53
53
  getConversationsOp,
54
+ getConversationsPageOp,
54
55
  getImageModel,
55
56
  getMemoriesNeedingTopicExtractionOp,
56
57
  getMessageCountOp,
@@ -89,7 +90,7 @@ import {
89
90
  upsertMessageOp,
90
91
  useEncryption,
91
92
  vaultMemoryToStored
92
- } from "./chunk-TCRDSUC6.mjs";
93
+ } from "./chunk-IY7NNIYM.mjs";
93
94
  import {
94
95
  PII_PATTERNS,
95
96
  PiiRedactor,
@@ -11816,6 +11817,7 @@ export {
11816
11817
  getConversationMemoriesOp,
11817
11818
  getConversationsByProjectLazyOp,
11818
11819
  getConversationsLazyOp,
11820
+ getConversationsPageOp,
11819
11821
  getLogger,
11820
11822
  getMemoriesNeedingTopicExtractionOp,
11821
11823
  getServerTools,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-TCRDSUC6.mjs";
3
+ } from "./chunk-IY7NNIYM.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
package/dist/index.cjs CHANGED
@@ -2115,7 +2115,7 @@ async function generateEmbedding(text, options) {
2115
2115
  const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
2116
2116
  if (cache) {
2117
2117
  const cached = cache.get(text);
2118
- if (cached) return cached;
2118
+ if (cached) return Array.from(cached);
2119
2119
  }
2120
2120
  let headers;
2121
2121
  if (apiKey) {
@@ -2154,10 +2154,11 @@ async function generateEmbedding(text, options) {
2154
2154
  totalTokens: response.data.usage.total_tokens ?? 0
2155
2155
  });
2156
2156
  }
2157
+ const f32Embedding = Float32Array.from(embedding);
2157
2158
  if (cache) {
2158
- cache.set(text, embedding);
2159
+ cache.set(text, f32Embedding);
2159
2160
  }
2160
- return embedding;
2161
+ return Array.from(f32Embedding);
2161
2162
  }
2162
2163
  var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
2163
2164
  var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
@@ -2195,7 +2196,7 @@ async function generateEmbeddings(texts, options) {
2195
2196
  if (cache) {
2196
2197
  const cached = cache.get(texts[i]);
2197
2198
  if (cached) {
2198
- results[i] = cached;
2199
+ results[i] = Array.from(cached);
2199
2200
  continue;
2200
2201
  }
2201
2202
  }
@@ -2256,9 +2257,10 @@ async function generateEmbeddings(texts, options) {
2256
2257
  newEmbeddings = allEmbeddings.flat();
2257
2258
  }
2258
2259
  for (let i = 0; i < uncachedIndices.length; i++) {
2259
- results[uncachedIndices[i]] = newEmbeddings[i];
2260
+ const f32Embedding = Float32Array.from(newEmbeddings[i]);
2261
+ results[uncachedIndices[i]] = Array.from(f32Embedding);
2260
2262
  if (cache) {
2261
- cache.set(uncachedTexts[i], newEmbeddings[i]);
2263
+ cache.set(uncachedTexts[i], f32Embedding);
2262
2264
  }
2263
2265
  }
2264
2266
  return results;
package/dist/index.mjs CHANGED
@@ -1919,7 +1919,7 @@ async function generateEmbedding(text, options) {
1919
1919
  const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
1920
1920
  if (cache) {
1921
1921
  const cached = cache.get(text);
1922
- if (cached) return cached;
1922
+ if (cached) return Array.from(cached);
1923
1923
  }
1924
1924
  let headers;
1925
1925
  if (apiKey) {
@@ -1958,10 +1958,11 @@ async function generateEmbedding(text, options) {
1958
1958
  totalTokens: response.data.usage.total_tokens ?? 0
1959
1959
  });
1960
1960
  }
1961
+ const f32Embedding = Float32Array.from(embedding);
1961
1962
  if (cache) {
1962
- cache.set(text, embedding);
1963
+ cache.set(text, f32Embedding);
1963
1964
  }
1964
- return embedding;
1965
+ return Array.from(f32Embedding);
1965
1966
  }
1966
1967
  var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
1967
1968
  var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
@@ -1999,7 +2000,7 @@ async function generateEmbeddings(texts, options) {
1999
2000
  if (cache) {
2000
2001
  const cached = cache.get(texts[i]);
2001
2002
  if (cached) {
2002
- results[i] = cached;
2003
+ results[i] = Array.from(cached);
2003
2004
  continue;
2004
2005
  }
2005
2006
  }
@@ -2060,9 +2061,10 @@ async function generateEmbeddings(texts, options) {
2060
2061
  newEmbeddings = allEmbeddings.flat();
2061
2062
  }
2062
2063
  for (let i = 0; i < uncachedIndices.length; i++) {
2063
- results[uncachedIndices[i]] = newEmbeddings[i];
2064
+ const f32Embedding = Float32Array.from(newEmbeddings[i]);
2065
+ results[uncachedIndices[i]] = Array.from(f32Embedding);
2064
2066
  if (cache) {
2065
- cache.set(uncachedTexts[i], newEmbeddings[i]);
2067
+ cache.set(uncachedTexts[i], f32Embedding);
2066
2068
  }
2067
2069
  }
2068
2070
  return results;
@@ -1098,6 +1098,67 @@ async function messageToStored(message, walletAddress, signMessage, embeddedWall
1098
1098
  }
1099
1099
  return baseMessage;
1100
1100
  }
1101
+ function rawDate(value) {
1102
+ return new Date(typeof value === "number" ? value : 0);
1103
+ }
1104
+ function messageRawToStoredRaw(raw, projection) {
1105
+ const parseJsonField = (rawValue) => {
1106
+ if (!rawValue) return void 0;
1107
+ if (typeof rawValue === "string") {
1108
+ if (rawValue.startsWith("enc:")) return rawValue;
1109
+ try {
1110
+ return JSON.parse(rawValue);
1111
+ } catch {
1112
+ return void 0;
1113
+ }
1114
+ }
1115
+ return rawValue;
1116
+ };
1117
+ const skipEmbeddings = projection?.skipEmbeddings === true;
1118
+ const vectorRaw = skipEmbeddings ? null : raw.vector;
1119
+ const chunksRaw = skipEmbeddings ? null : raw.chunks;
1120
+ return {
1121
+ uniqueId: raw.id,
1122
+ messageId: raw.message_id,
1123
+ conversationId: raw.conversation_id ?? "",
1124
+ role: raw.role ?? "",
1125
+ content: raw.content ?? "",
1126
+ model: raw.model,
1127
+ imageModel: raw.image_model,
1128
+ files: parseJsonField(raw.files),
1129
+ fileIds: parseJsonField(raw.file_ids),
1130
+ createdAt: rawDate(raw.created_at),
1131
+ updatedAt: rawDate(raw.updated_at),
1132
+ vector: skipEmbeddings ? void 0 : parseJsonField(vectorRaw),
1133
+ embeddingModel: raw.embedding_model,
1134
+ chunks: skipEmbeddings ? void 0 : parseJsonField(chunksRaw),
1135
+ usage: parseJsonField(raw.usage),
1136
+ sources: parseJsonField(raw.sources),
1137
+ responseDuration: raw.response_duration,
1138
+ // `was_stopped` is an OPTIONAL boolean: an unset row sanitizes to null, and the Model path
1139
+ // (message.wasStopped) returns that null verbatim. Preserve it (don't collapse to false) so the
1140
+ // raw path is byte-identical. When set, coerce SQLite 0/1 and LokiJS true/false alike.
1141
+ wasStopped: raw.was_stopped === null || raw.was_stopped === void 0 ? raw.was_stopped : raw.was_stopped === true || raw.was_stopped === 1,
1142
+ error: raw.error,
1143
+ thoughtProcess: parseJsonField(raw.thought_process),
1144
+ thinking: raw.thinking,
1145
+ parentMessageId: raw.parent_message_id,
1146
+ feedback: raw.feedback || null,
1147
+ toolCallEvents: parseJsonField(raw.tool_call_events)
1148
+ };
1149
+ }
1150
+ async function messageRawToStored(raw, walletAddress, signMessage, embeddedWalletSigner, projection) {
1151
+ const baseMessage = messageRawToStoredRaw(raw, projection);
1152
+ if (walletAddress) {
1153
+ return await decryptMessageFields(
1154
+ baseMessage,
1155
+ walletAddress,
1156
+ signMessage,
1157
+ embeddedWalletSigner
1158
+ );
1159
+ }
1160
+ return baseMessage;
1161
+ }
1101
1162
  function conversationToStoredRaw(conversation) {
1102
1163
  return {
1103
1164
  uniqueId: conversation.id,
@@ -1122,6 +1183,33 @@ async function conversationToStored(conversation, walletAddress, signMessage, em
1122
1183
  }
1123
1184
  return baseConversation;
1124
1185
  }
1186
+ function conversationRawToStoredRaw(raw) {
1187
+ const pinnedAt = raw.pinned_at;
1188
+ return {
1189
+ uniqueId: raw.id,
1190
+ conversationId: raw.conversation_id ?? "",
1191
+ title: raw.title ?? "",
1192
+ projectId: raw.project_id,
1193
+ createdAt: rawDate(raw.created_at),
1194
+ updatedAt: rawDate(raw.updated_at),
1195
+ // SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
1196
+ isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
1197
+ // @date maps a non-number raw column (incl. an explicit unpin null) to null; a number → Date.
1198
+ pinnedAt: typeof pinnedAt === "number" ? new Date(pinnedAt) : null
1199
+ };
1200
+ }
1201
+ async function conversationRawToStored(raw, walletAddress, signMessage, embeddedWalletSigner) {
1202
+ const baseConversation = conversationRawToStoredRaw(raw);
1203
+ if (walletAddress) {
1204
+ return await decryptConversationFields(
1205
+ baseConversation,
1206
+ walletAddress,
1207
+ signMessage,
1208
+ embeddedWalletSigner
1209
+ );
1210
+ }
1211
+ return baseConversation;
1212
+ }
1125
1213
  async function createConversationOp(ctx, opts, defaultTitle = "New Conversation") {
1126
1214
  const convId = opts?.conversationId || generateConversationId();
1127
1215
  const title = opts?.title || defaultTitle;
@@ -1161,36 +1249,51 @@ async function getConversationOp(ctx, id) {
1161
1249
  ) : null;
1162
1250
  }
1163
1251
  async function getConversationsOp(ctx) {
1164
- const results = await ctx.conversationsCollection.query(Q.where("is_deleted", false), Q.sortBy("created_at", Q.desc)).fetch();
1252
+ const results = await ctx.conversationsCollection.query(Q.where("is_deleted", false), Q.sortBy("created_at", Q.desc)).unsafeFetchRaw();
1165
1253
  return Promise.all(
1166
1254
  results.map(
1167
- (conv) => conversationToStored(conv, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1255
+ (raw) => conversationRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1168
1256
  )
1169
1257
  );
1170
1258
  }
1171
- function conversationToLazyStored(conversation) {
1259
+ function conversationRawToLazyStored(raw) {
1260
+ const pinnedAt = raw.pinned_at;
1172
1261
  return {
1173
- uniqueId: conversation.id,
1174
- conversationId: conversation.conversationId,
1175
- encryptedTitle: conversation.title,
1176
- projectId: conversation.projectId,
1177
- createdAt: conversation.createdAt,
1178
- updatedAt: conversation.updatedAt,
1179
- isDeleted: conversation.isDeleted,
1180
- pinnedAt: conversation.pinnedAt
1262
+ uniqueId: raw.id,
1263
+ conversationId: raw.conversation_id ?? "",
1264
+ encryptedTitle: raw.title ?? "",
1265
+ projectId: raw.project_id,
1266
+ createdAt: rawDate(raw.created_at),
1267
+ updatedAt: rawDate(raw.updated_at),
1268
+ isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
1269
+ pinnedAt: typeof pinnedAt === "number" ? new Date(pinnedAt) : null
1181
1270
  };
1182
1271
  }
1183
1272
  async function getConversationsLazyOp(ctx) {
1184
- const results = await ctx.conversationsCollection.query(Q.where("is_deleted", false), Q.sortBy("created_at", Q.desc)).fetch();
1185
- return results.map(conversationToLazyStored);
1273
+ const results = await ctx.conversationsCollection.query(Q.where("is_deleted", false), Q.sortBy("created_at", Q.desc)).unsafeFetchRaw();
1274
+ return results.map(conversationRawToLazyStored);
1275
+ }
1276
+ async function getConversationsPageOp(ctx, options) {
1277
+ const limit = Math.floor(options?.limit ?? 200);
1278
+ if (!Number.isFinite(limit) || limit < 1) return [];
1279
+ const exclude = new Set(options?.boundaryExcludeUniqueIds ?? []);
1280
+ const clauses = [Q.where("is_deleted", false)];
1281
+ if (options?.before !== void 0) {
1282
+ clauses.push(
1283
+ exclude.size > 0 ? Q.where("created_at", Q.lte(options.before)) : Q.where("created_at", Q.lt(options.before))
1284
+ );
1285
+ }
1286
+ const fetched = await ctx.conversationsCollection.query(...clauses, Q.sortBy("created_at", Q.desc), Q.take(limit + exclude.size)).unsafeFetchRaw();
1287
+ const results = exclude.size > 0 ? fetched.filter((raw) => !exclude.has(raw.id)) : fetched;
1288
+ return results.slice(0, limit).map(conversationRawToLazyStored);
1186
1289
  }
1187
1290
  async function getConversationsByProjectLazyOp(ctx, projectId) {
1188
1291
  const results = await ctx.conversationsCollection.query(
1189
1292
  Q.where("project_id", projectId === null ? "" : projectId),
1190
1293
  Q.where("is_deleted", false),
1191
1294
  Q.sortBy("created_at", Q.desc)
1192
- ).fetch();
1193
- return results.map(conversationToLazyStored);
1295
+ ).unsafeFetchRaw();
1296
+ return results.map(conversationRawToLazyStored);
1194
1297
  }
1195
1298
  async function updateConversationTitleOp(ctx, id, title) {
1196
1299
  const results = await ctx.conversationsCollection.query(Q.where("conversation_id", id), Q.where("is_deleted", false)).fetch();
@@ -1252,18 +1355,18 @@ async function getConversationsByProjectOp(ctx, projectId) {
1252
1355
  Q.where("project_id", projectId === null ? "" : projectId),
1253
1356
  Q.where("is_deleted", false),
1254
1357
  Q.sortBy("created_at", Q.desc)
1255
- ).fetch();
1358
+ ).unsafeFetchRaw();
1256
1359
  return Promise.all(
1257
1360
  results.map(
1258
- (conv) => conversationToStored(conv, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1361
+ (raw) => conversationRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1259
1362
  )
1260
1363
  );
1261
1364
  }
1262
1365
  async function getMessagesOp(ctx, convId) {
1263
- const results = await ctx.messagesCollection.query(Q.where("conversation_id", convId), Q.sortBy("message_id", Q.asc)).fetch();
1366
+ const results = await ctx.messagesCollection.query(Q.where("conversation_id", convId), Q.sortBy("message_id", Q.asc)).unsafeFetchRaw();
1264
1367
  return Promise.all(
1265
1368
  results.map(
1266
- (msg) => messageToStored(msg, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1369
+ (raw) => messageRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
1267
1370
  )
1268
1371
  );
1269
1372
  }
@@ -1280,39 +1383,40 @@ async function getMessagesPageOp(ctx, convId, opts) {
1280
1383
  exclude.size > 0 ? Q.where("message_id", Q.lte(opts.beforeMessageId)) : Q.where("message_id", Q.lt(opts.beforeMessageId))
1281
1384
  );
1282
1385
  }
1283
- const fetched = await ctx.messagesCollection.query(...clauses, Q.sortBy("message_id", Q.desc), Q.take(limit + exclude.size)).fetch();
1284
- const results = (exclude.size > 0 ? fetched.filter((msg) => !exclude.has(msg.id)) : fetched).slice(0, limit);
1386
+ const fetched = await ctx.messagesCollection.query(...clauses, Q.sortBy("message_id", Q.desc), Q.take(limit + exclude.size)).unsafeFetchRaw();
1387
+ const results = (exclude.size > 0 ? fetched.filter((raw) => !exclude.has(raw.id)) : fetched).slice(0, limit);
1285
1388
  results.reverse();
1286
1389
  return Promise.all(
1287
1390
  results.map(
1288
- (msg) => messageToStored(msg, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner, {
1391
+ (raw) => messageRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner, {
1289
1392
  skipEmbeddings: true
1290
1393
  })
1291
1394
  )
1292
1395
  );
1293
1396
  }
1294
1397
  async function getMessageSkeletonsOp(ctx, convId) {
1295
- const results = await ctx.messagesCollection.query(Q.where("conversation_id", convId), Q.sortBy("message_id", Q.asc)).fetch();
1398
+ const results = await ctx.messagesCollection.query(Q.where("conversation_id", convId), Q.sortBy("message_id", Q.asc)).unsafeFetchRaw();
1296
1399
  const roleById = /* @__PURE__ */ new Map();
1297
- for (const msg of results) {
1298
- roleById.set(msg.id, msg.role);
1299
- }
1300
- const skeletons = results.map((msg) => ({
1301
- uniqueId: msg.id,
1302
- messageId: msg.messageId,
1303
- conversationId: String(msg._getRaw("conversation_id")),
1304
- role: msg.role,
1305
- createdAt: msg.createdAt,
1400
+ for (const raw of results) {
1401
+ roleById.set(raw.id, raw.role);
1402
+ }
1403
+ const skeletons = results.map((raw) => ({
1404
+ uniqueId: raw.id,
1405
+ messageId: raw.message_id,
1406
+ conversationId: raw.conversation_id ?? "",
1407
+ role: raw.role ?? "",
1408
+ createdAt: rawDate(raw.created_at),
1306
1409
  // WatermelonDB surfaces unset text columns as null at runtime — normalize
1307
1410
  // to undefined so `parentMessageId ?? undefined` keying works everywhere.
1308
- parentMessageId: msg.parentMessageId ?? void 0,
1309
- model: msg.model ?? void 0
1411
+ parentMessageId: raw.parent_message_id ?? void 0,
1412
+ model: raw.model ?? void 0
1310
1413
  }));
1311
1414
  const artifactIndices = [];
1312
1415
  for (let i = 0; i < results.length; i++) {
1313
- const msg = results[i];
1314
- if (msg.role !== "user" || !msg.parentMessageId) continue;
1315
- if (roleById.get(msg.parentMessageId) === "user") {
1416
+ const raw = results[i];
1417
+ const parentMessageId = raw.parent_message_id;
1418
+ if (raw.role !== "user" || !parentMessageId) continue;
1419
+ if (roleById.get(parentMessageId) === "user") {
1316
1420
  artifactIndices.push(i);
1317
1421
  }
1318
1422
  }
@@ -3817,7 +3921,7 @@ async function generateEmbedding(text, options) {
3817
3921
  const { baseUrl = BASE_URL, getToken, apiKey, model, cache } = options;
3818
3922
  if (cache) {
3819
3923
  const cached = cache.get(text);
3820
- if (cached) return cached;
3924
+ if (cached) return Array.from(cached);
3821
3925
  }
3822
3926
  let headers;
3823
3927
  if (apiKey) {
@@ -3856,10 +3960,11 @@ async function generateEmbedding(text, options) {
3856
3960
  totalTokens: response.data.usage.total_tokens ?? 0
3857
3961
  });
3858
3962
  }
3963
+ const f32Embedding = Float32Array.from(embedding);
3859
3964
  if (cache) {
3860
- cache.set(text, embedding);
3965
+ cache.set(text, f32Embedding);
3861
3966
  }
3862
- return embedding;
3967
+ return Array.from(f32Embedding);
3863
3968
  }
3864
3969
  var DEFAULT_EMBEDDING_BATCH_SIZE = 100;
3865
3970
  var DEFAULT_EMBEDDING_BATCH_CONCURRENCY = 3;
@@ -3897,7 +4002,7 @@ async function generateEmbeddings(texts, options) {
3897
4002
  if (cache) {
3898
4003
  const cached = cache.get(texts[i]);
3899
4004
  if (cached) {
3900
- results[i] = cached;
4005
+ results[i] = Array.from(cached);
3901
4006
  continue;
3902
4007
  }
3903
4008
  }
@@ -3958,9 +4063,10 @@ async function generateEmbeddings(texts, options) {
3958
4063
  newEmbeddings = allEmbeddings.flat();
3959
4064
  }
3960
4065
  for (let i = 0; i < uncachedIndices.length; i++) {
3961
- results[uncachedIndices[i]] = newEmbeddings[i];
4066
+ const f32Embedding = Float32Array.from(newEmbeddings[i]);
4067
+ results[uncachedIndices[i]] = Array.from(f32Embedding);
3962
4068
  if (cache) {
3963
- cache.set(uncachedTexts[i], newEmbeddings[i]);
4069
+ cache.set(uncachedTexts[i], f32Embedding);
3964
4070
  }
3965
4071
  }
3966
4072
  return results;
@@ -5384,7 +5490,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
5384
5490
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
5385
5491
  );
5386
5492
  }
5387
- const { recall: recall2 } = await import("./recall-PV7L3SN3.mjs");
5493
+ const { recall: recall2 } = await import("./recall-3BDCIEQF.mjs");
5388
5494
  const result = await recall2(
5389
5495
  query,
5390
5496
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -6068,6 +6174,7 @@ export {
6068
6174
  getConversationOp,
6069
6175
  getConversationsOp,
6070
6176
  getConversationsLazyOp,
6177
+ getConversationsPageOp,
6071
6178
  getConversationsByProjectLazyOp,
6072
6179
  updateConversationTitleOp,
6073
6180
  deleteConversationOp,