Documentation
¶
Index ¶
- Constants
- func BuildPrompt(instructions string, envContext map[string]string, taskContent string) string
- func BuildResultSection(result AgentResultLike) string
- func PrintResult(ctx context.Context, result AgentResult) error
- type AgentDir
- type AgentResult
- type AgentResultLike
- type AgentStatus
- type AllowedTools
- type ClaudeConfigDir
- type ClaudeModel
- type ClaudeResult
- type ClaudeRunner
- type ClaudeRunnerConfig
- type Instruction
- type Instructions
- type ResultDeliverer
- type TaskRunner
Constants ¶
const ( // AgentStatusDone indicates the task completed successfully. AgentStatusDone = delivery.AgentStatusDone // AgentStatusFailed indicates the task failed. AgentStatusFailed = delivery.AgentStatusFailed // AgentStatusNeedsInput indicates the task requires additional user input. AgentStatusNeedsInput = delivery.AgentStatusNeedsInput )
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt combines instructions with environment context and task content.
func BuildResultSection ¶
func BuildResultSection(result AgentResultLike) string
BuildResultSection renders the default ## Result markdown block for any AgentResultLike.
func PrintResult ¶
func PrintResult(ctx context.Context, result AgentResult) error
PrintResult marshals an AgentResult to JSON and prints to stdout.
Types ¶
type AgentDir ¶
type AgentDir string
AgentDir is the path to the agent directory containing .claude/ config.
type AgentResult ¶
type AgentResult struct {
Status AgentStatus `json:"status"`
Message string `json:"message,omitempty"`
Files []string `json:"files,omitempty"`
}
AgentResult is the structured output written to stdout for the task/executor to read.
func (AgentResult) GetFiles ¶ added in v0.45.0
func (r AgentResult) GetFiles() []string
func (AgentResult) GetMessage ¶ added in v0.45.0
func (r AgentResult) GetMessage() string
func (AgentResult) GetStatus ¶ added in v0.45.0
func (r AgentResult) GetStatus() AgentStatus
func (AgentResult) RenderResultSection ¶ added in v0.45.0
func (r AgentResult) RenderResultSection() string
type AgentResultLike ¶ added in v0.45.0
type AgentResultLike interface {
GetStatus() AgentStatus
GetMessage() string
GetFiles() []string
RenderResultSection() string
}
AgentResultLike is the constraint for types that can be delivered as task results.
type AgentStatus ¶
type AgentStatus = delivery.AgentStatus
AgentStatus is the shared agent status type.
type AllowedTools ¶
type AllowedTools []string
AllowedTools is a list of tool names permitted in headless Claude sessions.
func ParseAllowedTools ¶
func ParseAllowedTools(s string) AllowedTools
ParseAllowedTools parses a comma-separated string into AllowedTools.
func (AllowedTools) String ¶
func (a AllowedTools) String() string
String returns the comma-separated tool list for the CLI --allowedTools flag.
type ClaudeConfigDir ¶
type ClaudeConfigDir string
ClaudeConfigDir is the path to the Claude Code configuration directory (~/.claude).
func (ClaudeConfigDir) String ¶
func (c ClaudeConfigDir) String() string
String returns the path as a string.
type ClaudeModel ¶
type ClaudeModel string
ClaudeModel identifies which Claude model to use.
const ( SonnetClaudeModel ClaudeModel = "sonnet" OpusClaudeModel ClaudeModel = "opus" )
type ClaudeResult ¶
type ClaudeResult struct {
Result string `json:"result"`
}
ClaudeResult holds the parsed output from a Claude Code CLI session.
type ClaudeRunner ¶
type ClaudeRunner interface {
Run(ctx context.Context, prompt string) (*ClaudeResult, error)
}
ClaudeRunner spawns a headless Claude Code CLI session with a prompt and MCP tools.
func NewClaudeRunner ¶
func NewClaudeRunner(config ClaudeRunnerConfig) ClaudeRunner
NewClaudeRunner creates a ClaudeRunner that spawns claude --print with MCP tools.
type ClaudeRunnerConfig ¶
type ClaudeRunnerConfig struct {
ClaudeConfigDir ClaudeConfigDir
AllowedTools AllowedTools
Model ClaudeModel
WorkingDirectory AgentDir
Env map[string]string
}
ClaudeRunnerConfig holds configuration for spawning Claude Code CLI.
type Instruction ¶
Instruction is a named prompt section wrapped in XML tags.
func (Instruction) String ¶
func (i Instruction) String() string
String renders the instruction as an XML-tagged block.
type Instructions ¶
type Instructions []Instruction
Instructions is a list of named prompt sections.
func (Instructions) String ¶
func (ii Instructions) String() string
String renders all instructions separated by newlines.
func (Instructions) Strings ¶
func (ii Instructions) Strings() []string
Strings returns each instruction rendered as an XML-tagged string.
type ResultDeliverer ¶
type ResultDeliverer[T AgentResultLike] interface { DeliverResult(ctx context.Context, result T) error }
ResultDeliverer publishes a task result back after execution completes.
func NewNoopResultDeliverer ¶
func NewNoopResultDeliverer() ResultDeliverer[AgentResult]
NewNoopResultDeliverer creates a ResultDeliverer[AgentResult] that does nothing.
func NewResultDelivererAdapter ¶
func NewResultDelivererAdapter[T AgentResultLike]( inner delivery.ResultDeliverer, ) ResultDeliverer[T]
NewResultDelivererAdapter wraps a delivery.ResultDeliverer to accept any AgentResultLike.
type TaskRunner ¶
type TaskRunner[T AgentResultLike] interface { Run(ctx context.Context, taskContent string) (*T, error) }
TaskRunner orchestrates task execution by launching a single Claude Code session.
func NewTaskRunner ¶
func NewTaskRunner[T AgentResultLike]( runner ClaudeRunner, instructions Instructions, envContext map[string]string, deliverer ResultDeliverer[T], ) TaskRunner[T]
NewTaskRunner creates a TaskRunner with injected dependencies.