Documentation
¶
Overview ¶
Package llmadapters contains the concrete LLM HTTP and subprocess adapters.
Index ¶
- Constants
- Variables
- func RequireReviewerWorkspace(adapter llm.Adapter) error
- func SupportsReviewerWorkspace(adapter llm.Adapter) bool
- type APIAdapter
- func (a *APIAdapter) Name() string
- func (a *APIAdapter) Quota(context.Context) (Quota, bool, error)
- func (a *APIAdapter) Resume(context.Context, string, Request) (Stream, error)
- func (a *APIAdapter) Start(ctx context.Context, req Request) (Stream, error)
- func (a *APIAdapter) SupportsCacheAccounting() bool
- func (a *APIAdapter) SupportsCostReporting() bool
- func (a *APIAdapter) SupportsResume() bool
- type APIOptions
- type PiRPCAdapter
- func (a *PiRPCAdapter) Name() string
- func (a *PiRPCAdapter) Quota(context.Context) (Quota, bool, error)
- func (a *PiRPCAdapter) Resume(context.Context, string, Request) (Stream, error)
- func (a *PiRPCAdapter) Start(ctx context.Context, req Request) (Stream, error)
- func (a *PiRPCAdapter) SupportsCacheAccounting() bool
- func (a *PiRPCAdapter) SupportsCostReporting() bool
- func (a *PiRPCAdapter) SupportsResume() bool
- type PiRPCOptions
- type Quota
- type Request
- type Response
- type ReviewerWorkspaceMode
- type ReviewerWorkspaceRequest
- type ScratchDirFactory
- type Stream
- type SubprocessAdapter
- func (a *SubprocessAdapter) Name() string
- func (a *SubprocessAdapter) Quota(context.Context) (Quota, bool, error)
- func (a *SubprocessAdapter) Resume(ctx context.Context, sessionID string, req Request) (Stream, error)
- func (a *SubprocessAdapter) ReviewerWorkspaceMode() ReviewerWorkspaceMode
- func (a *SubprocessAdapter) Start(ctx context.Context, req Request) (Stream, error)
- func (a *SubprocessAdapter) SupportsCacheAccounting() bool
- func (a *SubprocessAdapter) SupportsCostReporting() bool
- func (a *SubprocessAdapter) SupportsResume() bool
- type SubprocessOptions
- type Usage
Constants ¶
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 ¶
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") )
var ErrAPIAdapterConfig = errors.New("llm api: invalid configuration")
ErrAPIAdapterConfig reports invalid direct API adapter configuration.
var ( // ErrTransient marks a retryable provider failure. ErrTransient = llm.ErrTransient )
Functions ¶
func RequireReviewerWorkspace ¶
RequireReviewerWorkspace validates the neutral workspace capability.
func SupportsReviewerWorkspace ¶
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) 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) 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 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 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) 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 ¶
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.