Documentation
¶
Index ¶
- Constants
- func BuildSystemPrompt(workDir string, registry *tool.Registry) string
- type Agent
- func (a *Agent) ContextLimits() (available, used int)
- func (a *Agent) Messages() []anthropic.MessageParam
- func (a *Agent) Model() string
- func (a *Agent) ModelDisplayName() string
- func (a *Agent) Permissions() *permission.Checker
- func (a *Agent) SendMessage(ctx context.Context, userMsg string) <-chan StreamChunk
- func (a *Agent) SetMessages(messages []anthropic.MessageParam)
- func (a *Agent) SetModel(model string)
- func (a *Agent) TodoStore() *todo.Store
- func (a *Agent) TokenCount() int
- type ChunkType
- type Conversation
- func (c *Conversation) AddAssistantMessage(blocks ...anthropic.ContentBlockParamUnion)
- func (c *Conversation) AddToolResult(results ...anthropic.ContentBlockParamUnion)
- func (c *Conversation) AddUserMessage(text string)
- func (c *Conversation) Len() int
- func (c *Conversation) Messages() []anthropic.MessageParam
- func (c *Conversation) SetMessages(messages []anthropic.MessageParam)
- func (c *Conversation) TokenCount() int
- type ModelOption
- type PermissionResponse
- type StreamChunk
- type Usage
Constants ¶
const ( // DefaultModel is the Claude model used when none is specified. DefaultModel = anthropic.ModelClaudeSonnet4_20250514 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
PermResp chan PermissionResponse
// contains filtered or unexported fields
}
Agent is the core agentic loop that sends messages to Claude, streams the response, executes tools, and loops until done.
func New ¶
func New(client anthropic.Client, registry *tool.Registry, perms *permission.Checker, workDir string, logger *slog.Logger, model anthropic.Model, todoStore *todo.Store) *Agent
New creates a new Agent with the given client, registry, permission checker, working directory, logger, model, and todo store.
func (*Agent) ContextLimits ¶ added in v0.2.0
ContextLimits returns the context window limits configuration.
func (*Agent) Messages ¶ added in v0.2.0
func (a *Agent) Messages() []anthropic.MessageParam
Messages returns a copy of the conversation messages.
func (*Agent) ModelDisplayName ¶ added in v0.1.1
ModelDisplayName returns a human-readable name for the current model.
func (*Agent) Permissions ¶
func (a *Agent) Permissions() *permission.Checker
Permissions returns the permission checker for this agent.
func (*Agent) SendMessage ¶
func (a *Agent) SendMessage(ctx context.Context, userMsg string) <-chan StreamChunk
SendMessage starts the agentic loop for the given user message. It returns a channel that emits StreamChunks as the response is generated. The channel is closed when the loop completes.
func (*Agent) SetMessages ¶ added in v0.2.0
func (a *Agent) SetMessages(messages []anthropic.MessageParam)
SetMessages replaces the conversation messages with the provided slice. This is used to restore a conversation from a saved session.
func (*Agent) TokenCount ¶ added in v0.2.0
TokenCount returns the current estimated token count for the conversation.
type Conversation ¶
type Conversation struct {
// contains filtered or unexported fields
}
Conversation manages the message history for an agent session.
func NewConversation ¶
func NewConversation() *Conversation
NewConversation creates a new empty conversation.
func (*Conversation) AddAssistantMessage ¶
func (c *Conversation) AddAssistantMessage(blocks ...anthropic.ContentBlockParamUnion)
AddAssistantMessage appends an assistant message with the given content blocks.
func (*Conversation) AddToolResult ¶
func (c *Conversation) AddToolResult(results ...anthropic.ContentBlockParamUnion)
AddToolResult appends a user message containing tool result blocks. Each tool result is a separate content block within a single user message.
func (*Conversation) AddUserMessage ¶
func (c *Conversation) AddUserMessage(text string)
AddUserMessage appends a user text message to the conversation.
func (*Conversation) Len ¶
func (c *Conversation) Len() int
Len returns the number of messages in the conversation.
func (*Conversation) Messages ¶
func (c *Conversation) Messages() []anthropic.MessageParam
Messages returns the conversation history as API-ready params.
func (*Conversation) SetMessages ¶ added in v0.2.0
func (c *Conversation) SetMessages(messages []anthropic.MessageParam)
SetMessages replaces all messages in the conversation. This is used to restore a conversation from a saved session or after compaction.
func (*Conversation) TokenCount ¶ added in v0.2.0
func (c *Conversation) TokenCount() int
TokenCount returns the estimated token count of the conversation.
type ModelOption ¶ added in v0.2.0
type ModelOption struct {
ID string // The model identifier string
DisplayName string // Human-readable name
}
ModelOption represents an available model choice.
func AvailableModels ¶ added in v0.2.0
func AvailableModels() []ModelOption
AvailableModels returns the list of supported models.
type PermissionResponse ¶
type PermissionResponse int
PermissionResponse is the user's answer to a permission request.
const ( PermissionGranted PermissionResponse = iota // Allow this once PermissionDenied // Deny this once PermissionGrantedAlways // Allow always for this session )
type StreamChunk ¶
type StreamChunk struct {
Type ChunkType
Text string
ToolName string
ToolID string
ToolInput string
Result *tool.Result
Err error
ParallelProgress *tool.ProgressUpdate // For ChunkParallelProgress
Usage *Usage // For ChunkDone - token usage for this turn
CompactionInfo *ctxmgr.CompactionResult // For ChunkContextCompacted
Todos []todo.Todo // For ChunkTodoUpdate
}
StreamChunk is a unit of output from the agent's streaming loop.