@reverbia/sdk 1.0.0-next.20251212012743 → 1.0.0-next.20251215143604

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.
@@ -1,3 +1,7 @@
1
+ import { Database, Model } from '@nozbe/watermelondb';
2
+ import * as _nozbe_watermelondb_Schema from '@nozbe/watermelondb/Schema';
3
+ import { Associations } from '@nozbe/watermelondb/Model';
4
+
1
5
  /**
2
6
  * ExtraFields contains additional metadata
3
7
  */
@@ -379,6 +383,8 @@ type UseChatResult = BaseUseChatResult & {
379
383
  * - `sendMessage`: An async function to send chat messages
380
384
  * - `stop`: A function to abort the current request
381
385
  *
386
+ * @category Hooks
387
+ *
382
388
  * @example
383
389
  * ```tsx
384
390
  * const { isLoading, sendMessage, stop } = useChat({
@@ -397,6 +403,315 @@ type UseChatResult = BaseUseChatResult & {
397
403
  */
398
404
  declare function useChat(options?: UseChatOptions): UseChatResult;
399
405
 
406
+ /**
407
+ * Message role type
408
+ */
409
+ type ChatRole = "user" | "assistant" | "system";
410
+ /**
411
+ * File metadata for attached files
412
+ */
413
+ interface FileMetadata {
414
+ /** Unique file identifier */
415
+ id: string;
416
+ /** Original file name */
417
+ name: string;
418
+ /** MIME type */
419
+ type: string;
420
+ /** File size in bytes */
421
+ size: number;
422
+ /** Optional URL or data URI */
423
+ url?: string;
424
+ }
425
+ /**
426
+ * Token usage and cost information
427
+ */
428
+ interface ChatCompletionUsage {
429
+ /** Number of tokens in the prompt */
430
+ promptTokens?: number;
431
+ /** Number of tokens in the completion */
432
+ completionTokens?: number;
433
+ /** Total tokens used */
434
+ totalTokens?: number;
435
+ /** Cost in micro-dollars (USD × 1,000,000) */
436
+ costMicroUsd?: number;
437
+ }
438
+ /**
439
+ * Web search source information
440
+ */
441
+ interface SearchSource {
442
+ /** Source title */
443
+ title?: string;
444
+ /** Source URL */
445
+ url?: string;
446
+ /** Text snippet from the source */
447
+ snippet?: string;
448
+ /** Publication or last updated date */
449
+ date?: string;
450
+ }
451
+ /**
452
+ * Stored message record (what gets persisted to the database)
453
+ */
454
+ interface StoredMessage {
455
+ /** Primary key, unique message identifier (WatermelonDB auto-generated) */
456
+ uniqueId: string;
457
+ /** Sequential message ID within conversation */
458
+ messageId: number;
459
+ /** Links message to its conversation */
460
+ conversationId: string;
461
+ /** Who sent the message */
462
+ role: ChatRole;
463
+ /** The message text */
464
+ content: string;
465
+ /** LLM model used */
466
+ model?: string;
467
+ /** Optional attached files */
468
+ files?: FileMetadata[];
469
+ /** When the message was created */
470
+ createdAt: Date;
471
+ /** When the message was last updated */
472
+ updatedAt: Date;
473
+ /** Embedding vector for semantic search */
474
+ vector?: number[];
475
+ /** Model used to generate embedding */
476
+ embeddingModel?: string;
477
+ /** Token counts and cost */
478
+ usage?: ChatCompletionUsage;
479
+ /** Web search sources */
480
+ sources?: SearchSource[];
481
+ /** Response time in seconds */
482
+ responseDuration?: number;
483
+ }
484
+ /**
485
+ * Stored conversation record
486
+ */
487
+ interface StoredConversation {
488
+ /** Primary key (WatermelonDB auto-generated) */
489
+ uniqueId: string;
490
+ /** Unique conversation identifier */
491
+ conversationId: string;
492
+ /** Conversation title */
493
+ title: string;
494
+ /** When the conversation was created */
495
+ createdAt: Date;
496
+ /** When the conversation was last updated */
497
+ updatedAt: Date;
498
+ /** Soft delete flag */
499
+ isDeleted: boolean;
500
+ }
501
+ /**
502
+ * Stored message with similarity score (for search results)
503
+ */
504
+ interface StoredMessageWithSimilarity extends StoredMessage {
505
+ /** Cosine similarity score (0 to 1) */
506
+ similarity: number;
507
+ }
508
+ /**
509
+ * Options for creating a new message
510
+ */
511
+ interface CreateMessageOptions {
512
+ /** Conversation ID to add the message to */
513
+ conversationId: string;
514
+ /** Message role */
515
+ role: ChatRole;
516
+ /** Message content */
517
+ content: string;
518
+ /** LLM model used (for assistant messages) */
519
+ model?: string;
520
+ /** Attached files */
521
+ files?: FileMetadata[];
522
+ /** Token usage information */
523
+ usage?: ChatCompletionUsage;
524
+ /** Web search sources */
525
+ sources?: SearchSource[];
526
+ /** Response duration in seconds */
527
+ responseDuration?: number;
528
+ /** Embedding vector for semantic search */
529
+ vector?: number[];
530
+ /** Model used to generate the embedding */
531
+ embeddingModel?: string;
532
+ }
533
+ /**
534
+ * Options for creating a new conversation
535
+ */
536
+ interface CreateConversationOptions {
537
+ /** Custom conversation ID (auto-generated if not provided) */
538
+ conversationId?: string;
539
+ /** Conversation title */
540
+ title?: string;
541
+ }
542
+ /**
543
+ * Base options for useChatStorage hook (shared between React and Expo)
544
+ */
545
+ interface BaseUseChatStorageOptions {
546
+ /** WatermelonDB database instance */
547
+ database: Database;
548
+ /** Current conversation ID (will create new if not provided) */
549
+ conversationId?: string;
550
+ /** Auto-create conversation if it doesn't exist (default: true) */
551
+ autoCreateConversation?: boolean;
552
+ /** Default title for auto-created conversations */
553
+ defaultConversationTitle?: string;
554
+ /** Authentication token getter */
555
+ getToken?: () => Promise<string | null>;
556
+ /** Base URL for API requests */
557
+ baseUrl?: string;
558
+ /** Callback when data chunk is received */
559
+ onData?: (chunk: string) => void;
560
+ /** Callback when chat completion finishes */
561
+ onFinish?: (response: LlmapiChatCompletionResponse) => void;
562
+ /** Callback when an error occurs */
563
+ onError?: (error: Error) => void;
564
+ }
565
+ /**
566
+ * Base arguments for sendMessage with storage (shared between React and Expo)
567
+ */
568
+ interface BaseSendMessageWithStorageArgs {
569
+ /** Message content to send */
570
+ content: string;
571
+ /** Model to use for the completion */
572
+ model?: string;
573
+ /** Previous messages to include (if not using stored messages) */
574
+ messages?: LlmapiMessage[];
575
+ /** Whether to include stored messages from conversation */
576
+ includeHistory?: boolean;
577
+ /** Maximum number of history messages to include (default: 50) */
578
+ maxHistoryMessages?: number;
579
+ /** Attached files */
580
+ files?: FileMetadata[];
581
+ /** Per-request data callback */
582
+ onData?: (chunk: string) => void;
583
+ /** Memory context to inject as system message (formatted memories from useMemoryStorage) */
584
+ memoryContext?: string;
585
+ }
586
+ /**
587
+ * Base success result from sendMessage with storage
588
+ */
589
+ interface BaseSendMessageSuccessResult {
590
+ data: LlmapiChatCompletionResponse;
591
+ error: null;
592
+ userMessage: StoredMessage;
593
+ assistantMessage: StoredMessage;
594
+ }
595
+ /**
596
+ * Base error result from sendMessage with storage
597
+ */
598
+ interface BaseSendMessageErrorResult {
599
+ data: null;
600
+ error: string;
601
+ userMessage?: StoredMessage;
602
+ assistantMessage?: undefined;
603
+ }
604
+ /**
605
+ * Base result type from sendMessage with storage
606
+ */
607
+ type BaseSendMessageWithStorageResult = BaseSendMessageSuccessResult | BaseSendMessageErrorResult;
608
+ /**
609
+ * Base result returned by useChatStorage hook (shared between React and Expo)
610
+ */
611
+ interface BaseUseChatStorageResult {
612
+ /** Whether a chat request is in progress */
613
+ isLoading: boolean;
614
+ /** Stop the current request */
615
+ stop: () => void;
616
+ /** Current conversation ID */
617
+ conversationId: string | null;
618
+ /** Set the current conversation ID */
619
+ setConversationId: (id: string | null) => void;
620
+ /** Create a new conversation */
621
+ createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
622
+ /** Get a conversation by ID */
623
+ getConversation: (id: string) => Promise<StoredConversation | null>;
624
+ /** Get all conversations (excluding soft-deleted) */
625
+ getConversations: () => Promise<StoredConversation[]>;
626
+ /** Update conversation title. Returns true if updated, false if not found. */
627
+ updateConversationTitle: (id: string, title: string) => Promise<boolean>;
628
+ /** Soft delete a conversation. Returns true if deleted, false if not found. */
629
+ deleteConversation: (id: string) => Promise<boolean>;
630
+ /** Get messages for a conversation */
631
+ getMessages: (conversationId: string) => Promise<StoredMessage[]>;
632
+ /** Get message count for a conversation */
633
+ getMessageCount: (conversationId: string) => Promise<number>;
634
+ /** Clear all messages in a conversation */
635
+ clearMessages: (conversationId: string) => Promise<void>;
636
+ }
637
+ /**
638
+ * Generate a unique ID for conversations
639
+ */
640
+ declare function generateConversationId(): string;
641
+
642
+ /**
643
+ * Options for useChatStorage hook (Expo version)
644
+ *
645
+ * Uses the base options without React-specific features (no local chat, no tools).
646
+ */
647
+ type UseChatStorageOptions = BaseUseChatStorageOptions;
648
+ /**
649
+ * Arguments for sendMessage with storage (Expo version)
650
+ *
651
+ * Uses the base arguments without React-specific features (no runTools, no headers).
652
+ */
653
+ type SendMessageWithStorageArgs = BaseSendMessageWithStorageArgs;
654
+ /**
655
+ * Result from sendMessage with storage (Expo version)
656
+ *
657
+ * Uses the base result without tool execution information.
658
+ */
659
+ type SendMessageWithStorageResult = BaseSendMessageWithStorageResult;
660
+ /**
661
+ * Result returned by useChatStorage hook (Expo version)
662
+ *
663
+ * Extends base result with Expo-specific sendMessage signature.
664
+ */
665
+ interface UseChatStorageResult extends BaseUseChatStorageResult {
666
+ /** Send a message and automatically store it (Expo version) */
667
+ sendMessage: (args: SendMessageWithStorageArgs) => Promise<SendMessageWithStorageResult>;
668
+ }
669
+ /**
670
+ * A React hook that wraps useChat with automatic message persistence using WatermelonDB.
671
+ *
672
+ * **Expo/React Native version** - This is a lightweight version that only supports
673
+ * API-based chat completions. Local chat and client-side tools are not available.
674
+ *
675
+ * @param options - Configuration options
676
+ * @returns An object containing chat state, methods, and storage operations
677
+ *
678
+ * @example
679
+ * ```tsx
680
+ * import { Database } from '@nozbe/watermelondb';
681
+ * import { useChatStorage } from '@reverbia/sdk/expo';
682
+ *
683
+ * function ChatScreen({ database }: { database: Database }) {
684
+ * const {
685
+ * isLoading,
686
+ * sendMessage,
687
+ * conversationId,
688
+ * getMessages,
689
+ * } = useChatStorage({
690
+ * database,
691
+ * getToken: async () => getAuthToken(),
692
+ * onData: (chunk) => setResponse((prev) => prev + chunk),
693
+ * });
694
+ *
695
+ * const handleSend = async () => {
696
+ * const result = await sendMessage({
697
+ * content: 'Hello!',
698
+ * model: 'gpt-4o-mini',
699
+ * includeHistory: true,
700
+ * });
701
+ * };
702
+ *
703
+ * return (
704
+ * <View>
705
+ * <Button onPress={handleSend} disabled={isLoading} title="Send" />
706
+ * </View>
707
+ * );
708
+ * }
709
+ * ```
710
+ *
711
+ * @category Hooks
712
+ */
713
+ declare function useChatStorage(options: UseChatStorageOptions): UseChatStorageResult;
714
+
400
715
  type UseImageGenerationOptions = {
401
716
  /**
402
717
  * Custom function to get auth token for API calls
@@ -430,6 +745,7 @@ type UseImageGenerationResult = {
430
745
  };
431
746
  /**
432
747
  * React hook for generating images using the LLM API.
748
+ * @category Hooks
433
749
  */
434
750
  declare function useImageGeneration(options?: UseImageGenerationOptions): UseImageGenerationResult;
435
751
 
@@ -460,7 +776,438 @@ type UseModelsResult = {
460
776
  /**
461
777
  * React hook for fetching available LLM models.
462
778
  * Automatically fetches all available models.
779
+ * @category Hooks
463
780
  */
464
781
  declare function useModels(options?: UseModelsOptions): UseModelsResult;
465
782
 
466
- export { type UseModelsOptions, type UseModelsResult, useChat, useImageGeneration, useModels };
783
+ interface MemoryItem$1 {
784
+ type: "identity" | "preference" | "project" | "skill" | "constraint";
785
+ namespace: string;
786
+ key: string;
787
+ value: string;
788
+ rawEvidence: string;
789
+ confidence: number;
790
+ pii: boolean;
791
+ }
792
+ interface MemoryExtractionResult {
793
+ items: MemoryItem$1[];
794
+ }
795
+
796
+ /**
797
+ * Memory type classification
798
+ */
799
+ type MemoryType = "identity" | "preference" | "project" | "skill" | "constraint";
800
+ /**
801
+ * Base memory item (matches existing MemoryItem from memory/service.ts)
802
+ */
803
+ interface MemoryItem {
804
+ type: MemoryType;
805
+ namespace: string;
806
+ key: string;
807
+ value: string;
808
+ rawEvidence: string;
809
+ confidence: number;
810
+ pii: boolean;
811
+ }
812
+ /**
813
+ * Stored memory record (what gets persisted to the database)
814
+ */
815
+ interface StoredMemory {
816
+ /** Primary key, unique memory identifier (WatermelonDB auto-generated) */
817
+ uniqueId: string;
818
+ /** Memory type classification */
819
+ type: MemoryType;
820
+ /** Namespace for grouping related memories */
821
+ namespace: string;
822
+ /** Key within the namespace */
823
+ key: string;
824
+ /** The memory value/content */
825
+ value: string;
826
+ /** Raw evidence from which this memory was extracted */
827
+ rawEvidence: string;
828
+ /** Confidence score (0-1) */
829
+ confidence: number;
830
+ /** Whether this memory contains PII */
831
+ pii: boolean;
832
+ /** Composite key (namespace:key) for efficient lookups */
833
+ compositeKey: string;
834
+ /** Unique key (namespace:key:value) for deduplication */
835
+ uniqueKey: string;
836
+ /** ISO timestamp */
837
+ createdAt: Date;
838
+ /** ISO timestamp */
839
+ updatedAt: Date;
840
+ /** Embedding vector for semantic search */
841
+ embedding?: number[];
842
+ /** Model used to generate embedding */
843
+ embeddingModel?: string;
844
+ /** Soft delete flag */
845
+ isDeleted: boolean;
846
+ }
847
+ /**
848
+ * Memory with similarity score (returned from semantic search)
849
+ */
850
+ interface StoredMemoryWithSimilarity extends StoredMemory {
851
+ /** Cosine similarity score (0-1) */
852
+ similarity: number;
853
+ }
854
+ /**
855
+ * Options for creating a new memory
856
+ */
857
+ interface CreateMemoryOptions {
858
+ /** Memory type */
859
+ type: MemoryType;
860
+ /** Namespace for grouping */
861
+ namespace: string;
862
+ /** Key within namespace */
863
+ key: string;
864
+ /** Memory value/content */
865
+ value: string;
866
+ /** Raw evidence text */
867
+ rawEvidence: string;
868
+ /** Confidence score (0-1) */
869
+ confidence: number;
870
+ /** Whether this contains PII */
871
+ pii: boolean;
872
+ /** Optional embedding vector */
873
+ embedding?: number[];
874
+ /** Optional embedding model name */
875
+ embeddingModel?: string;
876
+ }
877
+ /**
878
+ * Options for updating a memory
879
+ */
880
+ interface UpdateMemoryOptions {
881
+ /** Memory type */
882
+ type?: MemoryType;
883
+ /** Namespace for grouping */
884
+ namespace?: string;
885
+ /** Key within namespace */
886
+ key?: string;
887
+ /** Memory value/content */
888
+ value?: string;
889
+ /** Raw evidence text */
890
+ rawEvidence?: string;
891
+ /** Confidence score (0-1) */
892
+ confidence?: number;
893
+ /** Whether this contains PII */
894
+ pii?: boolean;
895
+ /** Optional embedding vector */
896
+ embedding?: number[];
897
+ /** Optional embedding model name */
898
+ embeddingModel?: string;
899
+ }
900
+ /**
901
+ * Base options for useMemoryStorage hook (shared between React and Expo)
902
+ */
903
+ interface BaseUseMemoryStorageOptions {
904
+ /** WatermelonDB database instance */
905
+ database: Database;
906
+ /** The model to use for fact extraction (default: "openai/gpt-4o") */
907
+ completionsModel?: string;
908
+ /**
909
+ * The model to use for generating embeddings
910
+ * For local: default is "Snowflake/snowflake-arctic-embed-xs"
911
+ * For api: default is "openai/text-embedding-3-small"
912
+ * Set to null to disable embedding generation
913
+ */
914
+ embeddingModel?: string | null;
915
+ /**
916
+ * The provider to use for generating embeddings (default: "local")
917
+ * "local": Uses a local HuggingFace model (in-browser)
918
+ * "api": Uses the backend API
919
+ */
920
+ embeddingProvider?: "local" | "api";
921
+ /** Whether to automatically generate embeddings for extracted memories (default: true) */
922
+ generateEmbeddings?: boolean;
923
+ /** Callback when facts are extracted */
924
+ onFactsExtracted?: (facts: MemoryExtractionResult) => void;
925
+ /** Custom function to get auth token for API calls */
926
+ getToken?: () => Promise<string | null>;
927
+ /** Optional base URL for the API requests */
928
+ baseUrl?: string;
929
+ }
930
+ /**
931
+ * Base result returned by useMemoryStorage hook (shared between React and Expo)
932
+ */
933
+ interface BaseUseMemoryStorageResult {
934
+ /** Current memories in state (reactive) */
935
+ memories: StoredMemory[];
936
+ /** Refresh memories from storage */
937
+ refreshMemories: () => Promise<void>;
938
+ /**
939
+ * Extract memories from messages and store them
940
+ * @param options Messages and model to use for extraction
941
+ * @returns Extraction result or null if failed
942
+ */
943
+ extractMemoriesFromMessage: (options: {
944
+ messages: Array<{
945
+ role: string;
946
+ content: string;
947
+ }>;
948
+ model?: string;
949
+ }) => Promise<MemoryExtractionResult | null>;
950
+ /**
951
+ * Search for similar memories using semantic search
952
+ * @param query The text query to search for
953
+ * @param limit Maximum number of results (default: 10)
954
+ * @param minSimilarity Minimum similarity threshold 0-1 (default: 0.6)
955
+ * @returns Array of memories with similarity scores, sorted by relevance
956
+ */
957
+ searchMemories: (query: string, limit?: number, minSimilarity?: number) => Promise<StoredMemoryWithSimilarity[]>;
958
+ /**
959
+ * Get all memories stored in the database
960
+ * @returns Array of all stored memories
961
+ */
962
+ fetchAllMemories: () => Promise<StoredMemory[]>;
963
+ /**
964
+ * Get memories filtered by namespace
965
+ * @param namespace The namespace to filter by
966
+ * @returns Array of memories in the specified namespace
967
+ */
968
+ fetchMemoriesByNamespace: (namespace: string) => Promise<StoredMemory[]>;
969
+ /**
970
+ * Get memories by namespace and key
971
+ * @param namespace The namespace
972
+ * @param key The key within the namespace
973
+ * @returns Array of memories matching the namespace and key
974
+ */
975
+ fetchMemoriesByKey: (namespace: string, key: string) => Promise<StoredMemory[]>;
976
+ /**
977
+ * Get a memory by its unique ID
978
+ * @param id The memory unique ID
979
+ * @returns The memory or null if not found
980
+ */
981
+ getMemoryById: (id: string) => Promise<StoredMemory | null>;
982
+ /**
983
+ * Save a single memory to storage
984
+ * @param memory The memory to save
985
+ * @returns The stored memory
986
+ */
987
+ saveMemory: (memory: CreateMemoryOptions) => Promise<StoredMemory>;
988
+ /**
989
+ * Save multiple memories to storage
990
+ * @param memories Array of memories to save
991
+ * @returns Array of stored memories
992
+ */
993
+ saveMemories: (memories: CreateMemoryOptions[]) => Promise<StoredMemory[]>;
994
+ /**
995
+ * Update a memory by its ID
996
+ * @param id The memory ID
997
+ * @param updates Partial memory fields to update
998
+ * @returns The updated memory or null if not found
999
+ */
1000
+ updateMemory: (id: string, updates: UpdateMemoryOptions) => Promise<StoredMemory | null>;
1001
+ /**
1002
+ * Delete a specific memory by namespace, key, and value
1003
+ * @param namespace The namespace
1004
+ * @param key The key
1005
+ * @param value The value
1006
+ */
1007
+ removeMemory: (namespace: string, key: string, value: string) => Promise<void>;
1008
+ /**
1009
+ * Delete a memory by its ID (soft delete)
1010
+ * @param id The memory ID
1011
+ */
1012
+ removeMemoryById: (id: string) => Promise<void>;
1013
+ /**
1014
+ * Delete all memories by namespace and key
1015
+ * @param namespace The namespace
1016
+ * @param key The key
1017
+ */
1018
+ removeMemories: (namespace: string, key: string) => Promise<void>;
1019
+ /**
1020
+ * Clear all memories from storage
1021
+ */
1022
+ clearMemories: () => Promise<void>;
1023
+ }
1024
+ /**
1025
+ * Generate composite key from namespace and key
1026
+ */
1027
+ declare function generateCompositeKey(namespace: string, key: string): string;
1028
+ /**
1029
+ * Generate unique key from namespace, key, and value
1030
+ */
1031
+ declare function generateUniqueKey(namespace: string, key: string, value: string): string;
1032
+
1033
+ /**
1034
+ * Options for useMemoryStorage hook (Expo version)
1035
+ *
1036
+ * Uses the base options without local embedding support.
1037
+ * In Expo, only "api" embedding provider is supported.
1038
+ */
1039
+ interface UseMemoryStorageOptions extends Omit<BaseUseMemoryStorageOptions, "embeddingProvider"> {
1040
+ /**
1041
+ * The provider to use for generating embeddings
1042
+ * Note: In Expo, only "api" is supported (local embeddings require web APIs)
1043
+ */
1044
+ embeddingProvider?: "api";
1045
+ }
1046
+ /**
1047
+ * Result returned by useMemoryStorage hook (Expo version)
1048
+ *
1049
+ * Uses the base result.
1050
+ */
1051
+ type UseMemoryStorageResult = BaseUseMemoryStorageResult;
1052
+ /**
1053
+ * A React hook that wraps useMemory with automatic memory persistence using WatermelonDB.
1054
+ *
1055
+ * **Expo/React Native version** - This is a lightweight version that only supports
1056
+ * API-based embeddings. Local embeddings require web APIs not available in React Native.
1057
+ *
1058
+ * @param options - Configuration options
1059
+ * @returns An object containing memory state, methods, and storage operations
1060
+ *
1061
+ * @example
1062
+ * ```tsx
1063
+ * import { Database } from '@nozbe/watermelondb';
1064
+ * import { useMemoryStorage } from '@reverbia/sdk/expo';
1065
+ *
1066
+ * function MemoryScreen({ database }: { database: Database }) {
1067
+ * const {
1068
+ * memories,
1069
+ * extractMemoriesFromMessage,
1070
+ * searchMemories,
1071
+ * } = useMemoryStorage({
1072
+ * database,
1073
+ * getToken: async () => getAuthToken(),
1074
+ * embeddingProvider: 'api', // Only API embeddings supported in Expo
1075
+ * });
1076
+ *
1077
+ * const handleExtract = async () => {
1078
+ * await extractMemoriesFromMessage({
1079
+ * messages: [{ role: 'user', content: 'My name is John' }],
1080
+ * });
1081
+ * };
1082
+ *
1083
+ * return (
1084
+ * <View>
1085
+ * <Button onPress={handleExtract} title="Extract" />
1086
+ * <Text>Memories: {memories.length}</Text>
1087
+ * </View>
1088
+ * );
1089
+ * }
1090
+ * ```
1091
+ *
1092
+ * @category Hooks
1093
+ */
1094
+ declare function useMemoryStorage(options: UseMemoryStorageOptions): UseMemoryStorageResult;
1095
+
1096
+ /**
1097
+ * WatermelonDB schema for chat storage
1098
+ *
1099
+ * Defines two tables:
1100
+ * - history: Chat messages with metadata
1101
+ * - conversations: Conversation metadata
1102
+ */
1103
+ declare const chatStorageSchema: Readonly<{
1104
+ version: _nozbe_watermelondb_Schema.SchemaVersion;
1105
+ tables: _nozbe_watermelondb_Schema.TableMap;
1106
+ unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1107
+ }>;
1108
+
1109
+ /**
1110
+ * Message model representing a single chat message
1111
+ *
1112
+ * Note: This model uses raw column accessors instead of decorators
1113
+ * for better TypeScript compatibility without requiring legacy decorators.
1114
+ */
1115
+ declare class Message extends Model {
1116
+ static table: string;
1117
+ static associations: Associations;
1118
+ /** Sequential message ID within conversation */
1119
+ get messageId(): number;
1120
+ /** Links message to its conversation */
1121
+ get conversationId(): string;
1122
+ /** Who sent the message: 'user' | 'assistant' | 'system' */
1123
+ get role(): ChatRole;
1124
+ /** The message text content */
1125
+ get content(): string;
1126
+ /** LLM model used (e.g., GPT-4, Claude) */
1127
+ get model(): string | undefined;
1128
+ /** Optional attached files */
1129
+ get files(): FileMetadata[] | undefined;
1130
+ /** Created timestamp */
1131
+ get createdAt(): Date;
1132
+ /** Updated timestamp */
1133
+ get updatedAt(): Date;
1134
+ /** Embedding vector for semantic search */
1135
+ get vector(): number[] | undefined;
1136
+ /** Model used to generate embedding */
1137
+ get embeddingModel(): string | undefined;
1138
+ /** Token counts and cost */
1139
+ get usage(): ChatCompletionUsage | undefined;
1140
+ /** Web search sources */
1141
+ get sources(): SearchSource[] | undefined;
1142
+ /** Response time in seconds */
1143
+ get responseDuration(): number | undefined;
1144
+ }
1145
+ /**
1146
+ * Conversation model representing conversation metadata
1147
+ */
1148
+ declare class Conversation extends Model {
1149
+ static table: string;
1150
+ static associations: Associations;
1151
+ /** Unique conversation identifier */
1152
+ get conversationId(): string;
1153
+ /** Conversation title */
1154
+ get title(): string;
1155
+ /** Created timestamp */
1156
+ get createdAt(): Date;
1157
+ /** Updated timestamp */
1158
+ get updatedAt(): Date;
1159
+ /** Soft delete flag */
1160
+ get isDeleted(): boolean;
1161
+ }
1162
+
1163
+ /**
1164
+ * WatermelonDB schema for memory storage
1165
+ *
1166
+ * Defines the memories table for storing extracted user memories
1167
+ * with support for vector embeddings for semantic search.
1168
+ */
1169
+ declare const memoryStorageSchema: Readonly<{
1170
+ version: _nozbe_watermelondb_Schema.SchemaVersion;
1171
+ tables: _nozbe_watermelondb_Schema.TableMap;
1172
+ unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1173
+ }>;
1174
+
1175
+ /**
1176
+ * Memory model representing a single extracted memory
1177
+ *
1178
+ * Note: This model uses raw column accessors instead of decorators
1179
+ * for better TypeScript compatibility without requiring legacy decorators.
1180
+ */
1181
+ declare class Memory extends Model {
1182
+ static table: string;
1183
+ /** Memory type classification */
1184
+ get type(): MemoryType;
1185
+ /** Namespace for grouping related memories */
1186
+ get namespace(): string;
1187
+ /** Key within the namespace */
1188
+ get key(): string;
1189
+ /** The memory value/content */
1190
+ get value(): string;
1191
+ /** Raw evidence from which this memory was extracted */
1192
+ get rawEvidence(): string;
1193
+ /** Confidence score (0-1) */
1194
+ get confidence(): number;
1195
+ /** Whether this memory contains PII */
1196
+ get pii(): boolean;
1197
+ /** Composite key (namespace:key) for efficient lookups */
1198
+ get compositeKey(): string;
1199
+ /** Unique key (namespace:key:value) for deduplication */
1200
+ get uniqueKey(): string;
1201
+ /** Created timestamp */
1202
+ get createdAt(): Date;
1203
+ /** Updated timestamp */
1204
+ get updatedAt(): Date;
1205
+ /** Embedding vector for semantic search */
1206
+ get embedding(): number[] | undefined;
1207
+ /** Model used to generate embedding */
1208
+ get embeddingModel(): string | undefined;
1209
+ /** Soft delete flag */
1210
+ get isDeleted(): boolean;
1211
+ }
1212
+
1213
+ export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type FileMetadata, type MemoryItem, type MemoryType, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type UpdateMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseModelsOptions, type UseModelsResult, chatStorageSchema, generateCompositeKey, generateConversationId, generateUniqueKey, memoryStorageSchema, useChat, useChatStorage, useImageGeneration, useMemoryStorage, useModels };