githubcopilot

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package githubcopilot adapts GitHub Copilot's compatible text endpoints to sigma.

Index

Constants

View Source
const (
	DefaultBaseURL = "https://api.individual.githubcopilot.com"
)

Variables

This section is empty.

Functions

func GitHubCopilotBaseURL added in v0.6.0

func GitHubCopilotBaseURL(token string, enterpriseDomain string) string

GitHubCopilotBaseURL returns the Copilot API base URL implied by a token or enterprise domain.

func ProviderAuth added in v0.6.0

ProviderAuth returns GitHub Copilot API-key and OAuth auth descriptors.

func Register

func Register(registry *sigma.Registry, opts ...ProviderOption) error

Register adds a GitHub Copilot Chat Completions provider to registry.

func RegisterAnthropic

func RegisterAnthropic(registry *sigma.Registry, opts ...AnthropicProviderOption) error

RegisterAnthropic adds a GitHub Copilot Anthropic-compatible provider to registry.

func RegisterAuth added in v0.6.0

func RegisterAuth(registry *sigma.Registry, opts GitHubCopilotOAuthTokenProviderOptions, registerOpts ...sigma.RegisterOption) error

RegisterAuth registers GitHub Copilot auth descriptors on registry.

func RegisterDefault

func RegisterDefault(opts ...ProviderOption) error

RegisterDefault adds a GitHub Copilot Chat Completions provider to sigma's default registry.

func RegisterDefaultAnthropic

func RegisterDefaultAnthropic(opts ...AnthropicProviderOption) error

RegisterDefaultAnthropic adds a GitHub Copilot Anthropic-compatible provider to sigma's default registry.

func RegisterDefaultAuth added in v0.6.0

func RegisterDefaultAuth(opts GitHubCopilotOAuthTokenProviderOptions, registerOpts ...sigma.RegisterOption) error

RegisterDefaultAuth registers GitHub Copilot auth descriptors on the default registry.

func RegisterResponses

func RegisterResponses(registry *sigma.Registry, opts ...ProviderOption) error

RegisterResponses adds a GitHub Copilot Responses provider to registry.

func RegisterResponsesDefault

func RegisterResponsesDefault(opts ...ProviderOption) error

RegisterResponsesDefault adds a GitHub Copilot Responses provider to sigma's default registry.

Types

type AnthropicProvider

type AnthropicProvider = anthropic.Provider

AnthropicProvider adapts GitHub Copilot's Anthropic-compatible Messages endpoint.

func NewAnthropicProvider

func NewAnthropicProvider(opts ...AnthropicProviderOption) *AnthropicProvider

NewAnthropicProvider constructs a GitHub Copilot Anthropic-compatible provider.

type AnthropicProviderOption

type AnthropicProviderOption = anthropic.ProviderOption

AnthropicProviderOption configures an AnthropicProvider.

func WithAnthropicBaseURL

func WithAnthropicBaseURL(baseURL string) AnthropicProviderOption

WithAnthropicBaseURL configures the Anthropic-compatible provider base URL.

func WithAnthropicHTTPClient

func WithAnthropicHTTPClient(client *http.Client) AnthropicProviderOption

WithAnthropicHTTPClient configures the Anthropic-compatible provider fallback HTTP client.

func WithAnthropicHeader

func WithAnthropicHeader(key, value string) AnthropicProviderOption

WithAnthropicHeader configures an Anthropic-compatible provider default request header.

func WithAnthropicHeaders

func WithAnthropicHeaders(headers map[string]string) AnthropicProviderOption

WithAnthropicHeaders configures Anthropic-compatible provider default request headers.

func WithAnthropicMessagesCompat

func WithAnthropicMessagesCompat(compat anthropic.MessagesCompat) AnthropicProviderOption

WithAnthropicMessagesCompat overrides detected Anthropic-compatible endpoint behavior.

type GitHubCopilotDeviceCodeInfo added in v0.6.0

type GitHubCopilotDeviceCodeInfo struct {
	UserCode        string
	VerificationURI string
	Interval        time.Duration
	ExpiresIn       time.Duration
}

GitHubCopilotDeviceCodeInfo reports the user code and verification URL that should be shown to the caller during GitHub Copilot device-code login.

type GitHubCopilotDeviceCodeLoginOptions added in v0.6.0

type GitHubCopilotDeviceCodeLoginOptions struct {
	HTTPClient       *http.Client
	EnterpriseDomain string
	OnDeviceCode     func(GitHubCopilotDeviceCodeInfo)
}

GitHubCopilotDeviceCodeLoginOptions configures GitHub Copilot device-code login.

type GitHubCopilotModelEnableOptions added in v0.6.0

type GitHubCopilotModelEnableOptions struct {
	HTTPClient       *http.Client
	BaseURL          string
	EnterpriseDomain string
}

GitHubCopilotModelEnableOptions configures GitHub Copilot model-policy enablement helpers.

type GitHubCopilotModelEnableResult added in v0.6.0

type GitHubCopilotModelEnableResult struct {
	ModelID    string
	Enabled    bool
	StatusCode int
	Err        error
}

GitHubCopilotModelEnableResult reports the outcome for one model-policy enablement request.

func EnableGitHubCopilotModel added in v0.6.0

func EnableGitHubCopilotModel(ctx context.Context, token string, modelID string, opts GitHubCopilotModelEnableOptions) (GitHubCopilotModelEnableResult, error)

EnableGitHubCopilotModel enables one GitHub Copilot model policy for the resolved Copilot account.

func EnableGitHubCopilotModels added in v0.6.0

func EnableGitHubCopilotModels(ctx context.Context, token string, modelIDs []string, opts GitHubCopilotModelEnableOptions) []GitHubCopilotModelEnableResult

EnableGitHubCopilotModels enables multiple GitHub Copilot model policies and reports each result independently.

type GitHubCopilotOAuthCredentials added in v0.6.0

type GitHubCopilotOAuthCredentials struct {
	AccessToken      string
	RefreshToken     string
	Expiry           time.Time
	EnterpriseDomain string
	BaseURL          string
}

GitHubCopilotOAuthCredentials carries GitHub Copilot OAuth tokens. Callers own persistence; Sigma never stores these credentials.

func LoginGitHubCopilotDeviceCode added in v0.6.0

LoginGitHubCopilotDeviceCode runs the GitHub Copilot device-code OAuth flow and returns credentials for caller-managed persistence.

func RefreshGitHubCopilotToken added in v0.6.0

func RefreshGitHubCopilotToken(ctx context.Context, refreshToken string, opts GitHubCopilotOAuthTokenProviderOptions) (GitHubCopilotOAuthCredentials, error)

RefreshGitHubCopilotToken refreshes GitHub Copilot OAuth credentials from the GitHub device-flow token returned during login.

type GitHubCopilotOAuthTokenProvider added in v0.6.0

type GitHubCopilotOAuthTokenProvider struct {
	// contains filtered or unexported fields
}

GitHubCopilotOAuthTokenProvider resolves and refreshes caller-owned GitHub Copilot OAuth credentials.

func NewGitHubCopilotOAuthTokenProvider added in v0.6.0

NewGitHubCopilotOAuthTokenProvider adapts caller-managed GitHub Copilot OAuth credentials to Sigma's OAuthTokenProvider and AuthResolver interfaces. Refreshed credentials are kept in memory and passed to OnRefresh for caller persistence.

func (*GitHubCopilotOAuthTokenProvider) Resolve added in v0.6.0

Resolve implements sigma.AuthResolver.

func (*GitHubCopilotOAuthTokenProvider) Token added in v0.6.0

Token implements sigma.OAuthTokenProvider.

type GitHubCopilotOAuthTokenProviderOptions added in v0.6.0

type GitHubCopilotOAuthTokenProviderOptions struct {
	HTTPClient       *http.Client
	EnterpriseDomain string
	Now              func() time.Time
	RefreshBefore    time.Duration
	OnRefresh        func(context.Context, GitHubCopilotOAuthCredentials) error
}

GitHubCopilotOAuthTokenProviderOptions configures the OAuth token provider returned by NewGitHubCopilotOAuthTokenProvider.

type Provider

type Provider = openai.Provider

Provider adapts GitHub Copilot's OpenAI-compatible Chat Completions endpoint.

func NewProvider

func NewProvider(opts ...ProviderOption) *Provider

NewProvider constructs a GitHub Copilot Chat Completions provider.

type ProviderOption

type ProviderOption = openai.ProviderOption

ProviderOption configures a Provider.

func WithBaseURL

func WithBaseURL(baseURL string) ProviderOption

WithBaseURL configures the provider base URL, for example an httptest server URL.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ProviderOption

WithHTTPClient configures the provider fallback HTTP client.

func WithHeader

func WithHeader(key, value string) ProviderOption

WithHeader configures a provider default request header.

func WithHeaders

func WithHeaders(headers map[string]string) ProviderOption

WithHeaders configures provider default request headers.

type ResponsesProvider

type ResponsesProvider = openai.ResponsesProvider

ResponsesProvider adapts GitHub Copilot's OpenAI-compatible Responses endpoint.

func NewResponsesProvider

func NewResponsesProvider(opts ...ProviderOption) *ResponsesProvider

NewResponsesProvider constructs a GitHub Copilot Responses provider.

Jump to

Keyboard shortcuts

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