Files
zeekayandGitHub 5b5cf9e9db feat: merge AgentField control plane + SDKs as Hanzo Agents (#1)
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.
2026-02-09 18:53:09 -08:00

93 lines
2.0 KiB
Go

package services
import (
"bytes"
"context"
"crypto/sha256"
"encoding/hex"
"io"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestFilePayloadStoreLifecycle(t *testing.T) {
t.Parallel()
ctx := context.Background()
store := NewFilePayloadStore(t.TempDir())
original := []byte("hello world")
record, err := store.SaveFromReader(ctx, bytes.NewReader(original))
require.NoError(t, err)
require.NotNil(t, record)
require.Greater(t, record.Size, int64(0))
require.True(t, strings.HasPrefix(record.URI, payloadURIPrefix))
sum := sha256.Sum256(original)
require.Equal(t, hex.EncodeToString(sum[:]), record.SHA256)
rc, err := store.Open(ctx, record.URI)
require.NoError(t, err)
data, err := io.ReadAll(rc)
require.NoError(t, err)
require.Equal(t, original, data)
require.NoError(t, rc.Close())
require.NoError(t, store.Remove(ctx, record.URI))
require.NoError(t, store.Remove(ctx, record.URI))
_, err = store.Open(ctx, record.URI)
require.Error(t, err)
}
func TestFilePayloadStoreSaveBytes(t *testing.T) {
t.Parallel()
ctx := context.Background()
store := NewFilePayloadStore(t.TempDir())
record, err := store.SaveBytes(ctx, []byte("abc"))
require.NoError(t, err)
require.Equal(t, int64(3), record.Size)
}
func TestFilePayloadStoreErrors(t *testing.T) {
t.Parallel()
ctx := context.Background()
store := NewFilePayloadStore(t.TempDir())
_, err := store.SaveFromReader(ctx, nil)
require.Error(t, err)
_, err = store.Open(ctx, "invalid://uri")
require.Error(t, err)
}
func TestCopyWithContextCancels(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
pr, pw := io.Pipe()
go func() {
defer pw.Close()
buf := bytes.Repeat([]byte("a"), 1024)
for i := 0; i < 4; i++ {
if _, err := pw.Write(buf); err != nil {
return
}
time.Sleep(5 * time.Millisecond)
if i == 1 {
cancel()
}
}
}()
err := copyWithContext(ctx, io.Discard, pr)
require.ErrorIs(t, err, context.Canceled)
}