Documentation
¶
Index ¶
- func CheckAvailable() (string, error)
- func FindClaudePath() (string, error)
- type AssistantMessage
- type ContentBlock
- type Event
- type FinalResult
- type ResultEvent
- type Runner
- func (r *Runner) Ask(ctx context.Context, prompt string) (<-chan Event, error)
- func (r *Runner) AskSync(ctx context.Context, prompt string) (string, error)
- func (r *Runner) IsRunning() bool
- func (r *Runner) Prompt(ctx context.Context, text string) (<-chan Event, error)
- func (r *Runner) SetModel(model string)
- func (r *Runner) StartTalk(ctx context.Context) error
- func (r *Runner) Stop() error
- type StreamEvent
- type ToolCallInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAvailable ¶
CheckAvailable verifies the claude CLI is installed and returns its version.
func FindClaudePath ¶
FindClaudePath locates the claude CLI binary. Returns the full path or an error with installation instructions.
Types ¶
type AssistantMessage ¶
type AssistantMessage struct {
ID string `json:"id,omitempty"`
Role string `json:"role,omitempty"`
Content []ContentBlock `json:"content,omitempty"`
Usage *json.RawMessage `json:"usage,omitempty"`
}
AssistantMessage is the message object inside an assistant event.
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 any `json:"input,omitempty"`
}
ContentBlock represents a single block of content in a message.
type Event ¶
type Event struct {
Type string
Text string
ToolCall *ToolCallInfo
Thought string
Final *FinalResult
Error error
}
Event is the normalized event type consumed by callers, matching the pattern established by the hermes package.
type FinalResult ¶
FinalResult holds the completed response from the agent.
type ResultEvent ¶
type ResultEvent struct {
Type string `json:"type"`
Subtype string `json:"subtype"`
IsError bool `json:"is_error"`
Result string `json:"result"`
StopReason string `json:"stop_reason,omitempty"`
DurationMS int `json:"duration_ms,omitempty"`
TotalCost float64 `json:"total_cost_usd,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
ResultEvent is the final event from a claude --output-format json run.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner manages invocations of the claude CLI binary. It supports both single-shot (Ask) and interactive (Talk) modes.
func NewRunner ¶
NewRunner creates a runner for the claude CLI. The binary path is resolved lazily on first use if not already set.
func (*Runner) Ask ¶
Ask sends a single question and returns a channel of streaming events. The channel is closed when the response is complete or an error occurs.
func (*Runner) Prompt ¶
Prompt sends a message in an interactive talk session and returns streaming events.
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Subtype string `json:"subtype,omitempty"`
// Present when Type == "system" && Subtype == "init"
SessionID string `json:"session_id,omitempty"`
Model string `json:"model,omitempty"`
Tools []string `json:"tools,omitempty"`
// Present when Type == "assistant"
Message *AssistantMessage `json:"message,omitempty"`
// Present when Type == "result"
Result string `json:"result,omitempty"`
IsError bool `json:"is_error,omitempty"`
StopReason string `json:"stop_reason,omitempty"`
DurationMS int `json:"duration_ms,omitempty"`
TotalCost float64 `json:"total_cost_usd,omitempty"`
}
StreamEvent represents a single line of output from claude --output-format stream-json.
type ToolCallInfo ¶
ToolCallInfo holds details about a tool invocation by the agent.