mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
Adds a durable, sleep-aware 30-day sweep for Google Technical Information, keeps Google results out of decision training and shared feedback traces, and deletes the remaining copies of a cleaned run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import type { Db } from "@paperclipai/db";
|
|
import { DELIVERY_QUEUES } from "./delivery-work-notifications.js";
|
|
import { registerDeadlineWork } from "./deadline-work.js";
|
|
import type { createDeliveryWorkCoordinator } from "./delivery-work-coordinator.js";
|
|
import { registerIdleLocalWorkProbe } from "./idle-local-work.js";
|
|
import { createGoogleTechnicalInformationRetention } from "./tool-access/connections/google-technical-information.js";
|
|
|
|
export function registerGoogleTechnicalInformationWork(
|
|
db: Db,
|
|
coordinator: ReturnType<typeof createDeliveryWorkCoordinator>,
|
|
canRun: () => boolean,
|
|
) {
|
|
const retention = createGoogleTechnicalInformationRetention(db);
|
|
let deadline: number | null | undefined;
|
|
const unregister = registerIdleLocalWorkProbe((options = {}) => {
|
|
if (deadline === undefined) return "unknown";
|
|
if (deadline === null) return "none";
|
|
return options.deadlineCapability?.deadlineCatalog === "domain_deadlines_v1" && deadline > Date.now()
|
|
? "none" : "present";
|
|
});
|
|
const worker = registerDeadlineWork(coordinator, DELIVERY_QUEUES.googleTechnicalInformation, {
|
|
canRun,
|
|
retryMs: 60_000,
|
|
notificationCoalesceMs: 5_000,
|
|
onSettled: () => {
|
|
deadline = undefined;
|
|
},
|
|
run: (signal) => signal.aborted ? Promise.resolve() : retention.sweep(signal),
|
|
next: async () => {
|
|
deadline = await retention.nextDeadline();
|
|
return deadline;
|
|
},
|
|
});
|
|
return {
|
|
...worker,
|
|
stop: async () => {
|
|
unregister();
|
|
await worker.stop();
|
|
},
|
|
};
|
|
}
|