@anuma/sdk 11.3.4 → 11.4.0
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 +308 -13
- package/dist/expo/index.d.mts +67 -2
- package/dist/expo/index.d.ts +67 -2
- package/dist/expo/index.mjs +297 -13
- package/dist/index.cjs +281 -5
- package/dist/index.d.mts +69 -2
- package/dist/index.d.ts +69 -2
- package/dist/index.mjs +270 -5
- package/dist/react/index.cjs +310 -26
- package/dist/react/index.d.mts +67 -2
- package/dist/react/index.d.ts +67 -2
- package/dist/react/index.mjs +299 -26
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -1526,6 +1526,7 @@ __export(index_exports, {
|
|
|
1526
1526
|
addConversationMemoriesOp: () => addConversationMemoriesOp,
|
|
1527
1527
|
anumaLastReadSortKey: () => anumaLastReadSortKey,
|
|
1528
1528
|
anumaTurnContent: () => anumaTurnContent,
|
|
1529
|
+
appFileId: () => appFileId,
|
|
1529
1530
|
appFileToStored: () => appFileToStored,
|
|
1530
1531
|
archiveVaultMemoryOp: () => archiveVaultMemoryOp,
|
|
1531
1532
|
assembleMemoryContext: () => assembleMemoryContext,
|
|
@@ -1566,6 +1567,7 @@ __export(index_exports, {
|
|
|
1566
1567
|
conversationMemoryToStored: () => conversationMemoryToStored,
|
|
1567
1568
|
cosineInt8: () => cosineInt8,
|
|
1568
1569
|
countUnreadAnumaTurns: () => countUnreadAnumaTurns,
|
|
1570
|
+
createAppFileIndex: () => createAppFileIndex,
|
|
1569
1571
|
createAutoExtractor: () => createAutoExtractor,
|
|
1570
1572
|
createChunkVectorCache: () => createChunkVectorCache,
|
|
1571
1573
|
createCryptoPricePreProcessor: () => createCryptoPricePreProcessor,
|
|
@@ -1613,6 +1615,7 @@ __export(index_exports, {
|
|
|
1613
1615
|
defaultServerToolsFilter: () => defaultServerToolsFilter,
|
|
1614
1616
|
deleteAllAppFilesOp: () => deleteAllAppFilesOp,
|
|
1615
1617
|
deleteAllVaultMemoriesForUserOp: () => deleteAllVaultMemoriesForUserOp,
|
|
1618
|
+
deleteAppFile: () => deleteAppFile,
|
|
1616
1619
|
deleteAppFileOp: () => deleteAppFileOp,
|
|
1617
1620
|
deleteEncryptedFile: () => deleteEncryptedFile,
|
|
1618
1621
|
deleteMediaByConversationOp: () => deleteMediaByConversationOp,
|
|
@@ -1620,6 +1623,7 @@ __export(index_exports, {
|
|
|
1620
1623
|
deleteMediaOp: () => deleteMediaOp,
|
|
1621
1624
|
deleteMessageOp: () => deleteMessageOp,
|
|
1622
1625
|
deleteProjectOp: () => deleteProjectOp,
|
|
1626
|
+
deleteSavedTool: () => deleteSavedTool,
|
|
1623
1627
|
deleteSavedToolOp: () => deleteSavedToolOp,
|
|
1624
1628
|
deleteVaultFolderOp: () => deleteVaultFolderOp,
|
|
1625
1629
|
deleteVaultMemoryOp: () => deleteVaultMemoryOp,
|
|
@@ -1666,6 +1670,7 @@ __export(index_exports, {
|
|
|
1666
1670
|
getAllVaultMemoryContentsOp: () => getAllVaultMemoryContentsOp,
|
|
1667
1671
|
getAndClearNotionPendingMessage: () => getAndClearNotionPendingMessage,
|
|
1668
1672
|
getAndClearNotionReturnUrl: () => getAndClearNotionReturnUrl,
|
|
1673
|
+
getAppFile: () => getAppFile,
|
|
1669
1674
|
getAppFileMapOp: () => getAppFileMapOp,
|
|
1670
1675
|
getAppFileOp: () => getAppFileOp,
|
|
1671
1676
|
getAppFilesOp: () => getAppFilesOp,
|
|
@@ -1744,6 +1749,9 @@ __export(index_exports, {
|
|
|
1744
1749
|
isSupportedMediaType: () => isSupportedMediaType,
|
|
1745
1750
|
linkMemoryEntitiesOp: () => linkMemoryEntitiesOp,
|
|
1746
1751
|
listActiveStreams: () => listActiveStreams,
|
|
1752
|
+
listAppFiles: () => listAppFiles,
|
|
1753
|
+
listEveryAppFile: () => listEveryAppFile,
|
|
1754
|
+
loadSavedTools: () => loadSavedTools,
|
|
1747
1755
|
loadSettings: () => loadSettings,
|
|
1748
1756
|
localChatBackend: () => localChatBackend,
|
|
1749
1757
|
markAnumaRead: () => markAnumaRead,
|
|
@@ -1795,6 +1803,8 @@ __export(index_exports, {
|
|
|
1795
1803
|
resumeStream: () => resumeStream,
|
|
1796
1804
|
retain: () => retain,
|
|
1797
1805
|
revokeNotionAccess: () => revokeNotionAccess,
|
|
1806
|
+
saveAppFile: () => saveAppFile,
|
|
1807
|
+
saveSavedTool: () => saveSavedTool,
|
|
1798
1808
|
saveSetting: () => saveSetting,
|
|
1799
1809
|
savedToolToStored: () => savedToolToStored,
|
|
1800
1810
|
scoreProfileSalience: () => scoreProfileSalience,
|
|
@@ -1807,6 +1817,7 @@ __export(index_exports, {
|
|
|
1807
1817
|
searchMediaOp: () => searchMediaOp,
|
|
1808
1818
|
searchMessagesOp: () => searchMessagesOp,
|
|
1809
1819
|
searchVaultMemories: () => searchVaultMemories,
|
|
1820
|
+
seedAppFilesToVault: () => seedAppFilesToVault,
|
|
1810
1821
|
seedEncryptionKeys: () => seedEncryptionKeys,
|
|
1811
1822
|
selectServerToolsForPrompt: () => selectServerToolsForPrompt,
|
|
1812
1823
|
serializeJsx: () => serializeJsx,
|
|
@@ -8135,9 +8146,9 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
|
|
|
8135
8146
|
};
|
|
8136
8147
|
const request = async (path, init = {}, signal) => {
|
|
8137
8148
|
const controller = new AbortController();
|
|
8138
|
-
let
|
|
8149
|
+
let timedOut2 = false;
|
|
8139
8150
|
const timer = setTimeout(() => {
|
|
8140
|
-
|
|
8151
|
+
timedOut2 = true;
|
|
8141
8152
|
controller.abort();
|
|
8142
8153
|
}, timeoutMs);
|
|
8143
8154
|
const forwardAbort = () => controller.abort(signal?.reason);
|
|
@@ -8203,7 +8214,7 @@ function createNearbyRequest(options, apiPath = "/api/private-memories") {
|
|
|
8203
8214
|
if (response.status === 204) return null;
|
|
8204
8215
|
return await response.json();
|
|
8205
8216
|
} catch (error) {
|
|
8206
|
-
if (
|
|
8217
|
+
if (timedOut2) throw new RemoteMemoryError("Nearby request timed out", 408, "timeout");
|
|
8207
8218
|
throw error;
|
|
8208
8219
|
} finally {
|
|
8209
8220
|
clearTimeout(timer);
|
|
@@ -14251,6 +14262,168 @@ function countUnreadAnumaTurns(messages, lastReadSortKey) {
|
|
|
14251
14262
|
return turns.size;
|
|
14252
14263
|
}
|
|
14253
14264
|
|
|
14265
|
+
// src/utils/paths.ts
|
|
14266
|
+
function normalizePath(p) {
|
|
14267
|
+
return p.replace(/^\/+/, "").replace(/\/\/+/g, "/").split("/").reduce((acc, seg) => {
|
|
14268
|
+
if (seg === "..") acc.pop();
|
|
14269
|
+
else if (seg !== ".") acc.push(seg);
|
|
14270
|
+
return acc;
|
|
14271
|
+
}, []).join("/");
|
|
14272
|
+
}
|
|
14273
|
+
|
|
14274
|
+
// src/lib/chatStore/appFiles.ts
|
|
14275
|
+
var maxSaveAttempts = 3;
|
|
14276
|
+
async function appFileId(store, conversationId, path) {
|
|
14277
|
+
if (!store.sealedId) throw new Error("App file ids need a chat store that seals ids");
|
|
14278
|
+
return store.sealedId(`app_file\0${conversationId}\0${normalizePath(path)}`);
|
|
14279
|
+
}
|
|
14280
|
+
async function putLatest(store, target, next, signal) {
|
|
14281
|
+
for (let attempt = 1; ; attempt++) {
|
|
14282
|
+
const current = await store.get(target.kind, target.id, signal);
|
|
14283
|
+
if (next.isDeleted && (!current || current.record.isDeleted)) return current;
|
|
14284
|
+
const now = Date.now();
|
|
14285
|
+
try {
|
|
14286
|
+
const [saved] = await store.putMany(
|
|
14287
|
+
[
|
|
14288
|
+
{
|
|
14289
|
+
record: {
|
|
14290
|
+
...target,
|
|
14291
|
+
sortKey: 0,
|
|
14292
|
+
createdAt: current?.record.createdAt ?? now,
|
|
14293
|
+
updatedAt: Math.max(now, (current?.record.updatedAt ?? 0) + 1),
|
|
14294
|
+
isDeleted: next.isDeleted,
|
|
14295
|
+
data: next.isDeleted ? {} : next.data
|
|
14296
|
+
},
|
|
14297
|
+
expectedVersion: current?.version ?? 0
|
|
14298
|
+
}
|
|
14299
|
+
],
|
|
14300
|
+
signal
|
|
14301
|
+
);
|
|
14302
|
+
return saved;
|
|
14303
|
+
} catch (error) {
|
|
14304
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSaveAttempts)
|
|
14305
|
+
throw error;
|
|
14306
|
+
}
|
|
14307
|
+
}
|
|
14308
|
+
}
|
|
14309
|
+
async function listAll(store, kind, conversationId, signal) {
|
|
14310
|
+
const out = [];
|
|
14311
|
+
let cursor;
|
|
14312
|
+
do {
|
|
14313
|
+
const page = await store.list({ kind, conversationId, limit: 100, cursor, signal });
|
|
14314
|
+
out.push(...page.items.filter((item) => !item.record.isDeleted));
|
|
14315
|
+
cursor = page.nextCursor;
|
|
14316
|
+
} while (cursor);
|
|
14317
|
+
return out;
|
|
14318
|
+
}
|
|
14319
|
+
function toAppFile(snapshot) {
|
|
14320
|
+
const { path, content } = snapshot.record.data;
|
|
14321
|
+
if (typeof path !== "string" || typeof content !== "string") return null;
|
|
14322
|
+
return {
|
|
14323
|
+
conversationId: snapshot.record.conversationId,
|
|
14324
|
+
path,
|
|
14325
|
+
content,
|
|
14326
|
+
version: snapshot.version,
|
|
14327
|
+
createdAt: snapshot.record.createdAt,
|
|
14328
|
+
updatedAt: snapshot.record.updatedAt
|
|
14329
|
+
};
|
|
14330
|
+
}
|
|
14331
|
+
function toSavedTool(snapshot) {
|
|
14332
|
+
const d = snapshot.record.data;
|
|
14333
|
+
if (typeof d.name !== "string" || typeof d.displayName !== "string" || typeof d.description !== "string" || typeof d.parameters !== "string" || typeof d.html !== "string" || d.conversationId !== null && typeof d.conversationId !== "string")
|
|
14334
|
+
return null;
|
|
14335
|
+
return {
|
|
14336
|
+
id: snapshot.record.id,
|
|
14337
|
+
name: d.name,
|
|
14338
|
+
displayName: d.displayName,
|
|
14339
|
+
description: d.description,
|
|
14340
|
+
parameters: d.parameters,
|
|
14341
|
+
html: d.html,
|
|
14342
|
+
conversationId: d.conversationId,
|
|
14343
|
+
version: snapshot.version,
|
|
14344
|
+
createdAt: snapshot.record.createdAt,
|
|
14345
|
+
updatedAt: snapshot.record.updatedAt
|
|
14346
|
+
};
|
|
14347
|
+
}
|
|
14348
|
+
async function listAppFiles(store, conversationId, signal) {
|
|
14349
|
+
const items = await listAll(store, "app_file", conversationId, signal);
|
|
14350
|
+
return items.map(toAppFile).filter((file) => file !== null);
|
|
14351
|
+
}
|
|
14352
|
+
function createAppFileIndex(store) {
|
|
14353
|
+
const latest = /* @__PURE__ */ new Map();
|
|
14354
|
+
let cursor;
|
|
14355
|
+
let queue = Promise.resolve();
|
|
14356
|
+
const catchUp = async (signal) => {
|
|
14357
|
+
for (; ; ) {
|
|
14358
|
+
const page = await store.changes(cursor, { kinds: ["app_file"], limit: 200, signal });
|
|
14359
|
+
for (const item of page.items) latest.set(item.record.id, item);
|
|
14360
|
+
cursor = page.nextCursor ?? page.changesCursor;
|
|
14361
|
+
if (!page.nextCursor) break;
|
|
14362
|
+
}
|
|
14363
|
+
return [...latest.values()].filter((item) => !item.record.isDeleted).map(toAppFile).filter((file) => file !== null);
|
|
14364
|
+
};
|
|
14365
|
+
return {
|
|
14366
|
+
list(signal) {
|
|
14367
|
+
const next = queue.then(() => catchUp(signal));
|
|
14368
|
+
queue = next.catch(() => void 0);
|
|
14369
|
+
return next;
|
|
14370
|
+
}
|
|
14371
|
+
};
|
|
14372
|
+
}
|
|
14373
|
+
function listEveryAppFile(store, signal) {
|
|
14374
|
+
return createAppFileIndex(store).list(signal);
|
|
14375
|
+
}
|
|
14376
|
+
async function getAppFile(store, conversationId, path, signal) {
|
|
14377
|
+
const snapshot = await store.get(
|
|
14378
|
+
"app_file",
|
|
14379
|
+
await appFileId(store, conversationId, path),
|
|
14380
|
+
signal
|
|
14381
|
+
);
|
|
14382
|
+
return snapshot && !snapshot.record.isDeleted ? toAppFile(snapshot) : null;
|
|
14383
|
+
}
|
|
14384
|
+
async function saveAppFile(store, file, signal) {
|
|
14385
|
+
const saved = await putLatest(
|
|
14386
|
+
store,
|
|
14387
|
+
{
|
|
14388
|
+
kind: "app_file",
|
|
14389
|
+
id: await appFileId(store, file.conversationId, file.path),
|
|
14390
|
+
conversationId: file.conversationId
|
|
14391
|
+
},
|
|
14392
|
+
{ data: { path: normalizePath(file.path), content: file.content }, isDeleted: false },
|
|
14393
|
+
signal
|
|
14394
|
+
);
|
|
14395
|
+
return toAppFile(saved);
|
|
14396
|
+
}
|
|
14397
|
+
async function deleteAppFile(store, conversationId, path, signal) {
|
|
14398
|
+
await putLatest(
|
|
14399
|
+
store,
|
|
14400
|
+
{ kind: "app_file", id: await appFileId(store, conversationId, path), conversationId },
|
|
14401
|
+
{ data: {}, isDeleted: true },
|
|
14402
|
+
signal
|
|
14403
|
+
);
|
|
14404
|
+
}
|
|
14405
|
+
async function loadSavedTools(store, signal) {
|
|
14406
|
+
const items = await listAll(store, "saved_tool", void 0, signal);
|
|
14407
|
+
return items.map(toSavedTool).filter((tool) => tool !== null);
|
|
14408
|
+
}
|
|
14409
|
+
async function saveSavedTool(store, id2, tool, signal) {
|
|
14410
|
+
const saved = await putLatest(
|
|
14411
|
+
store,
|
|
14412
|
+
{ kind: "saved_tool", id: id2, conversationId: "" },
|
|
14413
|
+
{ data: { ...tool }, isDeleted: false },
|
|
14414
|
+
signal
|
|
14415
|
+
);
|
|
14416
|
+
return toSavedTool(saved);
|
|
14417
|
+
}
|
|
14418
|
+
async function deleteSavedTool(store, id2, signal) {
|
|
14419
|
+
await putLatest(
|
|
14420
|
+
store,
|
|
14421
|
+
{ kind: "saved_tool", id: id2, conversationId: "" },
|
|
14422
|
+
{ data: {}, isDeleted: true },
|
|
14423
|
+
signal
|
|
14424
|
+
);
|
|
14425
|
+
}
|
|
14426
|
+
|
|
14254
14427
|
// src/lib/db/chat/summaryOperations.ts
|
|
14255
14428
|
var import_watermelondb6 = require("@nozbe/watermelondb");
|
|
14256
14429
|
init_logger();
|
|
@@ -14454,7 +14627,16 @@ function batches(records) {
|
|
|
14454
14627
|
}
|
|
14455
14628
|
|
|
14456
14629
|
// src/lib/chatStore/remote.ts
|
|
14457
|
-
var kinds = /* @__PURE__ */ new Set([
|
|
14630
|
+
var kinds = /* @__PURE__ */ new Set([
|
|
14631
|
+
"conversation",
|
|
14632
|
+
"message",
|
|
14633
|
+
"summary",
|
|
14634
|
+
"project",
|
|
14635
|
+
"memory_links",
|
|
14636
|
+
"setting",
|
|
14637
|
+
"app_file",
|
|
14638
|
+
"saved_tool"
|
|
14639
|
+
]);
|
|
14458
14640
|
var cipherPattern = /^enc:v\d+:(?:[0-9a-f]{2}){28,}$/i;
|
|
14459
14641
|
var maxPayload = 2 * 1024 * 1024;
|
|
14460
14642
|
var storedDims2 = 1536;
|
|
@@ -14514,7 +14696,7 @@ function validRecord(value) {
|
|
|
14514
14696
|
return root ? value.conversationId === "" : id(value.conversationId);
|
|
14515
14697
|
}
|
|
14516
14698
|
function rootKind(kind) {
|
|
14517
|
-
return kind === "conversation" || kind === "project" || kind === "setting";
|
|
14699
|
+
return kind === "conversation" || kind === "project" || kind === "setting" || kind === "saved_tool";
|
|
14518
14700
|
}
|
|
14519
14701
|
function embeddings(write) {
|
|
14520
14702
|
if (write.embeddings === void 0) return true;
|
|
@@ -14595,6 +14777,7 @@ async function createRemoteChatStore(options) {
|
|
|
14595
14777
|
const keyId = options.keyId;
|
|
14596
14778
|
const encrypt = options.encrypt;
|
|
14597
14779
|
const decrypt = options.decrypt;
|
|
14780
|
+
const hashTopic = options.hashTopic;
|
|
14598
14781
|
const nearby = createNearbyRequest({ ...options }, "/api/private-chats");
|
|
14599
14782
|
const request = async (...args) => {
|
|
14600
14783
|
try {
|
|
@@ -14645,7 +14828,9 @@ async function createRemoteChatStore(options) {
|
|
|
14645
14828
|
JSON.stringify({ schema: 1, account_id: accountId, key_id: keyId, record: record3 })
|
|
14646
14829
|
);
|
|
14647
14830
|
signal?.throwIfAborted();
|
|
14648
|
-
if (!cipherPattern.test(payload)
|
|
14831
|
+
if (!cipherPattern.test(payload)) invalid();
|
|
14832
|
+
if (payload.length > maxPayload)
|
|
14833
|
+
throw new ChatStoreError("Encrypted chat record is too large", 413, "record_too_large");
|
|
14649
14834
|
return payload;
|
|
14650
14835
|
};
|
|
14651
14836
|
const capture = (items, max, signal) => {
|
|
@@ -14926,6 +15111,7 @@ async function createRemoteChatStore(options) {
|
|
|
14926
15111
|
if (!object(value) || !integer(value.deleted)) invalid();
|
|
14927
15112
|
return value.deleted;
|
|
14928
15113
|
},
|
|
15114
|
+
...hashTopic ? { sealedId: (value) => hashTopic(`record-id\0${value}`) } : {},
|
|
14929
15115
|
attachments: {
|
|
14930
15116
|
async create(sizeBytes, signal) {
|
|
14931
15117
|
if (!integer(sizeBytes, 1) || sizeBytes > maxAttachmentBytes) invalid();
|
|
@@ -15003,6 +15189,7 @@ var emptyMessage = {
|
|
|
15003
15189
|
};
|
|
15004
15190
|
|
|
15005
15191
|
// src/lib/chatStore/migrateChats.ts
|
|
15192
|
+
var timedOut = (error) => error instanceof ChatStoreError && error.status === 408;
|
|
15006
15193
|
var maxPasses = 5;
|
|
15007
15194
|
var verifyBatch = 1e3;
|
|
15008
15195
|
var writeBatch = 25;
|
|
@@ -15271,19 +15458,107 @@ async function migrateChatsToRemote(options) {
|
|
|
15271
15458
|
await journal.add(upload.map((r) => key(r.record)));
|
|
15272
15459
|
let sent = 0;
|
|
15273
15460
|
options.onProgress?.({ imported: sent, toImport: upload.length });
|
|
15274
|
-
|
|
15275
|
-
|
|
15461
|
+
const send = async (batch) => {
|
|
15462
|
+
try {
|
|
15463
|
+
await store.importRecords(batch, signal);
|
|
15464
|
+
} catch (error) {
|
|
15465
|
+
if (batch.length < 2 || !timedOut(error)) throw error;
|
|
15466
|
+
const half = Math.ceil(batch.length / 2);
|
|
15467
|
+
await send(batch.slice(0, half));
|
|
15468
|
+
await send(batch.slice(half));
|
|
15469
|
+
return;
|
|
15470
|
+
}
|
|
15276
15471
|
sent += batch.length;
|
|
15277
15472
|
options.onProgress?.({ imported: sent, toImport: upload.length });
|
|
15278
|
-
}
|
|
15473
|
+
};
|
|
15474
|
+
for (const batch of batches(upload)) await send(batch);
|
|
15279
15475
|
imported += sent;
|
|
15280
15476
|
}
|
|
15281
15477
|
};
|
|
15282
15478
|
return passes(false);
|
|
15283
15479
|
}
|
|
15284
15480
|
|
|
15481
|
+
// src/lib/chatStore/seedAppFiles.ts
|
|
15482
|
+
var maxSeedAttempts = 3;
|
|
15483
|
+
async function rawRows(database, table) {
|
|
15484
|
+
const rows = await database.get(table).query().fetch();
|
|
15485
|
+
return rows.map((row) => row._raw);
|
|
15486
|
+
}
|
|
15487
|
+
async function seedRecord(store, target, device, signal) {
|
|
15488
|
+
for (let attempt = 1; ; attempt++) {
|
|
15489
|
+
const current = await store.get(target.kind, target.id, signal);
|
|
15490
|
+
if (current && (current.record.isDeleted || current.record.updatedAt >= device.updatedAt))
|
|
15491
|
+
return false;
|
|
15492
|
+
try {
|
|
15493
|
+
await store.putMany(
|
|
15494
|
+
[
|
|
15495
|
+
{
|
|
15496
|
+
record: {
|
|
15497
|
+
...target,
|
|
15498
|
+
sortKey: 0,
|
|
15499
|
+
createdAt: current?.record.createdAt ?? device.createdAt,
|
|
15500
|
+
updatedAt: device.updatedAt,
|
|
15501
|
+
isDeleted: false,
|
|
15502
|
+
data: device.data
|
|
15503
|
+
},
|
|
15504
|
+
expectedVersion: current?.version ?? 0
|
|
15505
|
+
}
|
|
15506
|
+
],
|
|
15507
|
+
signal
|
|
15508
|
+
);
|
|
15509
|
+
return true;
|
|
15510
|
+
} catch (error) {
|
|
15511
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSeedAttempts)
|
|
15512
|
+
throw error;
|
|
15513
|
+
}
|
|
15514
|
+
}
|
|
15515
|
+
}
|
|
15516
|
+
function leftOnDevice(error, result) {
|
|
15517
|
+
if (!(error instanceof ChatStoreError)) return false;
|
|
15518
|
+
if (error.code === "conversation_not_found") result.orphaned++;
|
|
15519
|
+
else if (error.code === "record_too_large") result.tooLarge++;
|
|
15520
|
+
else return false;
|
|
15521
|
+
return true;
|
|
15522
|
+
}
|
|
15523
|
+
async function seedAppFilesToVault(database, store, signal) {
|
|
15524
|
+
const result = { appFiles: 0, savedTools: 0, orphaned: 0, tooLarge: 0 };
|
|
15525
|
+
for (const file of await rawRows(database, "app_files")) {
|
|
15526
|
+
try {
|
|
15527
|
+
const target = {
|
|
15528
|
+
kind: "app_file",
|
|
15529
|
+
id: await appFileId(store, file.conversation_id, file.path),
|
|
15530
|
+
conversationId: file.conversation_id
|
|
15531
|
+
};
|
|
15532
|
+
const data = { path: normalizePath(file.path), content: file.content };
|
|
15533
|
+
const device = { data, createdAt: file.created_at, updatedAt: file.updated_at };
|
|
15534
|
+
if (await seedRecord(store, target, device, signal)) result.appFiles++;
|
|
15535
|
+
} catch (error) {
|
|
15536
|
+
if (!leftOnDevice(error, result)) throw error;
|
|
15537
|
+
}
|
|
15538
|
+
}
|
|
15539
|
+
for (const tool of await rawRows(database, "saved_tools")) {
|
|
15540
|
+
if (tool.is_deleted) continue;
|
|
15541
|
+
try {
|
|
15542
|
+
const data = {
|
|
15543
|
+
name: tool.name,
|
|
15544
|
+
displayName: tool.display_name,
|
|
15545
|
+
description: tool.description,
|
|
15546
|
+
parameters: tool.parameters,
|
|
15547
|
+
html: tool.html,
|
|
15548
|
+
conversationId: tool.conversation_id || null
|
|
15549
|
+
};
|
|
15550
|
+
const target = { kind: "saved_tool", id: tool.id, conversationId: "" };
|
|
15551
|
+
const device = { data, createdAt: tool.created_at, updatedAt: tool.updated_at };
|
|
15552
|
+
if (await seedRecord(store, target, device, signal)) result.savedTools++;
|
|
15553
|
+
} catch (error) {
|
|
15554
|
+
if (!leftOnDevice(error, result)) throw error;
|
|
15555
|
+
}
|
|
15556
|
+
}
|
|
15557
|
+
return result;
|
|
15558
|
+
}
|
|
15559
|
+
|
|
15285
15560
|
// src/lib/chatStore/settings.ts
|
|
15286
|
-
var
|
|
15561
|
+
var maxSaveAttempts2 = 3;
|
|
15287
15562
|
function toSetting(snapshot) {
|
|
15288
15563
|
if (snapshot.record.isDeleted) return null;
|
|
15289
15564
|
return {
|
|
@@ -15332,7 +15607,7 @@ async function saveSetting(store, section, data, signal) {
|
|
|
15332
15607
|
);
|
|
15333
15608
|
return toSetting(saved);
|
|
15334
15609
|
} catch (error) {
|
|
15335
|
-
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >=
|
|
15610
|
+
if (!(error instanceof ChatStoreError) || error.code !== "version_conflict" || attempt >= maxSaveAttempts2)
|
|
15336
15611
|
throw error;
|
|
15337
15612
|
}
|
|
15338
15613
|
}
|
|
@@ -16158,12 +16433,15 @@ function createVaultChatBackend(options) {
|
|
|
16158
16433
|
emit({ type: "vector_quota" });
|
|
16159
16434
|
return "retry";
|
|
16160
16435
|
}
|
|
16161
|
-
if (error.code === "private_chat_storage_limit_reached" || error.code === "invalid_record" || error.status === 400) {
|
|
16436
|
+
if (error.code === "private_chat_storage_limit_reached" || error.code === "invalid_record" || error.code === "record_too_large" || error.status === 400) {
|
|
16162
16437
|
if (batch.length > 1) {
|
|
16163
16438
|
isolate = batch.length;
|
|
16164
16439
|
return "retry";
|
|
16165
16440
|
}
|
|
16166
|
-
drop(
|
|
16441
|
+
drop(
|
|
16442
|
+
batch[0],
|
|
16443
|
+
error.code === "private_chat_storage_limit_reached" ? "storage_quota" : "invalid"
|
|
16444
|
+
);
|
|
16167
16445
|
return "retry";
|
|
16168
16446
|
}
|
|
16169
16447
|
if (error.status === 429) return backoff(error.retryAfterMs, true);
|
|
@@ -16934,17 +17212,6 @@ __decorateClass([
|
|
|
16934
17212
|
|
|
16935
17213
|
// src/lib/db/appFiles/operations.ts
|
|
16936
17214
|
var import_watermelondb9 = require("@nozbe/watermelondb");
|
|
16937
|
-
|
|
16938
|
-
// src/utils/paths.ts
|
|
16939
|
-
function normalizePath(p) {
|
|
16940
|
-
return p.replace(/^\/+/, "").replace(/\/\/+/g, "/").split("/").reduce((acc, seg) => {
|
|
16941
|
-
if (seg === "..") acc.pop();
|
|
16942
|
-
else if (seg !== ".") acc.push(seg);
|
|
16943
|
-
return acc;
|
|
16944
|
-
}, []).join("/");
|
|
16945
|
-
}
|
|
16946
|
-
|
|
16947
|
-
// src/lib/db/appFiles/operations.ts
|
|
16948
17215
|
function appFileToStored(file) {
|
|
16949
17216
|
return {
|
|
16950
17217
|
uniqueId: file.id,
|
|
@@ -29376,6 +29643,12 @@ async function importBatch2(request, keyId, rows, signal) {
|
|
|
29376
29643
|
);
|
|
29377
29644
|
return;
|
|
29378
29645
|
} catch (error) {
|
|
29646
|
+
if (error instanceof RemoteMemoryError && error.status === 408 && rows.length > 1) {
|
|
29647
|
+
const half = Math.ceil(rows.length / 2);
|
|
29648
|
+
await importBatch2(request, keyId, rows.slice(0, half), signal);
|
|
29649
|
+
await importBatch2(request, keyId, rows.slice(half), signal);
|
|
29650
|
+
return;
|
|
29651
|
+
}
|
|
29379
29652
|
if (!(error instanceof RemoteMemoryError) || error.status !== 429 || attempt >= MAX_RATE_LIMIT_WAITS)
|
|
29380
29653
|
throw error;
|
|
29381
29654
|
await wait(error.retryAfterMs ?? DEFAULT_RATE_LIMIT_WAIT_MS, signal);
|
|
@@ -34590,12 +34863,12 @@ async function preprocessFiles(files, options = {}) {
|
|
|
34590
34863
|
}
|
|
34591
34864
|
} catch (error) {
|
|
34592
34865
|
errorCount++;
|
|
34593
|
-
const
|
|
34866
|
+
const timedOut2 = error instanceof ProcessingTimeoutError;
|
|
34594
34867
|
fileStatuses.push({
|
|
34595
34868
|
fileId: file.id,
|
|
34596
34869
|
fileName: file.name,
|
|
34597
34870
|
status: "failed",
|
|
34598
|
-
reason:
|
|
34871
|
+
reason: timedOut2 ? "timeout" : "error"
|
|
34599
34872
|
});
|
|
34600
34873
|
logger.error(
|
|
34601
34874
|
`[preprocessFiles] Error processing file ${label} with ${processor.name}:`,
|
|
@@ -44429,6 +44702,7 @@ function useWalletBinding(options = {}) {
|
|
|
44429
44702
|
addConversationMemoriesOp,
|
|
44430
44703
|
anumaLastReadSortKey,
|
|
44431
44704
|
anumaTurnContent,
|
|
44705
|
+
appFileId,
|
|
44432
44706
|
appFileToStored,
|
|
44433
44707
|
archiveVaultMemoryOp,
|
|
44434
44708
|
assembleMemoryContext,
|
|
@@ -44469,6 +44743,7 @@ function useWalletBinding(options = {}) {
|
|
|
44469
44743
|
conversationMemoryToStored,
|
|
44470
44744
|
cosineInt8,
|
|
44471
44745
|
countUnreadAnumaTurns,
|
|
44746
|
+
createAppFileIndex,
|
|
44472
44747
|
createAutoExtractor,
|
|
44473
44748
|
createChunkVectorCache,
|
|
44474
44749
|
createCryptoPricePreProcessor,
|
|
@@ -44516,6 +44791,7 @@ function useWalletBinding(options = {}) {
|
|
|
44516
44791
|
defaultServerToolsFilter,
|
|
44517
44792
|
deleteAllAppFilesOp,
|
|
44518
44793
|
deleteAllVaultMemoriesForUserOp,
|
|
44794
|
+
deleteAppFile,
|
|
44519
44795
|
deleteAppFileOp,
|
|
44520
44796
|
deleteEncryptedFile,
|
|
44521
44797
|
deleteMediaByConversationOp,
|
|
@@ -44523,6 +44799,7 @@ function useWalletBinding(options = {}) {
|
|
|
44523
44799
|
deleteMediaOp,
|
|
44524
44800
|
deleteMessageOp,
|
|
44525
44801
|
deleteProjectOp,
|
|
44802
|
+
deleteSavedTool,
|
|
44526
44803
|
deleteSavedToolOp,
|
|
44527
44804
|
deleteVaultFolderOp,
|
|
44528
44805
|
deleteVaultMemoryOp,
|
|
@@ -44569,6 +44846,7 @@ function useWalletBinding(options = {}) {
|
|
|
44569
44846
|
getAllVaultMemoryContentsOp,
|
|
44570
44847
|
getAndClearNotionPendingMessage,
|
|
44571
44848
|
getAndClearNotionReturnUrl,
|
|
44849
|
+
getAppFile,
|
|
44572
44850
|
getAppFileMapOp,
|
|
44573
44851
|
getAppFileOp,
|
|
44574
44852
|
getAppFilesOp,
|
|
@@ -44647,6 +44925,9 @@ function useWalletBinding(options = {}) {
|
|
|
44647
44925
|
isSupportedMediaType,
|
|
44648
44926
|
linkMemoryEntitiesOp,
|
|
44649
44927
|
listActiveStreams,
|
|
44928
|
+
listAppFiles,
|
|
44929
|
+
listEveryAppFile,
|
|
44930
|
+
loadSavedTools,
|
|
44650
44931
|
loadSettings,
|
|
44651
44932
|
localChatBackend,
|
|
44652
44933
|
markAnumaRead,
|
|
@@ -44698,6 +44979,8 @@ function useWalletBinding(options = {}) {
|
|
|
44698
44979
|
resumeStream,
|
|
44699
44980
|
retain,
|
|
44700
44981
|
revokeNotionAccess,
|
|
44982
|
+
saveAppFile,
|
|
44983
|
+
saveSavedTool,
|
|
44701
44984
|
saveSetting,
|
|
44702
44985
|
savedToolToStored,
|
|
44703
44986
|
scoreProfileSalience,
|
|
@@ -44710,6 +44993,7 @@ function useWalletBinding(options = {}) {
|
|
|
44710
44993
|
searchMediaOp,
|
|
44711
44994
|
searchMessagesOp,
|
|
44712
44995
|
searchVaultMemories,
|
|
44996
|
+
seedAppFilesToVault,
|
|
44713
44997
|
seedEncryptionKeys,
|
|
44714
44998
|
selectServerToolsForPrompt,
|
|
44715
44999
|
serializeJsx,
|