servers

package
v0.0.0-...-15b348c Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 8 Imported by: ? 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 servers is what agentop's `server` subcommand and its TUI share about the inference-router: the entry's name, the check every write passes, how a server is shown, and which server a host belongs to.

A package of its own because the subcommands live in package main, which the tui package cannot import, and because the generic writer in edit must stay generic: it knows nothing about any plugin, so the router's rules cannot live there. Two copies of Verify would be two answers to "may agentop write this", and the proxy only accepts one.

Index

Constants

View Source
const PluginName = "inference-router"

PluginName is the inference-router plugin's registered name: the outbound entry every server write reads and changes.

Variables

This section is empty.

Functions

func AgentChanges

func AgentChanges(agent, server string) []edit.ConfigChange

AgentChanges routes agent's new sessions to server, or stops routing it when server is "": the changes `agentop server use`, `agentop server reset` and the TUI's S picker make. ONE AGENT'S SPELLINGS AND NOTHING ELSE: a removal for every spelling the agent ever had — so a retired one ("bob-shell" beside "bob") cannot sit beside the canonical key and fold back into routing once it is gone — plus, when routing, the one set of the canonical key.

PER-KEY, NOT A WHOLE-MAP REPLACEMENT, deliberately: the write must not depend on a snapshot of the agents: map, or a concurrent write for a different agent — a shell `server use` while the TUI's picker is open, its view up to a poll stale — is silently reverted. Per-key changes touch only this agent's spellings, so sibling keys, their order and their comments survive byte for byte, and a removal of a spelling the file does not name is a no-op.

agent is the agent to change, itself canonical — callers fold the name they were given.

func ForHost

func ForHost(c routerconfig.Config, hostport string) (name string, ok bool)

ForHost is the server whose host hostport names, compared as the plugin matches a request. ok is false for a host no server has, and for "".

With two servers on one host, ForHost returns the first name in sorted order. To name a session's server, use ForSession.

func ForSession

func ForSession(c routerconfig.Config, s session.SessionSummary) (name string, ok bool)

ForSession is the server of session s. It is s.InferenceServer when the config has a server of that name. Else it is ForHost of s.InferenceHost: that fallback is for a proxy that does not send inferenceServer, and for a name that the config no longer has.

func Host

func Host(s routerconfig.Server) string

Host is how a server's URL is shown: its host, or the whole URL for plain http, so a server whose traffic crosses the network unencrypted says so.

A URL the router refuses shows nothing of itself, not even its host: the likeliest reason it is refused is a pasted key, and a key given as a username that contains '/', '?' or '#' ends the authority early, so url.Parse takes the key for the host (https://sk-.../x@gw.example parses with Host "sk-..."). No parentheses either: `server add` already puts this in some.

func Inactive

func Inactive(policy pipeline.ErrorPolicy, file string) string

Inactive is why a router entry under policy, its on_error, routes nothing, or "" when it routes. Under observe the router redirects nothing and records observe/would_route where it would have routed; under off it does not run. Either way a server given to an agent changes no traffic, and whatever said the agent's sessions now go there would be wrong. file is the config file as the caller shows it, for the fix; whether the result is "" does not depend on it.

One wording for `agentop server`, which reads the policy off the file, and the TUI's S, which reads it off /v1/pipeline, so the two say the same thing about the same router.

func KeyRouteChanges

func KeyRouteChanges(from, to string) []edit.ConfigChange

KeyRouteChanges sends the new sessions that send server from's key to server to: the change `agentop server use --key-of` and `agentop server reset --key-of` make. Per-key, for the same reason AgentChanges is. When to is "" or from, the change removes the entry: a key goes to its own server with no entry. A removal of an entry that the file does not have is a no-op.

func Mapping

func Mapping(s routerconfig.Server) string

Mapping is a server's main and helper words in one phrase, as the config gives them; what each resolves to is the server's list's to say.

func PruneSessions

func PruneSessions(cfg routerconfig.Config, live map[string]bool) []edit.ConfigChange

PruneSessions is the removals for every sessions: override whose session is neither live nor archived — inert config a move left behind. The caller decides liveness; a nil or empty set means nothing can be seen dead, and nothing is pruned: a live session must never lose its override to a blind prune.

func SessionChanges

func SessionChanges(session, server string) []edit.ConfigChange

SessionChanges is the config write that moves one session to server, "" to stop routing it: the changes `agentop server move` and the TUI's S picker on a session row make. Unlike AgentChanges there are no retired spellings to fold: a session id is opaque. Per-key, for the same reason AgentChanges is.

"" IS A VALUE, NOT A REMOVAL: the entry must stay, because the session's pin would otherwise route it right back — the pin the move (or the routing the user is undoing) settled. The entry is inert once the pin matches it.

func Verify

func Verify(cfg *config.Config) error

Verify is the check every write of the router's config makes of its result: the router entry must pass the plugin's own validation, so agentop never writes a config the proxy will refuse to reload. It is edit.ConfigWrite.Verify for every caller.

Types

This section is empty.

Jump to

Keyboard shortcuts

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