Complete BZZZ functionality port to CHORUS
🎭 CHORUS now contains full BZZZ functionality adapted for containers Core systems ported: - P2P networking (libp2p with DHT and PubSub) - Task coordination (COOEE protocol) - HMMM collaborative reasoning - SHHH encryption and security - SLURP admin election system - UCXL content addressing - UCXI server integration - Hypercore logging system - Health monitoring and graceful shutdown - License validation with KACHING Container adaptations: - Environment variable configuration (no YAML files) - Container-optimized logging to stdout/stderr - Auto-generated agent IDs for container deployments - Docker-first architecture All proven BZZZ P2P protocols, AI integration, and collaboration features are now available in containerized form. Next: Build and test container deployment. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
79
pkg/web/embed.go
Normal file
79
pkg/web/embed.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Static files embedded at build time
|
||||
//go:embed static
|
||||
//go:embed static/_next
|
||||
//go:embed static/_next/static
|
||||
//go:embed static/_next/static/css
|
||||
//go:embed static/_next/static/chunks
|
||||
var staticFiles embed.FS
|
||||
|
||||
// GetWebUIHandler returns HTTP handler for embedded web UI
|
||||
func GetWebUIHandler() http.Handler {
|
||||
// Use the embedded files directly (no static subdirectory)
|
||||
staticFS := staticFiles
|
||||
_, err := staticFiles.ReadFile("static/index.html")
|
||||
if err != nil {
|
||||
// Fallback to empty filesystem if no static files
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>BZZZ Setup</title></head>
|
||||
<body>
|
||||
<h1>BZZZ Setup</h1>
|
||||
<p>Web UI not yet built. Please build the React app first.</p>
|
||||
<p>Run: <code>cd install/config-ui && npm run build</code></p>
|
||||
</body>
|
||||
</html>
|
||||
`))
|
||||
})
|
||||
}
|
||||
|
||||
return http.FileServer(http.FS(staticFS))
|
||||
}
|
||||
|
||||
// IsEmbeddedFileAvailable checks if a file exists in the embedded filesystem
|
||||
func IsEmbeddedFileAvailable(path string) bool {
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
if path == "" {
|
||||
path = "index.html"
|
||||
}
|
||||
_, err := staticFiles.ReadFile("static/" + path)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// ServeEmbeddedFile serves a file from the embedded filesystem
|
||||
func ServeEmbeddedFile(w http.ResponseWriter, r *http.Request, path string) {
|
||||
path = strings.TrimPrefix(path, "/")
|
||||
if path == "" {
|
||||
path = "index.html"
|
||||
}
|
||||
|
||||
content, err := staticFiles.ReadFile("static/" + path)
|
||||
if err != nil {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// Set content type based on file extension
|
||||
contentType := "text/html"
|
||||
if strings.HasSuffix(path, ".js") {
|
||||
contentType = "application/javascript"
|
||||
} else if strings.HasSuffix(path, ".css") {
|
||||
contentType = "text/css"
|
||||
} else if strings.HasSuffix(path, ".json") {
|
||||
contentType = "application/json"
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", contentType)
|
||||
w.Write(content)
|
||||
}
|
||||
Reference in New Issue
Block a user