@anuma/sdk 3.11.3 → 3.11.5
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/{chunk-7AW2VD5W.mjs → chunk-ORVYPS3R.mjs} +8 -2
- package/dist/expo/index.cjs +7 -1
- package/dist/expo/index.mjs +1 -1
- package/dist/expo/{recall-JWQ4IJX6.mjs → recall-A4WZELH5.mjs} +1 -1
- package/dist/react/{chunk-L2QRTJII.mjs → chunk-QURYPMCE.mjs} +8 -2
- package/dist/react/index.cjs +7 -1
- package/dist/react/index.mjs +1 -1
- package/dist/react/{recall-DOFCEH2I.mjs → recall-NQNZDPNU.mjs} +1 -1
- package/dist/server/{chunk-FZZCEZL2.mjs → chunk-FXGG7JA5.mjs} +8 -2
- package/dist/server/index.cjs +83 -269
- package/dist/server/index.d.mts +1 -82
- package/dist/server/index.d.ts +1 -82
- package/dist/server/index.mjs +67 -250
- package/dist/server/{recall-QH3YX6T4.mjs → recall-SLMMIFHM.mjs} +1 -1
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -131,7 +131,7 @@ import {
|
|
|
131
131
|
updateVaultMemoryOp,
|
|
132
132
|
upsertMessageOp,
|
|
133
133
|
vaultMemoryToStored
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-FXGG7JA5.mjs";
|
|
135
135
|
import {
|
|
136
136
|
createStreamingDeAnonymizer,
|
|
137
137
|
resolvePiiRedactor
|
|
@@ -314,7 +314,7 @@ var require_children = __commonJS({
|
|
|
314
314
|
var _makeDecorator = _interopRequireDefault(require_makeDecorator());
|
|
315
315
|
var _logError = _interopRequireDefault(require_logError());
|
|
316
316
|
var _invariant = _interopRequireDefault(require_invariant());
|
|
317
|
-
var
|
|
317
|
+
var Q7 = _interopRequireWildcard(require_QueryDescription());
|
|
318
318
|
function _getRequireWildcardCache(e) {
|
|
319
319
|
if ("function" != typeof WeakMap) return null;
|
|
320
320
|
var r = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
|
|
@@ -348,7 +348,7 @@ var require_children = __commonJS({
|
|
|
348
348
|
var childCollection = model.collections.get(childTable);
|
|
349
349
|
var association = model.constructor.associations[childTable];
|
|
350
350
|
(0, _invariant.default)(association && "has_many" === association.type, "@children decorator used for a table that's not has_many");
|
|
351
|
-
var query = childCollection.query(
|
|
351
|
+
var query = childCollection.query(Q7.where(association.foreignKey, model.id));
|
|
352
352
|
that._childrenQueryCache[childTable] = query;
|
|
353
353
|
return query;
|
|
354
354
|
},
|
|
@@ -3455,182 +3455,8 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
3455
3455
|
}
|
|
3456
3456
|
}
|
|
3457
3457
|
|
|
3458
|
-
// src/lib/db/vaultFolders/operations.ts
|
|
3459
|
-
var import_watermelondb15 = __toESM(require_watermelondb());
|
|
3460
|
-
function folderToStored(folder) {
|
|
3461
|
-
return {
|
|
3462
|
-
uniqueId: folder.id,
|
|
3463
|
-
name: folder.name,
|
|
3464
|
-
scope: folder.scope,
|
|
3465
|
-
createdAt: folder.createdAt,
|
|
3466
|
-
updatedAt: folder.updatedAt,
|
|
3467
|
-
isDeleted: folder.isDeleted,
|
|
3468
|
-
isSystem: folder.isSystem ?? false,
|
|
3469
|
-
context: folder.context ?? null
|
|
3470
|
-
};
|
|
3471
|
-
}
|
|
3472
|
-
async function createVaultFolderOp(ctx, opts) {
|
|
3473
|
-
const created = await ctx.database.write(async () => {
|
|
3474
|
-
return ctx.vaultFolderCollection.create((record) => {
|
|
3475
|
-
record._setRaw("name", opts.name);
|
|
3476
|
-
record._setRaw("scope", opts.scope ?? "private");
|
|
3477
|
-
record._setRaw("is_system", opts.isSystem ?? false);
|
|
3478
|
-
record._setRaw("is_deleted", false);
|
|
3479
|
-
});
|
|
3480
|
-
});
|
|
3481
|
-
return folderToStored(created);
|
|
3482
|
-
}
|
|
3483
|
-
async function getAllVaultFoldersOp(ctx) {
|
|
3484
|
-
const results = await ctx.vaultFolderCollection.query(import_watermelondb15.Q.where("is_deleted", false), import_watermelondb15.Q.sortBy("created_at", import_watermelondb15.Q.desc)).fetch();
|
|
3485
|
-
return results.map(folderToStored);
|
|
3486
|
-
}
|
|
3487
|
-
async function updateVaultFolderOp(ctx, id, opts) {
|
|
3488
|
-
try {
|
|
3489
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3490
|
-
if (record.isDeleted) return null;
|
|
3491
|
-
const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
|
|
3492
|
-
const updated = await ctx.database.write(async () => {
|
|
3493
|
-
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch() : [];
|
|
3494
|
-
const updates = [];
|
|
3495
|
-
updates.push(
|
|
3496
|
-
record.prepareUpdate((r) => {
|
|
3497
|
-
if (opts.name !== void 0) r._setRaw("name", opts.name);
|
|
3498
|
-
if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
|
|
3499
|
-
})
|
|
3500
|
-
);
|
|
3501
|
-
for (const memory of memories) {
|
|
3502
|
-
updates.push(
|
|
3503
|
-
memory.prepareUpdate((r) => {
|
|
3504
|
-
r._setRaw("scope", opts.scope);
|
|
3505
|
-
})
|
|
3506
|
-
);
|
|
3507
|
-
}
|
|
3508
|
-
await ctx.database.batch(...updates);
|
|
3509
|
-
return ctx.vaultFolderCollection.find(id);
|
|
3510
|
-
});
|
|
3511
|
-
return folderToStored(updated);
|
|
3512
|
-
} catch {
|
|
3513
|
-
return null;
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
async function deleteVaultFolderOp(ctx, id) {
|
|
3517
|
-
try {
|
|
3518
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3519
|
-
if (record.isDeleted) return false;
|
|
3520
|
-
await ctx.database.write(async () => {
|
|
3521
|
-
const memories = await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3522
|
-
const preparedMemories = memories.map(
|
|
3523
|
-
(memory) => memory.prepareUpdate((r) => {
|
|
3524
|
-
r._setRaw("folder_id", null);
|
|
3525
|
-
r._setRaw("scope", "private");
|
|
3526
|
-
})
|
|
3527
|
-
);
|
|
3528
|
-
const preparedFolder = record.prepareUpdate((r) => {
|
|
3529
|
-
r._setRaw("is_deleted", true);
|
|
3530
|
-
});
|
|
3531
|
-
await ctx.database.batch(...preparedMemories, preparedFolder);
|
|
3532
|
-
});
|
|
3533
|
-
return true;
|
|
3534
|
-
} catch {
|
|
3535
|
-
return false;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
async function moveMemoriesToFolderOp(ctx, memoryIds, folderId) {
|
|
3539
|
-
if (memoryIds.length === 0) return true;
|
|
3540
|
-
try {
|
|
3541
|
-
let targetScope = "private";
|
|
3542
|
-
if (folderId) {
|
|
3543
|
-
const folder = await ctx.vaultFolderCollection.find(folderId);
|
|
3544
|
-
if (folder.isDeleted) return false;
|
|
3545
|
-
targetScope = folder.scope;
|
|
3546
|
-
}
|
|
3547
|
-
let movedCount = 0;
|
|
3548
|
-
await ctx.database.write(async () => {
|
|
3549
|
-
const memories = [];
|
|
3550
|
-
for (const id of memoryIds) {
|
|
3551
|
-
try {
|
|
3552
|
-
const m = await ctx.vaultMemoryCollection.find(id);
|
|
3553
|
-
if (!m.isDeleted) memories.push(m);
|
|
3554
|
-
} catch {
|
|
3555
|
-
}
|
|
3556
|
-
}
|
|
3557
|
-
if (memories.length === 0) return;
|
|
3558
|
-
const prepared = memories.map(
|
|
3559
|
-
(memory) => memory.prepareUpdate((r) => {
|
|
3560
|
-
r._setRaw("folder_id", folderId);
|
|
3561
|
-
r._setRaw("scope", targetScope);
|
|
3562
|
-
})
|
|
3563
|
-
);
|
|
3564
|
-
await ctx.database.batch(...prepared);
|
|
3565
|
-
movedCount = memories.length;
|
|
3566
|
-
});
|
|
3567
|
-
return movedCount > 0;
|
|
3568
|
-
} catch {
|
|
3569
|
-
return false;
|
|
3570
|
-
}
|
|
3571
|
-
}
|
|
3572
|
-
async function updateVaultFolderContextOp(ctx, id, context) {
|
|
3573
|
-
try {
|
|
3574
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3575
|
-
if (record.isDeleted) return null;
|
|
3576
|
-
const updated = await ctx.database.write(async () => {
|
|
3577
|
-
await ctx.database.batch(
|
|
3578
|
-
record.prepareUpdate((r) => {
|
|
3579
|
-
r._setRaw("context", context);
|
|
3580
|
-
})
|
|
3581
|
-
);
|
|
3582
|
-
return ctx.vaultFolderCollection.find(id);
|
|
3583
|
-
});
|
|
3584
|
-
return folderToStored(updated);
|
|
3585
|
-
} catch {
|
|
3586
|
-
return null;
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
async function getVaultFolderMemoryCountOp(ctx, folderId) {
|
|
3590
|
-
return await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", folderId), import_watermelondb15.Q.where("is_deleted", false)).fetchCount();
|
|
3591
|
-
}
|
|
3592
|
-
|
|
3593
|
-
// src/lib/db/vaultFolders/defaults.ts
|
|
3594
|
-
var DEFAULT_FOLDER_NAMES = ["Personal", "Work", "Interests"];
|
|
3595
|
-
var ensureDefaultFoldersLocks = /* @__PURE__ */ new WeakMap();
|
|
3596
|
-
async function ensureDefaultFoldersOp(ctx) {
|
|
3597
|
-
const existing = ensureDefaultFoldersLocks.get(ctx.database);
|
|
3598
|
-
if (existing) return existing;
|
|
3599
|
-
const promise = _ensureDefaultFoldersImpl(ctx);
|
|
3600
|
-
ensureDefaultFoldersLocks.set(ctx.database, promise);
|
|
3601
|
-
try {
|
|
3602
|
-
return await promise;
|
|
3603
|
-
} finally {
|
|
3604
|
-
ensureDefaultFoldersLocks.delete(ctx.database);
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
async function _ensureDefaultFoldersImpl(ctx) {
|
|
3608
|
-
const existing = await getAllVaultFoldersOp(ctx);
|
|
3609
|
-
const folderMap = /* @__PURE__ */ new Map();
|
|
3610
|
-
const existingByName = new Map(existing.map((f) => [f.name, f]));
|
|
3611
|
-
for (const name of DEFAULT_FOLDER_NAMES) {
|
|
3612
|
-
const found = existingByName.get(name);
|
|
3613
|
-
if (found) {
|
|
3614
|
-
folderMap.set(found.name, found.uniqueId);
|
|
3615
|
-
} else {
|
|
3616
|
-
const created = await createVaultFolderOp(ctx, {
|
|
3617
|
-
name,
|
|
3618
|
-
scope: "private",
|
|
3619
|
-
isSystem: true
|
|
3620
|
-
});
|
|
3621
|
-
folderMap.set(created.name, created.uniqueId);
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
for (const folder of existing) {
|
|
3625
|
-
if (!folderMap.has(folder.name)) {
|
|
3626
|
-
folderMap.set(folder.name, folder.uniqueId);
|
|
3627
|
-
}
|
|
3628
|
-
}
|
|
3629
|
-
return folderMap;
|
|
3630
|
-
}
|
|
3631
|
-
|
|
3632
3458
|
// src/lib/db/project/operations.ts
|
|
3633
|
-
var
|
|
3459
|
+
var import_watermelondb15 = __toESM(require_watermelondb());
|
|
3634
3460
|
|
|
3635
3461
|
// src/lib/db/project/types.ts
|
|
3636
3462
|
function generateProjectId() {
|
|
@@ -3661,15 +3487,15 @@ async function createProjectOp(ctx, opts, defaultName = "New Project") {
|
|
|
3661
3487
|
return projectToStored(created);
|
|
3662
3488
|
}
|
|
3663
3489
|
async function getProjectOp(ctx, id) {
|
|
3664
|
-
const results = await ctx.projectsCollection.query(
|
|
3490
|
+
const results = await ctx.projectsCollection.query(import_watermelondb15.Q.where("project_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3665
3491
|
return results.length > 0 ? projectToStored(results[0]) : null;
|
|
3666
3492
|
}
|
|
3667
3493
|
async function getProjectsOp(ctx) {
|
|
3668
|
-
const results = await ctx.projectsCollection.query(
|
|
3494
|
+
const results = await ctx.projectsCollection.query(import_watermelondb15.Q.where("is_deleted", false), import_watermelondb15.Q.sortBy("created_at", import_watermelondb15.Q.desc)).fetch();
|
|
3669
3495
|
return results.map(projectToStored);
|
|
3670
3496
|
}
|
|
3671
3497
|
async function updateProjectNameOp(ctx, id, name) {
|
|
3672
|
-
const results = await ctx.projectsCollection.query(
|
|
3498
|
+
const results = await ctx.projectsCollection.query(import_watermelondb15.Q.where("project_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3673
3499
|
if (results.length > 0) {
|
|
3674
3500
|
await ctx.database.write(async () => {
|
|
3675
3501
|
await results[0].update((proj) => {
|
|
@@ -3681,7 +3507,7 @@ async function updateProjectNameOp(ctx, id, name) {
|
|
|
3681
3507
|
return false;
|
|
3682
3508
|
}
|
|
3683
3509
|
async function updateProjectOp(ctx, id, opts) {
|
|
3684
|
-
const results = await ctx.projectsCollection.query(
|
|
3510
|
+
const results = await ctx.projectsCollection.query(import_watermelondb15.Q.where("project_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3685
3511
|
if (results.length > 0) {
|
|
3686
3512
|
await ctx.database.write(async () => {
|
|
3687
3513
|
await results[0].update((proj) => {
|
|
@@ -3693,7 +3519,7 @@ async function updateProjectOp(ctx, id, opts) {
|
|
|
3693
3519
|
return false;
|
|
3694
3520
|
}
|
|
3695
3521
|
async function deleteProjectOp(ctx, id) {
|
|
3696
|
-
const results = await ctx.projectsCollection.query(
|
|
3522
|
+
const results = await ctx.projectsCollection.query(import_watermelondb15.Q.where("project_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3697
3523
|
if (results.length > 0) {
|
|
3698
3524
|
await ctx.database.write(async () => {
|
|
3699
3525
|
await results[0].update((proj) => {
|
|
@@ -3706,14 +3532,14 @@ async function deleteProjectOp(ctx, id) {
|
|
|
3706
3532
|
}
|
|
3707
3533
|
async function getProjectConversationsOp(ctx, projectId) {
|
|
3708
3534
|
const results = await ctx.conversationsCollection.query(
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3535
|
+
import_watermelondb15.Q.where("project_id", projectId),
|
|
3536
|
+
import_watermelondb15.Q.where("is_deleted", false),
|
|
3537
|
+
import_watermelondb15.Q.sortBy("created_at", import_watermelondb15.Q.desc)
|
|
3712
3538
|
).fetch();
|
|
3713
3539
|
return results.map(conversationToStoredRaw);
|
|
3714
3540
|
}
|
|
3715
3541
|
async function getProjectConversationCountOp(ctx, projectId) {
|
|
3716
|
-
return await ctx.conversationsCollection.query(
|
|
3542
|
+
return await ctx.conversationsCollection.query(import_watermelondb15.Q.where("project_id", projectId), import_watermelondb15.Q.where("is_deleted", false)).fetchCount();
|
|
3717
3543
|
}
|
|
3718
3544
|
|
|
3719
3545
|
// src/lib/db/media/types.ts
|
|
@@ -3740,7 +3566,7 @@ function isSupportedMediaType(mimeType) {
|
|
|
3740
3566
|
}
|
|
3741
3567
|
|
|
3742
3568
|
// src/lib/db/media/operations.ts
|
|
3743
|
-
var
|
|
3569
|
+
var import_watermelondb16 = __toESM(require_watermelondb());
|
|
3744
3570
|
|
|
3745
3571
|
// src/lib/storage/mcpImages.ts
|
|
3746
3572
|
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
@@ -3970,7 +3796,7 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
3970
3796
|
})
|
|
3971
3797
|
);
|
|
3972
3798
|
});
|
|
3973
|
-
const results = await mediaCollection.query(
|
|
3799
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))).fetch();
|
|
3974
3800
|
return Promise.all(
|
|
3975
3801
|
results.map(
|
|
3976
3802
|
(m) => mediaToStored(m, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
@@ -3979,21 +3805,21 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
3979
3805
|
}
|
|
3980
3806
|
async function getMediaByIdOp(ctx, mediaId) {
|
|
3981
3807
|
const mediaCollection = ctx.database.get("media");
|
|
3982
|
-
const results = await mediaCollection.query(
|
|
3808
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId), import_watermelondb16.Q.where("is_deleted", false)).fetch();
|
|
3983
3809
|
return results.length > 0 ? await mediaToStored(results[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
3984
3810
|
}
|
|
3985
3811
|
async function getMediaBySourceUrlOp(ctx, sourceUrl, walletAddress) {
|
|
3986
3812
|
const mediaCollection = ctx.database.get("media");
|
|
3987
3813
|
const results = await mediaCollection.query(
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3814
|
+
import_watermelondb16.Q.where("source_url", sourceUrl),
|
|
3815
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
3816
|
+
import_watermelondb16.Q.where("is_deleted", false)
|
|
3991
3817
|
).fetch();
|
|
3992
3818
|
return results.length > 0 ? await mediaToStored(results[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
3993
3819
|
}
|
|
3994
3820
|
async function updateMediaOp(ctx, mediaId, options) {
|
|
3995
3821
|
const mediaCollection = ctx.database.get("media");
|
|
3996
|
-
const results = await mediaCollection.query(
|
|
3822
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
3997
3823
|
if (results.length === 0) {
|
|
3998
3824
|
return null;
|
|
3999
3825
|
}
|
|
@@ -4013,7 +3839,7 @@ async function updateMediaOp(ctx, mediaId, options) {
|
|
|
4013
3839
|
m._setRaw("updated_at", now);
|
|
4014
3840
|
});
|
|
4015
3841
|
});
|
|
4016
|
-
const updated = await mediaCollection.query(
|
|
3842
|
+
const updated = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4017
3843
|
return updated.length > 0 ? await mediaToStored(updated[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
4018
3844
|
}
|
|
4019
3845
|
async function updateMediaMessageIdBatchOp(ctx, mediaIds, messageId) {
|
|
@@ -4021,7 +3847,7 @@ async function updateMediaMessageIdBatchOp(ctx, mediaIds, messageId) {
|
|
|
4021
3847
|
return 0;
|
|
4022
3848
|
}
|
|
4023
3849
|
const mediaCollection = ctx.database.get("media");
|
|
4024
|
-
const results = await mediaCollection.query(
|
|
3850
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))).fetch();
|
|
4025
3851
|
if (results.length === 0) {
|
|
4026
3852
|
return 0;
|
|
4027
3853
|
}
|
|
@@ -4043,13 +3869,13 @@ var IMAGE_VIDEO_MIMES = VIDEO_EXTENSIONS.map((ext) => `image/${ext}`);
|
|
|
4043
3869
|
async function relinkMisclassifiedVideosOp(ctx, walletAddress) {
|
|
4044
3870
|
const mediaCollection = ctx.database.get("media");
|
|
4045
3871
|
const candidates = await mediaCollection.query(
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
...IMAGE_VIDEO_MIMES.map((m) =>
|
|
4052
|
-
|
|
3872
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
3873
|
+
import_watermelondb16.Q.where("is_deleted", false),
|
|
3874
|
+
import_watermelondb16.Q.where("media_type", "image"),
|
|
3875
|
+
import_watermelondb16.Q.or(
|
|
3876
|
+
import_watermelondb16.Q.where("mime_type", import_watermelondb16.Q.like("video/%")),
|
|
3877
|
+
...IMAGE_VIDEO_MIMES.map((m) => import_watermelondb16.Q.where("mime_type", m)),
|
|
3878
|
+
import_watermelondb16.Q.where("mime_type", "application/octet-stream")
|
|
4053
3879
|
)
|
|
4054
3880
|
).fetch();
|
|
4055
3881
|
if (candidates.length === 0) {
|
|
@@ -4098,7 +3924,7 @@ async function relinkMisclassifiedVideosOp(ctx, walletAddress) {
|
|
|
4098
3924
|
}
|
|
4099
3925
|
async function deleteMediaOp(ctx, mediaId) {
|
|
4100
3926
|
const mediaCollection = ctx.database.get("media");
|
|
4101
|
-
const results = await mediaCollection.query(
|
|
3927
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4102
3928
|
if (results.length === 0) {
|
|
4103
3929
|
return false;
|
|
4104
3930
|
}
|
|
@@ -4116,7 +3942,7 @@ async function deleteMediaOp(ctx, mediaId) {
|
|
|
4116
3942
|
}
|
|
4117
3943
|
async function hardDeleteMediaOp(ctx, mediaId) {
|
|
4118
3944
|
const mediaCollection = ctx.database.get("media");
|
|
4119
|
-
const results = await mediaCollection.query(
|
|
3945
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4120
3946
|
if (results.length === 0) {
|
|
4121
3947
|
return false;
|
|
4122
3948
|
}
|
|
@@ -4128,28 +3954,28 @@ async function hardDeleteMediaOp(ctx, mediaId) {
|
|
|
4128
3954
|
}
|
|
4129
3955
|
async function getMediaOp(ctx, filters) {
|
|
4130
3956
|
const mediaCollection = ctx.database.get("media");
|
|
4131
|
-
const conditions = [
|
|
3957
|
+
const conditions = [import_watermelondb16.Q.where("wallet_address", filters.walletAddress)];
|
|
4132
3958
|
if (!filters.includeDeleted) {
|
|
4133
|
-
conditions.push(
|
|
3959
|
+
conditions.push(import_watermelondb16.Q.where("is_deleted", false));
|
|
4134
3960
|
}
|
|
4135
3961
|
if (filters.mediaType) {
|
|
4136
|
-
conditions.push(
|
|
3962
|
+
conditions.push(import_watermelondb16.Q.where("media_type", filters.mediaType));
|
|
4137
3963
|
}
|
|
4138
3964
|
if (filters.role) {
|
|
4139
|
-
conditions.push(
|
|
3965
|
+
conditions.push(import_watermelondb16.Q.where("role", filters.role));
|
|
4140
3966
|
}
|
|
4141
3967
|
if (filters.conversationId) {
|
|
4142
|
-
conditions.push(
|
|
3968
|
+
conditions.push(import_watermelondb16.Q.where("conversation_id", filters.conversationId));
|
|
4143
3969
|
}
|
|
4144
3970
|
if (filters.model) {
|
|
4145
|
-
conditions.push(
|
|
3971
|
+
conditions.push(import_watermelondb16.Q.where("model", filters.model));
|
|
4146
3972
|
}
|
|
4147
|
-
conditions.push(
|
|
3973
|
+
conditions.push(import_watermelondb16.Q.sortBy("created_at", import_watermelondb16.Q.desc));
|
|
4148
3974
|
if (filters.limit) {
|
|
4149
|
-
conditions.push(
|
|
3975
|
+
conditions.push(import_watermelondb16.Q.take(filters.limit));
|
|
4150
3976
|
}
|
|
4151
3977
|
if (filters.offset) {
|
|
4152
|
-
conditions.push(
|
|
3978
|
+
conditions.push(import_watermelondb16.Q.skip(filters.offset));
|
|
4153
3979
|
}
|
|
4154
3980
|
const results = await mediaCollection.query(...conditions).fetch();
|
|
4155
3981
|
return Promise.all(
|
|
@@ -4179,9 +4005,9 @@ async function getMediaByConversationOp(ctx, walletAddress, conversationId, limi
|
|
|
4179
4005
|
async function getMediaByMessageOp(ctx, messageId) {
|
|
4180
4006
|
const mediaCollection = ctx.database.get("media");
|
|
4181
4007
|
const results = await mediaCollection.query(
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4008
|
+
import_watermelondb16.Q.where("message_id", messageId),
|
|
4009
|
+
import_watermelondb16.Q.where("is_deleted", false),
|
|
4010
|
+
import_watermelondb16.Q.sortBy("created_at", import_watermelondb16.Q.asc)
|
|
4185
4011
|
).fetch();
|
|
4186
4012
|
return Promise.all(
|
|
4187
4013
|
results.map(
|
|
@@ -4194,9 +4020,9 @@ async function getMediaByIdsOp(ctx, mediaIds, includeDeleted = false) {
|
|
|
4194
4020
|
return [];
|
|
4195
4021
|
}
|
|
4196
4022
|
const mediaCollection = ctx.database.get("media");
|
|
4197
|
-
const conditions = [
|
|
4023
|
+
const conditions = [import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))];
|
|
4198
4024
|
if (!includeDeleted) {
|
|
4199
|
-
conditions.push(
|
|
4025
|
+
conditions.push(import_watermelondb16.Q.where("is_deleted", false));
|
|
4200
4026
|
}
|
|
4201
4027
|
const results = await mediaCollection.query(...conditions).fetch();
|
|
4202
4028
|
const mediaMap = new Map(results.map((m) => [m.mediaId, m]));
|
|
@@ -4233,10 +4059,10 @@ async function searchMediaOp(ctx, walletAddress, query, limit) {
|
|
|
4233
4059
|
const queryLower = query.toLowerCase();
|
|
4234
4060
|
const MAX_SEARCH_RECORDS = 500;
|
|
4235
4061
|
const allResults = await mediaCollection.query(
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4062
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
4063
|
+
import_watermelondb16.Q.where("is_deleted", false),
|
|
4064
|
+
import_watermelondb16.Q.sortBy("created_at", import_watermelondb16.Q.desc),
|
|
4065
|
+
import_watermelondb16.Q.take(MAX_SEARCH_RECORDS)
|
|
4240
4066
|
).fetch();
|
|
4241
4067
|
const decrypted = await Promise.all(
|
|
4242
4068
|
allResults.map(
|
|
@@ -4249,11 +4075,11 @@ async function searchMediaOp(ctx, walletAddress, query, limit) {
|
|
|
4249
4075
|
async function getMediaCountOp(ctx, walletAddress, mediaType) {
|
|
4250
4076
|
const mediaCollection = ctx.database.get("media");
|
|
4251
4077
|
const conditions = [
|
|
4252
|
-
|
|
4253
|
-
|
|
4078
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
4079
|
+
import_watermelondb16.Q.where("is_deleted", false)
|
|
4254
4080
|
];
|
|
4255
4081
|
if (mediaType) {
|
|
4256
|
-
conditions.push(
|
|
4082
|
+
conditions.push(import_watermelondb16.Q.where("media_type", mediaType));
|
|
4257
4083
|
}
|
|
4258
4084
|
return await mediaCollection.query(...conditions).fetchCount();
|
|
4259
4085
|
}
|
|
@@ -4268,7 +4094,7 @@ async function getMediaCountsByTypeOp(ctx, walletAddress) {
|
|
|
4268
4094
|
}
|
|
4269
4095
|
async function deleteMediaByConversationOp(ctx, conversationId) {
|
|
4270
4096
|
const mediaCollection = ctx.database.get("media");
|
|
4271
|
-
const results = await mediaCollection.query(
|
|
4097
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("conversation_id", conversationId), import_watermelondb16.Q.where("is_deleted", false)).fetch();
|
|
4272
4098
|
if (results.length === 0) {
|
|
4273
4099
|
return 0;
|
|
4274
4100
|
}
|
|
@@ -4289,7 +4115,7 @@ async function deleteMediaByConversationOp(ctx, conversationId) {
|
|
|
4289
4115
|
}
|
|
4290
4116
|
async function deleteMediaByMessageOp(ctx, messageId) {
|
|
4291
4117
|
const mediaCollection = ctx.database.get("media");
|
|
4292
|
-
const results = await mediaCollection.query(
|
|
4118
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("message_id", messageId), import_watermelondb16.Q.where("is_deleted", false)).fetch();
|
|
4293
4119
|
if (results.length === 0) {
|
|
4294
4120
|
return 0;
|
|
4295
4121
|
}
|
|
@@ -4310,7 +4136,7 @@ async function deleteMediaByMessageOp(ctx, messageId) {
|
|
|
4310
4136
|
}
|
|
4311
4137
|
|
|
4312
4138
|
// src/lib/db/userPreferences/operations.ts
|
|
4313
|
-
var
|
|
4139
|
+
var import_watermelondb17 = __toESM(require_watermelondb());
|
|
4314
4140
|
function userPreferenceToStored(preference) {
|
|
4315
4141
|
return {
|
|
4316
4142
|
uniqueId: preference.id,
|
|
@@ -4325,7 +4151,7 @@ function userPreferenceToStored(preference) {
|
|
|
4325
4151
|
};
|
|
4326
4152
|
}
|
|
4327
4153
|
async function getUserPreferenceOp(ctx, walletAddress) {
|
|
4328
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4154
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4329
4155
|
return results.length > 0 ? userPreferenceToStored(results[0]) : null;
|
|
4330
4156
|
}
|
|
4331
4157
|
async function createUserPreferenceOp(ctx, opts) {
|
|
@@ -4345,7 +4171,7 @@ async function createUserPreferenceOp(ctx, opts) {
|
|
|
4345
4171
|
return userPreferenceToStored(created);
|
|
4346
4172
|
}
|
|
4347
4173
|
async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
4348
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4174
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4349
4175
|
if (results.length === 0) return null;
|
|
4350
4176
|
const preference = results[0];
|
|
4351
4177
|
await ctx.database.write(async () => {
|
|
@@ -4373,7 +4199,7 @@ async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
|
4373
4199
|
async function setUserPreferenceOp(ctx, walletAddress, opts) {
|
|
4374
4200
|
const now = Date.now();
|
|
4375
4201
|
const result = await ctx.database.write(async () => {
|
|
4376
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4202
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4377
4203
|
if (results.length > 0) {
|
|
4378
4204
|
const preference = results[0];
|
|
4379
4205
|
await preference.update((pref) => {
|
|
@@ -4421,7 +4247,7 @@ async function updateModelsOp(ctx, walletAddress, models) {
|
|
|
4421
4247
|
return updateUserPreferenceOp(ctx, walletAddress, { models });
|
|
4422
4248
|
}
|
|
4423
4249
|
async function deleteUserPreferenceOp(ctx, walletAddress) {
|
|
4424
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4250
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4425
4251
|
if (results.length === 0) return false;
|
|
4426
4252
|
await ctx.database.write(async () => {
|
|
4427
4253
|
await results[0].destroyPermanently();
|
|
@@ -4436,9 +4262,9 @@ async function migrateFromModelPreferencesOp(ctx, walletAddress) {
|
|
|
4436
4262
|
if (existing) {
|
|
4437
4263
|
return existing;
|
|
4438
4264
|
}
|
|
4439
|
-
const modelResults = await ctx.modelPreferencesCollection.query(
|
|
4265
|
+
const modelResults = await ctx.modelPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4440
4266
|
const personalityKey = `${walletAddress}_personality_settings`;
|
|
4441
|
-
const personalityResults = await ctx.modelPreferencesCollection.query(
|
|
4267
|
+
const personalityResults = await ctx.modelPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", personalityKey)).fetch();
|
|
4442
4268
|
if (modelResults.length === 0 && personalityResults.length === 0) {
|
|
4443
4269
|
return null;
|
|
4444
4270
|
}
|
|
@@ -4518,7 +4344,7 @@ var SLIDER_CONFIG = [
|
|
|
4518
4344
|
];
|
|
4519
4345
|
|
|
4520
4346
|
// src/lib/db/settings/operations.ts
|
|
4521
|
-
var
|
|
4347
|
+
var import_watermelondb18 = __toESM(require_watermelondb());
|
|
4522
4348
|
function modelPreferenceToStored(preference) {
|
|
4523
4349
|
return {
|
|
4524
4350
|
uniqueId: preference.id,
|
|
@@ -4527,12 +4353,12 @@ function modelPreferenceToStored(preference) {
|
|
|
4527
4353
|
};
|
|
4528
4354
|
}
|
|
4529
4355
|
async function getModelPreferenceOp(ctx, walletAddress) {
|
|
4530
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4356
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4531
4357
|
return results.length > 0 ? modelPreferenceToStored(results[0]) : null;
|
|
4532
4358
|
}
|
|
4533
4359
|
async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
4534
4360
|
const result = await ctx.database.write(async () => {
|
|
4535
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4361
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4536
4362
|
if (results.length > 0) {
|
|
4537
4363
|
const preference = results[0];
|
|
4538
4364
|
await preference.update((pref) => {
|
|
@@ -4550,7 +4376,7 @@ async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
|
4550
4376
|
return modelPreferenceToStored(result);
|
|
4551
4377
|
}
|
|
4552
4378
|
async function deleteModelPreferenceOp(ctx, walletAddress) {
|
|
4553
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4379
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4554
4380
|
if (results.length === 0) return false;
|
|
4555
4381
|
await ctx.database.write(async () => {
|
|
4556
4382
|
await results[0].destroyPermanently();
|
|
@@ -4884,7 +4710,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
4884
4710
|
}
|
|
4885
4711
|
|
|
4886
4712
|
// src/lib/memory/autoExtract.ts
|
|
4887
|
-
var
|
|
4713
|
+
var import_watermelondb19 = __toESM(require_watermelondb());
|
|
4888
4714
|
|
|
4889
4715
|
// src/lib/memory/entitySalience.ts
|
|
4890
4716
|
var GENERIC_ENTITY_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -5666,7 +5492,7 @@ async function assertMergeTargetGoneOrThrow(ctx, targetId) {
|
|
|
5666
5492
|
// src/lib/memory/autoExtract.ts
|
|
5667
5493
|
async function isMemoryTopicsUserManaged(ctx, memoryId) {
|
|
5668
5494
|
try {
|
|
5669
|
-
const rows = await ctx.database.get(VaultMemory.table).query(
|
|
5495
|
+
const rows = await ctx.database.get(VaultMemory.table).query(import_watermelondb19.Q.where("id", memoryId)).fetch();
|
|
5670
5496
|
return rows[0]?.topicsUserManaged === true;
|
|
5671
5497
|
} catch {
|
|
5672
5498
|
return true;
|
|
@@ -13087,7 +12913,6 @@ export {
|
|
|
13087
12913
|
TextProcessor,
|
|
13088
12914
|
UserPreference,
|
|
13089
12915
|
VAULT_SIZE_HOP_CAP,
|
|
13090
|
-
VaultFolder,
|
|
13091
12916
|
VaultMemory,
|
|
13092
12917
|
WalletPoller,
|
|
13093
12918
|
WordProcessor,
|
|
@@ -13143,7 +12968,6 @@ export {
|
|
|
13143
12968
|
createStockPricePreProcessor,
|
|
13144
12969
|
createSummaryContext,
|
|
13145
12970
|
createVaultEmbeddingCache,
|
|
13146
|
-
createVaultFolderOp,
|
|
13147
12971
|
createVaultMemoriesBatchOp,
|
|
13148
12972
|
createVaultMemoryOp,
|
|
13149
12973
|
createWeatherPreProcessor,
|
|
@@ -13164,7 +12988,6 @@ export {
|
|
|
13164
12988
|
deleteModelPreferenceOp,
|
|
13165
12989
|
deleteProjectOp,
|
|
13166
12990
|
deleteUserPreferenceOp,
|
|
13167
|
-
deleteVaultFolderOp,
|
|
13168
12991
|
deleteVaultMemoryOp,
|
|
13169
12992
|
eagerEmbedContent,
|
|
13170
12993
|
embedAllMessages,
|
|
@@ -13173,7 +12996,6 @@ export {
|
|
|
13173
12996
|
encryptDataBatch,
|
|
13174
12997
|
encryptDataBytes,
|
|
13175
12998
|
encryptDataWithKey,
|
|
13176
|
-
ensureDefaultFoldersOp,
|
|
13177
12999
|
estimateMessagesTokens,
|
|
13178
13000
|
estimateTokens,
|
|
13179
13001
|
exportPublicKey,
|
|
@@ -13189,7 +13011,6 @@ export {
|
|
|
13189
13011
|
generateProjectId,
|
|
13190
13012
|
getAIGeneratedMediaOp,
|
|
13191
13013
|
getAllFilesOp,
|
|
13192
|
-
getAllVaultFoldersOp,
|
|
13193
13014
|
getAllVaultMemoriesOp,
|
|
13194
13015
|
getAllVaultMemoryContentsOp,
|
|
13195
13016
|
getAudioOp,
|
|
@@ -13232,7 +13053,6 @@ export {
|
|
|
13232
13053
|
getUnfiledVaultMemoriesOp,
|
|
13233
13054
|
getUserPreferenceOp,
|
|
13234
13055
|
getUserUploadedMediaOp,
|
|
13235
|
-
getVaultFolderMemoryCountOp,
|
|
13236
13056
|
getVaultMemoryOp,
|
|
13237
13057
|
getVideosOp,
|
|
13238
13058
|
hardDeleteDecayedOp,
|
|
@@ -13248,7 +13068,6 @@ export {
|
|
|
13248
13068
|
maybeSummarizeHistory,
|
|
13249
13069
|
mediaToStored,
|
|
13250
13070
|
migrateFromModelPreferencesOp,
|
|
13251
|
-
moveMemoriesToFolderOp,
|
|
13252
13071
|
onKeyAvailable,
|
|
13253
13072
|
preEmbedVaultMemories,
|
|
13254
13073
|
preprocessFiles,
|
|
@@ -13309,8 +13128,6 @@ export {
|
|
|
13309
13128
|
updateProfileOp,
|
|
13310
13129
|
updateProjectNameOp,
|
|
13311
13130
|
updateProjectOp,
|
|
13312
|
-
updateVaultFolderContextOp,
|
|
13313
|
-
updateVaultFolderOp,
|
|
13314
13131
|
updateVaultMemoryEmbeddingOp,
|
|
13315
13132
|
updateVaultMemoryOp,
|
|
13316
13133
|
upsertConversationSummaryOp,
|