Documentation
¶
Overview ¶
Package enno provides a provider-neutral agent runtime for Go applications.
The core type is Agent. Callers use Agent.Run with an explicit Session and receive a structured RunResult. Optional streaming, events, policies, and hooks provide additional control and observability.
Index ¶
- Constants
- Variables
- func FormatCompactSummary(raw string) string
- func ToolMap(tools []Tool) map[string]Tool
- type AfterProviderCallResult
- type AfterProviderCallState
- type AfterToolCallResult
- type AfterToolCallState
- type Agent
- type BeforeProviderCallResult
- type BeforeProviderCallState
- type BeforeToolCallResult
- type BeforeToolCallState
- type CompactionConfig
- type Config
- type Event
- type EventHandler
- type EventType
- type Hook
- type Message
- type NoopHook
- func (NoopHook) AfterProviderCall(context.Context, AfterProviderCallState) (AfterProviderCallResult, error)
- func (NoopHook) AfterToolCall(context.Context, AfterToolCallState) (AfterToolCallResult, error)
- func (NoopHook) BeforeProviderCall(context.Context, BeforeProviderCallState) (BeforeProviderCallResult, error)
- func (NoopHook) BeforeToolCall(context.Context, BeforeToolCallState) (BeforeToolCallResult, error)
- type Policy
- type Provider
- type Request
- type RequestOptions
- type Response
- type ResponseFormat
- type Role
- type RoundResult
- type RunResult
- type RunStartPolicy
- type RunState
- type Schema
- func (s *Schema) BooleanProp(name string) *Schema
- func (s *Schema) EnumProp(name string, values ...string) *Schema
- func (s *Schema) IntegerProp(name string) *Schema
- func (s *Schema) Properties() map[string]any
- func (s *Schema) Required(names ...string) *Schema
- func (s *Schema) RequiredFields() []string
- func (s *Schema) StringProp(name string) *Schema
- type Session
- type StopReason
- type Stream
- type StreamEvent
- type StreamEventType
- type StreamHandler
- type StreamProvider
- type StructuredToolHandler
- type Tool
- func NewStructuredTool(name, description string, properties map[string]any, required []string, ...) Tool
- func NewTool(name, description string, properties map[string]any, required []string, ...) Tool
- func NewTypedTool[T any](name, description string, properties map[string]any, required []string, ...) Tool
- func NewTypedToolFromSchema[T any](name, description string, schema *Schema, ...) Tool
- type ToolCall
- type ToolCallResult
- type ToolChoice
- type ToolHandler
- type ToolResult
- type Usage
Constants ¶
const ( ToolChoiceAuto = "auto" ToolChoiceNone = "none" ToolChoiceRequired = "required" ToolChoiceTool = "tool" )
const ( ResponseFormatText = "text" ResponseFormatJSONObject = "json_object" ResponseFormatJSONSchema = "json_schema" )
const CompactionToolName = "compact"
CompactionToolName is the registered tool name for manual compaction (same string used by tools/compact).
Variables ¶
var ErrMissingProvider = errors.New("enno: missing provider")
var ErrNilSession = errors.New("enno: nil session")
var ErrUnsupportedOption = errors.New("enno: unsupported request option")
Functions ¶
func FormatCompactSummary ¶ added in v0.5.0
FormatCompactSummary strips <analysis>, extracts <summary> body when present, and normalizes whitespace. If no <summary> tag is found, returns the whole string trimmed (backward compatible).
Types ¶
type AfterProviderCallResult ¶ added in v0.7.0
type AfterProviderCallState ¶ added in v0.7.0
type AfterToolCallResult ¶ added in v0.7.0
type AfterToolCallResult struct {
ToolResult *ToolResult
Abort error
}
type AfterToolCallState ¶ added in v0.7.0
type AfterToolCallState struct {
Round int
Request Request
ToolCall ToolCall
ToolResult ToolResult
Err error
}
type BeforeProviderCallResult ¶ added in v0.7.0
type BeforeProviderCallState ¶ added in v0.7.0
type BeforeToolCallResult ¶ added in v0.7.0
type BeforeToolCallState ¶ added in v0.7.0
type CompactionConfig ¶ added in v0.5.0
type CompactionConfig struct {
Enabled bool
// TranscriptDir stores JSONL transcripts before summarization. Empty uses
// ~/.enno/transcripts when Enabled (after withDefaults).
TranscriptDir string
// ModelContextTokens, when positive, sets auto-compact threshold to
// ModelContextTokens - AutoCompactBufferTokens (buffer defaults to 13000 in withDefaults).
// Takes precedence over AutoCompactInputTokens when the difference is positive.
ModelContextTokens int64
// AutoCompactBufferTokens is subtracted from ModelContextTokens for the effective threshold.
// Ignored when ModelContextTokens is zero. Zero defaults to 13000 when ModelContextTokens > 0.
AutoCompactBufferTokens int64
// AutoCompactInputTokens triggers summarization when estimated/conservative input tokens
// meet or exceed this value. Zero defaults to 50000 when ModelContextTokens is zero.
AutoCompactInputTokens int64
// KeepRecentToolResults is how many latest eligible RoleTool messages keep full content in Micro.
// Zero defaults to 3.
KeepRecentToolResults int
// MicroCompactMinChars replaces longer RoleTool contents with a placeholder. Zero defaults to 100.
MicroCompactMinChars int
// MicroCompactToolNames, when non-empty, limits Micro compaction to tool results whose tool name
// is in this list. Empty means all RoleTool messages participate (legacy behavior).
MicroCompactToolNames []string
// SkipOnSummarizeError, when true, causes automatic compaction to log an error event and continue
// without replacing history if summarization fails. Manual compact via the compact tool remains strict.
SkipOnSummarizeError bool
}
CompactionConfig enables optional context compaction (micro-trimming of old tool results, automatic summarization when estimated input size exceeds a threshold, and the manual compact tool). Nil in Config means compaction is disabled.
type Config ¶
type Config struct {
Provider Provider
SystemPrompt string
Tools []Tool
// MaxToolRounds caps provider/model iterations for one Run (each round may invoke tools).
// Zero or negative means unlimited (default), matching Claude Code interactive sessions where maxTurns is unset.
// Set a positive value to bound tool loops.
MaxToolRounds int
EventHandler EventHandler
Compaction *CompactionConfig
Options RequestOptions
Policies []Policy
Hooks []Hook
}
type EventHandler ¶ added in v0.3.0
type Hook ¶ added in v0.7.0
type Hook interface {
BeforeProviderCall(context.Context, BeforeProviderCallState) (BeforeProviderCallResult, error)
AfterProviderCall(context.Context, AfterProviderCallState) (AfterProviderCallResult, error)
BeforeToolCall(context.Context, BeforeToolCallState) (BeforeToolCallResult, error)
AfterToolCall(context.Context, AfterToolCallState) (AfterToolCallResult, error)
}
type NoopHook ¶ added in v0.7.0
type NoopHook struct{}
func (NoopHook) AfterProviderCall ¶ added in v0.7.0
func (NoopHook) AfterProviderCall(context.Context, AfterProviderCallState) (AfterProviderCallResult, error)
func (NoopHook) AfterToolCall ¶ added in v0.7.0
func (NoopHook) AfterToolCall(context.Context, AfterToolCallState) (AfterToolCallResult, error)
func (NoopHook) BeforeProviderCall ¶ added in v0.7.0
func (NoopHook) BeforeProviderCall(context.Context, BeforeProviderCallState) (BeforeProviderCallResult, error)
func (NoopHook) BeforeToolCall ¶ added in v0.7.0
func (NoopHook) BeforeToolCall(context.Context, BeforeToolCallState) (BeforeToolCallResult, error)
type Request ¶
type Request struct {
SystemPrompt string
Messages []Message
Tools []Tool
Options RequestOptions
}
type RequestOptions ¶ added in v0.7.0
type RequestOptions struct {
Temperature *float64
MaxOutputTokens int64
ToolChoice ToolChoice
ResponseFormat ResponseFormat
Metadata map[string]string
}
func (RequestOptions) IsZero ¶ added in v0.7.0
func (o RequestOptions) IsZero() bool
func (RequestOptions) WithDefaults ¶ added in v0.7.0
func (o RequestOptions) WithDefaults(defaults RequestOptions) RequestOptions
type Response ¶
func ConsumeStream ¶ added in v0.7.0
type ResponseFormat ¶ added in v0.7.0
type RoundResult ¶ added in v0.7.0
type RunResult ¶ added in v0.7.0
type RunResult struct {
Content string
Messages []Message
Usage Usage
Rounds []RoundResult
StopReason StopReason
Duration time.Duration
}
type RunStartPolicy ¶ added in v0.7.0
type RunStartPolicy interface {
OnRunStart()
}
type Schema ¶ added in v0.7.0
type Schema struct {
// contains filtered or unexported fields
}
func SchemaObject ¶ added in v0.7.0
func SchemaObject() *Schema
func (*Schema) BooleanProp ¶ added in v0.7.0
func (*Schema) IntegerProp ¶ added in v0.7.0
func (*Schema) Properties ¶ added in v0.7.0
func (*Schema) RequiredFields ¶ added in v0.7.0
func (*Schema) StringProp ¶ added in v0.7.0
type Session ¶ added in v0.7.0
type Session struct {
Messages []Message
// contains filtered or unexported fields
}
type StopReason ¶ added in v0.7.0
type StopReason string
const ( StopReasonEndTurn StopReason = "end_turn" StopReasonMaxToolRounds StopReason = "max_tool_rounds" StopReasonError StopReason = "error" StopReasonCanceled StopReason = "canceled" )
type Stream ¶ added in v0.7.0
type Stream interface {
Next(context.Context) (StreamEvent, error)
Close() error
}
func NewResponseStream ¶ added in v0.7.0
type StreamEvent ¶ added in v0.7.0
type StreamEventType ¶ added in v0.7.0
type StreamEventType string
const ( StreamEventTextDelta StreamEventType = "text_delta" StreamEventThinkingDelta StreamEventType = "thinking_delta" StreamEventToolCallDelta StreamEventType = "tool_call_delta" StreamEventFinalResponse StreamEventType = "final_response" StreamEventUsage StreamEventType = "usage" )
type StreamHandler ¶ added in v0.7.0
type StreamHandler func(context.Context, StreamEvent)
type StreamProvider ¶ added in v0.7.0
type StructuredToolHandler ¶ added in v0.7.0
type StructuredToolHandler func(context.Context, json.RawMessage) (ToolResult, error)
type Tool ¶
type Tool struct {
Name string
Description string
Properties map[string]any
Required []string
Handler ToolHandler
StructuredHandler StructuredToolHandler
}
func NewStructuredTool ¶ added in v0.7.0
func NewTypedTool ¶
type ToolCallResult ¶ added in v0.7.0
type ToolChoice ¶ added in v0.7.0
type ToolHandler ¶
type ToolResult ¶ added in v0.7.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
enno
command
|
|
|
examples
|
|
|
anthropic
command
|
|
|
custom_tool
command
|
|
|
loadskill
command
|
|
|
simple_agent
command
|
|
|
subagent
command
|
|
|
internal
|
|
|
anthropic
Package anthropic adapts Anthropic Messages APIs to enno.Provider.
|
Package anthropic adapts Anthropic Messages APIs to enno.Provider. |
|
openai
Package openai adapts OpenAI-compatible Chat Completions APIs to enno.Provider.
|
Package openai adapts OpenAI-compatible Chat Completions APIs to enno.Provider. |
|
tools
|
|
|
glob
Package glob provides a read-only file listing tool backed by ripgrep (rg --files).
|
Package glob provides a read-only file listing tool backed by ripgrep (rg --files). |
|
grep
Package grep provides a read-only content search tool backed by ripgrep (rg).
|
Package grep provides a read-only content search tool backed by ripgrep (rg). |
|
taskgraph
Package taskgraph provides persistent DAG task tools (task_create / task_update / task_list / task_get) backed by JSON files under a configurable directory, aligned with s07-style task systems.
|
Package taskgraph provides persistent DAG task tools (task_create / task_update / task_list / task_get) backed by JSON files under a configurable directory, aligned with s07-style task systems. |