oauth

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultCopilotPickerModelNames

func DefaultCopilotPickerModelNames() []string

func FetchTokens

func FetchTokens(authVal config.AuthVal) (config.AuthVal, error)

func MakeOauthRequest

func MakeOauthRequest(provider string, model string, reasoningEffort string, messages []models.Message, system string, tools []responses.ToolUnionParam) (*openai.ChatCompletion, error)

func RefreshSavedCopilotModels

func RefreshSavedCopilotModels() error

func SaveAccessToken

func SaveAccessToken(token string) error

func SaveCodexAuth

func SaveCodexAuth(authVal config.AuthVal) error

func WaitForCodexAuth

func WaitForCodexAuth(device DeviceCodeResponse) (config.AuthVal, error)

func WaitForCodexLogin

func WaitForCodexLogin(flow CodexLoginFlow) (config.AuthVal, error)

Types

type AuthResponse

type AuthResponse struct {
	AccessToken      string `json:"access_token"`
	TokenType        string `json:"token_type"`
	Scope            string `json:"scope"`
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`
}

func PollForAccessToken

func PollForAccessToken(deviceCode string) (AuthResponse, error)

func WaitForAccessToken

func WaitForAccessToken(device DeviceCodeResponse) (AuthResponse, error)

type CodexBrowserAuthFlow

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

func StartCodexBrowserAuthFlow

func StartCodexBrowserAuthFlow() (*CodexBrowserAuthFlow, error)

func (*CodexBrowserAuthFlow) AuthURL

func (f *CodexBrowserAuthFlow) AuthURL() string

func (*CodexBrowserAuthFlow) Wait

type CodexLoginFlow

type CodexLoginFlow struct {
	AuthURL string
	Device  *DeviceCodeResponse
	Browser *CodexBrowserAuthFlow
}

func StartCodexLoginFlow

func StartCodexLoginFlow() (CodexLoginFlow, error)

type CopilotChatChoice

type CopilotChatChoice struct {
	Index        int                        `json:"index"`
	Message      CopilotChatResponseMessage `json:"message"`
	FinishReason string                     `json:"finish_reason"`
}

type CopilotChatCompletionRequest

type CopilotChatCompletionRequest struct {
	Model       string               `json:"model"`
	Messages    []CopilotChatMessage `json:"messages"`
	Tools       []CopilotChatTool    `json:"tools,omitempty"`
	ToolChoice  any                  `json:"tool_choice,omitempty"`
	Temperature *float64             `json:"temperature,omitempty"`
	Stream      bool                 `json:"stream,omitempty"`
}

type CopilotChatCompletionResponse

type CopilotChatCompletionResponse struct {
	ID      string              `json:"id"`
	Choices []CopilotChatChoice `json:"choices"`
	Usage   CopilotChatUsage    `json:"usage"`
}

type CopilotChatMessage

type CopilotChatMessage struct {
	Role       string                `json:"role"`
	Content    any                   `json:"content,omitempty"`
	ToolCalls  []CopilotChatToolCall `json:"tool_calls,omitempty"`
	ToolCallID string                `json:"tool_call_id,omitempty"`
}

type CopilotChatResponseMessage

type CopilotChatResponseMessage struct {
	Role            string                `json:"role"`
	Content         string                `json:"content"`
	ReasoningOpaque string                `json:"reasoning_opaque,omitempty"`
	ToolCalls       []CopilotChatToolCall `json:"tool_calls,omitempty"`
}

type CopilotChatTool

type CopilotChatTool struct {
	Type     string              `json:"type"`
	Function CopilotToolFunction `json:"function"`
}

type CopilotChatToolCall

type CopilotChatToolCall struct {
	ID       string                  `json:"id"`
	Type     string                  `json:"type"`
	Function CopilotChatToolFunction `json:"function"`
}

type CopilotChatToolFunction

type CopilotChatToolFunction struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments,omitempty"`
}

type CopilotChatUsage

type CopilotChatUsage struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
}

type CopilotModel

type CopilotModel struct {
	ID                  string                   `json:"id"`
	ModelPickerCategory string                   `json:"model_picker_category"`
	ModelPickerEnabled  bool                     `json:"model_picker_enabled"`
	Name                string                   `json:"name"`
	Object              string                   `json:"object"`
	Policy              CopilotModelPolicy       `json:"policy"`
	Preview             bool                     `json:"preview"`
	SupportedEndpoints  []string                 `json:"supported_endpoints"`
	Vendor              string                   `json:"vendor"`
	Version             string                   `json:"version"`
	Capabilities        CopilotModelCapabilities `json:"capabilities"`
}

func MakeModelsRequest

func MakeModelsRequest() ([]CopilotModel, error)

func ResolveCopilotModel

func ResolveCopilotModel(name string, liveModels []CopilotModel) (CopilotModel, bool)

type CopilotModelCapabilities

type CopilotModelCapabilities struct {
	Family    string               `json:"family"`
	Limits    CopilotModelLimits   `json:"limits"`
	Object    string               `json:"object"`
	Supports  CopilotModelSupports `json:"supports"`
	Tokenizer string               `json:"tokenizer"`
	Type      string               `json:"type"`
}

type CopilotModelLimits

type CopilotModelLimits struct {
	MaxContextWindowTokens      int                      `json:"max_context_window_tokens"`
	MaxNonStreamingOutputTokens int                      `json:"max_non_streaming_output_tokens"`
	MaxOutputTokens             int                      `json:"max_output_tokens"`
	MaxPromptTokens             int                      `json:"max_prompt_tokens"`
	Vision                      CopilotModelVisionLimits `json:"vision"`
}

type CopilotModelPolicy

type CopilotModelPolicy struct {
	State string `json:"state"`
	Terms string `json:"terms"`
}

type CopilotModelSupports

type CopilotModelSupports struct {
	AdaptiveThinking  bool     `json:"adaptive_thinking"`
	MaxThinkingBudget int      `json:"max_thinking_budget"`
	MinThinkingBudget int      `json:"min_thinking_budget"`
	ParallelToolCalls bool     `json:"parallel_tool_calls"`
	ReasoningEffort   []string `json:"reasoning_effort"`
	Streaming         bool     `json:"streaming"`
	StructuredOutputs bool     `json:"structured_outputs"`
	ToolCalls         bool     `json:"tool_calls"`
	Vision            bool     `json:"vision"`
}

type CopilotModelVisionLimits

type CopilotModelVisionLimits struct {
	MaxPromptImageSize  int      `json:"max_prompt_image_size"`
	MaxPromptImages     int      `json:"max_prompt_images"`
	SupportedMediaTypes []string `json:"supported_media_types"`
}

type CopilotReasoning

type CopilotReasoning struct {
	Effort  string `json:"effort,omitempty"`
	Summary string `json:"summary,omitempty"`
}

type CopilotResponsesContentPart

type CopilotResponsesContentPart struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	ImageURL string `json:"image_url,omitempty"`
}

type CopilotResponsesInputItem

type CopilotResponsesInputItem struct {
	Role      string `json:"role,omitempty"`
	Content   any    `json:"content,omitempty"`
	Type      string `json:"type,omitempty"`
	CallID    string `json:"call_id,omitempty"`
	Name      string `json:"name,omitempty"`
	Arguments string `json:"arguments,omitempty"`
	Output    string `json:"output,omitempty"`
}

type CopilotResponsesOutputContent

type CopilotResponsesOutputContent struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type CopilotResponsesOutputItem

type CopilotResponsesOutputItem struct {
	Type      string                          `json:"type"`
	Role      string                          `json:"role,omitempty"`
	CallID    string                          `json:"call_id,omitempty"`
	Name      string                          `json:"name,omitempty"`
	Arguments string                          `json:"arguments,omitempty"`
	Content   []CopilotResponsesOutputContent `json:"content,omitempty"`
}

type CopilotResponsesRequest

type CopilotResponsesRequest struct {
	Model      string                      `json:"model"`
	Input      []CopilotResponsesInputItem `json:"input"`
	Tools      []CopilotResponsesTool      `json:"tools,omitempty"`
	ToolChoice any                         `json:"tool_choice,omitempty"`
	Reasoning  *CopilotReasoning           `json:"reasoning,omitempty"`
	Include    []string                    `json:"include,omitempty"`
	Text       *CopilotTextOptions         `json:"text,omitempty"`
	Stream     bool                        `json:"stream,omitempty"`
}

type CopilotResponsesResponse

type CopilotResponsesResponse struct {
	ID     string                       `json:"id,omitempty"`
	Output []CopilotResponsesOutputItem `json:"output"`
	Usage  CopilotResponsesUsage        `json:"usage"`
}

func MakeCopilotResponsesRequest

func MakeCopilotResponsesRequest(request CopilotResponsesRequest) (CopilotResponsesResponse, error)

type CopilotResponsesTool

type CopilotResponsesTool struct {
	Type        string `json:"type"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  any    `json:"parameters,omitempty"`
}

type CopilotResponsesUsage

type CopilotResponsesUsage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

type CopilotTextOptions

type CopilotTextOptions struct {
	Verbosity string `json:"verbosity,omitempty"`
}

type CopilotToolFunction

type CopilotToolFunction struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Parameters  any    `json:"parameters,omitempty"`
}

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

func StartAuthFlow

func StartAuthFlow() (DeviceCodeResponse, error)

func StartCodexAuthFlow

func StartCodexAuthFlow() (DeviceCodeResponse, error)

type InputTokenDetails

type InputTokenDetails struct {
	CachedTokens int64 `json:"cached_tokens"`
}

type OutputTokenDetails

type OutputTokenDetails struct {
	ReasoningTokens int64 `json:"reasoning_tokens"`
}

type Usage

type Usage struct {
	InputTokens        int64              `json:"input_tokens"`
	OutputTokens       int64              `json:"output_tokens"`
	TotalTokens        int64              `json:"total_tokens"`
	InputTokenDetails  InputTokenDetails  `json:"input_tokens_details"`
	OutputTokenDetails OutputTokenDetails `json:"output_tokens_details"`
}

Jump to

Keyboard shortcuts

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