Documentation
¶
Overview ¶
Package claudecli implements provider.Provider by shelling out to the Claude Code CLI (`claude --print`). This uses the user's Max plan authentication from ~/.claude instead of requiring separate API credits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client invokes the claude CLI binary for chat completions.
func New ¶
New creates a claude-cli provider with the default timeout. If model is empty, the CLI uses its default.
func NewWithTimeout ¶ added in v0.1.8
NewWithTimeout creates a claude-cli provider with a custom timeout. Use this when the provider config specifies timeout_seconds.
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, req provider.ChatRequest) (*provider.ChatResponse, error)
Chat builds a prompt from the request messages, invokes `claude --print`, and returns the CLI output as the assistant response.
Output is read incrementally via pipes instead of CombinedOutput so that the onActivity callback fires as bytes arrive and hung processes are detected early (no output for staleOutputTimeout → cancel).
IMPORTANT: The prompt MUST be sent via stdin, not as a CLI argument. Passing the prompt as an argument causes the CLI to hang indefinitely. --dangerously-skip-permissions is required for headless/non-interactive use. --allowedTools pre-approves tools so the CLI never prompts in headless context. ANTHROPIC_API_KEY must be unset so the CLI uses OAuth (~/.claude) not API credits.
func (*Client) Healthy ¶
Healthy returns true if the claude binary is found and responds to --version.
func (*Client) SetOnActivity ¶ added in v0.1.13
func (c *Client) SetOnActivity(fn func())
SetOnActivity registers a callback invoked whenever the CLI process produces output bytes. The runner uses this to reset the dispatcher heartbeat timer, proving the session is actively producing tokens.
type Options ¶ added in v0.1.16
type Options struct {
AllowedTools string // comma-separated tool list (e.g. "Bash,Read,Edit,Write,Glob,Grep")
MaxTurns int // max agentic turns per session; 0 means no limit
BaseURL string // override ANTHROPIC_BASE_URL (e.g. Ollama endpoint)
Logger *zap.Logger // structured logger; nil uses nop logger
}
Options configures optional Client parameters.