openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
54 lines (53 loc) • 2.21 kB
JavaScript
import { i as listAgentIds } from "./agent-roster-t1ooUdXp.mjs";
import { O as tryResolveAmbientOwnerAgentId } from "./agent-scope-config-DmXgFGKP.mjs";
import "./agent-scope-BwB8YH6y.mjs";
import "./heartbeat-DHK32_6H.mjs";
import { i as tryResolveCronJobEffectiveAgentId } from "./agent-id-CX8HtxAT.mjs";
import { t as CronStoreSelectionRequiredError } from "./selection-error-CCb6S-v3.mjs";
//#region src/infra/heartbeat-summary-snapshot.ts
function resolveHeartbeatSummaryJobs(e, t) {
const n = tryResolveAmbientOwnerAgentId(e);
return t.flatMap((e) => {
const t = tryResolveCronJobEffectiveAgentId(e, n);
return t ? [{
...e,
agentId: t
}] : [];
});
}
/** Missing state is empty; unreadable or unmigrated state remains an explicit failure. */
async function readHeartbeatSummarySnapshot(e, t, n) {
const { readDefaultProactiveJobsAsync: r, readDefaultProactiveJobsByKeyAsync: i } = await import("./proactive-job-receipt-C5fQxmUn.mjs");
return resolveHeartbeatSummaryJobs(e, n ? await i(n, listAgentIds(e)) : await r(t, listAgentIds(e)));
}
/** Diagnostics stay available while the default cron partition awaits an operator choice. */
async function readHeartbeatSummaryForStatus(e) {
try {
return {
jobs: await e(),
selectionWarning: void 0
};
} catch (e) {
if (!(e instanceof CronStoreSelectionRequiredError)) throw e;
return {
jobs: [],
selectionWarning: e.message
};
}
}
function projectHeartbeatSummary(e, t) {
const n = Boolean(!t && e?.enabled && !e.state.autoDisabled);
const r = e?.schedule.kind === "every" ? e.schedule.everyMs : null;
return {
enabled: n,
every: t ? "paused" : n ? r ? `${r}ms` : "scheduled" : "disabled",
everyMs: n ? r : null,
prompt: t ?? (e?.payload.kind === "agentTurn" ? e.payload.message : ""),
target: e?.delivery?.mode === "none" ? "none" : e?.delivery?.target ?? e?.delivery?.channel ?? "none",
model: e?.payload.kind === "agentTurn" ? e.payload.model : void 0,
session: e?.sessionTarget.startsWith("session:") ? e.sessionTarget.slice(8) : e?.sessionKey,
ackMaxChars: 300
};
}
//#endregion
export { readHeartbeatSummaryForStatus as n, readHeartbeatSummarySnapshot as r, projectHeartbeatSummary as t };