@reverbia/sdk 1.0.0-next.20251217144159 → 1.0.0-next.20251218151654
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/index.cjs +313 -269
- package/dist/expo/index.d.mts +130 -414
- package/dist/expo/index.d.ts +130 -414
- package/dist/expo/index.mjs +299 -248
- package/dist/index.cjs +46 -2
- package/dist/index.d.mts +175 -2
- package/dist/index.d.ts +175 -2
- package/dist/index.mjs +41 -1
- package/dist/react/index.cjs +424 -331
- package/dist/react/index.d.mts +136 -453
- package/dist/react/index.d.ts +136 -453
- package/dist/react/index.mjs +404 -304
- package/package.json +2 -2
package/dist/expo/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
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
|
-
import { Associations } from '@nozbe/watermelondb/Model';
|
|
4
|
+
import Model$1, { Associations } from '@nozbe/watermelondb/Model';
|
|
5
|
+
import { Class } from '@nozbe/watermelondb/types';
|
|
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
|
*/
|
|
@@ -404,246 +409,161 @@ type UseChatResult = BaseUseChatResult & {
|
|
|
404
409
|
*/
|
|
405
410
|
declare function useChat(options?: UseChatOptions): UseChatResult;
|
|
406
411
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
412
|
+
declare const chatStorageSchema: Readonly<{
|
|
413
|
+
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
414
|
+
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
415
|
+
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
416
|
+
}>;
|
|
417
|
+
declare const chatStorageMigrations: Readonly<{
|
|
418
|
+
validated: true;
|
|
419
|
+
minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
420
|
+
maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
421
|
+
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
422
|
+
}>;
|
|
423
|
+
|
|
410
424
|
type ChatRole = "user" | "assistant" | "system";
|
|
411
|
-
/**
|
|
412
|
-
* File metadata for attached files
|
|
413
|
-
*/
|
|
414
425
|
interface FileMetadata {
|
|
415
|
-
/** Unique file identifier */
|
|
416
426
|
id: string;
|
|
417
|
-
/** Original file name */
|
|
418
427
|
name: string;
|
|
419
|
-
/** MIME type */
|
|
420
428
|
type: string;
|
|
421
|
-
/** File size in bytes */
|
|
422
429
|
size: number;
|
|
423
|
-
/** Optional URL or data URI */
|
|
424
430
|
url?: string;
|
|
425
431
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Token usage and cost information
|
|
428
|
-
*/
|
|
429
432
|
interface ChatCompletionUsage {
|
|
430
|
-
/** Number of tokens in the prompt */
|
|
431
433
|
promptTokens?: number;
|
|
432
|
-
/** Number of tokens in the completion */
|
|
433
434
|
completionTokens?: number;
|
|
434
|
-
/** Total tokens used */
|
|
435
435
|
totalTokens?: number;
|
|
436
|
-
/** Cost in micro-dollars (USD × 1,000,000) */
|
|
437
436
|
costMicroUsd?: number;
|
|
438
437
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Web search source information
|
|
441
|
-
*/
|
|
442
438
|
interface SearchSource {
|
|
443
|
-
/** Source title */
|
|
444
439
|
title?: string;
|
|
445
|
-
/** Source URL */
|
|
446
440
|
url?: string;
|
|
447
|
-
/** Text snippet from the source */
|
|
448
441
|
snippet?: string;
|
|
449
|
-
/** Publication or last updated date */
|
|
450
442
|
date?: string;
|
|
451
443
|
}
|
|
452
|
-
/**
|
|
453
|
-
* Stored message record (what gets persisted to the database)
|
|
454
|
-
*/
|
|
455
444
|
interface StoredMessage {
|
|
456
|
-
/** Primary key, unique message identifier (WatermelonDB auto-generated) */
|
|
457
445
|
uniqueId: string;
|
|
458
|
-
/** Sequential message ID within conversation */
|
|
459
446
|
messageId: number;
|
|
460
|
-
/** Links message to its conversation */
|
|
461
447
|
conversationId: string;
|
|
462
|
-
/** Who sent the message */
|
|
463
448
|
role: ChatRole;
|
|
464
|
-
/** The message text */
|
|
465
449
|
content: string;
|
|
466
|
-
/** LLM model used */
|
|
467
450
|
model?: string;
|
|
468
|
-
/** Optional attached files */
|
|
469
451
|
files?: FileMetadata[];
|
|
470
|
-
/** When the message was created */
|
|
471
452
|
createdAt: Date;
|
|
472
|
-
/** When the message was last updated */
|
|
473
453
|
updatedAt: Date;
|
|
474
|
-
/** Embedding vector for semantic search */
|
|
475
454
|
vector?: number[];
|
|
476
|
-
/** Model used to generate embedding */
|
|
477
455
|
embeddingModel?: string;
|
|
478
|
-
/** Token counts and cost */
|
|
479
456
|
usage?: ChatCompletionUsage;
|
|
480
|
-
/** Web search sources */
|
|
481
457
|
sources?: SearchSource[];
|
|
482
|
-
/** Response time in seconds */
|
|
483
458
|
responseDuration?: number;
|
|
484
|
-
/** Whether the message generation was stopped by the user */
|
|
485
459
|
wasStopped?: boolean;
|
|
486
460
|
}
|
|
487
|
-
/**
|
|
488
|
-
* Stored conversation record
|
|
489
|
-
*/
|
|
490
461
|
interface StoredConversation {
|
|
491
|
-
/** Primary key (WatermelonDB auto-generated) */
|
|
492
462
|
uniqueId: string;
|
|
493
|
-
/** Unique conversation identifier */
|
|
494
463
|
conversationId: string;
|
|
495
|
-
/** Conversation title */
|
|
496
464
|
title: string;
|
|
497
|
-
/** When the conversation was created */
|
|
498
465
|
createdAt: Date;
|
|
499
|
-
/** When the conversation was last updated */
|
|
500
466
|
updatedAt: Date;
|
|
501
|
-
/** Soft delete flag */
|
|
502
467
|
isDeleted: boolean;
|
|
503
468
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Stored message with similarity score (for search results)
|
|
506
|
-
*/
|
|
507
469
|
interface StoredMessageWithSimilarity extends StoredMessage {
|
|
508
|
-
/** Cosine similarity score (0 to 1) */
|
|
509
470
|
similarity: number;
|
|
510
471
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Options for creating a new message
|
|
513
|
-
*/
|
|
514
472
|
interface CreateMessageOptions {
|
|
515
|
-
/** Conversation ID to add the message to */
|
|
516
473
|
conversationId: string;
|
|
517
|
-
/** Message role */
|
|
518
474
|
role: ChatRole;
|
|
519
|
-
/** Message content */
|
|
520
475
|
content: string;
|
|
521
|
-
/** LLM model used (for assistant messages) */
|
|
522
476
|
model?: string;
|
|
523
|
-
/** Attached files */
|
|
524
477
|
files?: FileMetadata[];
|
|
525
|
-
/** Token usage information */
|
|
526
478
|
usage?: ChatCompletionUsage;
|
|
527
|
-
/** Web search sources */
|
|
528
479
|
sources?: SearchSource[];
|
|
529
|
-
/** Response duration in seconds */
|
|
530
480
|
responseDuration?: number;
|
|
531
|
-
/** Embedding vector for semantic search */
|
|
532
481
|
vector?: number[];
|
|
533
|
-
/** Model used to generate the embedding */
|
|
534
482
|
embeddingModel?: string;
|
|
535
|
-
/** Whether the message generation was stopped by the user */
|
|
536
483
|
wasStopped?: boolean;
|
|
537
484
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Options for creating a new conversation
|
|
540
|
-
*/
|
|
541
485
|
interface CreateConversationOptions {
|
|
542
|
-
/** Custom conversation ID (auto-generated if not provided) */
|
|
543
486
|
conversationId?: string;
|
|
544
|
-
/** Conversation title */
|
|
545
487
|
title?: string;
|
|
546
488
|
}
|
|
547
|
-
/**
|
|
548
|
-
* Base options for useChatStorage hook (shared between React and Expo)
|
|
549
|
-
*/
|
|
550
489
|
interface BaseUseChatStorageOptions {
|
|
551
|
-
/** WatermelonDB database instance */
|
|
552
490
|
database: Database;
|
|
553
|
-
/** Current conversation ID (will create new if not provided) */
|
|
554
491
|
conversationId?: string;
|
|
555
|
-
/** Auto-create conversation if it doesn't exist (default: true) */
|
|
556
492
|
autoCreateConversation?: boolean;
|
|
557
|
-
/** Default title for auto-created conversations */
|
|
558
493
|
defaultConversationTitle?: string;
|
|
559
|
-
/** Authentication token getter */
|
|
560
494
|
getToken?: () => Promise<string | null>;
|
|
561
|
-
/** Base URL for API requests */
|
|
562
495
|
baseUrl?: string;
|
|
563
|
-
/** Callback when data chunk is received */
|
|
564
496
|
onData?: (chunk: string) => void;
|
|
565
|
-
/** Callback when chat completion finishes */
|
|
566
497
|
onFinish?: (response: LlmapiChatCompletionResponse) => void;
|
|
567
|
-
/** Callback when an error occurs */
|
|
568
498
|
onError?: (error: Error) => void;
|
|
569
499
|
}
|
|
570
|
-
/**
|
|
571
|
-
* Base arguments for sendMessage with storage (shared between React and Expo)
|
|
572
|
-
*/
|
|
573
500
|
interface BaseSendMessageWithStorageArgs {
|
|
574
|
-
/** Message content to send */
|
|
575
501
|
content: string;
|
|
576
|
-
/** Model to use for the completion */
|
|
577
502
|
model?: string;
|
|
578
|
-
/** Previous messages to include (if not using stored messages) */
|
|
579
503
|
messages?: LlmapiMessage[];
|
|
580
|
-
/** Whether to include stored messages from conversation */
|
|
581
504
|
includeHistory?: boolean;
|
|
582
|
-
/** Maximum number of history messages to include (default: 50) */
|
|
583
505
|
maxHistoryMessages?: number;
|
|
584
|
-
/** Attached files */
|
|
585
506
|
files?: FileMetadata[];
|
|
586
|
-
/** Per-request data callback */
|
|
587
507
|
onData?: (chunk: string) => void;
|
|
588
|
-
/** Memory context to inject as system message (formatted memories from useMemoryStorage) */
|
|
589
508
|
memoryContext?: string;
|
|
590
509
|
}
|
|
591
|
-
/**
|
|
592
|
-
* Base success result from sendMessage with storage
|
|
593
|
-
*/
|
|
594
510
|
interface BaseSendMessageSuccessResult {
|
|
595
511
|
data: LlmapiChatCompletionResponse;
|
|
596
512
|
error: null;
|
|
597
513
|
userMessage: StoredMessage;
|
|
598
514
|
assistantMessage: StoredMessage;
|
|
599
515
|
}
|
|
600
|
-
/**
|
|
601
|
-
* Base error result from sendMessage with storage
|
|
602
|
-
*/
|
|
603
516
|
interface BaseSendMessageErrorResult {
|
|
604
517
|
data: null;
|
|
605
518
|
error: string;
|
|
606
519
|
userMessage?: StoredMessage;
|
|
607
520
|
assistantMessage?: undefined;
|
|
608
521
|
}
|
|
609
|
-
/**
|
|
610
|
-
* Base result type from sendMessage with storage
|
|
611
|
-
*/
|
|
612
522
|
type BaseSendMessageWithStorageResult = BaseSendMessageSuccessResult | BaseSendMessageErrorResult;
|
|
613
|
-
/**
|
|
614
|
-
* Base result returned by useChatStorage hook (shared between React and Expo)
|
|
615
|
-
*/
|
|
616
523
|
interface BaseUseChatStorageResult {
|
|
617
|
-
/** Whether a chat request is in progress */
|
|
618
524
|
isLoading: boolean;
|
|
619
|
-
/** Stop the current request */
|
|
620
525
|
stop: () => void;
|
|
621
|
-
/** Current conversation ID */
|
|
622
526
|
conversationId: string | null;
|
|
623
|
-
/** Set the current conversation ID */
|
|
624
527
|
setConversationId: (id: string | null) => void;
|
|
625
|
-
/** Create a new conversation */
|
|
626
528
|
createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
|
|
627
|
-
/** Get a conversation by ID */
|
|
628
529
|
getConversation: (id: string) => Promise<StoredConversation | null>;
|
|
629
|
-
/** Get all conversations (excluding soft-deleted) */
|
|
630
530
|
getConversations: () => Promise<StoredConversation[]>;
|
|
631
|
-
/** Update conversation title. Returns true if updated, false if not found. */
|
|
632
531
|
updateConversationTitle: (id: string, title: string) => Promise<boolean>;
|
|
633
|
-
/** Soft delete a conversation. Returns true if deleted, false if not found. */
|
|
634
532
|
deleteConversation: (id: string) => Promise<boolean>;
|
|
635
|
-
/** Get messages for a conversation */
|
|
636
533
|
getMessages: (conversationId: string) => Promise<StoredMessage[]>;
|
|
637
|
-
/** Get message count for a conversation */
|
|
638
534
|
getMessageCount: (conversationId: string) => Promise<number>;
|
|
639
|
-
/** Clear all messages in a conversation */
|
|
640
535
|
clearMessages: (conversationId: string) => Promise<void>;
|
|
641
536
|
}
|
|
642
|
-
/**
|
|
643
|
-
* Generate a unique ID for conversations
|
|
644
|
-
*/
|
|
645
537
|
declare function generateConversationId(): string;
|
|
646
538
|
|
|
539
|
+
declare class Message extends Model {
|
|
540
|
+
static table: string;
|
|
541
|
+
static associations: Associations;
|
|
542
|
+
messageId: number;
|
|
543
|
+
conversationId: string;
|
|
544
|
+
role: ChatRole;
|
|
545
|
+
content: string;
|
|
546
|
+
model?: string;
|
|
547
|
+
files?: FileMetadata[];
|
|
548
|
+
createdAt: Date;
|
|
549
|
+
updatedAt: Date;
|
|
550
|
+
vector?: number[];
|
|
551
|
+
embeddingModel?: string;
|
|
552
|
+
usage?: ChatCompletionUsage;
|
|
553
|
+
sources?: SearchSource[];
|
|
554
|
+
responseDuration?: number;
|
|
555
|
+
wasStopped?: boolean;
|
|
556
|
+
}
|
|
557
|
+
declare class Conversation extends Model {
|
|
558
|
+
static table: string;
|
|
559
|
+
static associations: Associations;
|
|
560
|
+
conversationId: string;
|
|
561
|
+
title: string;
|
|
562
|
+
createdAt: Date;
|
|
563
|
+
updatedAt: Date;
|
|
564
|
+
isDeleted: boolean;
|
|
565
|
+
}
|
|
566
|
+
|
|
647
567
|
/**
|
|
648
568
|
* Options for useChatStorage hook (Expo version)
|
|
649
569
|
*
|
|
@@ -785,6 +705,12 @@ type UseModelsResult = {
|
|
|
785
705
|
*/
|
|
786
706
|
declare function useModels(options?: UseModelsOptions): UseModelsResult;
|
|
787
707
|
|
|
708
|
+
declare const memoryStorageSchema: Readonly<{
|
|
709
|
+
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
710
|
+
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
711
|
+
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
712
|
+
}>;
|
|
713
|
+
|
|
788
714
|
interface MemoryItem$1 {
|
|
789
715
|
type: "identity" | "preference" | "project" | "skill" | "constraint";
|
|
790
716
|
namespace: string;
|
|
@@ -798,13 +724,7 @@ interface MemoryExtractionResult {
|
|
|
798
724
|
items: MemoryItem$1[];
|
|
799
725
|
}
|
|
800
726
|
|
|
801
|
-
/**
|
|
802
|
-
* Memory type classification
|
|
803
|
-
*/
|
|
804
727
|
type MemoryType = "identity" | "preference" | "project" | "skill" | "constraint";
|
|
805
|
-
/**
|
|
806
|
-
* Base memory item (matches existing MemoryItem from memory/service.ts)
|
|
807
|
-
*/
|
|
808
728
|
interface MemoryItem {
|
|
809
729
|
type: MemoryType;
|
|
810
730
|
namespace: string;
|
|
@@ -814,137 +734,37 @@ interface MemoryItem {
|
|
|
814
734
|
confidence: number;
|
|
815
735
|
pii: boolean;
|
|
816
736
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
737
|
+
interface CreateMemoryOptions extends MemoryItem {
|
|
738
|
+
embedding?: number[];
|
|
739
|
+
embeddingModel?: string;
|
|
740
|
+
}
|
|
741
|
+
type UpdateMemoryOptions = Partial<CreateMemoryOptions>;
|
|
742
|
+
interface StoredMemory extends MemoryItem {
|
|
822
743
|
uniqueId: string;
|
|
823
|
-
/** Memory type classification */
|
|
824
|
-
type: MemoryType;
|
|
825
|
-
/** Namespace for grouping related memories */
|
|
826
|
-
namespace: string;
|
|
827
|
-
/** Key within the namespace */
|
|
828
|
-
key: string;
|
|
829
|
-
/** The memory value/content */
|
|
830
|
-
value: string;
|
|
831
|
-
/** Raw evidence from which this memory was extracted */
|
|
832
|
-
rawEvidence: string;
|
|
833
|
-
/** Confidence score (0-1) */
|
|
834
|
-
confidence: number;
|
|
835
|
-
/** Whether this memory contains PII */
|
|
836
|
-
pii: boolean;
|
|
837
|
-
/** Composite key (namespace:key) for efficient lookups */
|
|
838
744
|
compositeKey: string;
|
|
839
|
-
/** Unique key (namespace:key:value) for deduplication */
|
|
840
745
|
uniqueKey: string;
|
|
841
|
-
/** ISO timestamp */
|
|
842
746
|
createdAt: Date;
|
|
843
|
-
/** ISO timestamp */
|
|
844
747
|
updatedAt: Date;
|
|
845
|
-
/** Embedding vector for semantic search */
|
|
846
748
|
embedding?: number[];
|
|
847
|
-
/** Model used to generate embedding */
|
|
848
749
|
embeddingModel?: string;
|
|
849
|
-
/** Soft delete flag */
|
|
850
750
|
isDeleted: boolean;
|
|
851
751
|
}
|
|
852
|
-
/**
|
|
853
|
-
* Memory with similarity score (returned from semantic search)
|
|
854
|
-
*/
|
|
855
752
|
interface StoredMemoryWithSimilarity extends StoredMemory {
|
|
856
|
-
/** Cosine similarity score (0-1) */
|
|
857
753
|
similarity: number;
|
|
858
754
|
}
|
|
859
|
-
/**
|
|
860
|
-
* Options for creating a new memory
|
|
861
|
-
*/
|
|
862
|
-
interface CreateMemoryOptions {
|
|
863
|
-
/** Memory type */
|
|
864
|
-
type: MemoryType;
|
|
865
|
-
/** Namespace for grouping */
|
|
866
|
-
namespace: string;
|
|
867
|
-
/** Key within namespace */
|
|
868
|
-
key: string;
|
|
869
|
-
/** Memory value/content */
|
|
870
|
-
value: string;
|
|
871
|
-
/** Raw evidence text */
|
|
872
|
-
rawEvidence: string;
|
|
873
|
-
/** Confidence score (0-1) */
|
|
874
|
-
confidence: number;
|
|
875
|
-
/** Whether this contains PII */
|
|
876
|
-
pii: boolean;
|
|
877
|
-
/** Optional embedding vector */
|
|
878
|
-
embedding?: number[];
|
|
879
|
-
/** Optional embedding model name */
|
|
880
|
-
embeddingModel?: string;
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Options for updating a memory
|
|
884
|
-
*/
|
|
885
|
-
interface UpdateMemoryOptions {
|
|
886
|
-
/** Memory type */
|
|
887
|
-
type?: MemoryType;
|
|
888
|
-
/** Namespace for grouping */
|
|
889
|
-
namespace?: string;
|
|
890
|
-
/** Key within namespace */
|
|
891
|
-
key?: string;
|
|
892
|
-
/** Memory value/content */
|
|
893
|
-
value?: string;
|
|
894
|
-
/** Raw evidence text */
|
|
895
|
-
rawEvidence?: string;
|
|
896
|
-
/** Confidence score (0-1) */
|
|
897
|
-
confidence?: number;
|
|
898
|
-
/** Whether this contains PII */
|
|
899
|
-
pii?: boolean;
|
|
900
|
-
/** Optional embedding vector */
|
|
901
|
-
embedding?: number[];
|
|
902
|
-
/** Optional embedding model name */
|
|
903
|
-
embeddingModel?: string;
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Base options for useMemoryStorage hook (shared between React and Expo)
|
|
907
|
-
*/
|
|
908
755
|
interface BaseUseMemoryStorageOptions {
|
|
909
|
-
/** WatermelonDB database instance */
|
|
910
756
|
database: Database;
|
|
911
|
-
/** The model to use for fact extraction (default: "openai/gpt-4o") */
|
|
912
757
|
completionsModel?: string;
|
|
913
|
-
/**
|
|
914
|
-
* The model to use for generating embeddings
|
|
915
|
-
* For local: default is "Snowflake/snowflake-arctic-embed-xs"
|
|
916
|
-
* For api: default is "openai/text-embedding-3-small"
|
|
917
|
-
* Set to null to disable embedding generation
|
|
918
|
-
*/
|
|
919
758
|
embeddingModel?: string | null;
|
|
920
|
-
/**
|
|
921
|
-
* The provider to use for generating embeddings (default: "local")
|
|
922
|
-
* "local": Uses a local HuggingFace model (in-browser)
|
|
923
|
-
* "api": Uses the backend API
|
|
924
|
-
*/
|
|
925
759
|
embeddingProvider?: "local" | "api";
|
|
926
|
-
/** Whether to automatically generate embeddings for extracted memories (default: true) */
|
|
927
760
|
generateEmbeddings?: boolean;
|
|
928
|
-
/** Callback when facts are extracted */
|
|
929
761
|
onFactsExtracted?: (facts: MemoryExtractionResult) => void;
|
|
930
|
-
/** Custom function to get auth token for API calls */
|
|
931
762
|
getToken?: () => Promise<string | null>;
|
|
932
|
-
/** Optional base URL for the API requests */
|
|
933
763
|
baseUrl?: string;
|
|
934
764
|
}
|
|
935
|
-
/**
|
|
936
|
-
* Base result returned by useMemoryStorage hook (shared between React and Expo)
|
|
937
|
-
*/
|
|
938
765
|
interface BaseUseMemoryStorageResult {
|
|
939
|
-
/** Current memories in state (reactive) */
|
|
940
766
|
memories: StoredMemory[];
|
|
941
|
-
/** Refresh memories from storage */
|
|
942
767
|
refreshMemories: () => Promise<void>;
|
|
943
|
-
/**
|
|
944
|
-
* Extract memories from messages and store them
|
|
945
|
-
* @param options Messages and model to use for extraction
|
|
946
|
-
* @returns Extraction result or null if failed
|
|
947
|
-
*/
|
|
948
768
|
extractMemoriesFromMessage: (options: {
|
|
949
769
|
messages: Array<{
|
|
950
770
|
role: string;
|
|
@@ -952,89 +772,40 @@ interface BaseUseMemoryStorageResult {
|
|
|
952
772
|
}>;
|
|
953
773
|
model?: string;
|
|
954
774
|
}) => Promise<MemoryExtractionResult | null>;
|
|
955
|
-
/**
|
|
956
|
-
* Search for similar memories using semantic search
|
|
957
|
-
* @param query The text query to search for
|
|
958
|
-
* @param limit Maximum number of results (default: 10)
|
|
959
|
-
* @param minSimilarity Minimum similarity threshold 0-1 (default: 0.6)
|
|
960
|
-
* @returns Array of memories with similarity scores, sorted by relevance
|
|
961
|
-
*/
|
|
962
775
|
searchMemories: (query: string, limit?: number, minSimilarity?: number) => Promise<StoredMemoryWithSimilarity[]>;
|
|
963
|
-
/**
|
|
964
|
-
* Get all memories stored in the database
|
|
965
|
-
* @returns Array of all stored memories
|
|
966
|
-
*/
|
|
967
776
|
fetchAllMemories: () => Promise<StoredMemory[]>;
|
|
968
|
-
/**
|
|
969
|
-
* Get memories filtered by namespace
|
|
970
|
-
* @param namespace The namespace to filter by
|
|
971
|
-
* @returns Array of memories in the specified namespace
|
|
972
|
-
*/
|
|
973
777
|
fetchMemoriesByNamespace: (namespace: string) => Promise<StoredMemory[]>;
|
|
974
|
-
/**
|
|
975
|
-
* Get memories by namespace and key
|
|
976
|
-
* @param namespace The namespace
|
|
977
|
-
* @param key The key within the namespace
|
|
978
|
-
* @returns Array of memories matching the namespace and key
|
|
979
|
-
*/
|
|
980
778
|
fetchMemoriesByKey: (namespace: string, key: string) => Promise<StoredMemory[]>;
|
|
981
|
-
/**
|
|
982
|
-
* Get a memory by its unique ID
|
|
983
|
-
* @param id The memory unique ID
|
|
984
|
-
* @returns The memory or null if not found
|
|
985
|
-
*/
|
|
986
779
|
getMemoryById: (id: string) => Promise<StoredMemory | null>;
|
|
987
|
-
/**
|
|
988
|
-
* Save a single memory to storage
|
|
989
|
-
* @param memory The memory to save
|
|
990
|
-
* @returns The stored memory
|
|
991
|
-
*/
|
|
992
780
|
saveMemory: (memory: CreateMemoryOptions) => Promise<StoredMemory>;
|
|
993
|
-
/**
|
|
994
|
-
* Save multiple memories to storage
|
|
995
|
-
* @param memories Array of memories to save
|
|
996
|
-
* @returns Array of stored memories
|
|
997
|
-
*/
|
|
998
781
|
saveMemories: (memories: CreateMemoryOptions[]) => Promise<StoredMemory[]>;
|
|
999
|
-
/**
|
|
1000
|
-
* Update a memory by its ID
|
|
1001
|
-
* @param id The memory ID
|
|
1002
|
-
* @param updates Partial memory fields to update
|
|
1003
|
-
* @returns The updated memory or null if not found
|
|
1004
|
-
*/
|
|
1005
782
|
updateMemory: (id: string, updates: UpdateMemoryOptions) => Promise<StoredMemory | null>;
|
|
1006
|
-
/**
|
|
1007
|
-
* Delete a specific memory by namespace, key, and value
|
|
1008
|
-
* @param namespace The namespace
|
|
1009
|
-
* @param key The key
|
|
1010
|
-
* @param value The value
|
|
1011
|
-
*/
|
|
1012
783
|
removeMemory: (namespace: string, key: string, value: string) => Promise<void>;
|
|
1013
|
-
/**
|
|
1014
|
-
* Delete a memory by its ID (soft delete)
|
|
1015
|
-
* @param id The memory ID
|
|
1016
|
-
*/
|
|
1017
784
|
removeMemoryById: (id: string) => Promise<void>;
|
|
1018
|
-
/**
|
|
1019
|
-
* Delete all memories by namespace and key
|
|
1020
|
-
* @param namespace The namespace
|
|
1021
|
-
* @param key The key
|
|
1022
|
-
*/
|
|
1023
785
|
removeMemories: (namespace: string, key: string) => Promise<void>;
|
|
1024
|
-
/**
|
|
1025
|
-
* Clear all memories from storage
|
|
1026
|
-
*/
|
|
1027
786
|
clearMemories: () => Promise<void>;
|
|
1028
787
|
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Generate composite key from namespace and key
|
|
1031
|
-
*/
|
|
1032
788
|
declare function generateCompositeKey(namespace: string, key: string): string;
|
|
1033
|
-
/**
|
|
1034
|
-
* Generate unique key from namespace, key, and value
|
|
1035
|
-
*/
|
|
1036
789
|
declare function generateUniqueKey(namespace: string, key: string, value: string): string;
|
|
1037
790
|
|
|
791
|
+
declare class Memory extends Model {
|
|
792
|
+
static table: string;
|
|
793
|
+
type: MemoryType;
|
|
794
|
+
namespace: string;
|
|
795
|
+
key: string;
|
|
796
|
+
value: string;
|
|
797
|
+
rawEvidence: string;
|
|
798
|
+
confidence: number;
|
|
799
|
+
pii: boolean;
|
|
800
|
+
compositeKey: string;
|
|
801
|
+
uniqueKey: string;
|
|
802
|
+
createdAt: Date;
|
|
803
|
+
updatedAt: Date;
|
|
804
|
+
embedding?: number[];
|
|
805
|
+
embeddingModel?: string;
|
|
806
|
+
isDeleted: boolean;
|
|
807
|
+
}
|
|
808
|
+
|
|
1038
809
|
/**
|
|
1039
810
|
* Options for useMemoryStorage hook (Expo version)
|
|
1040
811
|
*
|
|
@@ -1099,131 +870,76 @@ type UseMemoryStorageResult = BaseUseMemoryStorageResult;
|
|
|
1099
870
|
declare function useMemoryStorage(options: UseMemoryStorageOptions): UseMemoryStorageResult;
|
|
1100
871
|
|
|
1101
872
|
/**
|
|
1102
|
-
* WatermelonDB schema for
|
|
873
|
+
* Combined WatermelonDB schema for all SDK storage modules.
|
|
1103
874
|
*
|
|
1104
|
-
*
|
|
1105
|
-
* - history
|
|
1106
|
-
* - conversations
|
|
875
|
+
* This unified schema includes all tables needed by the SDK:
|
|
876
|
+
* - `history`: Chat message storage with embeddings and metadata
|
|
877
|
+
* - `conversations`: Conversation metadata and organization
|
|
878
|
+
* - `memories`: Persistent memory storage with semantic search
|
|
879
|
+
* - `modelPreferences`: User model preferences and settings
|
|
880
|
+
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```typescript
|
|
883
|
+
* import { Database } from '@nozbe/watermelondb';
|
|
884
|
+
* import LokiJSAdapter from '@nozbe/watermelondb/adapters/lokijs';
|
|
885
|
+
* import { sdkSchema, sdkMigrations, sdkModelClasses } from '@reverbia/sdk/react';
|
|
886
|
+
*
|
|
887
|
+
* const adapter = new LokiJSAdapter({
|
|
888
|
+
* schema: sdkSchema,
|
|
889
|
+
* migrations: sdkMigrations,
|
|
890
|
+
* dbName: 'my-app-db',
|
|
891
|
+
* useWebWorker: false,
|
|
892
|
+
* useIncrementalIndexedDB: true,
|
|
893
|
+
* });
|
|
894
|
+
*
|
|
895
|
+
* const database = new Database({
|
|
896
|
+
* adapter,
|
|
897
|
+
* modelClasses: sdkModelClasses,
|
|
898
|
+
* });
|
|
899
|
+
* ```
|
|
1107
900
|
*/
|
|
1108
|
-
declare const
|
|
901
|
+
declare const sdkSchema: Readonly<{
|
|
1109
902
|
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1110
903
|
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
1111
904
|
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
1112
905
|
}>;
|
|
1113
906
|
/**
|
|
1114
|
-
*
|
|
907
|
+
* Combined migrations for all SDK storage modules.
|
|
908
|
+
*
|
|
909
|
+
* These migrations handle database schema upgrades from any previous version
|
|
910
|
+
* to the current version. The SDK manages all migration logic internally,
|
|
911
|
+
* so consumer apps don't need to handle version arithmetic or migration merging.
|
|
912
|
+
*
|
|
913
|
+
* **Minimum supported version: v2**
|
|
914
|
+
* Migrations from v1 are not supported. Databases at v1 require a fresh install.
|
|
915
|
+
*
|
|
916
|
+
* Migration history:
|
|
917
|
+
* - v2 → v3: Added `was_stopped` column to history table
|
|
918
|
+
* - v3 → v4: Added `modelPreferences` table for settings storage
|
|
1115
919
|
*/
|
|
1116
|
-
declare const
|
|
920
|
+
declare const sdkMigrations: Readonly<{
|
|
1117
921
|
validated: true;
|
|
1118
922
|
minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1119
923
|
maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1120
924
|
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
1121
925
|
}>;
|
|
1122
|
-
|
|
1123
926
|
/**
|
|
1124
|
-
*
|
|
927
|
+
* Model classes to register with the WatermelonDB database.
|
|
1125
928
|
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
*/
|
|
1129
|
-
declare class Message extends Model {
|
|
1130
|
-
static table: string;
|
|
1131
|
-
static associations: Associations;
|
|
1132
|
-
/** Sequential message ID within conversation */
|
|
1133
|
-
get messageId(): number;
|
|
1134
|
-
/** Links message to its conversation */
|
|
1135
|
-
get conversationId(): string;
|
|
1136
|
-
/** Who sent the message: 'user' | 'assistant' | 'system' */
|
|
1137
|
-
get role(): ChatRole;
|
|
1138
|
-
/** The message text content */
|
|
1139
|
-
get content(): string;
|
|
1140
|
-
/** LLM model used (e.g., GPT-4, Claude) */
|
|
1141
|
-
get model(): string | undefined;
|
|
1142
|
-
/** Optional attached files */
|
|
1143
|
-
get files(): FileMetadata[] | undefined;
|
|
1144
|
-
/** Created timestamp */
|
|
1145
|
-
get createdAt(): Date;
|
|
1146
|
-
/** Updated timestamp */
|
|
1147
|
-
get updatedAt(): Date;
|
|
1148
|
-
/** Embedding vector for semantic search */
|
|
1149
|
-
get vector(): number[] | undefined;
|
|
1150
|
-
/** Model used to generate embedding */
|
|
1151
|
-
get embeddingModel(): string | undefined;
|
|
1152
|
-
/** Token counts and cost */
|
|
1153
|
-
get usage(): ChatCompletionUsage | undefined;
|
|
1154
|
-
/** Web search sources */
|
|
1155
|
-
get sources(): SearchSource[] | undefined;
|
|
1156
|
-
/** Response time in seconds */
|
|
1157
|
-
get responseDuration(): number | undefined;
|
|
1158
|
-
/** Whether the message generation was stopped by the user */
|
|
1159
|
-
get wasStopped(): boolean;
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Conversation model representing conversation metadata
|
|
1163
|
-
*/
|
|
1164
|
-
declare class Conversation extends Model {
|
|
1165
|
-
static table: string;
|
|
1166
|
-
static associations: Associations;
|
|
1167
|
-
/** Unique conversation identifier */
|
|
1168
|
-
get conversationId(): string;
|
|
1169
|
-
/** Conversation title */
|
|
1170
|
-
get title(): string;
|
|
1171
|
-
/** Created timestamp */
|
|
1172
|
-
get createdAt(): Date;
|
|
1173
|
-
/** Updated timestamp */
|
|
1174
|
-
get updatedAt(): Date;
|
|
1175
|
-
/** Soft delete flag */
|
|
1176
|
-
get isDeleted(): boolean;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* WatermelonDB schema for memory storage
|
|
929
|
+
* Pass this array directly to the `modelClasses` option when creating
|
|
930
|
+
* your Database instance.
|
|
1181
931
|
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1187
|
-
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
1188
|
-
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
1189
|
-
}>;
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* Memory model representing a single extracted memory
|
|
932
|
+
* @example
|
|
933
|
+
* ```typescript
|
|
934
|
+
* import { Database } from '@nozbe/watermelondb';
|
|
935
|
+
* import { sdkSchema, sdkMigrations, sdkModelClasses } from '@reverbia/sdk/react';
|
|
1193
936
|
*
|
|
1194
|
-
*
|
|
1195
|
-
*
|
|
937
|
+
* const database = new Database({
|
|
938
|
+
* adapter,
|
|
939
|
+
* modelClasses: sdkModelClasses,
|
|
940
|
+
* });
|
|
941
|
+
* ```
|
|
1196
942
|
*/
|
|
1197
|
-
declare
|
|
1198
|
-
static table: string;
|
|
1199
|
-
/** Memory type classification */
|
|
1200
|
-
get type(): MemoryType;
|
|
1201
|
-
/** Namespace for grouping related memories */
|
|
1202
|
-
get namespace(): string;
|
|
1203
|
-
/** Key within the namespace */
|
|
1204
|
-
get key(): string;
|
|
1205
|
-
/** The memory value/content */
|
|
1206
|
-
get value(): string;
|
|
1207
|
-
/** Raw evidence from which this memory was extracted */
|
|
1208
|
-
get rawEvidence(): string;
|
|
1209
|
-
/** Confidence score (0-1) */
|
|
1210
|
-
get confidence(): number;
|
|
1211
|
-
/** Whether this memory contains PII */
|
|
1212
|
-
get pii(): boolean;
|
|
1213
|
-
/** Composite key (namespace:key) for efficient lookups */
|
|
1214
|
-
get compositeKey(): string;
|
|
1215
|
-
/** Unique key (namespace:key:value) for deduplication */
|
|
1216
|
-
get uniqueKey(): string;
|
|
1217
|
-
/** Created timestamp */
|
|
1218
|
-
get createdAt(): Date;
|
|
1219
|
-
/** Updated timestamp */
|
|
1220
|
-
get updatedAt(): Date;
|
|
1221
|
-
/** Embedding vector for semantic search */
|
|
1222
|
-
get embedding(): number[] | undefined;
|
|
1223
|
-
/** Model used to generate embedding */
|
|
1224
|
-
get embeddingModel(): string | undefined;
|
|
1225
|
-
/** Soft delete flag */
|
|
1226
|
-
get isDeleted(): boolean;
|
|
1227
|
-
}
|
|
943
|
+
declare const sdkModelClasses: Class<Model$1>[];
|
|
1228
944
|
|
|
1229
|
-
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, chatStorageMigrations, chatStorageSchema, generateCompositeKey, generateConversationId, generateUniqueKey, memoryStorageSchema, useChat, useChatStorage, useImageGeneration, useMemoryStorage, useModels };
|
|
945
|
+
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, chatStorageMigrations, chatStorageSchema, generateCompositeKey, generateConversationId, generateUniqueKey, memoryStorageSchema, sdkMigrations, sdkModelClasses, sdkSchema, useChat, useChatStorage, useImageGeneration, useMemoryStorage, useModels };
|