@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/react/index.mjs
CHANGED
|
@@ -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(
|
|
1005
|
+
on_finalized_text(text4) {
|
|
995
1006
|
if (signal?.aborted) {
|
|
996
1007
|
throw new Error("AbortError");
|
|
997
1008
|
}
|
|
998
|
-
this.cb(
|
|
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/
|
|
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/
|
|
1824
|
+
// src/lib/db/chat/operations.ts
|
|
1687
1825
|
import { Q } from "@nozbe/watermelondb";
|
|
1688
1826
|
function messageToStored(message) {
|
|
1689
1827
|
return {
|
|
@@ -2189,38 +2327,102 @@ function useChatStorage(options) {
|
|
|
2189
2327
|
};
|
|
2190
2328
|
}
|
|
2191
2329
|
|
|
2192
|
-
// src/lib/
|
|
2193
|
-
import { appSchema, tableSchema } from "@nozbe/watermelondb";
|
|
2194
|
-
import {
|
|
2195
|
-
|
|
2196
|
-
|
|
2330
|
+
// src/lib/db/schema.ts
|
|
2331
|
+
import { appSchema as appSchema2, tableSchema as tableSchema2 } from "@nozbe/watermelondb";
|
|
2332
|
+
import {
|
|
2333
|
+
schemaMigrations as schemaMigrations2,
|
|
2334
|
+
addColumns as addColumns2,
|
|
2335
|
+
createTable
|
|
2336
|
+
} from "@nozbe/watermelondb/Schema/migrations";
|
|
2337
|
+
|
|
2338
|
+
// src/lib/db/memory/models.ts
|
|
2339
|
+
import { Model as Model2 } from "@nozbe/watermelondb";
|
|
2340
|
+
import { field as field2, text as text2, date as date2, json as json2 } from "@nozbe/watermelondb/decorators";
|
|
2341
|
+
var Memory = class extends Model2 {
|
|
2342
|
+
};
|
|
2343
|
+
Memory.table = "memories";
|
|
2344
|
+
__decorateClass([
|
|
2345
|
+
text2("type")
|
|
2346
|
+
], Memory.prototype, "type", 2);
|
|
2347
|
+
__decorateClass([
|
|
2348
|
+
text2("namespace")
|
|
2349
|
+
], Memory.prototype, "namespace", 2);
|
|
2350
|
+
__decorateClass([
|
|
2351
|
+
text2("key")
|
|
2352
|
+
], Memory.prototype, "key", 2);
|
|
2353
|
+
__decorateClass([
|
|
2354
|
+
text2("value")
|
|
2355
|
+
], Memory.prototype, "value", 2);
|
|
2356
|
+
__decorateClass([
|
|
2357
|
+
text2("raw_evidence")
|
|
2358
|
+
], Memory.prototype, "rawEvidence", 2);
|
|
2359
|
+
__decorateClass([
|
|
2360
|
+
field2("confidence")
|
|
2361
|
+
], Memory.prototype, "confidence", 2);
|
|
2362
|
+
__decorateClass([
|
|
2363
|
+
field2("pii")
|
|
2364
|
+
], Memory.prototype, "pii", 2);
|
|
2365
|
+
__decorateClass([
|
|
2366
|
+
text2("composite_key")
|
|
2367
|
+
], Memory.prototype, "compositeKey", 2);
|
|
2368
|
+
__decorateClass([
|
|
2369
|
+
text2("unique_key")
|
|
2370
|
+
], Memory.prototype, "uniqueKey", 2);
|
|
2371
|
+
__decorateClass([
|
|
2372
|
+
date2("created_at")
|
|
2373
|
+
], Memory.prototype, "createdAt", 2);
|
|
2374
|
+
__decorateClass([
|
|
2375
|
+
date2("updated_at")
|
|
2376
|
+
], Memory.prototype, "updatedAt", 2);
|
|
2377
|
+
__decorateClass([
|
|
2378
|
+
json2("embedding", (json3) => json3)
|
|
2379
|
+
], Memory.prototype, "embedding", 2);
|
|
2380
|
+
__decorateClass([
|
|
2381
|
+
text2("embedding_model")
|
|
2382
|
+
], Memory.prototype, "embeddingModel", 2);
|
|
2383
|
+
__decorateClass([
|
|
2384
|
+
field2("is_deleted")
|
|
2385
|
+
], Memory.prototype, "isDeleted", 2);
|
|
2386
|
+
|
|
2387
|
+
// src/lib/db/settings/models.ts
|
|
2388
|
+
import { Model as Model3 } from "@nozbe/watermelondb";
|
|
2389
|
+
import { text as text3 } from "@nozbe/watermelondb/decorators";
|
|
2390
|
+
var ModelPreference = class extends Model3 {
|
|
2391
|
+
};
|
|
2392
|
+
ModelPreference.table = "modelPreferences";
|
|
2393
|
+
__decorateClass([
|
|
2394
|
+
text3("wallet_address")
|
|
2395
|
+
], ModelPreference.prototype, "walletAddress", 2);
|
|
2396
|
+
__decorateClass([
|
|
2397
|
+
text3("models")
|
|
2398
|
+
], ModelPreference.prototype, "models", 2);
|
|
2399
|
+
|
|
2400
|
+
// src/lib/db/schema.ts
|
|
2401
|
+
var SDK_SCHEMA_VERSION = 4;
|
|
2402
|
+
var sdkSchema = appSchema2({
|
|
2403
|
+
version: SDK_SCHEMA_VERSION,
|
|
2197
2404
|
tables: [
|
|
2198
|
-
|
|
2405
|
+
// Chat storage tables
|
|
2406
|
+
tableSchema2({
|
|
2199
2407
|
name: "history",
|
|
2200
2408
|
columns: [
|
|
2201
2409
|
{ name: "message_id", type: "number" },
|
|
2202
|
-
// Sequential ID within conversation
|
|
2203
2410
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
2204
2411
|
{ name: "role", type: "string", isIndexed: true },
|
|
2205
|
-
// 'user' | 'assistant' | 'system'
|
|
2206
2412
|
{ name: "content", type: "string" },
|
|
2207
2413
|
{ name: "model", type: "string", isOptional: true },
|
|
2208
2414
|
{ name: "files", type: "string", isOptional: true },
|
|
2209
|
-
// JSON stringified FileMetadata[]
|
|
2210
2415
|
{ name: "created_at", type: "number", isIndexed: true },
|
|
2211
2416
|
{ name: "updated_at", type: "number" },
|
|
2212
2417
|
{ name: "vector", type: "string", isOptional: true },
|
|
2213
|
-
// JSON stringified number[]
|
|
2214
2418
|
{ name: "embedding_model", type: "string", isOptional: true },
|
|
2215
2419
|
{ name: "usage", type: "string", isOptional: true },
|
|
2216
|
-
// JSON stringified ChatCompletionUsage
|
|
2217
2420
|
{ name: "sources", type: "string", isOptional: true },
|
|
2218
|
-
// JSON stringified SearchSource[]
|
|
2219
2421
|
{ name: "response_duration", type: "number", isOptional: true },
|
|
2220
2422
|
{ name: "was_stopped", type: "boolean", isOptional: true }
|
|
2221
2423
|
]
|
|
2222
2424
|
}),
|
|
2223
|
-
|
|
2425
|
+
tableSchema2({
|
|
2224
2426
|
name: "conversations",
|
|
2225
2427
|
columns: [
|
|
2226
2428
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -2229,151 +2431,103 @@ var chatStorageSchema = appSchema({
|
|
|
2229
2431
|
{ name: "updated_at", type: "number" },
|
|
2230
2432
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
2231
2433
|
]
|
|
2434
|
+
}),
|
|
2435
|
+
// Memory storage tables
|
|
2436
|
+
tableSchema2({
|
|
2437
|
+
name: "memories",
|
|
2438
|
+
columns: [
|
|
2439
|
+
{ name: "type", type: "string", isIndexed: true },
|
|
2440
|
+
{ name: "namespace", type: "string", isIndexed: true },
|
|
2441
|
+
{ name: "key", type: "string", isIndexed: true },
|
|
2442
|
+
{ name: "value", type: "string" },
|
|
2443
|
+
{ name: "raw_evidence", type: "string" },
|
|
2444
|
+
{ name: "confidence", type: "number" },
|
|
2445
|
+
{ name: "pii", type: "boolean", isIndexed: true },
|
|
2446
|
+
{ name: "composite_key", type: "string", isIndexed: true },
|
|
2447
|
+
{ name: "unique_key", type: "string", isIndexed: true },
|
|
2448
|
+
{ name: "created_at", type: "number", isIndexed: true },
|
|
2449
|
+
{ name: "updated_at", type: "number" },
|
|
2450
|
+
{ name: "embedding", type: "string", isOptional: true },
|
|
2451
|
+
{ name: "embedding_model", type: "string", isOptional: true },
|
|
2452
|
+
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
2453
|
+
]
|
|
2454
|
+
}),
|
|
2455
|
+
// Settings storage tables
|
|
2456
|
+
tableSchema2({
|
|
2457
|
+
name: "modelPreferences",
|
|
2458
|
+
columns: [
|
|
2459
|
+
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
2460
|
+
{ name: "models", type: "string", isOptional: true }
|
|
2461
|
+
]
|
|
2232
2462
|
})
|
|
2233
2463
|
]
|
|
2234
2464
|
});
|
|
2235
|
-
var
|
|
2465
|
+
var sdkMigrations = schemaMigrations2({
|
|
2236
2466
|
migrations: [
|
|
2467
|
+
// v2 -> v3: Added was_stopped column to history
|
|
2237
2468
|
{
|
|
2238
|
-
toVersion:
|
|
2469
|
+
toVersion: 3,
|
|
2239
2470
|
steps: [
|
|
2240
|
-
|
|
2471
|
+
addColumns2({
|
|
2241
2472
|
table: "history",
|
|
2473
|
+
columns: [{ name: "was_stopped", type: "boolean", isOptional: true }]
|
|
2474
|
+
})
|
|
2475
|
+
]
|
|
2476
|
+
},
|
|
2477
|
+
// v3 -> v4: Added settings storage (modelPreferences table)
|
|
2478
|
+
{
|
|
2479
|
+
toVersion: 4,
|
|
2480
|
+
steps: [
|
|
2481
|
+
createTable({
|
|
2482
|
+
name: "modelPreferences",
|
|
2242
2483
|
columns: [
|
|
2243
|
-
{ name: "
|
|
2484
|
+
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
2485
|
+
{ name: "models", type: "string", isOptional: true }
|
|
2244
2486
|
]
|
|
2245
2487
|
})
|
|
2246
2488
|
]
|
|
2247
2489
|
}
|
|
2248
2490
|
]
|
|
2249
2491
|
});
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
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" }
|
|
2367
|
-
};
|
|
2492
|
+
var sdkModelClasses = [
|
|
2493
|
+
Message,
|
|
2494
|
+
Conversation,
|
|
2495
|
+
Memory,
|
|
2496
|
+
ModelPreference
|
|
2497
|
+
];
|
|
2368
2498
|
|
|
2369
2499
|
// src/react/useMemoryStorage.ts
|
|
2370
2500
|
import { useCallback as useCallback3, useState as useState3, useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
2371
2501
|
import { postApiV1ChatCompletions } from "@reverbia/sdk";
|
|
2372
2502
|
|
|
2373
|
-
// src/lib/
|
|
2374
|
-
import {
|
|
2503
|
+
// src/lib/db/memory/schema.ts
|
|
2504
|
+
import { appSchema as appSchema3, tableSchema as tableSchema3 } from "@nozbe/watermelondb";
|
|
2505
|
+
var memoryStorageSchema = appSchema3({
|
|
2506
|
+
version: 1,
|
|
2507
|
+
tables: [
|
|
2508
|
+
tableSchema3({
|
|
2509
|
+
name: "memories",
|
|
2510
|
+
columns: [
|
|
2511
|
+
{ name: "type", type: "string", isIndexed: true },
|
|
2512
|
+
{ name: "namespace", type: "string", isIndexed: true },
|
|
2513
|
+
{ name: "key", type: "string", isIndexed: true },
|
|
2514
|
+
{ name: "value", type: "string" },
|
|
2515
|
+
{ name: "raw_evidence", type: "string" },
|
|
2516
|
+
{ name: "confidence", type: "number" },
|
|
2517
|
+
{ name: "pii", type: "boolean", isIndexed: true },
|
|
2518
|
+
{ name: "composite_key", type: "string", isIndexed: true },
|
|
2519
|
+
{ name: "unique_key", type: "string", isIndexed: true },
|
|
2520
|
+
{ name: "created_at", type: "number", isIndexed: true },
|
|
2521
|
+
{ name: "updated_at", type: "number" },
|
|
2522
|
+
{ name: "embedding", type: "string", isOptional: true },
|
|
2523
|
+
{ name: "embedding_model", type: "string", isOptional: true },
|
|
2524
|
+
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
2525
|
+
]
|
|
2526
|
+
})
|
|
2527
|
+
]
|
|
2528
|
+
});
|
|
2375
2529
|
|
|
2376
|
-
// src/lib/
|
|
2530
|
+
// src/lib/db/memory/types.ts
|
|
2377
2531
|
function generateCompositeKey(namespace, key) {
|
|
2378
2532
|
return `${namespace}:${key}`;
|
|
2379
2533
|
}
|
|
@@ -2399,7 +2553,8 @@ function cosineSimilarity2(a, b) {
|
|
|
2399
2553
|
return dotProduct / denominator;
|
|
2400
2554
|
}
|
|
2401
2555
|
|
|
2402
|
-
// src/lib/
|
|
2556
|
+
// src/lib/db/memory/operations.ts
|
|
2557
|
+
import { Q as Q2 } from "@nozbe/watermelondb";
|
|
2403
2558
|
function memoryToStored(memory) {
|
|
2404
2559
|
return {
|
|
2405
2560
|
uniqueId: memory.id,
|
|
@@ -2816,7 +2971,7 @@ var DEFAULT_COMPLETION_MODEL = "openai/gpt-4o";
|
|
|
2816
2971
|
|
|
2817
2972
|
// src/lib/memory/embeddings.ts
|
|
2818
2973
|
var embeddingPipeline = null;
|
|
2819
|
-
var generateEmbeddingForText = async (
|
|
2974
|
+
var generateEmbeddingForText = async (text4, options = {}) => {
|
|
2820
2975
|
const { baseUrl = BASE_URL, provider = "local" } = options;
|
|
2821
2976
|
if (provider === "api") {
|
|
2822
2977
|
const { getToken, model: model2 } = options;
|
|
@@ -2830,7 +2985,7 @@ var generateEmbeddingForText = async (text, options = {}) => {
|
|
|
2830
2985
|
const response = await postApiV1Embeddings({
|
|
2831
2986
|
baseUrl,
|
|
2832
2987
|
body: {
|
|
2833
|
-
input:
|
|
2988
|
+
input: text4,
|
|
2834
2989
|
model: model2 ?? DEFAULT_API_EMBEDDING_MODEL
|
|
2835
2990
|
},
|
|
2836
2991
|
headers: {
|
|
@@ -2856,7 +3011,7 @@ var generateEmbeddingForText = async (text, options = {}) => {
|
|
|
2856
3011
|
const { pipeline } = await import("@huggingface/transformers");
|
|
2857
3012
|
embeddingPipeline = await pipeline("feature-extraction", model);
|
|
2858
3013
|
}
|
|
2859
|
-
const output = await embeddingPipeline(
|
|
3014
|
+
const output = await embeddingPipeline(text4, {
|
|
2860
3015
|
pooling: "cls",
|
|
2861
3016
|
normalize: true
|
|
2862
3017
|
});
|
|
@@ -2870,14 +3025,14 @@ var generateEmbeddingForText = async (text, options = {}) => {
|
|
|
2870
3025
|
}
|
|
2871
3026
|
};
|
|
2872
3027
|
var generateEmbeddingForMemory = async (memory, options = {}) => {
|
|
2873
|
-
const
|
|
3028
|
+
const text4 = [
|
|
2874
3029
|
memory.rawEvidence,
|
|
2875
3030
|
memory.type,
|
|
2876
3031
|
memory.namespace,
|
|
2877
3032
|
memory.key,
|
|
2878
3033
|
memory.value
|
|
2879
3034
|
].filter(Boolean).join(" ");
|
|
2880
|
-
return generateEmbeddingForText(
|
|
3035
|
+
return generateEmbeddingForText(text4, options);
|
|
2881
3036
|
};
|
|
2882
3037
|
|
|
2883
3038
|
// src/react/useMemoryStorage.ts
|
|
@@ -3429,117 +3584,25 @@ function useMemoryStorage(options) {
|
|
|
3429
3584
|
};
|
|
3430
3585
|
}
|
|
3431
3586
|
|
|
3432
|
-
// src/
|
|
3433
|
-
import {
|
|
3434
|
-
|
|
3587
|
+
// src/react/useSettings.ts
|
|
3588
|
+
import { useCallback as useCallback4, useState as useState4, useMemo as useMemo3, useEffect as useEffect2 } from "react";
|
|
3589
|
+
|
|
3590
|
+
// src/lib/db/settings/schema.ts
|
|
3591
|
+
import { appSchema as appSchema4, tableSchema as tableSchema4 } from "@nozbe/watermelondb";
|
|
3592
|
+
var settingsStorageSchema = appSchema4({
|
|
3435
3593
|
version: 1,
|
|
3436
3594
|
tables: [
|
|
3437
|
-
|
|
3438
|
-
name: "
|
|
3595
|
+
tableSchema4({
|
|
3596
|
+
name: "modelPreferences",
|
|
3439
3597
|
columns: [
|
|
3440
|
-
|
|
3441
|
-
{ name: "
|
|
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 }
|
|
3598
|
+
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
3599
|
+
{ name: "models", type: "string", isOptional: true }
|
|
3465
3600
|
]
|
|
3466
3601
|
})
|
|
3467
3602
|
]
|
|
3468
3603
|
});
|
|
3469
3604
|
|
|
3470
|
-
// src/lib/
|
|
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
|
-
}
|
|
3536
|
-
};
|
|
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";
|
|
3541
|
-
|
|
3542
|
-
// src/lib/settingsStorage/operations.ts
|
|
3605
|
+
// src/lib/db/settings/operations.ts
|
|
3543
3606
|
import { Q as Q3 } from "@nozbe/watermelondb";
|
|
3544
3607
|
function modelPreferenceToStored(preference) {
|
|
3545
3608
|
return {
|
|
@@ -3677,37 +3740,6 @@ function useSettings(options) {
|
|
|
3677
3740
|
};
|
|
3678
3741
|
}
|
|
3679
3742
|
|
|
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
3743
|
// src/react/usePdf.ts
|
|
3712
3744
|
import { useCallback as useCallback5, useState as useState5 } from "react";
|
|
3713
3745
|
|
|
@@ -3778,13 +3810,13 @@ function usePdf() {
|
|
|
3778
3810
|
const contexts = await Promise.all(
|
|
3779
3811
|
pdfFiles.map(async (file) => {
|
|
3780
3812
|
try {
|
|
3781
|
-
const
|
|
3782
|
-
if (!
|
|
3813
|
+
const text4 = await extractTextFromPdf(file.url);
|
|
3814
|
+
if (!text4.trim()) {
|
|
3783
3815
|
console.warn(`No text found in PDF ${file.filename}`);
|
|
3784
3816
|
return null;
|
|
3785
3817
|
}
|
|
3786
3818
|
return `[Context from PDF attachment ${file.filename}]:
|
|
3787
|
-
${
|
|
3819
|
+
${text4}`;
|
|
3788
3820
|
} catch (err) {
|
|
3789
3821
|
console.error(`Failed to process PDF ${file.filename}:`, err);
|
|
3790
3822
|
return null;
|
|
@@ -3864,15 +3896,15 @@ function useOCR() {
|
|
|
3864
3896
|
const result = await Tesseract.recognize(image, language);
|
|
3865
3897
|
pageTexts.push(result.data.text);
|
|
3866
3898
|
}
|
|
3867
|
-
const
|
|
3868
|
-
if (!
|
|
3899
|
+
const text4 = pageTexts.join("\n\n");
|
|
3900
|
+
if (!text4.trim()) {
|
|
3869
3901
|
console.warn(
|
|
3870
3902
|
`No text found in OCR source ${filename || "unknown"}`
|
|
3871
3903
|
);
|
|
3872
3904
|
return null;
|
|
3873
3905
|
}
|
|
3874
3906
|
return `[Context from OCR attachment ${filename || "unknown"}]:
|
|
3875
|
-
${
|
|
3907
|
+
${text4}`;
|
|
3876
3908
|
} catch (err) {
|
|
3877
3909
|
console.error(
|
|
3878
3910
|
`Failed to process OCR for ${file.filename || "unknown"}:`,
|
|
@@ -4362,7 +4394,10 @@ async function pushConversationToDropbox(database, conversationId, userAddress,
|
|
|
4362
4394
|
}
|
|
4363
4395
|
}
|
|
4364
4396
|
}
|
|
4365
|
-
const exportResult = await deps.exportConversation(
|
|
4397
|
+
const exportResult = await deps.exportConversation(
|
|
4398
|
+
conversationId,
|
|
4399
|
+
userAddress
|
|
4400
|
+
);
|
|
4366
4401
|
if (!exportResult.success || !exportResult.blob) {
|
|
4367
4402
|
return "failed";
|
|
4368
4403
|
}
|
|
@@ -4372,7 +4407,15 @@ async function pushConversationToDropbox(database, conversationId, userAddress,
|
|
|
4372
4407
|
if (isAuthError(err) && !_retried) {
|
|
4373
4408
|
try {
|
|
4374
4409
|
const newToken = await deps.requestDropboxAccess();
|
|
4375
|
-
return pushConversationToDropbox(
|
|
4410
|
+
return pushConversationToDropbox(
|
|
4411
|
+
database,
|
|
4412
|
+
conversationId,
|
|
4413
|
+
userAddress,
|
|
4414
|
+
newToken,
|
|
4415
|
+
deps,
|
|
4416
|
+
backupFolder,
|
|
4417
|
+
true
|
|
4418
|
+
);
|
|
4376
4419
|
} catch {
|
|
4377
4420
|
return "failed";
|
|
4378
4421
|
}
|
|
@@ -4412,9 +4455,17 @@ async function performDropboxImport(userAddress, token, deps, onProgress, backup
|
|
|
4412
4455
|
await deps.requestEncryptionKey(userAddress);
|
|
4413
4456
|
const remoteFiles = await listDropboxFiles(token, backupFolder);
|
|
4414
4457
|
if (remoteFiles.length === 0) {
|
|
4415
|
-
return {
|
|
4458
|
+
return {
|
|
4459
|
+
success: false,
|
|
4460
|
+
restored: 0,
|
|
4461
|
+
failed: 0,
|
|
4462
|
+
total: 0,
|
|
4463
|
+
noBackupsFound: true
|
|
4464
|
+
};
|
|
4416
4465
|
}
|
|
4417
|
-
const jsonFiles = remoteFiles.filter(
|
|
4466
|
+
const jsonFiles = remoteFiles.filter(
|
|
4467
|
+
(file) => file.name.endsWith(".json")
|
|
4468
|
+
);
|
|
4418
4469
|
const total = jsonFiles.length;
|
|
4419
4470
|
let restored = 0;
|
|
4420
4471
|
let failed = 0;
|
|
@@ -4880,7 +4931,12 @@ async function getConversationsFolder(token, requestDriveAccess, rootFolder, sub
|
|
|
4880
4931
|
async function pushConversationToDrive(database, conversationId, userAddress, token, deps, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER, _retried = false) {
|
|
4881
4932
|
try {
|
|
4882
4933
|
await deps.requestEncryptionKey(userAddress);
|
|
4883
|
-
const folderResult = await getConversationsFolder(
|
|
4934
|
+
const folderResult = await getConversationsFolder(
|
|
4935
|
+
token,
|
|
4936
|
+
deps.requestDriveAccess,
|
|
4937
|
+
rootFolder,
|
|
4938
|
+
subfolder
|
|
4939
|
+
);
|
|
4884
4940
|
if (!folderResult) return "failed";
|
|
4885
4941
|
const { folderId, token: activeToken } = folderResult;
|
|
4886
4942
|
const filename = `${conversationId}.json`;
|
|
@@ -4898,21 +4954,38 @@ async function pushConversationToDrive(database, conversationId, userAddress, to
|
|
|
4898
4954
|
}
|
|
4899
4955
|
}
|
|
4900
4956
|
}
|
|
4901
|
-
const exportResult = await deps.exportConversation(
|
|
4957
|
+
const exportResult = await deps.exportConversation(
|
|
4958
|
+
conversationId,
|
|
4959
|
+
userAddress
|
|
4960
|
+
);
|
|
4902
4961
|
if (!exportResult.success || !exportResult.blob) {
|
|
4903
4962
|
return "failed";
|
|
4904
4963
|
}
|
|
4905
4964
|
if (existingFile) {
|
|
4906
4965
|
await updateDriveFile(activeToken, existingFile.id, exportResult.blob);
|
|
4907
4966
|
} else {
|
|
4908
|
-
await uploadFileToDrive(
|
|
4967
|
+
await uploadFileToDrive(
|
|
4968
|
+
activeToken,
|
|
4969
|
+
folderId,
|
|
4970
|
+
exportResult.blob,
|
|
4971
|
+
filename
|
|
4972
|
+
);
|
|
4909
4973
|
}
|
|
4910
4974
|
return "uploaded";
|
|
4911
4975
|
} catch (err) {
|
|
4912
4976
|
if (isAuthError2(err) && !_retried) {
|
|
4913
4977
|
try {
|
|
4914
4978
|
const newToken = await deps.requestDriveAccess();
|
|
4915
|
-
return pushConversationToDrive(
|
|
4979
|
+
return pushConversationToDrive(
|
|
4980
|
+
database,
|
|
4981
|
+
conversationId,
|
|
4982
|
+
userAddress,
|
|
4983
|
+
newToken,
|
|
4984
|
+
deps,
|
|
4985
|
+
rootFolder,
|
|
4986
|
+
subfolder,
|
|
4987
|
+
true
|
|
4988
|
+
);
|
|
4916
4989
|
} catch {
|
|
4917
4990
|
return "failed";
|
|
4918
4991
|
}
|
|
@@ -4922,7 +4995,12 @@ async function pushConversationToDrive(database, conversationId, userAddress, to
|
|
|
4922
4995
|
}
|
|
4923
4996
|
async function performGoogleDriveExport(database, userAddress, token, deps, onProgress, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER) {
|
|
4924
4997
|
await deps.requestEncryptionKey(userAddress);
|
|
4925
|
-
const folderResult = await getConversationsFolder(
|
|
4998
|
+
const folderResult = await getConversationsFolder(
|
|
4999
|
+
token,
|
|
5000
|
+
deps.requestDriveAccess,
|
|
5001
|
+
rootFolder,
|
|
5002
|
+
subfolder
|
|
5003
|
+
);
|
|
4926
5004
|
if (!folderResult) {
|
|
4927
5005
|
return { success: false, uploaded: 0, skipped: 0, total: 0 };
|
|
4928
5006
|
}
|
|
@@ -4956,16 +5034,35 @@ async function performGoogleDriveExport(database, userAddress, token, deps, onPr
|
|
|
4956
5034
|
}
|
|
4957
5035
|
async function performGoogleDriveImport(userAddress, token, deps, onProgress, rootFolder = DEFAULT_ROOT_FOLDER, subfolder = DEFAULT_CONVERSATIONS_FOLDER) {
|
|
4958
5036
|
await deps.requestEncryptionKey(userAddress);
|
|
4959
|
-
const folderResult = await getConversationsFolder(
|
|
5037
|
+
const folderResult = await getConversationsFolder(
|
|
5038
|
+
token,
|
|
5039
|
+
deps.requestDriveAccess,
|
|
5040
|
+
rootFolder,
|
|
5041
|
+
subfolder
|
|
5042
|
+
);
|
|
4960
5043
|
if (!folderResult) {
|
|
4961
|
-
return {
|
|
5044
|
+
return {
|
|
5045
|
+
success: false,
|
|
5046
|
+
restored: 0,
|
|
5047
|
+
failed: 0,
|
|
5048
|
+
total: 0,
|
|
5049
|
+
noBackupsFound: true
|
|
5050
|
+
};
|
|
4962
5051
|
}
|
|
4963
5052
|
const { folderId, token: activeToken } = folderResult;
|
|
4964
5053
|
const remoteFiles = await listDriveFiles(activeToken, folderId);
|
|
4965
5054
|
if (remoteFiles.length === 0) {
|
|
4966
|
-
return {
|
|
5055
|
+
return {
|
|
5056
|
+
success: false,
|
|
5057
|
+
restored: 0,
|
|
5058
|
+
failed: 0,
|
|
5059
|
+
total: 0,
|
|
5060
|
+
noBackupsFound: true
|
|
5061
|
+
};
|
|
4967
5062
|
}
|
|
4968
|
-
const jsonFiles = remoteFiles.filter(
|
|
5063
|
+
const jsonFiles = remoteFiles.filter(
|
|
5064
|
+
(file) => file.name.endsWith(".json")
|
|
5065
|
+
);
|
|
4969
5066
|
const total = jsonFiles.length;
|
|
4970
5067
|
let restored = 0;
|
|
4971
5068
|
let failed = 0;
|
|
@@ -5108,6 +5205,9 @@ export {
|
|
|
5108
5205
|
hasEncryptionKey,
|
|
5109
5206
|
memoryStorageSchema,
|
|
5110
5207
|
requestEncryptionKey,
|
|
5208
|
+
sdkMigrations,
|
|
5209
|
+
sdkModelClasses,
|
|
5210
|
+
sdkSchema,
|
|
5111
5211
|
selectTool,
|
|
5112
5212
|
settingsStorageSchema,
|
|
5113
5213
|
storeToken as storeDropboxToken,
|