@anuma/sdk 11.3.5 → 11.4.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.
- package/dist/expo/index.cjs +286 -7
- package/dist/expo/index.d.mts +67 -2
- package/dist/expo/index.d.ts +67 -2
- package/dist/expo/index.mjs +275 -7
- package/dist/index.cjs +281 -5
- package/dist/index.d.mts +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.mjs +270 -5
- package/dist/react/index.cjs +286 -18
- package/dist/react/index.d.mts +67 -2
- package/dist/react/index.d.ts +67 -2
- package/dist/react/index.mjs +275 -18
- package/package.json +1 -1
package/dist/expo/index.d.ts
CHANGED
|
@@ -2662,7 +2662,7 @@ type ApiType = "auto" | "responses" | "completions";
|
|
|
2662
2662
|
*/
|
|
2663
2663
|
type ApiResponse = LlmapiResponseResponse | LlmapiChatCompletionResponse;
|
|
2664
2664
|
|
|
2665
|
-
type ChatRecordKind = "conversation" | "message" | "summary" | "project" | "memory_links" | "setting";
|
|
2665
|
+
type ChatRecordKind = "conversation" | "message" | "summary" | "project" | "memory_links" | "setting" | "app_file" | "saved_tool";
|
|
2666
2666
|
type ChatJson = null | boolean | number | string | ChatJson[] | {
|
|
2667
2667
|
[key: string]: ChatJson;
|
|
2668
2668
|
};
|
|
@@ -2796,6 +2796,8 @@ interface ChatStore {
|
|
|
2796
2796
|
}): Promise<ChatChanges>;
|
|
2797
2797
|
search(embedding: readonly number[], options?: ChatSearchOptions): Promise<ChatSearchHit[]>;
|
|
2798
2798
|
deleteAll(signal?: AbortSignal): Promise<number>;
|
|
2799
|
+
/** A keyed hash vault cannot reproduce, for record ids derived from private names. */
|
|
2800
|
+
sealedId?(value: string): Promise<string>;
|
|
2799
2801
|
attachments: ChatAttachments;
|
|
2800
2802
|
}
|
|
2801
2803
|
interface RemoteChatStoreOptions {
|
|
@@ -2804,6 +2806,7 @@ interface RemoteChatStoreOptions {
|
|
|
2804
2806
|
keyId: string;
|
|
2805
2807
|
encrypt: (plaintext: string) => Promise<string>;
|
|
2806
2808
|
decrypt: (ciphertext: string) => Promise<string>;
|
|
2809
|
+
hashTopic?: (normalized: string) => Promise<string>;
|
|
2807
2810
|
fetch?: typeof globalThis.fetch;
|
|
2808
2811
|
timeoutMs?: number;
|
|
2809
2812
|
signal?: AbortSignal;
|
|
@@ -8559,6 +8562,54 @@ declare function markAnumaRead(store: ChatStore, sortKey: number, options?: {
|
|
|
8559
8562
|
/** Counts Anuma turns the user has not read: assistant turns above both the read marker and the user's latest message. */
|
|
8560
8563
|
declare function countUnreadAnumaTurns(messages: readonly Pick<StoredMessage, "messageId" | "role" | "anuma" | "uniqueId">[], lastReadSortKey: number): number;
|
|
8561
8564
|
|
|
8565
|
+
interface AppFile {
|
|
8566
|
+
conversationId: string;
|
|
8567
|
+
path: string;
|
|
8568
|
+
content: string;
|
|
8569
|
+
version: number;
|
|
8570
|
+
createdAt: number;
|
|
8571
|
+
updatedAt: number;
|
|
8572
|
+
}
|
|
8573
|
+
interface SavedToolData {
|
|
8574
|
+
name: string;
|
|
8575
|
+
displayName: string;
|
|
8576
|
+
description: string;
|
|
8577
|
+
parameters: string;
|
|
8578
|
+
html: string;
|
|
8579
|
+
conversationId: string | null;
|
|
8580
|
+
}
|
|
8581
|
+
interface SavedTool extends SavedToolData {
|
|
8582
|
+
id: string;
|
|
8583
|
+
version: number;
|
|
8584
|
+
createdAt: number;
|
|
8585
|
+
updatedAt: number;
|
|
8586
|
+
}
|
|
8587
|
+
/** The vault record id of a conversation's file: a keyed hash, so vault cannot tell the path. */
|
|
8588
|
+
declare function appFileId(store: Pick<ChatStore, "sealedId">, conversationId: string, path: string): Promise<string>;
|
|
8589
|
+
/** Every live file of one conversation. */
|
|
8590
|
+
declare function listAppFiles(store: ChatStore, conversationId: string, signal?: AbortSignal): Promise<AppFile[]>;
|
|
8591
|
+
interface AppFileIndex {
|
|
8592
|
+
/** Every live file of every conversation, fetching only what changed since the last call. */
|
|
8593
|
+
list(signal?: AbortSignal): Promise<AppFile[]>;
|
|
8594
|
+
}
|
|
8595
|
+
/** Keeps every app file of the account current from the changes feed. */
|
|
8596
|
+
declare function createAppFileIndex(store: ChatStore): AppFileIndex;
|
|
8597
|
+
/** Every live file of every conversation, read from the changes feed. */
|
|
8598
|
+
declare function listEveryAppFile(store: ChatStore, signal?: AbortSignal): Promise<AppFile[]>;
|
|
8599
|
+
/** One conversation file, or null when vault holds none at that path. */
|
|
8600
|
+
declare function getAppFile(store: ChatStore, conversationId: string, path: string, signal?: AbortSignal): Promise<AppFile | null>;
|
|
8601
|
+
/** Creates or replaces a conversation file; the last save of a path wins across devices. */
|
|
8602
|
+
declare function saveAppFile(store: ChatStore, file: {
|
|
8603
|
+
conversationId: string;
|
|
8604
|
+
path: string;
|
|
8605
|
+
content: string;
|
|
8606
|
+
}, signal?: AbortSignal): Promise<AppFile>;
|
|
8607
|
+
declare function deleteAppFile(store: ChatStore, conversationId: string, path: string, signal?: AbortSignal): Promise<void>;
|
|
8608
|
+
declare function loadSavedTools(store: ChatStore, signal?: AbortSignal): Promise<SavedTool[]>;
|
|
8609
|
+
/** Creates or replaces a saved tool; the last save wins across devices. */
|
|
8610
|
+
declare function saveSavedTool(store: ChatStore, id: string, tool: SavedToolData, signal?: AbortSignal): Promise<SavedTool>;
|
|
8611
|
+
declare function deleteSavedTool(store: ChatStore, id: string, signal?: AbortSignal): Promise<void>;
|
|
8612
|
+
|
|
8562
8613
|
interface ChatMigrationOptions {
|
|
8563
8614
|
/** The device's local chat database. */
|
|
8564
8615
|
database: Database;
|
|
@@ -8606,6 +8657,20 @@ declare function migrateChatsToRemote(options: ChatMigrationOptions): Promise<Ch
|
|
|
8606
8657
|
/** Connect to owner-scoped server storage using the account's canonical device-held cipher. */
|
|
8607
8658
|
declare function createRemoteChatStore(options: RemoteChatStoreOptions): Promise<ChatStore>;
|
|
8608
8659
|
|
|
8660
|
+
interface AppFileSeedResult {
|
|
8661
|
+
appFiles: number;
|
|
8662
|
+
savedTools: number;
|
|
8663
|
+
/** Files of conversations vault does not hold, left on the device. */
|
|
8664
|
+
orphaned: number;
|
|
8665
|
+
/** Files too large for one vault record, left on the device. */
|
|
8666
|
+
tooLarge: number;
|
|
8667
|
+
}
|
|
8668
|
+
/**
|
|
8669
|
+
* Uploads this device's app files and saved tools that vault lacks or holds an older edit of,
|
|
8670
|
+
* keeping each one's own edit time so the newest copy across devices wins.
|
|
8671
|
+
*/
|
|
8672
|
+
declare function seedAppFilesToVault(database: Database, store: ChatStore, signal?: AbortSignal): Promise<AppFileSeedResult>;
|
|
8673
|
+
|
|
8609
8674
|
interface Setting {
|
|
8610
8675
|
section: string;
|
|
8611
8676
|
data: {
|
|
@@ -12479,4 +12544,4 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
12479
12544
|
*/
|
|
12480
12545
|
declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
|
|
12481
12546
|
|
|
12482
|
-
export { ANUMA_CONVERSATION_ID, type ActiveStream, type AnumaTurn, type AnumaTurnOrigin, type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, type ChatAccount, type ChatAccountState, type ChatAttachment, type ChatAttachments, type ChatBackend, type ChatBackendFactory, type ChatBackendSigner, type ChatCacheStorage, type ChatChanges, type ChatChunkSearchOptions, Conversation as ChatConversation, type ChatImport, type ChatJson, type ChatListOptions, Message as ChatMessage, type ChatMigrationOptions, type ChatMigrationProgress, type ChatMigrationResult, type ChatMigrationSkip, type ChatOutboxLocks, type ChatOutboxStorage, type ChatPage, type ChatPresignedUrl, type ChatRecord, type ChatRecordKind, type ChatRef, type ChatRevision, type ChatRole, type ChatSearchHit, type ChatSearchOptions, type ChatSnapshot, type ChatStore, ChatStoreError, type ChatWrite, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateSelectPaymentWalletToolOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CreateWalletPaymentToolOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InboxDeliveryResult, type InboxItem, type InboxPlaintext, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type LocalMessageAttachment, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCounts, type MemoryCreate, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageAttachmentMigrationOptions, type MessageAttachmentMigrationResult, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PaymentWallet, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteChatStoreOptions, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RemoteMemoryTopic, type RemoteMemoryWorkKind, type RemoteMemoryWorkLease, type RemoteMemoryWorkPersistence, type RemoteTopicPersistence, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SELECT_PAYMENT_WALLET_TOOL_NAME, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectPaymentWalletResult, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type Setting, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredTopic, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TOPIC_SALIENCE_WEIGHTS, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSalience, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultAttachmentCache, type VaultAttachmentJournal, type VaultAttachmentOwner, type VaultAttachmentRef, type VaultAttachmentUploadOptions, type VaultAttachments, type VaultAttachmentsOptions, type VaultChatActivity, type VaultChatBackend, type VaultChatBackendOptions, type VaultChatEvent, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultInbox, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, type WriteFailureReason, addConversationMemoriesOp, anumaLastReadSortKey, anumaTurnContent, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, countUnreadAnumaTurns, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteChatStore, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createSelectPaymentWalletTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultAttachments, createVaultChatBackend, createVaultEmbeddingCache, createVaultFolderOp, createVaultInbox, createVaultMemoriesBatchOp, createVaultMemoryOp, createWalletPaymentTool, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, decryptMessageEmbeddingFields, deleteAllVaultMemoriesForUserOp, deleteMessageOp, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, encryptToolCallEventsOp, ensureAnumaConversation, ensureDefaultFoldersOp, exchangeNotionCode, exportInboxPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, listActiveStreams, loadSettings, localChatBackend, markAnumaRead, maskScopedEmbeddingCache, maxVaultAttachmentBytes, memoryCipher, migrateChatsToRemote, migrateMemoriesToRemote, migrateMessageAttachments, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, openInboxItem, parseMedia, preEmbedVaultMemories, primaryTopic, quantizeEmbedding, queueManager, rankProfileCandidates, readAnumaTurn, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, saveSetting, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchVaultMemories, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, topicWeight, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, vaultAttachmentRefs, vaultChatBackend, verifyMemoriesForPublish, xhrTransport };
|
|
12547
|
+
export { ANUMA_CONVERSATION_ID, type ActiveStream, type AnumaTurn, type AnumaTurnOrigin, type AppFile, type AppFileIndex, type AppFileSeedResult, type AutoExtractMessage, type AutoExtractor, type Budget, CHUNKS_DISCARDED_ORIGIN, type CachedChunkVectors, type CachedServerTools, type ChatAccount, type ChatAccountState, type ChatAttachment, type ChatAttachments, type ChatBackend, type ChatBackendFactory, type ChatBackendSigner, type ChatCacheStorage, type ChatChanges, type ChatChunkSearchOptions, Conversation as ChatConversation, type ChatImport, type ChatJson, type ChatListOptions, Message as ChatMessage, type ChatMigrationOptions, type ChatMigrationProgress, type ChatMigrationResult, type ChatMigrationSkip, type ChatOutboxLocks, type ChatOutboxStorage, type ChatPage, type ChatPresignedUrl, type ChatRecord, type ChatRecordKind, type ChatRef, type ChatRevision, type ChatRole, type ChatSearchHit, type ChatSearchOptions, type ChatSnapshot, type ChatStore, ChatStoreError, type ChatWrite, type ChunkSearchStats, type ChunkVectorCache, type ChunkingOptions, type ConsolidationAction, type ConsolidationFallbackReason, type ConversationMemoryInput, ConversationMemory as ConversationMemoryModel, type ConversationMemoryOperationsContext, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateDecaySweeperOptions, type CreateMessageOptions, type CreateSelectPaymentWalletToolOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CreateWalletPaymentToolOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DECAY_POLICY, DEFAULT_MAX_CLASSIFIER_CALLS_PER_SWEEP, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_PROFILE_FACETS, DEFAULT_PROFILE_FACT_TYPE_WEIGHTS, DEFAULT_PROFILE_PROOF_ALPHA, DEFAULT_PROFILE_TREND_MULTIPLIERS, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type DecayCandidateRaw, type DecayClassifier, type DecayInput, type DecayPolicy, type DecaySweepResult, type DecaySweeper, type DecayVerdict, type DurableAutoExtractorOptions, ENTITY_FANOUT, type EmbeddedWalletSignerFn, type EmbeddingRepairOptions, type EmbeddingRepairResult, EncryptionKeyMissingError, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type ExtractionFunnel, type ExtractionMessageSource, type ExtractionSourceMessage, type ExtractionSourceStatus, type ExtractionTimings, type FactType, type FileMetadata, type FileProcessingReason, type FileProcessingStatus, type FlushResult, type GetConversationsPageOptions, type GetMessagesPageOptions, type GraphTraversalOptions, HARD_DELETE_WINDOW_MS, INFERENCE_ID_HEADER, type InboxDeliveryResult, type InboxItem, type InboxPlaintext, type InjectionClassifierOptions, type InjectionReason, type LazyStoredConversation, type LlmDecayClassifierOptions, type LlmNeighborRefinerOptions, type LocalMemoryStoreOptions, type LocalMessageAttachment, type Logger, LoggerProvider, type LoggerProviderProps, MAX_HOPS, MEDIUM_TTL_MS, MEMORY_KINDS, MEMORY_LEVELS, type ManualFactType, type MemoriesNeedingTopicExtraction, type MemoryContextItem, type MemoryContextLane, type MemoryContextOptions, type MemoryContextResult, type MemoryCounts, type MemoryCreate, type MemoryDecay, type MemoryDecaySweeperOptions, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, MemoryKeyError, type MemoryKeyRing, type MemoryKind, type MemoryLevel, MemoryLevelError, type MemoryListOptions, type MemoryMaintenance, type MemoryMigrationOptions, type MemoryMigrationProgress, type MemoryMigrationResult, type MemoryMigrationSkip, type MemoryQuarantinedEvent, type MemoryRecallOptions, type MemoryRetainOptions, type MemoryStore, type MemorySubscribeOptions, type MemoryToVerify, type MemoryTopic, type MemoryTopicBacklog, type MemoryTopicMaintenance, type MemoryUpdate, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, type MemoryVerification, type MessageAttachmentMigrationOptions, type MessageAttachmentMigrationResult, type MessageRedactionResult, type MessageSkeleton, NEVER_TTL_MS, NODE_BUDGET, NOTION_OAUTH_CONFIG, type NeighborRefiner, type NotionAuthUrlParams, type NotionClientRegistration, type NotionExchangeCodeParams, type NotionMcpCaller, type NotionOAuthEndpoints, type NotionPKCEChallenge, type NotionRefreshTokenParams, type NotionTokenResponse, type NowSource, type ObservationTrend, type ObservationTrendInput, PAST_EVENT_GRACE_MS, PII_PATTERNS, PROFILE_DOC_VERSION, type PaymentWallet, type PhotoIngestResult, type PhotoMediaRef, type PiiCategory, type PiiMatch, type PiiPattern, PiiRedactor, type PiiRedactorOptions, type PlatformStorage, type PortalLlmAuth, type PortalLlmFailure, type PortalLlmFailureReason, type ProfileConfigFingerprint, type ProfileDoc, type ProfileFacet, type ProfileFacetKey, type ProfileSalienceInput, type ProfileSection, type PromptPreProcessor, type PromptPreProcessorContext, type PublishedPhotoMemory, type QuantizedEmbedding, type QuarantinedMemoryInfo, QueueManager, type QueueStatus, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankableVaultMemory, type RankedMemory, type RankedProfileCandidate, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallEmptyReason, type RecallOptions, type RecallResult, type RecallTelemetryCallbacks, type RecallToolCallbacks, type RecallToolOptions, type RecallTruncation, type RecencyOptions, type RedactionResult, type ReflectOptions, type ReflectResult, type RemoteChatStoreOptions, type RemoteMemoryCandidateOptions, type RemoteMemoryDecodeFailure, RemoteMemoryError, type RemoteMemoryListOptions, type RemoteMemoryMetadataPage, type RemoteMemoryMetadataRecord, type RemoteMemoryPage, RemoteMemoryPartialCreateError, type RemoteMemoryPersistence, type RemoteMemoryPersistenceOptions, type RemoteMemoryPipeline, type RemoteMemoryPipelineOptions, type RemoteMemoryQueryOptions, type RemoteMemoryQueryPage, type RemoteMemoryReadFilters, type RemoteMemoryRecord, type RemoteMemoryRow, type RemoteMemoryStoreOptions, type RemoteMemoryTopic, type RemoteMemoryWorkKind, type RemoteMemoryWorkLease, type RemoteMemoryWorkPersistence, type RemoteTopicPersistence, type RequestEncryptionKeyOptions, RerankerUnavailableError, type ReservationReceipt, type ResumeStreamOptions, type ResumeStreamResult, type ResumeStreamWithStorageResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, SDK_SCHEMA_VERSION, SELECT_PAYMENT_WALLET_TOOL_NAME, SHORT_TTL_MS, STREAM_RESUMABLE_HEADER, type SavedTool, type SavedToolData, type ScoreBreakdown, type ScoreProfileSalienceOptions, type ScreenResult, type ScreenedCandidate, type SearchSource, type SelectPaymentWalletResult, type SendMessageWithStorageArgs, type SendMessageWithStorageDetachedResult, type SendMessageWithStorageResult, type ServerToolsOptions, type ServerToolsResponse, type Setting, type SignMessageFn, type StockPriceClassification, type StockPricePreProcessorOptions, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredConversationMemory, type StoredMessage, type StoredMessageWithSimilarity, type StoredTopic, type StoredVaultFolder, VaultFolder as StoredVaultFolderModel, type StoredVaultMemory, VaultMemory as StoredVaultMemoryModel, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type SynthesizeProfileOptions, TOOL_RESULT_ORIGIN, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, TOPIC_SALIENCE_WEIGHTS, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS, type TextChunk, type TopicExtractOptions, type TopicExtractionBatchDiagnostics, type TopicExtractionInput, type TopicExtractionRunResult, type TopicSalience, type TopicSkipReason, type TurnCompleteEvent, type TurnSkippedEvent, type UncheckedReason, type UnverifiableReason, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseCreditsOptions, type UseCreditsResult, type UseModelsOptions, type UseModelsResult, VAULT_SIZE_HOP_CAP, type VaultAttachmentCache, type VaultAttachmentJournal, type VaultAttachmentOwner, type VaultAttachmentRef, type VaultAttachmentUploadOptions, type VaultAttachments, type VaultAttachmentsOptions, type VaultChatActivity, type VaultChatBackend, type VaultChatBackendOptions, type VaultChatEvent, type VaultEmbeddingCache, type VaultEmbeddingExpectation, type VaultFolderOperationsContext, type VaultInbox, type VaultMemoryKind, type VaultMemoryOperationsContext, type VaultMemoryProjection, type VaultMemoryVisibility, type VaultMemoryWriter, type VaultSaveOperation, type VaultSearchResult, type VaultWriteAction, type VaultWriteInput, type VaultWriteOutcome, type VerificationSources, type VerifyMemoriesForPublishOptions, WALLET_PAYMENT_TOOL_NAME, type WalletPaymentOutcome, type WalletPaymentPassenger, type WalletPaymentRequest, type WalletPaymentResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, type WriteFailureReason, addConversationMemoriesOp, anumaLastReadSortKey, anumaTurnContent, appFileId, archiveVaultMemoryOp, assembleMemoryContext, attachFileContextToLastUserMessage, backfillMemoryTopicsOp, buildAttachedFilesText, buildNotionAuthUrl, capHopsForDensity, chatStorageMigrations, chatStorageSchema, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyDecay, classifyInjectionCandidates, classifyObservationTrend, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, clearAllEncryptionKeys, clearAllEncryptionState, clearConversationMemoriesOp, clearEncryptionKey, clearLazyTitleCache, clearModelsCache, clearServerToolsCache, consoleLogger, conversationMemoryToStored, cosineInt8, countUnreadAnumaTurns, createAppFileIndex, createAutoExtractor, createChunkVectorCache, createCryptoPricePreProcessor, createDecaySweeper, createDurableAutoExtractor, createLlmDecayClassifier, createLlmNeighborRefiner, createLocalMemoryStore, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageSourceResolver, createNotionProxyTools, createNotionTools, createPlatformCursorStore, createRecallTool, createRemoteChatStore, createRemoteMemoryPersistence, createRemoteMemoryPipeline, createRemoteMemoryStore, createSelectPaymentWalletTool, createStockPricePreProcessor, createStreamingDeAnonymizer, createVaultAttachments, createVaultChatBackend, createVaultEmbeddingCache, createVaultFolderOp, createVaultInbox, createVaultMemoriesBatchOp, createVaultMemoryOp, createWalletPaymentTool, createWeatherPreProcessor, createWebSearchPreProcessor, decodeChunkVector, decryptConversationTitle, decryptMessageEmbeddingFields, deleteAllVaultMemoriesForUserOp, deleteAppFile, deleteMessageOp, deleteSavedTool, deleteVaultFolderOp, deleteVaultMemoryOp, dequantizeEmbedding, deriveKeyFromSignatureBytes, deriveMemoryKeyRing, discoverNotionOAuthEndpoints, eagerEmbedContent, embedAllMessages, embedMessage, encodeChunkVector, encryptToolCallEventsOp, ensureAnumaConversation, ensureDefaultFoldersOp, exchangeNotionCode, exportInboxPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, extractReservationReceipts, formatFileProcessingNotes, generateConversationId, generateEmbedding, generateEmbeddings, generateNotionPKCE, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAppFile, getCachedServerTools, getConversationMemoriesOp, getConversationsByProjectLazyOp, getConversationsLazyOp, getConversationsPageOp, getDecayCandidatesRawOp, getLogger, getMemoriesNeedingTopicExtractionOp, getServerTools, getUnfiledVaultMemoriesOp, getVaultFolderMemoryCountOp, getVaultMemoriesByIdsOp, getVaultMemoryOp, getVaultRankingProjectionsOp, hardDeleteDecayedOp, hasEncryptionKey, ingestPublishedPhotoMemoriesOp, injectionSignatureCatalog, isAttachedFilesText, isDegradedTopicSkip, isEncrypted, isPiiRedactor, isRerankerAvailable, listActiveStreams, listAppFiles, listEveryAppFile, loadSavedTools, loadSettings, localChatBackend, markAnumaRead, maskScopedEmbeddingCache, maxVaultAttachmentBytes, memoryCipher, migrateChatsToRemote, migrateMemoriesToRemote, migrateMessageAttachments, moveMemoriesToFolderOp, noopLogger, onKeyAvailable, openInboxItem, parseMedia, preEmbedVaultMemories, primaryTopic, quantizeEmbedding, queueManager, rankProfileCandidates, readAnumaTurn, recall, reencryptMemoryField, reflect, refreshEncryptionKeyIfMatches, refreshNotionAccessToken, registerNotionClient, relinkMemoryTopicsOp, requestEncryptionKey, resolvePiiRedactor, restoreVaultMemoryOp, resumeStream, retain, saveAppFile, saveSavedTool, saveSetting, scoreProfileSalience, screenCandidatesForInjection, sdkMigrations, sdkModelClasses, sdkSchema, sealLegacyMessageEmbeddingsOp, searchVaultMemories, seedAppFilesToVault, seedEncryptionKeys, setLogger, setMemoryVisibilityOp, shouldChunkMessage, shouldRecallMemory, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, stripLegacyChunkTextOp, summarizeObservationTrends, supersedeVaultMemoryOp, synthesizeProfile, topicWeight, traverseGraphLane, ttlForType, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertMessageOp, useChat, useChatStorage, useCredits, useEncryption, useModels, vaultAttachmentRefs, vaultChatBackend, verifyMemoriesForPublish, xhrTransport };
|
package/dist/expo/index.mjs
CHANGED
|
@@ -11810,6 +11810,168 @@ function countUnreadAnumaTurns(messages, lastReadSortKey) {
|
|
|
11810
11810
|
return turns.size;
|
|
11811
11811
|
}
|
|
11812
11812
|
|
|
11813
|
+
// src/utils/paths.ts
|
|
11814
|
+
function normalizePath(p) {
|
|
11815
|
+
return p.replace(/^\/+/, "").replace(/\/\/+/g, "/").split("/").reduce((acc, seg) => {
|
|
11816
|
+
if (seg === "..") acc.pop();
|
|
11817
|
+
else if (seg !== ".") acc.push(seg);
|
|
11818
|
+
return acc;
|
|
11819
|
+
}, []).join("/");
|
|
11820
|
+
}
|
|
11821
|
+
|
|
11822
|
+
// src/lib/chatStore/appFiles.ts
|
|
11823
|
+
var maxSaveAttempts = 3;
|
|
11824
|
+
async function appFileId(store, conversationId, path) {
|
|
11825
|
+
if (!store.sealedId) throw new Error("App file ids need a chat store that seals ids");
|
|
11826
|
+
return store.sealedId(`app_file\0${conversationId}\0${normalizePath(path)}`);
|
|
11827
|
+
}
|
|
11828
|
+
async function putLatest(store, target, next, signal) {
|
|
11829
|
+
for (let attempt = 1; ; attempt++) {
|
|
11830
|
+
const current = await store.get(target.kind, target.id, signal);
|
|
11831
|
+
if (next.isDeleted && (!current || current.record.isDeleted)) return current;
|
|
11832
|
+
const now = Date.now();
|
|
11833
|
+
try {
|
|
11834
|
+
const [saved] = await store.putMany(
|
|
11835
|
+
[
|
|
11836
|
+
{
|
|
11837
|
+
record: {
|
|
11838
|
+
...target,
|
|
11839
|
+
sortKey: 0,
|
|
11840
|
+
createdAt: current?.record.createdAt ?? now,
|
|
11841
|
+
updatedAt: Math.max(now, (current?.record.updatedAt ?? 0) + 1),
|
|
11842
|
+
isDeleted: next.isDeleted,
|
|
11843
|
+
data: next.isDeleted ? {} : next.data
|
|
11844
|
+
},
|
|
11845
|
+
expectedVersion: current?.version ?? 0
|
|
11846
|
+
}
|
|
11847
|
+
],
|
|
11848
|
+
signal
|
|
11849
|
+
);
|
|
11850
|
+
return saved;
|
|
11851
|
+
} catch (error) {
|
|
11852
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSaveAttempts)
|
|
11853
|
+
throw error;
|
|
11854
|
+
}
|
|
11855
|
+
}
|
|
11856
|
+
}
|
|
11857
|
+
async function listAll(store, kind, conversationId, signal) {
|
|
11858
|
+
const out = [];
|
|
11859
|
+
let cursor;
|
|
11860
|
+
do {
|
|
11861
|
+
const page = await store.list({ kind, conversationId, limit: 100, cursor, signal });
|
|
11862
|
+
out.push(...page.items.filter((item) => !item.record.isDeleted));
|
|
11863
|
+
cursor = page.nextCursor;
|
|
11864
|
+
} while (cursor);
|
|
11865
|
+
return out;
|
|
11866
|
+
}
|
|
11867
|
+
function toAppFile(snapshot) {
|
|
11868
|
+
const { path, content } = snapshot.record.data;
|
|
11869
|
+
if (typeof path !== "string" || typeof content !== "string") return null;
|
|
11870
|
+
return {
|
|
11871
|
+
conversationId: snapshot.record.conversationId,
|
|
11872
|
+
path,
|
|
11873
|
+
content,
|
|
11874
|
+
version: snapshot.version,
|
|
11875
|
+
createdAt: snapshot.record.createdAt,
|
|
11876
|
+
updatedAt: snapshot.record.updatedAt
|
|
11877
|
+
};
|
|
11878
|
+
}
|
|
11879
|
+
function toSavedTool(snapshot) {
|
|
11880
|
+
const d = snapshot.record.data;
|
|
11881
|
+
if (typeof d.name !== "string" || typeof d.displayName !== "string" || typeof d.description !== "string" || typeof d.parameters !== "string" || typeof d.html !== "string" || d.conversationId !== null && typeof d.conversationId !== "string")
|
|
11882
|
+
return null;
|
|
11883
|
+
return {
|
|
11884
|
+
id: snapshot.record.id,
|
|
11885
|
+
name: d.name,
|
|
11886
|
+
displayName: d.displayName,
|
|
11887
|
+
description: d.description,
|
|
11888
|
+
parameters: d.parameters,
|
|
11889
|
+
html: d.html,
|
|
11890
|
+
conversationId: d.conversationId,
|
|
11891
|
+
version: snapshot.version,
|
|
11892
|
+
createdAt: snapshot.record.createdAt,
|
|
11893
|
+
updatedAt: snapshot.record.updatedAt
|
|
11894
|
+
};
|
|
11895
|
+
}
|
|
11896
|
+
async function listAppFiles(store, conversationId, signal) {
|
|
11897
|
+
const items = await listAll(store, "app_file", conversationId, signal);
|
|
11898
|
+
return items.map(toAppFile).filter((file) => file !== null);
|
|
11899
|
+
}
|
|
11900
|
+
function createAppFileIndex(store) {
|
|
11901
|
+
const latest = /* @__PURE__ */ new Map();
|
|
11902
|
+
let cursor;
|
|
11903
|
+
let queue = Promise.resolve();
|
|
11904
|
+
const catchUp = async (signal) => {
|
|
11905
|
+
for (; ; ) {
|
|
11906
|
+
const page = await store.changes(cursor, { kinds: ["app_file"], limit: 200, signal });
|
|
11907
|
+
for (const item of page.items) latest.set(item.record.id, item);
|
|
11908
|
+
cursor = page.nextCursor ?? page.changesCursor;
|
|
11909
|
+
if (!page.nextCursor) break;
|
|
11910
|
+
}
|
|
11911
|
+
return [...latest.values()].filter((item) => !item.record.isDeleted).map(toAppFile).filter((file) => file !== null);
|
|
11912
|
+
};
|
|
11913
|
+
return {
|
|
11914
|
+
list(signal) {
|
|
11915
|
+
const next = queue.then(() => catchUp(signal));
|
|
11916
|
+
queue = next.catch(() => void 0);
|
|
11917
|
+
return next;
|
|
11918
|
+
}
|
|
11919
|
+
};
|
|
11920
|
+
}
|
|
11921
|
+
function listEveryAppFile(store, signal) {
|
|
11922
|
+
return createAppFileIndex(store).list(signal);
|
|
11923
|
+
}
|
|
11924
|
+
async function getAppFile(store, conversationId, path, signal) {
|
|
11925
|
+
const snapshot = await store.get(
|
|
11926
|
+
"app_file",
|
|
11927
|
+
await appFileId(store, conversationId, path),
|
|
11928
|
+
signal
|
|
11929
|
+
);
|
|
11930
|
+
return snapshot && !snapshot.record.isDeleted ? toAppFile(snapshot) : null;
|
|
11931
|
+
}
|
|
11932
|
+
async function saveAppFile(store, file, signal) {
|
|
11933
|
+
const saved = await putLatest(
|
|
11934
|
+
store,
|
|
11935
|
+
{
|
|
11936
|
+
kind: "app_file",
|
|
11937
|
+
id: await appFileId(store, file.conversationId, file.path),
|
|
11938
|
+
conversationId: file.conversationId
|
|
11939
|
+
},
|
|
11940
|
+
{ data: { path: normalizePath(file.path), content: file.content }, isDeleted: false },
|
|
11941
|
+
signal
|
|
11942
|
+
);
|
|
11943
|
+
return toAppFile(saved);
|
|
11944
|
+
}
|
|
11945
|
+
async function deleteAppFile(store, conversationId, path, signal) {
|
|
11946
|
+
await putLatest(
|
|
11947
|
+
store,
|
|
11948
|
+
{ kind: "app_file", id: await appFileId(store, conversationId, path), conversationId },
|
|
11949
|
+
{ data: {}, isDeleted: true },
|
|
11950
|
+
signal
|
|
11951
|
+
);
|
|
11952
|
+
}
|
|
11953
|
+
async function loadSavedTools(store, signal) {
|
|
11954
|
+
const items = await listAll(store, "saved_tool", void 0, signal);
|
|
11955
|
+
return items.map(toSavedTool).filter((tool) => tool !== null);
|
|
11956
|
+
}
|
|
11957
|
+
async function saveSavedTool(store, id2, tool, signal) {
|
|
11958
|
+
const saved = await putLatest(
|
|
11959
|
+
store,
|
|
11960
|
+
{ kind: "saved_tool", id: id2, conversationId: "" },
|
|
11961
|
+
{ data: { ...tool }, isDeleted: false },
|
|
11962
|
+
signal
|
|
11963
|
+
);
|
|
11964
|
+
return toSavedTool(saved);
|
|
11965
|
+
}
|
|
11966
|
+
async function deleteSavedTool(store, id2, signal) {
|
|
11967
|
+
await putLatest(
|
|
11968
|
+
store,
|
|
11969
|
+
{ kind: "saved_tool", id: id2, conversationId: "" },
|
|
11970
|
+
{ data: {}, isDeleted: true },
|
|
11971
|
+
signal
|
|
11972
|
+
);
|
|
11973
|
+
}
|
|
11974
|
+
|
|
11813
11975
|
// src/lib/db/chat/summaryOperations.ts
|
|
11814
11976
|
import { Q as Q4 } from "@nozbe/watermelondb";
|
|
11815
11977
|
function createSummaryContext(database, encryption = {}) {
|
|
@@ -12012,7 +12174,16 @@ function batches(records) {
|
|
|
12012
12174
|
}
|
|
12013
12175
|
|
|
12014
12176
|
// src/lib/chatStore/remote.ts
|
|
12015
|
-
var kinds = /* @__PURE__ */ new Set([
|
|
12177
|
+
var kinds = /* @__PURE__ */ new Set([
|
|
12178
|
+
"conversation",
|
|
12179
|
+
"message",
|
|
12180
|
+
"summary",
|
|
12181
|
+
"project",
|
|
12182
|
+
"memory_links",
|
|
12183
|
+
"setting",
|
|
12184
|
+
"app_file",
|
|
12185
|
+
"saved_tool"
|
|
12186
|
+
]);
|
|
12016
12187
|
var cipherPattern = /^enc:v\d+:(?:[0-9a-f]{2}){28,}$/i;
|
|
12017
12188
|
var maxPayload = 2 * 1024 * 1024;
|
|
12018
12189
|
var storedDims2 = 1536;
|
|
@@ -12072,7 +12243,7 @@ function validRecord(value) {
|
|
|
12072
12243
|
return root ? value.conversationId === "" : id(value.conversationId);
|
|
12073
12244
|
}
|
|
12074
12245
|
function rootKind(kind) {
|
|
12075
|
-
return kind === "conversation" || kind === "project" || kind === "setting";
|
|
12246
|
+
return kind === "conversation" || kind === "project" || kind === "setting" || kind === "saved_tool";
|
|
12076
12247
|
}
|
|
12077
12248
|
function embeddings(write) {
|
|
12078
12249
|
if (write.embeddings === void 0) return true;
|
|
@@ -12153,6 +12324,7 @@ async function createRemoteChatStore(options) {
|
|
|
12153
12324
|
const keyId = options.keyId;
|
|
12154
12325
|
const encrypt = options.encrypt;
|
|
12155
12326
|
const decrypt = options.decrypt;
|
|
12327
|
+
const hashTopic = options.hashTopic;
|
|
12156
12328
|
const nearby = createNearbyRequest({ ...options }, "/api/private-chats");
|
|
12157
12329
|
const request = async (...args) => {
|
|
12158
12330
|
try {
|
|
@@ -12203,7 +12375,9 @@ async function createRemoteChatStore(options) {
|
|
|
12203
12375
|
JSON.stringify({ schema: 1, account_id: accountId, key_id: keyId, record: record3 })
|
|
12204
12376
|
);
|
|
12205
12377
|
signal?.throwIfAborted();
|
|
12206
|
-
if (!cipherPattern.test(payload)
|
|
12378
|
+
if (!cipherPattern.test(payload)) invalid();
|
|
12379
|
+
if (payload.length > maxPayload)
|
|
12380
|
+
throw new ChatStoreError("Encrypted chat record is too large", 413, "record_too_large");
|
|
12207
12381
|
return payload;
|
|
12208
12382
|
};
|
|
12209
12383
|
const capture = (items, max, signal) => {
|
|
@@ -12484,6 +12658,7 @@ async function createRemoteChatStore(options) {
|
|
|
12484
12658
|
if (!object(value) || !integer(value.deleted)) invalid();
|
|
12485
12659
|
return value.deleted;
|
|
12486
12660
|
},
|
|
12661
|
+
...hashTopic ? { sealedId: (value) => hashTopic(`record-id\0${value}`) } : {},
|
|
12487
12662
|
attachments: {
|
|
12488
12663
|
async create(sizeBytes, signal) {
|
|
12489
12664
|
if (!integer(sizeBytes, 1) || sizeBytes > maxAttachmentBytes) invalid();
|
|
@@ -12850,8 +13025,87 @@ async function migrateChatsToRemote(options) {
|
|
|
12850
13025
|
return passes(false);
|
|
12851
13026
|
}
|
|
12852
13027
|
|
|
13028
|
+
// src/lib/chatStore/seedAppFiles.ts
|
|
13029
|
+
var maxSeedAttempts = 3;
|
|
13030
|
+
async function rawRows(database, table) {
|
|
13031
|
+
const rows = await database.get(table).query().fetch();
|
|
13032
|
+
return rows.map((row) => row._raw);
|
|
13033
|
+
}
|
|
13034
|
+
async function seedRecord(store, target, device, signal) {
|
|
13035
|
+
for (let attempt = 1; ; attempt++) {
|
|
13036
|
+
const current = await store.get(target.kind, target.id, signal);
|
|
13037
|
+
if (current && (current.record.isDeleted || current.record.updatedAt >= device.updatedAt))
|
|
13038
|
+
return false;
|
|
13039
|
+
try {
|
|
13040
|
+
await store.putMany(
|
|
13041
|
+
[
|
|
13042
|
+
{
|
|
13043
|
+
record: {
|
|
13044
|
+
...target,
|
|
13045
|
+
sortKey: 0,
|
|
13046
|
+
createdAt: current?.record.createdAt ?? device.createdAt,
|
|
13047
|
+
updatedAt: device.updatedAt,
|
|
13048
|
+
isDeleted: false,
|
|
13049
|
+
data: device.data
|
|
13050
|
+
},
|
|
13051
|
+
expectedVersion: current?.version ?? 0
|
|
13052
|
+
}
|
|
13053
|
+
],
|
|
13054
|
+
signal
|
|
13055
|
+
);
|
|
13056
|
+
return true;
|
|
13057
|
+
} catch (error) {
|
|
13058
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSeedAttempts)
|
|
13059
|
+
throw error;
|
|
13060
|
+
}
|
|
13061
|
+
}
|
|
13062
|
+
}
|
|
13063
|
+
function leftOnDevice(error, result) {
|
|
13064
|
+
if (!(error instanceof ChatStoreError)) return false;
|
|
13065
|
+
if (error.code === "conversation_not_found") result.orphaned++;
|
|
13066
|
+
else if (error.code === "record_too_large") result.tooLarge++;
|
|
13067
|
+
else return false;
|
|
13068
|
+
return true;
|
|
13069
|
+
}
|
|
13070
|
+
async function seedAppFilesToVault(database, store, signal) {
|
|
13071
|
+
const result = { appFiles: 0, savedTools: 0, orphaned: 0, tooLarge: 0 };
|
|
13072
|
+
for (const file of await rawRows(database, "app_files")) {
|
|
13073
|
+
try {
|
|
13074
|
+
const target = {
|
|
13075
|
+
kind: "app_file",
|
|
13076
|
+
id: await appFileId(store, file.conversation_id, file.path),
|
|
13077
|
+
conversationId: file.conversation_id
|
|
13078
|
+
};
|
|
13079
|
+
const data = { path: normalizePath(file.path), content: file.content };
|
|
13080
|
+
const device = { data, createdAt: file.created_at, updatedAt: file.updated_at };
|
|
13081
|
+
if (await seedRecord(store, target, device, signal)) result.appFiles++;
|
|
13082
|
+
} catch (error) {
|
|
13083
|
+
if (!leftOnDevice(error, result)) throw error;
|
|
13084
|
+
}
|
|
13085
|
+
}
|
|
13086
|
+
for (const tool of await rawRows(database, "saved_tools")) {
|
|
13087
|
+
if (tool.is_deleted) continue;
|
|
13088
|
+
try {
|
|
13089
|
+
const data = {
|
|
13090
|
+
name: tool.name,
|
|
13091
|
+
displayName: tool.display_name,
|
|
13092
|
+
description: tool.description,
|
|
13093
|
+
parameters: tool.parameters,
|
|
13094
|
+
html: tool.html,
|
|
13095
|
+
conversationId: tool.conversation_id || null
|
|
13096
|
+
};
|
|
13097
|
+
const target = { kind: "saved_tool", id: tool.id, conversationId: "" };
|
|
13098
|
+
const device = { data, createdAt: tool.created_at, updatedAt: tool.updated_at };
|
|
13099
|
+
if (await seedRecord(store, target, device, signal)) result.savedTools++;
|
|
13100
|
+
} catch (error) {
|
|
13101
|
+
if (!leftOnDevice(error, result)) throw error;
|
|
13102
|
+
}
|
|
13103
|
+
}
|
|
13104
|
+
return result;
|
|
13105
|
+
}
|
|
13106
|
+
|
|
12853
13107
|
// src/lib/chatStore/settings.ts
|
|
12854
|
-
var
|
|
13108
|
+
var maxSaveAttempts2 = 3;
|
|
12855
13109
|
function toSetting(snapshot) {
|
|
12856
13110
|
if (snapshot.record.isDeleted) return null;
|
|
12857
13111
|
return {
|
|
@@ -12900,7 +13154,7 @@ async function saveSetting(store, section, data, signal) {
|
|
|
12900
13154
|
);
|
|
12901
13155
|
return toSetting(saved);
|
|
12902
13156
|
} catch (error) {
|
|
12903
|
-
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >=
|
|
13157
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSaveAttempts2)
|
|
12904
13158
|
throw error;
|
|
12905
13159
|
}
|
|
12906
13160
|
}
|
|
@@ -13726,12 +13980,15 @@ function createVaultChatBackend(options) {
|
|
|
13726
13980
|
emit({ type: "vector_quota" });
|
|
13727
13981
|
return "retry";
|
|
13728
13982
|
}
|
|
13729
|
-
if (error.code === "private_chat_storage_limit_reached" || error.code === "invalid_record" || error.status === 400) {
|
|
13983
|
+
if (error.code === "private_chat_storage_limit_reached" || error.code === "invalid_record" || error.code === "record_too_large" || error.status === 400) {
|
|
13730
13984
|
if (batch.length > 1) {
|
|
13731
13985
|
isolate = batch.length;
|
|
13732
13986
|
return "retry";
|
|
13733
13987
|
}
|
|
13734
|
-
drop(
|
|
13988
|
+
drop(
|
|
13989
|
+
batch[0],
|
|
13990
|
+
error.code === "private_chat_storage_limit_reached" ? "storage_quota" : "invalid"
|
|
13991
|
+
);
|
|
13735
13992
|
return "retry";
|
|
13736
13993
|
}
|
|
13737
13994
|
if (error.status === 429) return backoff(error.retryAfterMs, true);
|
|
@@ -34132,6 +34389,7 @@ export {
|
|
|
34132
34389
|
addConversationMemoriesOp,
|
|
34133
34390
|
anumaLastReadSortKey,
|
|
34134
34391
|
anumaTurnContent,
|
|
34392
|
+
appFileId,
|
|
34135
34393
|
archiveVaultMemoryOp,
|
|
34136
34394
|
assembleMemoryContext,
|
|
34137
34395
|
attachFileContextToLastUserMessage,
|
|
@@ -34166,6 +34424,7 @@ export {
|
|
|
34166
34424
|
conversationMemoryToStored,
|
|
34167
34425
|
cosineInt8,
|
|
34168
34426
|
countUnreadAnumaTurns,
|
|
34427
|
+
createAppFileIndex,
|
|
34169
34428
|
createAutoExtractor,
|
|
34170
34429
|
createChunkVectorCache,
|
|
34171
34430
|
createCryptoPricePreProcessor,
|
|
@@ -34203,7 +34462,9 @@ export {
|
|
|
34203
34462
|
decryptConversationTitle,
|
|
34204
34463
|
decryptMessageEmbeddingFields,
|
|
34205
34464
|
deleteAllVaultMemoriesForUserOp,
|
|
34465
|
+
deleteAppFile,
|
|
34206
34466
|
deleteMessageOp,
|
|
34467
|
+
deleteSavedTool,
|
|
34207
34468
|
deleteVaultFolderOp,
|
|
34208
34469
|
deleteVaultMemoryOp,
|
|
34209
34470
|
dequantizeEmbedding,
|
|
@@ -34232,6 +34493,7 @@ export {
|
|
|
34232
34493
|
getAllVaultFoldersOp,
|
|
34233
34494
|
getAllVaultMemoriesOp,
|
|
34234
34495
|
getAllVaultMemoryContentsOp,
|
|
34496
|
+
getAppFile,
|
|
34235
34497
|
getCachedServerTools,
|
|
34236
34498
|
getConversationMemoriesOp,
|
|
34237
34499
|
getConversationsByProjectLazyOp,
|
|
@@ -34256,6 +34518,9 @@ export {
|
|
|
34256
34518
|
isPiiRedactor,
|
|
34257
34519
|
isRerankerAvailable,
|
|
34258
34520
|
listActiveStreams,
|
|
34521
|
+
listAppFiles,
|
|
34522
|
+
listEveryAppFile,
|
|
34523
|
+
loadSavedTools,
|
|
34259
34524
|
loadSettings,
|
|
34260
34525
|
localChatBackend,
|
|
34261
34526
|
markAnumaRead,
|
|
@@ -34288,6 +34553,8 @@ export {
|
|
|
34288
34553
|
restoreVaultMemoryOp,
|
|
34289
34554
|
resumeStream,
|
|
34290
34555
|
retain,
|
|
34556
|
+
saveAppFile,
|
|
34557
|
+
saveSavedTool,
|
|
34291
34558
|
saveSetting,
|
|
34292
34559
|
scoreProfileSalience,
|
|
34293
34560
|
screenCandidatesForInjection,
|
|
@@ -34296,6 +34563,7 @@ export {
|
|
|
34296
34563
|
sdkSchema,
|
|
34297
34564
|
sealLegacyMessageEmbeddingsOp,
|
|
34298
34565
|
searchVaultMemories,
|
|
34566
|
+
seedAppFilesToVault,
|
|
34299
34567
|
seedEncryptionKeys,
|
|
34300
34568
|
setLogger,
|
|
34301
34569
|
setMemoryVisibilityOp,
|