@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.mjs
CHANGED
|
@@ -15758,6 +15758,9 @@ async function findQuarantinedDuplicateOp(ctx, content, sourceIds2, where) {
|
|
|
15758
15758
|
return null;
|
|
15759
15759
|
}
|
|
15760
15760
|
|
|
15761
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
15762
|
+
import { Q as Q10 } from "@nozbe/watermelondb";
|
|
15763
|
+
|
|
15761
15764
|
// src/lib/memory/decay.ts
|
|
15762
15765
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
15763
15766
|
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
@@ -15830,6 +15833,16 @@ function classifyDecay(m, now, policy) {
|
|
|
15830
15833
|
|
|
15831
15834
|
// src/lib/db/memoryVault/photoIngest.ts
|
|
15832
15835
|
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
15836
|
+
var PHOTO_ID_QUERY_CHUNK_SIZE = 500;
|
|
15837
|
+
async function getExistingPhotoMemoryIds(ctx, rows) {
|
|
15838
|
+
const existing = /* @__PURE__ */ new Set();
|
|
15839
|
+
for (let i = 0; i < rows.length; i += PHOTO_ID_QUERY_CHUNK_SIZE) {
|
|
15840
|
+
const ids = rows.slice(i, i + PHOTO_ID_QUERY_CHUNK_SIZE).map((row) => row.memoryId);
|
|
15841
|
+
const found = await ctx.vaultMemoryCollection.query(Q10.where("id", Q10.oneOf(ids))).fetchIds();
|
|
15842
|
+
for (const id2 of found) existing.add(id2);
|
|
15843
|
+
}
|
|
15844
|
+
return existing;
|
|
15845
|
+
}
|
|
15833
15846
|
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
15834
15847
|
const byId = /* @__PURE__ */ new Map();
|
|
15835
15848
|
for (const r of rows) {
|
|
@@ -15838,7 +15851,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
15838
15851
|
}
|
|
15839
15852
|
const photoRows = [...byId.values()];
|
|
15840
15853
|
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
15841
|
-
const known = await ctx
|
|
15854
|
+
const known = await getExistingPhotoMemoryIds(ctx, photoRows);
|
|
15842
15855
|
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
15843
15856
|
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
15844
15857
|
const fresh = candidates;
|
|
@@ -15858,7 +15871,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
15858
15871
|
const now = Date.now();
|
|
15859
15872
|
let inserted = 0;
|
|
15860
15873
|
await ctx.database.write(async () => {
|
|
15861
|
-
const present =
|
|
15874
|
+
const present = await getExistingPhotoMemoryIds(ctx, fresh);
|
|
15862
15875
|
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
15863
15876
|
inserted = writable.length;
|
|
15864
15877
|
if (writable.length === 0) return;
|
|
@@ -15892,7 +15905,7 @@ async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
|
15892
15905
|
}
|
|
15893
15906
|
|
|
15894
15907
|
// src/lib/db/project/operations.ts
|
|
15895
|
-
import { Q as
|
|
15908
|
+
import { Q as Q11 } from "@nozbe/watermelondb";
|
|
15896
15909
|
|
|
15897
15910
|
// src/lib/db/project/types.ts
|
|
15898
15911
|
function generateProjectId() {
|
|
@@ -15923,15 +15936,15 @@ async function createProjectOp(ctx, opts, defaultName = "New Project") {
|
|
|
15923
15936
|
return projectToStored(created);
|
|
15924
15937
|
}
|
|
15925
15938
|
async function getProjectOp(ctx, id2) {
|
|
15926
|
-
const results = await ctx.projectsCollection.query(
|
|
15939
|
+
const results = await ctx.projectsCollection.query(Q11.where("project_id", id2), Q11.where("is_deleted", false)).fetch();
|
|
15927
15940
|
return results.length > 0 ? projectToStored(results[0]) : null;
|
|
15928
15941
|
}
|
|
15929
15942
|
async function getProjectsOp(ctx) {
|
|
15930
|
-
const results = await ctx.projectsCollection.query(
|
|
15943
|
+
const results = await ctx.projectsCollection.query(Q11.where("is_deleted", false), Q11.sortBy("created_at", Q11.desc)).fetch();
|
|
15931
15944
|
return results.map(projectToStored);
|
|
15932
15945
|
}
|
|
15933
15946
|
async function updateProjectNameOp(ctx, id2, name) {
|
|
15934
|
-
const results = await ctx.projectsCollection.query(
|
|
15947
|
+
const results = await ctx.projectsCollection.query(Q11.where("project_id", id2), Q11.where("is_deleted", false)).fetch();
|
|
15935
15948
|
if (results.length > 0) {
|
|
15936
15949
|
await ctx.database.write(async () => {
|
|
15937
15950
|
await results[0].update((proj) => {
|
|
@@ -15943,7 +15956,7 @@ async function updateProjectNameOp(ctx, id2, name) {
|
|
|
15943
15956
|
return false;
|
|
15944
15957
|
}
|
|
15945
15958
|
async function updateProjectOp(ctx, id2, opts) {
|
|
15946
|
-
const results = await ctx.projectsCollection.query(
|
|
15959
|
+
const results = await ctx.projectsCollection.query(Q11.where("project_id", id2), Q11.where("is_deleted", false)).fetch();
|
|
15947
15960
|
if (results.length > 0) {
|
|
15948
15961
|
await ctx.database.write(async () => {
|
|
15949
15962
|
await results[0].update((proj) => {
|
|
@@ -15955,7 +15968,7 @@ async function updateProjectOp(ctx, id2, opts) {
|
|
|
15955
15968
|
return false;
|
|
15956
15969
|
}
|
|
15957
15970
|
async function deleteProjectOp(ctx, id2) {
|
|
15958
|
-
const results = await ctx.projectsCollection.query(
|
|
15971
|
+
const results = await ctx.projectsCollection.query(Q11.where("project_id", id2), Q11.where("is_deleted", false)).fetch();
|
|
15959
15972
|
if (results.length > 0) {
|
|
15960
15973
|
await ctx.database.write(async () => {
|
|
15961
15974
|
await results[0].update((proj) => {
|
|
@@ -15968,14 +15981,14 @@ async function deleteProjectOp(ctx, id2) {
|
|
|
15968
15981
|
}
|
|
15969
15982
|
async function getProjectConversationsOp(ctx, projectId) {
|
|
15970
15983
|
const results = await ctx.conversationsCollection.query(
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15984
|
+
Q11.where("project_id", projectId),
|
|
15985
|
+
Q11.where("is_deleted", false),
|
|
15986
|
+
Q11.sortBy("created_at", Q11.desc)
|
|
15974
15987
|
).fetch();
|
|
15975
15988
|
return results.map(conversationToStoredRaw);
|
|
15976
15989
|
}
|
|
15977
15990
|
async function getProjectConversationCountOp(ctx, projectId) {
|
|
15978
|
-
return await ctx.conversationsCollection.query(
|
|
15991
|
+
return await ctx.conversationsCollection.query(Q11.where("project_id", projectId), Q11.where("is_deleted", false)).fetchCount();
|
|
15979
15992
|
}
|
|
15980
15993
|
|
|
15981
15994
|
// src/lib/db/queue/manager.ts
|
|
@@ -16318,7 +16331,7 @@ var WalletPoller = class {
|
|
|
16318
16331
|
};
|
|
16319
16332
|
|
|
16320
16333
|
// src/lib/db/savedTools/operations.ts
|
|
16321
|
-
import { Q as
|
|
16334
|
+
import { Q as Q12 } from "@nozbe/watermelondb";
|
|
16322
16335
|
function savedToolToStored(tool) {
|
|
16323
16336
|
return {
|
|
16324
16337
|
uniqueId: tool.id,
|
|
@@ -16351,7 +16364,7 @@ async function createSavedToolOp(ctx, opts) {
|
|
|
16351
16364
|
return savedToolToStored(created);
|
|
16352
16365
|
}
|
|
16353
16366
|
async function getAllSavedToolsOp(ctx) {
|
|
16354
|
-
const results = await ctx.savedToolsCollection.query(
|
|
16367
|
+
const results = await ctx.savedToolsCollection.query(Q12.where("is_deleted", false), Q12.sortBy("created_at", Q12.desc)).fetch();
|
|
16355
16368
|
return results.map(savedToolToStored);
|
|
16356
16369
|
}
|
|
16357
16370
|
async function getSavedToolByIdOp(ctx, uniqueId) {
|
|
@@ -16403,7 +16416,7 @@ async function deleteSavedToolOp(ctx, uniqueId) {
|
|
|
16403
16416
|
}
|
|
16404
16417
|
|
|
16405
16418
|
// src/lib/db/settings/operations.ts
|
|
16406
|
-
import { Q as
|
|
16419
|
+
import { Q as Q13 } from "@nozbe/watermelondb";
|
|
16407
16420
|
function modelPreferenceToStored(preference) {
|
|
16408
16421
|
return {
|
|
16409
16422
|
uniqueId: preference.id,
|
|
@@ -16412,12 +16425,12 @@ function modelPreferenceToStored(preference) {
|
|
|
16412
16425
|
};
|
|
16413
16426
|
}
|
|
16414
16427
|
async function getModelPreferenceOp(ctx, walletAddress) {
|
|
16415
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
16428
|
+
const results = await ctx.modelPreferencesCollection.query(Q13.where("wallet_address", walletAddress)).fetch();
|
|
16416
16429
|
return results.length > 0 ? modelPreferenceToStored(results[0]) : null;
|
|
16417
16430
|
}
|
|
16418
16431
|
async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
16419
16432
|
const result = await ctx.database.write(async () => {
|
|
16420
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
16433
|
+
const results = await ctx.modelPreferencesCollection.query(Q13.where("wallet_address", walletAddress)).fetch();
|
|
16421
16434
|
if (results.length > 0) {
|
|
16422
16435
|
const preference = results[0];
|
|
16423
16436
|
await preference.update((pref) => {
|
|
@@ -16435,7 +16448,7 @@ async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
|
16435
16448
|
return modelPreferenceToStored(result);
|
|
16436
16449
|
}
|
|
16437
16450
|
async function deleteModelPreferenceOp(ctx, walletAddress) {
|
|
16438
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
16451
|
+
const results = await ctx.modelPreferencesCollection.query(Q13.where("wallet_address", walletAddress)).fetch();
|
|
16439
16452
|
if (results.length === 0) return false;
|
|
16440
16453
|
await ctx.database.write(async () => {
|
|
16441
16454
|
await results[0].destroyPermanently();
|
|
@@ -16459,7 +16472,7 @@ var settingsStorageSchema = appSchema3({
|
|
|
16459
16472
|
});
|
|
16460
16473
|
|
|
16461
16474
|
// src/lib/db/userPreferences/operations.ts
|
|
16462
|
-
import { Q as
|
|
16475
|
+
import { Q as Q14 } from "@nozbe/watermelondb";
|
|
16463
16476
|
function userPreferenceToStored(preference) {
|
|
16464
16477
|
return {
|
|
16465
16478
|
uniqueId: preference.id,
|
|
@@ -16475,7 +16488,7 @@ function userPreferenceToStored(preference) {
|
|
|
16475
16488
|
};
|
|
16476
16489
|
}
|
|
16477
16490
|
async function getUserPreferenceOp(ctx, walletAddress) {
|
|
16478
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
16491
|
+
const results = await ctx.userPreferencesCollection.query(Q14.where("wallet_address", walletAddress)).fetch();
|
|
16479
16492
|
return results.length > 0 ? userPreferenceToStored(results[0]) : null;
|
|
16480
16493
|
}
|
|
16481
16494
|
async function createUserPreferenceOp(ctx, opts) {
|
|
@@ -16496,7 +16509,7 @@ async function createUserPreferenceOp(ctx, opts) {
|
|
|
16496
16509
|
return userPreferenceToStored(created);
|
|
16497
16510
|
}
|
|
16498
16511
|
async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
16499
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
16512
|
+
const results = await ctx.userPreferencesCollection.query(Q14.where("wallet_address", walletAddress)).fetch();
|
|
16500
16513
|
if (results.length === 0) return null;
|
|
16501
16514
|
const preference = results[0];
|
|
16502
16515
|
await ctx.database.write(async () => {
|
|
@@ -16527,7 +16540,7 @@ async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
|
16527
16540
|
async function setUserPreferenceOp(ctx, walletAddress, opts) {
|
|
16528
16541
|
const now = Date.now();
|
|
16529
16542
|
const result = await ctx.database.write(async () => {
|
|
16530
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
16543
|
+
const results = await ctx.userPreferencesCollection.query(Q14.where("wallet_address", walletAddress)).fetch();
|
|
16531
16544
|
if (results.length > 0) {
|
|
16532
16545
|
const preference = results[0];
|
|
16533
16546
|
await preference.update((pref) => {
|
|
@@ -16579,7 +16592,7 @@ async function updateModelsOp(ctx, walletAddress, models) {
|
|
|
16579
16592
|
return updateUserPreferenceOp(ctx, walletAddress, { models });
|
|
16580
16593
|
}
|
|
16581
16594
|
async function deleteUserPreferenceOp(ctx, walletAddress) {
|
|
16582
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
16595
|
+
const results = await ctx.userPreferencesCollection.query(Q14.where("wallet_address", walletAddress)).fetch();
|
|
16583
16596
|
if (results.length === 0) return false;
|
|
16584
16597
|
await ctx.database.write(async () => {
|
|
16585
16598
|
await results[0].destroyPermanently();
|
|
@@ -16594,9 +16607,9 @@ async function migrateFromModelPreferencesOp(ctx, walletAddress) {
|
|
|
16594
16607
|
if (existing) {
|
|
16595
16608
|
return existing;
|
|
16596
16609
|
}
|
|
16597
|
-
const modelResults = await ctx.modelPreferencesCollection.query(
|
|
16610
|
+
const modelResults = await ctx.modelPreferencesCollection.query(Q14.where("wallet_address", walletAddress)).fetch();
|
|
16598
16611
|
const personalityKey = `${walletAddress}_personality_settings`;
|
|
16599
|
-
const personalityResults = await ctx.modelPreferencesCollection.query(
|
|
16612
|
+
const personalityResults = await ctx.modelPreferencesCollection.query(Q14.where("wallet_address", personalityKey)).fetch();
|
|
16600
16613
|
if (modelResults.length === 0 && personalityResults.length === 0) {
|
|
16601
16614
|
return null;
|
|
16602
16615
|
}
|
|
@@ -16698,7 +16711,7 @@ var SLIDER_CONFIG = [
|
|
|
16698
16711
|
];
|
|
16699
16712
|
|
|
16700
16713
|
// src/lib/db/vaultFolders/operations.ts
|
|
16701
|
-
import { Q as
|
|
16714
|
+
import { Q as Q15 } from "@nozbe/watermelondb";
|
|
16702
16715
|
function folderToStored(folder) {
|
|
16703
16716
|
return {
|
|
16704
16717
|
uniqueId: folder.id,
|
|
@@ -16723,7 +16736,7 @@ async function createVaultFolderOp(ctx, opts) {
|
|
|
16723
16736
|
return folderToStored(created);
|
|
16724
16737
|
}
|
|
16725
16738
|
async function getAllVaultFoldersOp(ctx) {
|
|
16726
|
-
const results = await ctx.vaultFolderCollection.query(
|
|
16739
|
+
const results = await ctx.vaultFolderCollection.query(Q15.where("is_deleted", false), Q15.sortBy("created_at", Q15.desc)).fetch();
|
|
16727
16740
|
return results.map(folderToStored);
|
|
16728
16741
|
}
|
|
16729
16742
|
async function updateVaultFolderOp(ctx, id2, opts) {
|
|
@@ -16732,7 +16745,7 @@ async function updateVaultFolderOp(ctx, id2, opts) {
|
|
|
16732
16745
|
if (record2.isDeleted) return null;
|
|
16733
16746
|
const scopeChanged = opts.scope !== void 0 && opts.scope !== record2.scope;
|
|
16734
16747
|
const updated = await ctx.database.write(async () => {
|
|
16735
|
-
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(
|
|
16748
|
+
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(Q15.where("folder_id", id2), Q15.where("is_deleted", false)).fetch() : [];
|
|
16736
16749
|
const updates = [];
|
|
16737
16750
|
updates.push(
|
|
16738
16751
|
record2.prepareUpdate((r) => {
|
|
@@ -16761,7 +16774,7 @@ async function deleteVaultFolderOp(ctx, id2) {
|
|
|
16761
16774
|
const record2 = await ctx.vaultFolderCollection.find(id2);
|
|
16762
16775
|
if (record2.isDeleted) return false;
|
|
16763
16776
|
await ctx.database.write(async () => {
|
|
16764
|
-
const memories = await ctx.vaultMemoryCollection.query(
|
|
16777
|
+
const memories = await ctx.vaultMemoryCollection.query(Q15.where("folder_id", id2), Q15.where("is_deleted", false)).fetch();
|
|
16765
16778
|
const preparedMemories = memories.map(
|
|
16766
16779
|
(memory) => memory.prepareUpdate((r) => {
|
|
16767
16780
|
r._setRaw("folder_id", null);
|
|
@@ -16832,7 +16845,7 @@ async function updateVaultFolderContextOp(ctx, id2, context) {
|
|
|
16832
16845
|
}
|
|
16833
16846
|
}
|
|
16834
16847
|
async function getVaultFolderMemoryCountOp(ctx, folderId) {
|
|
16835
|
-
return await ctx.vaultMemoryCollection.query(
|
|
16848
|
+
return await ctx.vaultMemoryCollection.query(Q15.where("folder_id", folderId), Q15.where("is_deleted", false)).fetchCount();
|
|
16836
16849
|
}
|
|
16837
16850
|
|
|
16838
16851
|
// src/lib/db/vaultFolders/defaults.ts
|
|
@@ -16875,7 +16888,7 @@ async function _ensureDefaultFoldersImpl(ctx) {
|
|
|
16875
16888
|
}
|
|
16876
16889
|
|
|
16877
16890
|
// src/lib/memory/autoExtract.ts
|
|
16878
|
-
import { Q as
|
|
16891
|
+
import { Q as Q16 } from "@nozbe/watermelondb";
|
|
16879
16892
|
|
|
16880
16893
|
// src/lib/memory/entitySalience.ts
|
|
16881
16894
|
var GENERIC_ENTITY_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -19669,7 +19682,7 @@ async function assertMergeTargetGoneOrThrow(ctx, targetId, expectedContent) {
|
|
|
19669
19682
|
// src/lib/memory/autoExtract.ts
|
|
19670
19683
|
async function isMemoryTopicsUserManaged(ctx, memoryId) {
|
|
19671
19684
|
try {
|
|
19672
|
-
const rows = await ctx.database.get(VaultMemory.table).query(
|
|
19685
|
+
const rows = await ctx.database.get(VaultMemory.table).query(Q16.where("id", memoryId)).fetch();
|
|
19673
19686
|
return rows[0]?.topicsUserManaged === true;
|
|
19674
19687
|
} catch {
|
|
19675
19688
|
return true;
|
|
@@ -22251,7 +22264,7 @@ function parseAnswer(body, base, parseSchema) {
|
|
|
22251
22264
|
}
|
|
22252
22265
|
|
|
22253
22266
|
// src/lib/memory/store/local.ts
|
|
22254
|
-
import { Q as
|
|
22267
|
+
import { Q as Q17 } from "@nozbe/watermelondb";
|
|
22255
22268
|
|
|
22256
22269
|
// src/lib/memory/topicExtract.ts
|
|
22257
22270
|
var TOPIC_EXTRACTION_BATCH_SIZE = 10;
|
|
@@ -22533,8 +22546,8 @@ function createLocalMemoryStore(options) {
|
|
|
22533
22546
|
writeOptions?.signal?.throwIfAborted();
|
|
22534
22547
|
};
|
|
22535
22548
|
const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
|
|
22536
|
-
const ownedBy = userId !== void 0 ? [
|
|
22537
|
-
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [
|
|
22549
|
+
const ownedBy = userId !== void 0 ? [Q17.where("user_id", userId)] : [];
|
|
22550
|
+
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [Q17.or(Q17.where("user_id", userId), Q17.where("user_id", null))] : [Q17.where("user_id", userId)];
|
|
22538
22551
|
const watchedColumns = [
|
|
22539
22552
|
"content",
|
|
22540
22553
|
"scope",
|
|
@@ -22580,7 +22593,7 @@ function createLocalMemoryStore(options) {
|
|
|
22580
22593
|
list: (listOptions) => getAllVaultMemoriesOp(vaultCtx, listOptions),
|
|
22581
22594
|
get: (id2) => getVaultMemoryOp(vaultCtx, id2),
|
|
22582
22595
|
listArchived: async () => {
|
|
22583
|
-
const ids = await vaultCtx.vaultMemoryCollection.query(
|
|
22596
|
+
const ids = await vaultCtx.vaultMemoryCollection.query(Q17.where("is_deleted", false), Q17.where("archived_at", Q17.notEq(null)), ...ownedBy).fetchIds();
|
|
22584
22597
|
if (ids.length === 0) return [];
|
|
22585
22598
|
const rows = await getAllVaultMemoriesOp(vaultCtx, { memoryIds: ids, includeArchived: true });
|
|
22586
22599
|
return rows.sort((a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0));
|
|
@@ -22596,7 +22609,7 @@ function createLocalMemoryStore(options) {
|
|
|
22596
22609
|
set.add(String(link.memory_id));
|
|
22597
22610
|
members.set(entityId, set);
|
|
22598
22611
|
}
|
|
22599
|
-
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(
|
|
22612
|
+
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(Q17.where("id", Q17.oneOf([...members.keys()]))).unsafeFetchRaw() : [];
|
|
22600
22613
|
const byName = /* @__PURE__ */ new Map();
|
|
22601
22614
|
for (const entity of entities) {
|
|
22602
22615
|
const name = String(entity.canonical_name);
|
|
@@ -22646,7 +22659,7 @@ function createLocalMemoryStore(options) {
|
|
|
22646
22659
|
setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
|
|
22647
22660
|
addTopics: (memoryId, topics, writeOptions) => database.write(async (writer) => {
|
|
22648
22661
|
await assertWrite(writeOptions);
|
|
22649
|
-
const owned = await vaultCtx.vaultMemoryCollection.query(
|
|
22662
|
+
const owned = await vaultCtx.vaultMemoryCollection.query(Q17.where("id", memoryId), Q17.where("is_deleted", false), ...ownedBy).fetchCount();
|
|
22650
22663
|
return owned > 0 ? writer.callWriter(
|
|
22651
22664
|
() => linkMemoryEntitiesOp(
|
|
22652
22665
|
{
|
|
@@ -22718,7 +22731,7 @@ function createLocalMemoryStore(options) {
|
|
|
22718
22731
|
else onChange();
|
|
22719
22732
|
};
|
|
22720
22733
|
};
|
|
22721
|
-
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(
|
|
22734
|
+
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(Q17.where("is_deleted", false), ...ownedBy).observeWithColumns(
|
|
22722
22735
|
subscribeOptions?.embeddings ? [...watchedColumns, "embedding", "embedding_model"] : watchedColumns
|
|
22723
22736
|
);
|
|
22724
22737
|
const subscriptions = [memories.subscribe(afterFirst())];
|
|
@@ -23633,7 +23646,7 @@ async function migrateMemoriesToRemote(options) {
|
|
|
23633
23646
|
}
|
|
23634
23647
|
|
|
23635
23648
|
// src/lib/memory/store/remoteStore.ts
|
|
23636
|
-
import { v7 as uuidv76 } from "uuid";
|
|
23649
|
+
import { v5 as uuidv5, v7 as uuidv76 } from "uuid";
|
|
23637
23650
|
function projection({ memory }) {
|
|
23638
23651
|
return {
|
|
23639
23652
|
uniqueId: memory.memory_id,
|
|
@@ -23708,32 +23721,38 @@ function stateFilters(options) {
|
|
|
23708
23721
|
include_superseded: options.includeSuperseded
|
|
23709
23722
|
};
|
|
23710
23723
|
}
|
|
23711
|
-
function
|
|
23712
|
-
|
|
23713
|
-
|
|
23714
|
-
return
|
|
23715
|
-
|
|
23716
|
-
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
|
|
23720
|
-
|
|
23721
|
-
|
|
23722
|
-
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
|
|
23726
|
-
|
|
23727
|
-
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23731
|
-
|
|
23732
|
-
|
|
23733
|
-
|
|
23734
|
-
|
|
23735
|
-
|
|
23736
|
-
|
|
23724
|
+
function subscriptionState({ memory, version }) {
|
|
23725
|
+
const membership = memory.trust_tier === "quarantined" ? void 0 : String(!!memory.is_deleted);
|
|
23726
|
+
const hidden = membership === void 0 || memory.is_deleted || memory.archived_at !== void 0 && memory.archived_at !== null || !!memory.superseded_by;
|
|
23727
|
+
return {
|
|
23728
|
+
version,
|
|
23729
|
+
membership,
|
|
23730
|
+
fingerprint: hidden ? void 0 : uuidv5(
|
|
23731
|
+
JSON.stringify([
|
|
23732
|
+
memory.content,
|
|
23733
|
+
memory.scope,
|
|
23734
|
+
memory.updated_at,
|
|
23735
|
+
memory.fact_type,
|
|
23736
|
+
memory.event_time_start,
|
|
23737
|
+
memory.event_time_end,
|
|
23738
|
+
memory.event_time_kind,
|
|
23739
|
+
memory.trust_tier,
|
|
23740
|
+
memory.visibility,
|
|
23741
|
+
memory.published_at,
|
|
23742
|
+
memory.geohash,
|
|
23743
|
+
memory.topics,
|
|
23744
|
+
memory.topics_user_managed,
|
|
23745
|
+
memory.media,
|
|
23746
|
+
memory.source
|
|
23747
|
+
]),
|
|
23748
|
+
uuidv5.URL
|
|
23749
|
+
)
|
|
23750
|
+
};
|
|
23751
|
+
}
|
|
23752
|
+
function subscriptionKey(state, options) {
|
|
23753
|
+
if (options.includeDeleted) return state.membership;
|
|
23754
|
+
if (state.fingerprint === void 0) return void 0;
|
|
23755
|
+
return options.embeddings ? `${state.version}:${state.fingerprint}` : state.fingerprint;
|
|
23737
23756
|
}
|
|
23738
23757
|
function topicInputs(topics, source) {
|
|
23739
23758
|
return topics.flatMap((topic2) => {
|
|
@@ -23811,7 +23830,7 @@ function createRemoteMemoryStore(options) {
|
|
|
23811
23830
|
for (const record2 of records) {
|
|
23812
23831
|
const previous = seen.get(record2.memory.memory_id);
|
|
23813
23832
|
if ((previous?.version ?? 0) + 1 === record2.version)
|
|
23814
|
-
seen.set(record2.memory.memory_id, record2);
|
|
23833
|
+
seen.set(record2.memory.memory_id, subscriptionState(record2));
|
|
23815
23834
|
}
|
|
23816
23835
|
for (const subscriber of [...subscribers])
|
|
23817
23836
|
if (relevant(change, subscriber.options)) safely(subscriber.onChange);
|
|
@@ -24318,7 +24337,8 @@ function createRemoteMemoryStore(options) {
|
|
|
24318
24337
|
const failed = /* @__PURE__ */ new Map();
|
|
24319
24338
|
const collect = (page) => {
|
|
24320
24339
|
warnFailed(page.failed);
|
|
24321
|
-
|
|
24340
|
+
for (const record2 of page.items)
|
|
24341
|
+
records.push({ id: record2.memory.memory_id, state: subscriptionState(record2) });
|
|
24322
24342
|
for (const failure of page.failed) failed.set(failure.memory_id, failure.version);
|
|
24323
24343
|
};
|
|
24324
24344
|
let resume = cursor2;
|
|
@@ -24423,14 +24443,13 @@ function createRemoteMemoryStore(options) {
|
|
|
24423
24443
|
if (subscriber.options.topics) changed.add(subscriber);
|
|
24424
24444
|
}
|
|
24425
24445
|
if (topicState !== void 0) topicFingerprint = topicState;
|
|
24426
|
-
for (const
|
|
24427
|
-
const id2 = record2.memory.memory_id;
|
|
24446
|
+
for (const { id: id2, state } of records) {
|
|
24428
24447
|
const previous = seen.get(id2);
|
|
24429
|
-
seen.set(id2,
|
|
24448
|
+
seen.set(id2, state);
|
|
24430
24449
|
if (!ready) continue;
|
|
24431
24450
|
for (const subscriber of subscribers) {
|
|
24432
24451
|
const before = previous && subscriptionKey(previous, subscriber.options);
|
|
24433
|
-
if (before !== subscriptionKey(
|
|
24452
|
+
if (before !== subscriptionKey(state, subscriber.options)) changed.add(subscriber);
|
|
24434
24453
|
}
|
|
24435
24454
|
}
|
|
24436
24455
|
ready = true;
|
|
@@ -25615,17 +25634,17 @@ async function assembleMemoryContext(options) {
|
|
|
25615
25634
|
}
|
|
25616
25635
|
|
|
25617
25636
|
// src/lib/memory/durableExtraction.ts
|
|
25618
|
-
import { Q as
|
|
25637
|
+
import { Q as Q18 } from "@nozbe/watermelondb";
|
|
25619
25638
|
async function messagePositions(storage, ids) {
|
|
25620
25639
|
try {
|
|
25621
25640
|
return await storage.messagesCollection.query(
|
|
25622
|
-
|
|
25641
|
+
Q18.unsafeSqlQuery(
|
|
25623
25642
|
`select "id", "conversation_id", "message_id" from "history" where "_status" is not 'deleted' and "id" in (${ids.map(() => "?").join(",")})`,
|
|
25624
25643
|
ids
|
|
25625
25644
|
)
|
|
25626
25645
|
).unsafeFetchRaw();
|
|
25627
25646
|
} catch {
|
|
25628
|
-
return await storage.messagesCollection.query(
|
|
25647
|
+
return await storage.messagesCollection.query(Q18.where("id", Q18.oneOf(ids))).unsafeFetchRaw();
|
|
25629
25648
|
}
|
|
25630
25649
|
}
|
|
25631
25650
|
var MAX_JOBS_PER_PASS = 3;
|
|
@@ -25798,7 +25817,7 @@ function createDurableAutoExtractor(options) {
|
|
|
25798
25817
|
const source = options.messageSource?.(conversationId);
|
|
25799
25818
|
if (source)
|
|
25800
25819
|
return await fromSource(source.status(conversationId)) === "ready" && (await loadFromSource(source, conversationId, ids)).every(Boolean);
|
|
25801
|
-
return await storage.conversationsCollection.query(
|
|
25820
|
+
return await storage.conversationsCollection.query(Q18.where("conversation_id", conversationId), Q18.where("is_deleted", false)).fetchCount() > 0 && await storage.messagesCollection.query(Q18.where("conversation_id", conversationId), Q18.where("id", Q18.oneOf(ids))).fetchCount() === ids.length;
|
|
25802
25821
|
}
|
|
25803
25822
|
function schedule(delay) {
|
|
25804
25823
|
if (disposed) return;
|
|
@@ -25972,7 +25991,7 @@ function createDurableAutoExtractor(options) {
|
|
|
25972
25991
|
let sourceWaiting = false;
|
|
25973
25992
|
try {
|
|
25974
25993
|
await writes;
|
|
25975
|
-
const pending = await jobs.query(
|
|
25994
|
+
const pending = await jobs.query(Q18.where("owner_key", owner), Q18.where("message_ids", Q18.notEq("[]"))).fetch();
|
|
25976
25995
|
storeFailures = 0;
|
|
25977
25996
|
let processed = 0;
|
|
25978
25997
|
for (const job of pending) {
|
|
@@ -26004,7 +26023,7 @@ function createDurableAutoExtractor(options) {
|
|
|
26004
26023
|
let ids = [];
|
|
26005
26024
|
let loaded = [];
|
|
26006
26025
|
try {
|
|
26007
|
-
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(
|
|
26026
|
+
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(Q18.where("conversation_id", conversationId), Q18.where("is_deleted", false)).fetchCount() > 0;
|
|
26008
26027
|
if (!present) {
|
|
26009
26028
|
await database.write(() => job.destroyPermanently());
|
|
26010
26029
|
continue;
|
|
@@ -26172,7 +26191,7 @@ function createDurableAutoExtractor(options) {
|
|
|
26172
26191
|
const scope = currentScope();
|
|
26173
26192
|
writes = writes.then(
|
|
26174
26193
|
() => database.write(async () => {
|
|
26175
|
-
const existing = await jobs.query(
|
|
26194
|
+
const existing = await jobs.query(Q18.where("owner_key", owner), Q18.where("conversation_id", conversationId)).fetch();
|
|
26176
26195
|
const job = existing.find(
|
|
26177
26196
|
(candidate) => candidate._getRaw("scope") === scope && (candidate._getRaw("folder_id") ?? null) === folderId
|
|
26178
26197
|
);
|
|
@@ -26185,8 +26204,8 @@ function createDurableAutoExtractor(options) {
|
|
|
26185
26204
|
if (watermarks.length) {
|
|
26186
26205
|
const misplaced = new Set(
|
|
26187
26206
|
await storage.messagesCollection.query(
|
|
26188
|
-
|
|
26189
|
-
|
|
26207
|
+
Q18.where("id", Q18.oneOf(watermarks)),
|
|
26208
|
+
Q18.where("conversation_id", Q18.notEq(conversationId))
|
|
26190
26209
|
).fetchIds()
|
|
26191
26210
|
);
|
|
26192
26211
|
for (const prior of existing)
|
|
@@ -31059,10 +31078,10 @@ var UNREVISIONED_COLUMNS = /* @__PURE__ */ new Set([
|
|
|
31059
31078
|
]);
|
|
31060
31079
|
async function getBackupRevision(database, conversationId) {
|
|
31061
31080
|
const serialized = await database.read(async () => {
|
|
31062
|
-
const { Q:
|
|
31081
|
+
const { Q: Q22 } = await import("@nozbe/watermelondb");
|
|
31063
31082
|
const tables = await Promise.all(
|
|
31064
31083
|
["conversations", "history"].map(
|
|
31065
|
-
(table) => database.get(table).query(
|
|
31084
|
+
(table) => database.get(table).query(Q22.where("conversation_id", conversationId), Q22.sortBy("id", Q22.asc)).unsafeFetchRaw()
|
|
31066
31085
|
)
|
|
31067
31086
|
);
|
|
31068
31087
|
return JSON.stringify(
|
|
@@ -31105,9 +31124,9 @@ async function pushConversationToICloud(database, conversationId, userAddress, d
|
|
|
31105
31124
|
}
|
|
31106
31125
|
async function performICloudExport(database, userAddress, deps, onProgress) {
|
|
31107
31126
|
await deps.requestEncryptionKey(userAddress);
|
|
31108
|
-
const { Q:
|
|
31127
|
+
const { Q: Q22 } = await import("@nozbe/watermelondb");
|
|
31109
31128
|
const conversationsCollection = database.get("conversations");
|
|
31110
|
-
const records = await conversationsCollection.query(
|
|
31129
|
+
const records = await conversationsCollection.query(Q22.where("is_deleted", false)).fetch();
|
|
31111
31130
|
const conversations = records.map(conversationToStoredRaw);
|
|
31112
31131
|
const total = conversations.length;
|
|
31113
31132
|
if (total === 0) {
|
|
@@ -34830,7 +34849,7 @@ function useExportPdf() {
|
|
|
34830
34849
|
}
|
|
34831
34850
|
|
|
34832
34851
|
// src/react/useFiles.ts
|
|
34833
|
-
import { Q as
|
|
34852
|
+
import { Q as Q19 } from "@nozbe/watermelondb";
|
|
34834
34853
|
import { useCallback as useCallback8, useEffect as useEffect6, useMemo as useMemo6, useState as useState8 } from "react";
|
|
34835
34854
|
function useFiles(options) {
|
|
34836
34855
|
const { database, walletAddress } = options;
|
|
@@ -34848,7 +34867,7 @@ function useFiles(options) {
|
|
|
34848
34867
|
setIsLoading(true);
|
|
34849
34868
|
try {
|
|
34850
34869
|
const coll = database.get("media");
|
|
34851
|
-
await coll.query(
|
|
34870
|
+
await coll.query(Q19.take(1)).fetch();
|
|
34852
34871
|
setMediaCollection(coll);
|
|
34853
34872
|
setIsReady(true);
|
|
34854
34873
|
} catch (error) {
|
|
@@ -36073,7 +36092,7 @@ function usePhoneCalls(options = {}) {
|
|
|
36073
36092
|
}
|
|
36074
36093
|
|
|
36075
36094
|
// src/react/useProjects.ts
|
|
36076
|
-
import { Q as
|
|
36095
|
+
import { Q as Q20 } from "@nozbe/watermelondb";
|
|
36077
36096
|
import { useCallback as useCallback15, useEffect as useEffect10, useMemo as useMemo8, useState as useState14 } from "react";
|
|
36078
36097
|
function useProjects(options) {
|
|
36079
36098
|
const { database, initialProjectId } = options;
|
|
@@ -36095,7 +36114,7 @@ function useProjects(options) {
|
|
|
36095
36114
|
conversations: convColl?.table
|
|
36096
36115
|
});
|
|
36097
36116
|
getLogger().debug("[useProjects] Running test query on projects table...");
|
|
36098
|
-
const testResult = await projColl.query(
|
|
36117
|
+
const testResult = await projColl.query(Q20.take(1)).fetch();
|
|
36099
36118
|
getLogger().debug(
|
|
36100
36119
|
"[useProjects] Test query succeeded, found",
|
|
36101
36120
|
testResult.length,
|
|
@@ -36182,7 +36201,7 @@ function useProjects(options) {
|
|
|
36182
36201
|
if (!projectsCollection) {
|
|
36183
36202
|
return;
|
|
36184
36203
|
}
|
|
36185
|
-
const subscription = projectsCollection.query(
|
|
36204
|
+
const subscription = projectsCollection.query(Q20.where("is_deleted", false)).observe().subscribe((records) => {
|
|
36186
36205
|
setProjects(records.map(projectToStored));
|
|
36187
36206
|
});
|
|
36188
36207
|
return () => subscription.unsubscribe();
|
|
@@ -36304,7 +36323,7 @@ function useProjects(options) {
|
|
|
36304
36323
|
import { useCallback as useCallback16, useMemo as useMemo9, useSyncExternalStore } from "react";
|
|
36305
36324
|
|
|
36306
36325
|
// src/react/userSettingsStore.ts
|
|
36307
|
-
import { Q as
|
|
36326
|
+
import { Q as Q21 } from "@nozbe/watermelondb";
|
|
36308
36327
|
var EMPTY_SNAPSHOT = Object.freeze({
|
|
36309
36328
|
modelPreference: null,
|
|
36310
36329
|
userPreference: null,
|
|
@@ -36356,7 +36375,7 @@ async function startLoad(entry, walletAddress) {
|
|
|
36356
36375
|
}
|
|
36357
36376
|
function startObserve(entry, walletAddress) {
|
|
36358
36377
|
let isInitialEmission = true;
|
|
36359
|
-
entry.observeSub = entry.storageCtx.userPreferencesCollection.query(
|
|
36378
|
+
entry.observeSub = entry.storageCtx.userPreferencesCollection.query(Q21.where("wallet_address", walletAddress)).observeWithColumns([
|
|
36360
36379
|
"nickname",
|
|
36361
36380
|
"occupation",
|
|
36362
36381
|
"description",
|