Documentation
¶
Index ¶
- Constants
- Variables
- type Server
- func (s *Server) GetMCPServerAccessTokensBatch(ctx context.Context, in *proto.GetMCPServerAccessTokensBatchRequest) (*proto.GetMCPServerAccessTokensBatchResponse, error)
- func (s *Server) GetMCPServerConfigs(_ context.Context, _ *proto.GetMCPServerConfigsRequest) (*proto.GetMCPServerConfigsResponse, error)
- func (s *Server) IsAuthorized(ctx context.Context, in *proto.IsAuthorizedRequest) (*proto.IsAuthorizedResponse, error)
- func (s *Server) RecordInterception(ctx context.Context, in *proto.RecordInterceptionRequest) (*proto.RecordInterceptionResponse, error)
- func (s *Server) RecordInterceptionEnded(ctx context.Context, in *proto.RecordInterceptionEndedRequest) (*proto.RecordInterceptionEndedResponse, error)
- func (s *Server) RecordModelThought(ctx context.Context, in *proto.RecordModelThoughtRequest) (*proto.RecordModelThoughtResponse, error)
- func (s *Server) RecordPromptUsage(ctx context.Context, in *proto.RecordPromptUsageRequest) (*proto.RecordPromptUsageResponse, error)
- func (s *Server) RecordTokenUsage(ctx context.Context, in *proto.RecordTokenUsageRequest) (*proto.RecordTokenUsageResponse, error)
- func (s *Server) RecordToolUsage(ctx context.Context, in *proto.RecordToolUsageRequest) (*proto.RecordToolUsageResponse, error)
Constants ¶
View Source
const ( InterceptionLogMarker = "interception log" MetadataUserAgentKey = "request_user_agent" )
Variables ¶
View Source
var ( ErrExpiredOrInvalidOAuthToken = xerrors.New("expired or invalid OAuth2 token") ErrNoMCPConfigFound = xerrors.New("no MCP config found") // These errors are returned by IsAuthorized. Since they're just returned as // a generic dRPC error, it's difficult to tell them apart without string // matching. // TODO: return these errors to the client in a more structured/comparable // way. ErrInvalidKey = xerrors.New("invalid key") ErrUnknownKey = xerrors.New("unknown key") ErrExpired = xerrors.New("expired") ErrUnknownUser = xerrors.New("unknown user") ErrDeletedUser = xerrors.New("deleted user") ErrSystemUser = xerrors.New("system user") ErrNoExternalAuthLinkFound = xerrors.New("no external auth link found") )
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(lifecycleCtx context.Context, store store, logger slog.Logger, accessURL string, bridgeCfg codersdk.AIBridgeConfig, externalAuthConfigs []*externalauth.Config, experiments codersdk.Experiments, aiSeatTracker aiseats.SeatTracker, ) (*Server, error)
func (*Server) GetMCPServerAccessTokensBatch ¶
func (s *Server) GetMCPServerAccessTokensBatch(ctx context.Context, in *proto.GetMCPServerAccessTokensBatchRequest) (*proto.GetMCPServerAccessTokensBatchResponse, error)
func (*Server) GetMCPServerConfigs ¶
func (s *Server) GetMCPServerConfigs(_ context.Context, _ *proto.GetMCPServerConfigsRequest) (*proto.GetMCPServerConfigsResponse, error)
func (*Server) IsAuthorized ¶
func (s *Server) IsAuthorized(ctx context.Context, in *proto.IsAuthorizedRequest) (*proto.IsAuthorizedResponse, error)
IsAuthorized validates a given Coder API key and returns the user ID to which it belongs (if valid).
NOTE: this should really be using the code from httpmw.ExtractAPIKey. That function not only validates the key but handles many other cases like updating last used, expiry, etc. This code does not currently use it for a few reasons:
- httpmw.ExtractAPIKey relies on keys being given in specific headers httpmw.APITokenFromRequest which AI bridge requests will not conform to.
- The code mixes many different concerns, and handles HTTP responses too, which is undesirable here.
- The core logic would need to be extracted, but that will surely be a complex & time-consuming distraction right now.
- Once we have an Early Access release of AI Bridge, we need to return to this.
TODO: replace with logic from httpmw.ExtractAPIKey.
func (*Server) RecordInterception ¶
func (s *Server) RecordInterception(ctx context.Context, in *proto.RecordInterceptionRequest) (*proto.RecordInterceptionResponse, error)
func (*Server) RecordInterceptionEnded ¶
func (s *Server) RecordInterceptionEnded(ctx context.Context, in *proto.RecordInterceptionEndedRequest) (*proto.RecordInterceptionEndedResponse, error)
func (*Server) RecordModelThought ¶ added in v2.32.0
func (s *Server) RecordModelThought(ctx context.Context, in *proto.RecordModelThoughtRequest) (*proto.RecordModelThoughtResponse, error)
func (*Server) RecordPromptUsage ¶
func (s *Server) RecordPromptUsage(ctx context.Context, in *proto.RecordPromptUsageRequest) (*proto.RecordPromptUsageResponse, error)
func (*Server) RecordTokenUsage ¶
func (s *Server) RecordTokenUsage(ctx context.Context, in *proto.RecordTokenUsageRequest) (*proto.RecordTokenUsageResponse, error)
func (*Server) RecordToolUsage ¶
func (s *Server) RecordToolUsage(ctx context.Context, in *proto.RecordToolUsageRequest) (*proto.RecordToolUsageResponse, error)
Click to show internal directories.
Click to hide internal directories.