Documentation
¶
Overview ¶
Package claude drives the claude CLI as a subprocess and parses its stream-json output into a plain text reply.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFinalMessage ¶
Types ¶
type LoginStatusReport ¶
type LoginStatusReport struct {
Command string
LoggedIn bool
AuthMethod string
APIProvider string
Output string
}
LoginStatusReport holds the result of a Claude CLI login status check.
func CheckLogin ¶
func CheckLogin(command string, timeout time.Duration) (LoginStatusReport, error)
CheckLogin runs "claude auth status" and returns the login state. If timeout is zero or negative, a 15-second default is used.
type Runner ¶
type Runner struct {
Command string
Timeout time.Duration
Env map[string]string
WorkspaceDir string
}
Runner executes the claude CLI for a single request.
func (Runner) Run ¶
Run is a convenience wrapper that runs without thread resumption or progress callbacks.
func (Runner) RunWithThreadAndProgress ¶
func (r Runner) RunWithThreadAndProgress( ctx context.Context, threadID string, userText string, model string, env map[string]string, onProgress func(step string), onRawEvent func(kind, line, detail string), ) (string, string, int64, int64, int64, error)
RunWithThreadAndProgress runs the claude CLI and returns the final assistant reply and the session ID to use for subsequent calls.
- threadID: resume an existing session when non-empty.
- userText: the fully assembled prompt (no further template rendering is done).
- model: overrides the CLI default when non-empty.
- env: merged over the process environment.
- onProgress: called with each intermediate assistant message; may be nil.
- onRawEvent: optional callback for raw stdout events (kind, line, detail); nil disables raw event delivery.
Click to show internal directories.
Click to hide internal directories.