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.
81 lines
1.8 KiB
Go
81 lines
1.8 KiB
Go
// hanzo-agents/internal/infrastructure/storage/registry.go
|
|
package storage
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/hanzoai/agents/control-plane/internal/core/domain"
|
|
"github.com/hanzoai/agents/control-plane/internal/core/interfaces"
|
|
)
|
|
|
|
type LocalRegistryStorage struct {
|
|
fs interfaces.FileSystemAdapter
|
|
storePath string
|
|
}
|
|
|
|
func NewLocalRegistryStorage(fs interfaces.FileSystemAdapter, path string) interfaces.RegistryStorage {
|
|
return &LocalRegistryStorage{
|
|
fs: fs,
|
|
storePath: path,
|
|
}
|
|
}
|
|
|
|
func (s *LocalRegistryStorage) LoadRegistry() (*domain.InstallationRegistry, error) {
|
|
if !s.fs.Exists(s.storePath) {
|
|
return &domain.InstallationRegistry{
|
|
Installed: make(map[string]domain.InstalledPackage),
|
|
}, nil
|
|
}
|
|
|
|
data, err := s.fs.ReadFile(s.storePath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var registry domain.InstallationRegistry
|
|
if err := json.Unmarshal(data, ®istry); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ®istry, nil
|
|
}
|
|
|
|
func (s *LocalRegistryStorage) SaveRegistry(registry *domain.InstallationRegistry) error {
|
|
data, err := json.MarshalIndent(registry, "", " ")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.MkdirAll(filepath.Dir(s.storePath), 0755); err != nil {
|
|
return err
|
|
}
|
|
|
|
return s.fs.WriteFile(s.storePath, data)
|
|
}
|
|
|
|
func (s *LocalRegistryStorage) GetPackage(name string) (*domain.InstalledPackage, error) {
|
|
registry, err := s.LoadRegistry()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
pkg, exists := registry.Installed[name]
|
|
if !exists {
|
|
return nil, os.ErrNotExist
|
|
}
|
|
|
|
return &pkg, nil
|
|
}
|
|
|
|
func (s *LocalRegistryStorage) SavePackage(name string, pkg *domain.InstalledPackage) error {
|
|
registry, err := s.LoadRegistry()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
registry.Installed[name] = *pkg
|
|
return s.SaveRegistry(registry)
|
|
}
|