Documentation
¶
Index ¶
- func BuildSystemPrompt(annaHome, workspace string, cwd ...string) string
- func DecodeEvent(raw []byte) (ai.AssistantEvent, error)
- func EncodeEvent(event ai.AssistantEvent) ([]byte, error)
- func FormatSkillsForPrompt(skills []Skill) string
- func MessageText(message MessageContent) string
- func ValidateSkillName(name, parentDirName string) []string
- type ActivityTracker
- type Aliver
- type Envelope
- type Event
- type GoRunner
- type GoRunnerConfig
- type HandlerFunc
- type ImageEvent
- type MessageContent
- type NewRunnerFunc
- type Runner
- type Skill
- type Stateful
- type ToolUseEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSystemPrompt ¶
BuildSystemPrompt composes the full system prompt: basic + memories + skills + project context. The basic prompt defaults to the embedded system.md but can be overridden by placing a system.md file in the project's .agents directory or the workspace. annaHome is the anna home directory (e.g. ~/.anna). workspace is the workspace directory (e.g. ~/.anna/workspace) containing SOUL.md, USER.md, system.md.
func DecodeEvent ¶
func DecodeEvent(raw []byte) (ai.AssistantEvent, error)
DecodeEvent deserializes envelope to concrete event type.
func EncodeEvent ¶
func EncodeEvent(event ai.AssistantEvent) ([]byte, error)
EncodeEvent serializes normalized assistant events.
func FormatSkillsForPrompt ¶
FormatSkillsForPrompt renders the available skills as XML for the system prompt. Skills with DisableModelInvocation=true are excluded.
func MessageText ¶
func MessageText(message MessageContent) string
MessageText extracts and joins all text from a message.
func ValidateSkillName ¶
ValidateSkillName checks a skill name against the Agent Skills spec. Returns validation errors (empty slice if valid).
Types ¶
type ActivityTracker ¶
ActivityTracker is an optional interface for runners that track last activity.
type Aliver ¶
type Aliver interface {
Alive() bool
}
Aliver is an optional interface for runners that can report liveness.
type Envelope ¶
type Envelope struct {
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
Envelope wraps stream events for transport.
type Event ¶
type Event struct {
Text string
Image *ImageEvent
ToolUse *ToolUseEvent
Store ai.Message // if non-nil, Pool appends to session history
Err error
}
Event is the consumer-facing stream event. Channels read these from the stream returned by Pool.Chat().
type GoRunner ¶
type GoRunner struct {
// contains filtered or unexported fields
}
GoRunner implements Runner by calling LLM providers directly via Engine.
func NewGoRunner ¶
func NewGoRunner(_ context.Context, cfg GoRunnerConfig) (*GoRunner, error)
NewGoRunner creates a Go runner with built-in providers.
func (*GoRunner) Chat ¶
func (r *GoRunner) Chat(ctx context.Context, history []ai.Message, message MessageContent) <-chan Event
Chat runs the Engine agent loop with the provided history and forwards events.
func (*GoRunner) LastActivity ¶
LastActivity returns the time of the last Chat call.
type GoRunnerConfig ¶
type GoRunnerConfig struct {
API string // provider key: "anthropic", "openai"
Model string // e.g. "claude-sonnet-4-20250514"
APIKey string
BaseURL string // optional provider base URL override
WorkDir string // working directory for tool execution
Workspace string // workspace dir for skills/memory (e.g. ~/.anna/workspace)
AnnaHome string // anna home directory (e.g. ~/.anna)
System string // optional system prompt override (bypasses BuildSystemPrompt)
ExtraTools []tool.Tool // additional tools to register
}
GoRunnerConfig configures the Go runner.
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, history []ai.Message, message MessageContent) <-chan Event
HandlerFunc is an adapter to allow the use of ordinary functions as Runners. If f is a function with the appropriate signature, HandlerFunc(f) is a Runner that calls f.
func (HandlerFunc) Chat ¶
func (f HandlerFunc) Chat(ctx context.Context, history []ai.Message, message MessageContent) <-chan Event
Chat calls f(ctx, history, message).
type ImageEvent ¶
ImageEvent carries a base64-encoded image to be sent to the channel.
type MessageContent ¶
type MessageContent = any
MessageContent is the type for user messages passed through the runner pipeline. It is either string (text-only) or []ai.ContentBlock (multimodal, e.g. text + images).
type NewRunnerFunc ¶
NewRunnerFunc creates a new Runner instance for the given model ID. An empty model means use the default.
type Runner ¶
type Runner interface {
Chat(ctx context.Context, history []ai.Message, message MessageContent) <-chan Event
}
Runner runs prompts against an AI backend. It is stateless — it receives full history each call and must reconstruct context from it.
type Skill ¶
type Skill struct {
Name string
Description string
FilePath string // absolute path to the SKILL.md or .md file
BaseDir string // directory containing the skill file
Source string // "user", "project", or "path"
DisableModelInvocation bool
}
Skill represents a discovered skill with its metadata and location.
func LoadSkills ¶
LoadSkills discovers skills from project, workspace, and common directories. annaHome is the anna home directory (e.g. ~/.anna), workspace is the workspace dir (e.g. ~/.anna/workspace), cwd is the working directory. Priority order: cwd/.agents/skills/ > workspace/skills/ > ~/.agents/skills/ > builtin
type Stateful ¶
type Stateful interface {
Stateful() bool
}
Stateful is an optional interface for runners that maintain their own context in-process (e.g., a long-running subprocess). When a runner is Stateful, Pool will not kill it after compaction — the runner keeps its live context and the compacted history is only persisted to disk for crash recovery.
type ToolUseEvent ¶
type ToolUseEvent struct {
Tool string // tool name, e.g. "bash", "read"
Status string // "running", "done", "error"
Input string // short summary of the tool input
Detail string // error detail or result summary (for "error" status)
}
ToolUseEvent describes a tool invocation in progress or completed.