@miniaxolotl/grove-server 1.11.23 → 1.11.24
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/bootstrap.js +27 -1
- package/dist/bootstrap.js.map +4 -4
- package/dist/migrate.js +27 -1
- package/dist/migrate.js.map +4 -4
- package/dist/server.js +44 -10
- package/dist/server.js.map +4 -4
- package/dist/telemetry-build.json +1 -1
- package/dist/worker.js +44 -10
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"enabled":true,"revision":"
|
|
1
|
+
{"enabled":true,"revision":"9ee71cc987a443c020fbf6030f76664b4cc5e914","version":"1.11.24","component":"api"}
|
package/dist/worker.js
CHANGED
|
@@ -18,7 +18,7 @@ var __export = (target2, all2) => {
|
|
|
18
18
|
var define_GROVE_TELEMETRY_default;
|
|
19
19
|
var init_define_GROVE_TELEMETRY = __esm({
|
|
20
20
|
"<define:__GROVE_TELEMETRY__>"() {
|
|
21
|
-
define_GROVE_TELEMETRY_default = { enabled: true, revision: "
|
|
21
|
+
define_GROVE_TELEMETRY_default = { enabled: true, revision: "9ee71cc987a443c020fbf6030f76664b4cc5e914", version: "1.11.24", component: "api", key: "phc_AqVrjhk7W2X2pFjyngY7uWxcSSRREfJhgr8mBmKbXYEh", cliDsn: "https://3f6d0711b5890dea4ce8e6ccf2a1a7fd@o4511632209346560.ingest.us.sentry.io/4512290791620608", apiDsn: "https://4524e8910e318110277babdfe818999b@o4511632209346560.ingest.us.sentry.io/4512290791489536" };
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -2606,6 +2606,32 @@ var dailyNotes = {
|
|
|
2606
2606
|
}
|
|
2607
2607
|
};
|
|
2608
2608
|
|
|
2609
|
+
// lib/database/src/cache-retention-migration.ts
|
|
2610
|
+
init_define_GROVE_TELEMETRY();
|
|
2611
|
+
var cacheRetention = {
|
|
2612
|
+
name: "20261118_043_cache_retention",
|
|
2613
|
+
async up(db) {
|
|
2614
|
+
const { rows } = await db.raw(
|
|
2615
|
+
"SELECT pg_get_functiondef('grove_schedule_cleanup()'::regprocedure) AS definition"
|
|
2616
|
+
);
|
|
2617
|
+
const definition2 = rows[0].definition;
|
|
2618
|
+
const anchor = "OR EXISTS(SELECT 1 FROM rate_buckets r";
|
|
2619
|
+
if (definition2.split(anchor).length !== 2)
|
|
2620
|
+
throw new Error("Unsupported retention scheduler baseline");
|
|
2621
|
+
await db.raw(
|
|
2622
|
+
definition2.replace(
|
|
2623
|
+
anchor,
|
|
2624
|
+
`OR EXISTS(SELECT 1 FROM ai_cache c WHERE c.account_id=a.id AND c.expires_at<=now())
|
|
2625
|
+
OR EXISTS(SELECT 1 FROM ai_provider_backoff b WHERE b.account_id=a.id AND b.retry_at<now()-interval '1 day')
|
|
2626
|
+
${anchor}`
|
|
2627
|
+
)
|
|
2628
|
+
);
|
|
2629
|
+
},
|
|
2630
|
+
async down() {
|
|
2631
|
+
throw new Error("Use a forward migration");
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
|
|
2609
2635
|
// lib/database/src/writing-allowance-migration.ts
|
|
2610
2636
|
init_define_GROVE_TELEMETRY();
|
|
2611
2637
|
var writingAllowance = {
|
|
@@ -6346,7 +6372,8 @@ var migrations = [
|
|
|
6346
6372
|
nativeSharing,
|
|
6347
6373
|
billingTrial,
|
|
6348
6374
|
writingAllowance,
|
|
6349
|
-
dailyNotes
|
|
6375
|
+
dailyNotes,
|
|
6376
|
+
cacheRetention
|
|
6350
6377
|
];
|
|
6351
6378
|
var migrationSource = {
|
|
6352
6379
|
getMigrations: async () => migrations,
|
|
@@ -6466,6 +6493,9 @@ async function probeDatabase(db) {
|
|
|
6466
6493
|
);
|
|
6467
6494
|
await db.raw("SELECT policy, version FROM writing_consents LIMIT 0");
|
|
6468
6495
|
await db.raw("SELECT connection_id FROM writing_cancellations LIMIT 0");
|
|
6496
|
+
await db.raw(
|
|
6497
|
+
"SELECT account_id, local_date, memory_id FROM daily_notes LIMIT 0"
|
|
6498
|
+
);
|
|
6469
6499
|
}
|
|
6470
6500
|
var MemoryModel = class extends Model {
|
|
6471
6501
|
static tableName = "memories";
|
|
@@ -21918,14 +21948,16 @@ async function owned2(trx, id2) {
|
|
|
21918
21948
|
return row;
|
|
21919
21949
|
}
|
|
21920
21950
|
async function expireDocumentDrafts(trx) {
|
|
21921
|
-
const
|
|
21951
|
+
const limit = 20;
|
|
21952
|
+
const expired = trx("document_import_batches").select("id").where("expiresAt", "<=", trx.fn.now()).where({ draftsCleared: false }).whereIn("status", ["uploading", "preparing", "ready", "cancelled"]).orderBy("id").limit(limit);
|
|
21922
21953
|
await trx("document_import_files").whereIn("batchId", expired).where({ originalReady: false }).whereNotNull("staging").update({ staging: null });
|
|
21923
21954
|
await trx("document_import_notes").whereIn("batchId", expired).whereNull("memoryId").whereNot("content", "[Expired import draft]").update({
|
|
21924
21955
|
content: "[Expired import draft]",
|
|
21925
21956
|
included: false,
|
|
21926
21957
|
suggestion: null
|
|
21927
21958
|
});
|
|
21928
|
-
await trx("document_import_batches").whereIn("id", expired).update({ draftsCleared: true });
|
|
21959
|
+
const processed = await trx("document_import_batches").whereIn("id", expired).update({ draftsCleared: true });
|
|
21960
|
+
return { processed, fullPage: processed === limit };
|
|
21929
21961
|
}
|
|
21930
21962
|
function documentImportHandlers(service, extract, store) {
|
|
21931
21963
|
const document_prepare = async (task, signal) => {
|
|
@@ -22126,8 +22158,9 @@ var available = (q) => q.whereNull("removedAt").where(
|
|
|
22126
22158
|
(sub) => sub.where("accepted", true).orWhere("expiresAt", ">", q.client.raw("now()"))
|
|
22127
22159
|
);
|
|
22128
22160
|
async function expireConversationDocuments(trx) {
|
|
22129
|
-
const
|
|
22130
|
-
|
|
22161
|
+
const limit = 25;
|
|
22162
|
+
const docs = await trx("conversation_documents").where({ accepted: false }).whereNull("removedAt").where("expiresAt", "<=", trx.fn.now()).orderBy("id").limit(limit).select("id", "conversationId");
|
|
22163
|
+
if (!docs.length) return { processed: 0, fullPage: false };
|
|
22131
22164
|
await trx("conversation_document_chunks").whereIn(
|
|
22132
22165
|
"documentId",
|
|
22133
22166
|
docs.map((d) => d.id)
|
|
@@ -22145,6 +22178,7 @@ async function expireConversationDocuments(trx) {
|
|
|
22145
22178
|
"id",
|
|
22146
22179
|
docs.map((d) => d.conversationId)
|
|
22147
22180
|
).increment("documentsVersion", 1);
|
|
22181
|
+
return { processed: docs.length, fullPage: docs.length === limit };
|
|
22148
22182
|
}
|
|
22149
22183
|
async function documentSnapshot(trx, conversationId, query) {
|
|
22150
22184
|
const chat = await documentChat(trx, conversationId);
|
|
@@ -25545,8 +25579,8 @@ function cleanupHandlers(db, deleteIdentity, cancelBilling) {
|
|
|
25545
25579
|
const retention_cleanup = async (task, signal) => {
|
|
25546
25580
|
await taskTransaction(db, task, async (trx) => {
|
|
25547
25581
|
signal.throwIfAborted();
|
|
25548
|
-
await expireDocumentDrafts(trx);
|
|
25549
|
-
await expireConversationDocuments(trx);
|
|
25582
|
+
const drafts = await expireDocumentDrafts(trx);
|
|
25583
|
+
const uploads = await expireConversationDocuments(trx);
|
|
25550
25584
|
const writingExpired = await expireWriting(trx);
|
|
25551
25585
|
const expired = await trx("memories").where("purgeAt", "<=", trx.fn.now()).select("id").orderBy("id").limit(batchSize);
|
|
25552
25586
|
if (expired.length) {
|
|
@@ -25562,8 +25596,8 @@ function cleanupHandlers(db, deleteIdentity, cancelBilling) {
|
|
|
25562
25596
|
await trx("rate_buckets").whereIn("minute", buckets).delete();
|
|
25563
25597
|
const cache = await pruneCache(trx, true);
|
|
25564
25598
|
return {
|
|
25565
|
-
processed: Number(task.processed) + expired.length + cache + writingExpired,
|
|
25566
|
-
complete: expired.length < batchSize && buckets.length < batchSize && writingExpired < batchSize && cache < batchSize
|
|
25599
|
+
processed: Number(task.processed) + expired.length + cache + writingExpired + drafts.processed + uploads.processed,
|
|
25600
|
+
complete: !drafts.fullPage && !uploads.fullPage && expired.length < batchSize && buckets.length < batchSize && writingExpired < batchSize && cache < batchSize
|
|
25567
25601
|
};
|
|
25568
25602
|
});
|
|
25569
25603
|
};
|