backend

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package backend is the engine-side HTTP client for everything the engine needs from fh-backend: agent registration, log ingestion, LLM chat, RAG queries. All requests authenticate with the engine's agent secret via the Agent-Key header (validated by the backend's AgentKeyAuth middleware).

Index

Constants

View Source
const (
	// BootCallbackTimeout caps the one-shot boot callback HTTP call so a
	// single unreachable backend cannot wedge engine startup.
	BootCallbackTimeout = 10 * time.Second
	// RegisterRetryInterval is the wait between failed Register attempts
	// when the backend is unreachable at engine startup.
	RegisterRetryInterval = 30 * time.Second
	// ProviderLoadTimeout caps the one-shot /llm/providers fetch used to
	// discover backend-routed LLM fallbacks at engine startup.
	ProviderLoadTimeout = 10 * time.Second
	// HeartbeatInterval is the cadence at which HeartbeatLoop ticks. Sized
	// at one third of the backend's 90s online-threshold so a single missed
	// tick does not flip the agent to offline.
	HeartbeatInterval = 30 * time.Second
	// HeartbeatTimeout caps a single heartbeat HTTP call so a hung attempt
	// cannot wedge the loop.
	HeartbeatTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func NewBackendProvider

func NewBackendProvider(c *Client, id llmproxy.ProviderID, models []llmproxy.ModelInfo) llmproxy.Provider

NewBackendProvider creates a backendRoutedProvider for the given provider ID and model list.

Types

type Client

type Client struct {
	BackendURL  string
	AgentSecret string
	// contains filtered or unexported fields
}

Client is the engine-side HTTP client for backend interactions. All requests carry the Agent-Key authorization header.

func NewClient

func NewClient(backendURL, agentSecret string) *Client

NewClient constructs a Client backed by the shared httpclient.

func (*Client) Chat

Chat forwards a chat request through the backend's /llm/generate route. The backend dispatches it to whichever underlying provider owns the model.

func (*Client) GetProviders

func (c *Client) GetProviders(ctx context.Context) ([]llmproxy.ProviderInfo, error)

GetProviders fetches the list of LLM providers configured on the backend and the models they expose. Used by the engine to decide which upstream providers it can fall back to via the backend.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health pings the backend's LLM service and returns nil if every configured provider on the backend is healthy.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, publicAddress string) error

Heartbeat performs a single POST /agents/heartbeat. The publicAddress is the externally reachable URL of this engine, e.g. "http://10.0.1.50:8081", or "" for Cloud-mode engines behind NAT.

func (*Client) Hydrate added in v1.0.2

func (c *Client) Hydrate(ctx context.Context) ([]workflow.MemoryFile, error)

Hydrate pulls every memory file owned by the calling agent. The Manager calls this on a cold start to seed an empty local working copy.

func (*Client) Push added in v1.0.2

func (c *Client) Push(ctx context.Context, uid, content string) error

Push mirrors new content for the memory file identified by uid to the backend. The Manager calls this best-effort after every local write. The backend rejects unknown uids (404) and oversized payloads (413).

func (*Client) QueryRAG

func (c *Client) QueryRAG(ctx context.Context, params engine.RAGQueryParams) ([]engine.RAGQueryResult, error)

QueryRAG forwards a similarity-search query through the backend's /rag/query route and returns the ranked results.

func (*Client) Register

func (c *Client) Register(ctx context.Context, reg engine.AgentRegistration) error

Register performs a single POST /agents/bootCallback. reg.Address is the externally reachable URL of this engine and may be empty for Cloud-mode engines behind NAT. reg.Manifest may be nil and reg.Error populated only when reg.Status is StatusBootError.

Directories

Path Synopsis
internal
httpclient
Package httpclient is a minimal JSON HTTP client vendored into the engine so the fh-backend capability implementation has no dependency on the closed fh-backend module.
Package httpclient is a minimal JSON HTTP client vendored into the engine so the fh-backend capability implementation has no dependency on the closed fh-backend module.

Jump to

Keyboard shortcuts

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