@anuma/sdk 8.0.0 → 8.0.2
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 +354 -258
- package/dist/expo/index.mjs +306 -210
- package/dist/react/index.cjs +452 -351
- package/dist/react/index.mjs +398 -297
- package/dist/server/index.cjs +9 -1
- package/dist/server/index.mjs +9 -1
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -2048,7 +2048,7 @@ ${appendix}` : appendix;
|
|
|
2048
2048
|
}
|
|
2049
2049
|
|
|
2050
2050
|
// src/lib/db/chat/operations.ts
|
|
2051
|
-
var
|
|
2051
|
+
var import_watermelondb3 = require("@nozbe/watermelondb");
|
|
2052
2052
|
var import_uuid2 = require("uuid");
|
|
2053
2053
|
|
|
2054
2054
|
// src/react/useEncryption.ts
|
|
@@ -3263,6 +3263,118 @@ async function assembleDecryptedMessage(message, address) {
|
|
|
3263
3263
|
return result;
|
|
3264
3264
|
}
|
|
3265
3265
|
|
|
3266
|
+
// src/lib/db/chat/toolCallEventIndex.ts
|
|
3267
|
+
var import_watermelondb2 = require("@nozbe/watermelondb");
|
|
3268
|
+
function parseEventIds(value) {
|
|
3269
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3270
|
+
let events;
|
|
3271
|
+
try {
|
|
3272
|
+
events = typeof value === "string" ? JSON.parse(value) : value;
|
|
3273
|
+
} catch {
|
|
3274
|
+
return ids;
|
|
3275
|
+
}
|
|
3276
|
+
if (!Array.isArray(events)) return ids;
|
|
3277
|
+
for (const event of events) {
|
|
3278
|
+
if (!event || typeof event !== "object") continue;
|
|
3279
|
+
const id = event.id;
|
|
3280
|
+
if (typeof id === "string" && id) ids.add(id);
|
|
3281
|
+
}
|
|
3282
|
+
return ids;
|
|
3283
|
+
}
|
|
3284
|
+
async function fetchEventRows(collection, conversationId) {
|
|
3285
|
+
try {
|
|
3286
|
+
return await collection.query(
|
|
3287
|
+
import_watermelondb2.Q.unsafeSqlQuery(
|
|
3288
|
+
`select "id", "tool_call_events" from "history" where "conversation_id" = ? and "_status" != 'deleted' and "tool_call_events" is not null and "tool_call_events" not in ('', '[]')`,
|
|
3289
|
+
[conversationId]
|
|
3290
|
+
)
|
|
3291
|
+
).unsafeFetchRaw();
|
|
3292
|
+
} catch (error) {
|
|
3293
|
+
if (!(error instanceof Error) || !/unsafeSqlQuery.*not supported/.test(error.message)) {
|
|
3294
|
+
throw error;
|
|
3295
|
+
}
|
|
3296
|
+
return await collection.query(
|
|
3297
|
+
import_watermelondb2.Q.where("conversation_id", conversationId),
|
|
3298
|
+
import_watermelondb2.Q.where("tool_call_events", import_watermelondb2.Q.notEq(null)),
|
|
3299
|
+
import_watermelondb2.Q.where("tool_call_events", import_watermelondb2.Q.notIn(["", "[]"])),
|
|
3300
|
+
import_watermelondb2.Q.unsafeLokiTransform(
|
|
3301
|
+
(rows) => rows.map(({ id, tool_call_events }) => ({ id, tool_call_events }))
|
|
3302
|
+
)
|
|
3303
|
+
).unsafeFetchRaw();
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
var ToolCallEventIndex = class {
|
|
3307
|
+
constructor(collection) {
|
|
3308
|
+
this.collection = collection;
|
|
3309
|
+
this.conversations = /* @__PURE__ */ new Map();
|
|
3310
|
+
this.messages = /* @__PURE__ */ new Map();
|
|
3311
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
3312
|
+
this.resetCount = collection.database._resetCount;
|
|
3313
|
+
collection.experimentalSubscribe((changes) => {
|
|
3314
|
+
for (const { record: record2, type } of changes) {
|
|
3315
|
+
this.replace(
|
|
3316
|
+
record2.id,
|
|
3317
|
+
type === "destroyed" ? void 0 : record2.conversationId,
|
|
3318
|
+
type === "destroyed" ? void 0 : record2._getRaw("tool_call_events")
|
|
3319
|
+
);
|
|
3320
|
+
}
|
|
3321
|
+
});
|
|
3322
|
+
}
|
|
3323
|
+
replace(messageId, conversationId, value) {
|
|
3324
|
+
const previous = this.messages.get(messageId);
|
|
3325
|
+
if (previous) {
|
|
3326
|
+
const counts2 = this.conversations.get(previous.conversationId);
|
|
3327
|
+
for (const id of previous.ids) {
|
|
3328
|
+
const count2 = counts2.get(id) - 1;
|
|
3329
|
+
if (count2 === 0) counts2.delete(id);
|
|
3330
|
+
else counts2.set(id, count2);
|
|
3331
|
+
}
|
|
3332
|
+
this.messages.delete(messageId);
|
|
3333
|
+
}
|
|
3334
|
+
const counts = conversationId === void 0 ? void 0 : this.conversations.get(conversationId);
|
|
3335
|
+
if (!counts || conversationId === void 0) return;
|
|
3336
|
+
const ids = parseEventIds(value);
|
|
3337
|
+
if (ids.size === 0) return;
|
|
3338
|
+
this.messages.set(messageId, { conversationId, ids });
|
|
3339
|
+
for (const id of ids) counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
3340
|
+
}
|
|
3341
|
+
async get(conversationId) {
|
|
3342
|
+
if (this.resetCount !== this.collection.database._resetCount) {
|
|
3343
|
+
this.conversations.clear();
|
|
3344
|
+
this.messages.clear();
|
|
3345
|
+
this.pending.clear();
|
|
3346
|
+
this.resetCount = this.collection.database._resetCount;
|
|
3347
|
+
}
|
|
3348
|
+
if (!this.conversations.has(conversationId)) {
|
|
3349
|
+
let pending = this.pending.get(conversationId);
|
|
3350
|
+
if (!pending) {
|
|
3351
|
+
pending = this.collection.database.read(async () => {
|
|
3352
|
+
const rows = await fetchEventRows(this.collection, conversationId);
|
|
3353
|
+
this.conversations.set(conversationId, /* @__PURE__ */ new Map());
|
|
3354
|
+
for (const row of rows)
|
|
3355
|
+
this.replace(String(row.id), conversationId, row.tool_call_events);
|
|
3356
|
+
});
|
|
3357
|
+
this.pending.set(conversationId, pending);
|
|
3358
|
+
}
|
|
3359
|
+
try {
|
|
3360
|
+
await pending;
|
|
3361
|
+
} finally {
|
|
3362
|
+
this.pending.delete(conversationId);
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return new Set(this.conversations.get(conversationId).keys());
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
var indexes = /* @__PURE__ */ new WeakMap();
|
|
3369
|
+
function getToolCallEventIds(collection, conversationId) {
|
|
3370
|
+
let index = indexes.get(collection);
|
|
3371
|
+
if (!index) {
|
|
3372
|
+
index = new ToolCallEventIndex(collection);
|
|
3373
|
+
indexes.set(collection, index);
|
|
3374
|
+
}
|
|
3375
|
+
return index.get(conversationId);
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3266
3378
|
// src/lib/db/chat/types.ts
|
|
3267
3379
|
var import_uuid = require("uuid");
|
|
3268
3380
|
|
|
@@ -3655,7 +3767,7 @@ async function createConversationOp(ctx, opts, defaultTitle = "New Conversation"
|
|
|
3655
3767
|
);
|
|
3656
3768
|
}
|
|
3657
3769
|
async function getConversationOp(ctx, id) {
|
|
3658
|
-
const results = await ctx.conversationsCollection.query(
|
|
3770
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("conversation_id", id), import_watermelondb3.Q.where("is_deleted", false)).fetch();
|
|
3659
3771
|
return results.length > 0 ? await conversationToStored(
|
|
3660
3772
|
results[0],
|
|
3661
3773
|
ctx.walletAddress,
|
|
@@ -3664,7 +3776,7 @@ async function getConversationOp(ctx, id) {
|
|
|
3664
3776
|
) : null;
|
|
3665
3777
|
}
|
|
3666
3778
|
async function getConversationsOp(ctx) {
|
|
3667
|
-
const results = await ctx.conversationsCollection.query(
|
|
3779
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("is_deleted", false), import_watermelondb3.Q.sortBy("created_at", import_watermelondb3.Q.desc)).unsafeFetchRaw();
|
|
3668
3780
|
return Promise.all(
|
|
3669
3781
|
results.map(
|
|
3670
3782
|
(raw) => conversationRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
@@ -3685,33 +3797,33 @@ function conversationRawToLazyStored(raw) {
|
|
|
3685
3797
|
};
|
|
3686
3798
|
}
|
|
3687
3799
|
async function getConversationsLazyOp(ctx) {
|
|
3688
|
-
const results = await ctx.conversationsCollection.query(
|
|
3800
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("is_deleted", false), import_watermelondb3.Q.sortBy("created_at", import_watermelondb3.Q.desc)).unsafeFetchRaw();
|
|
3689
3801
|
return results.map(conversationRawToLazyStored);
|
|
3690
3802
|
}
|
|
3691
3803
|
async function getConversationsPageOp(ctx, options) {
|
|
3692
3804
|
const limit = Math.floor(options?.limit ?? 200);
|
|
3693
3805
|
if (!Number.isFinite(limit) || limit < 1) return [];
|
|
3694
3806
|
const exclude = new Set(options?.boundaryExcludeUniqueIds ?? []);
|
|
3695
|
-
const clauses = [
|
|
3807
|
+
const clauses = [import_watermelondb3.Q.where("is_deleted", false)];
|
|
3696
3808
|
if (options?.before !== void 0) {
|
|
3697
3809
|
clauses.push(
|
|
3698
|
-
exclude.size > 0 ?
|
|
3810
|
+
exclude.size > 0 ? import_watermelondb3.Q.where("created_at", import_watermelondb3.Q.lte(options.before)) : import_watermelondb3.Q.where("created_at", import_watermelondb3.Q.lt(options.before))
|
|
3699
3811
|
);
|
|
3700
3812
|
}
|
|
3701
|
-
const fetched = await ctx.conversationsCollection.query(...clauses,
|
|
3813
|
+
const fetched = await ctx.conversationsCollection.query(...clauses, import_watermelondb3.Q.sortBy("created_at", import_watermelondb3.Q.desc), import_watermelondb3.Q.take(limit + exclude.size)).unsafeFetchRaw();
|
|
3702
3814
|
const results = exclude.size > 0 ? fetched.filter((raw) => !exclude.has(raw.id)) : fetched;
|
|
3703
3815
|
return results.slice(0, limit).map(conversationRawToLazyStored);
|
|
3704
3816
|
}
|
|
3705
3817
|
async function getConversationsByProjectLazyOp(ctx, projectId) {
|
|
3706
3818
|
const results = await ctx.conversationsCollection.query(
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3819
|
+
import_watermelondb3.Q.where("project_id", projectId === null ? "" : projectId),
|
|
3820
|
+
import_watermelondb3.Q.where("is_deleted", false),
|
|
3821
|
+
import_watermelondb3.Q.sortBy("created_at", import_watermelondb3.Q.desc)
|
|
3710
3822
|
).unsafeFetchRaw();
|
|
3711
3823
|
return results.map(conversationRawToLazyStored);
|
|
3712
3824
|
}
|
|
3713
3825
|
async function updateConversationTitleOp(ctx, id, title) {
|
|
3714
|
-
const results = await ctx.conversationsCollection.query(
|
|
3826
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("conversation_id", id), import_watermelondb3.Q.where("is_deleted", false)).fetch();
|
|
3715
3827
|
if (results.length > 0) {
|
|
3716
3828
|
const encryptedOpts = ctx.walletAddress && ctx.signMessage ? await encryptConversationFields(
|
|
3717
3829
|
{ title },
|
|
@@ -3730,13 +3842,13 @@ async function updateConversationTitleOp(ctx, id, title) {
|
|
|
3730
3842
|
return false;
|
|
3731
3843
|
}
|
|
3732
3844
|
async function deleteConversationOp(ctx, id) {
|
|
3733
|
-
const results = await ctx.conversationsCollection.query(
|
|
3845
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("conversation_id", id), import_watermelondb3.Q.where("is_deleted", false)).fetch();
|
|
3734
3846
|
if (results.length > 0) {
|
|
3735
3847
|
await ctx.database.write(async () => {
|
|
3736
3848
|
await results[0].update((conv) => {
|
|
3737
3849
|
conv._setRaw("is_deleted", true);
|
|
3738
3850
|
});
|
|
3739
|
-
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(
|
|
3851
|
+
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(import_watermelondb3.Q.where("conversation_id", id)).fetch() : [];
|
|
3740
3852
|
for (const job of jobs) await job.destroyPermanently();
|
|
3741
3853
|
});
|
|
3742
3854
|
return true;
|
|
@@ -3744,7 +3856,7 @@ async function deleteConversationOp(ctx, id) {
|
|
|
3744
3856
|
return false;
|
|
3745
3857
|
}
|
|
3746
3858
|
async function updateConversationPinnedOp(ctx, id, pinned) {
|
|
3747
|
-
const results = await ctx.conversationsCollection.query(
|
|
3859
|
+
const results = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("conversation_id", id), import_watermelondb3.Q.where("is_deleted", false)).fetch();
|
|
3748
3860
|
if (results.length > 0) {
|
|
3749
3861
|
await ctx.database.write(async () => {
|
|
3750
3862
|
await results[0].update((conv) => {
|
|
@@ -3756,7 +3868,7 @@ async function updateConversationPinnedOp(ctx, id, pinned) {
|
|
|
3756
3868
|
return false;
|
|
3757
3869
|
}
|
|
3758
3870
|
async function getMessagesOp(ctx, convId, opts) {
|
|
3759
|
-
const fetched = await ctx.messagesCollection.query(
|
|
3871
|
+
const fetched = await ctx.messagesCollection.query(import_watermelondb3.Q.where("conversation_id", convId), import_watermelondb3.Q.sortBy("message_id", import_watermelondb3.Q.asc)).unsafeFetchRaw();
|
|
3760
3872
|
const results = opts?.rawFilter ? fetched.filter(opts.rawFilter) : fetched;
|
|
3761
3873
|
return Promise.all(
|
|
3762
3874
|
results.map(
|
|
@@ -3765,19 +3877,19 @@ async function getMessagesOp(ctx, convId, opts) {
|
|
|
3765
3877
|
);
|
|
3766
3878
|
}
|
|
3767
3879
|
async function getMessageCountOp(ctx, convId) {
|
|
3768
|
-
return await ctx.messagesCollection.query(
|
|
3880
|
+
return await ctx.messagesCollection.query(import_watermelondb3.Q.where("conversation_id", convId)).fetchCount();
|
|
3769
3881
|
}
|
|
3770
3882
|
async function getMessagesPageOp(ctx, convId, opts) {
|
|
3771
3883
|
const limit = Math.floor(opts.limit);
|
|
3772
3884
|
if (!Number.isFinite(limit) || limit < 1) return [];
|
|
3773
3885
|
const exclude = new Set(opts.boundaryExcludeUniqueIds ?? []);
|
|
3774
|
-
const clauses = [
|
|
3886
|
+
const clauses = [import_watermelondb3.Q.where("conversation_id", convId)];
|
|
3775
3887
|
if (opts.beforeMessageId !== void 0) {
|
|
3776
3888
|
clauses.push(
|
|
3777
|
-
exclude.size > 0 ?
|
|
3889
|
+
exclude.size > 0 ? import_watermelondb3.Q.where("message_id", import_watermelondb3.Q.lte(opts.beforeMessageId)) : import_watermelondb3.Q.where("message_id", import_watermelondb3.Q.lt(opts.beforeMessageId))
|
|
3778
3890
|
);
|
|
3779
3891
|
}
|
|
3780
|
-
const fetched = await ctx.messagesCollection.query(...clauses,
|
|
3892
|
+
const fetched = await ctx.messagesCollection.query(...clauses, import_watermelondb3.Q.sortBy("message_id", import_watermelondb3.Q.desc), import_watermelondb3.Q.take(limit + exclude.size)).unsafeFetchRaw();
|
|
3781
3893
|
const results = (exclude.size > 0 ? fetched.filter((raw) => !exclude.has(raw.id)) : fetched).slice(0, limit);
|
|
3782
3894
|
results.reverse();
|
|
3783
3895
|
return Promise.all(
|
|
@@ -3789,7 +3901,7 @@ async function getMessagesPageOp(ctx, convId, opts) {
|
|
|
3789
3901
|
);
|
|
3790
3902
|
}
|
|
3791
3903
|
async function getMessageSkeletonsOp(ctx, convId) {
|
|
3792
|
-
const results = await ctx.messagesCollection.query(
|
|
3904
|
+
const results = await ctx.messagesCollection.query(import_watermelondb3.Q.where("conversation_id", convId), import_watermelondb3.Q.sortBy("message_id", import_watermelondb3.Q.asc)).unsafeFetchRaw();
|
|
3793
3905
|
const roleById = /* @__PURE__ */ new Map();
|
|
3794
3906
|
for (const raw of results) {
|
|
3795
3907
|
roleById.set(raw.id, raw.role);
|
|
@@ -3834,32 +3946,12 @@ async function getMessageSkeletonsOp(ctx, convId) {
|
|
|
3834
3946
|
return skeletons;
|
|
3835
3947
|
}
|
|
3836
3948
|
async function getToolCallEventIdsOp(ctx, convId) {
|
|
3837
|
-
|
|
3838
|
-
const ids = /* @__PURE__ */ new Set();
|
|
3839
|
-
for (const raw of results) {
|
|
3840
|
-
const value = raw.tool_call_events;
|
|
3841
|
-
if (!value) continue;
|
|
3842
|
-
let events;
|
|
3843
|
-
if (typeof value === "string") {
|
|
3844
|
-
try {
|
|
3845
|
-
events = JSON.parse(value);
|
|
3846
|
-
} catch {
|
|
3847
|
-
continue;
|
|
3848
|
-
}
|
|
3849
|
-
} else if (Array.isArray(value)) {
|
|
3850
|
-
events = value;
|
|
3851
|
-
}
|
|
3852
|
-
if (!Array.isArray(events)) continue;
|
|
3853
|
-
for (const evt of events) {
|
|
3854
|
-
if (evt && evt.id) ids.add(evt.id);
|
|
3855
|
-
}
|
|
3856
|
-
}
|
|
3857
|
-
return ids;
|
|
3949
|
+
return getToolCallEventIds(ctx.messagesCollection, convId);
|
|
3858
3950
|
}
|
|
3859
3951
|
async function clearMessagesOp(ctx, convId) {
|
|
3860
3952
|
await ctx.database.write(async () => {
|
|
3861
|
-
const messages = await ctx.messagesCollection.query(
|
|
3862
|
-
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(
|
|
3953
|
+
const messages = await ctx.messagesCollection.query(import_watermelondb3.Q.where("conversation_id", convId)).fetch();
|
|
3954
|
+
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(import_watermelondb3.Q.where("conversation_id", convId)).fetch() : [];
|
|
3863
3955
|
for (const job of jobs) {
|
|
3864
3956
|
await job.update((row) => {
|
|
3865
3957
|
row._setRaw("message_ids", "[]");
|
|
@@ -3884,7 +3976,7 @@ async function deleteMessageOp(ctx, uniqueId) {
|
|
|
3884
3976
|
return null;
|
|
3885
3977
|
}
|
|
3886
3978
|
await ctx.database.write(async () => {
|
|
3887
|
-
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(
|
|
3979
|
+
const jobs = ctx.database.schema?.tables[ExtractionJob.table] ? await ctx.database.get(ExtractionJob.table).query(import_watermelondb3.Q.where("conversation_id", message.conversationId)).fetch() : [];
|
|
3888
3980
|
for (const job of jobs) {
|
|
3889
3981
|
const ids = JSON.parse(String(job._getRaw("message_ids")));
|
|
3890
3982
|
await job.update((row) => {
|
|
@@ -3957,9 +4049,9 @@ async function createMessageOp(ctx, opts) {
|
|
|
3957
4049
|
}
|
|
3958
4050
|
}
|
|
3959
4051
|
const newest = await ctx.messagesCollection.query(
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4052
|
+
import_watermelondb3.Q.where("conversation_id", opts.conversationId),
|
|
4053
|
+
import_watermelondb3.Q.sortBy("message_id", import_watermelondb3.Q.desc),
|
|
4054
|
+
import_watermelondb3.Q.take(1)
|
|
3963
4055
|
).fetch();
|
|
3964
4056
|
const messageId = (newest[0]?.messageId ?? 0) + 1;
|
|
3965
4057
|
const encryptedOpts = await encryptMessageOptsIfNeeded(ctx, opts);
|
|
@@ -3973,7 +4065,7 @@ async function createMessageOp(ctx, opts) {
|
|
|
3973
4065
|
return messageToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
|
|
3974
4066
|
}
|
|
3975
4067
|
async function upsertMessageOp(ctx, opts) {
|
|
3976
|
-
const results = await ctx.messagesCollection.query(
|
|
4068
|
+
const results = await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", opts.uniqueId)).fetch();
|
|
3977
4069
|
const existing = results.length > 0 ? results[0] : null;
|
|
3978
4070
|
if (!existing) {
|
|
3979
4071
|
return createMessageOp(ctx, opts);
|
|
@@ -4081,13 +4173,13 @@ async function decryptMessageEmbeddingFields(raw, walletAddress) {
|
|
|
4081
4173
|
async function sealLegacyMessageEmbeddingsOp(ctx) {
|
|
4082
4174
|
if (!ctx.walletAddress) return 0;
|
|
4083
4175
|
const candidateIds = await ctx.messagesCollection.query(
|
|
4084
|
-
|
|
4085
|
-
|
|
4176
|
+
import_watermelondb3.Q.where("content", import_watermelondb3.Q.like("enc:%")),
|
|
4177
|
+
import_watermelondb3.Q.or(
|
|
4086
4178
|
...["vector", "chunks"].map(
|
|
4087
|
-
(column) =>
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4179
|
+
(column) => import_watermelondb3.Q.and(
|
|
4180
|
+
import_watermelondb3.Q.where(column, import_watermelondb3.Q.notEq(null)),
|
|
4181
|
+
import_watermelondb3.Q.where(column, import_watermelondb3.Q.notEq("")),
|
|
4182
|
+
import_watermelondb3.Q.where(column, import_watermelondb3.Q.notLike("enc:%"))
|
|
4091
4183
|
)
|
|
4092
4184
|
)
|
|
4093
4185
|
)
|
|
@@ -4097,7 +4189,7 @@ async function sealLegacyMessageEmbeddingsOp(ctx) {
|
|
|
4097
4189
|
for (let start = 0; start < candidateIds.length; start += 50) {
|
|
4098
4190
|
const pageIds = candidateIds.slice(start, start + 50);
|
|
4099
4191
|
await ctx.database.write(async () => {
|
|
4100
|
-
const pageMessages = await ctx.messagesCollection.query(
|
|
4192
|
+
const pageMessages = await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(pageIds))).fetch();
|
|
4101
4193
|
for (const message of pageMessages) {
|
|
4102
4194
|
if (!isEncrypted(message.content)) continue;
|
|
4103
4195
|
const content = await decryptFieldDetailed(message.content, ctx.walletAddress);
|
|
@@ -4178,15 +4270,15 @@ function chunksWithoutText(raw) {
|
|
|
4178
4270
|
});
|
|
4179
4271
|
}
|
|
4180
4272
|
async function stripLegacyChunkTextOp(ctx) {
|
|
4181
|
-
const candidateIds = await ctx.messagesCollection.query(
|
|
4273
|
+
const candidateIds = await ctx.messagesCollection.query(import_watermelondb3.Q.where("chunks", import_watermelondb3.Q.like(`%${import_watermelondb3.Q.sanitizeLikeString('"text":')}%`))).fetchIds();
|
|
4182
4274
|
let stripped = 0;
|
|
4183
4275
|
for (let start = 0; start < candidateIds.length; start += RAW_REPAIR_PAGE_SIZE) {
|
|
4184
4276
|
const pageIds = candidateIds.slice(start, start + RAW_REPAIR_PAGE_SIZE);
|
|
4185
|
-
const rows = await ctx.messagesCollection.query(
|
|
4277
|
+
const rows = await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(pageIds))).unsafeFetchRaw();
|
|
4186
4278
|
const changedIds = rows.filter((row) => chunksWithoutText(row.chunks) !== null).map((row) => String(row.id));
|
|
4187
4279
|
if (changedIds.length === 0) continue;
|
|
4188
4280
|
await ctx.database.write(async () => {
|
|
4189
|
-
const messages = await ctx.messagesCollection.query(
|
|
4281
|
+
const messages = await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(changedIds))).fetch();
|
|
4190
4282
|
const updates = messages.flatMap((message) => {
|
|
4191
4283
|
const raw = message._raw;
|
|
4192
4284
|
const chunks3 = chunksWithoutText(raw.chunks);
|
|
@@ -4233,13 +4325,13 @@ async function encryptToolCallEventsOp(ctx) {
|
|
|
4233
4325
|
return 0;
|
|
4234
4326
|
}
|
|
4235
4327
|
const candidateIds = await ctx.messagesCollection.query(
|
|
4236
|
-
|
|
4237
|
-
|
|
4328
|
+
import_watermelondb3.Q.where("tool_call_events", import_watermelondb3.Q.notEq(null)),
|
|
4329
|
+
import_watermelondb3.Q.where("tool_call_events", import_watermelondb3.Q.notIn(["", "[]"]))
|
|
4238
4330
|
).fetchIds();
|
|
4239
4331
|
let encrypted = 0;
|
|
4240
4332
|
for (let start = 0; start < candidateIds.length; start += RAW_REPAIR_PAGE_SIZE) {
|
|
4241
4333
|
const pageIds = candidateIds.slice(start, start + RAW_REPAIR_PAGE_SIZE);
|
|
4242
|
-
const rows = await ctx.messagesCollection.query(
|
|
4334
|
+
const rows = await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(pageIds))).unsafeFetchRaw();
|
|
4243
4335
|
const repairs = /* @__PURE__ */ new Map();
|
|
4244
4336
|
for (const row of rows) {
|
|
4245
4337
|
const column = await encryptedToolCallEventsColumn(
|
|
@@ -4252,12 +4344,12 @@ async function encryptToolCallEventsOp(ctx) {
|
|
|
4252
4344
|
}
|
|
4253
4345
|
if (repairs.size === 0) continue;
|
|
4254
4346
|
await ctx.database.write(async () => {
|
|
4255
|
-
const messages = (await ctx.messagesCollection.query(
|
|
4347
|
+
const messages = (await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf([...repairs.keys()]))).fetch()).filter(
|
|
4256
4348
|
(message) => message._raw.tool_call_events === repairs.get(message.id)?.raw
|
|
4257
4349
|
);
|
|
4258
4350
|
if (messages.length === 0) return;
|
|
4259
4351
|
const conversationIds = [...new Set(messages.map((message) => message.conversationId))];
|
|
4260
|
-
const conversations = await ctx.conversationsCollection.query(
|
|
4352
|
+
const conversations = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("conversation_id", import_watermelondb3.Q.oneOf(conversationIds))).fetch();
|
|
4261
4353
|
await ctx.database.batch(
|
|
4262
4354
|
...messages.map(
|
|
4263
4355
|
(message) => message.prepareUpdate((msg) => {
|
|
@@ -4284,7 +4376,7 @@ async function savedKeyOpensExistingData(ctx, address, signMessage, embeddedWall
|
|
|
4284
4376
|
return refreshEncryptionKeyIfMatches(address, v2Probe, signMessage, embeddedWalletSigner);
|
|
4285
4377
|
}
|
|
4286
4378
|
async function findEncryptedContent(ctx, pattern) {
|
|
4287
|
-
const [row] = await ctx.messagesCollection.query(
|
|
4379
|
+
const [row] = await ctx.messagesCollection.query(import_watermelondb3.Q.where("content", import_watermelondb3.Q.like(pattern)), import_watermelondb3.Q.take(1)).unsafeFetchRaw();
|
|
4288
4380
|
return row ? String(row.content) : null;
|
|
4289
4381
|
}
|
|
4290
4382
|
async function updateMessageErrorOp(ctx, uniqueId, error) {
|
|
@@ -4397,7 +4489,7 @@ function toChunkCandidateKey(raw) {
|
|
|
4397
4489
|
}
|
|
4398
4490
|
async function fetchRowsByIds(ctx, ids) {
|
|
4399
4491
|
if (ids.length === 0) return [];
|
|
4400
|
-
return await ctx.messagesCollection.query(
|
|
4492
|
+
return await ctx.messagesCollection.query(import_watermelondb3.Q.where("id", import_watermelondb3.Q.oneOf(ids))).unsafeFetchRaw();
|
|
4401
4493
|
}
|
|
4402
4494
|
async function projectedChunkRowSource(ctx, filter) {
|
|
4403
4495
|
const clauses = [
|
|
@@ -4415,7 +4507,7 @@ async function projectedChunkRowSource(ctx, filter) {
|
|
|
4415
4507
|
args.push(filter.excludeConversationId);
|
|
4416
4508
|
}
|
|
4417
4509
|
const keyRows = await ctx.messagesCollection.query(
|
|
4418
|
-
|
|
4510
|
+
import_watermelondb3.Q.unsafeSqlQuery(
|
|
4419
4511
|
`select "id", "conversation_id", "updated_at", "embedding_model" from "history" where ${clauses.join(" and ")}`,
|
|
4420
4512
|
args
|
|
4421
4513
|
)
|
|
@@ -4425,7 +4517,7 @@ async function projectedChunkRowSource(ctx, filter) {
|
|
|
4425
4517
|
loadVectorRows: async (ids) => {
|
|
4426
4518
|
if (ids.length === 0) return [];
|
|
4427
4519
|
return await ctx.messagesCollection.query(
|
|
4428
|
-
|
|
4520
|
+
import_watermelondb3.Q.unsafeSqlQuery(
|
|
4429
4521
|
`select "id", "updated_at", "chunks", "vector" from "history" where "_status" is not 'deleted' and "id" in (${ids.map(() => "?").join(",")})`,
|
|
4430
4522
|
ids
|
|
4431
4523
|
)
|
|
@@ -4435,11 +4527,11 @@ async function projectedChunkRowSource(ctx, filter) {
|
|
|
4435
4527
|
};
|
|
4436
4528
|
}
|
|
4437
4529
|
async function fullScanChunkRowSource(ctx, filter) {
|
|
4438
|
-
const activeConversations = await ctx.conversationsCollection.query(
|
|
4530
|
+
const activeConversations = await ctx.conversationsCollection.query(import_watermelondb3.Q.where("is_deleted", false)).fetch();
|
|
4439
4531
|
const activeConversationIds = new Set(
|
|
4440
4532
|
activeConversations.map((c) => String(c._getRaw("conversation_id")))
|
|
4441
4533
|
);
|
|
4442
|
-
const queryConditions = filter.conversationId !== void 0 ? [
|
|
4534
|
+
const queryConditions = filter.conversationId !== void 0 ? [import_watermelondb3.Q.where("conversation_id", filter.conversationId)] : [];
|
|
4443
4535
|
const rows = await ctx.messagesCollection.query(...queryConditions).unsafeFetchRaw();
|
|
4444
4536
|
const rowsById = /* @__PURE__ */ new Map();
|
|
4445
4537
|
for (const row of rows) {
|
|
@@ -11054,9 +11146,9 @@ async function decryptConversationTitle(encryptedTitle, address) {
|
|
|
11054
11146
|
}
|
|
11055
11147
|
|
|
11056
11148
|
// src/lib/db/chat/models.ts
|
|
11057
|
-
var
|
|
11149
|
+
var import_watermelondb4 = require("@nozbe/watermelondb");
|
|
11058
11150
|
var import_decorators = require("@nozbe/watermelondb/decorators");
|
|
11059
|
-
var Message = class extends
|
|
11151
|
+
var Message = class extends import_watermelondb4.Model {
|
|
11060
11152
|
};
|
|
11061
11153
|
Message.table = "history";
|
|
11062
11154
|
Message.associations = {
|
|
@@ -11135,7 +11227,7 @@ __decorateClass([
|
|
|
11135
11227
|
__decorateClass([
|
|
11136
11228
|
(0, import_decorators.text)("origin")
|
|
11137
11229
|
], Message.prototype, "origin", 2);
|
|
11138
|
-
var Conversation = class extends
|
|
11230
|
+
var Conversation = class extends import_watermelondb4.Model {
|
|
11139
11231
|
};
|
|
11140
11232
|
Conversation.table = "conversations";
|
|
11141
11233
|
Conversation.associations = {
|
|
@@ -11163,7 +11255,7 @@ __decorateClass([
|
|
|
11163
11255
|
__decorateClass([
|
|
11164
11256
|
(0, import_decorators.date)("pinned_at")
|
|
11165
11257
|
], Conversation.prototype, "pinnedAt", 2);
|
|
11166
|
-
var ConversationSummary = class extends
|
|
11258
|
+
var ConversationSummary = class extends import_watermelondb4.Model {
|
|
11167
11259
|
};
|
|
11168
11260
|
ConversationSummary.table = "conversation_summaries";
|
|
11169
11261
|
ConversationSummary.associations = {
|
|
@@ -11189,12 +11281,12 @@ __decorateClass([
|
|
|
11189
11281
|
], ConversationSummary.prototype, "updatedAt", 2);
|
|
11190
11282
|
|
|
11191
11283
|
// src/lib/db/chat/schema.ts
|
|
11192
|
-
var
|
|
11284
|
+
var import_watermelondb5 = require("@nozbe/watermelondb");
|
|
11193
11285
|
var import_migrations = require("@nozbe/watermelondb/Schema/migrations");
|
|
11194
|
-
var chatStorageSchema = (0,
|
|
11286
|
+
var chatStorageSchema = (0, import_watermelondb5.appSchema)({
|
|
11195
11287
|
version: 7,
|
|
11196
11288
|
tables: [
|
|
11197
|
-
(0,
|
|
11289
|
+
(0, import_watermelondb5.tableSchema)({
|
|
11198
11290
|
name: "history",
|
|
11199
11291
|
columns: [
|
|
11200
11292
|
{ name: "message_id", type: "number" },
|
|
@@ -11218,7 +11310,7 @@ var chatStorageSchema = (0, import_watermelondb4.appSchema)({
|
|
|
11218
11310
|
{ name: "thinking", type: "string", isOptional: true }
|
|
11219
11311
|
]
|
|
11220
11312
|
}),
|
|
11221
|
-
(0,
|
|
11313
|
+
(0, import_watermelondb5.tableSchema)({
|
|
11222
11314
|
name: "conversations",
|
|
11223
11315
|
columns: [
|
|
11224
11316
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -11290,7 +11382,7 @@ var chatStorageMigrations = (0, import_migrations.schemaMigrations)({
|
|
|
11290
11382
|
});
|
|
11291
11383
|
|
|
11292
11384
|
// src/lib/db/chat/summaryOperations.ts
|
|
11293
|
-
var
|
|
11385
|
+
var import_watermelondb6 = require("@nozbe/watermelondb");
|
|
11294
11386
|
function createSummaryContext(database) {
|
|
11295
11387
|
return {
|
|
11296
11388
|
database,
|
|
@@ -11309,14 +11401,14 @@ function modelToStored(record2) {
|
|
|
11309
11401
|
};
|
|
11310
11402
|
}
|
|
11311
11403
|
async function getConversationSummaryOp(ctx, conversationId) {
|
|
11312
|
-
const results = await ctx.summariesCollection.query(
|
|
11404
|
+
const results = await ctx.summariesCollection.query(import_watermelondb6.Q.where("conversation_id", conversationId)).fetch();
|
|
11313
11405
|
if (results.length === 0) return null;
|
|
11314
11406
|
return modelToStored(results[0]);
|
|
11315
11407
|
}
|
|
11316
11408
|
async function upsertConversationSummaryOp(ctx, conversationId, summary, summarizedUpTo, tokenCount) {
|
|
11317
11409
|
let record2;
|
|
11318
11410
|
await ctx.database.write(async () => {
|
|
11319
|
-
const existing = await ctx.summariesCollection.query(
|
|
11411
|
+
const existing = await ctx.summariesCollection.query(import_watermelondb6.Q.where("conversation_id", conversationId)).fetch();
|
|
11320
11412
|
if (existing.length > 0) {
|
|
11321
11413
|
record2 = await existing[0].update((rec) => {
|
|
11322
11414
|
rec.summary = summary;
|
|
@@ -11336,7 +11428,7 @@ async function upsertConversationSummaryOp(ctx, conversationId, summary, summari
|
|
|
11336
11428
|
}
|
|
11337
11429
|
async function deleteConversationSummaryOp(ctx, conversationId) {
|
|
11338
11430
|
await ctx.database.write(async () => {
|
|
11339
|
-
const existing = await ctx.summariesCollection.query(
|
|
11431
|
+
const existing = await ctx.summariesCollection.query(import_watermelondb6.Q.where("conversation_id", conversationId)).fetch();
|
|
11340
11432
|
for (const record2 of existing) {
|
|
11341
11433
|
await record2.destroyPermanently();
|
|
11342
11434
|
}
|
|
@@ -11370,9 +11462,9 @@ function maskScopedEmbeddingCache(cache, masked) {
|
|
|
11370
11462
|
}
|
|
11371
11463
|
|
|
11372
11464
|
// src/lib/db/conversationMemory/models.ts
|
|
11373
|
-
var
|
|
11465
|
+
var import_watermelondb7 = require("@nozbe/watermelondb");
|
|
11374
11466
|
var import_decorators2 = require("@nozbe/watermelondb/decorators");
|
|
11375
|
-
var ConversationMemory = class extends
|
|
11467
|
+
var ConversationMemory = class extends import_watermelondb7.Model {
|
|
11376
11468
|
};
|
|
11377
11469
|
ConversationMemory.table = "conversation_memory";
|
|
11378
11470
|
ConversationMemory.associations = {};
|
|
@@ -11391,7 +11483,7 @@ __decorateClass([
|
|
|
11391
11483
|
], ConversationMemory.prototype, "createdAt", 2);
|
|
11392
11484
|
|
|
11393
11485
|
// src/lib/db/conversationMemory/operations.ts
|
|
11394
|
-
var
|
|
11486
|
+
var import_watermelondb8 = require("@nozbe/watermelondb");
|
|
11395
11487
|
var MAX_PER_CONVERSATION = 200;
|
|
11396
11488
|
function conversationMemoryToStored(row) {
|
|
11397
11489
|
return {
|
|
@@ -11406,7 +11498,7 @@ async function addConversationMemoriesOp(ctx, conversationId, items) {
|
|
|
11406
11498
|
if (!conversationId || items.length === 0) return;
|
|
11407
11499
|
const now = Date.now();
|
|
11408
11500
|
await ctx.database.write(async () => {
|
|
11409
|
-
const existing = await ctx.conversationMemoryCollection.query(
|
|
11501
|
+
const existing = await ctx.conversationMemoryCollection.query(import_watermelondb8.Q.where("conversation_id", conversationId), import_watermelondb8.Q.sortBy("created_at", import_watermelondb8.Q.asc)).fetch();
|
|
11410
11502
|
const seen = new Set(existing.map((r) => r.memoryId));
|
|
11411
11503
|
const batchSeen = /* @__PURE__ */ new Set();
|
|
11412
11504
|
const deduped = [];
|
|
@@ -11436,13 +11528,13 @@ async function addConversationMemoriesOp(ctx, conversationId, items) {
|
|
|
11436
11528
|
}
|
|
11437
11529
|
async function getConversationMemoriesOp(ctx, conversationId) {
|
|
11438
11530
|
if (!conversationId) return [];
|
|
11439
|
-
const rows = await ctx.conversationMemoryCollection.query(
|
|
11531
|
+
const rows = await ctx.conversationMemoryCollection.query(import_watermelondb8.Q.where("conversation_id", conversationId), import_watermelondb8.Q.sortBy("created_at", import_watermelondb8.Q.asc)).fetch();
|
|
11440
11532
|
return rows.map(conversationMemoryToStored);
|
|
11441
11533
|
}
|
|
11442
11534
|
async function clearConversationMemoriesOp(ctx, conversationId) {
|
|
11443
11535
|
if (!conversationId) return;
|
|
11444
11536
|
await ctx.database.write(async () => {
|
|
11445
|
-
const rows = await ctx.conversationMemoryCollection.query(
|
|
11537
|
+
const rows = await ctx.conversationMemoryCollection.query(import_watermelondb8.Q.where("conversation_id", conversationId)).fetch();
|
|
11446
11538
|
if (rows.length === 0) return;
|
|
11447
11539
|
await ctx.database.batch(...rows.map((r) => r.prepareDestroyPermanently()));
|
|
11448
11540
|
});
|
|
@@ -11505,16 +11597,16 @@ function parseTopics(value) {
|
|
|
11505
11597
|
}
|
|
11506
11598
|
|
|
11507
11599
|
// src/lib/db/manager.ts
|
|
11508
|
-
var
|
|
11600
|
+
var import_watermelondb19 = require("@nozbe/watermelondb");
|
|
11509
11601
|
|
|
11510
11602
|
// src/lib/db/schema.ts
|
|
11511
|
-
var
|
|
11603
|
+
var import_watermelondb18 = require("@nozbe/watermelondb");
|
|
11512
11604
|
var import_migrations2 = require("@nozbe/watermelondb/Schema/migrations");
|
|
11513
11605
|
|
|
11514
11606
|
// src/lib/db/appFiles/models.ts
|
|
11515
|
-
var
|
|
11607
|
+
var import_watermelondb9 = require("@nozbe/watermelondb");
|
|
11516
11608
|
var import_decorators3 = require("@nozbe/watermelondb/decorators");
|
|
11517
|
-
var AppFile = class extends
|
|
11609
|
+
var AppFile = class extends import_watermelondb9.Model {
|
|
11518
11610
|
};
|
|
11519
11611
|
AppFile.table = "app_files";
|
|
11520
11612
|
AppFile.associations = {};
|
|
@@ -11536,9 +11628,9 @@ __decorateClass([
|
|
|
11536
11628
|
], AppFile.prototype, "updatedAt", 2);
|
|
11537
11629
|
|
|
11538
11630
|
// src/lib/db/entities/models.ts
|
|
11539
|
-
var
|
|
11631
|
+
var import_watermelondb10 = require("@nozbe/watermelondb");
|
|
11540
11632
|
var import_decorators4 = require("@nozbe/watermelondb/decorators");
|
|
11541
|
-
var Entity = class extends
|
|
11633
|
+
var Entity = class extends import_watermelondb10.Model {
|
|
11542
11634
|
};
|
|
11543
11635
|
Entity.table = "entity";
|
|
11544
11636
|
__decorateClass([
|
|
@@ -11554,7 +11646,7 @@ __decorateClass([
|
|
|
11554
11646
|
__decorateClass([
|
|
11555
11647
|
(0, import_decorators4.date)("updated_at")
|
|
11556
11648
|
], Entity.prototype, "updatedAt", 2);
|
|
11557
|
-
var MemoryEntity = class extends
|
|
11649
|
+
var MemoryEntity = class extends import_watermelondb10.Model {
|
|
11558
11650
|
};
|
|
11559
11651
|
MemoryEntity.table = "memory_entity";
|
|
11560
11652
|
__decorateClass([
|
|
@@ -11572,9 +11664,9 @@ __decorateClass([
|
|
|
11572
11664
|
], MemoryEntity.prototype, "createdAt", 2);
|
|
11573
11665
|
|
|
11574
11666
|
// src/lib/db/media/models.ts
|
|
11575
|
-
var
|
|
11667
|
+
var import_watermelondb11 = require("@nozbe/watermelondb");
|
|
11576
11668
|
var import_decorators5 = require("@nozbe/watermelondb/decorators");
|
|
11577
|
-
var Media = class extends
|
|
11669
|
+
var Media = class extends import_watermelondb11.Model {
|
|
11578
11670
|
};
|
|
11579
11671
|
Media.table = "media";
|
|
11580
11672
|
Media.associations = {
|
|
@@ -11635,9 +11727,9 @@ __decorateClass([
|
|
|
11635
11727
|
], Media.prototype, "isDeleted", 2);
|
|
11636
11728
|
|
|
11637
11729
|
// src/lib/db/memoryVault/models.ts
|
|
11638
|
-
var
|
|
11730
|
+
var import_watermelondb12 = require("@nozbe/watermelondb");
|
|
11639
11731
|
var import_decorators6 = require("@nozbe/watermelondb/decorators");
|
|
11640
|
-
var VaultMemory = class extends
|
|
11732
|
+
var VaultMemory = class extends import_watermelondb12.Model {
|
|
11641
11733
|
};
|
|
11642
11734
|
VaultMemory.table = "memory_vault";
|
|
11643
11735
|
__decorateClass([
|
|
@@ -11745,9 +11837,9 @@ __decorateClass([
|
|
|
11745
11837
|
], VaultMemory.prototype, "isDeleted", 2);
|
|
11746
11838
|
|
|
11747
11839
|
// src/lib/db/project/models.ts
|
|
11748
|
-
var
|
|
11840
|
+
var import_watermelondb13 = require("@nozbe/watermelondb");
|
|
11749
11841
|
var import_decorators7 = require("@nozbe/watermelondb/decorators");
|
|
11750
|
-
var Project = class extends
|
|
11842
|
+
var Project = class extends import_watermelondb13.Model {
|
|
11751
11843
|
};
|
|
11752
11844
|
Project.table = "projects";
|
|
11753
11845
|
Project.associations = {
|
|
@@ -11770,10 +11862,10 @@ __decorateClass([
|
|
|
11770
11862
|
], Project.prototype, "isDeleted", 2);
|
|
11771
11863
|
|
|
11772
11864
|
// src/lib/db/savedTools/models.ts
|
|
11773
|
-
var
|
|
11865
|
+
var import_watermelondb14 = require("@nozbe/watermelondb");
|
|
11774
11866
|
var import_decorators8 = require("@nozbe/watermelondb/decorators");
|
|
11775
11867
|
var sanitizeParameters = (raw) => raw ?? {};
|
|
11776
|
-
var SavedTool = class extends
|
|
11868
|
+
var SavedTool = class extends import_watermelondb14.Model {
|
|
11777
11869
|
};
|
|
11778
11870
|
SavedTool.table = "saved_tools";
|
|
11779
11871
|
SavedTool.associations = {};
|
|
@@ -11807,9 +11899,9 @@ __decorateClass([
|
|
|
11807
11899
|
], SavedTool.prototype, "isDeleted", 2);
|
|
11808
11900
|
|
|
11809
11901
|
// src/lib/db/settings/models.ts
|
|
11810
|
-
var
|
|
11902
|
+
var import_watermelondb15 = require("@nozbe/watermelondb");
|
|
11811
11903
|
var import_decorators9 = require("@nozbe/watermelondb/decorators");
|
|
11812
|
-
var ModelPreference = class extends
|
|
11904
|
+
var ModelPreference = class extends import_watermelondb15.Model {
|
|
11813
11905
|
};
|
|
11814
11906
|
ModelPreference.table = "modelPreferences";
|
|
11815
11907
|
__decorateClass([
|
|
@@ -11820,9 +11912,9 @@ __decorateClass([
|
|
|
11820
11912
|
], ModelPreference.prototype, "models", 2);
|
|
11821
11913
|
|
|
11822
11914
|
// src/lib/db/userPreferences/models.ts
|
|
11823
|
-
var
|
|
11915
|
+
var import_watermelondb16 = require("@nozbe/watermelondb");
|
|
11824
11916
|
var import_decorators10 = require("@nozbe/watermelondb/decorators");
|
|
11825
|
-
var UserPreference = class extends
|
|
11917
|
+
var UserPreference = class extends import_watermelondb16.Model {
|
|
11826
11918
|
};
|
|
11827
11919
|
UserPreference.table = "userPreferences";
|
|
11828
11920
|
__decorateClass([
|
|
@@ -11851,9 +11943,9 @@ __decorateClass([
|
|
|
11851
11943
|
], UserPreference.prototype, "updatedAt", 2);
|
|
11852
11944
|
|
|
11853
11945
|
// src/lib/db/vaultFolders/models.ts
|
|
11854
|
-
var
|
|
11946
|
+
var import_watermelondb17 = require("@nozbe/watermelondb");
|
|
11855
11947
|
var import_decorators11 = require("@nozbe/watermelondb/decorators");
|
|
11856
|
-
var VaultFolder = class extends
|
|
11948
|
+
var VaultFolder = class extends import_watermelondb17.Model {
|
|
11857
11949
|
};
|
|
11858
11950
|
VaultFolder.table = "vault_folders";
|
|
11859
11951
|
__decorateClass([
|
|
@@ -11881,10 +11973,10 @@ __decorateClass([
|
|
|
11881
11973
|
|
|
11882
11974
|
// src/lib/db/schema.ts
|
|
11883
11975
|
var SDK_SCHEMA_VERSION = 48;
|
|
11884
|
-
var sdkSchema = (0,
|
|
11976
|
+
var sdkSchema = (0, import_watermelondb18.appSchema)({
|
|
11885
11977
|
version: SDK_SCHEMA_VERSION,
|
|
11886
11978
|
tables: [
|
|
11887
|
-
(0,
|
|
11979
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11888
11980
|
name: "memory_extraction_jobs",
|
|
11889
11981
|
columns: [
|
|
11890
11982
|
{ name: "owner_key", type: "string", isIndexed: true },
|
|
@@ -11899,7 +11991,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
11899
11991
|
{ name: "failed_at", type: "number", isOptional: true }
|
|
11900
11992
|
]
|
|
11901
11993
|
}),
|
|
11902
|
-
(0,
|
|
11994
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11903
11995
|
name: "history",
|
|
11904
11996
|
columns: [
|
|
11905
11997
|
{ name: "message_id", type: "number" },
|
|
@@ -11928,7 +12020,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
11928
12020
|
{ name: "origin", type: "string", isOptional: true }
|
|
11929
12021
|
]
|
|
11930
12022
|
}),
|
|
11931
|
-
(0,
|
|
12023
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11932
12024
|
name: "conversations",
|
|
11933
12025
|
columns: [
|
|
11934
12026
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -11940,7 +12032,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
11940
12032
|
{ name: "pinned_at", type: "number", isOptional: true }
|
|
11941
12033
|
]
|
|
11942
12034
|
}),
|
|
11943
|
-
(0,
|
|
12035
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11944
12036
|
name: "projects",
|
|
11945
12037
|
columns: [
|
|
11946
12038
|
{ name: "project_id", type: "string", isIndexed: true },
|
|
@@ -11950,14 +12042,14 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
11950
12042
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
11951
12043
|
]
|
|
11952
12044
|
}),
|
|
11953
|
-
(0,
|
|
12045
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11954
12046
|
name: "modelPreferences",
|
|
11955
12047
|
columns: [
|
|
11956
12048
|
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
11957
12049
|
{ name: "models", type: "string", isOptional: true }
|
|
11958
12050
|
]
|
|
11959
12051
|
}),
|
|
11960
|
-
(0,
|
|
12052
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11961
12053
|
name: "userPreferences",
|
|
11962
12054
|
columns: [
|
|
11963
12055
|
{ name: "wallet_address", type: "string", isIndexed: true },
|
|
@@ -11970,7 +12062,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
11970
12062
|
{ name: "updated_at", type: "number" }
|
|
11971
12063
|
]
|
|
11972
12064
|
}),
|
|
11973
|
-
(0,
|
|
12065
|
+
(0, import_watermelondb18.tableSchema)({
|
|
11974
12066
|
name: "memory_vault",
|
|
11975
12067
|
columns: [
|
|
11976
12068
|
{ name: "content", type: "string" },
|
|
@@ -12009,7 +12101,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12009
12101
|
{ name: "geohash", type: "string", isOptional: true }
|
|
12010
12102
|
]
|
|
12011
12103
|
}),
|
|
12012
|
-
(0,
|
|
12104
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12013
12105
|
name: "entity",
|
|
12014
12106
|
columns: [
|
|
12015
12107
|
{ name: "canonical_name", type: "string", isIndexed: true },
|
|
@@ -12018,7 +12110,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12018
12110
|
{ name: "updated_at", type: "number" }
|
|
12019
12111
|
]
|
|
12020
12112
|
}),
|
|
12021
|
-
(0,
|
|
12113
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12022
12114
|
name: "memory_entity",
|
|
12023
12115
|
columns: [
|
|
12024
12116
|
{ name: "memory_id", type: "string", isIndexed: true },
|
|
@@ -12027,7 +12119,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12027
12119
|
{ name: "created_at", type: "number" }
|
|
12028
12120
|
]
|
|
12029
12121
|
}),
|
|
12030
|
-
(0,
|
|
12122
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12031
12123
|
name: "vault_folders",
|
|
12032
12124
|
columns: [
|
|
12033
12125
|
{ name: "name", type: "string" },
|
|
@@ -12039,7 +12131,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12039
12131
|
{ name: "context", type: "string", isOptional: true }
|
|
12040
12132
|
]
|
|
12041
12133
|
}),
|
|
12042
|
-
(0,
|
|
12134
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12043
12135
|
name: "conversation_summaries",
|
|
12044
12136
|
columns: [
|
|
12045
12137
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -12050,7 +12142,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12050
12142
|
{ name: "updated_at", type: "number" }
|
|
12051
12143
|
]
|
|
12052
12144
|
}),
|
|
12053
|
-
(0,
|
|
12145
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12054
12146
|
name: "media",
|
|
12055
12147
|
columns: [
|
|
12056
12148
|
{ name: "media_id", type: "string", isIndexed: true },
|
|
@@ -12072,7 +12164,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12072
12164
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
12073
12165
|
]
|
|
12074
12166
|
}),
|
|
12075
|
-
(0,
|
|
12167
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12076
12168
|
name: "app_files",
|
|
12077
12169
|
columns: [
|
|
12078
12170
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -12082,7 +12174,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12082
12174
|
{ name: "updated_at", type: "number" }
|
|
12083
12175
|
]
|
|
12084
12176
|
}),
|
|
12085
|
-
(0,
|
|
12177
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12086
12178
|
name: "saved_tools",
|
|
12087
12179
|
columns: [
|
|
12088
12180
|
{ name: "name", type: "string" },
|
|
@@ -12096,7 +12188,7 @@ var sdkSchema = (0, import_watermelondb17.appSchema)({
|
|
|
12096
12188
|
{ name: "is_deleted", type: "boolean", isIndexed: true }
|
|
12097
12189
|
]
|
|
12098
12190
|
}),
|
|
12099
|
-
(0,
|
|
12191
|
+
(0, import_watermelondb18.tableSchema)({
|
|
12100
12192
|
name: "conversation_memory",
|
|
12101
12193
|
columns: [
|
|
12102
12194
|
{ name: "conversation_id", type: "string", isIndexed: true },
|
|
@@ -12772,7 +12864,7 @@ var DatabaseManager = class {
|
|
|
12772
12864
|
walletAddress
|
|
12773
12865
|
});
|
|
12774
12866
|
const adapter = this.createAdapter(dbName, sdkSchema, sdkMigrations);
|
|
12775
|
-
const database = new
|
|
12867
|
+
const database = new import_watermelondb19.Database({
|
|
12776
12868
|
adapter,
|
|
12777
12869
|
modelClasses: sdkModelClasses
|
|
12778
12870
|
});
|
|
@@ -12851,11 +12943,11 @@ var DatabaseManager = class {
|
|
|
12851
12943
|
};
|
|
12852
12944
|
|
|
12853
12945
|
// src/lib/db/memoryVault/operations.ts
|
|
12854
|
-
var
|
|
12946
|
+
var import_watermelondb21 = require("@nozbe/watermelondb");
|
|
12855
12947
|
init_logger();
|
|
12856
12948
|
|
|
12857
12949
|
// src/lib/db/entities/operations.ts
|
|
12858
|
-
var
|
|
12950
|
+
var import_watermelondb20 = require("@nozbe/watermelondb");
|
|
12859
12951
|
|
|
12860
12952
|
// src/lib/db/memoryVault/types.ts
|
|
12861
12953
|
var MEMORY_KINDS = [
|
|
@@ -12948,7 +13040,7 @@ async function upsertEntitiesInWrite(ctx, entities) {
|
|
|
12948
13040
|
const unique = Array.from(kindByName.keys());
|
|
12949
13041
|
const out = /* @__PURE__ */ new Map();
|
|
12950
13042
|
if (unique.length === 0) return { entities: out, operations: [], kindBackfills: [] };
|
|
12951
|
-
const existing = await ctx.entityCollection.query(
|
|
13043
|
+
const existing = await ctx.entityCollection.query(import_watermelondb20.Q.where("canonical_name", import_watermelondb20.Q.oneOf(unique))).fetch();
|
|
12952
13044
|
const existingNames = new Set(existing.map((e) => e.canonicalName));
|
|
12953
13045
|
const kindBackfills = existing.filter((e) => {
|
|
12954
13046
|
const incoming = kindByName.get(e.canonicalName);
|
|
@@ -12978,7 +13070,7 @@ function prepareKindBackfills(backfills) {
|
|
|
12978
13070
|
}
|
|
12979
13071
|
async function findVaultRowInWrite(ctx, memoryId) {
|
|
12980
13072
|
try {
|
|
12981
|
-
const rows = await ctx.database.get("memory_vault").query(
|
|
13073
|
+
const rows = await ctx.database.get("memory_vault").query(import_watermelondb20.Q.where("id", memoryId)).fetch();
|
|
12982
13074
|
return rows[0] ?? null;
|
|
12983
13075
|
} catch {
|
|
12984
13076
|
return null;
|
|
@@ -13080,7 +13172,7 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
13080
13172
|
return;
|
|
13081
13173
|
}
|
|
13082
13174
|
if (entities.length === 0) return;
|
|
13083
|
-
const existingLinks = await ctx.memoryEntityCollection.query(
|
|
13175
|
+
const existingLinks = await ctx.memoryEntityCollection.query(import_watermelondb20.Q.where("memory_id", memoryId)).fetch();
|
|
13084
13176
|
const existingEntityIds = new Set(existingLinks.map((l) => String(l.entityId)));
|
|
13085
13177
|
const toCreate = entities.filter((e) => !existingEntityIds.has(e.uniqueId));
|
|
13086
13178
|
const keptIds = entities.map((e) => e.uniqueId);
|
|
@@ -13116,7 +13208,7 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
13116
13208
|
}
|
|
13117
13209
|
async function resolveEntitiesByIds(ctx, entityIds) {
|
|
13118
13210
|
if (entityIds.length === 0) return [];
|
|
13119
|
-
const rows = await ctx.entityCollection.query(
|
|
13211
|
+
const rows = await ctx.entityCollection.query(import_watermelondb20.Q.where("id", import_watermelondb20.Q.oneOf(Array.from(entityIds)))).fetch();
|
|
13120
13212
|
return rows.map(entityToStored);
|
|
13121
13213
|
}
|
|
13122
13214
|
function autoLinkBlocked(row) {
|
|
@@ -13152,7 +13244,7 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
13152
13244
|
kindBackfills
|
|
13153
13245
|
} = await upsertEntitiesInWrite(ctx, normalized);
|
|
13154
13246
|
entities = Array.from(byName.values());
|
|
13155
|
-
const existingLinks = await ctx.memoryEntityCollection.query(
|
|
13247
|
+
const existingLinks = await ctx.memoryEntityCollection.query(import_watermelondb20.Q.where("memory_id", memoryId)).fetch();
|
|
13156
13248
|
const keep = new Set(entities.map((e) => e.uniqueId));
|
|
13157
13249
|
const existingEntityIds = new Set(existingLinks.map((l) => String(l.entityId)));
|
|
13158
13250
|
const toCreate = entities.filter((e) => !existingEntityIds.has(e.uniqueId));
|
|
@@ -13188,17 +13280,17 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
13188
13280
|
async function findOrphanedEntities(ctx, memoryId, toDestroy) {
|
|
13189
13281
|
const candidateIds = [...new Set(toDestroy.map((l) => String(l.entityId)))];
|
|
13190
13282
|
if (candidateIds.length === 0) return [];
|
|
13191
|
-
const links = await ctx.memoryEntityCollection.query(
|
|
13283
|
+
const links = await ctx.memoryEntityCollection.query(import_watermelondb20.Q.where("entity_id", import_watermelondb20.Q.oneOf(candidateIds))).fetch();
|
|
13192
13284
|
const stillLinked = new Set(
|
|
13193
13285
|
links.filter((l) => String(l.memoryId) !== memoryId).map((l) => String(l.entityId))
|
|
13194
13286
|
);
|
|
13195
13287
|
const orphanIds = candidateIds.filter((id) => !stillLinked.has(id));
|
|
13196
13288
|
if (orphanIds.length === 0) return [];
|
|
13197
|
-
return await ctx.entityCollection.query(
|
|
13289
|
+
return await ctx.entityCollection.query(import_watermelondb20.Q.where("id", import_watermelondb20.Q.oneOf(orphanIds))).fetch();
|
|
13198
13290
|
}
|
|
13199
13291
|
async function unlinkMemoryEntitiesOp(ctx, memoryIds) {
|
|
13200
13292
|
if (memoryIds.length === 0) return;
|
|
13201
|
-
const links = await ctx.memoryEntityCollection.query(
|
|
13293
|
+
const links = await ctx.memoryEntityCollection.query(import_watermelondb20.Q.where("memory_id", import_watermelondb20.Q.oneOf(Array.from(memoryIds)))).fetch();
|
|
13202
13294
|
if (links.length === 0) return;
|
|
13203
13295
|
await ctx.database.write(async () => {
|
|
13204
13296
|
await assertCanWrite(ctx);
|
|
@@ -13207,7 +13299,7 @@ async function unlinkMemoryEntitiesOp(ctx, memoryIds) {
|
|
|
13207
13299
|
}
|
|
13208
13300
|
async function unlinkAllMemoryEntitiesForUserOp(ctx, userId) {
|
|
13209
13301
|
if (!userId) return;
|
|
13210
|
-
const links = await ctx.memoryEntityCollection.query(
|
|
13302
|
+
const links = await ctx.memoryEntityCollection.query(import_watermelondb20.Q.where("user_id", userId)).fetch();
|
|
13211
13303
|
if (links.length === 0) return;
|
|
13212
13304
|
await ctx.database.write(async () => {
|
|
13213
13305
|
await assertCanWrite(ctx);
|
|
@@ -13217,15 +13309,15 @@ async function unlinkAllMemoryEntitiesForUserOp(ctx, userId) {
|
|
|
13217
13309
|
async function getMemoriesByEntityNamesOp(ctx, entityNames) {
|
|
13218
13310
|
const unique = Array.from(new Set(entityNames.map(normalizeEntityName).filter((n) => n.length > 0)));
|
|
13219
13311
|
if (unique.length === 0) return /* @__PURE__ */ new Map();
|
|
13220
|
-
const entityRows = await ctx.entityCollection.query(
|
|
13312
|
+
const entityRows = await ctx.entityCollection.query(import_watermelondb20.Q.where("canonical_name", import_watermelondb20.Q.oneOf(unique))).fetch();
|
|
13221
13313
|
if (entityRows.length === 0) return /* @__PURE__ */ new Map();
|
|
13222
13314
|
const entityIdToName = new Map(entityRows.map((e) => [e.id, e.canonicalName]));
|
|
13223
|
-
const linkConditions = [
|
|
13315
|
+
const linkConditions = [import_watermelondb20.Q.where("entity_id", import_watermelondb20.Q.oneOf(entityRows.map((e) => e.id)))];
|
|
13224
13316
|
if (ctx.userId !== void 0) {
|
|
13225
13317
|
if (ctx.allowUnscopedRows) {
|
|
13226
|
-
linkConditions.push(
|
|
13318
|
+
linkConditions.push(import_watermelondb20.Q.or(import_watermelondb20.Q.where("user_id", ctx.userId), import_watermelondb20.Q.where("user_id", null)));
|
|
13227
13319
|
} else {
|
|
13228
|
-
linkConditions.push(
|
|
13320
|
+
linkConditions.push(import_watermelondb20.Q.where("user_id", ctx.userId));
|
|
13229
13321
|
}
|
|
13230
13322
|
}
|
|
13231
13323
|
const links = await ctx.memoryEntityCollection.query(...linkConditions).fetch();
|
|
@@ -13246,18 +13338,18 @@ async function getMemoriesByEntityNamesOp(ctx, entityNames) {
|
|
|
13246
13338
|
async function getEntitiesByMemoryIdsOp(ctx, memoryIds) {
|
|
13247
13339
|
const unique = Array.from(new Set(memoryIds.filter((id) => id.length > 0)));
|
|
13248
13340
|
if (unique.length === 0) return /* @__PURE__ */ new Map();
|
|
13249
|
-
const linkConditions = [
|
|
13341
|
+
const linkConditions = [import_watermelondb20.Q.where("memory_id", import_watermelondb20.Q.oneOf(unique))];
|
|
13250
13342
|
if (ctx.userId !== void 0) {
|
|
13251
13343
|
if (ctx.allowUnscopedRows) {
|
|
13252
|
-
linkConditions.push(
|
|
13344
|
+
linkConditions.push(import_watermelondb20.Q.or(import_watermelondb20.Q.where("user_id", ctx.userId), import_watermelondb20.Q.where("user_id", null)));
|
|
13253
13345
|
} else {
|
|
13254
|
-
linkConditions.push(
|
|
13346
|
+
linkConditions.push(import_watermelondb20.Q.where("user_id", ctx.userId));
|
|
13255
13347
|
}
|
|
13256
13348
|
}
|
|
13257
13349
|
const links = await ctx.memoryEntityCollection.query(...linkConditions).fetch();
|
|
13258
13350
|
if (links.length === 0) return /* @__PURE__ */ new Map();
|
|
13259
13351
|
const entityIds = Array.from(new Set(links.map((l) => String(l.entityId))));
|
|
13260
|
-
const entityRows = await ctx.entityCollection.query(
|
|
13352
|
+
const entityRows = await ctx.entityCollection.query(import_watermelondb20.Q.where("id", import_watermelondb20.Q.oneOf(entityIds))).fetch();
|
|
13261
13353
|
const entityIdToName = new Map(entityRows.map((e) => [e.id, e.canonicalName]));
|
|
13262
13354
|
const out = /* @__PURE__ */ new Map();
|
|
13263
13355
|
for (const link of links) {
|
|
@@ -13322,11 +13414,11 @@ var NON_PRIVATE_VISIBILITIES = ["public"];
|
|
|
13322
13414
|
function visibilityConditions(requested) {
|
|
13323
13415
|
if (!requested?.length) return [];
|
|
13324
13416
|
if (!requested.includes("private")) {
|
|
13325
|
-
return [
|
|
13417
|
+
return [import_watermelondb21.Q.where("visibility", import_watermelondb21.Q.oneOf([...requested]))];
|
|
13326
13418
|
}
|
|
13327
13419
|
const excluded = NON_PRIVATE_VISIBILITIES.filter((v) => !requested.includes(v));
|
|
13328
13420
|
if (excluded.length === 0) return [];
|
|
13329
|
-
return [
|
|
13421
|
+
return [import_watermelondb21.Q.or(import_watermelondb21.Q.where("visibility", null), import_watermelondb21.Q.where("visibility", import_watermelondb21.Q.notIn(excluded)))];
|
|
13330
13422
|
}
|
|
13331
13423
|
function isKinded(record2) {
|
|
13332
13424
|
return record2.kind !== null && record2.kind !== void 0;
|
|
@@ -13367,17 +13459,17 @@ function levelConditions(requested) {
|
|
|
13367
13459
|
const published = ["shared", "public"];
|
|
13368
13460
|
const wantsMatching = requested.includes("matching");
|
|
13369
13461
|
const wantsPrivate = requested.includes("private");
|
|
13370
|
-
const unresolved =
|
|
13371
|
-
const byLevel =
|
|
13372
|
-
if (wantsMatching && wantsPrivate) return [
|
|
13462
|
+
const unresolved = import_watermelondb21.Q.or(import_watermelondb21.Q.where("level", null), import_watermelondb21.Q.where("level", import_watermelondb21.Q.notIn([...MEMORY_LEVELS])));
|
|
13463
|
+
const byLevel = import_watermelondb21.Q.where("level", import_watermelondb21.Q.oneOf([...requested]));
|
|
13464
|
+
if (wantsMatching && wantsPrivate) return [import_watermelondb21.Q.or(byLevel, unresolved)];
|
|
13373
13465
|
if (wantsMatching) {
|
|
13374
|
-
return [
|
|
13466
|
+
return [import_watermelondb21.Q.or(byLevel, import_watermelondb21.Q.and(unresolved, import_watermelondb21.Q.where("scope", import_watermelondb21.Q.oneOf(published))))];
|
|
13375
13467
|
}
|
|
13376
13468
|
if (wantsPrivate) {
|
|
13377
13469
|
return [
|
|
13378
|
-
|
|
13470
|
+
import_watermelondb21.Q.or(
|
|
13379
13471
|
byLevel,
|
|
13380
|
-
|
|
13472
|
+
import_watermelondb21.Q.and(unresolved, import_watermelondb21.Q.or(import_watermelondb21.Q.where("scope", null), import_watermelondb21.Q.where("scope", import_watermelondb21.Q.notIn(published))))
|
|
13381
13473
|
)
|
|
13382
13474
|
];
|
|
13383
13475
|
}
|
|
@@ -13388,13 +13480,13 @@ function isOwnedByCtxUser(ctx, record2) {
|
|
|
13388
13480
|
}
|
|
13389
13481
|
function baseVaultConditions(ctx, options) {
|
|
13390
13482
|
return [
|
|
13391
|
-
...options?.memoryIds !== void 0 ? [
|
|
13392
|
-
...options?.includeDeleted ? [] : [
|
|
13393
|
-
...options?.includeArchived ? [] : [
|
|
13394
|
-
...options?.includeQuarantined ? [] : [
|
|
13395
|
-
...options?.includeSuperseded ? [] : [
|
|
13396
|
-
...ctx.userId !== void 0 ? [
|
|
13397
|
-
...options?.since ? [
|
|
13483
|
+
...options?.memoryIds !== void 0 ? [import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(options.memoryIds))] : [],
|
|
13484
|
+
...options?.includeDeleted ? [] : [import_watermelondb21.Q.where("is_deleted", false)],
|
|
13485
|
+
...options?.includeArchived ? [] : [import_watermelondb21.Q.where("archived_at", import_watermelondb21.Q.eq(null))],
|
|
13486
|
+
...options?.includeQuarantined ? [] : [import_watermelondb21.Q.where("trust_tier", import_watermelondb21.Q.notEq("quarantined"))],
|
|
13487
|
+
...options?.includeSuperseded ? [] : [import_watermelondb21.Q.where("superseded_by", null)],
|
|
13488
|
+
...ctx.userId !== void 0 ? [import_watermelondb21.Q.where("user_id", ctx.userId)] : [],
|
|
13489
|
+
...options?.since ? [import_watermelondb21.Q.where("updated_at", import_watermelondb21.Q.gt(options.since.getTime()))] : []
|
|
13398
13490
|
];
|
|
13399
13491
|
}
|
|
13400
13492
|
var KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
|
|
@@ -13564,11 +13656,11 @@ async function createSupersedingMemoryOp(ctx, opts, targetId) {
|
|
|
13564
13656
|
async function getMemoriesByEventTimeOp(ctx, windowStart, windowEnd) {
|
|
13565
13657
|
const records = await ctx.vaultMemoryCollection.query(
|
|
13566
13658
|
...baseVaultConditions(ctx),
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13659
|
+
import_watermelondb21.Q.where("event_time_start", import_watermelondb21.Q.notEq(null)),
|
|
13660
|
+
import_watermelondb21.Q.where("event_time_start", import_watermelondb21.Q.lte(windowEnd)),
|
|
13661
|
+
import_watermelondb21.Q.or(
|
|
13662
|
+
import_watermelondb21.Q.where("event_time_start", import_watermelondb21.Q.gte(windowStart)),
|
|
13663
|
+
import_watermelondb21.Q.where("event_time_kind", import_watermelondb21.Q.oneOf(["range", "ongoing"]))
|
|
13572
13664
|
)
|
|
13573
13665
|
).fetch();
|
|
13574
13666
|
const out = [];
|
|
@@ -13724,18 +13816,18 @@ async function getAllVaultMemoriesOp(ctx, options) {
|
|
|
13724
13816
|
function vaultListConditions(ctx, options) {
|
|
13725
13817
|
return [
|
|
13726
13818
|
...baseVaultConditions(ctx, options),
|
|
13727
|
-
...options?.scopes?.length ? [
|
|
13819
|
+
...options?.scopes?.length ? [import_watermelondb21.Q.where("scope", import_watermelondb21.Q.oneOf(options.scopes))] : [],
|
|
13728
13820
|
...visibilityConditions(options?.visibility),
|
|
13729
13821
|
...levelConditions(options?.levels),
|
|
13730
|
-
...options?.kinds?.length ? [
|
|
13731
|
-
...options?.folderId !== void 0 ? [
|
|
13732
|
-
...options?.factTypes?.length ? [
|
|
13822
|
+
...options?.kinds?.length ? [import_watermelondb21.Q.where("kind", import_watermelondb21.Q.oneOf(options.kinds))] : [],
|
|
13823
|
+
...options?.folderId !== void 0 ? [import_watermelondb21.Q.where("folder_id", options.folderId)] : [],
|
|
13824
|
+
...options?.factTypes?.length ? [import_watermelondb21.Q.where("fact_type", import_watermelondb21.Q.oneOf(options.factTypes))] : []
|
|
13733
13825
|
];
|
|
13734
13826
|
}
|
|
13735
13827
|
function vaultListOrder(options) {
|
|
13736
13828
|
return [
|
|
13737
|
-
|
|
13738
|
-
...options?.limit !== null && options?.limit !== void 0 && options.limit > 0 ? [
|
|
13829
|
+
import_watermelondb21.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb21.Q.desc),
|
|
13830
|
+
...options?.limit !== null && options?.limit !== void 0 && options.limit > 0 ? [import_watermelondb21.Q.take(options.limit)] : []
|
|
13739
13831
|
];
|
|
13740
13832
|
}
|
|
13741
13833
|
async function getAllVaultMemoryRowsOp(ctx) {
|
|
@@ -13774,10 +13866,10 @@ function vaultMemoryRawToRankable(raw) {
|
|
|
13774
13866
|
async function getVaultRankingProjectionsOp(ctx, options) {
|
|
13775
13867
|
const conditions = [
|
|
13776
13868
|
...baseVaultConditions(ctx, options),
|
|
13777
|
-
...options?.scopes?.length ? [
|
|
13778
|
-
...options?.folderId !== void 0 ? [
|
|
13779
|
-
|
|
13780
|
-
...options?.limit !== null && options?.limit !== void 0 && options.limit > 0 ? [
|
|
13869
|
+
...options?.scopes?.length ? [import_watermelondb21.Q.where("scope", import_watermelondb21.Q.oneOf(options.scopes))] : [],
|
|
13870
|
+
...options?.folderId !== void 0 ? [import_watermelondb21.Q.where("folder_id", options.folderId)] : [],
|
|
13871
|
+
import_watermelondb21.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb21.Q.desc),
|
|
13872
|
+
...options?.limit !== null && options?.limit !== void 0 && options.limit > 0 ? [import_watermelondb21.Q.take(options.limit)] : []
|
|
13781
13873
|
];
|
|
13782
13874
|
const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
|
|
13783
13875
|
return results.map(vaultMemoryRawToRankable);
|
|
@@ -13828,7 +13920,7 @@ async function getVaultCandidateKeysOp(ctx, options) {
|
|
|
13828
13920
|
args.push(...options.factTypes);
|
|
13829
13921
|
}
|
|
13830
13922
|
const sql = `select "id", "scope", "folder_id", "embedding_model", "updated_at" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
13831
|
-
const rows = await ctx.vaultMemoryCollection.query(
|
|
13923
|
+
const rows = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
13832
13924
|
return rows.map(mapRaw);
|
|
13833
13925
|
} catch (err) {
|
|
13834
13926
|
getLogger().debug(
|
|
@@ -13839,9 +13931,9 @@ async function getVaultCandidateKeysOp(ctx, options) {
|
|
|
13839
13931
|
memoryIds: options?.memoryIds,
|
|
13840
13932
|
...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
|
|
13841
13933
|
}),
|
|
13842
|
-
...options?.scopes?.length ? [
|
|
13843
|
-
...options?.folderId !== void 0 ? [
|
|
13844
|
-
...options?.factTypes?.length ? [
|
|
13934
|
+
...options?.scopes?.length ? [import_watermelondb21.Q.where("scope", import_watermelondb21.Q.oneOf(options.scopes))] : [],
|
|
13935
|
+
...options?.folderId !== void 0 ? [import_watermelondb21.Q.where("folder_id", options.folderId)] : [],
|
|
13936
|
+
...options?.factTypes?.length ? [import_watermelondb21.Q.where("fact_type", import_watermelondb21.Q.oneOf(options.factTypes))] : []
|
|
13845
13937
|
];
|
|
13846
13938
|
const rows = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
|
|
13847
13939
|
return rows.map(mapRaw);
|
|
@@ -13859,7 +13951,7 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids, options) {
|
|
|
13859
13951
|
...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
|
|
13860
13952
|
});
|
|
13861
13953
|
const sql = `select "id", "embedding", "embedding_model" from "memory_vault" where ${base.sql} and "id" in (${ids.map(() => "?").join(",")})`;
|
|
13862
|
-
const rows = await ctx.vaultMemoryCollection.query(
|
|
13954
|
+
const rows = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.unsafeSqlQuery(sql, [...base.args, ...ids])).unsafeFetchRaw();
|
|
13863
13955
|
return rows.map(mapRaw);
|
|
13864
13956
|
} catch (err) {
|
|
13865
13957
|
getLogger().debug(
|
|
@@ -13871,7 +13963,7 @@ async function getVaultEmbeddingsByIdsOp(ctx, ids, options) {
|
|
|
13871
13963
|
includeArchived: options.includeArchived
|
|
13872
13964
|
}
|
|
13873
13965
|
}),
|
|
13874
|
-
|
|
13966
|
+
import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(ids))
|
|
13875
13967
|
).unsafeFetchRaw();
|
|
13876
13968
|
return rows.map(mapRaw);
|
|
13877
13969
|
}
|
|
@@ -13882,7 +13974,7 @@ async function getVaultMemoriesByIdsOp(ctx, ids, options) {
|
|
|
13882
13974
|
...baseVaultConditions(ctx, {
|
|
13883
13975
|
...options?.includeArchived !== void 0 && { includeArchived: options.includeArchived }
|
|
13884
13976
|
}),
|
|
13885
|
-
|
|
13977
|
+
import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(ids))
|
|
13886
13978
|
];
|
|
13887
13979
|
const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
|
|
13888
13980
|
return mapInBatches(
|
|
@@ -13907,7 +13999,7 @@ async function countActiveVaultMemoriesOp(ctx) {
|
|
|
13907
13999
|
}
|
|
13908
14000
|
async function getActiveVaultMemoryIdsOp(ctx, ids) {
|
|
13909
14001
|
if (ids.length === 0) return /* @__PURE__ */ new Set();
|
|
13910
|
-
const rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx),
|
|
14002
|
+
const rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(ids))).unsafeFetchRaw();
|
|
13911
14003
|
return new Set(rows.map((r) => r.id));
|
|
13912
14004
|
}
|
|
13913
14005
|
async function updateVaultMemoryOp(ctx, id, opts) {
|
|
@@ -14056,7 +14148,7 @@ async function setMemoryEntitiesOp(ctx, memoryId, entities) {
|
|
|
14056
14148
|
() => linkMemoryEntitiesOp(entityCtx, memoryId, entities, { topicsSource: "user" })
|
|
14057
14149
|
) : [];
|
|
14058
14150
|
const keep = new Set(linked.map((e) => e.uniqueId));
|
|
14059
|
-
const existing = await entityCtx.memoryEntityCollection.query(
|
|
14151
|
+
const existing = await entityCtx.memoryEntityCollection.query(import_watermelondb21.Q.where("memory_id", memoryId)).fetch();
|
|
14060
14152
|
const staleLinks = existing.filter((l) => !keep.has(String(l.entityId)));
|
|
14061
14153
|
if (staleLinks.length === 0 && entities.length > 0) return;
|
|
14062
14154
|
const topicsWrite = await resolveMemoryTopicsWrite(
|
|
@@ -14197,9 +14289,9 @@ async function supersedeVaultMemoryOp(ctx, id, supersededById) {
|
|
|
14197
14289
|
}
|
|
14198
14290
|
async function getUnfiledVaultMemoriesOp(ctx) {
|
|
14199
14291
|
const conditions = [
|
|
14200
|
-
|
|
14292
|
+
import_watermelondb21.Q.where("folder_id", null),
|
|
14201
14293
|
...baseVaultConditions(ctx),
|
|
14202
|
-
|
|
14294
|
+
import_watermelondb21.Q.sortBy("created_at", import_watermelondb21.Q.desc)
|
|
14203
14295
|
];
|
|
14204
14296
|
const results = await ctx.vaultMemoryCollection.query(...conditions).fetch();
|
|
14205
14297
|
return mapInBatches(
|
|
@@ -14213,7 +14305,7 @@ async function linkedEntityNamesByMemory(entityCtx, memoryIds) {
|
|
|
14213
14305
|
const entityIdByMemory = /* @__PURE__ */ new Map();
|
|
14214
14306
|
const allEntityIds = /* @__PURE__ */ new Set();
|
|
14215
14307
|
for (let i = 0; i < memoryIds.length; i += CHUNK) {
|
|
14216
|
-
const links = await entityCtx.memoryEntityCollection.query(
|
|
14308
|
+
const links = await entityCtx.memoryEntityCollection.query(import_watermelondb21.Q.where("memory_id", import_watermelondb21.Q.oneOf(memoryIds.slice(i, i + CHUNK)))).unsafeFetchRaw();
|
|
14217
14309
|
for (const link of links) {
|
|
14218
14310
|
const memoryId = String(link.memory_id);
|
|
14219
14311
|
const entityId = String(link.entity_id);
|
|
@@ -14229,7 +14321,7 @@ async function linkedEntityNamesByMemory(entityCtx, memoryIds) {
|
|
|
14229
14321
|
const entityIds = Array.from(allEntityIds);
|
|
14230
14322
|
const nameById = /* @__PURE__ */ new Map();
|
|
14231
14323
|
for (let i = 0; i < entityIds.length; i += CHUNK) {
|
|
14232
|
-
const entities = await entityCtx.entityCollection.query(
|
|
14324
|
+
const entities = await entityCtx.entityCollection.query(import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(entityIds.slice(i, i + CHUNK)))).unsafeFetchRaw();
|
|
14233
14325
|
for (const e of entities) {
|
|
14234
14326
|
if (typeof e.canonical_name === "string") nameById.set(String(e.id), e.canonical_name);
|
|
14235
14327
|
}
|
|
@@ -14258,7 +14350,7 @@ async function getMemoriesNeedingTopicExtractionOp(ctx, options) {
|
|
|
14258
14350
|
if (!entityCtx) {
|
|
14259
14351
|
throw new Error("getMemoriesNeedingTopicExtractionOp requires ctx.entityCtx");
|
|
14260
14352
|
}
|
|
14261
|
-
const conditions = [...baseVaultConditions(ctx),
|
|
14353
|
+
const conditions = [...baseVaultConditions(ctx), import_watermelondb21.Q.sortBy("created_at", import_watermelondb21.Q.desc)];
|
|
14262
14354
|
const rows = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
|
|
14263
14355
|
const linkedNames = await linkedEntityNamesByMemory(
|
|
14264
14356
|
entityCtx,
|
|
@@ -14414,10 +14506,10 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
|
|
|
14414
14506
|
}
|
|
14415
14507
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) continue;
|
|
14416
14508
|
if (parseTopics(record2.topics) !== null) continue;
|
|
14417
|
-
const links = await entityCtx.memoryEntityCollection.query(
|
|
14509
|
+
const links = await entityCtx.memoryEntityCollection.query(import_watermelondb21.Q.where("memory_id", id)).unsafeFetchRaw();
|
|
14418
14510
|
const entityIds = links.map((l) => String(l.entity_id));
|
|
14419
14511
|
if (entityIds.length === 0) continue;
|
|
14420
|
-
const entities = await entityCtx.entityCollection.query(
|
|
14512
|
+
const entities = await entityCtx.entityCollection.query(import_watermelondb21.Q.where("id", import_watermelondb21.Q.oneOf(entityIds))).fetch();
|
|
14421
14513
|
if (entities.length === 0) continue;
|
|
14422
14514
|
const source = record2.topicsUserManaged ? "user" : "auto";
|
|
14423
14515
|
const write = await resolveMemoryTopicsWrite(entityCtx, id, entities, [], source);
|
|
@@ -14433,7 +14525,7 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
|
|
|
14433
14525
|
}
|
|
14434
14526
|
async function deleteAllVaultMemoriesForUserOp(ctx, userId) {
|
|
14435
14527
|
if (ctx.userId !== void 0 && ctx.userId !== userId) return 0;
|
|
14436
|
-
const records = await ctx.vaultMemoryCollection.query(
|
|
14528
|
+
const records = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.where("user_id", userId), import_watermelondb21.Q.where("is_deleted", false)).fetch();
|
|
14437
14529
|
if (records.length === 0) return 0;
|
|
14438
14530
|
await ctx.database.write(async () => {
|
|
14439
14531
|
await assertCanWrite2(ctx);
|
|
@@ -14470,7 +14562,7 @@ async function getDecayCandidatesRawOp(ctx) {
|
|
|
14470
14562
|
assertVaultScopeForSweep(ctx);
|
|
14471
14563
|
const results = await ctx.vaultMemoryCollection.query(
|
|
14472
14564
|
...baseVaultConditions(ctx, { includeArchived: true, includeQuarantined: true }),
|
|
14473
|
-
|
|
14565
|
+
import_watermelondb21.Q.where("kind", null)
|
|
14474
14566
|
).unsafeFetchRaw();
|
|
14475
14567
|
return results.map((raw) => ({
|
|
14476
14568
|
uniqueId: raw.id,
|
|
@@ -14600,11 +14692,11 @@ async function findQuarantinedDuplicateOp(ctx, content, sourceIds2, where) {
|
|
|
14600
14692
|
const wanted = [...new Set(sourceIds2)].sort().join("\0");
|
|
14601
14693
|
const target = normalizeForDedupe(content);
|
|
14602
14694
|
const rows = await ctx.vaultMemoryCollection.query(
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
|
|
14607
|
-
...ctx.userId !== void 0 ? [
|
|
14695
|
+
import_watermelondb21.Q.where("trust_tier", "quarantined"),
|
|
14696
|
+
import_watermelondb21.Q.where("is_deleted", false),
|
|
14697
|
+
import_watermelondb21.Q.where("scope", where.scope),
|
|
14698
|
+
import_watermelondb21.Q.where("folder_id", where.folderId),
|
|
14699
|
+
...ctx.userId !== void 0 ? [import_watermelondb21.Q.where("user_id", ctx.userId)] : []
|
|
14608
14700
|
).unsafeFetchRaw();
|
|
14609
14701
|
for (const raw of rows) {
|
|
14610
14702
|
let ids;
|
|
@@ -15101,7 +15193,7 @@ var WalletPoller = class {
|
|
|
15101
15193
|
};
|
|
15102
15194
|
|
|
15103
15195
|
// src/lib/db/vaultFolders/operations.ts
|
|
15104
|
-
var
|
|
15196
|
+
var import_watermelondb22 = require("@nozbe/watermelondb");
|
|
15105
15197
|
function folderToStored(folder) {
|
|
15106
15198
|
return {
|
|
15107
15199
|
uniqueId: folder.id,
|
|
@@ -15126,7 +15218,7 @@ async function createVaultFolderOp(ctx, opts) {
|
|
|
15126
15218
|
return folderToStored(created);
|
|
15127
15219
|
}
|
|
15128
15220
|
async function getAllVaultFoldersOp(ctx) {
|
|
15129
|
-
const results = await ctx.vaultFolderCollection.query(
|
|
15221
|
+
const results = await ctx.vaultFolderCollection.query(import_watermelondb22.Q.where("is_deleted", false), import_watermelondb22.Q.sortBy("created_at", import_watermelondb22.Q.desc)).fetch();
|
|
15130
15222
|
return results.map(folderToStored);
|
|
15131
15223
|
}
|
|
15132
15224
|
async function updateVaultFolderOp(ctx, id, opts) {
|
|
@@ -15135,7 +15227,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
|
|
|
15135
15227
|
if (record2.isDeleted) return null;
|
|
15136
15228
|
const scopeChanged = opts.scope !== void 0 && opts.scope !== record2.scope;
|
|
15137
15229
|
const updated = await ctx.database.write(async () => {
|
|
15138
|
-
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(
|
|
15230
|
+
const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb22.Q.where("folder_id", id), import_watermelondb22.Q.where("is_deleted", false)).fetch() : [];
|
|
15139
15231
|
const updates = [];
|
|
15140
15232
|
updates.push(
|
|
15141
15233
|
record2.prepareUpdate((r) => {
|
|
@@ -15164,7 +15256,7 @@ async function deleteVaultFolderOp(ctx, id) {
|
|
|
15164
15256
|
const record2 = await ctx.vaultFolderCollection.find(id);
|
|
15165
15257
|
if (record2.isDeleted) return false;
|
|
15166
15258
|
await ctx.database.write(async () => {
|
|
15167
|
-
const memories = await ctx.vaultMemoryCollection.query(
|
|
15259
|
+
const memories = await ctx.vaultMemoryCollection.query(import_watermelondb22.Q.where("folder_id", id), import_watermelondb22.Q.where("is_deleted", false)).fetch();
|
|
15168
15260
|
const preparedMemories = memories.map(
|
|
15169
15261
|
(memory) => memory.prepareUpdate((r) => {
|
|
15170
15262
|
r._setRaw("folder_id", null);
|
|
@@ -15235,7 +15327,7 @@ async function updateVaultFolderContextOp(ctx, id, context) {
|
|
|
15235
15327
|
}
|
|
15236
15328
|
}
|
|
15237
15329
|
async function getVaultFolderMemoryCountOp(ctx, folderId) {
|
|
15238
|
-
return await ctx.vaultMemoryCollection.query(
|
|
15330
|
+
return await ctx.vaultMemoryCollection.query(import_watermelondb22.Q.where("folder_id", folderId), import_watermelondb22.Q.where("is_deleted", false)).fetchCount();
|
|
15239
15331
|
}
|
|
15240
15332
|
|
|
15241
15333
|
// src/lib/db/vaultFolders/defaults.ts
|
|
@@ -15281,7 +15373,7 @@ async function _ensureDefaultFoldersImpl(ctx) {
|
|
|
15281
15373
|
init_logger();
|
|
15282
15374
|
|
|
15283
15375
|
// src/lib/memory/autoExtract.ts
|
|
15284
|
-
var
|
|
15376
|
+
var import_watermelondb23 = require("@nozbe/watermelondb");
|
|
15285
15377
|
init_logger();
|
|
15286
15378
|
init_redactor();
|
|
15287
15379
|
|
|
@@ -18008,7 +18100,7 @@ async function assertMergeTargetGoneOrThrow(ctx, targetId) {
|
|
|
18008
18100
|
// src/lib/memory/autoExtract.ts
|
|
18009
18101
|
async function isMemoryTopicsUserManaged(ctx, memoryId) {
|
|
18010
18102
|
try {
|
|
18011
|
-
const rows = await ctx.database.get(VaultMemory.table).query(
|
|
18103
|
+
const rows = await ctx.database.get(VaultMemory.table).query(import_watermelondb23.Q.where("id", memoryId)).fetch();
|
|
18012
18104
|
return rows[0]?.topicsUserManaged === true;
|
|
18013
18105
|
} catch {
|
|
18014
18106
|
return true;
|
|
@@ -20570,7 +20662,7 @@ function parseAnswer(body, base, parseSchema) {
|
|
|
20570
20662
|
}
|
|
20571
20663
|
|
|
20572
20664
|
// src/lib/memory/store/local.ts
|
|
20573
|
-
var
|
|
20665
|
+
var import_watermelondb24 = require("@nozbe/watermelondb");
|
|
20574
20666
|
init_logger();
|
|
20575
20667
|
|
|
20576
20668
|
// src/lib/memory/topicExtract.ts
|
|
@@ -20853,8 +20945,8 @@ function createLocalMemoryStore(options) {
|
|
|
20853
20945
|
writeOptions?.signal?.throwIfAborted();
|
|
20854
20946
|
};
|
|
20855
20947
|
const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
|
|
20856
|
-
const ownedBy = userId !== void 0 ? [
|
|
20857
|
-
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [
|
|
20948
|
+
const ownedBy = userId !== void 0 ? [import_watermelondb24.Q.where("user_id", userId)] : [];
|
|
20949
|
+
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [import_watermelondb24.Q.or(import_watermelondb24.Q.where("user_id", userId), import_watermelondb24.Q.where("user_id", null))] : [import_watermelondb24.Q.where("user_id", userId)];
|
|
20858
20950
|
const watchedColumns = [
|
|
20859
20951
|
"content",
|
|
20860
20952
|
"scope",
|
|
@@ -20899,7 +20991,7 @@ function createLocalMemoryStore(options) {
|
|
|
20899
20991
|
list: (listOptions) => getAllVaultMemoriesOp(vaultCtx, listOptions),
|
|
20900
20992
|
get: (id) => getVaultMemoryOp(vaultCtx, id),
|
|
20901
20993
|
listArchived: async () => {
|
|
20902
|
-
const ids = await vaultCtx.vaultMemoryCollection.query(
|
|
20994
|
+
const ids = await vaultCtx.vaultMemoryCollection.query(import_watermelondb24.Q.where("is_deleted", false), import_watermelondb24.Q.where("archived_at", import_watermelondb24.Q.notEq(null)), ...ownedBy).fetchIds();
|
|
20903
20995
|
if (ids.length === 0) return [];
|
|
20904
20996
|
const rows = await getAllVaultMemoriesOp(vaultCtx, { memoryIds: ids, includeArchived: true });
|
|
20905
20997
|
return rows.sort((a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0));
|
|
@@ -20915,7 +21007,7 @@ function createLocalMemoryStore(options) {
|
|
|
20915
21007
|
set.add(String(link.memory_id));
|
|
20916
21008
|
members.set(entityId, set);
|
|
20917
21009
|
}
|
|
20918
|
-
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(
|
|
21010
|
+
const entities = userId === void 0 ? await entityCtx.entityCollection.query().unsafeFetchRaw() : members.size ? await entityCtx.entityCollection.query(import_watermelondb24.Q.where("id", import_watermelondb24.Q.oneOf([...members.keys()]))).unsafeFetchRaw() : [];
|
|
20919
21011
|
const byName = /* @__PURE__ */ new Map();
|
|
20920
21012
|
for (const entity of entities) {
|
|
20921
21013
|
const name = String(entity.canonical_name);
|
|
@@ -20965,7 +21057,7 @@ function createLocalMemoryStore(options) {
|
|
|
20965
21057
|
setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
|
|
20966
21058
|
addTopics: (memoryId, topics, writeOptions) => database.write(async (writer) => {
|
|
20967
21059
|
await assertWrite(writeOptions);
|
|
20968
|
-
const owned = await vaultCtx.vaultMemoryCollection.query(
|
|
21060
|
+
const owned = await vaultCtx.vaultMemoryCollection.query(import_watermelondb24.Q.where("id", memoryId), import_watermelondb24.Q.where("is_deleted", false), ...ownedBy).fetchCount();
|
|
20969
21061
|
return owned > 0 ? writer.callWriter(
|
|
20970
21062
|
() => linkMemoryEntitiesOp(
|
|
20971
21063
|
{
|
|
@@ -21037,7 +21129,7 @@ function createLocalMemoryStore(options) {
|
|
|
21037
21129
|
else onChange();
|
|
21038
21130
|
};
|
|
21039
21131
|
};
|
|
21040
|
-
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(
|
|
21132
|
+
const memories = subscribeOptions?.includeDeleted ? vaultCtx.vaultMemoryCollection.query(...ownedBy).observe() : vaultCtx.vaultMemoryCollection.query(import_watermelondb24.Q.where("is_deleted", false), ...ownedBy).observeWithColumns(
|
|
21041
21133
|
subscribeOptions?.embeddings ? [...watchedColumns, "embedding", "embedding_model"] : watchedColumns
|
|
21042
21134
|
);
|
|
21043
21135
|
const subscriptions = [memories.subscribe(afterFirst())];
|
|
@@ -24104,7 +24196,7 @@ async function assembleMemoryContext(options) {
|
|
|
24104
24196
|
}
|
|
24105
24197
|
|
|
24106
24198
|
// src/lib/memory/durableExtraction.ts
|
|
24107
|
-
var
|
|
24199
|
+
var import_watermelondb25 = require("@nozbe/watermelondb");
|
|
24108
24200
|
var MAX_JOBS_PER_PASS = 3;
|
|
24109
24201
|
var MAX_ATTEMPTS = 3;
|
|
24110
24202
|
var MAX_FAILED_SESSIONS = 3;
|
|
@@ -24275,7 +24367,7 @@ function createDurableAutoExtractor(options) {
|
|
|
24275
24367
|
const source = options.messageSource?.(conversationId);
|
|
24276
24368
|
if (source)
|
|
24277
24369
|
return await fromSource(source.status(conversationId)) === "ready" && (await loadFromSource(source, conversationId, ids)).every(Boolean);
|
|
24278
|
-
return await storage.conversationsCollection.query(
|
|
24370
|
+
return await storage.conversationsCollection.query(import_watermelondb25.Q.where("conversation_id", conversationId), import_watermelondb25.Q.where("is_deleted", false)).fetchCount() > 0 && await storage.messagesCollection.query(import_watermelondb25.Q.where("conversation_id", conversationId), import_watermelondb25.Q.where("id", import_watermelondb25.Q.oneOf(ids))).fetchCount() === ids.length;
|
|
24279
24371
|
}
|
|
24280
24372
|
function schedule(delay) {
|
|
24281
24373
|
if (disposed) return;
|
|
@@ -24449,7 +24541,7 @@ function createDurableAutoExtractor(options) {
|
|
|
24449
24541
|
let sourceWaiting = false;
|
|
24450
24542
|
try {
|
|
24451
24543
|
await writes;
|
|
24452
|
-
const pending = await jobs.query(
|
|
24544
|
+
const pending = await jobs.query(import_watermelondb25.Q.where("owner_key", owner), import_watermelondb25.Q.where("message_ids", import_watermelondb25.Q.notEq("[]"))).fetch();
|
|
24453
24545
|
storeFailures = 0;
|
|
24454
24546
|
let processed = 0;
|
|
24455
24547
|
for (const job of pending) {
|
|
@@ -24481,7 +24573,7 @@ function createDurableAutoExtractor(options) {
|
|
|
24481
24573
|
let ids = [];
|
|
24482
24574
|
let loaded = [];
|
|
24483
24575
|
try {
|
|
24484
|
-
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(
|
|
24576
|
+
const present = source ? sourceStatus === "ready" : await storage.conversationsCollection.query(import_watermelondb25.Q.where("conversation_id", conversationId), import_watermelondb25.Q.where("is_deleted", false)).fetchCount() > 0;
|
|
24485
24577
|
if (!present) {
|
|
24486
24578
|
await database.write(() => job.destroyPermanently());
|
|
24487
24579
|
continue;
|
|
@@ -24649,7 +24741,7 @@ function createDurableAutoExtractor(options) {
|
|
|
24649
24741
|
const scope = currentScope();
|
|
24650
24742
|
writes = writes.then(
|
|
24651
24743
|
() => database.write(async () => {
|
|
24652
|
-
const existing = await jobs.query(
|
|
24744
|
+
const existing = await jobs.query(import_watermelondb25.Q.where("owner_key", owner), import_watermelondb25.Q.where("conversation_id", conversationId)).fetch();
|
|
24653
24745
|
const job = existing.find(
|
|
24654
24746
|
(candidate) => candidate._getRaw("scope") === scope && (candidate._getRaw("folder_id") ?? null) === folderId
|
|
24655
24747
|
);
|
|
@@ -24662,8 +24754,8 @@ function createDurableAutoExtractor(options) {
|
|
|
24662
24754
|
if (watermarks.length) {
|
|
24663
24755
|
const misplaced = new Set(
|
|
24664
24756
|
await storage.messagesCollection.query(
|
|
24665
|
-
|
|
24666
|
-
|
|
24757
|
+
import_watermelondb25.Q.where("id", import_watermelondb25.Q.oneOf(watermarks)),
|
|
24758
|
+
import_watermelondb25.Q.where("conversation_id", import_watermelondb25.Q.notEq(conversationId))
|
|
24667
24759
|
).fetchIds()
|
|
24668
24760
|
);
|
|
24669
24761
|
for (const prior of existing)
|
|
@@ -24673,7 +24765,7 @@ function createDurableAutoExtractor(options) {
|
|
|
24673
24765
|
r._setRaw("watermark_seq", null);
|
|
24674
24766
|
});
|
|
24675
24767
|
}
|
|
24676
|
-
const rows = fromSourceConversation ? [] : await storage.messagesCollection.query(
|
|
24768
|
+
const rows = fromSourceConversation ? [] : await storage.messagesCollection.query(import_watermelondb25.Q.where("id", import_watermelondb25.Q.oneOf(ids))).fetch();
|
|
24677
24769
|
const foreignRows = new Set(
|
|
24678
24770
|
rows.filter((row) => row._getRaw("conversation_id") !== conversationId).map((row) => row.id)
|
|
24679
24771
|
);
|
|
@@ -27734,7 +27826,7 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
27734
27826
|
}
|
|
27735
27827
|
|
|
27736
27828
|
// src/lib/db/media/operations.ts
|
|
27737
|
-
var
|
|
27829
|
+
var import_watermelondb26 = require("@nozbe/watermelondb");
|
|
27738
27830
|
|
|
27739
27831
|
// src/lib/storage/opfs.ts
|
|
27740
27832
|
function isOPFSSupported() {
|
|
@@ -27926,7 +28018,7 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
27926
28018
|
})
|
|
27927
28019
|
);
|
|
27928
28020
|
});
|
|
27929
|
-
const results = await mediaCollection.query(
|
|
28021
|
+
const results = await mediaCollection.query(import_watermelondb26.Q.where("media_id", import_watermelondb26.Q.oneOf(mediaIds))).fetch();
|
|
27930
28022
|
return Promise.all(
|
|
27931
28023
|
results.map(
|
|
27932
28024
|
(m) => mediaToStored(m, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
@@ -27936,7 +28028,7 @@ async function createMediaBatchOp(ctx, optionsArray) {
|
|
|
27936
28028
|
var IMAGE_VIDEO_MIMES = VIDEO_EXTENSIONS.map((ext) => `image/${ext}`);
|
|
27937
28029
|
async function deleteMediaByConversationOp(ctx, conversationId) {
|
|
27938
28030
|
const mediaCollection = ctx.database.get("media");
|
|
27939
|
-
const results = await mediaCollection.query(
|
|
28031
|
+
const results = await mediaCollection.query(import_watermelondb26.Q.where("conversation_id", conversationId), import_watermelondb26.Q.where("is_deleted", false)).fetch();
|
|
27940
28032
|
if (results.length === 0) {
|
|
27941
28033
|
return 0;
|
|
27942
28034
|
}
|
|
@@ -28193,6 +28285,8 @@ function useChatStorage(options) {
|
|
|
28193
28285
|
embeddedWalletSigner
|
|
28194
28286
|
]
|
|
28195
28287
|
);
|
|
28288
|
+
const storageCtxRef = (0, import_react5.useRef)(storageCtx);
|
|
28289
|
+
storageCtxRef.current = storageCtx;
|
|
28196
28290
|
const vaultMemoryCollection = (0, import_react5.useMemo)(
|
|
28197
28291
|
() => database.get("memory_vault"),
|
|
28198
28292
|
[database]
|
|
@@ -28296,24 +28390,12 @@ function useChatStorage(options) {
|
|
|
28296
28390
|
refreshQueueStatus();
|
|
28297
28391
|
return queueManager.onQueueChange(walletAddress, refreshQueueStatus);
|
|
28298
28392
|
}, [walletAddress, refreshQueueStatus]);
|
|
28299
|
-
(0, import_react5.useEffect)(() => {
|
|
28300
|
-
if (!walletAddress || !enableQueue || !autoFlushOnKeyAvailable || !signMessage) return;
|
|
28301
|
-
return onKeyAvailable(walletAddress, () => {
|
|
28302
|
-
flushQueue().catch((err) => {
|
|
28303
|
-
getLogger().warn("[useChatStorage] Auto-flush failed:", err);
|
|
28304
|
-
});
|
|
28305
|
-
});
|
|
28306
|
-
}, [walletAddress, enableQueue, autoFlushOnKeyAvailable, signMessage, flushQueue]);
|
|
28307
28393
|
(0, import_react5.useEffect)(() => {
|
|
28308
28394
|
if (!getWalletAddress || walletAddress) return;
|
|
28309
28395
|
const poller = new WalletPoller();
|
|
28310
28396
|
return poller.startPolling(getWalletAddress, () => {
|
|
28311
28397
|
});
|
|
28312
28398
|
}, [getWalletAddress, walletAddress]);
|
|
28313
|
-
const isEncryptionReady = (0, import_react5.useCallback)(() => {
|
|
28314
|
-
if (!walletAddress || !signMessage) return true;
|
|
28315
|
-
return hasEncryptionKey(walletAddress);
|
|
28316
|
-
}, [walletAddress, signMessage]);
|
|
28317
28399
|
const pendingOpsRef = (0, import_react5.useRef)([]);
|
|
28318
28400
|
const syntheticConvIdsRef = (0, import_react5.useRef)(/* @__PURE__ */ new Set());
|
|
28319
28401
|
(0, import_react5.useEffect)(() => {
|
|
@@ -28326,34 +28408,49 @@ function useChatStorage(options) {
|
|
|
28326
28408
|
pendingOpsRef.current = [];
|
|
28327
28409
|
refreshQueueStatus();
|
|
28328
28410
|
}, [walletAddress, enableQueue, refreshQueueStatus]);
|
|
28411
|
+
(0, import_react5.useEffect)(() => {
|
|
28412
|
+
if (!walletAddress || !enableQueue || !autoFlushOnKeyAvailable || !signMessage) return;
|
|
28413
|
+
return onKeyAvailable(walletAddress, () => {
|
|
28414
|
+
flushQueue().catch((err) => {
|
|
28415
|
+
getLogger().warn("[useChatStorage] Auto-flush failed:", err);
|
|
28416
|
+
});
|
|
28417
|
+
});
|
|
28418
|
+
}, [walletAddress, enableQueue, autoFlushOnKeyAvailable, signMessage, flushQueue]);
|
|
28329
28419
|
const writeOrQueue = (0, import_react5.useCallback)(
|
|
28330
28420
|
async (opType, payload, directWrite, makeSynthetic, dependencies = []) => {
|
|
28331
|
-
|
|
28332
|
-
|
|
28421
|
+
const currentStorageCtx = storageCtx.walletAddress ? storageCtx : storageCtxRef.current;
|
|
28422
|
+
const currentWalletAddress = currentStorageCtx.walletAddress;
|
|
28423
|
+
if (enableQueue && signMessage && !currentWalletAddress && getWalletAddress) {
|
|
28424
|
+
pendingOpsRef.current.push({ type: opType, payload, dependencies });
|
|
28425
|
+
return { result: makeSynthetic(), queued: true };
|
|
28426
|
+
}
|
|
28427
|
+
if (!currentWalletAddress || !currentStorageCtx.signMessage || hasEncryptionKey(currentWalletAddress)) {
|
|
28428
|
+
const result2 = await directWrite(currentStorageCtx);
|
|
28333
28429
|
return { result: result2, queued: false };
|
|
28334
28430
|
}
|
|
28335
28431
|
if (!enableQueue) {
|
|
28336
|
-
const result2 = await directWrite();
|
|
28432
|
+
const result2 = await directWrite(currentStorageCtx);
|
|
28337
28433
|
return { result: result2, queued: false };
|
|
28338
28434
|
}
|
|
28339
|
-
if (
|
|
28340
|
-
|
|
28341
|
-
|
|
28342
|
-
|
|
28343
|
-
|
|
28344
|
-
|
|
28435
|
+
if (currentWalletAddress) {
|
|
28436
|
+
const queueId = queueManager.queueOperation(
|
|
28437
|
+
currentWalletAddress,
|
|
28438
|
+
opType,
|
|
28439
|
+
payload,
|
|
28440
|
+
dependencies
|
|
28441
|
+
);
|
|
28345
28442
|
if (queueId === null) {
|
|
28346
28443
|
getLogger().warn("[useChatStorage] Queue full, falling back to direct write");
|
|
28347
|
-
const result2 = await directWrite();
|
|
28444
|
+
const result2 = await directWrite(currentStorageCtx);
|
|
28348
28445
|
return { result: result2, queued: false };
|
|
28349
28446
|
}
|
|
28350
|
-
|
|
28447
|
+
setQueueStatus(queueManager.getStatus(currentWalletAddress));
|
|
28351
28448
|
return { result: makeSynthetic(), queued: true, queueId };
|
|
28352
28449
|
}
|
|
28353
|
-
const result = await directWrite();
|
|
28450
|
+
const result = await directWrite(currentStorageCtx);
|
|
28354
28451
|
return { result, queued: false };
|
|
28355
28452
|
},
|
|
28356
|
-
[
|
|
28453
|
+
[storageCtx, enableQueue, signMessage, getWalletAddress]
|
|
28357
28454
|
);
|
|
28358
28455
|
const embedMessageAsync = (0, import_react5.useCallback)(
|
|
28359
28456
|
async (message, mask = maskForEmbedding) => {
|
|
@@ -28627,7 +28724,7 @@ function useChatStorage(options) {
|
|
|
28627
28724
|
const { result, queued } = await writeOrQueue(
|
|
28628
28725
|
"createConversation",
|
|
28629
28726
|
conversationOpts,
|
|
28630
|
-
() => createConversationOp(
|
|
28727
|
+
(ctx) => createConversationOp(ctx, conversationOpts, defaultConversationTitle),
|
|
28631
28728
|
() => makeSyntheticStoredConversation(conversationOpts, defaultConversationTitle)
|
|
28632
28729
|
);
|
|
28633
28730
|
if (queued) {
|
|
@@ -28636,7 +28733,7 @@ function useChatStorage(options) {
|
|
|
28636
28733
|
setCurrentConversationId(result.conversationId);
|
|
28637
28734
|
return result;
|
|
28638
28735
|
},
|
|
28639
|
-
[
|
|
28736
|
+
[defaultConversationTitle, writeOrQueue]
|
|
28640
28737
|
);
|
|
28641
28738
|
const getConversation = (0, import_react5.useCallback)(
|
|
28642
28739
|
async (id) => {
|
|
@@ -28652,24 +28749,24 @@ function useChatStorage(options) {
|
|
|
28652
28749
|
const { result } = await writeOrQueue(
|
|
28653
28750
|
"updateConversationTitle",
|
|
28654
28751
|
{ conversationId: id, title },
|
|
28655
|
-
() => updateConversationTitleOp(
|
|
28752
|
+
(ctx) => updateConversationTitleOp(ctx, id, title),
|
|
28656
28753
|
() => true
|
|
28657
28754
|
);
|
|
28658
28755
|
return result;
|
|
28659
28756
|
},
|
|
28660
|
-
[
|
|
28757
|
+
[writeOrQueue]
|
|
28661
28758
|
);
|
|
28662
28759
|
const updateConversationPinned = (0, import_react5.useCallback)(
|
|
28663
28760
|
async (id, pinned) => {
|
|
28664
28761
|
const { result } = await writeOrQueue(
|
|
28665
28762
|
"updateConversationPinned",
|
|
28666
28763
|
{ conversationId: id, pinned },
|
|
28667
|
-
() => updateConversationPinnedOp(
|
|
28764
|
+
(ctx) => updateConversationPinnedOp(ctx, id, pinned),
|
|
28668
28765
|
() => true
|
|
28669
28766
|
);
|
|
28670
28767
|
return result;
|
|
28671
28768
|
},
|
|
28672
|
-
[
|
|
28769
|
+
[writeOrQueue]
|
|
28673
28770
|
);
|
|
28674
28771
|
const deleteConversation = (0, import_react5.useCallback)(
|
|
28675
28772
|
async (id) => {
|
|
@@ -28887,7 +28984,7 @@ function useChatStorage(options) {
|
|
|
28887
28984
|
const { result } = await writeOrQueue(
|
|
28888
28985
|
"createMessage",
|
|
28889
28986
|
rowOpts,
|
|
28890
|
-
() => upsertMessageOp(
|
|
28987
|
+
(currentStorageCtx) => upsertMessageOp(currentStorageCtx, rowOpts),
|
|
28891
28988
|
() => makeSyntheticStoredMessage(rowOpts),
|
|
28892
28989
|
ctx.userMessageQueueId ? [ctx.userMessageQueueId] : []
|
|
28893
28990
|
);
|
|
@@ -29349,7 +29446,7 @@ function useChatStorage(options) {
|
|
|
29349
29446
|
const userMsgResult = await writeOrQueue(
|
|
29350
29447
|
"createMessage",
|
|
29351
29448
|
userMsgOpts,
|
|
29352
|
-
() => createMessageOp(
|
|
29449
|
+
(ctx) => createMessageOp(ctx, userMsgOpts),
|
|
29353
29450
|
() => makeSyntheticStoredMessage(userMsgOpts)
|
|
29354
29451
|
);
|
|
29355
29452
|
storedUserMessage = userMsgResult.result;
|
|
@@ -29698,7 +29795,7 @@ function useChatStorage(options) {
|
|
|
29698
29795
|
const assistantMsgResult = await writeOrQueue(
|
|
29699
29796
|
"createMessage",
|
|
29700
29797
|
assistantMsgOpts,
|
|
29701
|
-
() => createMessageOp(
|
|
29798
|
+
(ctx) => createMessageOp(ctx, assistantMsgOpts),
|
|
29702
29799
|
() => makeSyntheticStoredMessage(assistantMsgOpts),
|
|
29703
29800
|
userMsgQueueId ? [userMsgQueueId] : []
|
|
29704
29801
|
);
|
|
@@ -29730,7 +29827,7 @@ function useChatStorage(options) {
|
|
|
29730
29827
|
const toolResultsWrite = await writeOrQueue(
|
|
29731
29828
|
"createMessage",
|
|
29732
29829
|
toolResultsOpts,
|
|
29733
|
-
() => createMessageOp(
|
|
29830
|
+
(ctx) => createMessageOp(ctx, toolResultsOpts),
|
|
29734
29831
|
() => makeSyntheticStoredMessage(toolResultsOpts),
|
|
29735
29832
|
assistantMsgQueueId ? [assistantMsgQueueId] : []
|
|
29736
29833
|
);
|
|
@@ -29773,7 +29870,6 @@ function useChatStorage(options) {
|
|
|
29773
29870
|
walletAddress,
|
|
29774
29871
|
signMessage,
|
|
29775
29872
|
embeddedWalletSigner,
|
|
29776
|
-
isEncryptionReady,
|
|
29777
29873
|
enableQueue,
|
|
29778
29874
|
getWalletAddress,
|
|
29779
29875
|
refreshQueueStatus,
|