with open('src/infra/heartbeat-runner.ts', 'r') as f:content = f.read()# Fix 1: Add heartbeatFileContent param to resolveHeartbeatRunPromptold_sig = """function resolveHeartbeatRunPrompt(params: {cfg: OpenClawConfig;heartbeat?: HeartbeatConfig;preflight: HeartbeatPreflight;canRelayToUser: boolean;workspaceDir: string;startedAt: number;}): HeartbeatPromptResolution {"""new_sig = """function resolveHeartbeatRunPrompt(params: {cfg: OpenClawConfig;heartbeat?: HeartbeatConfig;preflight: HeartbeatPreflight;canRelayToUser: boolean;workspaceDir: string;startedAt: number;heartbeatFileContent?: string;}): HeartbeatPromptResolution {"""content = content.replace(old_sig, new_sig)# Fix 2: Update the task-mode prompt to include HEARTBEAT.md directivesold_prompt = ''' if (dueTasks.length > 0) {const taskList = dueTasks.map((task) => `- ${task.name}: ${task.prompt}`).join("\\n");const prompt = `Run the following periodic tasks (only those due based on their intervals):${taskList}After completing all due tasks, reply HEARTBEAT_OK.`;return { prompt, hasExecCompletion: false, hasCronEvents: false };}'''new_prompt = ''' if (dueTasks.length > 0) {const taskList = dueTasks.map((task) => `- ${task.name}: ${task.prompt}`).join("\\n");let prompt = `Run the following periodic tasks (only those due based on their intervals):${taskList}After completing all due tasks, reply HEARTBEAT_OK.`;// Preserve HEARTBEAT.md directives (non-task content)if (params.heartbeatFileContent) {const directives = params.heartbeatFileContent.replace(/^tasks:\\n(?:[ \\t].*\\n)*/m, "").trim();if (directives) {prompt += `\\n\\nAdditional context from HEARTBEAT.md:\\n${directives}`;}}return { prompt, hasExecCompletion: false, hasCronEvents: false };}'''content = content.replace(old_prompt, new_prompt)# Fix 3: Pass heartbeatFileContent from call siteold_call = """ const { prompt, hasExecCompletion, hasCronEvents } = resolveHeartbeatRunPrompt({cfg,heartbeat,preflight,canRelayToUser,workspaceDir,startedAt,});"""new_call = """ const { prompt, hasExecCompletion, hasCronEvents } = resolveHeartbeatRunPrompt({cfg,heartbeat,preflight,canRelayToUser,workspaceDir,startedAt,heartbeatFileContent: preflight.heartbeatFileContent,});"""content = content.replace(old_call, new_call)with open('src/infra/heartbeat-runner.ts', 'w') as f:f.write(content)print("Fix #2 applied: HEARTBEAT.md directives preserved in task-mode prompt")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。