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

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,4 +1,5 @@
1
1
  import { Database, Model } from '@nozbe/watermelondb';
2
+ import * as _nozbe_watermelondb_Schema_migrations from '@nozbe/watermelondb/Schema/migrations';
2
3
  import * as _nozbe_watermelondb_Schema from '@nozbe/watermelondb/Schema';
3
4
  import { Associations } from '@nozbe/watermelondb/Model';
4
5
 
@@ -475,7 +476,7 @@ type SendMessageResult = {
475
476
  error: null;
476
477
  toolExecution?: ToolExecutionResult;
477
478
  } | {
478
- data: null;
479
+ data: LlmapiChatCompletionResponse | null;
479
480
  error: string;
480
481
  toolExecution?: ToolExecutionResult;
481
482
  };
@@ -706,6 +707,8 @@ interface StoredMessage {
706
707
  sources?: SearchSource[];
707
708
  /** Response time in seconds */
708
709
  responseDuration?: number;
710
+ /** Whether the message generation was stopped by the user */
711
+ wasStopped?: boolean;
709
712
  }
710
713
  /**
711
714
  * Stored conversation record
@@ -755,6 +758,8 @@ interface CreateMessageOptions {
755
758
  vector?: number[];
756
759
  /** Model used to generate the embedding */
757
760
  embeddingModel?: string;
761
+ /** Whether the message generation was stopped by the user */
762
+ wasStopped?: boolean;
758
763
  }
759
764
  /**
760
765
  * Options for creating a new conversation
@@ -982,6 +987,15 @@ declare const chatStorageSchema: Readonly<{
982
987
  tables: _nozbe_watermelondb_Schema.TableMap;
983
988
  unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
984
989
  }>;
990
+ /**
991
+ * Schema migrations
992
+ */
993
+ declare const chatStorageMigrations: Readonly<{
994
+ validated: true;
995
+ minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
996
+ maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
997
+ sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
998
+ }>;
985
999
 
986
1000
  /**
987
1001
  * Message model representing a single chat message
@@ -1018,6 +1032,8 @@ declare class Message extends Model {
1018
1032
  get sources(): SearchSource[] | undefined;
1019
1033
  /** Response time in seconds */
1020
1034
  get responseDuration(): number | undefined;
1035
+ /** Whether the message generation was stopped by the user */
1036
+ get wasStopped(): boolean;
1021
1037
  }
1022
1038
  /**
1023
1039
  * Conversation model representing conversation metadata
@@ -1396,6 +1412,139 @@ declare class Memory extends Model {
1396
1412
  get isDeleted(): boolean;
1397
1413
  }
1398
1414
 
1415
+ /**
1416
+ * Stored model preference record (what gets persisted to the database)
1417
+ */
1418
+ interface StoredModelPreference {
1419
+ /** Primary key (WatermelonDB auto-generated) */
1420
+ uniqueId: string;
1421
+ /** User's wallet address */
1422
+ walletAddress: string;
1423
+ /** Preferred model identifiers */
1424
+ models?: string;
1425
+ }
1426
+ /**
1427
+ * Options for creating a new model preference
1428
+ */
1429
+ interface CreateModelPreferenceOptions {
1430
+ /** User's wallet address */
1431
+ walletAddress: string;
1432
+ /** Preferred model identifiers */
1433
+ models?: string;
1434
+ }
1435
+ /**
1436
+ * Options for updating a model preference
1437
+ */
1438
+ interface UpdateModelPreferenceOptions {
1439
+ /** New preferred model identifiers */
1440
+ models?: string;
1441
+ }
1442
+ /**
1443
+ * Base options for useSettings hook
1444
+ */
1445
+ interface BaseUseSettingsOptions {
1446
+ /** WatermelonDB database instance */
1447
+ database: Database;
1448
+ /** User's wallet address */
1449
+ walletAddress?: string;
1450
+ }
1451
+ /**
1452
+ * Base result returned by useSettings hook
1453
+ */
1454
+ interface BaseUseSettingsResult {
1455
+ /** Current model preference */
1456
+ modelPreference: StoredModelPreference | null;
1457
+ /** Whether the settings are loading */
1458
+ isLoading: boolean;
1459
+ /** Get model preference by wallet address. Throws on error. */
1460
+ getModelPreference: (walletAddress: string) => Promise<StoredModelPreference | null>;
1461
+ /** Create or update model preference. Throws on error. */
1462
+ setModelPreference: (walletAddress: string, models?: string) => Promise<StoredModelPreference | null>;
1463
+ /** Delete model preference. Throws on error. */
1464
+ deleteModelPreference: (walletAddress: string) => Promise<boolean>;
1465
+ }
1466
+
1467
+ /**
1468
+ * Options for useSettings hook (React version)
1469
+ */
1470
+ interface UseSettingsOptions extends BaseUseSettingsOptions {
1471
+ }
1472
+ /**
1473
+ * Result returned by useSettings hook (React version)
1474
+ */
1475
+ interface UseSettingsResult extends BaseUseSettingsResult {
1476
+ }
1477
+ /**
1478
+ * A React hook for managing user settings with automatic persistence using WatermelonDB.
1479
+ *
1480
+ * This hook provides methods to get, set, and delete user model preferences,
1481
+ * with automatic loading of preferences when a wallet address is provided.
1482
+ *
1483
+ * @param options - Configuration options
1484
+ * @returns An object containing settings state and methods
1485
+ *
1486
+ * @example
1487
+ * ```tsx
1488
+ * import { Database } from '@nozbe/watermelondb';
1489
+ * import { useSettings } from '@reverbia/sdk/react';
1490
+ *
1491
+ * function SettingsComponent({ database }: { database: Database }) {
1492
+ * const {
1493
+ * modelPreference,
1494
+ * isLoading,
1495
+ * setModelPreference,
1496
+ * getModelPreference,
1497
+ * deleteModelPreference,
1498
+ * } = useSettings({
1499
+ * database,
1500
+ * walletAddress: '0x123...', // Optional: auto-loads preference for this wallet
1501
+ * });
1502
+ *
1503
+ * const handleModelChange = async (model: string) => {
1504
+ * await setModelPreference('0x123...', model);
1505
+ * };
1506
+ *
1507
+ * return (
1508
+ * <div>
1509
+ * <p>Current model: {modelPreference?.model ?? 'Not set'}</p>
1510
+ * <button onClick={() => handleModelChange('gpt-4o')}>
1511
+ * Use GPT-4o
1512
+ * </button>
1513
+ * </div>
1514
+ * );
1515
+ * }
1516
+ * ```
1517
+ *
1518
+ * @category Hooks
1519
+ */
1520
+ declare function useSettings(options: UseSettingsOptions): UseSettingsResult;
1521
+
1522
+ /**
1523
+ * WatermelonDB schema for settings storage
1524
+ *
1525
+ * * Defines one table::
1526
+ * - modelPreferences: Model preferences metadata
1527
+ */
1528
+ declare const settingsStorageSchema: Readonly<{
1529
+ version: _nozbe_watermelondb_Schema.SchemaVersion;
1530
+ tables: _nozbe_watermelondb_Schema.TableMap;
1531
+ unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1532
+ }>;
1533
+
1534
+ /**
1535
+ * ModelPreference model representing user model preferences
1536
+ *
1537
+ * Note: This model uses raw column accessors instead of decorators
1538
+ * for better TypeScript compatibility without requiring legacy decorators.
1539
+ */
1540
+ declare class ModelPreference extends Model {
1541
+ static table: string;
1542
+ /** User's wallet address */
1543
+ get walletAddress(): string;
1544
+ /** Preferred model identifier */
1545
+ get models(): string | undefined;
1546
+ }
1547
+
1399
1548
  interface PdfFile {
1400
1549
  url: string;
1401
1550
  mediaType?: string;
@@ -1608,4 +1757,4 @@ declare function executeTool(tool: ClientTool, params: Record<string, unknown>):
1608
1757
  error?: string;
1609
1758
  }>;
1610
1759
 
1611
- export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, DEFAULT_TOOL_SELECTOR_MODEL, type FileMetadata, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, chatStorageSchema, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, useChat, useChatStorage, useEncryption, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch };
1760
+ export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, DEFAULT_TOOL_SELECTOR_MODEL, type FileMetadata, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, settingsStorageSchema, useChat, useChatStorage, useEncryption, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings };
@@ -1,4 +1,5 @@
1
1
  import { Database, Model } from '@nozbe/watermelondb';
2
+ import * as _nozbe_watermelondb_Schema_migrations from '@nozbe/watermelondb/Schema/migrations';
2
3
  import * as _nozbe_watermelondb_Schema from '@nozbe/watermelondb/Schema';
3
4
  import { Associations } from '@nozbe/watermelondb/Model';
4
5
 
@@ -475,7 +476,7 @@ type SendMessageResult = {
475
476
  error: null;
476
477
  toolExecution?: ToolExecutionResult;
477
478
  } | {
478
- data: null;
479
+ data: LlmapiChatCompletionResponse | null;
479
480
  error: string;
480
481
  toolExecution?: ToolExecutionResult;
481
482
  };
@@ -706,6 +707,8 @@ interface StoredMessage {
706
707
  sources?: SearchSource[];
707
708
  /** Response time in seconds */
708
709
  responseDuration?: number;
710
+ /** Whether the message generation was stopped by the user */
711
+ wasStopped?: boolean;
709
712
  }
710
713
  /**
711
714
  * Stored conversation record
@@ -755,6 +758,8 @@ interface CreateMessageOptions {
755
758
  vector?: number[];
756
759
  /** Model used to generate the embedding */
757
760
  embeddingModel?: string;
761
+ /** Whether the message generation was stopped by the user */
762
+ wasStopped?: boolean;
758
763
  }
759
764
  /**
760
765
  * Options for creating a new conversation
@@ -982,6 +987,15 @@ declare const chatStorageSchema: Readonly<{
982
987
  tables: _nozbe_watermelondb_Schema.TableMap;
983
988
  unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
984
989
  }>;
990
+ /**
991
+ * Schema migrations
992
+ */
993
+ declare const chatStorageMigrations: Readonly<{
994
+ validated: true;
995
+ minVersion: _nozbe_watermelondb_Schema.SchemaVersion;
996
+ maxVersion: _nozbe_watermelondb_Schema.SchemaVersion;
997
+ sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
998
+ }>;
985
999
 
986
1000
  /**
987
1001
  * Message model representing a single chat message
@@ -1018,6 +1032,8 @@ declare class Message extends Model {
1018
1032
  get sources(): SearchSource[] | undefined;
1019
1033
  /** Response time in seconds */
1020
1034
  get responseDuration(): number | undefined;
1035
+ /** Whether the message generation was stopped by the user */
1036
+ get wasStopped(): boolean;
1021
1037
  }
1022
1038
  /**
1023
1039
  * Conversation model representing conversation metadata
@@ -1396,6 +1412,139 @@ declare class Memory extends Model {
1396
1412
  get isDeleted(): boolean;
1397
1413
  }
1398
1414
 
1415
+ /**
1416
+ * Stored model preference record (what gets persisted to the database)
1417
+ */
1418
+ interface StoredModelPreference {
1419
+ /** Primary key (WatermelonDB auto-generated) */
1420
+ uniqueId: string;
1421
+ /** User's wallet address */
1422
+ walletAddress: string;
1423
+ /** Preferred model identifiers */
1424
+ models?: string;
1425
+ }
1426
+ /**
1427
+ * Options for creating a new model preference
1428
+ */
1429
+ interface CreateModelPreferenceOptions {
1430
+ /** User's wallet address */
1431
+ walletAddress: string;
1432
+ /** Preferred model identifiers */
1433
+ models?: string;
1434
+ }
1435
+ /**
1436
+ * Options for updating a model preference
1437
+ */
1438
+ interface UpdateModelPreferenceOptions {
1439
+ /** New preferred model identifiers */
1440
+ models?: string;
1441
+ }
1442
+ /**
1443
+ * Base options for useSettings hook
1444
+ */
1445
+ interface BaseUseSettingsOptions {
1446
+ /** WatermelonDB database instance */
1447
+ database: Database;
1448
+ /** User's wallet address */
1449
+ walletAddress?: string;
1450
+ }
1451
+ /**
1452
+ * Base result returned by useSettings hook
1453
+ */
1454
+ interface BaseUseSettingsResult {
1455
+ /** Current model preference */
1456
+ modelPreference: StoredModelPreference | null;
1457
+ /** Whether the settings are loading */
1458
+ isLoading: boolean;
1459
+ /** Get model preference by wallet address. Throws on error. */
1460
+ getModelPreference: (walletAddress: string) => Promise<StoredModelPreference | null>;
1461
+ /** Create or update model preference. Throws on error. */
1462
+ setModelPreference: (walletAddress: string, models?: string) => Promise<StoredModelPreference | null>;
1463
+ /** Delete model preference. Throws on error. */
1464
+ deleteModelPreference: (walletAddress: string) => Promise<boolean>;
1465
+ }
1466
+
1467
+ /**
1468
+ * Options for useSettings hook (React version)
1469
+ */
1470
+ interface UseSettingsOptions extends BaseUseSettingsOptions {
1471
+ }
1472
+ /**
1473
+ * Result returned by useSettings hook (React version)
1474
+ */
1475
+ interface UseSettingsResult extends BaseUseSettingsResult {
1476
+ }
1477
+ /**
1478
+ * A React hook for managing user settings with automatic persistence using WatermelonDB.
1479
+ *
1480
+ * This hook provides methods to get, set, and delete user model preferences,
1481
+ * with automatic loading of preferences when a wallet address is provided.
1482
+ *
1483
+ * @param options - Configuration options
1484
+ * @returns An object containing settings state and methods
1485
+ *
1486
+ * @example
1487
+ * ```tsx
1488
+ * import { Database } from '@nozbe/watermelondb';
1489
+ * import { useSettings } from '@reverbia/sdk/react';
1490
+ *
1491
+ * function SettingsComponent({ database }: { database: Database }) {
1492
+ * const {
1493
+ * modelPreference,
1494
+ * isLoading,
1495
+ * setModelPreference,
1496
+ * getModelPreference,
1497
+ * deleteModelPreference,
1498
+ * } = useSettings({
1499
+ * database,
1500
+ * walletAddress: '0x123...', // Optional: auto-loads preference for this wallet
1501
+ * });
1502
+ *
1503
+ * const handleModelChange = async (model: string) => {
1504
+ * await setModelPreference('0x123...', model);
1505
+ * };
1506
+ *
1507
+ * return (
1508
+ * <div>
1509
+ * <p>Current model: {modelPreference?.model ?? 'Not set'}</p>
1510
+ * <button onClick={() => handleModelChange('gpt-4o')}>
1511
+ * Use GPT-4o
1512
+ * </button>
1513
+ * </div>
1514
+ * );
1515
+ * }
1516
+ * ```
1517
+ *
1518
+ * @category Hooks
1519
+ */
1520
+ declare function useSettings(options: UseSettingsOptions): UseSettingsResult;
1521
+
1522
+ /**
1523
+ * WatermelonDB schema for settings storage
1524
+ *
1525
+ * * Defines one table::
1526
+ * - modelPreferences: Model preferences metadata
1527
+ */
1528
+ declare const settingsStorageSchema: Readonly<{
1529
+ version: _nozbe_watermelondb_Schema.SchemaVersion;
1530
+ tables: _nozbe_watermelondb_Schema.TableMap;
1531
+ unsafeSql?: (_: string, __: _nozbe_watermelondb_Schema.AppSchemaUnsafeSqlKind) => string;
1532
+ }>;
1533
+
1534
+ /**
1535
+ * ModelPreference model representing user model preferences
1536
+ *
1537
+ * Note: This model uses raw column accessors instead of decorators
1538
+ * for better TypeScript compatibility without requiring legacy decorators.
1539
+ */
1540
+ declare class ModelPreference extends Model {
1541
+ static table: string;
1542
+ /** User's wallet address */
1543
+ get walletAddress(): string;
1544
+ /** Preferred model identifier */
1545
+ get models(): string | undefined;
1546
+ }
1547
+
1399
1548
  interface PdfFile {
1400
1549
  url: string;
1401
1550
  mediaType?: string;
@@ -1608,4 +1757,4 @@ declare function executeTool(tool: ClientTool, params: Record<string, unknown>):
1608
1757
  error?: string;
1609
1758
  }>;
1610
1759
 
1611
- export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, DEFAULT_TOOL_SELECTOR_MODEL, type FileMetadata, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, chatStorageSchema, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, useChat, useChatStorage, useEncryption, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch };
1760
+ export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, DEFAULT_TOOL_SELECTOR_MODEL, type FileMetadata, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, settingsStorageSchema, useChat, useChatStorage, useEncryption, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings };