 aea4d45fd8
			
		
	
	aea4d45fd8
	
	
	
		
			
			🎭 Phase 2: HAP Terminal Interface Implementation ✅ **Core Terminal Interface**: Interactive command-driven HAP terminal with help system ✅ **HMMM Message Composition System**: - New reasoning messages, thread replies, network queries, decision proposals - Complete message metadata handling (topics, threads, timestamps) ✅ **UCXL Context Browsing System**: - Address parsing, content retrieval from DHT encrypted storage - Search functionality, content creation, history navigation ✅ **Decision Participation System**: - Active decision listing, decision details with voting status - Vote casting with reasoning, decision proposals, HMMM integration 🔧 Phase 3: Enhanced Human Workflows ✅ **Patch Creation and Submission Workflows**: - Complete patch lifecycle management (create, review, submit, track) - Multiple patch types (context, code, config, docs) - UCXL integration with DHT storage, HMMM coordination ✅ **Time-Travel Diff Support**: - Temporal navigation operators (~~<n>, ^^<n>, @<time>) - Decision-hop analysis, visual diff display, version comparison 🏗️ **Architecture Highlights**: - **Multi-binary structure**: Separate chorus-agent and chorus-hap binaries - **Shared P2P runtime**: Both binaries use identical libp2p, DHT, HMMM, UCXL systems - **Interactive sub-shells**: Dedicated command environments for HMMM, UCXL, patches, decisions - **Network integration**: All features connect to distributed P2P agent network - **Human-agent parity**: Humans participate as first-class network citizens 📦 **New Files**: - internal/hapui/terminal.go: Complete HAP terminal interface (2400+ lines) - prompts/human-roles.yaml: Role-based prompt configuration - docs/decisions/*: HAP conversion decision record 🔗 **Integration Points**: - HMMM: Collaborative reasoning and patch/decision announcements - UCXL: Context addressing and version management - DHT: Distributed storage of patches and content - Decision System: Formal approval and consensus workflows The HAP terminal interface now provides comprehensive human portal into the CHORUS autonomous agent network, enabling collaborative reasoning, context sharing, patch management, and distributed decision-making between humans and AI agents. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			126 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			126 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 	"path/filepath"
 | |
| 
 | |
| 	"chorus/internal/hapui"
 | |
| 	"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-hap %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 Human Agent Portal - Human Interface to P2P Agent Networks")
 | |
| 			fmt.Println()
 | |
| 			fmt.Println("This binary provides a human-friendly interface to participate in P2P agent")
 | |
| 			fmt.Println("coordination networks. Humans can collaborate with autonomous agents using")
 | |
| 			fmt.Println("the same protocols and appear as peers in the distributed network.")
 | |
| 			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("HAP-Specific Environment:")
 | |
| 			fmt.Println("  CHORUS_HAP_MODE                (terminal|web, default terminal)")
 | |
| 			fmt.Println("  CHORUS_HAP_WEB_PORT            (default 8082)")
 | |
| 			fmt.Println()
 | |
| 			fmt.Println("Example:")
 | |
| 			fmt.Println("  CHORUS_LICENSE_ID=dev-123 \\")
 | |
| 			fmt.Println("  CHORUS_AGENT_ID=human-alice \\")
 | |
| 			fmt.Println("  CHORUS_HAP_MODE=terminal \\")
 | |
| 			fmt.Println("  CHORUS_P2P_PORT=9001 ./chorus-hap")
 | |
| 			fmt.Println()
 | |
| 			fmt.Println("HAP Features:")
 | |
| 			fmt.Println("  - Human-friendly message composition")
 | |
| 			fmt.Println("  - HMMM reasoning template helpers")
 | |
| 			fmt.Println("  - UCXL context browsing")
 | |
| 			fmt.Println("  - Collaborative decision participation")
 | |
| 			fmt.Println("  - Terminal and web interface modes")
 | |
| 			fmt.Println("  - Same P2P protocols as autonomous agents")
 | |
| 			return
 | |
| 		case "--version", "-v":
 | |
| 			fmt.Printf("%s-hap %s\n", runtime.AppName, runtime.AppVersion)
 | |
| 			return
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	// Initialize shared P2P runtime (same as agent)
 | |
| 	sharedRuntime, err := runtime.Initialize("hap")
 | |
| 	if err != nil {
 | |
| 		fmt.Fprintf(os.Stderr, "❌ Failed to initialize CHORUS HAP: %v\n", err)
 | |
| 		os.Exit(1)
 | |
| 	}
 | |
| 	defer sharedRuntime.Cleanup()
 | |
| 
 | |
| 	// Start HAP mode with human interface
 | |
| 	if err := startHAPMode(sharedRuntime); err != nil {
 | |
| 		fmt.Fprintf(os.Stderr, "❌ HAP mode failed: %v\n", err)
 | |
| 		os.Exit(1)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // startHAPMode runs the Human Agent Portal with interactive interface
 | |
| func startHAPMode(runtime *runtime.SharedRuntime) error {
 | |
| 	runtime.Logger.Info("👤 Starting CHORUS Human Agent Portal (HAP)")
 | |
| 	runtime.Logger.Info("🔗 Connected to P2P network as human agent")
 | |
| 	runtime.Logger.Info("📝 Ready for collaborative reasoning and decision making")
 | |
| 
 | |
| 	// Get HAP mode from environment (terminal or web)
 | |
| 	hapMode := os.Getenv("CHORUS_HAP_MODE")
 | |
| 	if hapMode == "" {
 | |
| 		hapMode = "terminal"
 | |
| 	}
 | |
| 
 | |
| 	switch hapMode {
 | |
| 	case "terminal":
 | |
| 		return startTerminalInterface(runtime)
 | |
| 	case "web":
 | |
| 		return startWebInterface(runtime)
 | |
| 	default:
 | |
| 		return fmt.Errorf("unknown HAP mode: %s (valid: terminal, web)", hapMode)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // startTerminalInterface provides a terminal-based human interface
 | |
| func startTerminalInterface(runtime *runtime.SharedRuntime) error {
 | |
| 	runtime.Logger.Info("💻 Starting terminal interface for human interaction")
 | |
| 	
 | |
| 	// Create and start the HAP terminal interface
 | |
| 	terminal := hapui.NewTerminalInterface(runtime)
 | |
| 	
 | |
| 	runtime.Logger.Info("🎯 Human agent terminal interface ready")
 | |
| 	
 | |
| 	// Start the interactive terminal
 | |
| 	return terminal.Start()
 | |
| }
 | |
| 
 | |
| // startWebInterface provides a web-based human interface  
 | |
| func startWebInterface(runtime *runtime.SharedRuntime) error {
 | |
| 	runtime.Logger.Info("🌐 Starting web interface for human interaction")
 | |
| 	
 | |
| 	// TODO Phase 3: Implement web interface
 | |
| 	// - HTTP server with WebSocket for real-time updates
 | |
| 	// - Web forms for HMMM message composition
 | |
| 	// - Context browser UI
 | |
| 	// - Decision voting interface
 | |
| 	
 | |
| 	runtime.Logger.Info("⚠️ Web interface not yet implemented")
 | |
| 	runtime.Logger.Info("🔄 HAP running in stub mode - P2P connectivity established")
 | |
| 	runtime.Logger.Info("📍 Next: Implement Phase 3 web interface")
 | |
| 
 | |
| 	// For now, fall back to terminal mode
 | |
| 	return startTerminalInterface(runtime)
 | |
| } |