claude

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

internal/claude/invoker.go

Index

Constants

View Source
const (
	ProviderMoonshot   = "Moonshot (Kimi)"
	ProviderDeepSeek   = "DeepSeek"
	ProviderGLM        = "Zhipu (GLM)"
	ProviderMiniMax    = "MiniMax"
	ProviderAliyun     = "Alibaba Cloud (Qwen)"
	ProviderVolcengine = "Volcengine (Doubao)"
	ProviderTencent    = "Tencent Cloud"
	ProviderCustom     = "Custom provider"
)

Provider display names used in the selection menu and switch cases.

Variables

View Source
var ErrInterrupted = errors.New("interrupted")

ErrInterrupted is returned when the user cancels an interactive prompt (Ctrl+C).

View Source
var GitHubAPI = "https://api.github.com/repos/theopenbee/cc-download/releases/latest"

GitHubAPI is the GitHub Releases API endpoint for cc-download. It is a var (not const) so tests can override it with a local httptest server.

Functions

func ConfigureProvider added in v0.0.13

func ConfigureProvider() error

ConfigureProvider runs an interactive survey to select a provider and API key, then writes the result to ~/.claude/settings.json (and ~/.claude.json where needed). Returns ErrInterrupted if the user cancels with Ctrl+C.

func Download added in v0.0.13

func Download(stateDir string, force bool) (string, error)

Download downloads Claude Code to stateDir/bin/claude and returns the installed path. If the binary already exists and force is false, it returns the existing path immediately without re-downloading.

func HandleSurveyErr added in v0.0.13

func HandleSurveyErr(err error) error

HandleSurveyErr converts a survey interrupt into ErrInterrupted and passes other errors through unchanged. It is exported so that cmd-layer code can share the same sentinel error without duplicating the check.

Types

type Invoker

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

Invoker spawns Claude CLI processes. It is stateless and safe for concurrent use.

func NewInvoker

func NewInvoker(binary, mcpBasePath, apiKey string) *Invoker

NewInvoker creates an Invoker. mcpBasePath should include the full MCP base path (e.g. "http://host:port/mcp/bee"); "/sse" is appended automatically.

func (*Invoker) Run

func (inv *Invoker) Run(ctx context.Context, workDir, prompt string, opts RunOptions, logPath string) (*Process, <-chan Output, error)

Run starts a Claude CLI process, redirecting its stdout and stderr to logPath. The returned channel carries only lifecycle events: OutputDone on success, OutputError on failure. The channel is closed after the process exits.

type Output

type Output struct {
	Type    OutputType `json:"type"`
	Content string     `json:"content"`
}

Output is a single output event from a Claude CLI process.

type OutputType

type OutputType string

OutputType classifies a line of output from a Claude CLI process.

const (
	OutputStdout OutputType = "stdout"
	OutputStderr OutputType = "stderr"
	OutputDone   OutputType = "done"
	OutputError  OutputType = "error"
)

type Process

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

Process represents a running Claude CLI invocation.

func (*Process) PID

func (p *Process) PID() int

PID returns the process ID, or 0 if the process has not started.

func (*Process) Stop

func (p *Process) Stop() error

Stop kills the process.

type RunOptions

type RunOptions struct {
	SessionID string
	Resume    bool
}

RunOptions controls session behaviour for a Claude CLI invocation.

Jump to

Keyboard shortcuts

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