openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
59 lines (58 loc) • 2.37 kB
JavaScript
import { o as asRecord } from "./record-coerce-CVPuDqcc.mjs";
import { n as safeParseJsonRecord } from "./json-coercion-CaJLaav-.mjs";
import { a as fingerprintCronRuntimeRows, i as fingerprintCronJobRows, n as deleteCronJobRowInDatabase, o as loadCronRows, s as loadedCronStoreFromRows } from "./row-codec-D4aymQkb.mjs";
import { t as RETIRED_SKILL_COLLECTION_REVIEW_DECLARATION_PREFIX } from "./system-owned-declaration-DneSqJef.mjs";
import { a as loadCronRuntimeAuthorities, s as repairCronRuntimeAuthorityRows } from "./runtime-authority-store-486x-ema.mjs";
//#region src/cron/store/load.kernel.ts
/** The weekly Workshop curator and its older `skillCollectionReview` payload are retired. */
function isRetiredCollectionReview(e) {
const t = safeParseJsonRecord(e.job_json);
const n = e.declaration_key ?? t?.declarationKey;
return e.payload_kind === "skillCollectionReview" || asRecord(t?.payload).kind === "skillCollectionReview" || typeof n === "string" && n.startsWith("skill-collection-review:");
}
function loadCronStoreFromDatabase(e, t, n) {
let r = loadCronRows(e, t);
const i = new Set(r.filter(isRetiredCollectionReview).map((e) => e.job_id));
if (!n) r = r.filter((e) => !i.has(e.job_id));
else if (i.size > 0) {
if (n.write((e) => {
const n = loadCronRows(e, t, i).filter(isRetiredCollectionReview);
for (const r of n) deleteCronJobRowInDatabase(e, t, r.job_id);
return n.length;
}, "cron.retire-collection-review") > 0) n.committed();
r = loadCronRows(e, t);
}
const a = loadedCronStoreFromRows(r);
if (r.length > 0) {
const r = loadCronRuntimeAuthorities({
db: e,
storeKey: t,
jobs: a.store.jobs
});
if (n) repairLoadedCronRuntimeAuthority(n, {
storeKey: t,
jobIds: r.repairJobIds
});
}
return !n ? a : {
...a,
jobsFingerprint: fingerprintCronJobRows(r),
runtimeFingerprint: fingerprintCronRuntimeRows(r)
};
}
function repairLoadedCronRuntimeAuthority(e, t) {
if (t.jobIds.length === 0) return;
if (e.write((e) => {
const n = loadCronRows(e, t.storeKey, new Set(t.jobIds));
if (n.length === 0) return false;
const r = loadedCronStoreFromRows(n);
return repairCronRuntimeAuthorityRows({
db: e,
storeKey: t.storeKey,
jobs: r.store.jobs,
jobIds: t.jobIds
});
}, "cron.runtime-authority-repair")) e.committed();
}
//#endregion
export { loadCronStoreFromDatabase as t };