@anuma/sdk 3.11.2 → 3.11.4
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-7CTI3XR6.mjs → chunk-7AW2VD5W.mjs} +284 -93
- package/dist/expo/index.cjs +303 -99
- package/dist/expo/index.d.mts +14 -1
- package/dist/expo/index.d.ts +14 -1
- package/dist/expo/index.mjs +16 -5
- package/dist/expo/{recall-IBGUFY4P.mjs → recall-JWQ4IJX6.mjs} +1 -1
- package/dist/react/{chunk-LAFUCS4U.mjs → chunk-L2QRTJII.mjs} +284 -93
- package/dist/react/index.cjs +303 -99
- package/dist/react/index.d.mts +14 -1
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.mjs +16 -5
- package/dist/react/{recall-Q5V5DN4L.mjs → recall-DOFCEH2I.mjs} +1 -1
- package/dist/server/{chunk-NCKDSZPQ.mjs → chunk-FZZCEZL2.mjs} +284 -93
- package/dist/server/index.cjs +378 -367
- package/dist/server/index.d.mts +15 -83
- package/dist/server/index.d.ts +15 -83
- package/dist/server/index.mjs +82 -254
- package/dist/server/{recall-AN7HBEFS.mjs → recall-QH3YX6T4.mjs} +1 -1
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -4,11 +4,14 @@ import {
|
|
|
4
4
|
DEFAULT_CHUNK_SIZE,
|
|
5
5
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
6
6
|
DEFAULT_VAULT_CACHE_SIZE,
|
|
7
|
+
EMBEDDINGS_DEGRADED_EMPTY,
|
|
7
8
|
ENTITY_FANOUT,
|
|
8
9
|
ENTITY_KINDS,
|
|
9
10
|
LRUCache,
|
|
10
11
|
MAX_HOPS,
|
|
11
12
|
NODE_BUDGET,
|
|
13
|
+
RECALL_MAX_LIMIT,
|
|
14
|
+
RECALL_TOOL_NAME,
|
|
12
15
|
RerankerUnavailableError,
|
|
13
16
|
TOPICS_EXTRACTION_VERSION,
|
|
14
17
|
TREND_RECENT_WINDOW_DAYS,
|
|
@@ -128,7 +131,7 @@ import {
|
|
|
128
131
|
updateVaultMemoryOp,
|
|
129
132
|
upsertMessageOp,
|
|
130
133
|
vaultMemoryToStored
|
|
131
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-FZZCEZL2.mjs";
|
|
132
135
|
import {
|
|
133
136
|
createStreamingDeAnonymizer,
|
|
134
137
|
resolvePiiRedactor
|
|
@@ -311,7 +314,7 @@ var require_children = __commonJS({
|
|
|
311
314
|
var _makeDecorator = _interopRequireDefault(require_makeDecorator());
|
|
312
315
|
var _logError = _interopRequireDefault(require_logError());
|
|
313
316
|
var _invariant = _interopRequireDefault(require_invariant());
|
|
314
|
-
var
|
|
317
|
+
var Q7 = _interopRequireWildcard(require_QueryDescription());
|
|
315
318
|
function _getRequireWildcardCache(e) {
|
|
316
319
|
if ("function" != typeof WeakMap) return null;
|
|
317
320
|
var r = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
|
|
@@ -345,7 +348,7 @@ var require_children = __commonJS({
|
|
|
345
348
|
var childCollection = model.collections.get(childTable);
|
|
346
349
|
var association = model.constructor.associations[childTable];
|
|
347
350
|
(0, _invariant.default)(association && "has_many" === association.type, "@children decorator used for a table that's not has_many");
|
|
348
|
-
var query = childCollection.query(
|
|
351
|
+
var query = childCollection.query(Q7.where(association.foreignKey, model.id));
|
|
349
352
|
that._childrenQueryCache[childTable] = query;
|
|
350
353
|
return query;
|
|
351
354
|
},
|
|
@@ -3452,182 +3455,8 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
3452
3455
|
}
|
|
3453
3456
|
}
|
|
3454
3457
|
|
|
3455
|
-
// src/lib/db/vaultFolders/operations.ts
|
|
3456
|
-
var import_watermelondb15 = __toESM(require_watermelondb());
|
|
3457
|
-
function folderToStored(folder) {
|
|
3458
|
-
return {
|
|
3459
|
-
uniqueId: folder.id,
|
|
3460
|
-
name: folder.name,
|
|
3461
|
-
scope: folder.scope,
|
|
3462
|
-
createdAt: folder.createdAt,
|
|
3463
|
-
updatedAt: folder.updatedAt,
|
|
3464
|
-
isDeleted: folder.isDeleted,
|
|
3465
|
-
isSystem: folder.isSystem ?? false,
|
|
3466
|
-
context: folder.context ?? null
|
|
3467
|
-
};
|
|
3468
|
-
}
|
|
3469
|
-
async function createVaultFolderOp(ctx, opts) {
|
|
3470
|
-
const created = await ctx.database.write(async () => {
|
|
3471
|
-
return ctx.vaultFolderCollection.create((record) => {
|
|
3472
|
-
record._setRaw("name", opts.name);
|
|
3473
|
-
record._setRaw("scope", opts.scope ?? "private");
|
|
3474
|
-
record._setRaw("is_system", opts.isSystem ?? false);
|
|
3475
|
-
record._setRaw("is_deleted", false);
|
|
3476
|
-
});
|
|
3477
|
-
});
|
|
3478
|
-
return folderToStored(created);
|
|
3479
|
-
}
|
|
3480
|
-
async function getAllVaultFoldersOp(ctx) {
|
|
3481
|
-
const results = await ctx.vaultFolderCollection.query(import_watermelondb15.Q.where("is_deleted", false), import_watermelondb15.Q.sortBy("created_at", import_watermelondb15.Q.desc)).fetch();
|
|
3482
|
-
return results.map(folderToStored);
|
|
3483
|
-
}
|
|
3484
|
-
async function updateVaultFolderOp(ctx, id, opts) {
|
|
3485
|
-
try {
|
|
3486
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3487
|
-
if (record.isDeleted) return null;
|
|
3488
|
-
const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
|
|
3489
|
-
const updated = await ctx.database.write(async () => {
|
|
3490
|
-
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch() : [];
|
|
3491
|
-
const updates = [];
|
|
3492
|
-
updates.push(
|
|
3493
|
-
record.prepareUpdate((r) => {
|
|
3494
|
-
if (opts.name !== void 0) r._setRaw("name", opts.name);
|
|
3495
|
-
if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
|
|
3496
|
-
})
|
|
3497
|
-
);
|
|
3498
|
-
for (const memory of memories) {
|
|
3499
|
-
updates.push(
|
|
3500
|
-
memory.prepareUpdate((r) => {
|
|
3501
|
-
r._setRaw("scope", opts.scope);
|
|
3502
|
-
})
|
|
3503
|
-
);
|
|
3504
|
-
}
|
|
3505
|
-
await ctx.database.batch(...updates);
|
|
3506
|
-
return ctx.vaultFolderCollection.find(id);
|
|
3507
|
-
});
|
|
3508
|
-
return folderToStored(updated);
|
|
3509
|
-
} catch {
|
|
3510
|
-
return null;
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
async function deleteVaultFolderOp(ctx, id) {
|
|
3514
|
-
try {
|
|
3515
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3516
|
-
if (record.isDeleted) return false;
|
|
3517
|
-
await ctx.database.write(async () => {
|
|
3518
|
-
const memories = await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
|
|
3519
|
-
const preparedMemories = memories.map(
|
|
3520
|
-
(memory) => memory.prepareUpdate((r) => {
|
|
3521
|
-
r._setRaw("folder_id", null);
|
|
3522
|
-
r._setRaw("scope", "private");
|
|
3523
|
-
})
|
|
3524
|
-
);
|
|
3525
|
-
const preparedFolder = record.prepareUpdate((r) => {
|
|
3526
|
-
r._setRaw("is_deleted", true);
|
|
3527
|
-
});
|
|
3528
|
-
await ctx.database.batch(...preparedMemories, preparedFolder);
|
|
3529
|
-
});
|
|
3530
|
-
return true;
|
|
3531
|
-
} catch {
|
|
3532
|
-
return false;
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
|
-
async function moveMemoriesToFolderOp(ctx, memoryIds, folderId) {
|
|
3536
|
-
if (memoryIds.length === 0) return true;
|
|
3537
|
-
try {
|
|
3538
|
-
let targetScope = "private";
|
|
3539
|
-
if (folderId) {
|
|
3540
|
-
const folder = await ctx.vaultFolderCollection.find(folderId);
|
|
3541
|
-
if (folder.isDeleted) return false;
|
|
3542
|
-
targetScope = folder.scope;
|
|
3543
|
-
}
|
|
3544
|
-
let movedCount = 0;
|
|
3545
|
-
await ctx.database.write(async () => {
|
|
3546
|
-
const memories = [];
|
|
3547
|
-
for (const id of memoryIds) {
|
|
3548
|
-
try {
|
|
3549
|
-
const m = await ctx.vaultMemoryCollection.find(id);
|
|
3550
|
-
if (!m.isDeleted) memories.push(m);
|
|
3551
|
-
} catch {
|
|
3552
|
-
}
|
|
3553
|
-
}
|
|
3554
|
-
if (memories.length === 0) return;
|
|
3555
|
-
const prepared = memories.map(
|
|
3556
|
-
(memory) => memory.prepareUpdate((r) => {
|
|
3557
|
-
r._setRaw("folder_id", folderId);
|
|
3558
|
-
r._setRaw("scope", targetScope);
|
|
3559
|
-
})
|
|
3560
|
-
);
|
|
3561
|
-
await ctx.database.batch(...prepared);
|
|
3562
|
-
movedCount = memories.length;
|
|
3563
|
-
});
|
|
3564
|
-
return movedCount > 0;
|
|
3565
|
-
} catch {
|
|
3566
|
-
return false;
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
async function updateVaultFolderContextOp(ctx, id, context) {
|
|
3570
|
-
try {
|
|
3571
|
-
const record = await ctx.vaultFolderCollection.find(id);
|
|
3572
|
-
if (record.isDeleted) return null;
|
|
3573
|
-
const updated = await ctx.database.write(async () => {
|
|
3574
|
-
await ctx.database.batch(
|
|
3575
|
-
record.prepareUpdate((r) => {
|
|
3576
|
-
r._setRaw("context", context);
|
|
3577
|
-
})
|
|
3578
|
-
);
|
|
3579
|
-
return ctx.vaultFolderCollection.find(id);
|
|
3580
|
-
});
|
|
3581
|
-
return folderToStored(updated);
|
|
3582
|
-
} catch {
|
|
3583
|
-
return null;
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
async function getVaultFolderMemoryCountOp(ctx, folderId) {
|
|
3587
|
-
return await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", folderId), import_watermelondb15.Q.where("is_deleted", false)).fetchCount();
|
|
3588
|
-
}
|
|
3589
|
-
|
|
3590
|
-
// src/lib/db/vaultFolders/defaults.ts
|
|
3591
|
-
var DEFAULT_FOLDER_NAMES = ["Personal", "Work", "Interests"];
|
|
3592
|
-
var ensureDefaultFoldersLocks = /* @__PURE__ */ new WeakMap();
|
|
3593
|
-
async function ensureDefaultFoldersOp(ctx) {
|
|
3594
|
-
const existing = ensureDefaultFoldersLocks.get(ctx.database);
|
|
3595
|
-
if (existing) return existing;
|
|
3596
|
-
const promise = _ensureDefaultFoldersImpl(ctx);
|
|
3597
|
-
ensureDefaultFoldersLocks.set(ctx.database, promise);
|
|
3598
|
-
try {
|
|
3599
|
-
return await promise;
|
|
3600
|
-
} finally {
|
|
3601
|
-
ensureDefaultFoldersLocks.delete(ctx.database);
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
async function _ensureDefaultFoldersImpl(ctx) {
|
|
3605
|
-
const existing = await getAllVaultFoldersOp(ctx);
|
|
3606
|
-
const folderMap = /* @__PURE__ */ new Map();
|
|
3607
|
-
const existingByName = new Map(existing.map((f) => [f.name, f]));
|
|
3608
|
-
for (const name of DEFAULT_FOLDER_NAMES) {
|
|
3609
|
-
const found = existingByName.get(name);
|
|
3610
|
-
if (found) {
|
|
3611
|
-
folderMap.set(found.name, found.uniqueId);
|
|
3612
|
-
} else {
|
|
3613
|
-
const created = await createVaultFolderOp(ctx, {
|
|
3614
|
-
name,
|
|
3615
|
-
scope: "private",
|
|
3616
|
-
isSystem: true
|
|
3617
|
-
});
|
|
3618
|
-
folderMap.set(created.name, created.uniqueId);
|
|
3619
|
-
}
|
|
3620
|
-
}
|
|
3621
|
-
for (const folder of existing) {
|
|
3622
|
-
if (!folderMap.has(folder.name)) {
|
|
3623
|
-
folderMap.set(folder.name, folder.uniqueId);
|
|
3624
|
-
}
|
|
3625
|
-
}
|
|
3626
|
-
return folderMap;
|
|
3627
|
-
}
|
|
3628
|
-
|
|
3629
3458
|
// src/lib/db/project/operations.ts
|
|
3630
|
-
var
|
|
3459
|
+
var import_watermelondb15 = __toESM(require_watermelondb());
|
|
3631
3460
|
|
|
3632
3461
|
// src/lib/db/project/types.ts
|
|
3633
3462
|
function generateProjectId() {
|
|
@@ -3658,15 +3487,15 @@ async function createProjectOp(ctx, opts, defaultName = "New Project") {
|
|
|
3658
3487
|
return projectToStored(created);
|
|
3659
3488
|
}
|
|
3660
3489
|
async function getProjectOp(ctx, id) {
|
|
3661
|
-
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();
|
|
3662
3491
|
return results.length > 0 ? projectToStored(results[0]) : null;
|
|
3663
3492
|
}
|
|
3664
3493
|
async function getProjectsOp(ctx) {
|
|
3665
|
-
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();
|
|
3666
3495
|
return results.map(projectToStored);
|
|
3667
3496
|
}
|
|
3668
3497
|
async function updateProjectNameOp(ctx, id, name) {
|
|
3669
|
-
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();
|
|
3670
3499
|
if (results.length > 0) {
|
|
3671
3500
|
await ctx.database.write(async () => {
|
|
3672
3501
|
await results[0].update((proj) => {
|
|
@@ -3678,7 +3507,7 @@ async function updateProjectNameOp(ctx, id, name) {
|
|
|
3678
3507
|
return false;
|
|
3679
3508
|
}
|
|
3680
3509
|
async function updateProjectOp(ctx, id, opts) {
|
|
3681
|
-
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();
|
|
3682
3511
|
if (results.length > 0) {
|
|
3683
3512
|
await ctx.database.write(async () => {
|
|
3684
3513
|
await results[0].update((proj) => {
|
|
@@ -3690,7 +3519,7 @@ async function updateProjectOp(ctx, id, opts) {
|
|
|
3690
3519
|
return false;
|
|
3691
3520
|
}
|
|
3692
3521
|
async function deleteProjectOp(ctx, id) {
|
|
3693
|
-
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();
|
|
3694
3523
|
if (results.length > 0) {
|
|
3695
3524
|
await ctx.database.write(async () => {
|
|
3696
3525
|
await results[0].update((proj) => {
|
|
@@ -3703,14 +3532,14 @@ async function deleteProjectOp(ctx, id) {
|
|
|
3703
3532
|
}
|
|
3704
3533
|
async function getProjectConversationsOp(ctx, projectId) {
|
|
3705
3534
|
const results = await ctx.conversationsCollection.query(
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
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)
|
|
3709
3538
|
).fetch();
|
|
3710
3539
|
return results.map(conversationToStoredRaw);
|
|
3711
3540
|
}
|
|
3712
3541
|
async function getProjectConversationCountOp(ctx, projectId) {
|
|
3713
|
-
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();
|
|
3714
3543
|
}
|
|
3715
3544
|
|
|
3716
3545
|
// src/lib/db/media/types.ts
|
|
@@ -3737,7 +3566,7 @@ function isSupportedMediaType(mimeType) {
|
|
|
3737
3566
|
}
|
|
3738
3567
|
|
|
3739
3568
|
// src/lib/db/media/operations.ts
|
|
3740
|
-
var
|
|
3569
|
+
var import_watermelondb16 = __toESM(require_watermelondb());
|
|
3741
3570
|
|
|
3742
3571
|
// src/lib/storage/mcpImages.ts
|
|
3743
3572
|
var VIDEO_EXTENSIONS = ["mp4", "webm", "mov"];
|
|
@@ -3967,7 +3796,7 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
3967
3796
|
})
|
|
3968
3797
|
);
|
|
3969
3798
|
});
|
|
3970
|
-
const results = await mediaCollection.query(
|
|
3799
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))).fetch();
|
|
3971
3800
|
return Promise.all(
|
|
3972
3801
|
results.map(
|
|
3973
3802
|
(m) => mediaToStored(m, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
@@ -3976,21 +3805,21 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
3976
3805
|
}
|
|
3977
3806
|
async function getMediaByIdOp(ctx, mediaId) {
|
|
3978
3807
|
const mediaCollection = ctx.database.get("media");
|
|
3979
|
-
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();
|
|
3980
3809
|
return results.length > 0 ? await mediaToStored(results[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
3981
3810
|
}
|
|
3982
3811
|
async function getMediaBySourceUrlOp(ctx, sourceUrl, walletAddress) {
|
|
3983
3812
|
const mediaCollection = ctx.database.get("media");
|
|
3984
3813
|
const results = await mediaCollection.query(
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3814
|
+
import_watermelondb16.Q.where("source_url", sourceUrl),
|
|
3815
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
3816
|
+
import_watermelondb16.Q.where("is_deleted", false)
|
|
3988
3817
|
).fetch();
|
|
3989
3818
|
return results.length > 0 ? await mediaToStored(results[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
3990
3819
|
}
|
|
3991
3820
|
async function updateMediaOp(ctx, mediaId, options) {
|
|
3992
3821
|
const mediaCollection = ctx.database.get("media");
|
|
3993
|
-
const results = await mediaCollection.query(
|
|
3822
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
3994
3823
|
if (results.length === 0) {
|
|
3995
3824
|
return null;
|
|
3996
3825
|
}
|
|
@@ -4010,7 +3839,7 @@ async function updateMediaOp(ctx, mediaId, options) {
|
|
|
4010
3839
|
m._setRaw("updated_at", now);
|
|
4011
3840
|
});
|
|
4012
3841
|
});
|
|
4013
|
-
const updated = await mediaCollection.query(
|
|
3842
|
+
const updated = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4014
3843
|
return updated.length > 0 ? await mediaToStored(updated[0], ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner) : null;
|
|
4015
3844
|
}
|
|
4016
3845
|
async function updateMediaMessageIdBatchOp(ctx, mediaIds, messageId) {
|
|
@@ -4018,7 +3847,7 @@ async function updateMediaMessageIdBatchOp(ctx, mediaIds, messageId) {
|
|
|
4018
3847
|
return 0;
|
|
4019
3848
|
}
|
|
4020
3849
|
const mediaCollection = ctx.database.get("media");
|
|
4021
|
-
const results = await mediaCollection.query(
|
|
3850
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))).fetch();
|
|
4022
3851
|
if (results.length === 0) {
|
|
4023
3852
|
return 0;
|
|
4024
3853
|
}
|
|
@@ -4040,13 +3869,13 @@ var IMAGE_VIDEO_MIMES = VIDEO_EXTENSIONS.map((ext) => `image/${ext}`);
|
|
|
4040
3869
|
async function relinkMisclassifiedVideosOp(ctx, walletAddress) {
|
|
4041
3870
|
const mediaCollection = ctx.database.get("media");
|
|
4042
3871
|
const candidates = await mediaCollection.query(
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
...IMAGE_VIDEO_MIMES.map((m) =>
|
|
4049
|
-
|
|
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")
|
|
4050
3879
|
)
|
|
4051
3880
|
).fetch();
|
|
4052
3881
|
if (candidates.length === 0) {
|
|
@@ -4095,7 +3924,7 @@ async function relinkMisclassifiedVideosOp(ctx, walletAddress) {
|
|
|
4095
3924
|
}
|
|
4096
3925
|
async function deleteMediaOp(ctx, mediaId) {
|
|
4097
3926
|
const mediaCollection = ctx.database.get("media");
|
|
4098
|
-
const results = await mediaCollection.query(
|
|
3927
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4099
3928
|
if (results.length === 0) {
|
|
4100
3929
|
return false;
|
|
4101
3930
|
}
|
|
@@ -4113,7 +3942,7 @@ async function deleteMediaOp(ctx, mediaId) {
|
|
|
4113
3942
|
}
|
|
4114
3943
|
async function hardDeleteMediaOp(ctx, mediaId) {
|
|
4115
3944
|
const mediaCollection = ctx.database.get("media");
|
|
4116
|
-
const results = await mediaCollection.query(
|
|
3945
|
+
const results = await mediaCollection.query(import_watermelondb16.Q.where("media_id", mediaId)).fetch();
|
|
4117
3946
|
if (results.length === 0) {
|
|
4118
3947
|
return false;
|
|
4119
3948
|
}
|
|
@@ -4125,28 +3954,28 @@ async function hardDeleteMediaOp(ctx, mediaId) {
|
|
|
4125
3954
|
}
|
|
4126
3955
|
async function getMediaOp(ctx, filters) {
|
|
4127
3956
|
const mediaCollection = ctx.database.get("media");
|
|
4128
|
-
const conditions = [
|
|
3957
|
+
const conditions = [import_watermelondb16.Q.where("wallet_address", filters.walletAddress)];
|
|
4129
3958
|
if (!filters.includeDeleted) {
|
|
4130
|
-
conditions.push(
|
|
3959
|
+
conditions.push(import_watermelondb16.Q.where("is_deleted", false));
|
|
4131
3960
|
}
|
|
4132
3961
|
if (filters.mediaType) {
|
|
4133
|
-
conditions.push(
|
|
3962
|
+
conditions.push(import_watermelondb16.Q.where("media_type", filters.mediaType));
|
|
4134
3963
|
}
|
|
4135
3964
|
if (filters.role) {
|
|
4136
|
-
conditions.push(
|
|
3965
|
+
conditions.push(import_watermelondb16.Q.where("role", filters.role));
|
|
4137
3966
|
}
|
|
4138
3967
|
if (filters.conversationId) {
|
|
4139
|
-
conditions.push(
|
|
3968
|
+
conditions.push(import_watermelondb16.Q.where("conversation_id", filters.conversationId));
|
|
4140
3969
|
}
|
|
4141
3970
|
if (filters.model) {
|
|
4142
|
-
conditions.push(
|
|
3971
|
+
conditions.push(import_watermelondb16.Q.where("model", filters.model));
|
|
4143
3972
|
}
|
|
4144
|
-
conditions.push(
|
|
3973
|
+
conditions.push(import_watermelondb16.Q.sortBy("created_at", import_watermelondb16.Q.desc));
|
|
4145
3974
|
if (filters.limit) {
|
|
4146
|
-
conditions.push(
|
|
3975
|
+
conditions.push(import_watermelondb16.Q.take(filters.limit));
|
|
4147
3976
|
}
|
|
4148
3977
|
if (filters.offset) {
|
|
4149
|
-
conditions.push(
|
|
3978
|
+
conditions.push(import_watermelondb16.Q.skip(filters.offset));
|
|
4150
3979
|
}
|
|
4151
3980
|
const results = await mediaCollection.query(...conditions).fetch();
|
|
4152
3981
|
return Promise.all(
|
|
@@ -4176,9 +4005,9 @@ async function getMediaByConversationOp(ctx, walletAddress, conversationId, limi
|
|
|
4176
4005
|
async function getMediaByMessageOp(ctx, messageId) {
|
|
4177
4006
|
const mediaCollection = ctx.database.get("media");
|
|
4178
4007
|
const results = await mediaCollection.query(
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
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)
|
|
4182
4011
|
).fetch();
|
|
4183
4012
|
return Promise.all(
|
|
4184
4013
|
results.map(
|
|
@@ -4191,9 +4020,9 @@ async function getMediaByIdsOp(ctx, mediaIds, includeDeleted = false) {
|
|
|
4191
4020
|
return [];
|
|
4192
4021
|
}
|
|
4193
4022
|
const mediaCollection = ctx.database.get("media");
|
|
4194
|
-
const conditions = [
|
|
4023
|
+
const conditions = [import_watermelondb16.Q.where("media_id", import_watermelondb16.Q.oneOf(mediaIds))];
|
|
4195
4024
|
if (!includeDeleted) {
|
|
4196
|
-
conditions.push(
|
|
4025
|
+
conditions.push(import_watermelondb16.Q.where("is_deleted", false));
|
|
4197
4026
|
}
|
|
4198
4027
|
const results = await mediaCollection.query(...conditions).fetch();
|
|
4199
4028
|
const mediaMap = new Map(results.map((m) => [m.mediaId, m]));
|
|
@@ -4230,10 +4059,10 @@ async function searchMediaOp(ctx, walletAddress, query, limit) {
|
|
|
4230
4059
|
const queryLower = query.toLowerCase();
|
|
4231
4060
|
const MAX_SEARCH_RECORDS = 500;
|
|
4232
4061
|
const allResults = await mediaCollection.query(
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
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)
|
|
4237
4066
|
).fetch();
|
|
4238
4067
|
const decrypted = await Promise.all(
|
|
4239
4068
|
allResults.map(
|
|
@@ -4246,11 +4075,11 @@ async function searchMediaOp(ctx, walletAddress, query, limit) {
|
|
|
4246
4075
|
async function getMediaCountOp(ctx, walletAddress, mediaType) {
|
|
4247
4076
|
const mediaCollection = ctx.database.get("media");
|
|
4248
4077
|
const conditions = [
|
|
4249
|
-
|
|
4250
|
-
|
|
4078
|
+
import_watermelondb16.Q.where("wallet_address", walletAddress),
|
|
4079
|
+
import_watermelondb16.Q.where("is_deleted", false)
|
|
4251
4080
|
];
|
|
4252
4081
|
if (mediaType) {
|
|
4253
|
-
conditions.push(
|
|
4082
|
+
conditions.push(import_watermelondb16.Q.where("media_type", mediaType));
|
|
4254
4083
|
}
|
|
4255
4084
|
return await mediaCollection.query(...conditions).fetchCount();
|
|
4256
4085
|
}
|
|
@@ -4265,7 +4094,7 @@ async function getMediaCountsByTypeOp(ctx, walletAddress) {
|
|
|
4265
4094
|
}
|
|
4266
4095
|
async function deleteMediaByConversationOp(ctx, conversationId) {
|
|
4267
4096
|
const mediaCollection = ctx.database.get("media");
|
|
4268
|
-
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();
|
|
4269
4098
|
if (results.length === 0) {
|
|
4270
4099
|
return 0;
|
|
4271
4100
|
}
|
|
@@ -4286,7 +4115,7 @@ async function deleteMediaByConversationOp(ctx, conversationId) {
|
|
|
4286
4115
|
}
|
|
4287
4116
|
async function deleteMediaByMessageOp(ctx, messageId) {
|
|
4288
4117
|
const mediaCollection = ctx.database.get("media");
|
|
4289
|
-
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();
|
|
4290
4119
|
if (results.length === 0) {
|
|
4291
4120
|
return 0;
|
|
4292
4121
|
}
|
|
@@ -4307,7 +4136,7 @@ async function deleteMediaByMessageOp(ctx, messageId) {
|
|
|
4307
4136
|
}
|
|
4308
4137
|
|
|
4309
4138
|
// src/lib/db/userPreferences/operations.ts
|
|
4310
|
-
var
|
|
4139
|
+
var import_watermelondb17 = __toESM(require_watermelondb());
|
|
4311
4140
|
function userPreferenceToStored(preference) {
|
|
4312
4141
|
return {
|
|
4313
4142
|
uniqueId: preference.id,
|
|
@@ -4322,7 +4151,7 @@ function userPreferenceToStored(preference) {
|
|
|
4322
4151
|
};
|
|
4323
4152
|
}
|
|
4324
4153
|
async function getUserPreferenceOp(ctx, walletAddress) {
|
|
4325
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4154
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4326
4155
|
return results.length > 0 ? userPreferenceToStored(results[0]) : null;
|
|
4327
4156
|
}
|
|
4328
4157
|
async function createUserPreferenceOp(ctx, opts) {
|
|
@@ -4342,7 +4171,7 @@ async function createUserPreferenceOp(ctx, opts) {
|
|
|
4342
4171
|
return userPreferenceToStored(created);
|
|
4343
4172
|
}
|
|
4344
4173
|
async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
4345
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4174
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4346
4175
|
if (results.length === 0) return null;
|
|
4347
4176
|
const preference = results[0];
|
|
4348
4177
|
await ctx.database.write(async () => {
|
|
@@ -4370,7 +4199,7 @@ async function updateUserPreferenceOp(ctx, walletAddress, opts) {
|
|
|
4370
4199
|
async function setUserPreferenceOp(ctx, walletAddress, opts) {
|
|
4371
4200
|
const now = Date.now();
|
|
4372
4201
|
const result = await ctx.database.write(async () => {
|
|
4373
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4202
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4374
4203
|
if (results.length > 0) {
|
|
4375
4204
|
const preference = results[0];
|
|
4376
4205
|
await preference.update((pref) => {
|
|
@@ -4418,7 +4247,7 @@ async function updateModelsOp(ctx, walletAddress, models) {
|
|
|
4418
4247
|
return updateUserPreferenceOp(ctx, walletAddress, { models });
|
|
4419
4248
|
}
|
|
4420
4249
|
async function deleteUserPreferenceOp(ctx, walletAddress) {
|
|
4421
|
-
const results = await ctx.userPreferencesCollection.query(
|
|
4250
|
+
const results = await ctx.userPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4422
4251
|
if (results.length === 0) return false;
|
|
4423
4252
|
await ctx.database.write(async () => {
|
|
4424
4253
|
await results[0].destroyPermanently();
|
|
@@ -4433,9 +4262,9 @@ async function migrateFromModelPreferencesOp(ctx, walletAddress) {
|
|
|
4433
4262
|
if (existing) {
|
|
4434
4263
|
return existing;
|
|
4435
4264
|
}
|
|
4436
|
-
const modelResults = await ctx.modelPreferencesCollection.query(
|
|
4265
|
+
const modelResults = await ctx.modelPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", walletAddress)).fetch();
|
|
4437
4266
|
const personalityKey = `${walletAddress}_personality_settings`;
|
|
4438
|
-
const personalityResults = await ctx.modelPreferencesCollection.query(
|
|
4267
|
+
const personalityResults = await ctx.modelPreferencesCollection.query(import_watermelondb17.Q.where("wallet_address", personalityKey)).fetch();
|
|
4439
4268
|
if (modelResults.length === 0 && personalityResults.length === 0) {
|
|
4440
4269
|
return null;
|
|
4441
4270
|
}
|
|
@@ -4515,7 +4344,7 @@ var SLIDER_CONFIG = [
|
|
|
4515
4344
|
];
|
|
4516
4345
|
|
|
4517
4346
|
// src/lib/db/settings/operations.ts
|
|
4518
|
-
var
|
|
4347
|
+
var import_watermelondb18 = __toESM(require_watermelondb());
|
|
4519
4348
|
function modelPreferenceToStored(preference) {
|
|
4520
4349
|
return {
|
|
4521
4350
|
uniqueId: preference.id,
|
|
@@ -4524,12 +4353,12 @@ function modelPreferenceToStored(preference) {
|
|
|
4524
4353
|
};
|
|
4525
4354
|
}
|
|
4526
4355
|
async function getModelPreferenceOp(ctx, walletAddress) {
|
|
4527
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4356
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4528
4357
|
return results.length > 0 ? modelPreferenceToStored(results[0]) : null;
|
|
4529
4358
|
}
|
|
4530
4359
|
async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
4531
4360
|
const result = await ctx.database.write(async () => {
|
|
4532
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4361
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4533
4362
|
if (results.length > 0) {
|
|
4534
4363
|
const preference = results[0];
|
|
4535
4364
|
await preference.update((pref) => {
|
|
@@ -4547,7 +4376,7 @@ async function setModelPreferenceOp(ctx, walletAddress, models) {
|
|
|
4547
4376
|
return modelPreferenceToStored(result);
|
|
4548
4377
|
}
|
|
4549
4378
|
async function deleteModelPreferenceOp(ctx, walletAddress) {
|
|
4550
|
-
const results = await ctx.modelPreferencesCollection.query(
|
|
4379
|
+
const results = await ctx.modelPreferencesCollection.query(import_watermelondb18.Q.where("wallet_address", walletAddress)).fetch();
|
|
4551
4380
|
if (results.length === 0) return false;
|
|
4552
4381
|
await ctx.database.write(async () => {
|
|
4553
4382
|
await results[0].destroyPermanently();
|
|
@@ -4881,7 +4710,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
4881
4710
|
}
|
|
4882
4711
|
|
|
4883
4712
|
// src/lib/memory/autoExtract.ts
|
|
4884
|
-
var
|
|
4713
|
+
var import_watermelondb19 = __toESM(require_watermelondb());
|
|
4885
4714
|
|
|
4886
4715
|
// src/lib/memory/entitySalience.ts
|
|
4887
4716
|
var GENERIC_ENTITY_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -5334,6 +5163,11 @@ async function retain(content, ctx, options = {}) {
|
|
|
5334
5163
|
...options.folderId !== void 0 && { folderId: options.folderId }
|
|
5335
5164
|
}
|
|
5336
5165
|
);
|
|
5166
|
+
if (prepared.embeddingFailure || prepared.embeddingsUnavailable) {
|
|
5167
|
+
throw new Error(
|
|
5168
|
+
"retain: embeddings unavailable \u2014 refusing to auto-merge against an inert cosine lane, which would create a duplicate instead of merging into the existing memory. Retry when embeddings recover, or pass enableAutoMerge: false to force a create."
|
|
5169
|
+
);
|
|
5170
|
+
}
|
|
5337
5171
|
if (options.consolidateOptions) {
|
|
5338
5172
|
const outcome = await tryConsolidate(trimmed, ctx, options, prepared);
|
|
5339
5173
|
if (outcome) {
|
|
@@ -5658,7 +5492,7 @@ async function assertMergeTargetGoneOrThrow(ctx, targetId) {
|
|
|
5658
5492
|
// src/lib/memory/autoExtract.ts
|
|
5659
5493
|
async function isMemoryTopicsUserManaged(ctx, memoryId) {
|
|
5660
5494
|
try {
|
|
5661
|
-
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();
|
|
5662
5496
|
return rows[0]?.topicsUserManaged === true;
|
|
5663
5497
|
} catch {
|
|
5664
5498
|
return true;
|
|
@@ -6566,10 +6400,6 @@ function rankProfileCandidates(inputs, now = Date.now(), options = {}) {
|
|
|
6566
6400
|
return ranked;
|
|
6567
6401
|
}
|
|
6568
6402
|
|
|
6569
|
-
// src/lib/memory/recallConstants.ts
|
|
6570
|
-
var RECALL_TOOL_NAME = "recall_memory";
|
|
6571
|
-
var RECALL_MAX_LIMIT = 50;
|
|
6572
|
-
|
|
6573
6403
|
// src/lib/memory/recallTool.ts
|
|
6574
6404
|
var DEFAULT_LIMIT = 8;
|
|
6575
6405
|
var DEFAULT_BUDGET = "low";
|
|
@@ -6720,7 +6550,11 @@ function createRecallTool(ctx, toolOptions, callbacks) {
|
|
|
6720
6550
|
conversationMemories += effectiveLimit;
|
|
6721
6551
|
let surfaced = 0;
|
|
6722
6552
|
try {
|
|
6553
|
+
let recallDegraded = [];
|
|
6723
6554
|
const recallOpts = {
|
|
6555
|
+
onDiagnostics: (d) => {
|
|
6556
|
+
recallDegraded = d.degraded;
|
|
6557
|
+
},
|
|
6724
6558
|
types: defaultTypes,
|
|
6725
6559
|
limit: effectiveLimit,
|
|
6726
6560
|
budget: defaultBudget,
|
|
@@ -6752,6 +6586,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
|
|
|
6752
6586
|
}
|
|
6753
6587
|
}
|
|
6754
6588
|
surfaced = result.memories.length;
|
|
6589
|
+
if (result.memories.length === 0 && recallDegraded.includes("embeddings-unavailable")) {
|
|
6590
|
+
return EMBEDDINGS_DEGRADED_EMPTY;
|
|
6591
|
+
}
|
|
6755
6592
|
const formatted = formatRecallResult(result.memories);
|
|
6756
6593
|
return truncatedByBudget && surfaced > 0 ? `${formatted}
|
|
6757
6594
|
|
|
@@ -13076,7 +12913,6 @@ export {
|
|
|
13076
12913
|
TextProcessor,
|
|
13077
12914
|
UserPreference,
|
|
13078
12915
|
VAULT_SIZE_HOP_CAP,
|
|
13079
|
-
VaultFolder,
|
|
13080
12916
|
VaultMemory,
|
|
13081
12917
|
WalletPoller,
|
|
13082
12918
|
WordProcessor,
|
|
@@ -13132,7 +12968,6 @@ export {
|
|
|
13132
12968
|
createStockPricePreProcessor,
|
|
13133
12969
|
createSummaryContext,
|
|
13134
12970
|
createVaultEmbeddingCache,
|
|
13135
|
-
createVaultFolderOp,
|
|
13136
12971
|
createVaultMemoriesBatchOp,
|
|
13137
12972
|
createVaultMemoryOp,
|
|
13138
12973
|
createWeatherPreProcessor,
|
|
@@ -13153,7 +12988,6 @@ export {
|
|
|
13153
12988
|
deleteModelPreferenceOp,
|
|
13154
12989
|
deleteProjectOp,
|
|
13155
12990
|
deleteUserPreferenceOp,
|
|
13156
|
-
deleteVaultFolderOp,
|
|
13157
12991
|
deleteVaultMemoryOp,
|
|
13158
12992
|
eagerEmbedContent,
|
|
13159
12993
|
embedAllMessages,
|
|
@@ -13162,7 +12996,6 @@ export {
|
|
|
13162
12996
|
encryptDataBatch,
|
|
13163
12997
|
encryptDataBytes,
|
|
13164
12998
|
encryptDataWithKey,
|
|
13165
|
-
ensureDefaultFoldersOp,
|
|
13166
12999
|
estimateMessagesTokens,
|
|
13167
13000
|
estimateTokens,
|
|
13168
13001
|
exportPublicKey,
|
|
@@ -13178,7 +13011,6 @@ export {
|
|
|
13178
13011
|
generateProjectId,
|
|
13179
13012
|
getAIGeneratedMediaOp,
|
|
13180
13013
|
getAllFilesOp,
|
|
13181
|
-
getAllVaultFoldersOp,
|
|
13182
13014
|
getAllVaultMemoriesOp,
|
|
13183
13015
|
getAllVaultMemoryContentsOp,
|
|
13184
13016
|
getAudioOp,
|
|
@@ -13221,7 +13053,6 @@ export {
|
|
|
13221
13053
|
getUnfiledVaultMemoriesOp,
|
|
13222
13054
|
getUserPreferenceOp,
|
|
13223
13055
|
getUserUploadedMediaOp,
|
|
13224
|
-
getVaultFolderMemoryCountOp,
|
|
13225
13056
|
getVaultMemoryOp,
|
|
13226
13057
|
getVideosOp,
|
|
13227
13058
|
hardDeleteDecayedOp,
|
|
@@ -13237,7 +13068,6 @@ export {
|
|
|
13237
13068
|
maybeSummarizeHistory,
|
|
13238
13069
|
mediaToStored,
|
|
13239
13070
|
migrateFromModelPreferencesOp,
|
|
13240
|
-
moveMemoriesToFolderOp,
|
|
13241
13071
|
onKeyAvailable,
|
|
13242
13072
|
preEmbedVaultMemories,
|
|
13243
13073
|
preprocessFiles,
|
|
@@ -13298,8 +13128,6 @@ export {
|
|
|
13298
13128
|
updateProfileOp,
|
|
13299
13129
|
updateProjectNameOp,
|
|
13300
13130
|
updateProjectOp,
|
|
13301
|
-
updateVaultFolderContextOp,
|
|
13302
|
-
updateVaultFolderOp,
|
|
13303
13131
|
updateVaultMemoryEmbeddingOp,
|
|
13304
13132
|
updateVaultMemoryOp,
|
|
13305
13133
|
upsertConversationSummaryOp,
|