aibridgedserver

package
v2.33.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

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) IsAuthorized

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:

  1. httpmw.ExtractAPIKey relies on keys being given in specific headers httpmw.APITokenFromRequest which AI bridge requests will not conform to.
  2. The code mixes many different concerns, and handles HTTP responses too, which is undesirable here.
  3. The core logic would need to be extracted, but that will surely be a complex & time-consuming distraction right now.
  4. 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) RecordModelThought added in v2.32.0

func (*Server) RecordTokenUsage

func (*Server) RecordToolUsage

Jump to

Keyboard shortcuts

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