UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

52 lines (51 loc) • 2.14 kB
import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs"; import "./agent-scope-BwB8YH6y.mjs"; import { t as readDefaultProactiveJobReceiptsAsync } from "./proactive-job-receipt-DquAVkxB.mjs"; //#region src/infra/heartbeat-compat.ts /** Deprecated v4 controls. Ordinary automation receipts are the only ownership source. */ async function getLegacyHeartbeatJobIds(e) { const t = await readDefaultProactiveJobReceiptsAsync(void 0, listAgentIds(e)); const n = []; for (const e of Object.values(t)) if (e.phase === "complete") n.push(e.jobId, ...e.convertedJobIds ?? []); return n; } async function setLegacyHeartbeatsEnabled(e, t, n, r) { r?.(); const i = new Set(await getLegacyHeartbeatJobIds(e)); const a = (await t.list({ includeDisabled: true })).filter((e) => i.has(e.id)); if (!a.length) throw new Error("No converted/default proactive automation exists. Run openclaw doctor --fix or manage ordinary automations; deleted jobs are not recreated."); for (const e of a) { r?.(); await t.update(e.id, { enabled: n }, { commitGuard: r }); } } /** Stable hook boundary: converted/default jobs only, never unrelated cron turns. */ async function applyLegacyHeartbeatPromptContribution(e) { e.assertCurrent(); const { getGlobalHookRunner: t } = await import("./plugins/hook-runner-global.js"); e.assertCurrent(); const n = t(); if (!n?.hasHooks("heartbeat_prompt_contribution")) return e.prompt; const r = await getLegacyHeartbeatJobIds(e.cfg); e.assertCurrent(); if (!r.includes(e.jobId)) return e.prompt; const i = await n.runHeartbeatPromptContribution({ agentId: e.agentId, sessionKey: e.sessionKey, heartbeatName: e.name }, { agentId: e.agentId, sessionKey: e.sessionKey, trigger: "heartbeat" }); e.assertCurrent(); const { sliceToolResultTextToBudget: a } = await import("./tool-result-text-budget-BpZ8ynO9.mjs"); e.assertCurrent(); return [ i?.prependContext && a(i.prependContext, 1e3), e.prompt, i?.appendContext && a(i.appendContext, 1e3) ].filter(Boolean).join("\n\n"); } //#endregion export { setLegacyHeartbeatsEnabled as n, applyLegacyHeartbeatPromptContribution as t };