claudecode

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssistantMessage

type AssistantMessage struct {
	ID           string         `json:"id"`
	Type         string         `json:"type"`
	Role         string         `json:"role"`
	Model        string         `json:"model"`
	Content      []ContentBlock `json:"content"`
	StopReason   string         `json:"stop_reason"`
	StopSequence string         `json:"stop_sequence"`
	Usage        *Usage         `json:"usage"`
}

AssistantMessage represents the message content in assistant responses

type ClaudeCodeConfig

type ClaudeCodeConfig struct {
	ExecutablePath             string        `yaml:"executable_path"`
	WorkingDirectory           string        `yaml:"working_directory"`
	SessionTimeout             time.Duration `yaml:"session_timeout"`
	MaxSessions                int           `yaml:"max_sessions"`
	Model                      string        `yaml:"model"`
	LogLevel                   string        `yaml:"log_level"`
	EnableStreaming            bool          `yaml:"enable_streaming"`
	DangerouslySkipPermissions bool          `yaml:"dangerously_skip_permissions"`
	WhitelistedTools           []string      `yaml:"whitelisted_tools"`
}

ClaudeCodeConfig contains configuration for Claude Code provider

func DefaultClaudeCodeConfig

func DefaultClaudeCodeConfig() *ClaudeCodeConfig

Default configuration for Claude Code

type ClaudeCodeProvider

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

ClaudeCodeProvider implements the ModelProvider interface using Claude Code CLI

func NewProvider

func NewProvider(yamlConfig map[string]interface{}) (*ClaudeCodeProvider, error)

NewProvider creates a new Claude Code model provider

func (*ClaudeCodeProvider) Close

func (p *ClaudeCodeProvider) Close() error

func (*ClaudeCodeProvider) Generate

Generate generates a response using Claude Code with streaming enabled by default

func (*ClaudeCodeProvider) GetName

func (p *ClaudeCodeProvider) GetName() string

GetName returns the provider name

func (*ClaudeCodeProvider) ListModels

func (p *ClaudeCodeProvider) ListModels(ctx context.Context) ([]provider.Info, error)

ListModels returns the Claude Code model (single model for local provider)

type ClaudeCodeResponse

type ClaudeCodeResponse struct {
	Content   string                 `json:"content"`
	ToolUses  []ClaudeCodeToolUse    `json:"tool_uses,omitempty"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
	Error     string                 `json:"error,omitempty"`
	SessionID string                 `json:"session_id,omitempty"`
}

ClaudeCodeResponse represents a response from Claude Code

type ClaudeCodeSession

type ClaudeCodeSession struct {
	Process      *exec.Cmd
	Stdout       io.ReadCloser
	Stderr       io.ReadCloser
	Scanner      *bufio.Scanner
	ErrorScanner *bufio.Scanner
	WorkingDir   string
}

type ClaudeCodeToolUse

type ClaudeCodeToolUse struct {
	Name       string                 `json:"name"`
	Parameters map[string]interface{} `json:"parameters"`
	Result     string                 `json:"result,omitempty"`
	Error      string                 `json:"error,omitempty"`
}

ClaudeCodeToolUse represents a tool usage in Claude Code

type ContentBlock

type ContentBlock struct {
	Type      string                 `json:"type"`
	Text      string                 `json:"text,omitempty"`
	ID        string                 `json:"id,omitempty"`
	Name      string                 `json:"name,omitempty"`
	Input     map[string]interface{} `json:"input,omitempty"`
	Content   string                 `json:"content,omitempty"`
	ToolUseID string                 `json:"tool_use_id,omitempty"`
}

ContentBlock represents a content block in the message

type StreamMessage

type StreamMessage struct {
	Type            string            `json:"type"`
	Subtype         string            `json:"subtype,omitempty"`
	Message         *AssistantMessage `json:"message,omitempty"`
	SessionID       string            `json:"session_id,omitempty"`
	ParentToolUseID string            `json:"parent_tool_use_id,omitempty"`
	IsError         bool              `json:"is_error,omitempty"`
	Result          string            `json:"result,omitempty"`
	DurationMS      int               `json:"duration_ms,omitempty"`
	DurationAPIMS   int               `json:"duration_api_ms,omitempty"`
	NumTurns        int               `json:"num_turns,omitempty"`
	TotalCostUSD    float64           `json:"total_cost_usd,omitempty"`
	Usage           *Usage            `json:"usage,omitempty"`
	CWD             string            `json:"cwd,omitempty"`
	Tools           []string          `json:"tools,omitempty"`
	Model           string            `json:"model,omitempty"`
	PermissionMode  string            `json:"permissionMode,omitempty"`
	APIKeySource    string            `json:"apiKeySource,omitempty"`
	MCPServers      []interface{}     `json:"mcp_servers,omitempty"`
}

StreamMessage represents a message in the streaming JSON output

type StreamingOptions

type StreamingOptions struct {
	ShowToolUse  bool
	ShowThinking bool
	ProgressChan chan<- pkgEvents.ExecutionEvent
}

StreamingOptions contains options for streaming responses

type Usage

type Usage struct {
	InputTokens              int                    `json:"input_tokens"`
	CacheCreationInputTokens int                    `json:"cache_creation_input_tokens,omitempty"`
	CacheReadInputTokens     int                    `json:"cache_read_input_tokens,omitempty"`
	OutputTokens             int                    `json:"output_tokens"`
	ServiceTier              string                 `json:"service_tier,omitempty"`
	ServerToolUse            map[string]interface{} `json:"server_tool_use,omitempty"`
}

Usage represents token usage information

Jump to

Keyboard shortcuts

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