Documentation
¶
Overview ¶
Package claude implements a registry.Agent that shells out to the Claude Code CLI in headless mode and parses its stream-json NDJSON output via the agent/event/claude_types package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClaudeAgent ¶
type ClaudeAgent struct {
AgentPath string
SettingsPath string
Workspace string
Env *exec.Env
LastSessionID string
}
ClaudeAgent wraps the claude CLI (Anthropic's Claude Code agent).
func (*ClaudeAgent) Ask ¶
func (a *ClaudeAgent) Ask(ctx context.Context, question string, opts *registry.AskOptions, onDelta registry.DeltaCallback) (string, error)
Ask invokes the claude CLI with the given prompt and streams the response.
It runs:
claude -p "<prompt>" --output-format stream-json --verbose
with optional --model and --resume flags. The --verbose flag is required by claude when using --output-format stream-json.
func (*ClaudeAgent) ListModels ¶
ListModels returns nil, nil because the claude CLI has no model-listing command.
type ClaudeEventWriter ¶
type ClaudeEventWriter struct {
// contains filtered or unexported fields
}
ClaudeEventWriter converts claude stream-json NDJSON lines into coalesced AgentEvent JSONL. It is a thin pass-through to claude_types.FromClaude, which emits the correct 0..N canonical events per native line in order.
func NewClaudeEventWriter ¶
func NewClaudeEventWriter(w io.Writer) *ClaudeEventWriter
NewClaudeEventWriter creates a writer that emits AgentEvent JSONL to w.
func (*ClaudeEventWriter) Flush ¶
func (c *ClaudeEventWriter) Flush()
Flush finalizes any buffered state. ClaudeEventWriter holds no pending state — FromClaude handles a single line's blocks in one call.
func (*ClaudeEventWriter) WriteClaudeLine ¶
func (c *ClaudeEventWriter) WriteClaudeLine(line string)
WriteClaudeLine parses one claude stream-json line and writes AgentEvent JSONL.