aibridged
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
const (InternalMCPServerID = "coder")Variables¶
var (ErrNoAuthKey =xerrors.New("no authentication key provided")ErrConnect =xerrors.New("could not connect to coderd")ErrUnauthorized =xerrors.New("unauthorized")ErrAcquireRequestHandler =xerrors.New("failed to acquire request handler"))
var (ErrEmptyConfig =xerrors.New("empty config given")ErrCompileRegex =xerrors.New("compile tool regex"))
var DefaultPoolOptions =PoolOptions{MaxItems: 100, TTL:time.Minute * 15}Functions¶
funcExtractAuthToken¶
ExtractAuthToken extracts authorization token from HTTP request using multiple sources.These sources represent the different ways clients authenticate against AI providers.It checks the Authorization header (Bearer token) and X-Api-Key header.If neither are present, an empty string is returned.
Types¶
typeCachedBridgePool¶
type CachedBridgePool struct {// contains filtered or unexported fields}funcNewCachedBridgePool¶
func NewCachedBridgePool(optionsPoolOptions, providers []aibridge.Provider, loggerslog.Logger) (*CachedBridgePool,error)
func (*CachedBridgePool)Acquire¶
func (p *CachedBridgePool) Acquire(ctxcontext.Context, reqRequest, clientFnClientFunc, mcpProxyFactoryMCPProxyBuilder) (http.Handler,error)
Acquire retrieves or creates a*aibridge.RequestBridge instance per given key.
Each returned*aibridge.RequestBridge is safe for concurrent use.Each*aibridge.RequestBridge is stateful because it has MCP clients which maintain sessions to the configured MCP server.
func (*CachedBridgePool)Metrics¶
func (p *CachedBridgePool) Metrics()PoolMetrics
typeClient¶
type Client struct {proto.DRPCRecorderClientproto.DRPCMCPConfiguratorClientproto.DRPCAuthorizerClientConndrpc.Conn}typeClientFunc¶
type ClientFunc func() (DRPCClient,error)
typeDRPCClient¶
type DRPCClient interface {proto.DRPCRecorderClientproto.DRPCMCPConfiguratorClientproto.DRPCAuthorizerClient}DRPCClient is the union of various service interfaces the client must support.
typeDRPCServer¶
type DRPCServer interface {proto.DRPCRecorderServerproto.DRPCMCPConfiguratorServerproto.DRPCAuthorizerServer}typeMCPProxyBuilder¶
type MCPProxyBuilder interface {// Build creates a [mcp.ServerProxier] for the given request initiator.// At minimum, the Coder MCP server will be proxied.// The SessionKey from [Request] is used to authenticate against the Coder MCP server.//// NOTE: the [mcp.ServerProxier] instance may be proxying one or more MCP servers.Build(ctxcontext.Context, reqRequest) (mcp.ServerProxier,error)}typeMCPProxyFactory¶
type MCPProxyFactory struct {// contains filtered or unexported fields}funcNewMCPProxyFactory¶
func NewMCPProxyFactory(loggerslog.Logger, clientFnClientFunc) *MCPProxyFactory
func (*MCPProxyFactory)Build¶
func (m *MCPProxyFactory) Build(ctxcontext.Context, reqRequest) (mcp.ServerProxier,error)
typePoolMetrics¶
typePoolOptions¶
typePooler¶
type Pooler interface {Acquire(ctxcontext.Context, reqRequest, clientFnClientFunc, mcpBootstrapperMCPProxyBuilder) (http.Handler,error)Shutdown(ctxcontext.Context)error}Pooler describes a pool of*aibridge.RequestBridge instances from which instances can be retrieved.One*aibridge.RequestBridge instance is created per given key.
typeServer¶
type Server struct {// contains filtered or unexported fields}Server provides the AI Bridge functionality.It is responsible for:
- receiving requests on /api/v2/aibridged/*
- manipulating the requests
- relaying requests to upstream AI services and relaying responses to caller
It requires aDialer to provide aDRPCClient implementation tocommunicate with aDRPCServer implementation, to persist state and perform other functions.
func (*Server)Client¶
func (s *Server) Client() (DRPCClient,error)
func (*Server)GetRequestHandler¶
GetRequestHandler retrieves a (possibly reused)*aibridge.RequestBridge from the pool, for the given user.
func (*Server)ServeHTTP¶
func (s *Server) ServeHTTP(rwhttp.ResponseWriter, r *http.Request)
ServeHTTP is the entrypoint for requests which will be intercepted by AI Bridge.This function will validate that the given API key may be used to perform the request.
Anaibridge.RequestBridge instance is acquired from a pool based on the API key'sowner (referred to as the "initiator"); this instance is responsible for theAI Bridge-specific handling of the request.
ADRPCClient is provided to theaibridge.RequestBridge instance so that data canbe passed up to aDRPCServer for persistence.
Source Files¶
Directories¶
| Path | Synopsis |
|---|---|
Package aibridgedmock is a generated GoMock package. | Package aibridgedmock is a generated GoMock package. |