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.
38 lines
1013 B
Go
38 lines
1013 B
Go
package storage
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"log"
|
|
"strings"
|
|
)
|
|
|
|
// safeJSONRawMessage safely creates a json.RawMessage from a potentially corrupted string
|
|
// It validates the JSON and provides a safe fallback if the data is corrupted
|
|
func safeJSONRawMessage(data string, fallback string, context string) json.RawMessage {
|
|
if data == "" {
|
|
return json.RawMessage(fallback)
|
|
}
|
|
|
|
// Validate JSON before creating RawMessage
|
|
if json.Valid([]byte(data)) {
|
|
return json.RawMessage(data)
|
|
}
|
|
|
|
// Log corruption warning with context
|
|
log.Printf("WARNING: Corrupted JSON data detected in %s, using fallback. Data preview: %.100s", context, data)
|
|
|
|
// Return safe fallback with error indication
|
|
errorFallback := fmt.Sprintf(`{"error": "corrupted_json_data", "context": "%s", "preview": "%s"}`,
|
|
context, strings.ReplaceAll(data[:min(50, len(data))], `"`, `\"`))
|
|
return json.RawMessage(errorFallback)
|
|
}
|
|
|
|
// min returns the minimum of two integers
|
|
func min(a, b int) int {
|
|
if a < b {
|
|
return a
|
|
}
|
|
return b
|
|
}
|