mirror of
https://github.com/hanzoai/agents.git
synced 2026-10-30 18:48:36 +00:00
The admin control surface was the last gRPC/protobuf in the control plane. Replace it end to end with the native ZAP stack — no protobuf, no gRPC, no build-tag dance. Schema + wire: - proto/admin/reasoner_admin.zap: the AdminReasoner interface as a .zap schema (text fields; param-less listReasoners since ZAP rejects an empty struct). - pkg/adminwire: zapgen output — zero-copy New<Msg>/Wrap<Msg>, the bytes are the message, no marshal step. Server: - internal/server/server_admin.go: transport.Serve over the ZAP transport. Capability auth carries the API key in each request's Cap field, checked in constant time (crypto/subtle) — an upgrade over the deleted gRPC path, which compared with ==, a timing oracle. - H-1 hardening: with no API key configured the surface is unauthenticated, so it binds loopback only (adminBindHost) and is unreachable off-box; a keyed surface binds all interfaces. Reachability and authentication are decided separately, not entangled. - server.go: the adminTransport/UnimplementedServer gRPC scaffolding drops out for a *transport.Server. Removed: - google.golang.org/grpc, the direct google.golang.org/protobuf dependency, pkg/adminpb (the generated .pb.go + grpc stub), the grpc_auth middleware, server_grpc.go / server_zap.go, and the dead `replace operator => ../`. Tests (all pass): adminwire round-trip over real TCP and Unix sockets with all seven Reasoner fields intact, unknown-ordinal rejection, the five authorize cases, and the loopback-bind decision.
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
// Code generated by zapgen; DO NOT EDIT.
|
|
// source: reasoner_admin.zap
|
|
|
|
package admin
|
|
|
|
import (
|
|
zap "github.com/zap-proto/go"
|
|
)
|
|
|
|
const (
|
|
reasonerReasonerIdOff = 0
|
|
reasonerAgentNodeIdOff = 8
|
|
reasonerNameOff = 16
|
|
reasonerDescriptionOff = 24
|
|
reasonerStatusOff = 32
|
|
reasonerNodeVersionOff = 40
|
|
reasonerLastHeartbeatOff = 48
|
|
reasonerSize = 56
|
|
)
|
|
|
|
// Reasoner is a zero-copy view into a ZAP-encoded Reasoner message.
|
|
type Reasoner struct{ o zap.Object }
|
|
|
|
// WrapReasoner parses b and returns a typed view. Returns an error if the
|
|
// wire-level checks (magic, version, size) fail.
|
|
func WrapReasoner(b []byte) (Reasoner, error) {
|
|
m, err := zap.Parse(b)
|
|
if err != nil {
|
|
return Reasoner{}, err
|
|
}
|
|
return Reasoner{o: m.Root()}, nil
|
|
}
|
|
|
|
func (t Reasoner) ReasonerId() string { return t.o.Text(reasonerReasonerIdOff) }
|
|
func (t Reasoner) AgentNodeId() string { return t.o.Text(reasonerAgentNodeIdOff) }
|
|
func (t Reasoner) Name() string { return t.o.Text(reasonerNameOff) }
|
|
func (t Reasoner) Description() string { return t.o.Text(reasonerDescriptionOff) }
|
|
func (t Reasoner) Status() string { return t.o.Text(reasonerStatusOff) }
|
|
func (t Reasoner) NodeVersion() string { return t.o.Text(reasonerNodeVersionOff) }
|
|
func (t Reasoner) LastHeartbeat() string { return t.o.Text(reasonerLastHeartbeatOff) }
|
|
|
|
// ReasonerInput collects the field values for NewReasoner.
|
|
type ReasonerInput struct {
|
|
ReasonerId string
|
|
AgentNodeId string
|
|
Name string
|
|
Description string
|
|
Status string
|
|
NodeVersion string
|
|
LastHeartbeat string
|
|
}
|
|
|
|
// NewReasoner builds a ZAP-encoded Reasoner message from in and returns the bytes.
|
|
func NewReasoner(in ReasonerInput) []byte {
|
|
b := zap.NewBuilder(256)
|
|
ob := b.StartObject(reasonerSize)
|
|
ob.SetText(reasonerReasonerIdOff, in.ReasonerId)
|
|
ob.SetText(reasonerAgentNodeIdOff, in.AgentNodeId)
|
|
ob.SetText(reasonerNameOff, in.Name)
|
|
ob.SetText(reasonerDescriptionOff, in.Description)
|
|
ob.SetText(reasonerStatusOff, in.Status)
|
|
ob.SetText(reasonerNodeVersionOff, in.NodeVersion)
|
|
ob.SetText(reasonerLastHeartbeatOff, in.LastHeartbeat)
|
|
ob.FinishAsRoot()
|
|
return b.Finish()
|
|
}
|