@anuma/sdk 9.1.8 → 9.1.9
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 +79 -60
- package/dist/expo/index.mjs +80 -61
- package/dist/react/index.cjs +116 -97
- package/dist/react/index.mjs +111 -92
- package/dist/server/index.cjs +66 -53
- package/dist/server/index.mjs +66 -53
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -17614,6 +17614,9 @@ async function findQuarantinedDuplicateOp(ctx, content, sourceIds2, where) {
|
|
|
17614
17614
|
return null;
|
|
17615
17615
|
}
|
|
17616
17616
|
|
|
17617
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
17618
|
+
var import_watermelondb25 = require("@nozbe/watermelondb");
|
|
17619
|
+
|
|
17617
17620
|
// src/lib/memory/decay.ts
|
|
17618
17621
|
init_logger();
|
|
17619
17622
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -17687,6 +17690,16 @@ function classifyDecay(m, now, policy) {
|
|
|
17687
17690
|
|
|
17688
17691
|
// src/lib/db/memoryVault/photoIngest.ts
|
|
17689
17692
|
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
17693
|
+
var PHOTO_ID_QUERY_CHUNK_SIZE = 500;
|
|
17694
|
+
async function getExistingPhotoMemoryIds(ctx, rows) {
|
|
17695
|
+
const existing = /* @__PURE__ */ new Set();
|
|
17696
|
+
for (let i = 0; i < rows.length; i += PHOTO_ID_QUERY_CHUNK_SIZE) {
|
|
17697
|
+
const ids = rows.slice(i, i + PHOTO_ID_QUERY_CHUNK_SIZE).map((row) => row.memoryId);
|
|
17698
|
+
const found = await ctx.vaultMemoryCollection.query(import_watermelondb25.Q.where("id", import_watermelondb25.Q.oneOf(ids))).fetchIds();
|
|
17699
|
+
for (const id2 of found) existing.add(id2);
|
|
17700
|
+
}
|
|
17701
|
+
return existing;
|
|
17702
|
+
}
|
|
17690
17703
|
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
17691
17704
|
const byId = /* @__PURE__ */ new Map();
|
|
17692
17705
|
for (const r of rows) {
|
|
@@ -17695,7 +17708,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
17695
17708
|
}
|
|
17696
17709
|
const photoRows = [...byId.values()];
|
|
17697
17710
|
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
17698
|
-
const known = await ctx
|
|
17711
|
+
const known = await getExistingPhotoMemoryIds(ctx, photoRows);
|
|
17699
17712
|
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
17700
17713
|
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
17701
17714
|
const fresh = candidates;
|
|
@@ -17715,7 +17728,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
17715
17728
|
const now = Date.now();
|
|
17716
17729
|
let inserted = 0;
|
|
17717
17730
|
await ctx.database.write(async () => {
|
|
17718
|
-
const present =
|
|
17731
|
+
const present = await getExistingPhotoMemoryIds(ctx, fresh);
|
|
17719
17732
|
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
17720
17733
|
inserted = writable.length;
|
|
17721
17734
|
if (writable.length === 0) return;
|
|
@@ -17749,7 +17762,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
17749
17762
|
}
|
|
17750
17763
|
|
|
17751
17764
|
// src/lib/db/project/operations.ts
|
|
17752
|
-
var
|
|
17765
|
+
var import_watermelondb26 = require("@nozbe/watermelondb");
|
|
17753
17766
|
|
|
17754
17767
|
// src/lib/db/project/types.ts
|
|
17755
17768
|
function generateProjectId() {
|
|
@@ -17780,15 +17793,15 @@ async function createProjectOp(ctx, opts, defaultName = "New Project") {
|
|
|
17780
17793
|
return projectToStored(created);
|
|
17781
17794
|
}
|
|
17782
17795
|
async function getProjectOp(ctx, id2) {
|
|
17783
|
-
const results = await ctx.projectsCollection.query(
|
|
17796
|
+
const results = await ctx.projectsCollection.query(import_watermelondb26.Q.where("project_id", id2), import_watermelondb26.Q.where("is_deleted", false)).fetch();
|
|
17784
17797
|
return results.length > 0 ? projectToStored(results[0]) : null;
|
|
17785
17798
|
}
|
|
17786
17799
|
async function getProjectsOp(ctx) {
|
|
17787
|
-
const results = await ctx.projectsCollection.query(
|
|
17800
|
+
const results = await ctx.projectsCollection.query(import_watermelondb26.Q.where("is_deleted", false), import_watermelondb26.Q.sortBy("created_at", import_watermelondb26.Q.desc)).fetch();
|
|
17788
17801
|
return results.map(projectToStored);
|
|
17789
17802
|
}
|
|
17790
17803
|
async function updateProjectNameOp(ctx, id2, name) {
|
|
17791
|
-
const results = await ctx.projectsCollection.query(
|
|
17804
|
+
const results = await ctx.projectsCollection.query(import_watermelondb26.Q.where("project_id", id2), import_watermelondb26.Q.where("is_deleted", false)).fetch();
|
|
17792
17805
|
if (results.length > 0) {
|
|
17793
17806
|
await ctx.database.write(async () => {
|
|
17794
17807
|
await results[0].update((proj) => {
|
|
@@ -17800,7 +17813,7 @@ async function updateProjectNameOp(ctx, id2, name) {
|
|
|
17800
17813
|
return false;
|
|
17801
17814
|
}
|
|
17802
17815
|
async function updateProjectOp(ctx, id2, opts) {
|
|
17803
|
-
const results = await ctx.projectsCollection.query(
|
|
17816
|
+
const results = await ctx.projectsCollection.query(import_watermelondb26.Q.where("project_id", id2), import_watermelondb26.Q.where("is_deleted", false)).fetch();
|
|
17804
17817
|
if (results.length > 0) {
|
|
17805
17818
|
await ctx.database.write(async () => {
|
|
17806
17819
|
await results[0].update((proj) => {
|
|
@@ -17812,7 +17825,7 @@ async function updateProjectOp(ctx, id2, opts) {
|
|
|
17812
17825
|
return false;
|
|
17813
17826
|
}
|
|
17814
17827
|
async function deleteProjectOp(ctx, id2) {
|
|
17815
|
-
const results = await ctx.projectsCollection.query(
|
|
17828
|
+
const results = await ctx.projectsCollection.query(import_watermelondb26.Q.where("project_id", id2), import_watermelondb26.Q.where("is_deleted", false)).fetch();
|
|
17816
17829
|
if (results.length > 0) {
|
|
17817
17830
|
await ctx.database.write(async () => {
|
|
17818
17831
|
await results[0].update((proj) => {
|
|
@@ -17825,14 +17838,14 @@ async function deleteProjectOp(ctx, id2) {
|
|
|
17825
17838
|
}
|
|
17826
17839
|
async function getProjectConversationsOp(ctx, projectId) {
|
|
17827
17840
|
const results = await ctx.conversationsCollection.query(
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17841
|
+
import_watermelondb26.Q.where("project_id", projectId),
|
|
17842
|
+
import_watermelondb26.Q.where("is_deleted", false),
|
|
17843
|
+
import_watermelondb26.Q.sortBy("created_at", import_watermelondb26.Q.desc)
|
|
17831
17844
|
).fetch();
|
|
17832
17845
|
return results.map(conversationToStoredRaw);
|
|
17833
17846
|
}
|
|
17834
17847
|
async function getProjectConversationCountOp(ctx, projectId) {
|
|
17835
|
-
return await ctx.conversationsCollection.query(
|
|
17848
|
+
return await ctx.conversationsCollection.query(import_watermelondb26.Q.where("project_id", projectId), import_watermelondb26.Q.where("is_deleted", false)).fetchCount();
|
|
17836
17849
|
}
|
|
17837
17850
|
|
|
17838
17851
|
// src/lib/db/queue/manager.ts
|
|
@@ -18176,7 +18189,7 @@ var WalletPoller = class {
|
|
|
18176
18189
|
};
|
|
18177
18190
|
|
|
18178
18191
|
// src/lib/db/savedTools/operations.ts
|
|
18179
|
-
var
|
|
18192
|
+
var import_watermelondb27 = require("@nozbe/watermelondb");
|
|
18180
18193
|
function savedToolToStored(tool) {
|
|
18181
18194
|
return {
|
|
18182
18195
|
uniqueId: tool.id,
|
|
@@ -18209,7 +18222,7 @@ async function createSavedToolOp(ctx, opts) {
|
|
|
18209
18222
|
return savedToolToStored(created);
|
|
18210
18223
|
}
|
|
18211
18224
|
async function getAllSavedToolsOp(ctx) {
|
|
18212
|
-
const results = await ctx.savedToolsCollection.query(
|
|
18225
|
+
const results = await ctx.savedToolsCollection.query(import_watermelondb27.Q.where("is_deleted", false), import_watermelondb27.Q.sortBy("created_at", import_watermelondb27.Q.desc)).fetch();
|
|
18213
18226
|
return results.map(savedToolToStored);
|
|
18214
18227
|
}
|
|
18215
18228
|
async function getSavedToolByIdOp(ctx, uniqueId) {
|
|
@@ -18261,7 +18274,7 @@ async function deleteSavedToolOp(ctx, uniqueId) {
|
|
|
18261
18274
|
}
|
|
18262
18275
|
|
|
18263
18276
|
// src/lib/db/settings/operations.ts
|
|
18264
|
-
var
|
|
18277
|
+
var import_watermelondb28 = require("@nozbe/watermelondb");
|
|
18265
18278
|
function modelPreferenceToStored(preference) {
|
|
18266
18279
|
return {
|
|
18267
18280
|
uniqueId: preference.id,
|
|
@@ -18270,12 +18283,12 @@ function modelPreferenceToStored(preference) {
|
|
|
18270
18283
|
};
|
|
18271
18284
|
}
|
|
18272
18285
|
async function getModelPreferenceOp(ctx, walletAddress) {
|
|
18273
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
18286
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb28.Q.where("wallet_address", walletAddress)).fetch();
|
|
18274
18287
|
return results.length > 0 ? modelPreferenceToStored(results[0]) : null;
|
|
18275
18288
|
}
|
|
18276
18289
|
async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
18277
18290
|
const result = await ctx.database.write(async () => {
|
|
18278
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
18291
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb28.Q.where("wallet_address", walletAddress)).fetch();
|
|
18279
18292
|
if (results.length > 0) {
|
|
18280
18293
|
const preference = results[0];
|
|
18281
18294
|
await preference.update((pref) => {
|
|
@@ -18293,7 +18306,7 @@ async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
|
18293
18306
|
return modelPreferenceToStored(result);
|
|
18294
18307
|
}
|
|
18295
18308
|
async function deleteModelPreferenceOp(ctx, walletAddress) {
|
|
18296
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
18309
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb28.Q.where("wallet_address", walletAddress)).fetch();
|
|
18297
18310
|
if (results.length === 0) return false;
|
|
18298
18311
|
await ctx.database.write(async () => {
|
|
18299
18312
|
await results[0].destroyPermanently();
|
|
@@ -18302,11 +18315,11 @@ async function deleteModelPreferenceOp(ctx, walletAddress) {
|
|
|
18302
18315
|
}
|
|
18303
18316
|
|
|
18304
18317
|
// src/lib/db/settings/schema.ts
|
|
18305
|
-
var
|
|
18306
|
-
var settingsStorageSchema = (0,
|
|
18318
|
+
var import_watermelondb29 = require("@nozbe/watermelondb");
|
|
18319
|
+
var settingsStorageSchema = (0, import_watermelondb29.appSchema)({
|
|
18307
18320
|
version: 1,
|
|
18308
18321
|
tables: [
|
|
18309
|
-
(0,
|
|
18322
|
+
(0, import_watermelondb29.tableSchema)({
|
|
18310
18323
|
name: "modelPreferences",
|
|
18311
18324
|
columns: [
|
|
18312
18325
|
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
@@ -18317,7 +18330,7 @@ var settingsStorageSchema = (0, import_watermelondb28.appSchema)({
|
|
|
18317
18330
|
});
|
|
18318
18331
|
|
|
18319
18332
|
// src/lib/db/userPreferences/operations.ts
|
|
18320
|
-
var
|
|
18333
|
+
var import_watermelondb30 = require("@nozbe/watermelondb");
|
|
18321
18334
|
function userPreferenceToStored(preference) {
|
|
18322
18335
|
return {
|
|
18323
18336
|
uniqueId: preference.id,
|
|
@@ -18333,7 +18346,7 @@ function userPreferenceToStored(preference) {
|
|
|
18333
18346
|
};
|
|
18334
18347
|
}
|
|
18335
18348
|
async function getUserPreferenceOp(ctx, walletAddress) {
|
|
18336
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
18349
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", walletAddress)).fetch();
|
|
18337
18350
|
return results.length > 0 ? userPreferenceToStored(results[0]) : null;
|
|
18338
18351
|
}
|
|
18339
18352
|
async function createUserPreferenceOp(ctx, opts) {
|
|
@@ -18354,7 +18367,7 @@ async function createUserPreferenceOp(ctx, opts) {
|
|
|
18354
18367
|
return userPreferenceToStored(created);
|
|
18355
18368
|
}
|
|
18356
18369
|
async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
18357
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
18370
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", walletAddress)).fetch();
|
|
18358
18371
|
if (results.length === 0) return null;
|
|
18359
18372
|
const preference = results[0];
|
|
18360
18373
|
await ctx.database.write(async () => {
|
|
@@ -18385,7 +18398,7 @@ async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
|
18385
18398
|
async function setUserPreferenceOp(ctx, walletAddress, opts) {
|
|
18386
18399
|
const now = Date.now();
|
|
18387
18400
|
const result = await ctx.database.write(async () => {
|
|
18388
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
18401
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", walletAddress)).fetch();
|
|
18389
18402
|
if (results.length > 0) {
|
|
18390
18403
|
const preference = results[0];
|
|
18391
18404
|
await preference.update((pref) => {
|
|
@@ -18437,7 +18450,7 @@ async function updateModelsOp(ctx, walletAddress, models) {
|
|
|
18437
18450
|
return updateUserPreferenceOp(ctx, walletAddress, { models });
|
|
18438
18451
|
}
|
|
18439
18452
|
async function deleteUserPreferenceOp(ctx, walletAddress) {
|
|
18440
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
18453
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", walletAddress)).fetch();
|
|
18441
18454
|
if (results.length === 0) return false;
|
|
18442
18455
|
await ctx.database.write(async () => {
|
|
18443
18456
|
await results[0].destroyPermanently();
|
|
@@ -18452,9 +18465,9 @@ async function migrateFromModelPreferencesOp(ctx, walletAddress) {
|
|
|
18452
18465
|
if (existing) {
|
|
18453
18466
|
return existing;
|
|
18454
18467
|
}
|
|
18455
|
-
const modelResults = await ctx.modelPreferencesCollection.query(
|
|
18468
|
+
const modelResults = await ctx.modelPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", walletAddress)).fetch();
|
|
18456
18469
|
const personalityKey = `${walletAddress}_personality_settings`;
|
|
18457
|
-
const personalityResults = await ctx.modelPreferencesCollection.query(
|
|
18470
|
+
const personalityResults = await ctx.modelPreferencesCollection.query(import_watermelondb30.Q.where("wallet_address", personalityKey)).fetch();
|
|
18458
18471
|
if (modelResults.length === 0 && personalityResults.length === 0) {
|
|
18459
18472
|
return null;
|
|
18460
18473
|
}
|
|
@@ -18496,11 +18509,11 @@ async function migrateFromModelPreferencesOp(ctx, walletAddress) {
|
|
|
18496
18509
|
}
|
|
18497
18510
|
|
|
18498
18511
|
// src/lib/db/userPreferences/schema.ts
|
|
18499
|
-
var
|
|
18500
|
-
var userPreferencesStorageSchema = (0,
|
|
18512
|
+
var import_watermelondb31 = require("@nozbe/watermelondb");
|
|
18513
|
+
var userPreferencesStorageSchema = (0, import_watermelondb31.appSchema)({
|
|
18501
18514
|
version: 1,
|
|
18502
18515
|
tables: [
|
|
18503
|
-
(0,
|
|
18516
|
+
(0, import_watermelondb31.tableSchema)({
|
|
18504
18517
|
name: "userPreferences",
|
|
18505
18518
|
columns: [
|
|
18506
18519
|
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
@@ -18556,7 +18569,7 @@ var SLIDER_CONFIG = [
|
|
|
18556
18569
|
];
|
|
18557
18570
|
|
|
18558
18571
|
// src/lib/db/vaultFolders/operations.ts
|
|
18559
|
-
var
|
|
18572
|
+
var import_watermelondb32 = require("@nozbe/watermelondb");
|
|
18560
18573
|
function folderToStored(folder) {
|
|
18561
18574
|
return {
|
|
18562
18575
|
uniqueId: folder.id,
|
|
@@ -18581,7 +18594,7 @@ async function createVaultFolderOp(ctx, opts) {
|
|
|
18581
18594
|
return folderToStored(created);
|
|
18582
18595
|
}
|
|
18583
18596
|
async function getAllVaultFoldersOp(ctx) {
|
|
18584
|
-
const results = await ctx.vaultFolderCollection.query(
|
|
18597
|
+
const results = await ctx.vaultFolderCollection.query(import_watermelondb32.Q.where("is_deleted", false), import_watermelondb32.Q.sortBy("created_at", import_watermelondb32.Q.desc)).fetch();
|
|
18585
18598
|
return results.map(folderToStored);
|
|
18586
18599
|
}
|
|
18587
18600
|
async function updateVaultFolderOp(ctx, id2, opts) {
|
|
@@ -18590,7 +18603,7 @@ async function updateVaultFolderOp(ctx, id2, opts) {
|
|
|
18590
18603
|
if (record2.isDeleted) return null;
|
|
18591
18604
|
const scopeChanged = opts.scope !== void 0 && opts.scope !== record2.scope;
|
|
18592
18605
|
const updated = await ctx.database.write(async () => {
|
|
18593
|
-
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(
|
|
18606
|
+
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb32.Q.where("folder_id", id2), import_watermelondb32.Q.where("is_deleted", false)).fetch() : [];
|
|
18594
18607
|
const updates = [];
|
|
18595
18608
|
updates.push(
|
|
18596
18609
|
record2.prepareUpdate((r) => {
|
|
@@ -18619,7 +18632,7 @@ async function deleteVaultFolderOp(ctx, id2) {
|
|
|
18619
18632
|
const record2 = await ctx.vaultFolderCollection.find(id2);
|
|
18620
18633
|
if (record2.isDeleted) return false;
|
|
18621
18634
|
await ctx.database.write(async () => {
|
|
18622
|
-
const memories = await ctx.vaultMemoryCollection.query(
|
|
18635
|
+
const memories = await ctx.vaultMemoryCollection.query(import_watermelondb32.Q.where("folder_id", id2), import_watermelondb32.Q.where("is_deleted", false)).fetch();
|
|
18623
18636
|
const preparedMemories = memories.map(
|
|
18624
18637
|
(memory) => memory.prepareUpdate((r) => {
|
|
18625
18638
|
r._setRaw("folder_id", null);
|
|
@@ -18690,7 +18703,7 @@ async function updateVaultFolderContextOp(ctx, id2, context) {
|
|
|
18690
18703
|
}
|
|
18691
18704
|
}
|
|
18692
18705
|
async function getVaultFolderMemoryCountOp(ctx, folderId) {
|
|
18693
|
-
return await ctx.vaultMemoryCollection.query(
|
|
18706
|
+
return await ctx.vaultMemoryCollection.query(import_watermelondb32.Q.where("folder_id", folderId), import_watermelondb32.Q.where("is_deleted", false)).fetchCount();
|
|
18694
18707
|
}
|
|
18695
18708
|
|
|
18696
18709
|
// src/lib/db/vaultFolders/defaults.ts
|
|
@@ -18739,7 +18752,7 @@ init_logger();
|
|
|
18739
18752
|
init_internalFlowMarker();
|
|
18740
18753
|
|
|
18741
18754
|
// src/lib/memory/autoExtract.ts
|
|
18742
|
-
var
|
|
18755
|
+
var import_watermelondb33 = require("@nozbe/watermelondb");
|
|
18743
18756
|
init_logger();
|
|
18744
18757
|
init_redactor();
|
|
18745
18758
|
|
|
@@ -21552,7 +21565,7 @@ async function assertMergeTargetGoneOrThrow(ctx, targetId, expectedContent) {
|
|
|
21552
21565
|
// src/lib/memory/autoExtract.ts
|
|
21553
21566
|
async function isMemoryTopicsUserManaged(ctx, memoryId) {
|
|
21554
21567
|
try {
|
|
21555
|
-
const rows = await ctx.database.get(VaultMemory.table).query(
|
|
21568
|
+
const rows = await ctx.database.get(VaultMemory.table).query(import_watermelondb33.Q.where("id", memoryId)).fetch();
|
|
21556
21569
|
return rows[0]?.topicsUserManaged === true;
|
|
21557
21570
|
} catch {
|
|
21558
21571
|
return true;
|
|
@@ -24151,7 +24164,7 @@ function parseAnswer(body, base, parseSchema) {
|
|
|
24151
24164
|
}
|
|
24152
24165
|
|
|
24153
24166
|
// src/lib/memory/store/local.ts
|
|
24154
|
-
var
|
|
24167
|
+
var import_watermelondb34 = require("@nozbe/watermelondb");
|
|
24155
24168
|
init_logger();
|
|
24156
24169
|
|
|
24157
24170
|
// src/lib/memory/topicExtract.ts
|
|
@@ -24437,8 +24450,8 @@ function createLocalMemoryStore(options) {
|
|
|
24437
24450
|
writeOptions?.signal?.throwIfAborted();
|
|
24438
24451
|
};
|
|
24439
24452
|
const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
|
|
24440
|
-
const ownedBy = userId !== void 0 ? [
|
|
24441
|
-
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [
|
|
24453
|
+
const ownedBy = userId !== void 0 ? [import_watermelondb34.Q.where("user_id", userId)] : [];
|
|
24454
|
+
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [import_watermelondb34.Q.or(import_watermelondb34.Q.where("user_id", userId), import_watermelondb34.Q.where("user_id", null))] : [import_watermelondb34.Q.where("user_id", userId)];
|
|
24442
24455
|
const watchedColumns = [
|
|
24443
24456
|
"content",
|
|
24444
24457
|
"scope",
|
|
@@ -24484,7 +24497,7 @@ function createLocalMemoryStore(options) {
|
|
|
24484
24497
|
list: (listOptions) => getAllVaultMemoriesOp(vaultCtx, listOptions),
|
|
24485
24498
|
get: (id2) => getVaultMemoryOp(vaultCtx, id2),
|
|
24486
24499
|
listArchived: async () => {
|
|
24487
|
-
const ids = await vaultCtx.vaultMemoryCollection.query(
|
|
24500
|
+
const ids = await vaultCtx.vaultMemoryCollection.query(import_watermelondb34.Q.where("is_deleted", false), import_watermelondb34.Q.where("archived_at", import_watermelondb34.Q.notEq(null)), ...ownedBy).fetchIds();
|
|
24488
24501
|
if (ids.length === 0) return [];
|
|
24489
24502
|
const rows = await getAllVaultMemoriesOp(vaultCtx, { memoryIds: ids, includeArchived: true });
|
|
24490
24503
|
return rows.sort((a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0));
|
|
@@ -24500,7 +24513,7 @@ function createLocalMemoryStore(options) {
|
|
|
24500
24513
|
set.add(String(link.memory_id));
|
|
24501
24514
|
members.set(entityId, set);
|
|
24502
24515
|
}
|
|
24503
|
-
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(
|
|
24516
|
+
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(import_watermelondb34.Q.where("id", import_watermelondb34.Q.oneOf([...members.keys()]))).unsafeFetchRaw() : [];
|
|
24504
24517
|
const byName = /* @__PURE__ */ new Map();
|
|
24505
24518
|
for (const entity of entities) {
|
|
24506
24519
|
const name = String(entity.canonical_name);
|
|
@@ -24550,7 +24563,7 @@ function createLocalMemoryStore(options) {
|
|
|
24550
24563
|
setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
|
|
24551
24564
|
addTopics: (memoryId, topics, writeOptions) => database.write(async (writer) => {
|
|
24552
24565
|
await assertWrite(writeOptions);
|
|
24553
|
-
const owned = await vaultCtx.vaultMemoryCollection.query(
|
|
24566
|
+
const owned = await vaultCtx.vaultMemoryCollection.query(import_watermelondb34.Q.where("id", memoryId), import_watermelondb34.Q.where("is_deleted", false), ...ownedBy).fetchCount();
|
|
24554
24567
|
return owned > 0 ? writer.callWriter(
|
|
24555
24568
|
() => linkMemoryEntitiesOp(
|
|
24556
24569
|
{
|
|
@@ -24622,7 +24635,7 @@ function createLocalMemoryStore(options) {
|
|
|
24622
24635
|
else onChange();
|
|
24623
24636
|
};
|
|
24624
24637
|
};
|
|
24625
|
-
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(
|
|
24638
|
+
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(import_watermelondb34.Q.where("is_deleted", false), ...ownedBy).observeWithColumns(
|
|
24626
24639
|
subscribeOptions?.embeddings ? [...watchedColumns, "embedding", "embedding_model"] : watchedColumns
|
|
24627
24640
|
);
|
|
24628
24641
|
const subscriptions = [memories.subscribe(afterFirst())];
|
|
@@ -25617,32 +25630,38 @@ function stateFilters(options) {
|
|
|
25617
25630
|
include_superseded: options.includeSuperseded
|
|
25618
25631
|
};
|
|
25619
25632
|
}
|
|
25620
|
-
function
|
|
25621
|
-
|
|
25622
|
-
|
|
25623
|
-
return
|
|
25624
|
-
|
|
25625
|
-
|
|
25626
|
-
|
|
25627
|
-
|
|
25628
|
-
|
|
25629
|
-
|
|
25630
|
-
|
|
25631
|
-
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
|
|
25635
|
-
|
|
25636
|
-
|
|
25637
|
-
|
|
25638
|
-
|
|
25639
|
-
|
|
25640
|
-
|
|
25641
|
-
|
|
25642
|
-
|
|
25643
|
-
|
|
25644
|
-
|
|
25645
|
-
|
|
25633
|
+
function subscriptionState({ memory, version }) {
|
|
25634
|
+
const membership = memory.trust_tier === "quarantined" ? void 0 : String(!!memory.is_deleted);
|
|
25635
|
+
const hidden = membership === void 0 || memory.is_deleted || memory.archived_at !== void 0 && memory.archived_at !== null || !!memory.superseded_by;
|
|
25636
|
+
return {
|
|
25637
|
+
version,
|
|
25638
|
+
membership,
|
|
25639
|
+
fingerprint: hidden ? void 0 : (0, import_uuid6.v5)(
|
|
25640
|
+
JSON.stringify([
|
|
25641
|
+
memory.content,
|
|
25642
|
+
memory.scope,
|
|
25643
|
+
memory.updated_at,
|
|
25644
|
+
memory.fact_type,
|
|
25645
|
+
memory.event_time_start,
|
|
25646
|
+
memory.event_time_end,
|
|
25647
|
+
memory.event_time_kind,
|
|
25648
|
+
memory.trust_tier,
|
|
25649
|
+
memory.visibility,
|
|
25650
|
+
memory.published_at,
|
|
25651
|
+
memory.geohash,
|
|
25652
|
+
memory.topics,
|
|
25653
|
+
memory.topics_user_managed,
|
|
25654
|
+
memory.media,
|
|
25655
|
+
memory.source
|
|
25656
|
+
]),
|
|
25657
|
+
import_uuid6.v5.URL
|
|
25658
|
+
)
|
|
25659
|
+
};
|
|
25660
|
+
}
|
|
25661
|
+
function subscriptionKey(state, options) {
|
|
25662
|
+
if (options.includeDeleted) return state.membership;
|
|
25663
|
+
if (state.fingerprint === void 0) return void 0;
|
|
25664
|
+
return options.embeddings ? `${state.version}:${state.fingerprint}` : state.fingerprint;
|
|
25646
25665
|
}
|
|
25647
25666
|
function topicInputs(topics, source) {
|
|
25648
25667
|
return topics.flatMap((topic2) => {
|
|
@@ -25720,7 +25739,7 @@ function createRemoteMemoryStore(options) {
|
|
|
25720
25739
|
for (const record2 of records) {
|
|
25721
25740
|
const previous = seen.get(record2.memory.memory_id);
|
|
25722
25741
|
if ((previous?.version ?? 0) + 1 === record2.version)
|
|
25723
|
-
seen.set(record2.memory.memory_id, record2);
|
|
25742
|
+
seen.set(record2.memory.memory_id, subscriptionState(record2));
|
|
25724
25743
|
}
|
|
25725
25744
|
for (const subscriber of [...subscribers])
|
|
25726
25745
|
if (relevant(change, subscriber.options)) safely(subscriber.onChange);
|
|
@@ -26227,7 +26246,8 @@ function createRemoteMemoryStore(options) {
|
|
|
26227
26246
|
const failed = /* @__PURE__ */ new Map();
|
|
26228
26247
|
const collect = (page) => {
|
|
26229
26248
|
warnFailed(page.failed);
|
|
26230
|
-
|
|
26249
|
+
for (const record2 of page.items)
|
|
26250
|
+
records.push({ id: record2.memory.memory_id, state: subscriptionState(record2) });
|
|
26231
26251
|
for (const failure of page.failed) failed.set(failure.memory_id, failure.version);
|
|
26232
26252
|
};
|
|
26233
26253
|
let resume = cursor2;
|
|
@@ -26332,14 +26352,13 @@ function createRemoteMemoryStore(options) {
|
|
|
26332
26352
|
if (subscriber.options.topics) changed.add(subscriber);
|
|
26333
26353
|
}
|
|
26334
26354
|
if (topicState !== void 0) topicFingerprint = topicState;
|
|
26335
|
-
for (const
|
|
26336
|
-
const id2 = record2.memory.memory_id;
|
|
26355
|
+
for (const { id: id2, state } of records) {
|
|
26337
26356
|
const previous = seen.get(id2);
|
|
26338
|
-
seen.set(id2,
|
|
26357
|
+
seen.set(id2, state);
|
|
26339
26358
|
if (!ready) continue;
|
|
26340
26359
|
for (const subscriber of subscribers) {
|
|
26341
26360
|
const before = previous && subscriptionKey(previous, subscriber.options);
|
|
26342
|
-
if (before !== subscriptionKey(
|
|
26361
|
+
if (before !== subscriptionKey(state, subscriber.options)) changed.add(subscriber);
|
|
26343
26362
|
}
|
|
26344
26363
|
}
|
|
26345
26364
|
ready = true;
|
|
@@ -27526,17 +27545,17 @@ async function assembleMemoryContext(options) {
|
|
|
27526
27545
|
}
|
|
27527
27546
|
|
|
27528
27547
|
// src/lib/memory/durableExtraction.ts
|
|
27529
|
-
var
|
|
27548
|
+
var import_watermelondb35 = require("@nozbe/watermelondb");
|
|
27530
27549
|
async function messagePositions(storage, ids) {
|
|
27531
27550
|
try {
|
|
27532
27551
|
return await storage.messagesCollection.query(
|
|
27533
|
-
|
|
27552
|
+
import_watermelondb35.Q.unsafeSqlQuery(
|
|
27534
27553
|
`select "id", "conversation_id", "message_id" from "history" where "_status" is not 'deleted' and "id" in (${ids.map(() => "?").join(",")})`,
|
|
27535
27554
|
ids
|
|
27536
27555
|
)
|
|
27537
27556
|
).unsafeFetchRaw();
|
|
27538
27557
|
} catch {
|
|
27539
|
-
return await storage.messagesCollection.query(
|
|
27558
|
+
return await storage.messagesCollection.query(import_watermelondb35.Q.where("id", import_watermelondb35.Q.oneOf(ids))).unsafeFetchRaw();
|
|
27540
27559
|
}
|
|
27541
27560
|
}
|
|
27542
27561
|
var MAX_JOBS_PER_PASS = 3;
|
|
@@ -27709,7 +27728,7 @@ function createDurableAutoExtractor(options) {
|
|
|
27709
27728
|
const source = options.messageSource?.(conversationId);
|
|
27710
27729
|
if (source)
|
|
27711
27730
|
return await fromSource(source.status(conversationId)) === "ready" && (await loadFromSource(source, conversationId, ids)).every(Boolean);
|
|
27712
|
-
return await storage.conversationsCollection.query(
|
|
27731
|
+
return await storage.conversationsCollection.query(import_watermelondb35.Q.where("conversation_id", conversationId), import_watermelondb35.Q.where("is_deleted", false)).fetchCount() > 0 && await storage.messagesCollection.query(import_watermelondb35.Q.where("conversation_id", conversationId), import_watermelondb35.Q.where("id", import_watermelondb35.Q.oneOf(ids))).fetchCount() === ids.length;
|
|
27713
27732
|
}
|
|
27714
27733
|
function schedule(delay) {
|
|
27715
27734
|
if (disposed) return;
|
|
@@ -27883,7 +27902,7 @@ function createDurableAutoExtractor(options) {
|
|
|
27883
27902
|
let sourceWaiting = false;
|
|
27884
27903
|
try {
|
|
27885
27904
|
await writes;
|
|
27886
|
-
const pending = await jobs.query(
|
|
27905
|
+
const pending = await jobs.query(import_watermelondb35.Q.where("owner_key", owner), import_watermelondb35.Q.where("message_ids", import_watermelondb35.Q.notEq("[]"))).fetch();
|
|
27887
27906
|
storeFailures = 0;
|
|
27888
27907
|
let processed = 0;
|
|
27889
27908
|
for (const job of pending) {
|
|
@@ -27915,7 +27934,7 @@ function createDurableAutoExtractor(options) {
|
|
|
27915
27934
|
let ids = [];
|
|
27916
27935
|
let loaded = [];
|
|
27917
27936
|
try {
|
|
27918
|
-
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(
|
|
27937
|
+
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(import_watermelondb35.Q.where("conversation_id", conversationId), import_watermelondb35.Q.where("is_deleted", false)).fetchCount() > 0;
|
|
27919
27938
|
if (!present) {
|
|
27920
27939
|
await database.write(() => job.destroyPermanently());
|
|
27921
27940
|
continue;
|
|
@@ -28083,7 +28102,7 @@ function createDurableAutoExtractor(options) {
|
|
|
28083
28102
|
const scope = currentScope();
|
|
28084
28103
|
writes = writes.then(
|
|
28085
28104
|
() => database.write(async () => {
|
|
28086
|
-
const existing = await jobs.query(
|
|
28105
|
+
const existing = await jobs.query(import_watermelondb35.Q.where("owner_key", owner), import_watermelondb35.Q.where("conversation_id", conversationId)).fetch();
|
|
28087
28106
|
const job = existing.find(
|
|
28088
28107
|
(candidate) => candidate._getRaw("scope") === scope && (candidate._getRaw("folder_id") ?? null) === folderId
|
|
28089
28108
|
);
|
|
@@ -28096,8 +28115,8 @@ function createDurableAutoExtractor(options) {
|
|
|
28096
28115
|
if (watermarks.length) {
|
|
28097
28116
|
const misplaced = new Set(
|
|
28098
28117
|
await storage.messagesCollection.query(
|
|
28099
|
-
|
|
28100
|
-
|
|
28118
|
+
import_watermelondb35.Q.where("id", import_watermelondb35.Q.oneOf(watermarks)),
|
|
28119
|
+
import_watermelondb35.Q.where("conversation_id", import_watermelondb35.Q.notEq(conversationId))
|
|
28101
28120
|
).fetchIds()
|
|
28102
28121
|
);
|
|
28103
28122
|
for (const prior of existing)
|
|
@@ -32973,10 +32992,10 @@ var UNREVISIONED_COLUMNS = /* @__PURE__ */ new Set([
|
|
|
32973
32992
|
]);
|
|
32974
32993
|
async function getBackupRevision(database, conversationId) {
|
|
32975
32994
|
const serialized = await database.read(async () => {
|
|
32976
|
-
const { Q:
|
|
32995
|
+
const { Q: Q22 } = await import("@nozbe/watermelondb");
|
|
32977
32996
|
const tables = await Promise.all(
|
|
32978
32997
|
["conversations", "history"].map(
|
|
32979
|
-
(table) => database.get(table).query(
|
|
32998
|
+
(table) => database.get(table).query(Q22.where("conversation_id", conversationId), Q22.sortBy("id", Q22.asc)).unsafeFetchRaw()
|
|
32980
32999
|
)
|
|
32981
33000
|
);
|
|
32982
33001
|
return JSON.stringify(
|
|
@@ -33019,9 +33038,9 @@ async function pushConversationToICloud(database, conversationId, userAddress, d
|
|
|
33019
33038
|
}
|
|
33020
33039
|
async function performICloudExport(database, userAddress, deps, onProgress) {
|
|
33021
33040
|
await deps.requestEncryptionKey(userAddress);
|
|
33022
|
-
const { Q:
|
|
33041
|
+
const { Q: Q22 } = await import("@nozbe/watermelondb");
|
|
33023
33042
|
const conversationsCollection = database.get("conversations");
|
|
33024
|
-
const records = await conversationsCollection.query(
|
|
33043
|
+
const records = await conversationsCollection.query(Q22.where("is_deleted", false)).fetch();
|
|
33025
33044
|
const conversations = records.map(conversationToStoredRaw);
|
|
33026
33045
|
const total = conversations.length;
|
|
33027
33046
|
if (total === 0) {
|
|
@@ -36751,7 +36770,7 @@ function useExportPdf() {
|
|
|
36751
36770
|
}
|
|
36752
36771
|
|
|
36753
36772
|
// src/react/useFiles.ts
|
|
36754
|
-
var
|
|
36773
|
+
var import_watermelondb36 = require("@nozbe/watermelondb");
|
|
36755
36774
|
var import_react10 = require("react");
|
|
36756
36775
|
init_logger();
|
|
36757
36776
|
function useFiles(options) {
|
|
@@ -36770,7 +36789,7 @@ function useFiles(options) {
|
|
|
36770
36789
|
setIsLoading(true);
|
|
36771
36790
|
try {
|
|
36772
36791
|
const coll = database.get("media");
|
|
36773
|
-
await coll.query(
|
|
36792
|
+
await coll.query(import_watermelondb36.Q.take(1)).fetch();
|
|
36774
36793
|
setMediaCollection(coll);
|
|
36775
36794
|
setIsReady(true);
|
|
36776
36795
|
} catch (error) {
|
|
@@ -37992,7 +38011,7 @@ function usePhoneCalls(options = {}) {
|
|
|
37992
38011
|
}
|
|
37993
38012
|
|
|
37994
38013
|
// src/react/useProjects.ts
|
|
37995
|
-
var
|
|
38014
|
+
var import_watermelondb37 = require("@nozbe/watermelondb");
|
|
37996
38015
|
var import_react17 = require("react");
|
|
37997
38016
|
init_logger();
|
|
37998
38017
|
function useProjects(options) {
|
|
@@ -38015,7 +38034,7 @@ function useProjects(options) {
|
|
|
38015
38034
|
conversations: convColl?.table
|
|
38016
38035
|
});
|
|
38017
38036
|
getLogger().debug("[useProjects] Running test query on projects table...");
|
|
38018
|
-
const testResult = await projColl.query(
|
|
38037
|
+
const testResult = await projColl.query(import_watermelondb37.Q.take(1)).fetch();
|
|
38019
38038
|
getLogger().debug(
|
|
38020
38039
|
"[useProjects] Test query succeeded, found",
|
|
38021
38040
|
testResult.length,
|
|
@@ -38102,7 +38121,7 @@ function useProjects(options) {
|
|
|
38102
38121
|
if (!projectsCollection) {
|
|
38103
38122
|
return;
|
|
38104
38123
|
}
|
|
38105
|
-
const subscription = projectsCollection.query(
|
|
38124
|
+
const subscription = projectsCollection.query(import_watermelondb37.Q.where("is_deleted", false)).observe().subscribe((records) => {
|
|
38106
38125
|
setProjects(records.map(projectToStored));
|
|
38107
38126
|
});
|
|
38108
38127
|
return () => subscription.unsubscribe();
|
|
@@ -38224,7 +38243,7 @@ function useProjects(options) {
|
|
|
38224
38243
|
var import_react18 = require("react");
|
|
38225
38244
|
|
|
38226
38245
|
// src/react/userSettingsStore.ts
|
|
38227
|
-
var
|
|
38246
|
+
var import_watermelondb38 = require("@nozbe/watermelondb");
|
|
38228
38247
|
var EMPTY_SNAPSHOT = Object.freeze({
|
|
38229
38248
|
modelPreference: null,
|
|
38230
38249
|
userPreference: null,
|
|
@@ -38276,7 +38295,7 @@ async function startLoad(entry, walletAddress) {
|
|
|
38276
38295
|
}
|
|
38277
38296
|
function startObserve(entry, walletAddress) {
|
|
38278
38297
|
let isInitialEmission = true;
|
|
38279
|
-
entry.observeSub = entry.storageCtx.userPreferencesCollection.query(
|
|
38298
|
+
entry.observeSub = entry.storageCtx.userPreferencesCollection.query(import_watermelondb38.Q.where("wallet_address", walletAddress)).observeWithColumns([
|
|
38280
38299
|
"nickname",
|
|
38281
38300
|
"occupation",
|
|
38282
38301
|
"description",
|