refactor(core): dedupe shared config and runtime helpers

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:03 +00:00
parent 544ffbcf7b
commit 04892ee230
68 changed files with 1966 additions and 2018 deletions

View File

@@ -3,6 +3,25 @@ import type { OpenClawConfig } from "../config/config.js";
import { resolveHeartbeatVisibility } from "./heartbeat-visibility.js";
describe("resolveHeartbeatVisibility", () => {
function createTelegramAccountHeartbeatConfig(): OpenClawConfig {
return {
channels: {
telegram: {
heartbeat: {
showOk: true,
},
accounts: {
primary: {
heartbeat: {
showOk: false,
},
},
},
},
},
} as OpenClawConfig;
}
it("returns default values when no config is provided", () => {
const cfg = {} as OpenClawConfig;
const result = resolveHeartbeatVisibility({ cfg, channel: "telegram" });
@@ -136,46 +155,14 @@ describe("resolveHeartbeatVisibility", () => {
});
it("handles missing accountId gracefully", () => {
const cfg = {
channels: {
telegram: {
heartbeat: {
showOk: true,
},
accounts: {
primary: {
heartbeat: {
showOk: false,
},
},
},
},
},
} as OpenClawConfig;
const cfg = createTelegramAccountHeartbeatConfig();
const result = resolveHeartbeatVisibility({ cfg, channel: "telegram" });
expect(result.showOk).toBe(true);
});
it("handles non-existent account gracefully", () => {
const cfg = {
channels: {
telegram: {
heartbeat: {
showOk: true,
},
accounts: {
primary: {
heartbeat: {
showOk: false,
},
},
},
},
},
} as OpenClawConfig;
const cfg = createTelegramAccountHeartbeatConfig();
const result = resolveHeartbeatVisibility({
cfg,
channel: "telegram",