colony-agent: implement worker loop + dream cycle

Worker:
- run_pulse(): check inbox → heartbeat → HEARTBEAT_OK or invoke Claude
- run_worker_loop(): forever loop with 30s/10s sleep
- Builds prompt from inbox items + heartbeat.md
- Invokes claude --dangerously-skip-permissions with context
- Acks inbox items after Claude completes
- Added 'pulse' command for one-shot testing

Dream:
- Checks memory.md line count (skip if < 50)
- Posts "dreaming..." to #general
- Invokes Claude to consolidate, prune, evolve
- Posts "back from dreaming" when done

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 22:53:49 +02:00
parent 5c59b598c6
commit 67c81fc518
3 changed files with 177 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
mod dream;
mod worker;
use clap::{Parser, Subcommand};
#[derive(Parser)]
@@ -13,6 +16,8 @@ enum Commands {
Worker,
/// Run one dream cycle (memory consolidation)
Dream,
/// Run one pulse cycle (check inbox, respond if needed)
Pulse,
/// Create a new agent on this VM
Birth {
name: String,
@@ -29,12 +34,14 @@ async fn main() {
match cli.command {
Commands::Worker => {
eprintln!("colony-agent: worker not yet implemented");
std::process::exit(1);
worker::run_worker_loop("");
}
Commands::Pulse => {
worker::run_pulse("");
eprintln!("pulse complete");
}
Commands::Dream => {
eprintln!("colony-agent: dream not yet implemented");
std::process::exit(1);
dream::run_dream();
}
Commands::Birth { name, instruction } => {
eprintln!("colony-agent: birth '{}' with instruction: {}", name, instruction);