Versions in this module Expand all Collapse all v0 v0.1.2 Jul 2, 2026 v0.1.1 Jul 2, 2026 v0.1.0 Jun 29, 2026 Changes in this version + const MinCLIVersion + const SDKVersion + var ErrAPI = errors.New("API error") + var ErrAuth = errors.New("authentication failed") + var ErrBilling = errors.New("billing error") + var ErrContextWindowExceeded = errors.New("context window exceeded") + var ErrEmptyOutput = errors.New("claudecli: empty output") + var ErrInvalidRequest = errors.New("invalid request") + var ErrMaxTurns = errors.New("max turns reached") + var ErrNoManifestPath = errors.New("claudecli: cannot derive workflow manifest path") + var ErrNotFound = errors.New("not found") + var ErrOverloaded = errors.New("API overloaded") + var ErrPermission = errors.New("permission denied") + var ErrRateLimit = errors.New("rate limit") + var ErrRequestTooLarge = errors.New("request too large") + func AuthLogout(ctx context.Context) error + func CheckCLIVersion(ctx context.Context, binaryPath string) error + func FormatAgentMessage(senderName, content string) string + func ModelDisplayName(id string) string + func ParseEvents(ctx context.Context, r io.Reader, ch chan<- Event) + func WatchWorkflow(ctx context.Context, launch *WorkflowLaunch, opts ...WatchOption) (<-chan WorkflowSnapshot, error) + type ActivityState string + const ActivityAwaitingToolResult + const ActivityIdle + const ActivityThinking + type AgentInput struct + Description string + Isolation string + Mode string + Model string + Name string + Prompt string + RunInBackground bool + SubagentType string + TeamName string + type AgentResult struct + AgentID string + AgentType string + Content []ToolContent + Prompt string + Status string + TotalDurationMs int + TotalTokens int + TotalToolUseCount int + type AuthLoginOption func(*authLoginConfig) + func WithAuthMethod(m AuthMethod) AuthLoginOption + func WithLoginEmail(email string) AuthLoginOption + func WithNoBrowser() AuthLoginOption + func WithSSO() AuthLoginOption + type AuthMethod string + const AuthMethodClaudeAI + const AuthMethodConsole + type AuthState string + const AuthStateAuthenticated + const AuthStateUnauthenticated + const AuthStateUnknown + type AuthStatusEvent struct + Error string + IsAuthenticating bool + Output string + func (e *AuthStatusEvent) String() string + type AuthStatusResult struct + APIProvider string + AuthMethod string + Email string + LoggedIn bool + Message string + OrgID string + OrgName string + Status AuthState + SubscriptionType string + func AuthStatus(ctx context.Context) (*AuthStatusResult, error) + type BidiFixtureExecutor struct + StdinReader io.ReadCloser + StdoutWriter io.WriteCloser + func NewBidiFixtureExecutor() *BidiFixtureExecutor + func (e *BidiFixtureExecutor) Start(_ context.Context, _ *StartConfig) (*Process, error) + type BlockingResult struct + CostUSD float64 + Duration time.Duration + IsError bool + NumTurns int + SessionID string + Stderr string + StructuredOutput json.RawMessage + Subtype string + Text string + Usage Usage + func RunBlockingJSON[T any](ctx context.Context, c *Client, prompt string, opts ...Option) (T, *BlockingResult, error) + type CLIExitEvent struct + At time.Time + Err error + ExitCode int + Reason ExitReason + Signal string + func (e *CLIExitEvent) String() string + type CLIStateChangeEvent struct + At time.Time + State ActivityState + func (e *CLIStateChangeEvent) String() string + type CLIToolProgressEvent struct + ElapsedSeconds float64 + TaskID string + ToolName string + ToolUseID string + func (e *CLIToolProgressEvent) String() string + type Client struct + func New(defaults ...Option) *Client + func NewClient(clientOpts []ClientOption, defaults ...Option) *Client + func NewWithExecutor(executor Executor, defaults ...Option) *Client + func (c *Client) AuthLogin(ctx context.Context, opts ...AuthLoginOption) (*LoginProcess, error) + func (c *Client) AuthLogout(ctx context.Context) error + func (c *Client) AuthStatus(ctx context.Context) (*AuthStatusResult, error) + func (c *Client) Connect(ctx context.Context, opts ...Option) (*Session, error) + func (c *Client) Run(ctx context.Context, prompt string, opts ...Option) *Stream + func (c *Client) RunBlocking(ctx context.Context, prompt string, opts ...Option) (*BlockingResult, error) + func (c *Client) RunText(ctx context.Context, prompt string, opts ...Option) (string, *ResultEvent, error) + type ClientOption func(*Client) + func WithLogger(l *slog.Logger) ClientOption + type CompactBoundaryEvent struct + PreTokens int + Raw json.RawMessage + SessionID string + Trigger string + func (e *CompactBoundaryEvent) String() string + type CompactStatusEvent struct + SessionID string + Status string + func (e *CompactStatusEvent) String() string + type ContentBlock struct + func DocumentBlock(mediaType string, data []byte) ContentBlock + func ImageBlock(mediaType string, data []byte) ContentBlock + func TextBlock(text string) ContentBlock + func (b ContentBlock) MarshalJSON() ([]byte, error) + type ContextManagementEvent struct + Raw json.RawMessage + func (e *ContextManagementEvent) String() string + type ContextSnapshot struct + CacheCreationInputTokens int + CacheReadInputTokens int + ContextWindow int + InputTokens int + OutputTokens int + type ControlRequestEvent struct + Body json.RawMessage + RequestID string + Subtype string + func (e *ControlRequestEvent) String() string + type EffortLevel string + const DefaultEffort + const EffortHigh + const EffortLow + const EffortMax + const EffortMedium + const EffortXHigh + type Error struct + ExitCode int + LastEvents []string + Message string + Stderr string + func (e *Error) Error() string + func (e *Error) Unwrap() []error + type ErrorEvent struct + Err error + Fatal bool + func (e *ErrorEvent) Error() string + func (e *ErrorEvent) String() string + func (e *ErrorEvent) Unwrap() error + type Event interface + type Executor interface + Start func(ctx context.Context, cfg *StartConfig) (*Process, error) + type ExitReason string + const ExitReasonContextCanceled + const ExitReasonCrashed + const ExitReasonKilled + const ExitReasonNormal + const ExitReasonUnknown + type FailedFile struct + Error string + Filename string + type FilesPersistedEvent struct + Failed []FailedFile + Files []PersistedFile + func (e *FilesPersistedEvent) String() string + type FixtureExecutor struct + func NewFixtureExecutor(r io.Reader) *FixtureExecutor + func NewFixtureExecutorFromFile(path string) (*FixtureExecutor, error) + func (e *FixtureExecutor) Start(_ context.Context, _ *StartConfig) (*Process, error) + type HookEvent struct + ExitCode int + HookEvent string + HookID string + HookName string + Outcome string + Output string + Raw json.RawMessage + SessionID string + Stderr string + Stdout string + Subtype string + UUID string + func (e *HookEvent) String() string + type InitEvent struct + Agents []string + MCPServers []MCPServerStatus + Model string + SessionID string + Skills []string + Tools []string + func (e *InitEvent) ModelDisplayName() string + func (e *InitEvent) String() string + type LocalExecutor struct + BinaryPath string + func NewLocalExecutor() *LocalExecutor + func (e *LocalExecutor) Start(ctx context.Context, cfg *StartConfig) (*Process, error) + type LoginProcess struct + AutoOpenURL string + URL string + func AuthLogin(ctx context.Context, opts ...AuthLoginOption) (*LoginProcess, error) + func (p *LoginProcess) CallbackPort() int + func (p *LoginProcess) Cancel() error + func (p *LoginProcess) SubmitCode(code string) error + func (p *LoginProcess) Wait() error + type MCPServerStatus struct + Name string + Status string + type MaxTurnsError struct + Message string + Turns int + func (e *MaxTurnsError) Error() string + func (e *MaxTurnsError) Is(target error) bool + type Model string + const DefaultModel + const ModelFable + const ModelHaiku + const ModelOpus + const ModelSonnet + type ModelUsage struct + CacheCreateTokens int + CacheReadTokens int + ContextWindow int + CostUSD float64 + InputTokens int + MaxOutputTokens int + OutputTokens int + WebFetchRequests int + WebSearchRequests int + func (m ModelUsage) TotalTokens() int + type Option func(*options) + func WithAddDirs(dirs ...string) Option + func WithAgent(name string) Option + func WithAgentDef(jsonDef string) Option + func WithAppendSystemPrompt(p string) Option + func WithAppendSystemPromptFile(p string) Option + func WithBare() Option + func WithBetas(betas ...string) Option + func WithBinaryPath(path string) Option + func WithBuiltinTools(tools ...string) Option + func WithCanUseTool(fn ToolPermissionFunc) Option + func WithContinue() Option + func WithControlTimeout(d time.Duration) Option + func WithDangerouslySkipPermissions() Option + func WithDebugFile(path string) Option + func WithDisableSlashCommands() Option + func WithDisallowedTools(tools ...string) Option + func WithEffort(level EffortLevel) Option + func WithEnv(env map[string]string) Option + func WithExtraArgs(args map[string]string) Option + func WithFallbackModel(m Model) Option + func WithFileCheckpointing() Option + func WithForkSession() Option + func WithIncludePartialMessages() Option + func WithInitTimeout(d time.Duration) Option + func WithJSONSchema(schema string) Option + func WithMCPConfig(configs ...string) Option + func WithMaxBudget(usd float64) Option + func WithMaxTurns(n int) Option + func WithModel(m Model) Option + func WithPermissionMode(m PermissionMode) Option + func WithPermissionPromptToolName(name string) Option + func WithPluginDirs(dirs ...string) Option + func WithReplayUserMessages() Option + func WithResume(sessionID string) Option + func WithSessionID(id string) Option + func WithSessionName(name string) Option + func WithSettingSources(sources ...string) Option + func WithSettings(s string) Option + func WithSkipVersionCheck() Option + func WithStderrCallback(fn func(string)) Option + func WithStrictMCPConfig() Option + func WithSystemPrompt(p string) Option + func WithSystemPromptFile(p string) Option + func WithTaskBudget(totalTokens int) Option + func WithThinking(cfg ThinkingConfig) Option + func WithTimeout(d time.Duration) Option + func WithTools(tools ...string) Option + func WithUser(user string) Option + func WithUserInput(fn UserInputFunc) Option + func WithWorkDir(dir string) Option + type PermissionMode string + const PermissionAcceptEdits + const PermissionAuto + const PermissionBypass + const PermissionDefault + const PermissionDontAsk + const PermissionPlan + type PermissionResponse struct + Allow bool + DenyMessage string + UpdatedInput json.RawMessage + type PersistedFile struct + FileID string + Filename string + type Pool struct + func NewPool() *Pool + func (p *Pool) Add(session *Session, meta SessionMeta) error + func (p *Pool) Close() + func (p *Pool) CloseAll() error + func (p *Pool) Events() <-chan PoolEvent + func (p *Pool) Get(sessionID string) (*Session, SessionMeta, bool) + func (p *Pool) List() []SessionEntry + func (p *Pool) Remove(sessionID string) error + func (p *Pool) SendAgentMessage(fromSessionID, toSessionID, content string) error + type PoolEvent struct + Event Event + SessionID string + type Process struct + Stderr io.ReadCloser + Stdin io.WriteCloser + Stdout io.ReadCloser + Wait func() error + type ProcessInfo struct + ActivityState ActivityState + LastStdoutAt time.Time + Lifecycle State + SessionID string + type Question struct + Header string + MultiSelect bool + Options []QuestionOption + Question string + type QuestionOption struct + Description string + Label string + type RateLimitError struct + Message string + RetryAfter time.Duration + func (e *RateLimitError) Error() string + func (e *RateLimitError) Is(target error) bool + type RateLimitEvent struct + OverageDisabledReason string + OverageResetsAt int64 + OverageStatus string + RateLimitType string + Raw map[string]any + ResetsAt int64 + SessionID string + Status string + UUID string + Utilization float64 + func (e *RateLimitEvent) String() string + type ResultEvent struct + ContextSnapshot *ContextSnapshot + CostUSD float64 + Duration time.Duration + ModelUsage map[string]ModelUsage + NumTurns int + SessionID string + StopReason string + StructuredOutput json.RawMessage + Subtype string + Text string + Usage Usage + func RunJSON[T any](ctx context.Context, c *Client, prompt string, opts ...Option) (T, *ResultEvent, error) + func RunText(ctx context.Context, prompt string, opts ...Option) (string, *ResultEvent, error) + func (e *ResultEvent) String() string + type Session struct + func Connect(ctx context.Context, opts ...Option) (*Session, error) + func (s *Session) ActivityState() ActivityState + func (s *Session) Close() error + func (s *Session) Events() <-chan Event + func (s *Session) GetMCPStatus() error + func (s *Session) GetServerInfo() json.RawMessage + func (s *Session) Interrupt() error + func (s *Session) Ping(timeout time.Duration) error + func (s *Session) ProcessInfo() ProcessInfo + func (s *Session) Query(prompt string) error + func (s *Session) QueryMCPStatus() ([]MCPServerStatus, error) + func (s *Session) QueryWithContent(prompt string, blocks ...ContentBlock) error + func (s *Session) ReconnectMCPServer(serverName string) error + func (s *Session) ReconnectMCPServerWait(serverName string, timeout time.Duration) error + func (s *Session) RewindFiles(userMessageID string) error + func (s *Session) SendMessage(prompt string) error + func (s *Session) SendMessageWithContent(prompt string, blocks ...ContentBlock) error + func (s *Session) SessionID() string + func (s *Session) SetModel(model Model) error + func (s *Session) SetPermissionMode(mode PermissionMode) error + func (s *Session) State() State + func (s *Session) StopTask(taskID string) error + func (s *Session) ToggleMCPServer(serverName string, enabled bool) error + func (s *Session) Wait() (*ResultEvent, error) + type SessionEntry struct + Meta SessionMeta + Session *Session + type SessionMeta struct + Labels map[string]string + Name string + type StartConfig struct + Args []string + EnableFileCheckpointing bool + Env map[string]string + KeepStdinOpen bool + SkipVersionCheck bool + Stdin io.Reader + WorkDir string + type StartEvent struct + Args []string + Model Model + WorkDir string + func (e *StartEvent) String() string + type State int + const StateDone + const StateFailed + const StateIdle + const StateRunning + const StateStarting + func (s State) String() string + type StderrEvent struct + Content string + func (e *StderrEvent) String() string + type Stream struct + func Run(ctx context.Context, prompt string, opts ...Option) *Stream + func (s *Stream) Close() error + func (s *Stream) Events() <-chan Event + func (s *Stream) Next() (Event, bool) + func (s *Stream) State() State + func (s *Stream) Wait() (*ResultEvent, error) + type StreamEvent struct + Event json.RawMessage + SessionID string + UUID string + func (e *StreamEvent) String() string + type TaskEvent struct + Description string + DurationMs int + EndTime int64 + LastToolName string + OutputFile string + Prompt string + Raw json.RawMessage + SessionID string + Status string + Subtype string + Summary string + TaskID string + TaskType string + ToolUseID string + ToolUses int + TotalTokens int + WorkflowName string + WorkflowProgress []WorkflowProgressEntry + func (e *TaskEvent) IsWorkflow() bool + func (e *TaskEvent) String() string + type TextEvent struct + Content string + ParentToolUseID string + func (e *TextEvent) String() string + type ThinkingAdaptive struct + type ThinkingConfig interface + type ThinkingDisabled struct + type ThinkingEnabled struct + BudgetTokens int + type ThinkingEvent struct + Content string + ParentToolUseID string + Signature string + func (e *ThinkingEvent) String() string + type ThinkingTokensEvent struct + EstimatedTokens int + EstimatedTokensDelta int + SessionID string + UUID string + func (e *ThinkingTokensEvent) String() string + type ToolContent struct + Data string + MediaType string + Text string + Type string + type ToolPermissionFunc func(toolName string, input json.RawMessage) (*PermissionResponse, error) + func ResolveCanUseTool(opts ...Option) ToolPermissionFunc + type ToolPermissionRequest struct + Input json.RawMessage + PermissionSuggestions []json.RawMessage + ToolName string + type ToolProgressEvent struct + At time.Time + Elapsed time.Duration + ToolName string + ToolUseID string + func (e *ToolProgressEvent) String() string + type ToolResultEvent struct + Content []ToolContent + ParentToolUseID string + ToolUseID string + func (e *ToolResultEvent) String() string + func (e *ToolResultEvent) Text() string + type ToolUseEvent struct + ID string + Input json.RawMessage + MCP bool + Name string + ParentToolUseID string + ServerSide bool + func (e *ToolUseEvent) ParseAgentInput() *AgentInput + func (e *ToolUseEvent) String() string + type ToolUseSummaryEvent struct + PrecedingToolUseIDs []string + Summary string + func (e *ToolUseSummaryEvent) String() string + type TurnEvent struct + ToolName string + Turn int + func (e *TurnEvent) String() string + type UnknownEvent struct + Raw json.RawMessage + Type string + func (e *UnknownEvent) String() string + type UnmarshalError struct + Err error + RawText string + func (e *UnmarshalError) Error() string + func (e *UnmarshalError) Unwrap() error + type Usage struct + CacheCreateTokens int + CacheReadTokens int + InputTokens int + OutputTokens int + func (u Usage) String() string + func (u Usage) TotalTokens() int + type UserContent struct + Content []ToolContent + Text string + ToolUseID string + Type string + type UserEvent struct + AgentResult *AgentResult + Content []UserContent + IsReplay bool + ParentToolUseID string + SessionID string + Timestamp string + UUID string + WorkflowLaunch *WorkflowLaunch + func (e *UserEvent) String() string + func (e *UserEvent) Text() string + type UserInputFunc func(questions []Question) (answers map[string]string, err error) + type VersionError struct + Found string + Minimum string + func (e *VersionError) Error() string + type WatchOption func(*watchConfig) + func WithPollInterval(d time.Duration) WatchOption + type WorkflowLaunch struct + RunID string + ScriptPath string + Status string + Summary string + TaskID string + TaskType string + TranscriptDir string + WorkflowName string + func (l *WorkflowLaunch) JournalPath() string + func (l *WorkflowLaunch) ManifestPath() string + type WorkflowPhase struct + Title string + type WorkflowProgressEntry struct + AgentID string + Attempt int + DurationMs int + Index int + Label string + LastProgressAt int64 + LastToolName string + LastToolSummary string + Model string + PhaseIndex int + PhaseTitle string + PromptPreview string + QueuedAt int64 + ResultPreview string + StartedAt int64 + State string + Title string + Tokens int + ToolCalls int + Type string + func (e WorkflowProgressEntry) IsAgent() bool + func (e WorkflowProgressEntry) IsPhase() bool + type WorkflowSnapshot struct + AgentCount int + DefaultModel string + DurationMs int + Phases []WorkflowPhase + Progress []WorkflowProgressEntry + Raw json.RawMessage + Result json.RawMessage + RunID string + ScriptPath string + StartTime int64 + Status string + TaskID string + Timestamp string + TotalTokens int + TotalToolCalls int + WorkflowName string + func ReadWorkflowSnapshot(launch *WorkflowLaunch) (*WorkflowSnapshot, error) + func (s *WorkflowSnapshot) Agents() []WorkflowProgressEntry + func (s *WorkflowSnapshot) IsTerminal() bool