cliprovider

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CodexHomeEnvVar = "CODEX_HOME"

CodexHomeEnvVar is the environment variable that overrides the Codex CLI home directory when resolving the codex auth.json credentials file. Default: ~/.codex

Variables

This section is empty.

Functions

func CreateCodexCliTokenSource

func CreateCodexCliTokenSource() func() (string, string, error)

CreateCodexCliTokenSource creates a token source that reads from ~/.codex/auth.json. This allows the existing CodexProvider to reuse Codex CLI credentials.

func ReadCodexCliCredentials

func ReadCodexCliCredentials() (accessToken, accountID string, expiresAt time.Time, err error)

ReadCodexCliCredentials reads OAuth tokens from the Codex CLI's auth.json file. Expiry is estimated as file modification time + 1 hour (same approach as moltbot).

Types

type ClaudeCliProvider

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

ClaudeCliProvider implements LLMProvider using the claude CLI as a subprocess.

func NewClaudeCliProvider

func NewClaudeCliProvider(workspace string) *ClaudeCliProvider

NewClaudeCliProvider creates a new Claude CLI provider.

func (*ClaudeCliProvider) Chat

func (p *ClaudeCliProvider) Chat(
	ctx context.Context, messages []Message, tools []ToolDefinition, model string, options map[string]any,
) (*LLMResponse, error)

Chat implements LLMProvider.Chat by executing the claude CLI.

func (*ClaudeCliProvider) GetDefaultModel

func (p *ClaudeCliProvider) GetDefaultModel() string

GetDefaultModel returns the default model identifier.

type CodexCliAuth

type CodexCliAuth struct {
	Tokens struct {
		AccessToken  string `json:"access_token"`
		RefreshToken string `json:"refresh_token"`
		AccountID    string `json:"account_id"`
	} `json:"tokens"`
}

CodexCliAuth represents the ~/.codex/auth.json file structure.

type CodexCliProvider

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

CodexCliProvider implements LLMProvider by wrapping the codex CLI as a subprocess.

func NewCodexCliProvider

func NewCodexCliProvider(workspace string) *CodexCliProvider

NewCodexCliProvider creates a new Codex CLI provider.

func (*CodexCliProvider) Chat

func (p *CodexCliProvider) Chat(
	ctx context.Context, messages []Message, tools []ToolDefinition, model string, options map[string]any,
) (*LLMResponse, error)

Chat implements LLMProvider.Chat by executing the codex CLI in non-interactive mode.

func (*CodexCliProvider) GetDefaultModel

func (p *CodexCliProvider) GetDefaultModel() string

GetDefaultModel returns the default model identifier.

type FunctionCall

type FunctionCall = protocoltypes.FunctionCall

type GitHubCopilotProvider

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

func NewGitHubCopilotProvider

func NewGitHubCopilotProvider(uri string, connectMode string, model string) (*GitHubCopilotProvider, error)

func (*GitHubCopilotProvider) Chat

func (p *GitHubCopilotProvider) Chat(
	ctx context.Context,
	messages []Message,
	tools []ToolDefinition,
	model string,
	options map[string]any,
) (*LLMResponse, error)

func (*GitHubCopilotProvider) Close

func (p *GitHubCopilotProvider) Close()

func (*GitHubCopilotProvider) GetDefaultModel

func (p *GitHubCopilotProvider) GetDefaultModel() string

type LLMProvider

type LLMProvider interface {
	Chat(
		ctx context.Context,
		messages []Message,
		tools []ToolDefinition,
		model string,
		options map[string]any,
	) (*LLMResponse, error)
	GetDefaultModel() string
}

type LLMResponse

type LLMResponse = protocoltypes.LLMResponse

type Message

type Message = protocoltypes.Message

type ToolCall

type ToolCall = protocoltypes.ToolCall

func NormalizeToolCall

func NormalizeToolCall(tc ToolCall) ToolCall

NormalizeToolCall normalizes a ToolCall to ensure all fields are properly populated. It handles cases where Name/Arguments might be in different locations (top-level vs Function) and ensures both are populated consistently.

type ToolDefinition

type ToolDefinition = protocoltypes.ToolDefinition

type ToolFunctionDefinition

type ToolFunctionDefinition = protocoltypes.ToolFunctionDefinition

type UsageInfo

type UsageInfo = protocoltypes.UsageInfo

Jump to

Keyboard shortcuts

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