Menu
popagent
publicLatest change 6edc7e928c57dab23c0973ed3f7ee70b3ebb72d5 - Initial popagent baseline by AkurAI Build
import { Cron } from "croner";
import { hookAudit } from "./hook-audit";
import { longTermMemory } from "./long-term-memory";
type MaintenanceStores = {
memory: Pick<typeof longTermMemory, "pruneEpisodes">;
audit: Pick<typeof hookAudit, "cleanupAll">;
};
export async function runMaintenanceOnce(stores: MaintenanceStores = { memory: longTermMemory, audit: hookAudit }): Promise<void> {
await Promise.all([stores.memory.pruneEpisodes(), stores.audit.cleanupAll()]);
}
export function startMaintenance(): Cron {
const job = new Cron("0 3 * * *", { timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }, () => {
void runMaintenanceOnce().catch((error) => console.error("maintenance failed", error));
});
void runMaintenanceOnce().catch((error) => console.error("maintenance failed", error));
return job;
}