accelclient

package
v0.206.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 14 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

Overview

Package accelclient calls an accelerator's HTTP sidecar over loopback — the Hailo-8L's (server/http_server.py in the Hailo repo) and the Coral Edge TPU's (accelerators/coral/server.py here), which speak one wire contract. It is the harness's accelerator lane (ADR 0024): LOCAL and free like llama-swap, never cloud — but a separate device with its own process, so it gets its own client rather than riding the OpenAI shape. Mirrors nimclient: pure net/http, no SDK, a result is a map the caller shapes.

It was `hailoclient` until the second device arrived (Coral design D2): the package held nothing Hailo-specific but its name and error strings, so it was renamed and given a Device label rather than copied into a second package that would diverge from day one.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSidecarCmd = errors.New("sidecar not running and no launcher configured (hailo_sidecar_cmd / coral_sidecar_cmd / rknpu_sidecar_cmd)")

ErrNoSidecarCmd: the sidecar is down and this box has no way to start it (no <device>_sidecar_cmd configured). One sentinel for every device — callers compare identity, and the device is on the wrapping error's prefix.

Functions

func SpawnCmd

func SpawnCmd(cmdPath string, idleSec int) func() error

SpawnCmd launches the configured launcher DETACHED (Start, not Run — the sidecar outlives this call and exits on its own idle timer) with no console window. The idle window is passed through so config is the single source.

Types

type Client

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

Client targets one sidecar base (scheme://host:port, no path) for one device.

func New

func New(base string, timeout time.Duration) *Client

New builds a Hailo-8L client — the original constructor, kept so the Hailo path and its tests are unchanged. timeout bounds ONE call including a cold HEF load.

func NewDevice

func NewDevice(device, base string, timeout time.Duration) *Client

NewDevice builds a client for the named accelerator (an id from config.Accelerators, e.g. "hailo-8l", "coral-edgetpu"). The label is carried on every error so a defer reads "<device>: ..." whichever lane produced it.

func (*Client) Base

func (c *Client) Base() string

Base is the configured endpoint, for status reporting.

func (*Client) Call

func (c *Client) Call(ctx context.Context, tool string, args map[string]any) (map[string]any, error)

Call POSTs args to /v1/<tool> and returns the tool's dict. A 200 carrying {"error":true,...} is a STRUCTURED RESULT (the tool refused the input), so it comes back as the map with a nil error — the MCP handler passes it through verbatim. Only transport failures and non-200 statuses are errors.

func (*Client) Device

func (c *Client) Device() string

Device is the accelerator id this client speaks for.

func (*Client) Health

func (c *Client) Health(ctx context.Context) (map[string]any, error)

Health returns the sidecar's /health dict (hailo_status() on the Hailo sidecar; {enabled, device, status, temp_c, loaded, ...} on the Coral one). An unreachable sidecar is an error — the caller decides whether to spawn it (Sidecar.Ensure) or defer.

type Sidecar

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

Sidecar starts the HTTP sidecar ON DEMAND (operator decision 2026-08-22: no scheduler, no always-on service — the sidecar self-exits idle, the harness brings it back when needed). Ensure is the single entry point every NPU tool calls first; concurrent callers share one spawn.

func NewSidecar

func NewSidecar(c *Client, spawn func() error, startTimeout time.Duration) *Sidecar

NewSidecar wires a client to a spawn function (nil = cannot spawn).

func (*Sidecar) Client

func (s *Sidecar) Client() *Client

Client returns the wired client, for callers that hold only the Sidecar.

func (*Sidecar) Ensure

func (s *Sidecar) Ensure(ctx context.Context) error

Ensure returns nil once /health answers. Down + spawnable → spawn once and poll until startTimeout; down + not spawnable → ErrNoSidecarCmd.

Jump to

Keyboard shortcuts

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