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 RegisterToolBuilder(b ToolBuilder)
- 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 BuiltTools
- type BuiltinTools
- type CompactTool
- type CompactionConfig
- type Config
- type Event
- type EventHandler
- type EventType
- type FetchURLTool
- type FilesystemTool
- type GlobTool
- type GrepTool
- type Hook
- type LoadSkillTool
- 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 PermissionMode
- 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 ShellSafetyPolicy
- type ShellTool
- type StopReason
- type Stream
- type StreamEvent
- type StreamEventType
- type StreamHandler
- type StreamProvider
- type StructuredToolHandler
- type SubagentTool
- type SystemPromptSection
- type TaskGraphTool
- 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 ToolBuilder
- type ToolCall
- type ToolCallResult
- type ToolChoice
- type ToolHandler
- type ToolPermissions
- 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.
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).
func RegisterToolBuilder ¶ added in v0.13.0
func RegisterToolBuilder(b ToolBuilder)
RegisterToolBuilder installs the tool builder used by NewAgent when BuiltinTools or related config fields are set. Call this from a wiring package (e.g. main) that imports both enno and the builtintools packages.
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 BuiltTools ¶ added in v0.13.0
BuiltTools holds the result of assembling built-in tool configuration.
type BuiltinTools ¶ added in v0.13.0
type BuiltinTools struct {
TaskGraph *TaskGraphTool
Filesystem *FilesystemTool
Shell *ShellTool
Grep *GrepTool
Glob *GlobTool
FetchURL *FetchURLTool
Subagent *SubagentTool
LoadSkill *LoadSkillTool
Compact *CompactTool
}
type CompactTool ¶ added in v0.13.0
type CompactTool struct{}
type CompactionConfig ¶ added in v0.5.0
type CompactionConfig struct {
Enabled bool
// TranscriptDir stores JSONL transcripts before summarization. Empty keeps
// transcript persistence disabled; applications that enable compaction should
// set this when they want transcripts written to disk.
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
SystemPromptSections []SystemPromptSection
BuiltinTools BuiltinTools
Permissions ToolPermissions
Tools []Tool
CustomTools []Tool
MaxToolRounds int
EventHandler EventHandler
Compaction *CompactionConfig
Options RequestOptions
Policies []Policy
Hooks []Hook
}
func AssembleConfig ¶ added in v0.13.0
AssembleConfig resolves the high-level Config fields (BuiltinTools, SystemPromptSections, Permissions, CustomTools) into a low-level Config ready for Agent construction. It is called automatically by NewAgent when any assembly-level fields are set.
type EventHandler ¶ added in v0.3.0
type FetchURLTool ¶ added in v0.13.0
type FilesystemTool ¶ added in v0.13.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 LoadSkillTool ¶ added in v0.13.0
type LoadSkillTool struct {
Dirs []string
}
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 PermissionMode ¶ added in v0.13.0
type PermissionMode string
const ( PermissionAsk PermissionMode = "ask" PermissionAllow PermissionMode = "allow" PermissionDeny PermissionMode = "deny" )
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 ShellSafetyPolicy ¶ added in v0.13.0
type ShellSafetyPolicy string
const ( ShellSafetyPolicyDenyList ShellSafetyPolicy = "denylist" ShellSafetyPolicyAllowAll ShellSafetyPolicy = "allow_all" )
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 SubagentTool ¶ added in v0.13.0
type SubagentTool struct {
SystemPrompt string
MaxToolRounds int
MaxResultChars int
ToolName string
EventHandler EventHandler
}
type SystemPromptSection ¶ added in v0.13.0
SystemPromptSection is an application-owned named system prompt section.
type TaskGraphTool ¶ added in v0.13.0
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 ToolBuilder ¶ added in v0.13.0
type ToolBuilder interface {
BuildTools(BuiltinTools) (BuiltTools, error)
BuildCompact() ([]Tool, error)
BuildSubagent(SubagentTool, Provider, []Tool, []Hook) (Tool, error)
}
ToolBuilder constructs Tool slices from BuiltinTools configuration.
type ToolCallResult ¶ added in v0.7.0
type ToolChoice ¶ added in v0.7.0
type ToolHandler ¶
type ToolPermissions ¶ added in v0.13.0
type ToolPermissions struct {
Mode PermissionMode
AllowedTools []string
DisallowedTools []string
}
func (ToolPermissions) IsZero ¶ added in v0.13.0
func (p ToolPermissions) IsZero() bool
type ToolResult ¶ added in v0.7.0
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
builtintools
|
|
|
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. |
|
examples
|
|
|
anthropic
command
|
|
|
custom_tool
command
|
|
|
loadskill
command
|
|
|
sdk_walkthrough
command
|
|
|
simple_agent
command
|
|
|
subagent
command
|
|
|
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. |
|
Package setup registers the default ToolBuilder that constructs built-in tools from enno.BuiltinTools configuration.
|
Package setup registers the default ToolBuilder that constructs built-in tools from enno.BuiltinTools configuration. |