@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.
@@ -1,3 +1,14 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
1
12
  // src/react/useChat.ts
2
13
  import { useCallback, useEffect, useRef, useState } from "react";
3
14
 
@@ -991,11 +1002,11 @@ async function generateLocalChatCompletion(messages, options = {}) {
991
1002
  });
992
1003
  this.cb = cb;
993
1004
  }
994
- on_finalized_text(text) {
1005
+ on_finalized_text(text4) {
995
1006
  if (signal?.aborted) {
996
1007
  throw new Error("AbortError");
997
1008
  }
998
- this.cb(text);
1009
+ this.cb(text4);
999
1010
  }
1000
1011
  }
1001
1012
  const streamer = onToken ? new CallbackStreamer(chatPipeline.tokenizer, onToken) : void 0;
@@ -1669,7 +1680,137 @@ function useEncryption(signMessage) {
1669
1680
  // src/react/useChatStorage.ts
1670
1681
  import { useCallback as useCallback2, useState as useState2, useMemo } from "react";
1671
1682
 
1672
- // src/lib/chatStorage/types.ts
1683
+ // src/lib/db/chat/schema.ts
1684
+ import { appSchema, tableSchema } from "@nozbe/watermelondb";
1685
+ import {
1686
+ schemaMigrations,
1687
+ addColumns
1688
+ } from "@nozbe/watermelondb/Schema/migrations";
1689
+ var chatStorageSchema = appSchema({
1690
+ version: 2,
1691
+ tables: [
1692
+ tableSchema({
1693
+ name: "history",
1694
+ columns: [
1695
+ { name: "message_id", type: "number" },
1696
+ { name: "conversation_id", type: "string", isIndexed: true },
1697
+ { name: "role", type: "string", isIndexed: true },
1698
+ { name: "content", type: "string" },
1699
+ { name: "model", type: "string", isOptional: true },
1700
+ { name: "files", type: "string", isOptional: true },
1701
+ { name: "created_at", type: "number", isIndexed: true },
1702
+ { name: "updated_at", type: "number" },
1703
+ { name: "vector", type: "string", isOptional: true },
1704
+ { name: "embedding_model", type: "string", isOptional: true },
1705
+ { name: "usage", type: "string", isOptional: true },
1706
+ { name: "sources", type: "string", isOptional: true },
1707
+ { name: "response_duration", type: "number", isOptional: true },
1708
+ { name: "was_stopped", type: "boolean", isOptional: true }
1709
+ ]
1710
+ }),
1711
+ tableSchema({
1712
+ name: "conversations",
1713
+ columns: [
1714
+ { name: "conversation_id", type: "string", isIndexed: true },
1715
+ { name: "title", type: "string" },
1716
+ { name: "created_at", type: "number" },
1717
+ { name: "updated_at", type: "number" },
1718
+ { name: "is_deleted", type: "boolean", isIndexed: true }
1719
+ ]
1720
+ })
1721
+ ]
1722
+ });
1723
+ var chatStorageMigrations = schemaMigrations({
1724
+ migrations: [
1725
+ {
1726
+ toVersion: 2,
1727
+ steps: [
1728
+ addColumns({
1729
+ table: "history",
1730
+ columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
1731
+ })
1732
+ ]
1733
+ }
1734
+ ]
1735
+ });
1736
+
1737
+ // src/lib/db/chat/models.ts
1738
+ import { Model } from "@nozbe/watermelondb";
1739
+ import { field, text, date, json } from "@nozbe/watermelondb/decorators";
1740
+ var Message = class extends Model {
1741
+ };
1742
+ Message.table = "history";
1743
+ Message.associations = {
1744
+ conversations: { type: "belongs_to", key: "conversation_id" }
1745
+ };
1746
+ __decorateClass([
1747
+ field("message_id")
1748
+ ], Message.prototype, "messageId", 2);
1749
+ __decorateClass([
1750
+ text("conversation_id")
1751
+ ], Message.prototype, "conversationId", 2);
1752
+ __decorateClass([
1753
+ text("role")
1754
+ ], Message.prototype, "role", 2);
1755
+ __decorateClass([
1756
+ text("content")
1757
+ ], Message.prototype, "content", 2);
1758
+ __decorateClass([
1759
+ text("model")
1760
+ ], Message.prototype, "model", 2);
1761
+ __decorateClass([
1762
+ json("files", (json3) => json3)
1763
+ ], Message.prototype, "files", 2);
1764
+ __decorateClass([
1765
+ date("created_at")
1766
+ ], Message.prototype, "createdAt", 2);
1767
+ __decorateClass([
1768
+ date("updated_at")
1769
+ ], Message.prototype, "updatedAt", 2);
1770
+ __decorateClass([
1771
+ json("vector", (json3) => json3)
1772
+ ], Message.prototype, "vector", 2);
1773
+ __decorateClass([
1774
+ text("embedding_model")
1775
+ ], Message.prototype, "embeddingModel", 2);
1776
+ __decorateClass([
1777
+ json("usage", (json3) => json3)
1778
+ ], Message.prototype, "usage", 2);
1779
+ __decorateClass([
1780
+ json("sources", (json3) => json3)
1781
+ ], Message.prototype, "sources", 2);
1782
+ __decorateClass([
1783
+ field("response_duration")
1784
+ ], Message.prototype, "responseDuration", 2);
1785
+ __decorateClass([
1786
+ field("was_stopped")
1787
+ ], Message.prototype, "wasStopped", 2);
1788
+ var Conversation = class extends Model {
1789
+ };
1790
+ Conversation.table = "conversations";
1791
+ Conversation.associations = {
1792
+ history: { type: "has_many", foreignKey: "conversation_id" }
1793
+ };
1794
+ __decorateClass([
1795
+ text("conversation_id")
1796
+ ], Conversation.prototype, "conversationId", 2);
1797
+ __decorateClass([
1798
+ text("title")
1799
+ ], Conversation.prototype, "title", 2);
1800
+ __decorateClass([
1801
+ date("created_at")
1802
+ ], Conversation.prototype, "createdAt", 2);
1803
+ __decorateClass([
1804
+ date("updated_at")
1805
+ ], Conversation.prototype, "updatedAt", 2);
1806
+ __decorateClass([
1807
+ field("is_deleted")
1808
+ ], Conversation.prototype, "isDeleted", 2);
1809
+
1810
+ // src/lib/db/chat/types.ts
1811
+ function generateConversationId() {
1812
+ return `conv_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
1813
+ }
1673
1814
  function convertUsageToStored(usage) {
1674
1815
  if (!usage) return void 0;
1675
1816
  return {
@@ -1679,11 +1820,8 @@ function convertUsageToStored(usage) {
1679
1820
  costMicroUsd: usage.cost_micro_usd
1680
1821
  };
1681
1822
  }
1682
- function generateConversationId() {
1683
- return `conv_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
1684
- }
1685
1823
 
1686
- // src/lib/chatStorage/operations.ts
1824
+ // src/lib/db/chat/operations.ts
1687
1825
  import { Q } from "@nozbe/watermelondb";
1688
1826
  function messageToStored(message) {
1689
1827
  return {
@@ -2189,191 +2327,87 @@ function useChatStorage(options) {
2189
2327
  };
2190
2328
  }
2191
2329
 
2192
- // src/lib/chatStorage/schema.ts
2193
- import { appSchema, tableSchema } from "@nozbe/watermelondb";
2194
- import { schemaMigrations, addColumns } from "@nozbe/watermelondb/Schema/migrations";
2195
- var chatStorageSchema = appSchema({
2196
- version: 2,
2330
+ // src/react/useMemoryStorage.ts
2331
+ import { useCallback as useCallback3, useState as useState3, useMemo as useMemo2, useRef as useRef2 } from "react";
2332
+ import { postApiV1ChatCompletions } from "@reverbia/sdk";
2333
+
2334
+ // src/lib/db/memory/schema.ts
2335
+ import { appSchema as appSchema2, tableSchema as tableSchema2 } from "@nozbe/watermelondb";
2336
+ var memoryStorageSchema = appSchema2({
2337
+ version: 1,
2197
2338
  tables: [
2198
- tableSchema({
2199
- name: "history",
2339
+ tableSchema2({
2340
+ name: "memories",
2200
2341
  columns: [
2201
- { name: "message_id", type: "number" },
2202
- // Sequential ID within conversation
2203
- { name: "conversation_id", type: "string", isIndexed: true },
2204
- { name: "role", type: "string", isIndexed: true },
2205
- // 'user' | 'assistant' | 'system'
2206
- { name: "content", type: "string" },
2207
- { name: "model", type: "string", isOptional: true },
2208
- { name: "files", type: "string", isOptional: true },
2209
- // JSON stringified FileMetadata[]
2342
+ { name: "type", type: "string", isIndexed: true },
2343
+ { name: "namespace", type: "string", isIndexed: true },
2344
+ { name: "key", type: "string", isIndexed: true },
2345
+ { name: "value", type: "string" },
2346
+ { name: "raw_evidence", type: "string" },
2347
+ { name: "confidence", type: "number" },
2348
+ { name: "pii", type: "boolean", isIndexed: true },
2349
+ { name: "composite_key", type: "string", isIndexed: true },
2350
+ { name: "unique_key", type: "string", isIndexed: true },
2210
2351
  { name: "created_at", type: "number", isIndexed: true },
2211
2352
  { name: "updated_at", type: "number" },
2212
- { name: "vector", type: "string", isOptional: true },
2213
- // JSON stringified number[]
2353
+ { name: "embedding", type: "string", isOptional: true },
2214
2354
  { name: "embedding_model", type: "string", isOptional: true },
2215
- { name: "usage", type: "string", isOptional: true },
2216
- // JSON stringified ChatCompletionUsage
2217
- { name: "sources", type: "string", isOptional: true },
2218
- // JSON stringified SearchSource[]
2219
- { name: "response_duration", type: "number", isOptional: true },
2220
- { name: "was_stopped", type: "boolean", isOptional: true }
2221
- ]
2222
- }),
2223
- tableSchema({
2224
- name: "conversations",
2225
- columns: [
2226
- { name: "conversation_id", type: "string", isIndexed: true },
2227
- { name: "title", type: "string" },
2228
- { name: "created_at", type: "number" },
2229
- { name: "updated_at", type: "number" },
2230
2355
  { name: "is_deleted", type: "boolean", isIndexed: true }
2231
2356
  ]
2232
2357
  })
2233
2358
  ]
2234
2359
  });
2235
- var chatStorageMigrations = schemaMigrations({
2236
- migrations: [
2237
- {
2238
- toVersion: 2,
2239
- steps: [
2240
- addColumns({
2241
- table: "history",
2242
- columns: [
2243
- { name: "was_stopped", type: "boolean", isOptional: true }
2244
- ]
2245
- })
2246
- ]
2247
- }
2248
- ]
2249
- });
2250
2360
 
2251
- // src/lib/chatStorage/models.ts
2252
- import { Model } from "@nozbe/watermelondb";
2253
- var Message = class extends Model {
2254
- /** Sequential message ID within conversation */
2255
- get messageId() {
2256
- return this._getRaw("message_id");
2257
- }
2258
- /** Links message to its conversation */
2259
- get conversationId() {
2260
- return this._getRaw("conversation_id");
2261
- }
2262
- /** Who sent the message: 'user' | 'assistant' | 'system' */
2263
- get role() {
2264
- return this._getRaw("role");
2265
- }
2266
- /** The message text content */
2267
- get content() {
2268
- return this._getRaw("content");
2269
- }
2270
- /** LLM model used (e.g., GPT-4, Claude) */
2271
- get model() {
2272
- const value = this._getRaw("model");
2273
- return value ? value : void 0;
2274
- }
2275
- /** Optional attached files */
2276
- get files() {
2277
- const raw = this._getRaw("files");
2278
- if (!raw) return void 0;
2279
- try {
2280
- return JSON.parse(raw);
2281
- } catch {
2282
- return void 0;
2283
- }
2284
- }
2285
- /** Created timestamp */
2286
- get createdAt() {
2287
- return new Date(this._getRaw("created_at"));
2288
- }
2289
- /** Updated timestamp */
2290
- get updatedAt() {
2291
- return new Date(this._getRaw("updated_at"));
2292
- }
2293
- /** Embedding vector for semantic search */
2294
- get vector() {
2295
- const raw = this._getRaw("vector");
2296
- if (!raw) return void 0;
2297
- try {
2298
- return JSON.parse(raw);
2299
- } catch {
2300
- return void 0;
2301
- }
2302
- }
2303
- /** Model used to generate embedding */
2304
- get embeddingModel() {
2305
- const value = this._getRaw("embedding_model");
2306
- return value ? value : void 0;
2307
- }
2308
- /** Token counts and cost */
2309
- get usage() {
2310
- const raw = this._getRaw("usage");
2311
- if (!raw) return void 0;
2312
- try {
2313
- return JSON.parse(raw);
2314
- } catch {
2315
- return void 0;
2316
- }
2317
- }
2318
- /** Web search sources */
2319
- get sources() {
2320
- const raw = this._getRaw("sources");
2321
- if (!raw) return void 0;
2322
- try {
2323
- return JSON.parse(raw);
2324
- } catch {
2325
- return void 0;
2326
- }
2327
- }
2328
- /** Response time in seconds */
2329
- get responseDuration() {
2330
- const value = this._getRaw("response_duration");
2331
- return value !== null && value !== void 0 ? value : void 0;
2332
- }
2333
- /** Whether the message generation was stopped by the user */
2334
- get wasStopped() {
2335
- return this._getRaw("was_stopped");
2336
- }
2337
- };
2338
- Message.table = "history";
2339
- Message.associations = {
2340
- conversations: { type: "belongs_to", key: "conversation_id" }
2341
- };
2342
- var Conversation = class extends Model {
2343
- /** Unique conversation identifier */
2344
- get conversationId() {
2345
- return this._getRaw("conversation_id");
2346
- }
2347
- /** Conversation title */
2348
- get title() {
2349
- return this._getRaw("title");
2350
- }
2351
- /** Created timestamp */
2352
- get createdAt() {
2353
- return new Date(this._getRaw("created_at"));
2354
- }
2355
- /** Updated timestamp */
2356
- get updatedAt() {
2357
- return new Date(this._getRaw("updated_at"));
2358
- }
2359
- /** Soft delete flag */
2360
- get isDeleted() {
2361
- return this._getRaw("is_deleted");
2362
- }
2363
- };
2364
- Conversation.table = "conversations";
2365
- Conversation.associations = {
2366
- history: { type: "has_many", foreignKey: "conversation_id" }
2361
+ // src/lib/db/memory/models.ts
2362
+ import { Model as Model2 } from "@nozbe/watermelondb";
2363
+ import { field as field2, text as text2, date as date2, json as json2 } from "@nozbe/watermelondb/decorators";
2364
+ var Memory = class extends Model2 {
2367
2365
  };
2366
+ Memory.table = "memories";
2367
+ __decorateClass([
2368
+ text2("type")
2369
+ ], Memory.prototype, "type", 2);
2370
+ __decorateClass([
2371
+ text2("namespace")
2372
+ ], Memory.prototype, "namespace", 2);
2373
+ __decorateClass([
2374
+ text2("key")
2375
+ ], Memory.prototype, "key", 2);
2376
+ __decorateClass([
2377
+ text2("value")
2378
+ ], Memory.prototype, "value", 2);
2379
+ __decorateClass([
2380
+ text2("raw_evidence")
2381
+ ], Memory.prototype, "rawEvidence", 2);
2382
+ __decorateClass([
2383
+ field2("confidence")
2384
+ ], Memory.prototype, "confidence", 2);
2385
+ __decorateClass([
2386
+ field2("pii")
2387
+ ], Memory.prototype, "pii", 2);
2388
+ __decorateClass([
2389
+ text2("composite_key")
2390
+ ], Memory.prototype, "compositeKey", 2);
2391
+ __decorateClass([
2392
+ text2("unique_key")
2393
+ ], Memory.prototype, "uniqueKey", 2);
2394
+ __decorateClass([
2395
+ date2("created_at")
2396
+ ], Memory.prototype, "createdAt", 2);
2397
+ __decorateClass([
2398
+ date2("updated_at")
2399
+ ], Memory.prototype, "updatedAt", 2);
2400
+ __decorateClass([
2401
+ json2("embedding", (json3) => json3)
2402
+ ], Memory.prototype, "embedding", 2);
2403
+ __decorateClass([
2404
+ text2("embedding_model")
2405
+ ], Memory.prototype, "embeddingModel", 2);
2406
+ __decorateClass([
2407
+ field2("is_deleted")
2408
+ ], Memory.prototype, "isDeleted", 2);
2368
2409
 
2369
- // src/react/useMemoryStorage.ts
2370
- import { useCallback as useCallback3, useState as useState3, useMemo as useMemo2, useRef as useRef2 } from "react";
2371
- import { postApiV1ChatCompletions } from "@reverbia/sdk";
2372
-
2373
- // src/lib/memoryStorage/operations.ts
2374
- import { Q as Q2 } from "@nozbe/watermelondb";
2375
-
2376
- // src/lib/memoryStorage/types.ts
2410
+ // src/lib/db/memory/types.ts
2377
2411
  function generateCompositeKey(namespace, key) {
2378
2412
  return `${namespace}:${key}`;
2379
2413
  }
@@ -2399,7 +2433,8 @@ function cosineSimilarity2(a, b) {
2399
2433
  return dotProduct / denominator;
2400
2434
  }
2401
2435
 
2402
- // src/lib/memoryStorage/operations.ts
2436
+ // src/lib/db/memory/operations.ts
2437
+ import { Q as Q2 } from "@nozbe/watermelondb";
2403
2438
  function memoryToStored(memory) {
2404
2439
  return {
2405
2440
  uniqueId: memory.id,
@@ -2816,7 +2851,7 @@ var DEFAULT_COMPLETION_MODEL = "openai/gpt-4o";
2816
2851
 
2817
2852
  // src/lib/memory/embeddings.ts
2818
2853
  var embeddingPipeline = null;
2819
- var generateEmbeddingForText = async (text, options = {}) => {
2854
+ var generateEmbeddingForText = async (text4, options = {}) => {
2820
2855
  const { baseUrl = BASE_URL, provider = "local" } = options;
2821
2856
  if (provider === "api") {
2822
2857
  const { getToken, model: model2 } = options;
@@ -2830,7 +2865,7 @@ var generateEmbeddingForText = async (text, options = {}) => {
2830
2865
  const response = await postApiV1Embeddings({
2831
2866
  baseUrl,
2832
2867
  body: {
2833
- input: text,
2868
+ input: text4,
2834
2869
  model: model2 ?? DEFAULT_API_EMBEDDING_MODEL
2835
2870
  },
2836
2871
  headers: {
@@ -2856,7 +2891,7 @@ var generateEmbeddingForText = async (text, options = {}) => {
2856
2891
  const { pipeline } = await import("@huggingface/transformers");
2857
2892
  embeddingPipeline = await pipeline("feature-extraction", model);
2858
2893
  }
2859
- const output = await embeddingPipeline(text, {
2894
+ const output = await embeddingPipeline(text4, {
2860
2895
  pooling: "cls",
2861
2896
  normalize: true
2862
2897
  });
@@ -2870,14 +2905,14 @@ var generateEmbeddingForText = async (text, options = {}) => {
2870
2905
  }
2871
2906
  };
2872
2907
  var generateEmbeddingForMemory = async (memory, options = {}) => {
2873
- const text = [
2908
+ const text4 = [
2874
2909
  memory.rawEvidence,
2875
2910
  memory.type,
2876
2911
  memory.namespace,
2877
2912
  memory.key,
2878
2913
  memory.value
2879
2914
  ].filter(Boolean).join(" ");
2880
- return generateEmbeddingForText(text, options);
2915
+ return generateEmbeddingForText(text4, options);
2881
2916
  };
2882
2917
 
2883
2918
  // src/react/useMemoryStorage.ts
@@ -3429,117 +3464,38 @@ function useMemoryStorage(options) {
3429
3464
  };
3430
3465
  }
3431
3466
 
3432
- // src/lib/memoryStorage/schema.ts
3433
- import { appSchema as appSchema2, tableSchema as tableSchema2 } from "@nozbe/watermelondb";
3434
- var memoryStorageSchema = appSchema2({
3467
+ // src/react/useSettings.ts
3468
+ import { useCallback as useCallback4, useState as useState4, useMemo as useMemo3, useEffect as useEffect2 } from "react";
3469
+
3470
+ // src/lib/db/settings/schema.ts
3471
+ import { appSchema as appSchema3, tableSchema as tableSchema3 } from "@nozbe/watermelondb";
3472
+ var settingsStorageSchema = appSchema3({
3435
3473
  version: 1,
3436
3474
  tables: [
3437
- tableSchema2({
3438
- name: "memories",
3475
+ tableSchema3({
3476
+ name: "modelPreferences",
3439
3477
  columns: [
3440
- // Memory type classification
3441
- { name: "type", type: "string", isIndexed: true },
3442
- // 'identity' | 'preference' | 'project' | 'skill' | 'constraint'
3443
- // Hierarchical key structure
3444
- { name: "namespace", type: "string", isIndexed: true },
3445
- { name: "key", type: "string", isIndexed: true },
3446
- { name: "value", type: "string" },
3447
- // Evidence and confidence
3448
- { name: "raw_evidence", type: "string" },
3449
- { name: "confidence", type: "number" },
3450
- { name: "pii", type: "boolean", isIndexed: true },
3451
- // Composite keys for efficient lookups
3452
- { name: "composite_key", type: "string", isIndexed: true },
3453
- // namespace:key
3454
- { name: "unique_key", type: "string", isIndexed: true },
3455
- // namespace:key:value
3456
- // Timestamps
3457
- { name: "created_at", type: "number", isIndexed: true },
3458
- { name: "updated_at", type: "number" },
3459
- // Vector embeddings for semantic search
3460
- { name: "embedding", type: "string", isOptional: true },
3461
- // JSON stringified number[]
3462
- { name: "embedding_model", type: "string", isOptional: true },
3463
- // Soft delete flag
3464
- { name: "is_deleted", type: "boolean", isIndexed: true }
3478
+ { name: "wallet_address", type: "string", isIndexed: true },
3479
+ { name: "models", type: "string", isOptional: true }
3465
3480
  ]
3466
3481
  })
3467
3482
  ]
3468
3483
  });
3469
3484
 
3470
- // src/lib/memoryStorage/models.ts
3471
- import { Model as Model2 } from "@nozbe/watermelondb";
3472
- var Memory = class extends Model2 {
3473
- /** Memory type classification */
3474
- get type() {
3475
- return this._getRaw("type");
3476
- }
3477
- /** Namespace for grouping related memories */
3478
- get namespace() {
3479
- return this._getRaw("namespace");
3480
- }
3481
- /** Key within the namespace */
3482
- get key() {
3483
- return this._getRaw("key");
3484
- }
3485
- /** The memory value/content */
3486
- get value() {
3487
- return this._getRaw("value");
3488
- }
3489
- /** Raw evidence from which this memory was extracted */
3490
- get rawEvidence() {
3491
- return this._getRaw("raw_evidence");
3492
- }
3493
- /** Confidence score (0-1) */
3494
- get confidence() {
3495
- return this._getRaw("confidence");
3496
- }
3497
- /** Whether this memory contains PII */
3498
- get pii() {
3499
- return this._getRaw("pii");
3500
- }
3501
- /** Composite key (namespace:key) for efficient lookups */
3502
- get compositeKey() {
3503
- return this._getRaw("composite_key");
3504
- }
3505
- /** Unique key (namespace:key:value) for deduplication */
3506
- get uniqueKey() {
3507
- return this._getRaw("unique_key");
3508
- }
3509
- /** Created timestamp */
3510
- get createdAt() {
3511
- return new Date(this._getRaw("created_at"));
3512
- }
3513
- /** Updated timestamp */
3514
- get updatedAt() {
3515
- return new Date(this._getRaw("updated_at"));
3516
- }
3517
- /** Embedding vector for semantic search */
3518
- get embedding() {
3519
- const raw = this._getRaw("embedding");
3520
- if (!raw) return void 0;
3521
- try {
3522
- return JSON.parse(raw);
3523
- } catch {
3524
- return void 0;
3525
- }
3526
- }
3527
- /** Model used to generate embedding */
3528
- get embeddingModel() {
3529
- const value = this._getRaw("embedding_model");
3530
- return value ? value : void 0;
3531
- }
3532
- /** Soft delete flag */
3533
- get isDeleted() {
3534
- return this._getRaw("is_deleted");
3535
- }
3485
+ // src/lib/db/settings/models.ts
3486
+ import { Model as Model3 } from "@nozbe/watermelondb";
3487
+ import { text as text3 } from "@nozbe/watermelondb/decorators";
3488
+ var ModelPreference = class extends Model3 {
3536
3489
  };
3537
- Memory.table = "memories";
3538
-
3539
- // src/react/useSettings.ts
3540
- import { useCallback as useCallback4, useState as useState4, useMemo as useMemo3, useEffect as useEffect2 } from "react";
3490
+ ModelPreference.table = "modelPreferences";
3491
+ __decorateClass([
3492
+ text3("wallet_address")
3493
+ ], ModelPreference.prototype, "walletAddress", 2);
3494
+ __decorateClass([
3495
+ text3("models")
3496
+ ], ModelPreference.prototype, "models", 2);
3541
3497
 
3542
- // src/lib/settingsStorage/operations.ts
3498
+ // src/lib/db/settings/operations.ts
3543
3499
  import { Q as Q3 } from "@nozbe/watermelondb";
3544
3500
  function modelPreferenceToStored(preference) {
3545
3501
  return {
@@ -3677,37 +3633,6 @@ function useSettings(options) {
3677
3633
  };
3678
3634
  }
3679
3635
 
3680
- // src/lib/settingsStorage/schema.ts
3681
- import { appSchema as appSchema3, tableSchema as tableSchema3 } from "@nozbe/watermelondb";
3682
- var settingsStorageSchema = appSchema3({
3683
- version: 1,
3684
- tables: [
3685
- tableSchema3({
3686
- name: "modelPreferences",
3687
- columns: [
3688
- { name: "wallet_address", type: "string", isIndexed: true },
3689
- { name: "models", type: "string", isOptional: true }
3690
- // stored as JSON stringified ModelPreference[]
3691
- ]
3692
- })
3693
- ]
3694
- });
3695
-
3696
- // src/lib/settingsStorage/models.ts
3697
- import { Model as Model3 } from "@nozbe/watermelondb";
3698
- var ModelPreference = class extends Model3 {
3699
- /** User's wallet address */
3700
- get walletAddress() {
3701
- return this._getRaw("wallet_address");
3702
- }
3703
- /** Preferred model identifier */
3704
- get models() {
3705
- const value = this._getRaw("models");
3706
- return value ? value : void 0;
3707
- }
3708
- };
3709
- ModelPreference.table = "modelPreferences";
3710
-
3711
3636
  // src/react/usePdf.ts
3712
3637
  import { useCallback as useCallback5, useState as useState5 } from "react";
3713
3638
 
@@ -3778,13 +3703,13 @@ function usePdf() {
3778
3703
  const contexts = await Promise.all(
3779
3704
  pdfFiles.map(async (file) => {
3780
3705
  try {
3781
- const text = await extractTextFromPdf(file.url);
3782
- if (!text.trim()) {
3706
+ const text4 = await extractTextFromPdf(file.url);
3707
+ if (!text4.trim()) {
3783
3708
  console.warn(`No text found in PDF ${file.filename}`);
3784
3709
  return null;
3785
3710
  }
3786
3711
  return `[Context from PDF attachment ${file.filename}]:
3787
- ${text}`;
3712
+ ${text4}`;
3788
3713
  } catch (err) {
3789
3714
  console.error(`Failed to process PDF ${file.filename}:`, err);
3790
3715
  return null;
@@ -3864,15 +3789,15 @@ function useOCR() {
3864
3789
  const result = await Tesseract.recognize(image, language);
3865
3790
  pageTexts.push(result.data.text);
3866
3791
  }
3867
- const text = pageTexts.join("\n\n");
3868
- if (!text.trim()) {
3792
+ const text4 = pageTexts.join("\n\n");
3793
+ if (!text4.trim()) {
3869
3794
  console.warn(
3870
3795
  `No text found in OCR source ${filename || "unknown"}`
3871
3796
  );
3872
3797
  return null;
3873
3798
  }
3874
3799
  return `[Context from OCR attachment ${filename || "unknown"}]:
3875
- ${text}`;
3800
+ ${text4}`;
3876
3801
  } catch (err) {
3877
3802
  console.error(
3878
3803
  `Failed to process OCR for ${file.filename || "unknown"}:`,
@@ -4362,7 +4287,10 @@ async function pushConversationToDropbox(database, conversationId, userAddress,
4362
4287
  }
4363
4288
  }
4364
4289
  }
4365
- const exportResult = await deps.exportConversation(conversationId, userAddress);
4290
+ const exportResult = await deps.exportConversation(
4291
+ conversationId,
4292
+ userAddress
4293
+ );
4366
4294
  if (!exportResult.success || !exportResult.blob) {
4367
4295
  return "failed";
4368
4296
  }
@@ -4372,7 +4300,15 @@ async function pushConversationToDropbox(database, conversationId, userAddress,
4372
4300
  if (isAuthError(err) && !_retried) {
4373
4301
  try {
4374
4302
  const newToken = await deps.requestDropboxAccess();
4375
- return pushConversationToDropbox(database, conversationId, userAddress, newToken, deps, backupFolder, true);
4303
+ return pushConversationToDropbox(
4304
+ database,
4305
+ conversationId,
4306
+ userAddress,
4307
+ newToken,
4308
+ deps,
4309
+ backupFolder,
4310
+ true
4311
+ );
4376
4312
  } catch {
4377
4313
  return "failed";
4378
4314
  }
@@ -4412,9 +4348,17 @@ async function performDropboxImport(userAddress, token, deps, onProgress, backup
4412
4348
  await deps.requestEncryptionKey(userAddress);
4413
4349
  const remoteFiles = await listDropboxFiles(token, backupFolder);
4414
4350
  if (remoteFiles.length === 0) {
4415
- return { success: false, restored: 0, failed: 0, total: 0, noBackupsFound: true };
4351
+ return {
4352
+ success: false,
4353
+ restored: 0,
4354
+ failed: 0,
4355
+ total: 0,
4356
+ noBackupsFound: true
4357
+ };
4416
4358
  }
4417
- const jsonFiles = remoteFiles.filter((file) => file.name.endsWith(".json"));
4359
+ const jsonFiles = remoteFiles.filter(
4360
+ (file) => file.name.endsWith(".json")
4361
+ );
4418
4362
  const total = jsonFiles.length;
4419
4363
  let restored = 0;
4420
4364
  let failed = 0;
@@ -4880,7 +4824,12 @@ async function getConversationsFolder(token, requestDriveAccess, rootFolder, sub
4880
4824
  async function pushConversationToDrive(database, conversationId, userAddress, token, deps, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER, _retried = false) {
4881
4825
  try {
4882
4826
  await deps.requestEncryptionKey(userAddress);
4883
- const folderResult = await getConversationsFolder(token, deps.requestDriveAccess, rootFolder, subfolder);
4827
+ const folderResult = await getConversationsFolder(
4828
+ token,
4829
+ deps.requestDriveAccess,
4830
+ rootFolder,
4831
+ subfolder
4832
+ );
4884
4833
  if (!folderResult) return "failed";
4885
4834
  const { folderId, token: activeToken } = folderResult;
4886
4835
  const filename = `${conversationId}.json`;
@@ -4898,21 +4847,38 @@ async function pushConversationToDrive(database, conversationId, userAddress, to
4898
4847
  }
4899
4848
  }
4900
4849
  }
4901
- const exportResult = await deps.exportConversation(conversationId, userAddress);
4850
+ const exportResult = await deps.exportConversation(
4851
+ conversationId,
4852
+ userAddress
4853
+ );
4902
4854
  if (!exportResult.success || !exportResult.blob) {
4903
4855
  return "failed";
4904
4856
  }
4905
4857
  if (existingFile) {
4906
4858
  await updateDriveFile(activeToken, existingFile.id, exportResult.blob);
4907
4859
  } else {
4908
- await uploadFileToDrive(activeToken, folderId, exportResult.blob, filename);
4860
+ await uploadFileToDrive(
4861
+ activeToken,
4862
+ folderId,
4863
+ exportResult.blob,
4864
+ filename
4865
+ );
4909
4866
  }
4910
4867
  return "uploaded";
4911
4868
  } catch (err) {
4912
4869
  if (isAuthError2(err) && !_retried) {
4913
4870
  try {
4914
4871
  const newToken = await deps.requestDriveAccess();
4915
- return pushConversationToDrive(database, conversationId, userAddress, newToken, deps, rootFolder, subfolder, true);
4872
+ return pushConversationToDrive(
4873
+ database,
4874
+ conversationId,
4875
+ userAddress,
4876
+ newToken,
4877
+ deps,
4878
+ rootFolder,
4879
+ subfolder,
4880
+ true
4881
+ );
4916
4882
  } catch {
4917
4883
  return "failed";
4918
4884
  }
@@ -4922,7 +4888,12 @@ async function pushConversationToDrive(database, conversationId, userAddress, to
4922
4888
  }
4923
4889
  async function performGoogleDriveExport(database, userAddress, token, deps, onProgress, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER) {
4924
4890
  await deps.requestEncryptionKey(userAddress);
4925
- const folderResult = await getConversationsFolder(token, deps.requestDriveAccess, rootFolder, subfolder);
4891
+ const folderResult = await getConversationsFolder(
4892
+ token,
4893
+ deps.requestDriveAccess,
4894
+ rootFolder,
4895
+ subfolder
4896
+ );
4926
4897
  if (!folderResult) {
4927
4898
  return { success: false, uploaded: 0, skipped: 0, total: 0 };
4928
4899
  }
@@ -4956,16 +4927,35 @@ async function performGoogleDriveExport(database, userAddress, token, deps, onPr
4956
4927
  }
4957
4928
  async function performGoogleDriveImport(userAddress, token, deps, onProgress, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER) {
4958
4929
  await deps.requestEncryptionKey(userAddress);
4959
- const folderResult = await getConversationsFolder(token, deps.requestDriveAccess, rootFolder, subfolder);
4930
+ const folderResult = await getConversationsFolder(
4931
+ token,
4932
+ deps.requestDriveAccess,
4933
+ rootFolder,
4934
+ subfolder
4935
+ );
4960
4936
  if (!folderResult) {
4961
- return { success: false, restored: 0, failed: 0, total: 0, noBackupsFound: true };
4937
+ return {
4938
+ success: false,
4939
+ restored: 0,
4940
+ failed: 0,
4941
+ total: 0,
4942
+ noBackupsFound: true
4943
+ };
4962
4944
  }
4963
4945
  const { folderId, token: activeToken } = folderResult;
4964
4946
  const remoteFiles = await listDriveFiles(activeToken, folderId);
4965
4947
  if (remoteFiles.length === 0) {
4966
- return { success: false, restored: 0, failed: 0, total: 0, noBackupsFound: true };
4948
+ return {
4949
+ success: false,
4950
+ restored: 0,
4951
+ failed: 0,
4952
+ total: 0,
4953
+ noBackupsFound: true
4954
+ };
4967
4955
  }
4968
- const jsonFiles = remoteFiles.filter((file) => file.name.endsWith(".json"));
4956
+ const jsonFiles = remoteFiles.filter(
4957
+ (file) => file.name.endsWith(".json")
4958
+ );
4969
4959
  const total = jsonFiles.length;
4970
4960
  let restored = 0;
4971
4961
  let failed = 0;