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
- func AgentChanges(agent, server string) []edit.ConfigChange
- func ForHost(c routerconfig.Config, hostport string) (name string, ok bool)
- func ForSession(c routerconfig.Config, s session.SessionSummary) (name string, ok bool)
- func Host(s routerconfig.Server) string
- func Inactive(policy pipeline.ErrorPolicy, file string) string
- func KeyRouteChanges(from, to string) []edit.ConfigChange
- func Mapping(s routerconfig.Server) string
- func PruneSessions(cfg routerconfig.Config, live map[string]bool) []edit.ConfigChange
- func SessionChanges(session, server string) []edit.ConfigChange
- func Verify(cfg *config.Config) error
Constants ¶
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.
Types ¶
This section is empty.