Files
bzzz/examples/sdk/go/simple-client.go
anthonyrawlins ee6bb09511 Complete Phase 2B documentation suite and implementation
🎉 MAJOR MILESTONE: Complete BZZZ Phase 2B documentation and core implementation

## Documentation Suite (7,000+ lines)
-  User Manual: Comprehensive guide with practical examples
-  API Reference: Complete REST API documentation
-  SDK Documentation: Multi-language SDK guide (Go, Python, JS, Rust)
-  Developer Guide: Development setup and contribution procedures
-  Architecture Documentation: Detailed system design with ASCII diagrams
-  Technical Report: Performance analysis and benchmarks
-  Security Documentation: Comprehensive security model
-  Operations Guide: Production deployment and monitoring
-  Documentation Index: Cross-referenced navigation system

## SDK Examples & Integration
- 🔧 Go SDK: Simple client, event streaming, crypto operations
- 🐍 Python SDK: Async client with comprehensive examples
- 📜 JavaScript SDK: Collaborative agent implementation
- 🦀 Rust SDK: High-performance monitoring system
- 📖 Multi-language README with setup instructions

## Core Implementation
- 🔐 Age encryption implementation (pkg/crypto/age_crypto.go)
- 🗂️ Shamir secret sharing (pkg/crypto/shamir.go)
- 💾 DHT encrypted storage (pkg/dht/encrypted_storage.go)
- 📤 UCXL decision publisher (pkg/ucxl/decision_publisher.go)
- 🔄 Updated main.go with Phase 2B integration

## Project Organization
- 📂 Moved legacy docs to old-docs/ directory
- 🎯 Comprehensive README.md update with modern structure
- 🔗 Full cross-reference system between all documentation
- 📊 Production-ready deployment procedures

## Quality Assurance
-  All documentation cross-referenced and validated
-  Working code examples in multiple languages
-  Production deployment procedures tested
-  Security best practices implemented
-  Performance benchmarks documented

Ready for production deployment and community adoption.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-08 19:57:40 +10:00

105 lines
3.0 KiB
Go

package main
import (
"context"
"fmt"
"log"
"time"
"github.com/anthonyrawlins/bzzz/sdk/bzzz"
"github.com/anthonyrawlins/bzzz/sdk/decisions"
)
// Simple BZZZ SDK client example
// Shows basic connection, status checks, and decision publishing
func main() {
fmt.Println("🚀 BZZZ SDK Simple Client Example")
// Create context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
// Initialize BZZZ client
client, err := bzzz.NewClient(bzzz.Config{
Endpoint: "http://localhost:8080",
Role: "backend_developer",
Timeout: 30 * time.Second,
})
if err != nil {
log.Fatalf("Failed to create BZZZ client: %v", err)
}
defer client.Close()
// Get and display agent status
status, err := client.GetStatus(ctx)
if err != nil {
log.Fatalf("Failed to get status: %v", err)
}
fmt.Printf("✅ Connected to BZZZ node\n")
fmt.Printf(" Node ID: %s\n", status.NodeID)
fmt.Printf(" Agent ID: %s\n", status.AgentID)
fmt.Printf(" Role: %s\n", status.Role)
fmt.Printf(" Authority Level: %s\n", status.AuthorityLevel)
fmt.Printf(" Can decrypt: %v\n", status.CanDecrypt)
fmt.Printf(" Active tasks: %d/%d\n", status.ActiveTasks, status.MaxTasks)
// Create decisions client
decisionsClient := decisions.NewClient(client)
// Publish a simple code decision
fmt.Println("\n📝 Publishing code decision...")
err = decisionsClient.PublishCode(ctx, decisions.CodeDecision{
Task: "implement_simple_client",
Decision: "Created a simple BZZZ SDK client example",
FilesModified: []string{"examples/sdk/go/simple-client.go"},
LinesChanged: 75,
TestResults: &decisions.TestResults{
Passed: 3,
Failed: 0,
Coverage: 100.0,
},
Dependencies: []string{
"github.com/anthonyrawlins/bzzz/sdk/bzzz",
"github.com/anthonyrawlins/bzzz/sdk/decisions",
},
Language: "go",
})
if err != nil {
log.Fatalf("Failed to publish decision: %v", err)
}
fmt.Println("✅ Decision published successfully")
// Get connected peers
fmt.Println("\n🌐 Getting connected peers...")
peers, err := client.GetPeers(ctx)
if err != nil {
log.Printf("Warning: Failed to get peers: %v", err)
} else {
fmt.Printf(" Connected peers: %d\n", len(peers.ConnectedPeers))
for _, peer := range peers.ConnectedPeers {
fmt.Printf(" - %s (%s) - %s\n", peer.AgentID, peer.Role, peer.AuthorityLevel)
}
}
// Query recent decisions
fmt.Println("\n📊 Querying recent decisions...")
recent, err := decisionsClient.QueryRecent(ctx, decisions.QueryRequest{
Role: "backend_developer",
Limit: 5,
Since: time.Now().Add(-24 * time.Hour),
})
if err != nil {
log.Printf("Warning: Failed to query decisions: %v", err)
} else {
fmt.Printf(" Found %d recent decisions\n", len(recent.Decisions))
for i, decision := range recent.Decisions {
if i < 3 { // Show first 3
fmt.Printf(" - %s: %s\n", decision.Task, decision.Decision)
}
}
}
fmt.Println("\n✅ Simple client example completed successfully")
}