executor

package
v6.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 38 Imported by: 0

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

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 (*AIStudioExecutor) Execute added in v6.2.38

func (*AIStudioExecutor) ExecuteStream added in v6.2.38

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

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) Execute

func (*ClaudeExecutor) ExecuteStream

func (*ClaudeExecutor) Identifier

func (e *ClaudeExecutor) Identifier() string

func (*ClaudeExecutor) PrepareRequest

func (e *ClaudeExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error

func (*ClaudeExecutor) Refresh

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) Execute

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) Execute

func (*GeminiCLIExecutor) ExecuteStream

func (*GeminiCLIExecutor) Identifier

func (e *GeminiCLIExecutor) Identifier() string

func (*GeminiCLIExecutor) PrepareRequest

func (e *GeminiCLIExecutor) PrepareRequest(_ *http.Request, _ *cliproxyauth.Auth) error

func (*GeminiCLIExecutor) Refresh

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) Execute

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 (*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

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 (*IFlowExecutor) Execute added in v6.1.0

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 (*OpenAICompatExecutor) Execute

func (*OpenAICompatExecutor) ExecuteStream

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

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) Execute

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)

Jump to

Keyboard shortcuts

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