refactor(heartbeat): simplify service with single handler and direct bus usage
- Remove redundant ChannelSender interface, use *bus.MessageBus directly - Consolidate two handlers (onHeartbeat, onHeartbeatWithTools) into one - Move HEARTBEAT.md and heartbeat.log to workspace root - Simplify NewHeartbeatService signature (remove handler param) - Add SetBus and SetHandler methods for dependency injection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -654,10 +654,20 @@ func gatewayCmd() {
|
||||
|
||||
heartbeatService := heartbeat.NewHeartbeatService(
|
||||
cfg.WorkspacePath(),
|
||||
nil,
|
||||
30*60,
|
||||
30,
|
||||
cfg.Heartbeat.Enabled,
|
||||
)
|
||||
heartbeatService.SetBus(msgBus)
|
||||
heartbeatService.SetHandler(func(prompt string) *tools.ToolResult {
|
||||
response, err := agentLoop.ProcessDirect(context.Background(), prompt, "heartbeat")
|
||||
if err != nil {
|
||||
return tools.ErrorResult(fmt.Sprintf("Heartbeat error: %v", err))
|
||||
}
|
||||
if response == "HEARTBEAT_OK" {
|
||||
return tools.SilentResult("Heartbeat OK")
|
||||
}
|
||||
return tools.UserResult(response)
|
||||
})
|
||||
|
||||
channelManager, err := channels.NewManager(cfg, msgBus)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user