mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:57:40 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -22,7 +22,7 @@ import type { ReplyPayload } from "../auto-reply/types.js";
|
||||
import { getChannelPlugin } from "../channels/plugins/index.js";
|
||||
import type { ChannelHeartbeatDeps } from "../channels/plugins/types.js";
|
||||
import { parseDurationMs } from "../cli/parse-duration.js";
|
||||
import type { MoltbotConfig } from "../config/config.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { loadConfig } from "../config/config.js";
|
||||
import {
|
||||
canonicalizeMainSessionAlias,
|
||||
@@ -97,7 +97,7 @@ const EXEC_EVENT_PROMPT =
|
||||
"Please relay the command output to the user in a helpful way. If the command succeeded, share the relevant output. " +
|
||||
"If it failed, explain what went wrong.";
|
||||
|
||||
function resolveActiveHoursTimezone(cfg: MoltbotConfig, raw?: string): string {
|
||||
function resolveActiveHoursTimezone(cfg: OpenClawConfig, raw?: string): string {
|
||||
const trimmed = raw?.trim();
|
||||
if (!trimmed || trimmed === "user") {
|
||||
return resolveUserTimezone(cfg.agents?.defaults?.userTimezone);
|
||||
@@ -149,7 +149,7 @@ function resolveMinutesInTimeZone(nowMs: number, timeZone: string): number | nul
|
||||
}
|
||||
|
||||
function isWithinActiveHours(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
heartbeat?: HeartbeatConfig,
|
||||
nowMs?: number,
|
||||
): boolean {
|
||||
@@ -181,15 +181,15 @@ type HeartbeatAgentState = {
|
||||
|
||||
export type HeartbeatRunner = {
|
||||
stop: () => void;
|
||||
updateConfig: (cfg: MoltbotConfig) => void;
|
||||
updateConfig: (cfg: OpenClawConfig) => void;
|
||||
};
|
||||
|
||||
function hasExplicitHeartbeatAgents(cfg: MoltbotConfig) {
|
||||
function hasExplicitHeartbeatAgents(cfg: OpenClawConfig) {
|
||||
const list = cfg.agents?.list ?? [];
|
||||
return list.some((entry) => Boolean(entry?.heartbeat));
|
||||
}
|
||||
|
||||
export function isHeartbeatEnabledForAgent(cfg: MoltbotConfig, agentId?: string): boolean {
|
||||
export function isHeartbeatEnabledForAgent(cfg: OpenClawConfig, agentId?: string): boolean {
|
||||
const resolvedAgentId = normalizeAgentId(agentId ?? resolveDefaultAgentId(cfg));
|
||||
const list = cfg.agents?.list ?? [];
|
||||
const hasExplicit = hasExplicitHeartbeatAgents(cfg);
|
||||
@@ -201,7 +201,10 @@ export function isHeartbeatEnabledForAgent(cfg: MoltbotConfig, agentId?: string)
|
||||
return resolvedAgentId === resolveDefaultAgentId(cfg);
|
||||
}
|
||||
|
||||
function resolveHeartbeatConfig(cfg: MoltbotConfig, agentId?: string): HeartbeatConfig | undefined {
|
||||
function resolveHeartbeatConfig(
|
||||
cfg: OpenClawConfig,
|
||||
agentId?: string,
|
||||
): HeartbeatConfig | undefined {
|
||||
const defaults = cfg.agents?.defaults?.heartbeat;
|
||||
if (!agentId) return defaults;
|
||||
const overrides = resolveAgentConfig(cfg, agentId)?.heartbeat;
|
||||
@@ -210,7 +213,7 @@ function resolveHeartbeatConfig(cfg: MoltbotConfig, agentId?: string): Heartbeat
|
||||
}
|
||||
|
||||
export function resolveHeartbeatSummaryForAgent(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
agentId?: string,
|
||||
): HeartbeatSummary {
|
||||
const defaults = cfg.agents?.defaults?.heartbeat;
|
||||
@@ -257,7 +260,7 @@ export function resolveHeartbeatSummaryForAgent(
|
||||
};
|
||||
}
|
||||
|
||||
function resolveHeartbeatAgents(cfg: MoltbotConfig): HeartbeatAgent[] {
|
||||
function resolveHeartbeatAgents(cfg: OpenClawConfig): HeartbeatAgent[] {
|
||||
const list = cfg.agents?.list ?? [];
|
||||
if (hasExplicitHeartbeatAgents(cfg)) {
|
||||
return list
|
||||
@@ -273,7 +276,7 @@ function resolveHeartbeatAgents(cfg: MoltbotConfig): HeartbeatAgent[] {
|
||||
}
|
||||
|
||||
export function resolveHeartbeatIntervalMs(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
overrideEvery?: string,
|
||||
heartbeat?: HeartbeatConfig,
|
||||
) {
|
||||
@@ -295,11 +298,11 @@ export function resolveHeartbeatIntervalMs(
|
||||
return ms;
|
||||
}
|
||||
|
||||
export function resolveHeartbeatPrompt(cfg: MoltbotConfig, heartbeat?: HeartbeatConfig) {
|
||||
export function resolveHeartbeatPrompt(cfg: OpenClawConfig, heartbeat?: HeartbeatConfig) {
|
||||
return resolveHeartbeatPromptText(heartbeat?.prompt ?? cfg.agents?.defaults?.heartbeat?.prompt);
|
||||
}
|
||||
|
||||
function resolveHeartbeatAckMaxChars(cfg: MoltbotConfig, heartbeat?: HeartbeatConfig) {
|
||||
function resolveHeartbeatAckMaxChars(cfg: OpenClawConfig, heartbeat?: HeartbeatConfig) {
|
||||
return Math.max(
|
||||
0,
|
||||
heartbeat?.ackMaxChars ??
|
||||
@@ -309,7 +312,7 @@ function resolveHeartbeatAckMaxChars(cfg: MoltbotConfig, heartbeat?: HeartbeatCo
|
||||
}
|
||||
|
||||
function resolveHeartbeatSession(
|
||||
cfg: MoltbotConfig,
|
||||
cfg: OpenClawConfig,
|
||||
agentId?: string,
|
||||
heartbeat?: HeartbeatConfig,
|
||||
) {
|
||||
@@ -428,7 +431,7 @@ function normalizeHeartbeatReply(
|
||||
}
|
||||
|
||||
export async function runHeartbeatOnce(opts: {
|
||||
cfg?: MoltbotConfig;
|
||||
cfg?: OpenClawConfig;
|
||||
agentId?: string;
|
||||
heartbeat?: HeartbeatConfig;
|
||||
reason?: string;
|
||||
@@ -755,7 +758,7 @@ export async function runHeartbeatOnce(opts: {
|
||||
}
|
||||
|
||||
export function startHeartbeatRunner(opts: {
|
||||
cfg?: MoltbotConfig;
|
||||
cfg?: OpenClawConfig;
|
||||
runtime?: RuntimeEnv;
|
||||
abortSignal?: AbortSignal;
|
||||
runOnce?: typeof runHeartbeatOnce;
|
||||
@@ -801,7 +804,7 @@ export function startHeartbeatRunner(opts: {
|
||||
state.timer.unref?.();
|
||||
};
|
||||
|
||||
const updateConfig = (cfg: MoltbotConfig) => {
|
||||
const updateConfig = (cfg: OpenClawConfig) => {
|
||||
if (state.stopped) return;
|
||||
const now = Date.now();
|
||||
const prevAgents = state.agents;
|
||||
|
||||
Reference in New Issue
Block a user