@reverbia/sdk 1.0.0-next.20260110032702 → 1.0.0-next.20260110210906
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.d.mts +26 -0
- package/dist/expo/index.d.ts +26 -0
- package/dist/react/index.cjs +418 -19
- package/dist/react/index.d.mts +159 -1
- package/dist/react/index.d.ts +159 -1
- package/dist/react/index.mjs +442 -52
- package/package.json +1 -1
package/dist/react/index.d.mts
CHANGED
|
@@ -1055,6 +1055,15 @@ declare function clearEncryptionKey(address: string): void;
|
|
|
1055
1055
|
* Clears all encryption keys from memory
|
|
1056
1056
|
*/
|
|
1057
1057
|
declare function clearAllEncryptionKeys(): void;
|
|
1058
|
+
/**
|
|
1059
|
+
* Gets the encryption key from in-memory storage and imports it as a CryptoKey.
|
|
1060
|
+
* The key must have been previously requested via requestEncryptionKey.
|
|
1061
|
+
*
|
|
1062
|
+
* @param address - The wallet address
|
|
1063
|
+
* @returns The CryptoKey for AES-GCM encryption/decryption
|
|
1064
|
+
* @throws Error if the key hasn't been requested yet
|
|
1065
|
+
*/
|
|
1066
|
+
declare function getEncryptionKey(address: string): Promise<CryptoKey>;
|
|
1058
1067
|
/**
|
|
1059
1068
|
* Encrypts data using AES-GCM with the stored encryption key.
|
|
1060
1069
|
*
|
|
@@ -1423,12 +1432,38 @@ declare function generateCompositeKey(namespace: string, key: string): string;
|
|
|
1423
1432
|
declare function generateUniqueKey(namespace: string, key: string, value: string): string;
|
|
1424
1433
|
|
|
1425
1434
|
type ChatRole = "user" | "assistant" | "system";
|
|
1435
|
+
/**
|
|
1436
|
+
* Metadata for files attached to messages.
|
|
1437
|
+
*
|
|
1438
|
+
* Note the distinction between `url` and `sourceUrl`:
|
|
1439
|
+
* - `url`: Content URL that gets sent to the AI as part of the message (e.g., data URIs for user uploads)
|
|
1440
|
+
* - `sourceUrl`: Original external URL for locally-cached files (for lookup only, never sent to AI)
|
|
1441
|
+
*/
|
|
1426
1442
|
interface FileMetadata {
|
|
1443
|
+
/** Unique identifier for the file (used as OPFS key for cached files) */
|
|
1427
1444
|
id: string;
|
|
1445
|
+
/** Display name of the file */
|
|
1428
1446
|
name: string;
|
|
1447
|
+
/** MIME type (e.g., "image/png") */
|
|
1429
1448
|
type: string;
|
|
1449
|
+
/** File size in bytes */
|
|
1430
1450
|
size: number;
|
|
1451
|
+
/**
|
|
1452
|
+
* Content URL to include when sending this message to the AI.
|
|
1453
|
+
* When present, this URL is added as an `image_url` content part.
|
|
1454
|
+
* Typically used for user-uploaded files (data URIs) that should be sent with the message.
|
|
1455
|
+
*
|
|
1456
|
+
* NOT used for MCP-cached files - those use `sourceUrl` for lookup and render from OPFS.
|
|
1457
|
+
*/
|
|
1431
1458
|
url?: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* Original external URL for files downloaded and cached locally (e.g., from MCP R2).
|
|
1461
|
+
* Used purely for URL→OPFS mapping to enable fallback when the source returns 404.
|
|
1462
|
+
*
|
|
1463
|
+
* This is metadata for local lookup only - it is NOT sent to the AI or rendered directly.
|
|
1464
|
+
* The file content is served from OPFS using the `id` field.
|
|
1465
|
+
*/
|
|
1466
|
+
sourceUrl?: string;
|
|
1432
1467
|
}
|
|
1433
1468
|
interface ChatCompletionUsage {
|
|
1434
1469
|
promptTokens?: number;
|
|
@@ -1744,6 +1779,39 @@ declare class Conversation extends Model {
|
|
|
1744
1779
|
isDeleted: boolean;
|
|
1745
1780
|
}
|
|
1746
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* Replace a URL in content with an MCP_IMAGE placeholder.
|
|
1784
|
+
* This is used to swap external URLs with locally-stored file references.
|
|
1785
|
+
*
|
|
1786
|
+
* @param content - The message content containing the URL
|
|
1787
|
+
* @param url - The URL to replace
|
|
1788
|
+
* @param fileId - The OPFS file ID to reference
|
|
1789
|
+
* @returns The content with the URL replaced by ![MCP_IMAGE:fileId]
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* ```ts
|
|
1793
|
+
* // Replace a URL that returned 404 with local file reference
|
|
1794
|
+
* const newContent = replaceUrlWithMCPPlaceholder(
|
|
1795
|
+
* message.content,
|
|
1796
|
+
* "https://example.com/image.png",
|
|
1797
|
+
* "abc-123-def"
|
|
1798
|
+
* );
|
|
1799
|
+
* await updateMessage(message.uniqueId, { content: newContent });
|
|
1800
|
+
* ```
|
|
1801
|
+
*/
|
|
1802
|
+
declare function replaceUrlWithMCPPlaceholder(content: string, url: string, fileId: string): string;
|
|
1803
|
+
/**
|
|
1804
|
+
* Find the OPFS file ID for a given source URL from a message's files.
|
|
1805
|
+
* Used to look up local file storage when an external URL fails (e.g., 404).
|
|
1806
|
+
*
|
|
1807
|
+
* @param files - Array of FileMetadata from a stored message
|
|
1808
|
+
* @param sourceUrl - The original URL to look up
|
|
1809
|
+
* @returns The file ID if found, or undefined
|
|
1810
|
+
*/
|
|
1811
|
+
declare function findFileIdBySourceUrl(files: {
|
|
1812
|
+
id: string;
|
|
1813
|
+
sourceUrl?: string;
|
|
1814
|
+
}[] | undefined, sourceUrl: string): string | undefined;
|
|
1747
1815
|
/**
|
|
1748
1816
|
* Options for useChatStorage hook (React version)
|
|
1749
1817
|
*
|
|
@@ -1757,6 +1825,18 @@ interface UseChatStorageOptions extends BaseUseChatStorageOptions {
|
|
|
1757
1825
|
* - "completions": OpenAI Chat Completions API (wider model compatibility)
|
|
1758
1826
|
*/
|
|
1759
1827
|
apiType?: ApiType;
|
|
1828
|
+
/**
|
|
1829
|
+
* Wallet address for encrypted file storage.
|
|
1830
|
+
* When provided, MCP-generated images are automatically encrypted and stored
|
|
1831
|
+
* in OPFS using wallet-derived keys. Messages are returned with working blob URLs.
|
|
1832
|
+
*
|
|
1833
|
+
* Requires:
|
|
1834
|
+
* - OPFS browser support
|
|
1835
|
+
* - Encryption key to be requested via `requestEncryptionKey` first
|
|
1836
|
+
*
|
|
1837
|
+
* When not provided, falls back to the `writeFile` callback in sendMessage args.
|
|
1838
|
+
*/
|
|
1839
|
+
walletAddress?: string;
|
|
1760
1840
|
}
|
|
1761
1841
|
/**
|
|
1762
1842
|
* Arguments for sendMessage with storage (React version)
|
|
@@ -1923,6 +2003,84 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
1923
2003
|
*/
|
|
1924
2004
|
declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
|
|
1925
2005
|
|
|
2006
|
+
/**
|
|
2007
|
+
* Checks if the browser supports OPFS.
|
|
2008
|
+
*/
|
|
2009
|
+
declare function isOPFSSupported(): boolean;
|
|
2010
|
+
/**
|
|
2011
|
+
* File metadata stored alongside encrypted content.
|
|
2012
|
+
*/
|
|
2013
|
+
interface StoredFileMetadata {
|
|
2014
|
+
id: string;
|
|
2015
|
+
name: string;
|
|
2016
|
+
type: string;
|
|
2017
|
+
size: number;
|
|
2018
|
+
sourceUrl?: string;
|
|
2019
|
+
createdAt: number;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Writes an encrypted file to OPFS.
|
|
2023
|
+
*
|
|
2024
|
+
* @param fileId - Unique identifier for the file
|
|
2025
|
+
* @param blob - The file content
|
|
2026
|
+
* @param encryptionKey - CryptoKey for encryption
|
|
2027
|
+
* @param metadata - Optional metadata (name, type, sourceUrl)
|
|
2028
|
+
*/
|
|
2029
|
+
declare function writeEncryptedFile(fileId: string, blob: Blob, encryptionKey: CryptoKey, metadata?: {
|
|
2030
|
+
name?: string;
|
|
2031
|
+
sourceUrl?: string;
|
|
2032
|
+
}): Promise<void>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Reads and decrypts a file from OPFS.
|
|
2035
|
+
*
|
|
2036
|
+
* @param fileId - The file identifier
|
|
2037
|
+
* @param encryptionKey - CryptoKey for decryption
|
|
2038
|
+
* @returns The decrypted blob, or null if not found
|
|
2039
|
+
*/
|
|
2040
|
+
declare function readEncryptedFile(fileId: string, encryptionKey: CryptoKey): Promise<{
|
|
2041
|
+
blob: Blob;
|
|
2042
|
+
metadata: StoredFileMetadata;
|
|
2043
|
+
} | null>;
|
|
2044
|
+
/**
|
|
2045
|
+
* Deletes a file from OPFS.
|
|
2046
|
+
*
|
|
2047
|
+
* @param fileId - The file identifier
|
|
2048
|
+
*/
|
|
2049
|
+
declare function deleteEncryptedFile(fileId: string): Promise<void>;
|
|
2050
|
+
/**
|
|
2051
|
+
* Checks if a file exists in OPFS.
|
|
2052
|
+
*
|
|
2053
|
+
* @param fileId - The file identifier
|
|
2054
|
+
*/
|
|
2055
|
+
declare function fileExists(fileId: string): Promise<boolean>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Manager for blob URLs to prevent memory leaks.
|
|
2058
|
+
* Tracks active blob URLs and provides cleanup functionality.
|
|
2059
|
+
*/
|
|
2060
|
+
declare class BlobUrlManager {
|
|
2061
|
+
private activeUrls;
|
|
2062
|
+
/**
|
|
2063
|
+
* Creates a blob URL for a file and tracks it.
|
|
2064
|
+
*/
|
|
2065
|
+
createUrl(fileId: string, blob: Blob): string;
|
|
2066
|
+
/**
|
|
2067
|
+
* Gets the active blob URL for a file, if any.
|
|
2068
|
+
*/
|
|
2069
|
+
getUrl(fileId: string): string | undefined;
|
|
2070
|
+
/**
|
|
2071
|
+
* Revokes a blob URL and removes it from tracking.
|
|
2072
|
+
*/
|
|
2073
|
+
revokeUrl(fileId: string): void;
|
|
2074
|
+
/**
|
|
2075
|
+
* Revokes all tracked blob URLs.
|
|
2076
|
+
*/
|
|
2077
|
+
revokeAll(): void;
|
|
2078
|
+
/**
|
|
2079
|
+
* Gets the count of active blob URLs.
|
|
2080
|
+
*/
|
|
2081
|
+
get size(): number;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1926
2084
|
/**
|
|
1927
2085
|
* Combined WatermelonDB schema for all SDK storage modules.
|
|
1928
2086
|
*
|
|
@@ -3742,4 +3900,4 @@ declare function storeDriveToken(accessToken: string, expiresIn?: number, refres
|
|
|
3742
3900
|
*/
|
|
3743
3901
|
declare function hasDriveCredentials(): boolean;
|
|
3744
3902
|
|
|
3745
|
-
export { DEFAULT_CONVERSATIONS_FOLDER as BACKUP_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as BACKUP_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER as BACKUP_ICLOUD_FOLDER, type BackupAuthContextValue, BackupAuthProvider, type BackupAuthProviderProps, type BackupOperationOptions, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateUserPreferenceOptions, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_DROPBOX_FOLDER, DEFAULT_BACKUP_FOLDER as DEFAULT_ICLOUD_BACKUP_FOLDER, DEFAULT_PERSONALITY_SETTINGS, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type EmbeddedWalletSignerFn, type FileMetadata, type GoogleDriveAuthContextValue, GoogleDriveAuthProvider, type GoogleDriveAuthProviderProps, type GoogleDriveExportResult, type GoogleDriveImportResult, type ICloudAuthContextValue, ICloudAuthProvider, type ICloudAuthProviderProps, type ICloudExportResult, type ICloudImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type ProfileUpdate, type ProgressCallback, type ProviderAuthState, type ProviderBackupState, SLIDER_CONFIG, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type StoredUserPreference, UserPreference as StoredUserPreferenceModel, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UpdateUserPreferenceOptions, type UseBackupOptions, type UseBackupResult, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseEncryptionResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseICloudBackupOptions, type UseICloudBackupResult, type UseImageGenerationResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseModelsResult, type UseOCRResult, type UsePdfResult, type UseSearchResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearAllEncryptionKeys, clearAllKeyPairs, clearCalendarToken, clearDriveToken, clearToken as clearDropboxToken, clearEncryptionKey, clearGoogleDriveToken, clearICloudAuth, clearKeyPair, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, exportPublicKey, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getAndClearCalendarPendingMessage, getAndClearCalendarReturnUrl, getAndClearDrivePendingMessage, getAndClearDriveReturnUrl, getCalendarAccessToken, getDriveAccessToken, getGoogleDriveStoredToken, getValidCalendarToken, getValidDriveToken, handleCalendarCallback, handleDriveCallback, hasCalendarCredentials, hasDriveCredentials, hasDropboxCredentials, hasEncryptionKey, hasGoogleDriveCredentials, hasICloudCredentials, hasKeyPair, isCalendarCallback, isDriveCallback, memoryStorageSchema, refreshCalendarToken, refreshDriveToken, requestEncryptionKey, requestKeyPair, revokeCalendarToken, revokeDriveToken, sdkMigrations, sdkModelClasses, sdkSchema, settingsStorageSchema, startCalendarAuth, startDriveAuth, storeCalendarPendingMessage, storeCalendarReturnUrl, storeCalendarToken, storeDrivePendingMessage, storeDriveReturnUrl, storeDriveToken, useBackup, useBackupAuth, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveAuth, useGoogleDriveBackup, useICloudAuth, useICloudBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings, userPreferencesStorageSchema };
|
|
3903
|
+
export { DEFAULT_CONVERSATIONS_FOLDER as BACKUP_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as BACKUP_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER as BACKUP_ICLOUD_FOLDER, type BackupAuthContextValue, BackupAuthProvider, type BackupAuthProviderProps, type BackupOperationOptions, BlobUrlManager, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateUserPreferenceOptions, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_DROPBOX_FOLDER, DEFAULT_BACKUP_FOLDER as DEFAULT_ICLOUD_BACKUP_FOLDER, DEFAULT_PERSONALITY_SETTINGS, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type EmbeddedWalletSignerFn, type FileMetadata, type GoogleDriveAuthContextValue, GoogleDriveAuthProvider, type GoogleDriveAuthProviderProps, type GoogleDriveExportResult, type GoogleDriveImportResult, type ICloudAuthContextValue, ICloudAuthProvider, type ICloudAuthProviderProps, type ICloudExportResult, type ICloudImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type ProfileUpdate, type ProgressCallback, type ProviderAuthState, type ProviderBackupState, SLIDER_CONFIG, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type StoredUserPreference, UserPreference as StoredUserPreferenceModel, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UpdateUserPreferenceOptions, type UseBackupOptions, type UseBackupResult, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseEncryptionResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseICloudBackupOptions, type UseICloudBackupResult, type UseImageGenerationResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseModelsResult, type UseOCRResult, type UsePdfResult, type UseSearchResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearAllEncryptionKeys, clearAllKeyPairs, clearCalendarToken, clearDriveToken, clearToken as clearDropboxToken, clearEncryptionKey, clearGoogleDriveToken, clearICloudAuth, clearKeyPair, createMemoryContextSystemMessage, decryptData, decryptDataBytes, deleteEncryptedFile, encryptData, exportPublicKey, extractConversationContext, fileExists, findFileIdBySourceUrl, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getAndClearCalendarPendingMessage, getAndClearCalendarReturnUrl, getAndClearDrivePendingMessage, getAndClearDriveReturnUrl, getCalendarAccessToken, getDriveAccessToken, getEncryptionKey, getGoogleDriveStoredToken, getValidCalendarToken, getValidDriveToken, handleCalendarCallback, handleDriveCallback, hasCalendarCredentials, hasDriveCredentials, hasDropboxCredentials, hasEncryptionKey, hasGoogleDriveCredentials, hasICloudCredentials, hasKeyPair, isCalendarCallback, isDriveCallback, isOPFSSupported, memoryStorageSchema, readEncryptedFile, refreshCalendarToken, refreshDriveToken, replaceUrlWithMCPPlaceholder, requestEncryptionKey, requestKeyPair, revokeCalendarToken, revokeDriveToken, sdkMigrations, sdkModelClasses, sdkSchema, settingsStorageSchema, startCalendarAuth, startDriveAuth, storeCalendarPendingMessage, storeCalendarReturnUrl, storeCalendarToken, storeDrivePendingMessage, storeDriveReturnUrl, storeDriveToken, useBackup, useBackupAuth, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveAuth, useGoogleDriveBackup, useICloudAuth, useICloudBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings, userPreferencesStorageSchema, writeEncryptedFile };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1055,6 +1055,15 @@ declare function clearEncryptionKey(address: string): void;
|
|
|
1055
1055
|
* Clears all encryption keys from memory
|
|
1056
1056
|
*/
|
|
1057
1057
|
declare function clearAllEncryptionKeys(): void;
|
|
1058
|
+
/**
|
|
1059
|
+
* Gets the encryption key from in-memory storage and imports it as a CryptoKey.
|
|
1060
|
+
* The key must have been previously requested via requestEncryptionKey.
|
|
1061
|
+
*
|
|
1062
|
+
* @param address - The wallet address
|
|
1063
|
+
* @returns The CryptoKey for AES-GCM encryption/decryption
|
|
1064
|
+
* @throws Error if the key hasn't been requested yet
|
|
1065
|
+
*/
|
|
1066
|
+
declare function getEncryptionKey(address: string): Promise<CryptoKey>;
|
|
1058
1067
|
/**
|
|
1059
1068
|
* Encrypts data using AES-GCM with the stored encryption key.
|
|
1060
1069
|
*
|
|
@@ -1423,12 +1432,38 @@ declare function generateCompositeKey(namespace: string, key: string): string;
|
|
|
1423
1432
|
declare function generateUniqueKey(namespace: string, key: string, value: string): string;
|
|
1424
1433
|
|
|
1425
1434
|
type ChatRole = "user" | "assistant" | "system";
|
|
1435
|
+
/**
|
|
1436
|
+
* Metadata for files attached to messages.
|
|
1437
|
+
*
|
|
1438
|
+
* Note the distinction between `url` and `sourceUrl`:
|
|
1439
|
+
* - `url`: Content URL that gets sent to the AI as part of the message (e.g., data URIs for user uploads)
|
|
1440
|
+
* - `sourceUrl`: Original external URL for locally-cached files (for lookup only, never sent to AI)
|
|
1441
|
+
*/
|
|
1426
1442
|
interface FileMetadata {
|
|
1443
|
+
/** Unique identifier for the file (used as OPFS key for cached files) */
|
|
1427
1444
|
id: string;
|
|
1445
|
+
/** Display name of the file */
|
|
1428
1446
|
name: string;
|
|
1447
|
+
/** MIME type (e.g., "image/png") */
|
|
1429
1448
|
type: string;
|
|
1449
|
+
/** File size in bytes */
|
|
1430
1450
|
size: number;
|
|
1451
|
+
/**
|
|
1452
|
+
* Content URL to include when sending this message to the AI.
|
|
1453
|
+
* When present, this URL is added as an `image_url` content part.
|
|
1454
|
+
* Typically used for user-uploaded files (data URIs) that should be sent with the message.
|
|
1455
|
+
*
|
|
1456
|
+
* NOT used for MCP-cached files - those use `sourceUrl` for lookup and render from OPFS.
|
|
1457
|
+
*/
|
|
1431
1458
|
url?: string;
|
|
1459
|
+
/**
|
|
1460
|
+
* Original external URL for files downloaded and cached locally (e.g., from MCP R2).
|
|
1461
|
+
* Used purely for URL→OPFS mapping to enable fallback when the source returns 404.
|
|
1462
|
+
*
|
|
1463
|
+
* This is metadata for local lookup only - it is NOT sent to the AI or rendered directly.
|
|
1464
|
+
* The file content is served from OPFS using the `id` field.
|
|
1465
|
+
*/
|
|
1466
|
+
sourceUrl?: string;
|
|
1432
1467
|
}
|
|
1433
1468
|
interface ChatCompletionUsage {
|
|
1434
1469
|
promptTokens?: number;
|
|
@@ -1744,6 +1779,39 @@ declare class Conversation extends Model {
|
|
|
1744
1779
|
isDeleted: boolean;
|
|
1745
1780
|
}
|
|
1746
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* Replace a URL in content with an MCP_IMAGE placeholder.
|
|
1784
|
+
* This is used to swap external URLs with locally-stored file references.
|
|
1785
|
+
*
|
|
1786
|
+
* @param content - The message content containing the URL
|
|
1787
|
+
* @param url - The URL to replace
|
|
1788
|
+
* @param fileId - The OPFS file ID to reference
|
|
1789
|
+
* @returns The content with the URL replaced by ![MCP_IMAGE:fileId]
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* ```ts
|
|
1793
|
+
* // Replace a URL that returned 404 with local file reference
|
|
1794
|
+
* const newContent = replaceUrlWithMCPPlaceholder(
|
|
1795
|
+
* message.content,
|
|
1796
|
+
* "https://example.com/image.png",
|
|
1797
|
+
* "abc-123-def"
|
|
1798
|
+
* );
|
|
1799
|
+
* await updateMessage(message.uniqueId, { content: newContent });
|
|
1800
|
+
* ```
|
|
1801
|
+
*/
|
|
1802
|
+
declare function replaceUrlWithMCPPlaceholder(content: string, url: string, fileId: string): string;
|
|
1803
|
+
/**
|
|
1804
|
+
* Find the OPFS file ID for a given source URL from a message's files.
|
|
1805
|
+
* Used to look up local file storage when an external URL fails (e.g., 404).
|
|
1806
|
+
*
|
|
1807
|
+
* @param files - Array of FileMetadata from a stored message
|
|
1808
|
+
* @param sourceUrl - The original URL to look up
|
|
1809
|
+
* @returns The file ID if found, or undefined
|
|
1810
|
+
*/
|
|
1811
|
+
declare function findFileIdBySourceUrl(files: {
|
|
1812
|
+
id: string;
|
|
1813
|
+
sourceUrl?: string;
|
|
1814
|
+
}[] | undefined, sourceUrl: string): string | undefined;
|
|
1747
1815
|
/**
|
|
1748
1816
|
* Options for useChatStorage hook (React version)
|
|
1749
1817
|
*
|
|
@@ -1757,6 +1825,18 @@ interface UseChatStorageOptions extends BaseUseChatStorageOptions {
|
|
|
1757
1825
|
* - "completions": OpenAI Chat Completions API (wider model compatibility)
|
|
1758
1826
|
*/
|
|
1759
1827
|
apiType?: ApiType;
|
|
1828
|
+
/**
|
|
1829
|
+
* Wallet address for encrypted file storage.
|
|
1830
|
+
* When provided, MCP-generated images are automatically encrypted and stored
|
|
1831
|
+
* in OPFS using wallet-derived keys. Messages are returned with working blob URLs.
|
|
1832
|
+
*
|
|
1833
|
+
* Requires:
|
|
1834
|
+
* - OPFS browser support
|
|
1835
|
+
* - Encryption key to be requested via `requestEncryptionKey` first
|
|
1836
|
+
*
|
|
1837
|
+
* When not provided, falls back to the `writeFile` callback in sendMessage args.
|
|
1838
|
+
*/
|
|
1839
|
+
walletAddress?: string;
|
|
1760
1840
|
}
|
|
1761
1841
|
/**
|
|
1762
1842
|
* Arguments for sendMessage with storage (React version)
|
|
@@ -1923,6 +2003,84 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
|
|
|
1923
2003
|
*/
|
|
1924
2004
|
declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
|
|
1925
2005
|
|
|
2006
|
+
/**
|
|
2007
|
+
* Checks if the browser supports OPFS.
|
|
2008
|
+
*/
|
|
2009
|
+
declare function isOPFSSupported(): boolean;
|
|
2010
|
+
/**
|
|
2011
|
+
* File metadata stored alongside encrypted content.
|
|
2012
|
+
*/
|
|
2013
|
+
interface StoredFileMetadata {
|
|
2014
|
+
id: string;
|
|
2015
|
+
name: string;
|
|
2016
|
+
type: string;
|
|
2017
|
+
size: number;
|
|
2018
|
+
sourceUrl?: string;
|
|
2019
|
+
createdAt: number;
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Writes an encrypted file to OPFS.
|
|
2023
|
+
*
|
|
2024
|
+
* @param fileId - Unique identifier for the file
|
|
2025
|
+
* @param blob - The file content
|
|
2026
|
+
* @param encryptionKey - CryptoKey for encryption
|
|
2027
|
+
* @param metadata - Optional metadata (name, type, sourceUrl)
|
|
2028
|
+
*/
|
|
2029
|
+
declare function writeEncryptedFile(fileId: string, blob: Blob, encryptionKey: CryptoKey, metadata?: {
|
|
2030
|
+
name?: string;
|
|
2031
|
+
sourceUrl?: string;
|
|
2032
|
+
}): Promise<void>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Reads and decrypts a file from OPFS.
|
|
2035
|
+
*
|
|
2036
|
+
* @param fileId - The file identifier
|
|
2037
|
+
* @param encryptionKey - CryptoKey for decryption
|
|
2038
|
+
* @returns The decrypted blob, or null if not found
|
|
2039
|
+
*/
|
|
2040
|
+
declare function readEncryptedFile(fileId: string, encryptionKey: CryptoKey): Promise<{
|
|
2041
|
+
blob: Blob;
|
|
2042
|
+
metadata: StoredFileMetadata;
|
|
2043
|
+
} | null>;
|
|
2044
|
+
/**
|
|
2045
|
+
* Deletes a file from OPFS.
|
|
2046
|
+
*
|
|
2047
|
+
* @param fileId - The file identifier
|
|
2048
|
+
*/
|
|
2049
|
+
declare function deleteEncryptedFile(fileId: string): Promise<void>;
|
|
2050
|
+
/**
|
|
2051
|
+
* Checks if a file exists in OPFS.
|
|
2052
|
+
*
|
|
2053
|
+
* @param fileId - The file identifier
|
|
2054
|
+
*/
|
|
2055
|
+
declare function fileExists(fileId: string): Promise<boolean>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Manager for blob URLs to prevent memory leaks.
|
|
2058
|
+
* Tracks active blob URLs and provides cleanup functionality.
|
|
2059
|
+
*/
|
|
2060
|
+
declare class BlobUrlManager {
|
|
2061
|
+
private activeUrls;
|
|
2062
|
+
/**
|
|
2063
|
+
* Creates a blob URL for a file and tracks it.
|
|
2064
|
+
*/
|
|
2065
|
+
createUrl(fileId: string, blob: Blob): string;
|
|
2066
|
+
/**
|
|
2067
|
+
* Gets the active blob URL for a file, if any.
|
|
2068
|
+
*/
|
|
2069
|
+
getUrl(fileId: string): string | undefined;
|
|
2070
|
+
/**
|
|
2071
|
+
* Revokes a blob URL and removes it from tracking.
|
|
2072
|
+
*/
|
|
2073
|
+
revokeUrl(fileId: string): void;
|
|
2074
|
+
/**
|
|
2075
|
+
* Revokes all tracked blob URLs.
|
|
2076
|
+
*/
|
|
2077
|
+
revokeAll(): void;
|
|
2078
|
+
/**
|
|
2079
|
+
* Gets the count of active blob URLs.
|
|
2080
|
+
*/
|
|
2081
|
+
get size(): number;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1926
2084
|
/**
|
|
1927
2085
|
* Combined WatermelonDB schema for all SDK storage modules.
|
|
1928
2086
|
*
|
|
@@ -3742,4 +3900,4 @@ declare function storeDriveToken(accessToken: string, expiresIn?: number, refres
|
|
|
3742
3900
|
*/
|
|
3743
3901
|
declare function hasDriveCredentials(): boolean;
|
|
3744
3902
|
|
|
3745
|
-
export { DEFAULT_CONVERSATIONS_FOLDER as BACKUP_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as BACKUP_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER as BACKUP_ICLOUD_FOLDER, type BackupAuthContextValue, BackupAuthProvider, type BackupAuthProviderProps, type BackupOperationOptions, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateUserPreferenceOptions, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_DROPBOX_FOLDER, DEFAULT_BACKUP_FOLDER as DEFAULT_ICLOUD_BACKUP_FOLDER, DEFAULT_PERSONALITY_SETTINGS, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type EmbeddedWalletSignerFn, type FileMetadata, type GoogleDriveAuthContextValue, GoogleDriveAuthProvider, type GoogleDriveAuthProviderProps, type GoogleDriveExportResult, type GoogleDriveImportResult, type ICloudAuthContextValue, ICloudAuthProvider, type ICloudAuthProviderProps, type ICloudExportResult, type ICloudImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type ProfileUpdate, type ProgressCallback, type ProviderAuthState, type ProviderBackupState, SLIDER_CONFIG, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type StoredUserPreference, UserPreference as StoredUserPreferenceModel, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UpdateUserPreferenceOptions, type UseBackupOptions, type UseBackupResult, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseEncryptionResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseICloudBackupOptions, type UseICloudBackupResult, type UseImageGenerationResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseModelsResult, type UseOCRResult, type UsePdfResult, type UseSearchResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearAllEncryptionKeys, clearAllKeyPairs, clearCalendarToken, clearDriveToken, clearToken as clearDropboxToken, clearEncryptionKey, clearGoogleDriveToken, clearICloudAuth, clearKeyPair, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, exportPublicKey, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getAndClearCalendarPendingMessage, getAndClearCalendarReturnUrl, getAndClearDrivePendingMessage, getAndClearDriveReturnUrl, getCalendarAccessToken, getDriveAccessToken, getGoogleDriveStoredToken, getValidCalendarToken, getValidDriveToken, handleCalendarCallback, handleDriveCallback, hasCalendarCredentials, hasDriveCredentials, hasDropboxCredentials, hasEncryptionKey, hasGoogleDriveCredentials, hasICloudCredentials, hasKeyPair, isCalendarCallback, isDriveCallback, memoryStorageSchema, refreshCalendarToken, refreshDriveToken, requestEncryptionKey, requestKeyPair, revokeCalendarToken, revokeDriveToken, sdkMigrations, sdkModelClasses, sdkSchema, settingsStorageSchema, startCalendarAuth, startDriveAuth, storeCalendarPendingMessage, storeCalendarReturnUrl, storeCalendarToken, storeDrivePendingMessage, storeDriveReturnUrl, storeDriveToken, useBackup, useBackupAuth, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveAuth, useGoogleDriveBackup, useICloudAuth, useICloudBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings, userPreferencesStorageSchema };
|
|
3903
|
+
export { DEFAULT_CONVERSATIONS_FOLDER as BACKUP_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as BACKUP_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER as BACKUP_ICLOUD_FOLDER, type BackupAuthContextValue, BackupAuthProvider, type BackupAuthProviderProps, type BackupOperationOptions, BlobUrlManager, Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateUserPreferenceOptions, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_BACKUP_FOLDER$1 as DEFAULT_DROPBOX_FOLDER, DEFAULT_BACKUP_FOLDER as DEFAULT_ICLOUD_BACKUP_FOLDER, DEFAULT_PERSONALITY_SETTINGS, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type EmbeddedWalletSignerFn, type FileMetadata, type GoogleDriveAuthContextValue, GoogleDriveAuthProvider, type GoogleDriveAuthProviderProps, type GoogleDriveExportResult, type GoogleDriveImportResult, type ICloudAuthContextValue, ICloudAuthProvider, type ICloudAuthProviderProps, type ICloudExportResult, type ICloudImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type ProfileUpdate, type ProgressCallback, type ProviderAuthState, type ProviderBackupState, SLIDER_CONFIG, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type StoredUserPreference, UserPreference as StoredUserPreferenceModel, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UpdateUserPreferenceOptions, type UseBackupOptions, type UseBackupResult, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseEncryptionResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseICloudBackupOptions, type UseICloudBackupResult, type UseImageGenerationResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseModelsResult, type UseOCRResult, type UsePdfResult, type UseSearchResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearAllEncryptionKeys, clearAllKeyPairs, clearCalendarToken, clearDriveToken, clearToken as clearDropboxToken, clearEncryptionKey, clearGoogleDriveToken, clearICloudAuth, clearKeyPair, createMemoryContextSystemMessage, decryptData, decryptDataBytes, deleteEncryptedFile, encryptData, exportPublicKey, extractConversationContext, fileExists, findFileIdBySourceUrl, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getAndClearCalendarPendingMessage, getAndClearCalendarReturnUrl, getAndClearDrivePendingMessage, getAndClearDriveReturnUrl, getCalendarAccessToken, getDriveAccessToken, getEncryptionKey, getGoogleDriveStoredToken, getValidCalendarToken, getValidDriveToken, handleCalendarCallback, handleDriveCallback, hasCalendarCredentials, hasDriveCredentials, hasDropboxCredentials, hasEncryptionKey, hasGoogleDriveCredentials, hasICloudCredentials, hasKeyPair, isCalendarCallback, isDriveCallback, isOPFSSupported, memoryStorageSchema, readEncryptedFile, refreshCalendarToken, refreshDriveToken, replaceUrlWithMCPPlaceholder, requestEncryptionKey, requestKeyPair, revokeCalendarToken, revokeDriveToken, sdkMigrations, sdkModelClasses, sdkSchema, settingsStorageSchema, startCalendarAuth, startDriveAuth, storeCalendarPendingMessage, storeCalendarReturnUrl, storeCalendarToken, storeDrivePendingMessage, storeDriveReturnUrl, storeDriveToken, useBackup, useBackupAuth, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveAuth, useGoogleDriveBackup, useICloudAuth, useICloudBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings, userPreferencesStorageSchema, writeEncryptedFile };
|