Documentation
¶
Index ¶
- type CompactionResult
- type ModelFactory
- type Session
- func (s *Session) APIKey() string
- func (s *Session) Abort()
- func (s *Session) AbortSilent()
- func (s *Session) BaseURL() string
- func (s *Session) ClearConversation()
- func (s *Session) Close()
- func (s *Session) Compact() (CompactionResult, error)
- func (s *Session) ContextUsage() *agentcore.ContextUsage
- func (s *Session) CostEstimate() (inputTokens, outputTokens int, cost float64)
- func (s *Session) CurrentSessionInfo() (storage.SessionInfo, error)
- func (s *Session) IsRunning() bool
- func (s *Session) LastAssistantText() string
- func (s *Session) ListSessions() ([]storage.SessionInfo, error)
- func (s *Session) Messages() []agentcore.AgentMessage
- func (s *Session) ModelName() string
- func (s *Session) NewSession() error
- func (s *Session) Prompt(text string) error
- func (s *Session) PromptWithBlocks(blocks []agentcore.ContentBlock) error
- func (s *Session) Provider() string
- func (s *Session) Registry() *provider.ModelRegistry
- func (s *Session) Reload()
- func (s *Session) ReplaceAllTools(tools []agentcore.Tool)
- func (s *Session) ResolveAndSetModel(pattern string) (string, error)
- func (s *Session) RestoreAllTools(extra ...agentcore.Tool)
- func (s *Session) SetBeforePrompt(fn func())
- func (s *Session) SetModel(prov, model string) error
- func (s *Session) SetSystemSuffix(suffix string)
- func (s *Session) SetThinkingLevel(level agentcore.ThinkingLevel)
- func (s *Session) SetTools(tools ...agentcore.Tool)
- func (s *Session) Settings() config.Resolved
- func (s *Session) Skills() []config.Skill
- func (s *Session) Steer(text string)
- func (s *Session) Subscribe(fn func(SessionEvent)) func()
- func (s *Session) SwitchSession(id string) error
- func (s *Session) ToolsByName(names ...string) []agentcore.Tool
- func (s *Session) TotalTokens() int
- type SessionConfig
- type SessionEvent
- type SessionEventType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompactionResult ¶ added in v0.0.2
type ModelFactory ¶
ModelFactory creates a chat model instance for a provider/model tuple.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the business-logic core that wraps Agent + session persistence. It is independent of any UI framework and drives interactive, print, and RPC modes.
func NewSession ¶
func NewSession(cfg SessionConfig) *Session
NewSession creates a Session and wires auto-persist to the agent.
func (*Session) AbortSilent ¶
func (s *Session) AbortSilent()
func (*Session) ClearConversation ¶
func (s *Session) ClearConversation()
func (*Session) Compact ¶
func (s *Session) Compact() (CompactionResult, error)
func (*Session) ContextUsage ¶
func (s *Session) ContextUsage() *agentcore.ContextUsage
func (*Session) CostEstimate ¶
func (*Session) CurrentSessionInfo ¶
func (s *Session) CurrentSessionInfo() (storage.SessionInfo, error)
func (*Session) LastAssistantText ¶
func (*Session) ListSessions ¶
func (s *Session) ListSessions() ([]storage.SessionInfo, error)
func (*Session) Messages ¶ added in v0.0.2
func (s *Session) Messages() []agentcore.AgentMessage
Messages returns the current agent message history.
func (*Session) NewSession ¶
func (*Session) PromptWithBlocks ¶
func (s *Session) PromptWithBlocks(blocks []agentcore.ContentBlock) error
func (*Session) Registry ¶
func (s *Session) Registry() *provider.ModelRegistry
func (*Session) ReplaceAllTools ¶
func (*Session) ResolveAndSetModel ¶
func (*Session) RestoreAllTools ¶
func (*Session) SetBeforePrompt ¶
func (s *Session) SetBeforePrompt(fn func())
func (*Session) SetSystemSuffix ¶
func (*Session) SetThinkingLevel ¶
func (s *Session) SetThinkingLevel(level agentcore.ThinkingLevel)
func (*Session) Subscribe ¶
func (s *Session) Subscribe(fn func(SessionEvent)) func()
func (*Session) SwitchSession ¶
func (*Session) TotalTokens ¶
type SessionConfig ¶
type SessionConfig struct {
Agent *agentcore.Agent
Store *storage.Store
Manager *storage.Manager
Registry *provider.ModelRegistry
Settings config.Resolved
Cwd string
// CreateModel allows tests/integrations to override model construction.
// Defaults to provider.CreateModel when nil.
CreateModel ModelFactory
// LazyPersist buffers user messages and flushes them only when
// an assistant response arrives. Disabled by default for safety.
LazyPersist bool
// ChatModel is the active ChatModel reference, used for max_tokens adjustment
// during overflow recovery.
ChatModel agentcore.ChatModel
// HookRunner fires lifecycle hooks (notification, etc.). Nil when no hooks configured.
HookRunner *hooks.Runner
// Tools is the full set of tools registered with the agent.
// Used by ToolsByName / RestoreAllTools for plan mode filtering.
Tools []agentcore.Tool
// ContextFiles holds loaded context files for dynamic system prompt rebuilding.
// When tools change the prompt is regenerated from these inputs.
ContextFiles config.ContextFiles
// Skills holds loaded skills for system prompt injection and /skill: commands.
Skills []config.Skill
// DeferredToolsPreamble is injected as the first user message (once).
DeferredToolsPreamble string
// Reminders are <system-reminder> fragments prepended to each user message.
Reminders []string
// PreambleInjected indicates the preamble was already in conversation history (resume).
PreambleInjected bool
}
SessionConfig configures a new Session.
type SessionEvent ¶
type SessionEvent struct {
Type SessionEventType
AgentEvent *agentcore.Event
// Session-level fields (populated based on Type)
ModelName string
Provider string
Level agentcore.ThinkingLevel
SessionID string
Error error
// Retry fields (populated for SEAutoRetryStart / SEAutoRetryEnd)
RetryAttempt int
RetryMax int
RetryDelay time.Duration
RetrySuccess bool
// Compaction reason: "overflow" or "threshold"
CompactionReason string
CompactionChanged bool
TokensBefore int
TokensAfter int
}
SessionEvent extends agent events with session-level metadata. When Type == SEAgentEvent, AgentEvent is non-nil.
type SessionEventType ¶
type SessionEventType string
SessionEventType identifies a session-level event.
const ( // SEAgentEvent wraps an agentcore.Event transparently. SEAgentEvent SessionEventType = "agent_event" // Session lifecycle events SEAutoCompactionStart SessionEventType = "auto_compaction_start" SEAutoCompactionEnd SessionEventType = "auto_compaction_end" SEAutoRetryStart SessionEventType = "auto_retry_start" SEAutoRetryEnd SessionEventType = "auto_retry_end" SEModelChanged SessionEventType = "model_changed" SEThinkingChanged SessionEventType = "thinking_changed" SESessionSwitched SessionEventType = "session_switched" SEError SessionEventType = "session_error" )
Click to show internal directories.
Click to hide internal directories.