Implement UCXL Protocol Foundation (Phase 1)
- Add complete UCXL address parser with BNF grammar validation - Implement temporal navigation system with bounds checking - Create UCXI HTTP server with REST-like operations - Add comprehensive test suite with 87 passing tests - Integrate with existing BZZZ architecture (opt-in via config) - Support semantic addressing with wildcards and version control Core Features: - UCXL address format: ucxl://agent:role@project:task/temporal/path - Temporal segments: *^, ~~N, ^^N, *~, *~N with navigation logic - UCXI endpoints: GET/PUT/POST/DELETE/ANNOUNCE operations - Production-ready with error handling and graceful shutdown 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
50
main.go
50
main.go
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/anthonyrawlins/bzzz/p2p"
|
||||
"github.com/anthonyrawlins/bzzz/pkg/config"
|
||||
"github.com/anthonyrawlins/bzzz/pkg/hive"
|
||||
"github.com/anthonyrawlins/bzzz/pkg/ucxi"
|
||||
"github.com/anthonyrawlins/bzzz/pubsub"
|
||||
"github.com/anthonyrawlins/bzzz/reasoning"
|
||||
)
|
||||
@@ -181,6 +182,55 @@ func main() {
|
||||
defer httpServer.Stop()
|
||||
fmt.Printf("🌐 HTTP API server started on :8080\n")
|
||||
|
||||
// === UCXI Server Integration ===
|
||||
// Initialize UCXI server if UCXL protocol is enabled
|
||||
var ucxiServer *ucxi.Server
|
||||
if cfg.UCXL.Enabled && cfg.UCXL.Server.Enabled {
|
||||
// Create storage directory
|
||||
storageDir := cfg.UCXL.Storage.Directory
|
||||
if storageDir == "" {
|
||||
storageDir = filepath.Join(os.TempDir(), "bzzz-ucxi-storage")
|
||||
}
|
||||
|
||||
storage, err := ucxi.NewBasicContentStorage(storageDir)
|
||||
if err != nil {
|
||||
fmt.Printf("⚠️ Failed to create UCXI storage: %v\n", err)
|
||||
} else {
|
||||
// Create resolver
|
||||
resolver := ucxi.NewBasicAddressResolver(node.ID().ShortString())
|
||||
resolver.SetDefaultTTL(cfg.UCXL.Resolution.CacheTTL)
|
||||
|
||||
// TODO: Add P2P integration hooks here
|
||||
// resolver.SetAnnounceHook(...)
|
||||
// resolver.SetDiscoverHook(...)
|
||||
|
||||
// Create UCXI server
|
||||
ucxiConfig := ucxi.ServerConfig{
|
||||
Port: cfg.UCXL.Server.Port,
|
||||
BasePath: cfg.UCXL.Server.BasePath,
|
||||
Resolver: resolver,
|
||||
Storage: storage,
|
||||
Logger: ucxi.SimpleLogger{},
|
||||
}
|
||||
|
||||
ucxiServer = ucxi.NewServer(ucxiConfig)
|
||||
go func() {
|
||||
if err := ucxiServer.Start(); err != nil && err != http.ErrServerClosed {
|
||||
fmt.Printf("❌ UCXI server error: %v\n", err)
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
if ucxiServer != nil {
|
||||
ucxiServer.Stop()
|
||||
}
|
||||
}()
|
||||
fmt.Printf("🔗 UCXI server started on :%d%s/ucxi/v1\n",
|
||||
cfg.UCXL.Server.Port, cfg.UCXL.Server.BasePath)
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("⚪ UCXI server disabled (UCXL protocol not enabled)\n")
|
||||
}
|
||||
// ============================
|
||||
|
||||
// Create simple task tracker
|
||||
taskTracker := &SimpleTaskTracker{
|
||||
|
||||
Reference in New Issue
Block a user