This commit completes Phase 1 of the HAP implementation by restructuring CHORUS from a single binary to a dual-binary architecture that supports both autonomous agents and human agent portals using shared P2P infrastructure. ## Key Changes ### Multi-Binary Architecture - **cmd/agent/main.go**: Autonomous agent binary (preserves all original functionality) - **cmd/hap/main.go**: Human Agent Portal binary (Phase 2 stub implementation) - **cmd/chorus/main.go**: Backward compatibility wrapper with deprecation notices ### Shared Runtime Infrastructure - **internal/runtime/shared.go**: Extracted all P2P infrastructure initialization - **internal/runtime/agent_support.go**: Agent-specific behaviors and health monitoring - Preserves 100% of existing CHORUS functionality in shared components ### Enhanced Build System - **Makefile**: Complete multi-binary build system - `make build` - Builds all binaries (agent, hap, compatibility wrapper) - `make build-agent` - Agent only - `make build-hap` - HAP only - `make test-compile` - Compilation verification ## Architecture Achievement ✅ **Shared P2P Infrastructure**: Both binaries use identical libp2p, DHT, HMMM, UCXL systems ✅ **Protocol Compatibility**: Human agents appear as valid peers to autonomous agents ✅ **Container-First Design**: Maintains CHORUS's container deployment model ✅ **Zero Functionality Loss**: Existing users see no disruption ## Phase 1 Success Metrics - ALL ACHIEVED ✅ `make build` produces `chorus-agent`, `chorus-hap`, and `chorus` binaries ✅ Existing autonomous agent functionality unchanged ✅ Both new binaries can join same P2P mesh ✅ Clean deprecation path for existing users ## Next Steps Phase 2 will implement the interactive terminal interface for chorus-hap, enabling: - HMMM message composition helpers - UCXL context browsing - Human-friendly command interface - Collaborative decision participation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"chorus/internal/runtime"
|
|
)
|
|
|
|
func main() {
|
|
// Early CLI handling: print help/version without requiring env/config
|
|
for _, a := range os.Args[1:] {
|
|
switch a {
|
|
case "--help", "-h", "help":
|
|
fmt.Printf("%s-agent %s\n\n", runtime.AppName, runtime.AppVersion)
|
|
fmt.Println("Usage:")
|
|
fmt.Printf(" %s [--help] [--version]\n\n", filepath.Base(os.Args[0]))
|
|
fmt.Println("CHORUS Autonomous Agent - P2P Task Coordination")
|
|
fmt.Println()
|
|
fmt.Println("This binary runs autonomous AI agents that participate in P2P task coordination,")
|
|
fmt.Println("collaborative reasoning via HMMM, and distributed decision making.")
|
|
fmt.Println()
|
|
fmt.Println("Environment (common):")
|
|
fmt.Println(" CHORUS_LICENSE_ID (required)")
|
|
fmt.Println(" CHORUS_AGENT_ID (optional; auto-generated if empty)")
|
|
fmt.Println(" CHORUS_P2P_PORT (default 9000)")
|
|
fmt.Println(" CHORUS_API_PORT (default 8080)")
|
|
fmt.Println(" CHORUS_HEALTH_PORT (default 8081)")
|
|
fmt.Println(" CHORUS_DHT_ENABLED (default true)")
|
|
fmt.Println(" CHORUS_BOOTSTRAP_PEERS (comma-separated multiaddrs)")
|
|
fmt.Println(" OLLAMA_ENDPOINT (default http://localhost:11434)")
|
|
fmt.Println()
|
|
fmt.Println("Example:")
|
|
fmt.Println(" CHORUS_LICENSE_ID=dev-123 \\")
|
|
fmt.Println(" CHORUS_AGENT_ID=chorus-agent-1 \\")
|
|
fmt.Println(" CHORUS_P2P_PORT=9000 CHORUS_API_PORT=8080 ./chorus-agent")
|
|
fmt.Println()
|
|
fmt.Println("Agent Features:")
|
|
fmt.Println(" - Autonomous task execution")
|
|
fmt.Println(" - P2P mesh networking")
|
|
fmt.Println(" - HMMM collaborative reasoning")
|
|
fmt.Println(" - DHT encrypted storage")
|
|
fmt.Println(" - UCXL context addressing")
|
|
fmt.Println(" - Democratic leader election")
|
|
fmt.Println(" - Health monitoring")
|
|
return
|
|
case "--version", "-v":
|
|
fmt.Printf("%s-agent %s\n", runtime.AppName, runtime.AppVersion)
|
|
return
|
|
}
|
|
}
|
|
|
|
// Initialize shared P2P runtime
|
|
sharedRuntime, err := runtime.Initialize("agent")
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ Failed to initialize CHORUS agent: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
defer sharedRuntime.Cleanup()
|
|
|
|
// Start agent mode with autonomous behaviors
|
|
if err := sharedRuntime.StartAgentMode(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "❌ Agent mode failed: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
} |