- 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>
1. Remove duplicate ToolResult definition in heartbeat package
- Import tools.ToolResult instead of local definition
- Add nil check for handler before execution
2. Fix SpawnTool to return AsyncResult and implement AsyncTool
- Add callback field and SetCallback method
- Return AsyncResult instead of NewToolResult
3. Add context cancellation support to SubagentManager
- Check ctx.Done() before and during task execution
- Set task status to "cancelled" on cancellation
- Call callback with result on completion
4. Fix data race window in CronTool.addJob
- Use Lock instead of RLock for channel/chatID access
- Ensure consistent snapshot during job creation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add ChannelSender interface for sending heartbeat results to users
- Add sendResponse() to automatically deliver results to last channel
- Add createDefaultHeartbeatTemplate() for first-run setup
- Support HEARTBEAT_OK silent response (legacy compatibility)
- Add structured logging with INFO/ERROR levels
- Move integration tests to separate file with build tag
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verified and tested that heartbeat log is written to memory directory:
- Current code uses workspace/memory/heartbeat.log (correct)
- Added TestLogPath test verifying log is in memory directory
- All acceptance criteria met
Note: US-020 was already implemented (log path was already memory/heartbeat.log).
This commit adds the missing test to verify the requirement.
Acceptance criteria met:
- Log path is workspace/memory/heartbeat.log (not workspace/heartbeat.log)
- Directory auto-created if missing (os.MkdirAll)
- Log format unchanged (timestamped messages)
- Typecheck passes (go build ./... succeeds)
- go test ./pkg/heartbeat -run TestLogPath passes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add local ToolResult struct definition to avoid circular dependencies
- Define HeartbeatHandler function type for tool-supporting callbacks
- Add SetOnHeartbeatWithTools method to configure new handler
- Add ExecuteHeartbeatWithTools public method
- Add internal executeHeartbeatWithTools implementation
- Update checkHeartbeat to prefer new tool-supporting handler
- Detect and handle async tasks (log and return immediately)
- Handle error results with proper logging
- Add comprehensive tests for async, error, sync, and nil result cases
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>