@reverbia/sdk 1.0.0-next.20251217134403 → 1.0.0-next.20251217144909

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.
@@ -2,6 +2,7 @@ import { Database, Model } from '@nozbe/watermelondb';
2
2
  import * as _nozbe_watermelondb_Schema_migrations from '@nozbe/watermelondb/Schema/migrations';
3
3
  import * as _nozbe_watermelondb_Schema from '@nozbe/watermelondb/Schema';
4
4
  import { Associations } from '@nozbe/watermelondb/Model';
5
+ import { ReactNode, JSX } from 'react';
5
6
 
6
7
  /**
7
8
  * ExtraFields contains additional metadata
@@ -236,6 +237,10 @@ type LlmapiModel = {
236
237
  * MaxOutputTokens is the maximum output tokens
237
238
  */
238
239
  max_output_tokens?: number;
240
+ /**
241
+ * Modalities is a list of supported modalities (e.g., ["llm", "vision"])
242
+ */
243
+ modalities?: Array<string>;
239
244
  /**
240
245
  * Name is the human-readable model name (optional)
241
246
  */
@@ -630,224 +635,148 @@ declare function useEncryption(signMessage: SignMessageFn): {
630
635
  requestEncryptionKey: (walletAddress: string) => Promise<void>;
631
636
  };
632
637
 
633
- /**
634
- * Message role type
635
- */
638
+ declare const chatStorageSchema: Readonly<{
639
+ version: _nozbe_watermelondb_Schema.SchemaVersion;
640
+ tables: _nozbe_watermelondb_Schema.TableMap;
641
+ unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
642
+ }>;
643
+ declare const chatStorageMigrations: Readonly<{
644
+ validated: true;
645
+ minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
646
+ maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
647
+ sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
648
+ }>;
649
+
636
650
  type ChatRole = "user" | "assistant" | "system";
637
- /**
638
- * File metadata for attached files
639
- */
640
651
  interface FileMetadata {
641
- /** Unique file identifier */
642
652
  id: string;
643
- /** Original file name */
644
653
  name: string;
645
- /** MIME type */
646
654
  type: string;
647
- /** File size in bytes */
648
655
  size: number;
649
- /** Optional URL or data URI */
650
656
  url?: string;
651
657
  }
652
- /**
653
- * Token usage and cost information
654
- */
655
658
  interface ChatCompletionUsage {
656
- /** Number of tokens in the prompt */
657
659
  promptTokens?: number;
658
- /** Number of tokens in the completion */
659
660
  completionTokens?: number;
660
- /** Total tokens used */
661
661
  totalTokens?: number;
662
- /** Cost in micro-dollars (USD × 1,000,000) */
663
662
  costMicroUsd?: number;
664
663
  }
665
- /**
666
- * Web search source information
667
- */
668
664
  interface SearchSource {
669
- /** Source title */
670
665
  title?: string;
671
- /** Source URL */
672
666
  url?: string;
673
- /** Text snippet from the source */
674
667
  snippet?: string;
675
- /** Publication or last updated date */
676
668
  date?: string;
677
669
  }
678
- /**
679
- * Stored message record (what gets persisted to the database)
680
- */
681
670
  interface StoredMessage {
682
- /** Primary key, unique message identifier (WatermelonDB auto-generated) */
683
671
  uniqueId: string;
684
- /** Sequential message ID within conversation */
685
672
  messageId: number;
686
- /** Links message to its conversation */
687
673
  conversationId: string;
688
- /** Who sent the message */
689
674
  role: ChatRole;
690
- /** The message text */
691
675
  content: string;
692
- /** LLM model used */
693
676
  model?: string;
694
- /** Optional attached files */
695
677
  files?: FileMetadata[];
696
- /** When the message was created */
697
678
  createdAt: Date;
698
- /** When the message was last updated */
699
679
  updatedAt: Date;
700
- /** Embedding vector for semantic search */
701
680
  vector?: number[];
702
- /** Model used to generate embedding */
703
681
  embeddingModel?: string;
704
- /** Token counts and cost */
705
682
  usage?: ChatCompletionUsage;
706
- /** Web search sources */
707
683
  sources?: SearchSource[];
708
- /** Response time in seconds */
709
684
  responseDuration?: number;
710
- /** Whether the message generation was stopped by the user */
711
685
  wasStopped?: boolean;
712
686
  }
713
- /**
714
- * Stored conversation record
715
- */
716
687
  interface StoredConversation {
717
- /** Primary key (WatermelonDB auto-generated) */
718
688
  uniqueId: string;
719
- /** Unique conversation identifier */
720
689
  conversationId: string;
721
- /** Conversation title */
722
690
  title: string;
723
- /** When the conversation was created */
724
691
  createdAt: Date;
725
- /** When the conversation was last updated */
726
692
  updatedAt: Date;
727
- /** Soft delete flag */
728
693
  isDeleted: boolean;
729
694
  }
730
- /**
731
- * Stored message with similarity score (for search results)
732
- */
733
695
  interface StoredMessageWithSimilarity extends StoredMessage {
734
- /** Cosine similarity score (0 to 1) */
735
696
  similarity: number;
736
697
  }
737
- /**
738
- * Options for creating a new message
739
- */
740
698
  interface CreateMessageOptions {
741
- /** Conversation ID to add the message to */
742
699
  conversationId: string;
743
- /** Message role */
744
700
  role: ChatRole;
745
- /** Message content */
746
701
  content: string;
747
- /** LLM model used (for assistant messages) */
748
702
  model?: string;
749
- /** Attached files */
750
703
  files?: FileMetadata[];
751
- /** Token usage information */
752
704
  usage?: ChatCompletionUsage;
753
- /** Web search sources */
754
705
  sources?: SearchSource[];
755
- /** Response duration in seconds */
756
706
  responseDuration?: number;
757
- /** Embedding vector for semantic search */
758
707
  vector?: number[];
759
- /** Model used to generate the embedding */
760
708
  embeddingModel?: string;
761
- /** Whether the message generation was stopped by the user */
762
709
  wasStopped?: boolean;
763
710
  }
764
- /**
765
- * Options for creating a new conversation
766
- */
767
711
  interface CreateConversationOptions {
768
- /** Custom conversation ID (auto-generated if not provided) */
769
712
  conversationId?: string;
770
- /** Conversation title */
771
713
  title?: string;
772
714
  }
773
- /**
774
- * Base options for useChatStorage hook (shared between React and Expo)
775
- */
776
715
  interface BaseUseChatStorageOptions {
777
- /** WatermelonDB database instance */
778
716
  database: Database;
779
- /** Current conversation ID (will create new if not provided) */
780
717
  conversationId?: string;
781
- /** Auto-create conversation if it doesn't exist (default: true) */
782
718
  autoCreateConversation?: boolean;
783
- /** Default title for auto-created conversations */
784
719
  defaultConversationTitle?: string;
785
- /** Authentication token getter */
786
720
  getToken?: () => Promise<string | null>;
787
- /** Base URL for API requests */
788
721
  baseUrl?: string;
789
- /** Callback when data chunk is received */
790
722
  onData?: (chunk: string) => void;
791
- /** Callback when chat completion finishes */
792
723
  onFinish?: (response: LlmapiChatCompletionResponse) => void;
793
- /** Callback when an error occurs */
794
724
  onError?: (error: Error) => void;
795
725
  }
796
- /**
797
- * Base arguments for sendMessage with storage (shared between React and Expo)
798
- */
799
726
  interface BaseSendMessageWithStorageArgs {
800
- /** Message content to send */
801
727
  content: string;
802
- /** Model to use for the completion */
803
728
  model?: string;
804
- /** Previous messages to include (if not using stored messages) */
805
729
  messages?: LlmapiMessage[];
806
- /** Whether to include stored messages from conversation */
807
730
  includeHistory?: boolean;
808
- /** Maximum number of history messages to include (default: 50) */
809
731
  maxHistoryMessages?: number;
810
- /** Attached files */
811
732
  files?: FileMetadata[];
812
- /** Per-request data callback */
813
733
  onData?: (chunk: string) => void;
814
- /** Memory context to inject as system message (formatted memories from useMemoryStorage) */
815
734
  memoryContext?: string;
816
735
  }
817
- /**
818
- * Base result returned by useChatStorage hook (shared between React and Expo)
819
- */
820
736
  interface BaseUseChatStorageResult {
821
- /** Whether a chat request is in progress */
822
737
  isLoading: boolean;
823
- /** Stop the current request */
824
738
  stop: () => void;
825
- /** Current conversation ID */
826
739
  conversationId: string | null;
827
- /** Set the current conversation ID */
828
740
  setConversationId: (id: string | null) => void;
829
- /** Create a new conversation */
830
741
  createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
831
- /** Get a conversation by ID */
832
742
  getConversation: (id: string) => Promise<StoredConversation | null>;
833
- /** Get all conversations (excluding soft-deleted) */
834
743
  getConversations: () => Promise<StoredConversation[]>;
835
- /** Update conversation title. Returns true if updated, false if not found. */
836
744
  updateConversationTitle: (id: string, title: string) => Promise<boolean>;
837
- /** Soft delete a conversation. Returns true if deleted, false if not found. */
838
745
  deleteConversation: (id: string) => Promise<boolean>;
839
- /** Get messages for a conversation */
840
746
  getMessages: (conversationId: string) => Promise<StoredMessage[]>;
841
- /** Get message count for a conversation */
842
747
  getMessageCount: (conversationId: string) => Promise<number>;
843
- /** Clear all messages in a conversation */
844
748
  clearMessages: (conversationId: string) => Promise<void>;
845
749
  }
846
- /**
847
- * Generate a unique ID for conversations
848
- */
849
750
  declare function generateConversationId(): string;
850
751
 
752
+ declare class Message extends Model {
753
+ static table: string;
754
+ static associations: Associations;
755
+ messageId: number;
756
+ conversationId: string;
757
+ role: ChatRole;
758
+ content: string;
759
+ model?: string;
760
+ files?: FileMetadata[];
761
+ createdAt: Date;
762
+ updatedAt: Date;
763
+ vector?: number[];
764
+ embeddingModel?: string;
765
+ usage?: ChatCompletionUsage;
766
+ sources?: SearchSource[];
767
+ responseDuration?: number;
768
+ wasStopped?: boolean;
769
+ }
770
+ declare class Conversation extends Model {
771
+ static table: string;
772
+ static associations: Associations;
773
+ conversationId: string;
774
+ title: string;
775
+ createdAt: Date;
776
+ updatedAt: Date;
777
+ isDeleted: boolean;
778
+ }
779
+
851
780
  /**
852
781
  * Options for useChatStorage hook (React version)
853
782
  *
@@ -975,83 +904,11 @@ interface UseChatStorageResult extends BaseUseChatStorageResult {
975
904
  */
976
905
  declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
977
906
 
978
- /**
979
- * WatermelonDB schema for chat storage
980
- *
981
- * Defines two tables:
982
- * - history: Chat messages with metadata
983
- * - conversations: Conversation metadata
984
- */
985
- declare const chatStorageSchema: Readonly<{
907
+ declare const memoryStorageSchema: Readonly<{
986
908
  version: _nozbe_watermelondb_Schema.SchemaVersion;
987
909
  tables: _nozbe_watermelondb_Schema.TableMap;
988
910
  unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
989
911
  }>;
990
- /**
991
- * Schema migrations
992
- */
993
- declare const chatStorageMigrations: Readonly<{
994
- validated: true;
995
- minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
996
- maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
997
- sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
998
- }>;
999
-
1000
- /**
1001
- * Message model representing a single chat message
1002
- *
1003
- * Note: This model uses raw column accessors instead of decorators
1004
- * for better TypeScript compatibility without requiring legacy decorators.
1005
- */
1006
- declare class Message extends Model {
1007
- static table: string;
1008
- static associations: Associations;
1009
- /** Sequential message ID within conversation */
1010
- get messageId(): number;
1011
- /** Links message to its conversation */
1012
- get conversationId(): string;
1013
- /** Who sent the message: 'user' | 'assistant' | 'system' */
1014
- get role(): ChatRole;
1015
- /** The message text content */
1016
- get content(): string;
1017
- /** LLM model used (e.g., GPT-4, Claude) */
1018
- get model(): string | undefined;
1019
- /** Optional attached files */
1020
- get files(): FileMetadata[] | undefined;
1021
- /** Created timestamp */
1022
- get createdAt(): Date;
1023
- /** Updated timestamp */
1024
- get updatedAt(): Date;
1025
- /** Embedding vector for semantic search */
1026
- get vector(): number[] | undefined;
1027
- /** Model used to generate embedding */
1028
- get embeddingModel(): string | undefined;
1029
- /** Token counts and cost */
1030
- get usage(): ChatCompletionUsage | undefined;
1031
- /** Web search sources */
1032
- get sources(): SearchSource[] | undefined;
1033
- /** Response time in seconds */
1034
- get responseDuration(): number | undefined;
1035
- /** Whether the message generation was stopped by the user */
1036
- get wasStopped(): boolean;
1037
- }
1038
- /**
1039
- * Conversation model representing conversation metadata
1040
- */
1041
- declare class Conversation extends Model {
1042
- static table: string;
1043
- static associations: Associations;
1044
- /** Unique conversation identifier */
1045
- get conversationId(): string;
1046
- /** Conversation title */
1047
- get title(): string;
1048
- /** Created timestamp */
1049
- get createdAt(): Date;
1050
- /** Updated timestamp */
1051
- get updatedAt(): Date;
1052
- /** Soft delete flag */
1053
- get isDeleted(): boolean;
1054
- }
1055
912
 
1056
913
  interface MemoryItem$1 {
1057
914
  type: "identity" | "preference" | "project" | "skill" | "constraint";
@@ -1066,13 +923,7 @@ interface MemoryExtractionResult {
1066
923
  items: MemoryItem$1[];
1067
924
  }
1068
925
 
1069
- /**
1070
- * Memory type classification
1071
- */
1072
926
  type MemoryType = "identity" | "preference" | "project" | "skill" | "constraint";
1073
- /**
1074
- * Base memory item (matches existing MemoryItem from memory/service.ts)
1075
- */
1076
927
  interface MemoryItem {
1077
928
  type: MemoryType;
1078
929
  namespace: string;
@@ -1082,137 +933,37 @@ interface MemoryItem {
1082
933
  confidence: number;
1083
934
  pii: boolean;
1084
935
  }
1085
- /**
1086
- * Stored memory record (what gets persisted to the database)
1087
- */
1088
- interface StoredMemory {
1089
- /** Primary key, unique memory identifier (WatermelonDB auto-generated) */
936
+ interface CreateMemoryOptions extends MemoryItem {
937
+ embedding?: number[];
938
+ embeddingModel?: string;
939
+ }
940
+ type UpdateMemoryOptions = Partial<CreateMemoryOptions>;
941
+ interface StoredMemory extends MemoryItem {
1090
942
  uniqueId: string;
1091
- /** Memory type classification */
1092
- type: MemoryType;
1093
- /** Namespace for grouping related memories */
1094
- namespace: string;
1095
- /** Key within the namespace */
1096
- key: string;
1097
- /** The memory value/content */
1098
- value: string;
1099
- /** Raw evidence from which this memory was extracted */
1100
- rawEvidence: string;
1101
- /** Confidence score (0-1) */
1102
- confidence: number;
1103
- /** Whether this memory contains PII */
1104
- pii: boolean;
1105
- /** Composite key (namespace:key) for efficient lookups */
1106
943
  compositeKey: string;
1107
- /** Unique key (namespace:key:value) for deduplication */
1108
944
  uniqueKey: string;
1109
- /** ISO timestamp */
1110
945
  createdAt: Date;
1111
- /** ISO timestamp */
1112
946
  updatedAt: Date;
1113
- /** Embedding vector for semantic search */
1114
947
  embedding?: number[];
1115
- /** Model used to generate embedding */
1116
948
  embeddingModel?: string;
1117
- /** Soft delete flag */
1118
949
  isDeleted: boolean;
1119
950
  }
1120
- /**
1121
- * Memory with similarity score (returned from semantic search)
1122
- */
1123
951
  interface StoredMemoryWithSimilarity extends StoredMemory {
1124
- /** Cosine similarity score (0-1) */
1125
952
  similarity: number;
1126
953
  }
1127
- /**
1128
- * Options for creating a new memory
1129
- */
1130
- interface CreateMemoryOptions {
1131
- /** Memory type */
1132
- type: MemoryType;
1133
- /** Namespace for grouping */
1134
- namespace: string;
1135
- /** Key within namespace */
1136
- key: string;
1137
- /** Memory value/content */
1138
- value: string;
1139
- /** Raw evidence text */
1140
- rawEvidence: string;
1141
- /** Confidence score (0-1) */
1142
- confidence: number;
1143
- /** Whether this contains PII */
1144
- pii: boolean;
1145
- /** Optional embedding vector */
1146
- embedding?: number[];
1147
- /** Optional embedding model name */
1148
- embeddingModel?: string;
1149
- }
1150
- /**
1151
- * Options for updating a memory
1152
- */
1153
- interface UpdateMemoryOptions {
1154
- /** Memory type */
1155
- type?: MemoryType;
1156
- /** Namespace for grouping */
1157
- namespace?: string;
1158
- /** Key within namespace */
1159
- key?: string;
1160
- /** Memory value/content */
1161
- value?: string;
1162
- /** Raw evidence text */
1163
- rawEvidence?: string;
1164
- /** Confidence score (0-1) */
1165
- confidence?: number;
1166
- /** Whether this contains PII */
1167
- pii?: boolean;
1168
- /** Optional embedding vector */
1169
- embedding?: number[];
1170
- /** Optional embedding model name */
1171
- embeddingModel?: string;
1172
- }
1173
- /**
1174
- * Base options for useMemoryStorage hook (shared between React and Expo)
1175
- */
1176
954
  interface BaseUseMemoryStorageOptions {
1177
- /** WatermelonDB database instance */
1178
955
  database: Database;
1179
- /** The model to use for fact extraction (default: "openai/gpt-4o") */
1180
956
  completionsModel?: string;
1181
- /**
1182
- * The model to use for generating embeddings
1183
- * For local: default is "Snowflake/snowflake-arctic-embed-xs"
1184
- * For api: default is "openai/text-embedding-3-small"
1185
- * Set to null to disable embedding generation
1186
- */
1187
957
  embeddingModel?: string | null;
1188
- /**
1189
- * The provider to use for generating embeddings (default: "local")
1190
- * "local": Uses a local HuggingFace model (in-browser)
1191
- * "api": Uses the backend API
1192
- */
1193
958
  embeddingProvider?: "local" | "api";
1194
- /** Whether to automatically generate embeddings for extracted memories (default: true) */
1195
959
  generateEmbeddings?: boolean;
1196
- /** Callback when facts are extracted */
1197
960
  onFactsExtracted?: (facts: MemoryExtractionResult) => void;
1198
- /** Custom function to get auth token for API calls */
1199
961
  getToken?: () => Promise<string | null>;
1200
- /** Optional base URL for the API requests */
1201
962
  baseUrl?: string;
1202
963
  }
1203
- /**
1204
- * Base result returned by useMemoryStorage hook (shared between React and Expo)
1205
- */
1206
964
  interface BaseUseMemoryStorageResult {
1207
- /** Current memories in state (reactive) */
1208
965
  memories: StoredMemory[];
1209
- /** Refresh memories from storage */
1210
966
  refreshMemories: () => Promise<void>;
1211
- /**
1212
- * Extract memories from messages and store them
1213
- * @param options Messages and model to use for extraction
1214
- * @returns Extraction result or null if failed
1215
- */
1216
967
  extractMemoriesFromMessage: (options: {
1217
968
  messages: Array<{
1218
969
  role: string;
@@ -1220,89 +971,40 @@ interface BaseUseMemoryStorageResult {
1220
971
  }>;
1221
972
  model?: string;
1222
973
  }) => Promise<MemoryExtractionResult | null>;
1223
- /**
1224
- * Search for similar memories using semantic search
1225
- * @param query The text query to search for
1226
- * @param limit Maximum number of results (default: 10)
1227
- * @param minSimilarity Minimum similarity threshold 0-1 (default: 0.6)
1228
- * @returns Array of memories with similarity scores, sorted by relevance
1229
- */
1230
974
  searchMemories: (query: string, limit?: number, minSimilarity?: number) => Promise<StoredMemoryWithSimilarity[]>;
1231
- /**
1232
- * Get all memories stored in the database
1233
- * @returns Array of all stored memories
1234
- */
1235
975
  fetchAllMemories: () => Promise<StoredMemory[]>;
1236
- /**
1237
- * Get memories filtered by namespace
1238
- * @param namespace The namespace to filter by
1239
- * @returns Array of memories in the specified namespace
1240
- */
1241
976
  fetchMemoriesByNamespace: (namespace: string) => Promise<StoredMemory[]>;
1242
- /**
1243
- * Get memories by namespace and key
1244
- * @param namespace The namespace
1245
- * @param key The key within the namespace
1246
- * @returns Array of memories matching the namespace and key
1247
- */
1248
977
  fetchMemoriesByKey: (namespace: string, key: string) => Promise<StoredMemory[]>;
1249
- /**
1250
- * Get a memory by its unique ID
1251
- * @param id The memory unique ID
1252
- * @returns The memory or null if not found
1253
- */
1254
978
  getMemoryById: (id: string) => Promise<StoredMemory | null>;
1255
- /**
1256
- * Save a single memory to storage
1257
- * @param memory The memory to save
1258
- * @returns The stored memory
1259
- */
1260
979
  saveMemory: (memory: CreateMemoryOptions) => Promise<StoredMemory>;
1261
- /**
1262
- * Save multiple memories to storage
1263
- * @param memories Array of memories to save
1264
- * @returns Array of stored memories
1265
- */
1266
980
  saveMemories: (memories: CreateMemoryOptions[]) => Promise<StoredMemory[]>;
1267
- /**
1268
- * Update a memory by its ID
1269
- * @param id The memory ID
1270
- * @param updates Partial memory fields to update
1271
- * @returns The updated memory or null if not found
1272
- */
1273
981
  updateMemory: (id: string, updates: UpdateMemoryOptions) => Promise<StoredMemory | null>;
1274
- /**
1275
- * Delete a specific memory by namespace, key, and value
1276
- * @param namespace The namespace
1277
- * @param key The key
1278
- * @param value The value
1279
- */
1280
982
  removeMemory: (namespace: string, key: string, value: string) => Promise<void>;
1281
- /**
1282
- * Delete a memory by its ID (soft delete)
1283
- * @param id The memory ID
1284
- */
1285
983
  removeMemoryById: (id: string) => Promise<void>;
1286
- /**
1287
- * Delete all memories by namespace and key
1288
- * @param namespace The namespace
1289
- * @param key The key
1290
- */
1291
984
  removeMemories: (namespace: string, key: string) => Promise<void>;
1292
- /**
1293
- * Clear all memories from storage
1294
- */
1295
985
  clearMemories: () => Promise<void>;
1296
986
  }
1297
- /**
1298
- * Generate composite key from namespace and key
1299
- */
1300
987
  declare function generateCompositeKey(namespace: string, key: string): string;
1301
- /**
1302
- * Generate unique key from namespace, key, and value
1303
- */
1304
988
  declare function generateUniqueKey(namespace: string, key: string, value: string): string;
1305
989
 
990
+ declare class Memory extends Model {
991
+ static table: string;
992
+ type: MemoryType;
993
+ namespace: string;
994
+ key: string;
995
+ value: string;
996
+ rawEvidence: string;
997
+ confidence: number;
998
+ pii: boolean;
999
+ compositeKey: string;
1000
+ uniqueKey: string;
1001
+ createdAt: Date;
1002
+ updatedAt: Date;
1003
+ embedding?: number[];
1004
+ embeddingModel?: string;
1005
+ isDeleted: boolean;
1006
+ }
1007
+
1306
1008
  /**
1307
1009
  * Options for useMemoryStorage hook (React version)
1308
1010
  *
@@ -1362,105 +1064,39 @@ type UseMemoryStorageResult = BaseUseMemoryStorageResult;
1362
1064
  */
1363
1065
  declare function useMemoryStorage(options: UseMemoryStorageOptions): UseMemoryStorageResult;
1364
1066
 
1365
- /**
1366
- * WatermelonDB schema for memory storage
1367
- *
1368
- * Defines the memories table for storing extracted user memories
1369
- * with support for vector embeddings for semantic search.
1370
- */
1371
- declare const memoryStorageSchema: Readonly<{
1067
+ declare const settingsStorageSchema: Readonly<{
1372
1068
  version: _nozbe_watermelondb_Schema.SchemaVersion;
1373
1069
  tables: _nozbe_watermelondb_Schema.TableMap;
1374
1070
  unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1375
1071
  }>;
1376
1072
 
1377
- /**
1378
- * Memory model representing a single extracted memory
1379
- *
1380
- * Note: This model uses raw column accessors instead of decorators
1381
- * for better TypeScript compatibility without requiring legacy decorators.
1382
- */
1383
- declare class Memory extends Model {
1073
+ declare class ModelPreference extends Model {
1384
1074
  static table: string;
1385
- /** Memory type classification */
1386
- get type(): MemoryType;
1387
- /** Namespace for grouping related memories */
1388
- get namespace(): string;
1389
- /** Key within the namespace */
1390
- get key(): string;
1391
- /** The memory value/content */
1392
- get value(): string;
1393
- /** Raw evidence from which this memory was extracted */
1394
- get rawEvidence(): string;
1395
- /** Confidence score (0-1) */
1396
- get confidence(): number;
1397
- /** Whether this memory contains PII */
1398
- get pii(): boolean;
1399
- /** Composite key (namespace:key) for efficient lookups */
1400
- get compositeKey(): string;
1401
- /** Unique key (namespace:key:value) for deduplication */
1402
- get uniqueKey(): string;
1403
- /** Created timestamp */
1404
- get createdAt(): Date;
1405
- /** Updated timestamp */
1406
- get updatedAt(): Date;
1407
- /** Embedding vector for semantic search */
1408
- get embedding(): number[] | undefined;
1409
- /** Model used to generate embedding */
1410
- get embeddingModel(): string | undefined;
1411
- /** Soft delete flag */
1412
- get isDeleted(): boolean;
1075
+ walletAddress: string;
1076
+ models?: string;
1413
1077
  }
1414
1078
 
1415
- /**
1416
- * Stored model preference record (what gets persisted to the database)
1417
- */
1418
1079
  interface StoredModelPreference {
1419
- /** Primary key (WatermelonDB auto-generated) */
1420
1080
  uniqueId: string;
1421
- /** User's wallet address */
1422
1081
  walletAddress: string;
1423
- /** Preferred model identifiers */
1424
1082
  models?: string;
1425
1083
  }
1426
- /**
1427
- * Options for creating a new model preference
1428
- */
1429
1084
  interface CreateModelPreferenceOptions {
1430
- /** User's wallet address */
1431
1085
  walletAddress: string;
1432
- /** Preferred model identifiers */
1433
1086
  models?: string;
1434
1087
  }
1435
- /**
1436
- * Options for updating a model preference
1437
- */
1438
1088
  interface UpdateModelPreferenceOptions {
1439
- /** New preferred model identifiers */
1440
1089
  models?: string;
1441
1090
  }
1442
- /**
1443
- * Base options for useSettings hook
1444
- */
1445
1091
  interface BaseUseSettingsOptions {
1446
- /** WatermelonDB database instance */
1447
1092
  database: Database;
1448
- /** User's wallet address */
1449
1093
  walletAddress?: string;
1450
1094
  }
1451
- /**
1452
- * Base result returned by useSettings hook
1453
- */
1454
1095
  interface BaseUseSettingsResult {
1455
- /** Current model preference */
1456
1096
  modelPreference: StoredModelPreference | null;
1457
- /** Whether the settings are loading */
1458
1097
  isLoading: boolean;
1459
- /** Get model preference by wallet address. Throws on error. */
1460
1098
  getModelPreference: (walletAddress: string) => Promise<StoredModelPreference | null>;
1461
- /** Create or update model preference. Throws on error. */
1462
1099
  setModelPreference: (walletAddress: string, models?: string) => Promise<StoredModelPreference | null>;
1463
- /** Delete model preference. Throws on error. */
1464
1100
  deleteModelPreference: (walletAddress: string) => Promise<boolean>;
1465
1101
  }
1466
1102
 
@@ -1519,32 +1155,6 @@ interface UseSettingsResult extends BaseUseSettingsResult {
1519
1155
  */
1520
1156
  declare function useSettings(options: UseSettingsOptions): UseSettingsResult;
1521
1157
 
1522
- /**
1523
- * WatermelonDB schema for settings storage
1524
- *
1525
- * * Defines one table::
1526
- * - modelPreferences: Model preferences metadata
1527
- */
1528
- declare const settingsStorageSchema: Readonly<{
1529
- version: _nozbe_watermelondb_Schema.SchemaVersion;
1530
- tables: _nozbe_watermelondb_Schema.TableMap;
1531
- unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1532
- }>;
1533
-
1534
- /**
1535
- * ModelPreference model representing user model preferences
1536
- *
1537
- * Note: This model uses raw column accessors instead of decorators
1538
- * for better TypeScript compatibility without requiring legacy decorators.
1539
- */
1540
- declare class ModelPreference extends Model {
1541
- static table: string;
1542
- /** User's wallet address */
1543
- get walletAddress(): string;
1544
- /** Preferred model identifier */
1545
- get models(): string | undefined;
1546
- }
1547
-
1548
1158
  interface PdfFile {
1549
1159
  url: string;
1550
1160
  mediaType?: string;
@@ -1757,4 +1367,352 @@ declare function executeTool(tool: ClientTool, params: Record<string, unknown>):
1757
1367
  error?: string;
1758
1368
  }>;
1759
1369
 
1760
- export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, DEFAULT_TOOL_SELECTOR_MODEL, type FileMetadata, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, 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 ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, settingsStorageSchema, useChat, useChatStorage, useEncryption, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings };
1370
+ /**
1371
+ * Dropbox API utilities
1372
+ *
1373
+ * Uses Dropbox HTTP API for file operations.
1374
+ * Dropbox uses OAuth 2.0 with PKCE for browser apps.
1375
+ */
1376
+ /** Default folder path for Dropbox backups */
1377
+ declare const DEFAULT_BACKUP_FOLDER = "/ai-chat-app/conversations";
1378
+
1379
+ /**
1380
+ * Dropbox Backup Implementation
1381
+ *
1382
+ * Generic backup/restore functionality for Dropbox storage.
1383
+ * Works directly with WatermelonDB database.
1384
+ */
1385
+
1386
+ interface DropboxExportResult {
1387
+ success: boolean;
1388
+ uploaded: number;
1389
+ skipped: number;
1390
+ total: number;
1391
+ }
1392
+ interface DropboxImportResult {
1393
+ success: boolean;
1394
+ restored: number;
1395
+ failed: number;
1396
+ total: number;
1397
+ /** True if no backups were found in Dropbox */
1398
+ noBackupsFound?: boolean;
1399
+ }
1400
+
1401
+ /**
1402
+ * Options for useDropboxBackup hook
1403
+ */
1404
+ interface UseDropboxBackupOptions {
1405
+ /** WatermelonDB database instance */
1406
+ database: Database;
1407
+ /** Current user address (null if not signed in) */
1408
+ userAddress: string | null;
1409
+ /** Request encryption key for the user address */
1410
+ requestEncryptionKey: (address: string) => Promise<void>;
1411
+ /** Export a conversation to an encrypted blob */
1412
+ exportConversation: (conversationId: string, userAddress: string) => Promise<{
1413
+ success: boolean;
1414
+ blob?: Blob;
1415
+ }>;
1416
+ /** Import a conversation from an encrypted blob */
1417
+ importConversation: (blob: Blob, userAddress: string) => Promise<{
1418
+ success: boolean;
1419
+ }>;
1420
+ /** Dropbox folder path for backups (default: '/ai-chat-app/conversations') */
1421
+ backupFolder?: string;
1422
+ }
1423
+ /**
1424
+ * Result returned by useDropboxBackup hook
1425
+ */
1426
+ interface UseDropboxBackupResult {
1427
+ /** Backup all conversations to Dropbox */
1428
+ backup: (options?: {
1429
+ onProgress?: (current: number, total: number) => void;
1430
+ }) => Promise<DropboxExportResult | {
1431
+ error: string;
1432
+ }>;
1433
+ /** Restore conversations from Dropbox */
1434
+ restore: (options?: {
1435
+ onProgress?: (current: number, total: number) => void;
1436
+ }) => Promise<DropboxImportResult | {
1437
+ error: string;
1438
+ }>;
1439
+ /** Whether Dropbox is configured */
1440
+ isConfigured: boolean;
1441
+ /** Whether user has a Dropbox token */
1442
+ isAuthenticated: boolean;
1443
+ }
1444
+ /**
1445
+ * React hook for Dropbox backup and restore functionality.
1446
+ *
1447
+ * This hook provides methods to backup conversations to Dropbox and restore them.
1448
+ * It handles all the logic for checking timestamps, skipping unchanged files,
1449
+ * authentication, and managing the backup/restore process.
1450
+ *
1451
+ * Must be used within a DropboxAuthProvider.
1452
+ *
1453
+ * @example
1454
+ * ```tsx
1455
+ * import { useDropboxBackup } from "@reverbia/sdk/react";
1456
+ *
1457
+ * function BackupButton() {
1458
+ * const { backup, restore, isConfigured } = useDropboxBackup({
1459
+ * database,
1460
+ * userAddress,
1461
+ * requestEncryptionKey,
1462
+ * exportConversation,
1463
+ * importConversation,
1464
+ * });
1465
+ *
1466
+ * const handleBackup = async () => {
1467
+ * const result = await backup({
1468
+ * onProgress: (current, total) => {
1469
+ * console.log(`Progress: ${current}/${total}`);
1470
+ * },
1471
+ * });
1472
+ *
1473
+ * if ("error" in result) {
1474
+ * console.error(result.error);
1475
+ * } else {
1476
+ * console.log(`Uploaded: ${result.uploaded}, Skipped: ${result.skipped}`);
1477
+ * }
1478
+ * };
1479
+ *
1480
+ * return <button onClick={handleBackup} disabled={!isConfigured}>Backup</button>;
1481
+ * }
1482
+ * ```
1483
+ *
1484
+ * @category Hooks
1485
+ */
1486
+ declare function useDropboxBackup(options: UseDropboxBackupOptions): UseDropboxBackupResult;
1487
+
1488
+ /**
1489
+ * Dropbox OAuth 2.0 with PKCE
1490
+ *
1491
+ * Flow:
1492
+ * 1. Generate code_verifier and code_challenge
1493
+ * 2. Redirect user to Dropbox authorization URL
1494
+ * 3. User authorizes and is redirected back with authorization code
1495
+ * 4. Exchange code for access token using code_verifier
1496
+ */
1497
+ /**
1498
+ * Get the stored access token from session storage
1499
+ */
1500
+ declare function getStoredToken(): string | null;
1501
+ /**
1502
+ * Store access token in session storage
1503
+ */
1504
+ declare function storeToken(token: string): void;
1505
+ /**
1506
+ * Clear stored access token
1507
+ */
1508
+ declare function clearToken(): void;
1509
+
1510
+ /**
1511
+ * Props for DropboxAuthProvider
1512
+ */
1513
+ interface DropboxAuthProviderProps {
1514
+ /** Dropbox App Key (from Dropbox Developer Console) */
1515
+ appKey: string | undefined;
1516
+ /** OAuth callback path (e.g., "/auth/dropbox/callback") */
1517
+ callbackPath?: string;
1518
+ /** Children to render */
1519
+ children: ReactNode;
1520
+ }
1521
+ /**
1522
+ * Context value for Dropbox authentication
1523
+ */
1524
+ interface DropboxAuthContextValue {
1525
+ /** Current access token (null if not authenticated) */
1526
+ accessToken: string | null;
1527
+ /** Whether user has authenticated with Dropbox */
1528
+ isAuthenticated: boolean;
1529
+ /** Whether Dropbox is configured (app key exists) */
1530
+ isConfigured: boolean;
1531
+ /** Request Dropbox access - returns token or redirects to OAuth */
1532
+ requestAccess: () => Promise<string>;
1533
+ /** Clear stored token and log out */
1534
+ logout: () => void;
1535
+ }
1536
+ /**
1537
+ * Provider component for Dropbox OAuth authentication.
1538
+ *
1539
+ * Wrap your app with this provider to enable Dropbox authentication.
1540
+ * It handles the OAuth 2.0 PKCE flow automatically.
1541
+ *
1542
+ * @example
1543
+ * ```tsx
1544
+ * import { DropboxAuthProvider } from "@reverbia/sdk/react";
1545
+ *
1546
+ * function App() {
1547
+ * return (
1548
+ * <DropboxAuthProvider
1549
+ * appKey={process.env.NEXT_PUBLIC_DROPBOX_APP_KEY}
1550
+ * callbackPath="/auth/dropbox/callback"
1551
+ * >
1552
+ * <MyApp />
1553
+ * </DropboxAuthProvider>
1554
+ * );
1555
+ * }
1556
+ * ```
1557
+ *
1558
+ * @category Components
1559
+ */
1560
+ declare function DropboxAuthProvider({ appKey, callbackPath, children, }: DropboxAuthProviderProps): JSX.Element;
1561
+ /**
1562
+ * Hook to access Dropbox authentication state and methods.
1563
+ *
1564
+ * Must be used within a DropboxAuthProvider.
1565
+ *
1566
+ * @example
1567
+ * ```tsx
1568
+ * import { useDropboxAuth } from "@reverbia/sdk/react";
1569
+ *
1570
+ * function DropboxButton() {
1571
+ * const { isAuthenticated, isConfigured, requestAccess, logout } = useDropboxAuth();
1572
+ *
1573
+ * if (!isConfigured) {
1574
+ * return <p>Dropbox not configured</p>;
1575
+ * }
1576
+ *
1577
+ * if (isAuthenticated) {
1578
+ * return <button onClick={logout}>Disconnect Dropbox</button>;
1579
+ * }
1580
+ *
1581
+ * return <button onClick={requestAccess}>Connect Dropbox</button>;
1582
+ * }
1583
+ * ```
1584
+ *
1585
+ * @category Hooks
1586
+ */
1587
+ declare function useDropboxAuth(): DropboxAuthContextValue;
1588
+
1589
+ /**
1590
+ * Google Drive API utilities
1591
+ *
1592
+ * Uses Google Drive API v3 for file operations.
1593
+ * Requires an OAuth 2.0 access token with drive.file scope.
1594
+ */
1595
+ /** Default root folder name for backups */
1596
+ declare const DEFAULT_ROOT_FOLDER = "ai-chat-app";
1597
+ /** Default subfolder for conversation backups */
1598
+ declare const DEFAULT_CONVERSATIONS_FOLDER = "conversations";
1599
+
1600
+ /**
1601
+ * Google Drive Backup Implementation
1602
+ *
1603
+ * Generic backup/restore functionality for Google Drive storage.
1604
+ * Works directly with WatermelonDB database.
1605
+ */
1606
+
1607
+ interface GoogleDriveExportResult {
1608
+ success: boolean;
1609
+ uploaded: number;
1610
+ skipped: number;
1611
+ total: number;
1612
+ }
1613
+ interface GoogleDriveImportResult {
1614
+ success: boolean;
1615
+ restored: number;
1616
+ failed: number;
1617
+ total: number;
1618
+ /** True if no backups were found in Google Drive */
1619
+ noBackupsFound?: boolean;
1620
+ }
1621
+
1622
+ /**
1623
+ * Options for useGoogleDriveBackup hook
1624
+ */
1625
+ interface UseGoogleDriveBackupOptions {
1626
+ /** WatermelonDB database instance */
1627
+ database: Database;
1628
+ /** Current user address (null if not signed in) */
1629
+ userAddress: string | null;
1630
+ /** Current Google Drive access token (null if not authenticated) */
1631
+ accessToken: string | null;
1632
+ /** Request Google Drive access - returns access token */
1633
+ requestDriveAccess: () => Promise<string>;
1634
+ /** Request encryption key for the user address */
1635
+ requestEncryptionKey: (address: string) => Promise<void>;
1636
+ /** Export a conversation to an encrypted blob */
1637
+ exportConversation: (conversationId: string, userAddress: string) => Promise<{
1638
+ success: boolean;
1639
+ blob?: Blob;
1640
+ }>;
1641
+ /** Import a conversation from an encrypted blob */
1642
+ importConversation: (blob: Blob, userAddress: string) => Promise<{
1643
+ success: boolean;
1644
+ }>;
1645
+ /** Root folder name in Google Drive (default: 'ai-chat-app') */
1646
+ rootFolder?: string;
1647
+ /** Subfolder for conversations (default: 'conversations') */
1648
+ conversationsFolder?: string;
1649
+ }
1650
+ /**
1651
+ * Result returned by useGoogleDriveBackup hook
1652
+ */
1653
+ interface UseGoogleDriveBackupResult {
1654
+ /** Backup all conversations to Google Drive */
1655
+ backup: (options?: {
1656
+ onProgress?: (current: number, total: number) => void;
1657
+ }) => Promise<GoogleDriveExportResult | {
1658
+ error: string;
1659
+ }>;
1660
+ /** Restore conversations from Google Drive */
1661
+ restore: (options?: {
1662
+ onProgress?: (current: number, total: number) => void;
1663
+ }) => Promise<GoogleDriveImportResult | {
1664
+ error: string;
1665
+ }>;
1666
+ /** Whether user has a Google Drive token */
1667
+ isAuthenticated: boolean;
1668
+ }
1669
+ /**
1670
+ * React hook for Google Drive backup and restore functionality.
1671
+ *
1672
+ * This hook provides methods to backup conversations to Google Drive and restore them.
1673
+ * It handles all the logic for checking timestamps, skipping unchanged files,
1674
+ * and managing the backup/restore process.
1675
+ *
1676
+ * Unlike Dropbox, Google Drive auth requires browser-specific setup (Google Identity Services),
1677
+ * so the auth provider must be implemented in the app. This hook accepts the auth
1678
+ * callbacks as options.
1679
+ *
1680
+ * @example
1681
+ * ```tsx
1682
+ * import { useGoogleDriveBackup } from "@reverbia/sdk/react";
1683
+ *
1684
+ * function BackupButton() {
1685
+ * const { accessToken, requestDriveAccess } = useGoogleAccessToken();
1686
+ * const { backup, restore, isAuthenticated } = useGoogleDriveBackup({
1687
+ * database,
1688
+ * userAddress,
1689
+ * accessToken,
1690
+ * requestDriveAccess,
1691
+ * requestEncryptionKey,
1692
+ * exportConversation,
1693
+ * importConversation,
1694
+ * });
1695
+ *
1696
+ * const handleBackup = async () => {
1697
+ * const result = await backup({
1698
+ * onProgress: (current, total) => {
1699
+ * console.log(`Progress: ${current}/${total}`);
1700
+ * },
1701
+ * });
1702
+ *
1703
+ * if ("error" in result) {
1704
+ * console.error(result.error);
1705
+ * } else {
1706
+ * console.log(`Uploaded: ${result.uploaded}, Skipped: ${result.skipped}`);
1707
+ * }
1708
+ * };
1709
+ *
1710
+ * return <button onClick={handleBackup}>Backup</button>;
1711
+ * }
1712
+ * ```
1713
+ *
1714
+ * @category Hooks
1715
+ */
1716
+ declare function useGoogleDriveBackup(options: UseGoogleDriveBackupOptions): UseGoogleDriveBackupResult;
1717
+
1718
+ export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_TOOL_SELECTOR_MODEL, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type FileMetadata, type GoogleDriveExportResult, type GoogleDriveImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, 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 ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearToken as clearDropboxToken, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getStoredToken as getDropboxToken, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, settingsStorageSchema, storeToken as storeDropboxToken, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings };