llmadapters

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package llmadapters contains the concrete LLM HTTP and subprocess adapters.

Index

Constants

View Source
const (
	// ReviewerWorkspaceNone means the adapter cannot use a reviewer workspace.
	ReviewerWorkspaceNone = llm.ReviewerWorkspaceNone
	// ReviewerWorkspacePermissionBounded means tool permissions bound workspace access.
	ReviewerWorkspacePermissionBounded = llm.ReviewerWorkspacePermissionBounded
	// ReviewerWorkspaceWrite means the adapter can use a writable workspace.
	ReviewerWorkspaceWrite = llm.ReviewerWorkspaceWrite
)

Variables

View Source
var (
	// ErrToolUse reports a subprocess no-IO contract violation.
	ErrToolUse = errors.New("llm subprocess: tool use event")

	// ErrUnsafeSubprocessConfig reports a launch spec missing required safety flags.
	ErrUnsafeSubprocessConfig = errors.New("llm subprocess: unsafe configuration")
)
View Source
var ErrAPIAdapterConfig = errors.New("llm api: invalid configuration")

ErrAPIAdapterConfig reports invalid direct API adapter configuration.

View Source
var (
	// ErrTransient marks a retryable provider failure.
	ErrTransient = llm.ErrTransient
)

Functions

func RequireReviewerWorkspace

func RequireReviewerWorkspace(adapter llm.Adapter) error

RequireReviewerWorkspace validates the neutral workspace capability.

func SupportsReviewerWorkspace

func SupportsReviewerWorkspace(adapter llm.Adapter) bool

SupportsReviewerWorkspace reports whether an adapter accepts a workspace.

Types

type APIAdapter

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

APIAdapter calls a direct provider HTTP API as an LLM adapter.

func NewAPIAdapterFromConfig

func NewAPIAdapterFromConfig(llmConfig config.LLMConfig, store credentials.Reader, opts APIOptions) (*APIAdapter, error)

NewAPIAdapterFromConfig resolves an API-key LLM adapter from profile config.

func (*APIAdapter) Name

func (a *APIAdapter) Name() string

Name returns the adapter name.

func (*APIAdapter) Quota

func (a *APIAdapter) Quota(context.Context) (Quota, bool, error)

Quota reports unsupported quota for direct API adapters.

func (*APIAdapter) Resume

Resume is unsupported until API session persistence is designed.

func (*APIAdapter) Start

func (a *APIAdapter) Start(ctx context.Context, req Request) (Stream, error)

Start begins one provider HTTP request and returns its stream handle.

func (*APIAdapter) SupportsCacheAccounting

func (a *APIAdapter) SupportsCacheAccounting() bool

SupportsCacheAccounting reports whether provider usage can include cache fields.

func (*APIAdapter) SupportsCostReporting

func (a *APIAdapter) SupportsCostReporting() bool

SupportsCostReporting reports whether provider responses include cost.

func (*APIAdapter) SupportsResume

func (a *APIAdapter) SupportsResume() bool

SupportsResume reports whether API session resume is implemented.

type APIOptions

type APIOptions struct {
	APIKey           string
	HTTPClient       *http.Client
	BaseURL          string
	MaxTokens        int
	AnthropicVersion string
	FastModeModels   []string
}

APIOptions configures direct HTTP LLM adapters.

type PiRPCAdapter

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

PiRPCAdapter runs Pi in RPC mode as an LLM adapter.

func NewPiRPCAdapter

func NewPiRPCAdapter(opts PiRPCOptions) *PiRPCAdapter

NewPiRPCAdapter returns a Pi RPC subprocess adapter.

func (*PiRPCAdapter) Name

func (a *PiRPCAdapter) Name() string

Name returns the adapter name.

func (*PiRPCAdapter) Quota

func (a *PiRPCAdapter) Quota(context.Context) (Quota, bool, error)

Quota reports unsupported quota for Pi RPC.

func (*PiRPCAdapter) Resume

Resume is unsupported until Pi RPC session persistence is designed.

func (*PiRPCAdapter) Start

func (a *PiRPCAdapter) Start(ctx context.Context, req Request) (Stream, error)

Start launches Pi in RPC mode in a fresh scratch directory.

func (*PiRPCAdapter) SupportsCacheAccounting

func (a *PiRPCAdapter) SupportsCacheAccounting() bool

SupportsCacheAccounting reports whether provider usage can include cache fields.

func (*PiRPCAdapter) SupportsCostReporting

func (a *PiRPCAdapter) SupportsCostReporting() bool

SupportsCostReporting reports whether provider responses include cost.

func (*PiRPCAdapter) SupportsResume

func (a *PiRPCAdapter) SupportsResume() bool

SupportsResume reports whether Pi RPC session resume is implemented.

type PiRPCOptions

type PiRPCOptions struct {
	Command           string
	Env               []string
	Timeout           time.Duration
	ScratchDirFactory ScratchDirFactory
	FastModeModels    []string
	// contains filtered or unexported fields
}

PiRPCOptions configures the Pi RPC subprocess adapter.

type Quota

type Quota = llm.Quota

Quota aliases neutral quota state.

type Request

type Request = llm.Request

Request aliases the neutral invocation contract.

type Response

type Response = llm.Response

Response aliases the neutral result contract.

type ReviewerWorkspaceMode

type ReviewerWorkspaceMode = llm.ReviewerWorkspaceMode

ReviewerWorkspaceMode aliases the neutral workspace capability.

func AdapterReviewerWorkspaceMode

func AdapterReviewerWorkspaceMode(adapter llm.Adapter) ReviewerWorkspaceMode

AdapterReviewerWorkspaceMode returns an adapter's workspace capability.

type ReviewerWorkspaceRequest

type ReviewerWorkspaceRequest = llm.ReviewerWorkspaceRequest

ReviewerWorkspaceRequest aliases the neutral workspace request.

type ScratchDirFactory

type ScratchDirFactory = llm.ScratchDirFactory

ScratchDirFactory aliases the shared scratch-directory factory.

type Stream

type Stream = llm.Stream

Stream aliases the neutral asynchronous result contract.

type SubprocessAdapter

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

SubprocessAdapter runs a subscription CLI as an LLM adapter.

func NewClaudeCLIAdapter

func NewClaudeCLIAdapter(opts SubprocessOptions) *SubprocessAdapter

NewClaudeCLIAdapter returns a Claude Code subprocess adapter.

func NewCodexCLIAdapter

func NewCodexCLIAdapter(opts SubprocessOptions) *SubprocessAdapter

NewCodexCLIAdapter returns a Codex CLI subprocess adapter.

func (*SubprocessAdapter) Name

func (a *SubprocessAdapter) Name() string

Name returns the adapter name.

func (*SubprocessAdapter) Quota

Quota reports unsupported quota for subscription CLI adapters.

func (*SubprocessAdapter) Resume

func (a *SubprocessAdapter) Resume(ctx context.Context, sessionID string, req Request) (Stream, error)

Resume starts a subprocess request from an existing provider session when the adapter supports provider-side session reuse.

func (*SubprocessAdapter) ReviewerWorkspaceMode

func (a *SubprocessAdapter) ReviewerWorkspaceMode() ReviewerWorkspaceMode

ReviewerWorkspaceMode reports the subprocess adapter's reviewer workspace mode.

func (*SubprocessAdapter) Start

func (a *SubprocessAdapter) Start(ctx context.Context, req Request) (Stream, error)

Start launches the configured subprocess in a fresh scratch directory.

func (*SubprocessAdapter) SupportsCacheAccounting

func (a *SubprocessAdapter) SupportsCacheAccounting() bool

SupportsCacheAccounting reports whether cache usage metrics are guaranteed.

func (*SubprocessAdapter) SupportsCostReporting

func (a *SubprocessAdapter) SupportsCostReporting() bool

SupportsCostReporting reports whether cost metrics are guaranteed.

func (*SubprocessAdapter) SupportsResume

func (a *SubprocessAdapter) SupportsResume() bool

SupportsResume reports whether subprocess session resume is implemented.

type SubprocessOptions

type SubprocessOptions struct {
	Command string
	Env     []string
	// Timeout bounds a single LLM task (one subprocess run, or one background
	// job launch + result wait). Zero applies defaultLLMTaskTimeout — without a
	// deadline, one hung CLI worker or never-terminal background job hangs the
	// entire review until something external kills it. Negative disables the
	// bound explicitly.
	Timeout                time.Duration
	ScratchDirFactory      ScratchDirFactory
	AllowBestEffortNoTools bool
	FastModeModels         []string
	// contains filtered or unexported fields
}

SubprocessOptions configures subprocess LLM adapters.

type Usage

type Usage = llm.Usage

Usage aliases neutral usage accounting.

Jump to

Keyboard shortcuts

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