Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountPool ¶
type AccountPool interface {
PickCandidates() []*cursor_account_sdk.Account
EnsureAccess(ctx context.Context, id string) (*cursor_account_sdk.Account, error)
MarkUsed(id string)
MarkRateLimited(id string)
}
AccountPool is the account rotation surface Server needs. *account_pool.Pool satisfies this interface.
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []cursor_api_sdk.ChatMessage `json:"messages"`
Stream bool `json:"stream"`
Tools []cursor_api_sdk.OpenAIToolDef `json:"tools,omitempty"`
}
ChatCompletionRequest is the OpenAI chat completions body we accept.
type CompletionsRequest ¶
type CompletionsRequest struct {
Model string `json:"model"`
Prompt any `json:"prompt"`
Stream bool `json:"stream"`
}
CompletionsRequest is the legacy OpenAI text completions shape.
type Server ¶
type Server struct {
Pool AccountPool
API UpstreamAPI
Log *slog.Logger
MaxBody int64
// contains filtered or unexported fields
}
Server holds shared dependencies for OpenAI handlers.
func NewServer ¶
func NewServer(pool *account_pool.Pool, api *cursor_api_sdk.Client, log *slog.Logger) *Server
NewServer wires a concrete pool and API client for handlers / CLI reuse.
func (*Server) ListModels ¶
ListModels returns the cached catalog when fresh; otherwise fetches via the account pool.
type UpstreamAPI ¶
type UpstreamAPI interface {
CachedModels() []cursor_api_sdk.Model
ListModels(ctx context.Context, accessToken string) ([]cursor_api_sdk.Model, error)
ResolveModelSelection(ctx context.Context, accessToken, modelID string) (cursor_api_sdk.ModelSelection, error)
StartRun(ctx context.Context, accessToken string, payload *cursor_api_sdk.RunPayload, bridgeTools bool) (*cursor_api_sdk.RunControl, error)
}
UpstreamAPI is the Cursor upstream surface Server needs. *cursor_api_sdk.Client satisfies this interface.
Click to show internal directories.
Click to hide internal directories.