nodeagent

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ExposeNone        = "none"        // the operator supplies --endpoint
	ExposeCloudflared = "cloudflared" // gateway on localhost behind a quick tunnel
)

How the node becomes reachable by the proxy.

View Source
const DefaultEngineURL = "http://127.0.0.1:11434"

DefaultEngineURL is Ollama's default listen address.

Variables

This section is empty.

Functions

func FilterModels

func FilterModels(models []*pb.NodeModelSpec, allow []string) []*pb.NodeModelSpec

FilterModels keeps only the allowed models; an empty allow list keeps all. An engine shared with other tools would otherwise advertise models this node must not serve.

func Render

func Render(w io.Writer, findings []Finding) (problems int)

Render prints the findings and returns how many are problems.

func ResolveURLs

func ResolveURLs(engineURL, endpoint string) (poll, report string)

ResolveURLs returns the engine URL to poll and the endpoint to report. With only endpoint set, polling uses it too, as before --engine-url existed.

func TagJudgeModels

func TagJudgeModels(models []*pb.NodeModelSpec, judgeModels []string) []*pb.NodeModelSpec

TagJudgeModels ensures models in judge list declare the "judge" capability.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(cfg AgentConfig) *Agent

func (*Agent) Run

func (a *Agent) Run(ctx context.Context) error

type AgentConfig

type AgentConfig struct {
	ProxyAddr      string
	TLS            bool // dial ProxyAddr over TLS with system roots, e.g. a load balancer on :443
	NodeKey        string
	NodeID         string
	NodeName       string
	EngineURL      string // where the agent itself polls the engine; local, never reported
	Endpoint       string // address the proxy dials, as reported at registration
	Engine         string
	NodeAuthToken  string   // bearer the proxy presents to Endpoint; replaced by a generated key when exposing
	EngineToken    string   // bearer the engine itself requires, if any
	OnlyModels     []string // when set, report only these engine models
	JudgeModels    []string // models to tag with capability "judge"
	Expose         string   // ExposeNone or ExposeCloudflared
	CloudflaredBin string
	BaseWeight     float64
	MaxConcurrent  uint32
}

type DecisionsInspector

type DecisionsInspector struct{}

DecisionsInspector inspects engines serving decision models (/v1/decisions).

func (*DecisionsInspector) Inspect

func (di *DecisionsInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

type Doctor

type Doctor struct {
	Cfg   AgentConfig
	Model string // the model this node should serve; empty = any

	// Seams for tests; zero values use the real thing.
	HTTP       *http.Client
	DialTCP    func(ctx context.Context, addr string) error
	UsesProxy  func(addr string) bool // true when HTTPS_PROXY or similar routes addr; gRPC honors it, a raw dial does not
	LookPath   func(name string) (string, error)
	RunCmd     func(ctx context.Context, name string, args ...string) error
	MachOArchs func(path string) ([]string, error)
	GOOS       string
	GOARCH     string
}

Doctor explains why a node is not (or is badly) serving. It sends one Heartbeat for a made-up node id, which the proxy answers without storing.

func (*Doctor) Run

func (d *Doctor) Run(ctx context.Context) []Finding

Run executes every check. A failed check never stops the later ones.

type EngineInspector

type EngineInspector interface {
	Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
}

func GetInspector

func GetInspector(engine string) EngineInspector

type EngineLoad added in v0.13.1

type EngineLoad struct {
	Running uint32
	Waiting uint32
}

EngineLoad is the engine's own view of its work: requests it is generating and requests it has accepted but not started. The proxy adds Waiting to its queue estimate, so a node busy with other clients is not overbooked.

type Finding

type Finding struct {
	Check   string
	Level   Level
	Message string
	Fix     string
}

Finding is one line of the report, in plain language, with what to do next.

type GPUStats

type GPUStats struct {
	TotalVRAMMB uint64
	FreeVRAMMB  uint64
	UtilPercent float64
	TempC       uint32
	ModelName   string
}

func ReadNvidiaSMI

func ReadNvidiaSMI(ctx context.Context) (*GPUStats, error)

ReadNvidiaSMI parses `nvidia-smi --query-gpu=memory.total,memory.free,utilization.gpu,temperature.gpu,name --format=csv,noheader,nounits`

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway is the only door to the engine that the proxy gets: a bearer check plus an allowlist of the routes it needs (/v1/chat/completions, /v1/decisions, /v1/models). Everything else (pull, delete, engine admin APIs) is unreachable.

func NewGateway

func NewGateway(engineURL, accessKey, engineToken string) *Gateway

NewGateway forwards to the engine at engineURL. accessKey is what callers must present; engineToken, if any, is what the engine itself expects.

func (*Gateway) ServeHTTP

func (g *Gateway) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GenericOpenAIInspector

type GenericOpenAIInspector struct{}

Generic OpenAI Inspector

func (*GenericOpenAIInspector) Inspect

func (goi *GenericOpenAIInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

type Level

type Level int

Level ranks a finding. Only a problem makes the doctor exit non-zero.

const (
	LevelOK Level = iota
	LevelWarn
	LevelProblem
)

type LlamaCppInspector

type LlamaCppInspector struct{}

LlamaCpp Inspector

func (*LlamaCppInspector) Inspect

func (li *LlamaCppInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

func (*LlamaCppInspector) Load added in v0.13.1

func (li *LlamaCppInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)

type LoadProber added in v0.13.1

type LoadProber interface {
	Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)
}

LoadProber is implemented by inspectors whose engine publishes its queue. Ollama has no such API.

type OllamaInspector

type OllamaInspector struct{}

Ollama Inspector

func (*OllamaInspector) Inspect

func (oi *OllamaInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

type TGIInspector

type TGIInspector struct{}

TGI Inspector

func (*TGIInspector) Inspect

func (ti *TGIInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

func (*TGIInspector) Load added in v0.13.1

func (ti *TGIInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)

type VLLMInspector

type VLLMInspector struct{}

vLLM Inspector

func (*VLLMInspector) Inspect

func (vi *VLLMInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)

func (*VLLMInspector) Load added in v0.13.1

func (vi *VLLMInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL