Documentation
¶
Index ¶
- Constants
- func ClearProviderRegistry()
- func ConfigurePromptCache(provider types.LLMProvider, opts types.PromptCacheOptions)
- 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 ValidateConfig(cfg *Config) error
- func WaitAsync()
- type ApprovalError
- type ApprovalRejectedError
- 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 EventSource
- type EventType
- type ExecuteRequest
- type ExecuteResponse
- type ExternalPathApprovalTool
- func (e *ExternalPathApprovalTool) Description() string
- func (e *ExternalPathApprovalTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
- func (e *ExternalPathApprovalTool) Metadata() types.ToolMetadata
- func (e *ExternalPathApprovalTool) Name() string
- func (e *ExternalPathApprovalTool) Schema() map[string]interface{}
- 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) OnQuestion(fn func(question string, toolCallID string)) *HandlerBuilder
- func (hb *HandlerBuilder) OnSubagentMessage(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 MemLongTermConfig
- 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 OutputObserver
- type Part
- type PartInfo
- type PermissionRequest
- type Plan
- type PlanStep
- type PlannerModeConfig
- type PromptCachingConfig
- 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 TraceConfig
- type TurnCanceledError
- type TurnObservation
- type TurnSessionClosedError
- type Usage
Constants ¶
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" )
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 EventTypeQuestion = session.EventTypeQuestion StreamEventContent = session.EventTypeMessage StreamEventReasoning = session.EventTypeThinking StreamEventToolCall = session.EventTypeToolCall StreamEventToolResult = session.EventTypeToolResult StreamEventError = session.EventTypeError StreamEventDone = session.EventTypeDone StreamEventApproval = session.EventTypeApproval EventSourceUser = session.EventSourceUser EventSourceSubagent = session.EventSourceSubagent )
Variables ¶
This section is empty.
Functions ¶
func ClearProviderRegistry ¶
func ClearProviderRegistry()
func ConfigurePromptCache ¶ added in v1.10.0
func ConfigurePromptCache(provider types.LLMProvider, opts types.PromptCacheOptions)
ConfigurePromptCache applies prompt caching to a provider that supports it. It is a no-op for providers that don't implement types.PromptCacheConfigurer (OpenAI/DeepSeek/Volce — no cache_control protocol).
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 ¶
func ValidateConfig ¶ added in v1.10.0
ValidateConfig 在构造 DinoFactory 前做配置校验,让配置错误尽早、清晰暴露 (而不是等到 createLLMProvider 时才报笼统的 provider not found)。
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 ApprovalRejectedError ¶ added in v1.10.0
type ApprovalRejectedError = dinoTools.ApprovalRejectedError
ApprovalRejectedError marks a user denial of a tool approval. It is an unrecoverable user veto: feeding it back to the model as a recoverable {ok:false} result would make the model retry the very tool the user just refused, looping until the doom detector fires. Wrappers (nonFatalTool) must pass it through as a real error so the engine surfaces the veto instead of resuming the loop. Defined in dino/tools so both the approval wrappers here and nonFatalTool (in dino/tools) can share it without an import cycle.
type ApprovalSender ¶
type ApprovalStore ¶
type ApprovalStore struct {
// contains filtered or unexported fields
}
ApprovalStore gates tool execution on user approval via ApprovalSender. Call SetSender before any tool that uses ActionAsk runs; if sender is nil, RequestApproval returns ErrApprovalNotAvailable immediately.
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) bool
Respond delivers an approval decision to the pending RequestApproval waiter. It returns true if the decision was delivered, false if the requestID is unknown/cleaned up or the delivery timed out. Unlike the previous select-default drop, it blocks (up to approvalRespondTimeout) so a response is never silently lost while the waiter is still alive.
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 `json:"-" yaml:"-"`
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"`
PromptCaching PromptCachingConfig `yaml:"prompt_caching"`
LongTermMemory MemLongTermConfig `yaml:"long_term_memory"`
Subagent agent.SubagentConfig `yaml:"subagent"`
MCP MCPConfig `yaml:"mcp"`
Trace TraceConfig `yaml:"trace"`
}
func CloneConfig ¶ added in v1.9.1
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) PromptCacheOptions ¶ added in v1.10.0
func (c *Config) PromptCacheOptions() types.PromptCacheOptions
PromptCacheOptions maps dino's PromptCachingConfig onto the shared types.PromptCacheOptions, starting from provider defaults so partial YAML overrides don't zero unrelated toggles.
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
RespondToolApproval(requestID string, approved bool)
SaveSessionSnapshot(ctx context.Context, sessionID string, dir string) (string, error)
RestoreSessionSnapshot(ctx context.Context, sessionID string, snapPath string) error
}
func NewDinoFactory ¶
func NewDinoFactory(cfg *Config, opts ...FactoryOption) (DinoFactory, error)
type EventHandler ¶
type EventHandler func(event *Event)
type EventSource ¶ added in v1.10.0
type EventSource = session.EventSource
type ExecuteRequest ¶
type ExecuteRequest struct {
SessionID string
Content string
Files []FileAttachment
ExtraSystemPrompt string
Stream bool
}
type ExecuteResponse ¶
type ExecuteResponse = session.ExecuteResponse
type ExternalPathApprovalTool ¶ added in v1.8.10
type ExternalPathApprovalTool struct {
// contains filtered or unexported fields
}
func NewExternalPathApprovalTool ¶ added in v1.8.10
func NewExternalPathApprovalTool(inner types.Tool, workspace, sessionID string, store *ApprovalStore) *ExternalPathApprovalTool
func (*ExternalPathApprovalTool) Description ¶ added in v1.8.10
func (e *ExternalPathApprovalTool) Description() string
func (*ExternalPathApprovalTool) Execute ¶ added in v1.8.10
func (e *ExternalPathApprovalTool) Execute(ctx context.Context, input map[string]interface{}) (interface{}, error)
func (*ExternalPathApprovalTool) Metadata ¶ added in v1.8.10
func (e *ExternalPathApprovalTool) Metadata() types.ToolMetadata
func (*ExternalPathApprovalTool) Name ¶ added in v1.8.10
func (e *ExternalPathApprovalTool) Name() string
func (*ExternalPathApprovalTool) Schema ¶ added in v1.8.10
func (e *ExternalPathApprovalTool) Schema() map[string]interface{}
type FactoryOption ¶
type FactoryOption func(*dinoFactory)
func WithApprovalSender ¶ added in v1.8.10
func WithApprovalSender(sender ApprovalSender) FactoryOption
func WithHooks ¶ added in v1.9.3
func WithHooks(h hooks.Hooks) FactoryOption
WithHooks sets lifecycle hooks that will be applied to every session created by this factory. This is a convenience alternative to calling session.GetAgent().SetHooks() after CreateSession.
func WithSessionTools ¶ added in v1.8.9
func WithSessionTools(fn func(sessionID string) []types.Tool) FactoryOption
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) OnQuestion ¶ added in v1.10.0
func (hb *HandlerBuilder) OnQuestion(fn func(question string, toolCallID string)) *HandlerBuilder
OnQuestion 注册 question 工具提问回调(P2.1)。question 工具被调用且返回 SentinelQuestionResult 时触发,调用方可把问题展示给用户。
func (*HandlerBuilder) OnSubagentMessage ¶ added in v1.10.0
func (hb *HandlerBuilder) OnSubagentMessage(fn func(content string)) *HandlerBuilder
OnSubagentMessage 注册子代理完成唤醒注入消息的回调(S4/B2)。不注册时这些 "幽灵消息"被折叠(默认不喷 UI);注册后由调用方决定如何展示。
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 MemLongTermConfig ¶ added in v1.10.0
type MemLongTermConfig = mem.MemLongTermConfig
MemLongTermConfig 长期记忆配置段。定义在 dino/mem 包(避免 import cycle), 这里按原样引用。
type MemoryConfig ¶
type MemoryConfig struct {
EnableCompress bool `yaml:"enable_compress"`
EnableLLMCompress bool `yaml:"enable_llm_compress"` // 压缩是否走 LLM 摘要(Hybrid 包裹);false 退回 DeterministicCompact。与 EnableCompress(是否压缩)语义正交
MaxHistoryMessages int `yaml:"max_history_messages"`
MaxBudgetTokens int `yaml:"max_budget_tokens"`
CompactAfterTurns int `yaml:"compact_after_turns"`
CompressThreshold int `yaml:"compress_threshold"` // message-count gate for async compress; if <=0, CreateSession uses budget.max_tool_calls/2 then agent default
KeepRecentCount int `yaml:"keep_recent_count"`
PersistDirectory string `yaml:"persist_directory"`
PersistFileName string `yaml:"persist_file_name"`
PersistEnabled bool `yaml:"persist_enabled"`
Type string `yaml:"type"` // "memory" or "sqlite"
// CompactionPrefix enables prefix-preserving compaction (P3.1 · prompt
// caching Step 4): trimHistoryToTokenBudget keeps a head cache anchor and
// preserves the recent tail verbatim, replacing the middle with a summary,
// so prompt-cache segments 1-2 (system+tools) survive compaction. Default
// off (conservative): the trim output structure changes when on.
CompactionPrefix bool `yaml:"compaction_prefix"`
// CacheAnchorTokens caps the head-cache-anchor budget (tokens). 0 = no
// anchor (the head is trimmed like today). Default 0. Suggest ≤30% of
// MaxBudgetTokens so the tail keeps enough room to anchor segment 3 (R5).
CacheAnchorTokens int `yaml:"cache_anchor_tokens"`
}
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 OutputObserver ¶ added in v1.9.1
type OutputObserver = session.OutputObserver
type PermissionRequest ¶
type PlannerModeConfig ¶
type PromptCachingConfig ¶ added in v1.10.0
type PromptCachingConfig struct {
Enabled bool `yaml:"enabled"` // default true (pure cost optimization)
SystemBreakpoint *bool `yaml:"system_breakpoint,omitempty"`
ToolsBreakpoint *bool `yaml:"tools_breakpoint,omitempty"`
HistoryEveryN *int `yaml:"history_every_n,omitempty"` // history breakpoint budget (≤ remaining of 4); 0 = none
MinCacheTokens *int `yaml:"min_cache_tokens,omitempty"`
}
PromptCachingConfig controls provider prompt caching. nil sub-fields mean "use the provider default" (see types.DefaultPromptCacheOptions). This lets a partial YAML block (e.g. only `enabled: false`) override just that field instead of silently zeroing the other toggles.
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 ToolConfig struct {
Profile string `yaml:"profile"`
Allowed []string `yaml:"allowed"`
ApprovalRequired []string `yaml:"approval_required"`
Denied []string `yaml:"denied"`
MaxToolParallelism int `yaml:"max_tool_parallelism,omitempty"` // 0=默认 max(4, GOMAXPROCS*2);>0 用该值
StreamBufferSize int `yaml:"stream_buffer_size,omitempty"` // 0=默认 50
ResultLimiterMaxBytes int `yaml:"result_limiter_max_bytes,omitempty"` // 0=默认 120_000
ResultLimiterMaxStringBytes int `yaml:"result_limiter_max_string_bytes,omitempty"` // 0=默认 60_000
// ToolSearchEnabled 控制是否注入 tool_search 工具并启用 Deferred 工具的
// 延迟发现(E2)。默认 true。
ToolSearchEnabled bool `yaml:"tool_search_enabled,omitempty"`
// MCPDeferred 为 true 时,所有 MCP 工具以 ExposureDeferred 注册(不进初始
// 工具列表,靠 tool_search 发现)。默认 false 灰度,稳定后翻 true(§2.5)。
MCPDeferred bool `yaml:"mcp_deferred,omitempty"`
// MaxDiscoveredTools 每个 session 可通过 tool_search 发现/注入的 Deferred
// 工具上限(R1)。0 = 默认 32;<0 = 不设上限。
MaxDiscoveredTools int `yaml:"max_discovered_tools,omitempty"`
}
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"`
}
type TraceConfig ¶ added in v1.10.0
type TraceConfig struct {
Enabled bool `yaml:"enabled"`
Dir string `yaml:"dir,omitempty"` // default "./dino_sessions/traces"
QueueSize int `yaml:"queue_size,omitempty"`
FlushIntervalMs int `yaml:"flush_interval_ms,omitempty"`
CaptureFullMessages bool `yaml:"capture_full_messages,omitempty"`
CaptureFullToolOutput bool `yaml:"capture_full_tool_output,omitempty"`
CaptureChunks bool `yaml:"capture_chunks,omitempty"`
}
TraceConfig controls the context-trace event log (docs/design/context-trace.md). Enabled=false (default) means no recorder is constructed at all — the engine's tracer stays nil (zero overhead).
type TurnCanceledError ¶ added in v1.9.0
type TurnCanceledError = session.TurnCanceledError
type TurnObservation ¶ added in v1.9.0
type TurnObservation = session.TurnObservation
func ObserveOneUserTurn ¶ added in v1.9.0
func ObserveOneUserTurn(ctx context.Context, s *Session, in types.AgentInput) (*TurnObservation, bool, error)
type TurnSessionClosedError ¶ added in v1.9.0
type TurnSessionClosedError = session.TurnSessionClosedError
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package trace implements the context-trace event log: an append-only JSONL record of everything that happened during an agent session, separate from the chatstore state layer.
|
Package trace implements the context-trace event log: an append-only JSONL record of everything that happened during an agent session, separate from the chatstore state layer. |