Documentation
¶
Index ¶
- Variables
- func DecodeStoredAgentRouteConfig(data []byte) (any, error)
- func GenerateRouteID(prefix, serviceID, pathPrefix string) string
- func ValidateRouteID(id string) error
- type AgentRouteConfig
- type AgentRouteConfigManager
- func (m *AgentRouteConfigManager) Create(ctx context.Context, route AgentRouteConfig, tag string) error
- func (m *AgentRouteConfigManager) Delete(ctx context.Context, routeID string) error
- func (m *AgentRouteConfigManager) Get(ctx context.Context, routeID string) (AgentRouteConfig, error)
- func (m *AgentRouteConfigManager) InitStaticRoutes(routes []AgentRouteConfig)
- func (m *AgentRouteConfigManager) IsStatic(routeID string) bool
- func (m *AgentRouteConfigManager) List(ctx context.Context, opts RouteListOptions) ([]AgentRouteConfig, error)
- func (m *AgentRouteConfigManager) Match(ctx context.Context, r *http.Request) (AgentRouteConfig, bool, error)
- func (m *AgentRouteConfigManager) Refresh(ctx context.Context) error
- func (m *AgentRouteConfigManager) Reset()
- func (m *AgentRouteConfigManager) Update(ctx context.Context, routeID string, route AgentRouteConfig) error
- type RouteAuthPolicy
- type RouteKind
- type RouteListOptions
- type RouteMatchPolicy
- type RouteProtocol
- type RouteTargetPolicyKind
Constants ¶
This section is empty.
Variables ¶
var ( ErrRouteNotConfigured = errors.New("route is not configured") ErrStaticRouteReadOnly = errors.New("static route is read-only") )
var ErrInvalidRouteID = errors.New("invalid route id")
ErrInvalidRouteID marks a route id that cannot be addressed as a single Admin API path segment. It is a client-correctable input error; callers should map it to a 400, not a 500.
Functions ¶
func GenerateRouteID ¶ added in v0.4.1
GenerateRouteID builds a deterministic, slash-free route id of the form "<prefix>:<service_id>:<path-slug>".
The id is fully predictable from (prefix, serviceID, pathPrefix) so callers can compute it by hand and cross-reference a route before it is applied (e.g. in a virtual key's allowed_route_ids). prefix is the protocol tag (e.g. "acp" or "mcp"). Both prefix and serviceID are assumed slash-free (service ids are already constrained to a single Admin API path segment); ValidateRouteID guards the final result regardless.
Because no disambiguating suffix is appended, two routes on the same service whose path prefixes slugify to the same value collide on id; that collision surfaces as a duplicate-id error at create/validate time, at which point the operator sets an explicit id.
func ValidateRouteID ¶ added in v0.4.1
ValidateRouteID rejects route ids that cannot be addressed as a single Admin API path segment. Route ids are used verbatim in "/admin/<proto>/routes/{id}", so a slash (raw or escaped) would break GET/PUT/DELETE routing.
Types ¶
type AgentRouteConfig ¶
type AgentRouteConfig struct {
ID string `json:"id"`
Kind RouteKind `json:"kind"`
Protocol RouteProtocol `json:"protocol"`
Description string `json:"description,omitempty"`
Disabled bool `json:"disabled"`
AuthPolicy RouteAuthPolicy `json:"auth_policy"`
MatchPolicy RouteMatchPolicy `json:"match_policy"`
TargetPolicy json.RawMessage `json:"target_policy"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func MatchManagers ¶
func MatchManagers(ctx context.Context, r *http.Request, managers ...*AgentRouteConfigManager) (AgentRouteConfig, bool, error)
func MatchRouteConfigs ¶
func MatchRouteConfigs(routes []AgentRouteConfig, r *http.Request) (AgentRouteConfig, bool)
func (AgentRouteConfig) Fingerprint ¶ added in v0.3.0
func (c AgentRouteConfig) Fingerprint() string
Fingerprint returns a cheap version string for the route config used as the runtime resolver materializer key. UpdatedAt is bumped on every Create/Update, so it changes whenever the stored config changes. This is a secondary cache signal only: the route resolvers also explicitly Invalidate on every mutation, so the fingerprint exists to self-heal any resolver that missed invalidation. Avoid marshaling the whole config here; this runs on every matched request.
type AgentRouteConfigManager ¶
type AgentRouteConfigManager struct {
// contains filtered or unexported fields
}
func NewAgentRouteConfigManager ¶
func NewAgentRouteConfigManager(store configstore.ConfigStore) *AgentRouteConfigManager
func (*AgentRouteConfigManager) Create ¶
func (m *AgentRouteConfigManager) Create(ctx context.Context, route AgentRouteConfig, tag string) error
func (*AgentRouteConfigManager) Delete ¶
func (m *AgentRouteConfigManager) Delete(ctx context.Context, routeID string) error
func (*AgentRouteConfigManager) Get ¶
func (m *AgentRouteConfigManager) Get(ctx context.Context, routeID string) (AgentRouteConfig, error)
func (*AgentRouteConfigManager) InitStaticRoutes ¶
func (m *AgentRouteConfigManager) InitStaticRoutes(routes []AgentRouteConfig)
func (*AgentRouteConfigManager) IsStatic ¶
func (m *AgentRouteConfigManager) IsStatic(routeID string) bool
func (*AgentRouteConfigManager) List ¶
func (m *AgentRouteConfigManager) List(ctx context.Context, opts RouteListOptions) ([]AgentRouteConfig, error)
func (*AgentRouteConfigManager) Match ¶
func (m *AgentRouteConfigManager) Match(ctx context.Context, r *http.Request) (AgentRouteConfig, bool, error)
Match resolves the most specific route config whose MatchPolicy accepts the request.
func (*AgentRouteConfigManager) Refresh ¶ added in v0.3.0
func (m *AgentRouteConfigManager) Refresh(ctx context.Context) error
func (*AgentRouteConfigManager) Reset ¶
func (m *AgentRouteConfigManager) Reset()
func (*AgentRouteConfigManager) Update ¶
func (m *AgentRouteConfigManager) Update(ctx context.Context, routeID string, route AgentRouteConfig) error
type RouteAuthPolicy ¶
type RouteAuthPolicy struct {
RequireVirtualKey bool `json:"require_virtual_key"`
}
type RouteListOptions ¶
type RouteMatchPolicy ¶
type RouteMatchPolicy struct {
Host string `json:"host,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
Methods []string `json:"methods,omitempty"`
}
RouteMatchPolicy contains transport-facing match fields for binding requests to a route.
type RouteProtocol ¶
type RouteProtocol string
const ( RouteProtocolOpenAI RouteProtocol = "openai" RouteProtocolAnthropic RouteProtocol = "anthropic" RouteProtocolCC RouteProtocol = "cc" RouteProtocolMCP RouteProtocol = "mcp" RouteProtocolACP RouteProtocol = "acp" )
type RouteTargetPolicyKind ¶
type RouteTargetPolicyKind string
const ( RouteTargetPolicyKindDirectProvider RouteTargetPolicyKind = "direct-provider" RouteTargetPolicyKindLogicalModel RouteTargetPolicyKind = "logical-model" RouteTargetPolicyKindMCPService RouteTargetPolicyKind = "mcp-service" RouteTargetPolicyKindACPService RouteTargetPolicyKind = "acp-service" )