openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines (4 loc) • 1.75 kB
JavaScript
import{i as listAgentIds}from"./agent-roster-4XrgUgPK.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{t as readDefaultProactiveJobReceiptsAsync}from"./proactive-job-receipt-DqdDnf_9.mjs";
//!src/infra/heartbeat-compat.ts
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})}}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-B6EDt5AG.mjs`);e.assertCurrent();return[i?.prependContext&&a(i.prependContext,1e3),e.prompt,i?.appendContext&&a(i.appendContext,1e3)].filter(Boolean).join(`
`)}export{setLegacyHeartbeatsEnabled as n,applyLegacyHeartbeatPromptContribution as t};