@reverbia/sdk 1.0.0-next.20251217144159 → 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.
- package/dist/expo/index.cjs +240 -318
- package/dist/expo/index.d.mts +74 -432
- package/dist/expo/index.d.ts +74 -432
- package/dist/expo/index.mjs +225 -297
- 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 +347 -363
- package/dist/react/index.d.mts +73 -464
- package/dist/react/index.d.ts +73 -464
- package/dist/react/index.mjs +326 -336
- package/package.json +2 -2
package/dist/expo/index.d.mts
CHANGED
|
@@ -236,6 +236,10 @@ type LlmapiModel = {
|
|
|
236
236
|
* MaxOutputTokens is the maximum output tokens
|
|
237
237
|
*/
|
|
238
238
|
max_output_tokens?: number;
|
|
239
|
+
/**
|
|
240
|
+
* Modalities is a list of supported modalities (e.g., ["llm", "vision"])
|
|
241
|
+
*/
|
|
242
|
+
modalities?: Array<string>;
|
|
239
243
|
/**
|
|
240
244
|
* Name is the human-readable model name (optional)
|
|
241
245
|
*/
|
|
@@ -404,246 +408,161 @@ type UseChatResult = BaseUseChatResult & {
|
|
|
404
408
|
*/
|
|
405
409
|
declare function useChat(options?: UseChatOptions): UseChatResult;
|
|
406
410
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
411
|
+
declare const chatStorageSchema: Readonly<{
|
|
412
|
+
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
413
|
+
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
414
|
+
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
415
|
+
}>;
|
|
416
|
+
declare const chatStorageMigrations: Readonly<{
|
|
417
|
+
validated: true;
|
|
418
|
+
minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
419
|
+
maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
420
|
+
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
421
|
+
}>;
|
|
422
|
+
|
|
410
423
|
type ChatRole = "user" | "assistant" | "system";
|
|
411
|
-
/**
|
|
412
|
-
* File metadata for attached files
|
|
413
|
-
*/
|
|
414
424
|
interface FileMetadata {
|
|
415
|
-
/** Unique file identifier */
|
|
416
425
|
id: string;
|
|
417
|
-
/** Original file name */
|
|
418
426
|
name: string;
|
|
419
|
-
/** MIME type */
|
|
420
427
|
type: string;
|
|
421
|
-
/** File size in bytes */
|
|
422
428
|
size: number;
|
|
423
|
-
/** Optional URL or data URI */
|
|
424
429
|
url?: string;
|
|
425
430
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Token usage and cost information
|
|
428
|
-
*/
|
|
429
431
|
interface ChatCompletionUsage {
|
|
430
|
-
/** Number of tokens in the prompt */
|
|
431
432
|
promptTokens?: number;
|
|
432
|
-
/** Number of tokens in the completion */
|
|
433
433
|
completionTokens?: number;
|
|
434
|
-
/** Total tokens used */
|
|
435
434
|
totalTokens?: number;
|
|
436
|
-
/** Cost in micro-dollars (USD × 1,000,000) */
|
|
437
435
|
costMicroUsd?: number;
|
|
438
436
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Web search source information
|
|
441
|
-
*/
|
|
442
437
|
interface SearchSource {
|
|
443
|
-
/** Source title */
|
|
444
438
|
title?: string;
|
|
445
|
-
/** Source URL */
|
|
446
439
|
url?: string;
|
|
447
|
-
/** Text snippet from the source */
|
|
448
440
|
snippet?: string;
|
|
449
|
-
/** Publication or last updated date */
|
|
450
441
|
date?: string;
|
|
451
442
|
}
|
|
452
|
-
/**
|
|
453
|
-
* Stored message record (what gets persisted to the database)
|
|
454
|
-
*/
|
|
455
443
|
interface StoredMessage {
|
|
456
|
-
/** Primary key, unique message identifier (WatermelonDB auto-generated) */
|
|
457
444
|
uniqueId: string;
|
|
458
|
-
/** Sequential message ID within conversation */
|
|
459
445
|
messageId: number;
|
|
460
|
-
/** Links message to its conversation */
|
|
461
446
|
conversationId: string;
|
|
462
|
-
/** Who sent the message */
|
|
463
447
|
role: ChatRole;
|
|
464
|
-
/** The message text */
|
|
465
448
|
content: string;
|
|
466
|
-
/** LLM model used */
|
|
467
449
|
model?: string;
|
|
468
|
-
/** Optional attached files */
|
|
469
450
|
files?: FileMetadata[];
|
|
470
|
-
/** When the message was created */
|
|
471
451
|
createdAt: Date;
|
|
472
|
-
/** When the message was last updated */
|
|
473
452
|
updatedAt: Date;
|
|
474
|
-
/** Embedding vector for semantic search */
|
|
475
453
|
vector?: number[];
|
|
476
|
-
/** Model used to generate embedding */
|
|
477
454
|
embeddingModel?: string;
|
|
478
|
-
/** Token counts and cost */
|
|
479
455
|
usage?: ChatCompletionUsage;
|
|
480
|
-
/** Web search sources */
|
|
481
456
|
sources?: SearchSource[];
|
|
482
|
-
/** Response time in seconds */
|
|
483
457
|
responseDuration?: number;
|
|
484
|
-
/** Whether the message generation was stopped by the user */
|
|
485
458
|
wasStopped?: boolean;
|
|
486
459
|
}
|
|
487
|
-
/**
|
|
488
|
-
* Stored conversation record
|
|
489
|
-
*/
|
|
490
460
|
interface StoredConversation {
|
|
491
|
-
/** Primary key (WatermelonDB auto-generated) */
|
|
492
461
|
uniqueId: string;
|
|
493
|
-
/** Unique conversation identifier */
|
|
494
462
|
conversationId: string;
|
|
495
|
-
/** Conversation title */
|
|
496
463
|
title: string;
|
|
497
|
-
/** When the conversation was created */
|
|
498
464
|
createdAt: Date;
|
|
499
|
-
/** When the conversation was last updated */
|
|
500
465
|
updatedAt: Date;
|
|
501
|
-
/** Soft delete flag */
|
|
502
466
|
isDeleted: boolean;
|
|
503
467
|
}
|
|
504
|
-
/**
|
|
505
|
-
* Stored message with similarity score (for search results)
|
|
506
|
-
*/
|
|
507
468
|
interface StoredMessageWithSimilarity extends StoredMessage {
|
|
508
|
-
/** Cosine similarity score (0 to 1) */
|
|
509
469
|
similarity: number;
|
|
510
470
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Options for creating a new message
|
|
513
|
-
*/
|
|
514
471
|
interface CreateMessageOptions {
|
|
515
|
-
/** Conversation ID to add the message to */
|
|
516
472
|
conversationId: string;
|
|
517
|
-
/** Message role */
|
|
518
473
|
role: ChatRole;
|
|
519
|
-
/** Message content */
|
|
520
474
|
content: string;
|
|
521
|
-
/** LLM model used (for assistant messages) */
|
|
522
475
|
model?: string;
|
|
523
|
-
/** Attached files */
|
|
524
476
|
files?: FileMetadata[];
|
|
525
|
-
/** Token usage information */
|
|
526
477
|
usage?: ChatCompletionUsage;
|
|
527
|
-
/** Web search sources */
|
|
528
478
|
sources?: SearchSource[];
|
|
529
|
-
/** Response duration in seconds */
|
|
530
479
|
responseDuration?: number;
|
|
531
|
-
/** Embedding vector for semantic search */
|
|
532
480
|
vector?: number[];
|
|
533
|
-
/** Model used to generate the embedding */
|
|
534
481
|
embeddingModel?: string;
|
|
535
|
-
/** Whether the message generation was stopped by the user */
|
|
536
482
|
wasStopped?: boolean;
|
|
537
483
|
}
|
|
538
|
-
/**
|
|
539
|
-
* Options for creating a new conversation
|
|
540
|
-
*/
|
|
541
484
|
interface CreateConversationOptions {
|
|
542
|
-
/** Custom conversation ID (auto-generated if not provided) */
|
|
543
485
|
conversationId?: string;
|
|
544
|
-
/** Conversation title */
|
|
545
486
|
title?: string;
|
|
546
487
|
}
|
|
547
|
-
/**
|
|
548
|
-
* Base options for useChatStorage hook (shared between React and Expo)
|
|
549
|
-
*/
|
|
550
488
|
interface BaseUseChatStorageOptions {
|
|
551
|
-
/** WatermelonDB database instance */
|
|
552
489
|
database: Database;
|
|
553
|
-
/** Current conversation ID (will create new if not provided) */
|
|
554
490
|
conversationId?: string;
|
|
555
|
-
/** Auto-create conversation if it doesn't exist (default: true) */
|
|
556
491
|
autoCreateConversation?: boolean;
|
|
557
|
-
/** Default title for auto-created conversations */
|
|
558
492
|
defaultConversationTitle?: string;
|
|
559
|
-
/** Authentication token getter */
|
|
560
493
|
getToken?: () => Promise<string | null>;
|
|
561
|
-
/** Base URL for API requests */
|
|
562
494
|
baseUrl?: string;
|
|
563
|
-
/** Callback when data chunk is received */
|
|
564
495
|
onData?: (chunk: string) => void;
|
|
565
|
-
/** Callback when chat completion finishes */
|
|
566
496
|
onFinish?: (response: LlmapiChatCompletionResponse) => void;
|
|
567
|
-
/** Callback when an error occurs */
|
|
568
497
|
onError?: (error: Error) => void;
|
|
569
498
|
}
|
|
570
|
-
/**
|
|
571
|
-
* Base arguments for sendMessage with storage (shared between React and Expo)
|
|
572
|
-
*/
|
|
573
499
|
interface BaseSendMessageWithStorageArgs {
|
|
574
|
-
/** Message content to send */
|
|
575
500
|
content: string;
|
|
576
|
-
/** Model to use for the completion */
|
|
577
501
|
model?: string;
|
|
578
|
-
/** Previous messages to include (if not using stored messages) */
|
|
579
502
|
messages?: LlmapiMessage[];
|
|
580
|
-
/** Whether to include stored messages from conversation */
|
|
581
503
|
includeHistory?: boolean;
|
|
582
|
-
/** Maximum number of history messages to include (default: 50) */
|
|
583
504
|
maxHistoryMessages?: number;
|
|
584
|
-
/** Attached files */
|
|
585
505
|
files?: FileMetadata[];
|
|
586
|
-
/** Per-request data callback */
|
|
587
506
|
onData?: (chunk: string) => void;
|
|
588
|
-
/** Memory context to inject as system message (formatted memories from useMemoryStorage) */
|
|
589
507
|
memoryContext?: string;
|
|
590
508
|
}
|
|
591
|
-
/**
|
|
592
|
-
* Base success result from sendMessage with storage
|
|
593
|
-
*/
|
|
594
509
|
interface BaseSendMessageSuccessResult {
|
|
595
510
|
data: LlmapiChatCompletionResponse;
|
|
596
511
|
error: null;
|
|
597
512
|
userMessage: StoredMessage;
|
|
598
513
|
assistantMessage: StoredMessage;
|
|
599
514
|
}
|
|
600
|
-
/**
|
|
601
|
-
* Base error result from sendMessage with storage
|
|
602
|
-
*/
|
|
603
515
|
interface BaseSendMessageErrorResult {
|
|
604
516
|
data: null;
|
|
605
517
|
error: string;
|
|
606
518
|
userMessage?: StoredMessage;
|
|
607
519
|
assistantMessage?: undefined;
|
|
608
520
|
}
|
|
609
|
-
/**
|
|
610
|
-
* Base result type from sendMessage with storage
|
|
611
|
-
*/
|
|
612
521
|
type BaseSendMessageWithStorageResult = BaseSendMessageSuccessResult | BaseSendMessageErrorResult;
|
|
613
|
-
/**
|
|
614
|
-
* Base result returned by useChatStorage hook (shared between React and Expo)
|
|
615
|
-
*/
|
|
616
522
|
interface BaseUseChatStorageResult {
|
|
617
|
-
/** Whether a chat request is in progress */
|
|
618
523
|
isLoading: boolean;
|
|
619
|
-
/** Stop the current request */
|
|
620
524
|
stop: () => void;
|
|
621
|
-
/** Current conversation ID */
|
|
622
525
|
conversationId: string | null;
|
|
623
|
-
/** Set the current conversation ID */
|
|
624
526
|
setConversationId: (id: string | null) => void;
|
|
625
|
-
/** Create a new conversation */
|
|
626
527
|
createConversation: (options?: CreateConversationOptions) => Promise<StoredConversation>;
|
|
627
|
-
/** Get a conversation by ID */
|
|
628
528
|
getConversation: (id: string) => Promise<StoredConversation | null>;
|
|
629
|
-
/** Get all conversations (excluding soft-deleted) */
|
|
630
529
|
getConversations: () => Promise<StoredConversation[]>;
|
|
631
|
-
/** Update conversation title. Returns true if updated, false if not found. */
|
|
632
530
|
updateConversationTitle: (id: string, title: string) => Promise<boolean>;
|
|
633
|
-
/** Soft delete a conversation. Returns true if deleted, false if not found. */
|
|
634
531
|
deleteConversation: (id: string) => Promise<boolean>;
|
|
635
|
-
/** Get messages for a conversation */
|
|
636
532
|
getMessages: (conversationId: string) => Promise<StoredMessage[]>;
|
|
637
|
-
/** Get message count for a conversation */
|
|
638
533
|
getMessageCount: (conversationId: string) => Promise<number>;
|
|
639
|
-
/** Clear all messages in a conversation */
|
|
640
534
|
clearMessages: (conversationId: string) => Promise<void>;
|
|
641
535
|
}
|
|
642
|
-
/**
|
|
643
|
-
* Generate a unique ID for conversations
|
|
644
|
-
*/
|
|
645
536
|
declare function generateConversationId(): string;
|
|
646
537
|
|
|
538
|
+
declare class Message extends Model {
|
|
539
|
+
static table: string;
|
|
540
|
+
static associations: Associations;
|
|
541
|
+
messageId: number;
|
|
542
|
+
conversationId: string;
|
|
543
|
+
role: ChatRole;
|
|
544
|
+
content: string;
|
|
545
|
+
model?: string;
|
|
546
|
+
files?: FileMetadata[];
|
|
547
|
+
createdAt: Date;
|
|
548
|
+
updatedAt: Date;
|
|
549
|
+
vector?: number[];
|
|
550
|
+
embeddingModel?: string;
|
|
551
|
+
usage?: ChatCompletionUsage;
|
|
552
|
+
sources?: SearchSource[];
|
|
553
|
+
responseDuration?: number;
|
|
554
|
+
wasStopped?: boolean;
|
|
555
|
+
}
|
|
556
|
+
declare class Conversation extends Model {
|
|
557
|
+
static table: string;
|
|
558
|
+
static associations: Associations;
|
|
559
|
+
conversationId: string;
|
|
560
|
+
title: string;
|
|
561
|
+
createdAt: Date;
|
|
562
|
+
updatedAt: Date;
|
|
563
|
+
isDeleted: boolean;
|
|
564
|
+
}
|
|
565
|
+
|
|
647
566
|
/**
|
|
648
567
|
* Options for useChatStorage hook (Expo version)
|
|
649
568
|
*
|
|
@@ -785,6 +704,12 @@ type UseModelsResult = {
|
|
|
785
704
|
*/
|
|
786
705
|
declare function useModels(options?: UseModelsOptions): UseModelsResult;
|
|
787
706
|
|
|
707
|
+
declare const memoryStorageSchema: Readonly<{
|
|
708
|
+
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
709
|
+
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
710
|
+
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
711
|
+
}>;
|
|
712
|
+
|
|
788
713
|
interface MemoryItem$1 {
|
|
789
714
|
type: "identity" | "preference" | "project" | "skill" | "constraint";
|
|
790
715
|
namespace: string;
|
|
@@ -798,13 +723,7 @@ interface MemoryExtractionResult {
|
|
|
798
723
|
items: MemoryItem$1[];
|
|
799
724
|
}
|
|
800
725
|
|
|
801
|
-
/**
|
|
802
|
-
* Memory type classification
|
|
803
|
-
*/
|
|
804
726
|
type MemoryType = "identity" | "preference" | "project" | "skill" | "constraint";
|
|
805
|
-
/**
|
|
806
|
-
* Base memory item (matches existing MemoryItem from memory/service.ts)
|
|
807
|
-
*/
|
|
808
727
|
interface MemoryItem {
|
|
809
728
|
type: MemoryType;
|
|
810
729
|
namespace: string;
|
|
@@ -814,137 +733,37 @@ interface MemoryItem {
|
|
|
814
733
|
confidence: number;
|
|
815
734
|
pii: boolean;
|
|
816
735
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
736
|
+
interface CreateMemoryOptions extends MemoryItem {
|
|
737
|
+
embedding?: number[];
|
|
738
|
+
embeddingModel?: string;
|
|
739
|
+
}
|
|
740
|
+
type UpdateMemoryOptions = Partial<CreateMemoryOptions>;
|
|
741
|
+
interface StoredMemory extends MemoryItem {
|
|
822
742
|
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
743
|
compositeKey: string;
|
|
839
|
-
/** Unique key (namespace:key:value) for deduplication */
|
|
840
744
|
uniqueKey: string;
|
|
841
|
-
/** ISO timestamp */
|
|
842
745
|
createdAt: Date;
|
|
843
|
-
/** ISO timestamp */
|
|
844
746
|
updatedAt: Date;
|
|
845
|
-
/** Embedding vector for semantic search */
|
|
846
747
|
embedding?: number[];
|
|
847
|
-
/** Model used to generate embedding */
|
|
848
748
|
embeddingModel?: string;
|
|
849
|
-
/** Soft delete flag */
|
|
850
749
|
isDeleted: boolean;
|
|
851
750
|
}
|
|
852
|
-
/**
|
|
853
|
-
* Memory with similarity score (returned from semantic search)
|
|
854
|
-
*/
|
|
855
751
|
interface StoredMemoryWithSimilarity extends StoredMemory {
|
|
856
|
-
/** Cosine similarity score (0-1) */
|
|
857
752
|
similarity: number;
|
|
858
753
|
}
|
|
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
754
|
interface BaseUseMemoryStorageOptions {
|
|
909
|
-
/** WatermelonDB database instance */
|
|
910
755
|
database: Database;
|
|
911
|
-
/** The model to use for fact extraction (default: "openai/gpt-4o") */
|
|
912
756
|
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
757
|
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
758
|
embeddingProvider?: "local" | "api";
|
|
926
|
-
/** Whether to automatically generate embeddings for extracted memories (default: true) */
|
|
927
759
|
generateEmbeddings?: boolean;
|
|
928
|
-
/** Callback when facts are extracted */
|
|
929
760
|
onFactsExtracted?: (facts: MemoryExtractionResult) => void;
|
|
930
|
-
/** Custom function to get auth token for API calls */
|
|
931
761
|
getToken?: () => Promise<string | null>;
|
|
932
|
-
/** Optional base URL for the API requests */
|
|
933
762
|
baseUrl?: string;
|
|
934
763
|
}
|
|
935
|
-
/**
|
|
936
|
-
* Base result returned by useMemoryStorage hook (shared between React and Expo)
|
|
937
|
-
*/
|
|
938
764
|
interface BaseUseMemoryStorageResult {
|
|
939
|
-
/** Current memories in state (reactive) */
|
|
940
765
|
memories: StoredMemory[];
|
|
941
|
-
/** Refresh memories from storage */
|
|
942
766
|
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
767
|
extractMemoriesFromMessage: (options: {
|
|
949
768
|
messages: Array<{
|
|
950
769
|
role: string;
|
|
@@ -952,89 +771,40 @@ interface BaseUseMemoryStorageResult {
|
|
|
952
771
|
}>;
|
|
953
772
|
model?: string;
|
|
954
773
|
}) => 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
774
|
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
775
|
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
776
|
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
777
|
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
778
|
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
779
|
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
780
|
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
781
|
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
782
|
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
783
|
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
784
|
removeMemories: (namespace: string, key: string) => Promise<void>;
|
|
1024
|
-
/**
|
|
1025
|
-
* Clear all memories from storage
|
|
1026
|
-
*/
|
|
1027
785
|
clearMemories: () => Promise<void>;
|
|
1028
786
|
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Generate composite key from namespace and key
|
|
1031
|
-
*/
|
|
1032
787
|
declare function generateCompositeKey(namespace: string, key: string): string;
|
|
1033
|
-
/**
|
|
1034
|
-
* Generate unique key from namespace, key, and value
|
|
1035
|
-
*/
|
|
1036
788
|
declare function generateUniqueKey(namespace: string, key: string, value: string): string;
|
|
1037
789
|
|
|
790
|
+
declare class Memory extends Model {
|
|
791
|
+
static table: string;
|
|
792
|
+
type: MemoryType;
|
|
793
|
+
namespace: string;
|
|
794
|
+
key: string;
|
|
795
|
+
value: string;
|
|
796
|
+
rawEvidence: string;
|
|
797
|
+
confidence: number;
|
|
798
|
+
pii: boolean;
|
|
799
|
+
compositeKey: string;
|
|
800
|
+
uniqueKey: string;
|
|
801
|
+
createdAt: Date;
|
|
802
|
+
updatedAt: Date;
|
|
803
|
+
embedding?: number[];
|
|
804
|
+
embeddingModel?: string;
|
|
805
|
+
isDeleted: boolean;
|
|
806
|
+
}
|
|
807
|
+
|
|
1038
808
|
/**
|
|
1039
809
|
* Options for useMemoryStorage hook (Expo version)
|
|
1040
810
|
*
|
|
@@ -1098,132 +868,4 @@ type UseMemoryStorageResult = BaseUseMemoryStorageResult;
|
|
|
1098
868
|
*/
|
|
1099
869
|
declare function useMemoryStorage(options: UseMemoryStorageOptions): UseMemoryStorageResult;
|
|
1100
870
|
|
|
1101
|
-
/**
|
|
1102
|
-
* WatermelonDB schema for chat storage
|
|
1103
|
-
*
|
|
1104
|
-
* Defines two tables:
|
|
1105
|
-
* - history: Chat messages with metadata
|
|
1106
|
-
* - conversations: Conversation metadata
|
|
1107
|
-
*/
|
|
1108
|
-
declare const chatStorageSchema: Readonly<{
|
|
1109
|
-
version: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1110
|
-
tables: _nozbe_watermelondb_Schema.TableMap;
|
|
1111
|
-
unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
|
|
1112
|
-
}>;
|
|
1113
|
-
/**
|
|
1114
|
-
* Schema migrations
|
|
1115
|
-
*/
|
|
1116
|
-
declare const chatStorageMigrations: Readonly<{
|
|
1117
|
-
validated: true;
|
|
1118
|
-
minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1119
|
-
maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
|
|
1120
|
-
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
1121
|
-
}>;
|
|
1122
|
-
|
|
1123
|
-
/**
|
|
1124
|
-
* Message model representing a single chat message
|
|
1125
|
-
*
|
|
1126
|
-
* Note: This model uses raw column accessors instead of decorators
|
|
1127
|
-
* for better TypeScript compatibility without requiring legacy decorators.
|
|
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
|
|
1181
|
-
*
|
|
1182
|
-
* Defines the memories table for storing extracted user memories
|
|
1183
|
-
* with support for vector embeddings for semantic search.
|
|
1184
|
-
*/
|
|
1185
|
-
declare const memoryStorageSchema: Readonly<{
|
|
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
|
|
1193
|
-
*
|
|
1194
|
-
* Note: This model uses raw column accessors instead of decorators
|
|
1195
|
-
* for better TypeScript compatibility without requiring legacy decorators.
|
|
1196
|
-
*/
|
|
1197
|
-
declare class Memory extends Model {
|
|
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
|
-
}
|
|
1228
|
-
|
|
1229
871
|
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 };
|