Documentation
¶
Index ¶
- Constants
- func ClearProviderRegistry()
- func GetRegisteredProviders() []string
- func HasSubscribers(eventType string) bool
- func NewAgentInput(text string) types.AgentInput
- func Publish(eventType string, sessionID string, data interface{})
- func RegisterLLMProvider(name string, factory LLMProviderFactory)
- func SetGlobalBus(bus *Bus)
- func Subscribe(eventType string, handler func(BusEvent))
- func SubscribeAsync(eventType string, handler func(BusEvent), transactional bool)
- func SubscribeOnce(eventType string, handler func(BusEvent))
- func SubscribeOnceAsync(eventType string, handler func(BusEvent))
- func Unsubscribe(eventType string, handler func(BusEvent)) bool
- func WaitAsync()
- type ApprovalError
- type ApprovalSender
- type ApprovalStore
- type ApprovalTool
- func (a *ApprovalTool) Description() string
- func (a *ApprovalTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
- func (a *ApprovalTool) Metadata() types.ToolMetadata
- func (a *ApprovalTool) Name() string
- func (a *ApprovalTool) RequiresApproval() bool
- func (a *ApprovalTool) Schema() map[string]interface{}
- type AssistantMeta
- type AssistantPath
- type Budget
- type BudgetConfig
- type BudgetRequest
- type BudgetResult
- type BudgetState
- type Bus
- func (b *Bus) HasSubscribers(eventType string) bool
- func (b *Bus) Publish(eventType string, sessionID string, data interface{})
- func (b *Bus) Subscribe(eventType string, handler func(BusEvent))
- func (b *Bus) SubscribeAsync(eventType string, handler func(BusEvent), transactional bool)
- func (b *Bus) SubscribeOnce(eventType string, handler func(BusEvent))
- func (b *Bus) SubscribeOnceAsync(eventType string, handler func(BusEvent))
- func (b *Bus) Unsubscribe(eventType string, handler func(BusEvent)) bool
- func (b *Bus) WaitAsync()
- type BusEvent
- type Client
- type ClientOption
- type ClientSession
- func (cs *ClientSession) Close()
- func (cs *ClientSession) Done() <-chan struct{}
- func (cs *ClientSession) Err() <-chan error
- func (cs *ClientSession) Handler() *HandlerBuilder
- func (cs *ClientSession) Input() chan<- interface{}
- func (cs *ClientSession) Output() <-chan *Event
- func (cs *ClientSession) Send(ctx context.Context, input types.AgentInput) error
- func (cs *ClientSession) SendAndWait(ctx context.Context, input types.AgentInput) (*Event, error)
- func (cs *ClientSession) Subscribe(observer Observer) string
- func (cs *ClientSession) SubscribeFunc(fn func(*Event)) string
- func (cs *ClientSession) Unsubscribe(id string)
- type Config
- type Cost
- type DefinedTool
- func (t *DefinedTool) Description() string
- func (t *DefinedTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
- func (t *DefinedTool) Metadata() types.ToolMetadata
- func (t *DefinedTool) Name() string
- func (t *DefinedTool) Schema() map[string]interface{}
- func (t *DefinedTool) ToAgentTool() types.Tool
- func (t *DefinedTool) ToJSON() (string, error)
- func (t *DefinedTool) WithParameters(params map[string]interface{}) *DefinedTool
- type DinoFactory
- type Event
- type EventHandler
- type EventType
- type ExecuteRequest
- type ExecuteResponse
- type FactoryOption
- type FileAttachment
- type FilePart
- type HandlerBuilder
- func (hb *HandlerBuilder) Build() string
- func (hb *HandlerBuilder) OnApproval(fn func(toolName string, approved bool)) *HandlerBuilder
- func (hb *HandlerBuilder) OnDone(fn func()) *HandlerBuilder
- func (hb *HandlerBuilder) OnError(fn func(err string)) *HandlerBuilder
- func (hb *HandlerBuilder) OnMessage(fn func(content string)) *HandlerBuilder
- func (hb *HandlerBuilder) OnThinking(fn func(thinking string)) *HandlerBuilder
- func (hb *HandlerBuilder) OnToolCall(fn func(toolName string, input map[string]interface{})) *HandlerBuilder
- func (hb *HandlerBuilder) OnToolResult(fn func(toolName string, output interface{})) *HandlerBuilder
- type LLMProviderFactory
- type LoopDetectionConfig
- type MCPConfig
- type MCPServerConfig
- type MemoryConfig
- type Message
- func (m *Message) AddReasoning(text string)
- func (m *Message) AddText(text string)
- func (m *Message) AddToolCall(toolCallID, toolName string, args map[string]interface{})
- func (m *Message) AddToolResult(toolCallID, toolName, result string)
- func (m *Message) Complete()
- func (m *Message) GetReasoning() string
- func (m *Message) GetText() string
- func (m *Message) GetToolCalls() []ToolInvocation
- func (m *Message) GetToolResults() []ToolInvocation
- type MessageError
- type MessageInfo
- type MessageMetadata
- type MessageRole
- type MessageTime
- type OAuthConfig
- type Observer
- type ObserverFunc
- type Part
- type PartInfo
- type PermissionRequest
- type Plan
- type PlanStep
- type PlannerModeConfig
- type ProviderConfig
- type ProviderError
- type ReasoningPart
- type Session
- type SessionLister
- type SessionOption
- type Skill
- type SkillsConfig
- type SourceURLPart
- type StepStartPart
- type StreamEvent
- type StreamEventSender
- type TextPart
- type TokenCache
- type TokenInfo
- type ToolCallInfo
- type ToolConfig
- type ToolContext
- type ToolDefinition
- type ToolExecutor
- type ToolInvocation
- type ToolInvocationPart
- type ToolInvocationState
- type ToolMeta
- type ToolMetaTime
- type ToolMetadataExt
- type ToolResult
- type ToolState
- type ToolTime
- type Usage
Constants ¶
View Source
const ( EventSessionCreated = "session.created" EventSessionUpdated = "session.updated" EventSessionDeleted = "session.deleted" EventSessionError = "session.error" EventMessageCreated = "message.created" EventMessageUpdated = "message.updated" EventMessageDeleted = "message.deleted" EventToolInvoked = "tool.invoked" EventToolResult = "tool.result" EventToolError = "tool.error" EventUsageUpdated = "usage.updated" EventApprovalRequired = "approval.required" EventApprovalGiven = "approval.given" EventApprovalDenied = "approval.denied" EventPermissionAsked = "permission.asked" EventPermissionReply = "permission.reply" )
View Source
const ( EventTypeMessage = session.EventTypeMessage EventTypeThinking = session.EventTypeThinking EventTypeToolCall = session.EventTypeToolCall EventTypeToolResult = session.EventTypeToolResult EventTypeToolStart = session.EventTypeToolStart EventTypeTokenUsage = session.EventTypeTokenUsage EventTypeError = session.EventTypeError EventTypeDone = session.EventTypeDone EventTypeApproved = session.EventTypeApproved EventTypeApproval = session.EventTypeApproval EventTypePlan = session.EventTypePlan EventTypePlanStep = session.EventTypePlanStep StreamEventContent = session.EventTypeMessage StreamEventReasoning = session.EventTypeThinking StreamEventToolCall = session.EventTypeToolCall StreamEventToolResult = session.EventTypeToolResult StreamEventError = session.EventTypeError StreamEventDone = session.EventTypeDone StreamEventApproval = session.EventTypeApproval )
Variables ¶
This section is empty.
Functions ¶
func ClearProviderRegistry ¶
func ClearProviderRegistry()
func GetRegisteredProviders ¶
func GetRegisteredProviders() []string
func HasSubscribers ¶
func NewAgentInput ¶
func NewAgentInput(text string) types.AgentInput
func RegisterLLMProvider ¶
func RegisterLLMProvider(name string, factory LLMProviderFactory)
func SetGlobalBus ¶
func SetGlobalBus(bus *Bus)
func SubscribeAsync ¶
func SubscribeOnce ¶
func SubscribeOnceAsync ¶
func Unsubscribe ¶
Types ¶
type ApprovalError ¶
type ApprovalError string
const ( ErrApprovalTimeout ApprovalError = "approval timeout" ErrApprovalNotAvailable ApprovalError = "approval not available in this context" )
func (ApprovalError) Error ¶
func (e ApprovalError) Error() string
type ApprovalSender ¶
type ApprovalStore ¶
type ApprovalStore struct {
// contains filtered or unexported fields
}
func NewApprovalStore ¶
func NewApprovalStore(timeout time.Duration) *ApprovalStore
func (*ApprovalStore) Clear ¶
func (s *ApprovalStore) Clear()
func (*ApprovalStore) RequestApproval ¶
func (*ApprovalStore) Respond ¶
func (s *ApprovalStore) Respond(requestID string, approved bool)
func (*ApprovalStore) SetSender ¶
func (s *ApprovalStore) SetSender(sender ApprovalSender)
type ApprovalTool ¶
type ApprovalTool struct {
// contains filtered or unexported fields
}
func NewApprovalTool ¶
func NewApprovalTool(inner types.Tool, sessionID string, store *ApprovalStore, dangerous map[string]bool) *ApprovalTool
func (*ApprovalTool) Description ¶
func (a *ApprovalTool) Description() string
func (*ApprovalTool) Execute ¶
func (a *ApprovalTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
func (*ApprovalTool) Metadata ¶
func (a *ApprovalTool) Metadata() types.ToolMetadata
func (*ApprovalTool) Name ¶
func (a *ApprovalTool) Name() string
func (*ApprovalTool) RequiresApproval ¶
func (a *ApprovalTool) RequiresApproval() bool
func (*ApprovalTool) Schema ¶
func (a *ApprovalTool) Schema() map[string]interface{}
type AssistantMeta ¶
type AssistantPath ¶
type Budget ¶
type Budget = agentutils.Budget
func NewBudget ¶
func NewBudget(cfg *BudgetConfig) Budget
type BudgetConfig ¶
type BudgetRequest ¶
type BudgetRequest = agentutils.BudgetRequest
type BudgetResult ¶
type BudgetResult = agentutils.BudgetResult
type BudgetState ¶
type BudgetState = agentutils.BudgetState
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func GetGlobalBus ¶
func GetGlobalBus() *Bus
func (*Bus) HasSubscribers ¶
func (*Bus) SubscribeAsync ¶
func (*Bus) SubscribeOnce ¶
func (*Bus) SubscribeOnceAsync ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(factory DinoFactory, opts ...ClientOption) *Client
func (*Client) CloseSession ¶
func (*Client) CreateSession ¶
func (*Client) GetSession ¶
func (c *Client) GetSession(sessionID string) *ClientSession
func (*Client) ListSessions ¶
type ClientOption ¶
type ClientOption func(*clientConfig)
func WithSessionBufferSize ¶
func WithSessionBufferSize(size int) ClientOption
func WithSessionQueueEnabled ¶
func WithSessionQueueEnabled(maxSize, maxPending int) ClientOption
type ClientSession ¶
type ClientSession struct {
*Session
// contains filtered or unexported fields
}
func (*ClientSession) Close ¶
func (cs *ClientSession) Close()
func (*ClientSession) Done ¶
func (cs *ClientSession) Done() <-chan struct{}
func (*ClientSession) Err ¶
func (cs *ClientSession) Err() <-chan error
func (*ClientSession) Handler ¶
func (cs *ClientSession) Handler() *HandlerBuilder
func (*ClientSession) Input ¶
func (cs *ClientSession) Input() chan<- interface{}
func (*ClientSession) Output ¶
func (cs *ClientSession) Output() <-chan *Event
func (*ClientSession) Send ¶
func (cs *ClientSession) Send(ctx context.Context, input types.AgentInput) error
func (*ClientSession) SendAndWait ¶
func (cs *ClientSession) SendAndWait(ctx context.Context, input types.AgentInput) (*Event, error)
func (*ClientSession) Subscribe ¶
func (cs *ClientSession) Subscribe(observer Observer) string
func (*ClientSession) SubscribeFunc ¶
func (cs *ClientSession) SubscribeFunc(fn func(*Event)) string
func (*ClientSession) Unsubscribe ¶
func (cs *ClientSession) Unsubscribe(id string)
type Config ¶
type Config struct {
DefaultModel string `yaml:"default_model"`
DefaultProvider string `yaml:"default_provider"`
Temperature float32 `yaml:"temperature"`
MaxTokens int `yaml:"max_tokens"`
TopP float32 `yaml:"top_p"`
Timeout time.Duration `yaml:"timeout"`
SystemPrompt string `yaml:"system_prompt"`
MaxIterations int `yaml:"max_iterations"`
MaxSessions int `yaml:"max_sessions"`
ToolExecutionTimeout time.Duration `yaml:"tool_execution_timeout"`
ToolTimeouts map[string]time.Duration `yaml:"tool_timeouts"`
ToolTimeoutCalculator func(toolName string, input map[string]interface{}) time.Duration
LoopDetection LoopDetectionConfig `yaml:"loop_detection"`
Budget BudgetConfig `yaml:"budget"`
Tools ToolConfig `yaml:"tools"`
Permission map[string]interface{} `yaml:"permission"`
WorkspaceRoot string `yaml:"workspace_root"`
Skills SkillsConfig `yaml:"skills"`
Provider ProviderConfig `yaml:"provider"`
PlannerMode PlannerModeConfig `yaml:"planner_mode"`
Memory MemoryConfig `yaml:"memory"`
Subagent agent.SubagentConfig `yaml:"subagent"`
MCP MCPConfig `yaml:"mcp"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
type Cost ¶
type Cost = agentutils.Cost
type DefinedTool ¶
type DefinedTool struct {
// contains filtered or unexported fields
}
func DefinedToolFromAgent ¶
func DefinedToolFromAgent(agentTool types.Tool) *DefinedTool
func DefinedToolFromJSON ¶
func DefinedToolFromJSON(jsonStr string) (*DefinedTool, error)
func NewDefinedTool ¶
func NewDefinedTool(id, name, description string, executor ToolExecutor) *DefinedTool
func (*DefinedTool) Description ¶
func (t *DefinedTool) Description() string
func (*DefinedTool) Execute ¶
func (t *DefinedTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
func (*DefinedTool) Metadata ¶
func (t *DefinedTool) Metadata() types.ToolMetadata
func (*DefinedTool) Name ¶
func (t *DefinedTool) Name() string
func (*DefinedTool) Schema ¶
func (t *DefinedTool) Schema() map[string]interface{}
func (*DefinedTool) ToAgentTool ¶
func (t *DefinedTool) ToAgentTool() types.Tool
func (*DefinedTool) ToJSON ¶
func (t *DefinedTool) ToJSON() (string, error)
func (*DefinedTool) WithParameters ¶
func (t *DefinedTool) WithParameters(params map[string]interface{}) *DefinedTool
type DinoFactory ¶
type DinoFactory interface {
CreateSession(ctx context.Context, sessionID string, opts ...session.Option) (*session.Session, error)
GetSession(sessionID string) *session.Session
CloseSession(sessionID string)
CloseAll()
GetTools() []types.Tool
GetSkills() []*Skill
Shutdown(ctx context.Context) error
GetLLMProvider() types.LLMProvider
GetPlannerConfig() *PlannerModeConfig
Budget() Budget
}
func NewDinoFactory ¶
func NewDinoFactory(cfg *Config, opts ...FactoryOption) (DinoFactory, error)
type EventHandler ¶
type EventHandler func(event *Event)
type ExecuteRequest ¶
type ExecuteRequest struct {
SessionID string
Content string
Files []FileAttachment
ExtraSystemPrompt string
Stream bool
}
type ExecuteResponse ¶
type ExecuteResponse = session.ExecuteResponse
type FactoryOption ¶
type FactoryOption func(*dinoFactory)
func WithStreamEventSender ¶
func WithStreamEventSender(sender StreamEventSender) FactoryOption
type FileAttachment ¶
type HandlerBuilder ¶
type HandlerBuilder struct {
// contains filtered or unexported fields
}
func (*HandlerBuilder) Build ¶
func (hb *HandlerBuilder) Build() string
func (*HandlerBuilder) OnApproval ¶
func (hb *HandlerBuilder) OnApproval(fn func(toolName string, approved bool)) *HandlerBuilder
func (*HandlerBuilder) OnDone ¶
func (hb *HandlerBuilder) OnDone(fn func()) *HandlerBuilder
func (*HandlerBuilder) OnError ¶
func (hb *HandlerBuilder) OnError(fn func(err string)) *HandlerBuilder
func (*HandlerBuilder) OnMessage ¶
func (hb *HandlerBuilder) OnMessage(fn func(content string)) *HandlerBuilder
func (*HandlerBuilder) OnThinking ¶
func (hb *HandlerBuilder) OnThinking(fn func(thinking string)) *HandlerBuilder
func (*HandlerBuilder) OnToolCall ¶
func (hb *HandlerBuilder) OnToolCall(fn func(toolName string, input map[string]interface{})) *HandlerBuilder
func (*HandlerBuilder) OnToolResult ¶
func (hb *HandlerBuilder) OnToolResult(fn func(toolName string, output interface{})) *HandlerBuilder
type LLMProviderFactory ¶
type LLMProviderFactory func(config *Config) (types.LLMProvider, error)
type LoopDetectionConfig ¶
type MCPConfig ¶
type MCPConfig struct {
Enabled bool `yaml:"enabled"`
Servers map[string]MCPServerConfig `yaml:"servers"`
}
type MCPServerConfig ¶
type MCPServerConfig struct {
Type string `yaml:"type"` // "remote" | "stdio"
URL string `yaml:"url,omitempty"`
Command string `yaml:"command,omitempty"`
Args []string `yaml:"args,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Headers map[string]string `yaml:"headers,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
OAuth *OAuthConfig `yaml:"oauth,omitempty"`
Enabled bool `yaml:"enabled"`
}
type MemoryConfig ¶
type MemoryConfig struct {
EnableCompress bool `yaml:"enable_compress"`
MaxHistoryMessages int `yaml:"max_history_messages"`
CompressThreshold int `yaml:"compress_threshold"`
KeepRecentCount int `yaml:"keep_recent_count"`
PersistDirectory string `yaml:"persist_directory"`
PersistEnabled bool `yaml:"persist_enabled"`
Type string `yaml:"type"` // "memory" or "sqlite"
}
type Message ¶
type Message struct {
ID string `json:"id"`
Role MessageRole `json:"role"`
Parts []Part `json:"parts"`
Metadata *MessageMetadata `json:"metadata,omitempty"`
}
func NewMessage ¶
func NewMessage(id string, role MessageRole, sessionID string) *Message
func (*Message) AddReasoning ¶
func (*Message) AddToolCall ¶
func (*Message) AddToolResult ¶
func (*Message) GetReasoning ¶
func (*Message) GetToolCalls ¶
func (m *Message) GetToolCalls() []ToolInvocation
func (*Message) GetToolResults ¶
func (m *Message) GetToolResults() []ToolInvocation
type MessageError ¶
type MessageInfo ¶
type MessageMetadata ¶
type MessageMetadata struct {
Time MessageTime `json:"time"`
Error *MessageError `json:"error,omitempty"`
SessionID string `json:"session_id"`
Tool map[string]ToolMeta `json:"tool,omitempty"`
Assistant *AssistantMeta `json:"assistant,omitempty"`
Snapshot string `json:"snapshot,omitempty"`
}
type MessageRole ¶
type MessageRole string
const ( RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" )
type MessageTime ¶
type OAuthConfig ¶
type ObserverFunc ¶
type ObserverFunc = session.ObserverFunc
type PermissionRequest ¶
type PlannerModeConfig ¶
type ProviderConfig ¶
type ProviderError ¶
type ProviderError string
const ErrProviderNotFound ProviderError = "provider not found"
func (ProviderError) Error ¶
func (e ProviderError) Error() string
type ReasoningPart ¶
type SessionLister ¶
type SessionLister interface {
ListSessions() []string
}
type SessionOption ¶
func WithInputBufferSize ¶
func WithInputBufferSize(size int) SessionOption
func WithOutputBufferSize ¶
func WithOutputBufferSize(size int) SessionOption
func WithPlannerEnabled ¶
func WithPlannerEnabled(enabled bool, prompt string, autoApprove bool) SessionOption
func WithQueueEnabled ¶
func WithQueueEnabled(maxSize, maxPending int) SessionOption
type SkillsConfig ¶
type SourceURLPart ¶
type StepStartPart ¶
type StepStartPart struct {
Type string `json:"type"`
}
type StreamEvent ¶
type StreamEventSender ¶
type StreamEventSender interface {
SendStreamEvent(sessionID string, event interface{})
}
type TokenCache ¶
type TokenInfo ¶
type TokenInfo struct {
Input int `json:"input"`
Output int `json:"output"`
Reasoning int `json:"reasoning"`
Cache TokenCache `json:"cache"`
}
type ToolCallInfo ¶
type ToolCallInfo = session.ToolCallInfo
type ToolConfig ¶
type ToolContext ¶
type ToolContext struct {
SessionID string
MessageID string
Agent string
Abort <-chan struct{}
CallID string
Extra map[string]interface{}
Messages []MessageInfo
Metadata func(title string, metadata map[string]interface{})
Ask func(request PermissionRequest) error
}
type ToolDefinition ¶
type ToolDefinition struct {
ID string
Name string
Description string
Parameters map[string]interface{}
Metadata ToolMetadataExt
}
type ToolExecutor ¶
type ToolExecutor func(args map[string]interface{}, ctx ToolContext) (*ToolResult, error)
type ToolInvocation ¶
type ToolInvocationPart ¶
type ToolInvocationPart struct {
Type string `json:"type"`
ToolInvocation ToolInvocation `json:"tool_invocation"`
}
type ToolInvocationState ¶
type ToolInvocationState string
const ( ToolStateCall ToolInvocationState = "call" ToolStatePartialCall ToolInvocationState = "partial-call" ToolStateResult ToolInvocationState = "result" )
type ToolMeta ¶
type ToolMeta struct {
Title string `json:"title"`
Snapshot string `json:"snapshot,omitempty"`
Time ToolMetaTime `json:"time"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
type ToolMetaTime ¶
type ToolMetadataExt ¶
type ToolMetadataExt struct {
Title string `json:"title,omitempty"`
Snapshot string `json:"snapshot,omitempty"`
Truncated bool `json:"truncated,omitempty"`
OutputPath string `json:"output_path,omitempty"`
Attachments []FileAttachment `json:"attachments,omitempty"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
type ToolResult ¶
type ToolResult struct {
Title string `json:"title"`
Metadata map[string]interface{} `json:"metadata"`
Output string `json:"output"`
Attachments []FileAttachment `json:"attachments,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.