Documentation
¶
Overview ¶
Package executor provides runtime execution capabilities for various AI service providers. It includes stateless executors that handle API requests, streaming responses, token counting, and authentication refresh for different AI service providers.
Index ¶
- type AIStudioExecutor
- func (e *AIStudioExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *AIStudioExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *AIStudioExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *AIStudioExecutor) Identifier() string
- func (e *AIStudioExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *AIStudioExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type ClaudeExecutor
- func (e *ClaudeExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *ClaudeExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *ClaudeExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *ClaudeExecutor) Identifier() string
- func (e *ClaudeExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *ClaudeExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type CodexExecutor
- func (e *CodexExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *CodexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *CodexExecutor) Identifier() string
- func (e *CodexExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *CodexExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type GeminiCLIExecutor
- func (e *GeminiCLIExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *GeminiCLIExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *GeminiCLIExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *GeminiCLIExecutor) Identifier() string
- func (e *GeminiCLIExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *GeminiCLIExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type GeminiExecutor
- func (e *GeminiExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *GeminiExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *GeminiExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *GeminiExecutor) Identifier() string
- func (e *GeminiExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *GeminiExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type IFlowExecutor
- func (e *IFlowExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *IFlowExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *IFlowExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *IFlowExecutor) Identifier() string
- func (e *IFlowExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *IFlowExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type OpenAICompatExecutor
- func (e *OpenAICompatExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *OpenAICompatExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *OpenAICompatExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *OpenAICompatExecutor) Identifier() string
- func (e *OpenAICompatExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *OpenAICompatExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
- type QwenExecutor
- func (e *QwenExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (cliproxyexecutor.Response, error)
- func (e *QwenExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (resp cliproxyexecutor.Response, err error)
- func (e *QwenExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, ...) (stream <-chan cliproxyexecutor.StreamChunk, err error)
- func (e *QwenExecutor) Identifier() string
- func (e *QwenExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
- func (e *QwenExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIStudioExecutor ¶ added in v6.2.38
type AIStudioExecutor struct {
// contains filtered or unexported fields
}
AIStudioExecutor routes AI Studio requests through a websocket-backed transport.
func NewAIStudioExecutor ¶ added in v6.2.38
func NewAIStudioExecutor(cfg *config.Config, provider string, relay *wsrelay.Manager) *AIStudioExecutor
NewAIStudioExecutor constructs a websocket executor for the provider name.
func (*AIStudioExecutor) CountTokens ¶ added in v6.2.38
func (e *AIStudioExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*AIStudioExecutor) Execute ¶ added in v6.2.38
func (e *AIStudioExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*AIStudioExecutor) ExecuteStream ¶ added in v6.2.38
func (e *AIStudioExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*AIStudioExecutor) Identifier ¶ added in v6.2.38
func (e *AIStudioExecutor) Identifier() string
Identifier returns the logical provider key for routing.
func (*AIStudioExecutor) PrepareRequest ¶ added in v6.2.38
func (e *AIStudioExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
PrepareRequest is a no-op because websocket transport already injects headers.
func (*AIStudioExecutor) Refresh ¶ added in v6.2.38
func (e *AIStudioExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
type ClaudeExecutor ¶
type ClaudeExecutor struct {
// contains filtered or unexported fields
}
ClaudeExecutor is a stateless executor for Anthropic Claude over the messages API. If api_key is unavailable on auth, it falls back to legacy via ClientAdapter.
func NewClaudeExecutor ¶
func NewClaudeExecutor(cfg *config.Config) *ClaudeExecutor
func (*ClaudeExecutor) CountTokens ¶
func (e *ClaudeExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*ClaudeExecutor) Execute ¶
func (e *ClaudeExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*ClaudeExecutor) ExecuteStream ¶
func (e *ClaudeExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*ClaudeExecutor) Identifier ¶
func (e *ClaudeExecutor) Identifier() string
func (*ClaudeExecutor) PrepareRequest ¶
func (e *ClaudeExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
func (*ClaudeExecutor) Refresh ¶
func (e *ClaudeExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
type CodexExecutor ¶
type CodexExecutor struct {
// contains filtered or unexported fields
}
CodexExecutor is a stateless executor for Codex (OpenAI Responses API entrypoint). If api_key is unavailable on auth, it falls back to legacy via ClientAdapter.
func NewCodexExecutor ¶
func NewCodexExecutor(cfg *config.Config) *CodexExecutor
func (*CodexExecutor) CountTokens ¶
func (e *CodexExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*CodexExecutor) Execute ¶
func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*CodexExecutor) ExecuteStream ¶
func (e *CodexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*CodexExecutor) Identifier ¶
func (e *CodexExecutor) Identifier() string
func (*CodexExecutor) PrepareRequest ¶
func (e *CodexExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
func (*CodexExecutor) Refresh ¶
func (e *CodexExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
type GeminiCLIExecutor ¶
type GeminiCLIExecutor struct {
// contains filtered or unexported fields
}
GeminiCLIExecutor talks to the Cloud Code Assist endpoint using OAuth credentials from auth metadata.
func NewGeminiCLIExecutor ¶
func NewGeminiCLIExecutor(cfg *config.Config) *GeminiCLIExecutor
func (*GeminiCLIExecutor) CountTokens ¶
func (e *GeminiCLIExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*GeminiCLIExecutor) Execute ¶
func (e *GeminiCLIExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*GeminiCLIExecutor) ExecuteStream ¶
func (e *GeminiCLIExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*GeminiCLIExecutor) Identifier ¶
func (e *GeminiCLIExecutor) Identifier() string
func (*GeminiCLIExecutor) PrepareRequest ¶
func (e *GeminiCLIExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
func (*GeminiCLIExecutor) Refresh ¶
func (e *GeminiCLIExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
type GeminiExecutor ¶
type GeminiExecutor struct {
// contains filtered or unexported fields
}
GeminiExecutor is a stateless executor for the official Gemini API using API keys. It handles both API key and OAuth bearer token authentication, supporting both regular and streaming requests to the Google Generative Language API.
func NewGeminiExecutor ¶
func NewGeminiExecutor(cfg *config.Config) *GeminiExecutor
NewGeminiExecutor creates a new Gemini executor instance.
Parameters:
- cfg: The application configuration
Returns:
- *GeminiExecutor: A new Gemini executor instance
func (*GeminiExecutor) CountTokens ¶
func (e *GeminiExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*GeminiExecutor) Execute ¶
func (e *GeminiExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
Execute performs a non-streaming request to the Gemini API. It translates the request to Gemini format, sends it to the API, and translates the response back to the requested format.
Parameters:
- ctx: The context for the request
- auth: The authentication information
- req: The request to execute
- opts: Additional execution options
Returns:
- cliproxyexecutor.Response: The response from the API
- error: An error if the request fails
func (*GeminiExecutor) ExecuteStream ¶
func (e *GeminiExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*GeminiExecutor) Identifier ¶
func (e *GeminiExecutor) Identifier() string
Identifier returns the executor identifier for Gemini.
func (*GeminiExecutor) PrepareRequest ¶
func (e *GeminiExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
PrepareRequest prepares the HTTP request for execution (no-op for Gemini).
func (*GeminiExecutor) Refresh ¶
func (e *GeminiExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
type IFlowExecutor ¶ added in v6.1.0
type IFlowExecutor struct {
// contains filtered or unexported fields
}
IFlowExecutor executes OpenAI-compatible chat completions against the iFlow API using API keys derived from OAuth.
func NewIFlowExecutor ¶ added in v6.1.0
func NewIFlowExecutor(cfg *config.Config) *IFlowExecutor
NewIFlowExecutor constructs a new executor instance.
func (*IFlowExecutor) CountTokens ¶ added in v6.1.0
func (e *IFlowExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*IFlowExecutor) Execute ¶ added in v6.1.0
func (e *IFlowExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
Execute performs a non-streaming chat completion request.
func (*IFlowExecutor) ExecuteStream ¶ added in v6.1.0
func (e *IFlowExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
ExecuteStream performs a streaming chat completion request.
func (*IFlowExecutor) Identifier ¶ added in v6.1.0
func (e *IFlowExecutor) Identifier() string
Identifier returns the provider key.
func (*IFlowExecutor) PrepareRequest ¶ added in v6.1.0
func (e *IFlowExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
PrepareRequest implements ProviderExecutor but requires no preprocessing.
func (*IFlowExecutor) Refresh ¶ added in v6.1.0
func (e *IFlowExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
Refresh refreshes OAuth tokens and updates the stored API key.
type OpenAICompatExecutor ¶
type OpenAICompatExecutor struct {
// contains filtered or unexported fields
}
OpenAICompatExecutor implements a stateless executor for OpenAI-compatible providers. It performs request/response translation and executes against the provider base URL using per-auth credentials (API key) and per-auth HTTP transport (proxy) from context.
func NewOpenAICompatExecutor ¶
func NewOpenAICompatExecutor(provider string, cfg *config.Config) *OpenAICompatExecutor
NewOpenAICompatExecutor creates an executor bound to a provider key (e.g., "openrouter").
func (*OpenAICompatExecutor) CountTokens ¶
func (e *OpenAICompatExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*OpenAICompatExecutor) Execute ¶
func (e *OpenAICompatExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*OpenAICompatExecutor) ExecuteStream ¶
func (e *OpenAICompatExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*OpenAICompatExecutor) Identifier ¶
func (e *OpenAICompatExecutor) Identifier() string
Identifier implements cliproxyauth.ProviderExecutor.
func (*OpenAICompatExecutor) PrepareRequest ¶
func (e *OpenAICompatExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
PrepareRequest is a no-op for now (credentials are added via headers at execution time).
func (*OpenAICompatExecutor) Refresh ¶
func (e *OpenAICompatExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)
Refresh is a no-op for API-key based compatibility providers.
type QwenExecutor ¶
type QwenExecutor struct {
// contains filtered or unexported fields
}
QwenExecutor is a stateless executor for Qwen Code using OpenAI-compatible chat completions. If access token is unavailable, it falls back to legacy via ClientAdapter.
func NewQwenExecutor ¶
func NewQwenExecutor(cfg *config.Config) *QwenExecutor
func (*QwenExecutor) CountTokens ¶
func (e *QwenExecutor) CountTokens(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error)
func (*QwenExecutor) Execute ¶
func (e *QwenExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (resp cliproxyexecutor.Response, err error)
func (*QwenExecutor) ExecuteStream ¶
func (e *QwenExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Auth, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (stream <-chan cliproxyexecutor.StreamChunk, err error)
func (*QwenExecutor) Identifier ¶
func (e *QwenExecutor) Identifier() string
func (*QwenExecutor) PrepareRequest ¶
func (e *QwenExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error
func (*QwenExecutor) Refresh ¶
func (e *QwenExecutor) Refresh(ctx context.Context, auth *cliproxyauth.Auth) (*cliproxyauth.Auth, error)