mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
Transforms hanzoai/agents from a marketplace config repo into a full agent orchestration platform by merging the AgentField infrastructure: - Go control plane (K8s-like agent orchestration, service mesh, DAG workflows) - Python SDK (FastAPI-based agent framework, LiteLLM, memory, DID/VC) - TypeScript SDK (@hanzo/agents - Vercel AI SDK, MCP, workflows) - Go SDK (idiomatic agent builder + client) - React 19 embedded dashboard (XyFlow DAGs, Recharts, Radix UI) - Docker/K8s/Helm deployment configs - Examples: hello world, deep research, RAG, simulation, benchmarks - Functional test suite across Python/Go/TypeScript All references rebranded: AgentField → Hanzo Agents - Module: github.com/hanzoai/agents/control-plane - Python: hanzo_agents - TypeScript: @hanzo/agents - Go: github.com/hanzoai/agents/sdk/go - Env vars: HANZO_AGENTS_* - Config: hanzo-agents.yaml Previous marketplace configs moved to config/ directory.
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package utils
|
|
|
|
import (
|
|
cryptoRand "crypto/rand"
|
|
"fmt"
|
|
mathrand "math/rand"
|
|
"time"
|
|
)
|
|
|
|
// GenerateWorkflowID generates a new workflow ID
|
|
func GenerateWorkflowID() string {
|
|
timestamp := time.Now().Format("20060102_150405")
|
|
random := generateRandomString(8)
|
|
return fmt.Sprintf("wf_%s_%s", timestamp, random)
|
|
}
|
|
|
|
// GenerateExecutionID generates a new execution ID
|
|
func GenerateExecutionID() string {
|
|
timestamp := time.Now().Format("20060102_150405")
|
|
random := generateRandomString(8)
|
|
return fmt.Sprintf("exec_%s_%s", timestamp, random)
|
|
}
|
|
|
|
// GenerateRunID generates a new workflow run ID.
|
|
func GenerateRunID() string {
|
|
timestamp := time.Now().Format("20060102_150405")
|
|
random := generateRandomString(8)
|
|
return fmt.Sprintf("run_%s_%s", timestamp, random)
|
|
}
|
|
|
|
// GenerateHanzoAgentsRequestID generates a new hanzo-agents request ID
|
|
func GenerateHanzoAgentsRequestID() string {
|
|
timestamp := time.Now().Format("20060102_150405")
|
|
random := generateRandomString(8)
|
|
return fmt.Sprintf("req_%s_%s", timestamp, random)
|
|
}
|
|
|
|
// ValidateWorkflowID validates a workflow ID format
|
|
func ValidateWorkflowID(workflowID string) bool {
|
|
// Basic validation - can be enhanced later
|
|
return len(workflowID) > 0 && len(workflowID) <= 255
|
|
}
|
|
|
|
// generateRandomString generates a random string of specified length
|
|
func generateRandomString(length int) string {
|
|
const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
|
|
b := make([]byte, length)
|
|
if _, err := cryptoRand.Read(b); err != nil {
|
|
// Fallback to pseudo-random source if crypto source is unavailable.
|
|
src := mathrand.New(mathrand.NewSource(time.Now().UnixNano()))
|
|
for i := range b {
|
|
b[i] = charset[src.Intn(len(charset))]
|
|
}
|
|
return string(b)
|
|
}
|
|
for i := range b {
|
|
b[i] = charset[b[i]%byte(len(charset))]
|
|
}
|
|
return string(b)
|
|
}
|