server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 20 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 server wires configuration into a running HTTP gateway: it builds the adapters, the router and the API frontends, and owns the listener.

Index

Constants

View Source
const ProbeTimeout = 30 * time.Second

ProbeTimeout bounds the health check of a single backend at startup, so one wedged CLI cannot hold up the listener.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is the agent2api HTTP gateway.

func New

func New(cfg *config.Config, log *slog.Logger) (*Server, error)

New builds the gateway. Backends are auto-detected: each configured CLI is probed, and the ones that are installed and logged in start serving. The rest are reported in Server.Skipped rather than failing startup, so the gateway runs with whatever this machine happens to have.

func (*Server) Addr

func (s *Server) Addr() string

Addr is the address the gateway binds to.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler exposes the fully wired HTTP handler, for tests.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe runs the gateway until ctx is canceled, then drains in-flight requests before returning.

func (*Server) Router

func (s *Server) Router() *router.Router

Router exposes the model router, for `doctor` and tests.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, ln net.Listener) error

Serve runs the gateway on an existing listener.

func (*Server) Skipped

func (s *Server) Skipped() []Skipped

Skipped lists adapters that were configured but are not being served.

type Skipped

type Skipped struct {
	ID     string
	Reason string
}

Skipped records a backend that was configured but is not being served — almost always a CLI that is not installed or not logged in on this machine.

func BuildAdapters

func BuildAdapters(ctx context.Context, cfg *config.Config, log *slog.Logger) ([]adapter.Adapter, []Skipped, error)

BuildAdapters instantiates the backends this machine can actually serve.

Every configured adapter is probed. A probe failure is a skip, not an error: having only some of these CLIs installed is the normal case, and a gateway that refuses to start because Cursor is absent would be useless. Startup only fails when nothing at all is usable, which New reports.

Jump to

Keyboard shortcuts

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