Documentation
¶
Index ¶
- type ContextBlock
- type ContextBlockType
- type Hook
- type HookType
- type PreCompactOptions
- type PreCompactResult
- type Session
- type SessionListOptions
- type SessionListResult
- type SessionManager
- func (sm *SessionManager) AddContextBlock(blockType ContextBlockType, content string, tokens int) error
- func (sm *SessionManager) CleanupExpired() error
- func (sm *SessionManager) Close() error
- func (sm *SessionManager) CreateSession(agent, projectPath string) (*Session, error)
- func (sm *SessionManager) CreateSnapshot(sessionID string) (*SessionSnapshot, error)
- func (sm *SessionManager) GetActiveSession() *Session
- func (sm *SessionManager) GetSession(id string) (*Session, error)
- func (sm *SessionManager) PreCompact(ctx context.Context, maxTokens int) (string, error)
- func (sm *SessionManager) RegisterHook(hookType HookType, hook Hook)
- func (sm *SessionManager) RestoreSnapshot(snapshotID int64) (*Session, error)
- func (sm *SessionManager) SetActiveSession(id string) error
- type SessionMetadata
- type SessionSnapshot
- type SessionState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextBlock ¶
type ContextBlock struct {
Type ContextBlockType `json:"type"`
Content string `json:"content"`
Timestamp time.Time `json:"timestamp"`
Tokens int `json:"tokens"`
}
ContextBlock represents a piece of context in a session
type ContextBlockType ¶
type ContextBlockType string
ContextBlockType represents the type of context block
const ( BlockTypeUserQuery ContextBlockType = "user_query" BlockTypeToolResult ContextBlockType = "tool_result" BlockTypeSummary ContextBlockType = "summary" BlockTypeSystem ContextBlockType = "system" BlockTypeError ContextBlockType = "error" )
type PreCompactOptions ¶
type PreCompactOptions struct {
MaxTokens int
PreserveRecent int // Number of recent turns to preserve
IncludeState bool
IncludeMetadata bool
}
PreCompactOptions contains options for PreCompact operation
type PreCompactResult ¶
type PreCompactResult struct {
Summary string `json:"summary"`
TokensUsed int `json:"tokens_used"`
BlocksKept int `json:"blocks_kept"`
BlocksTotal int `json:"blocks_total"`
}
PreCompactResult contains the result of PreCompact operation
type Session ¶
type Session struct {
ID string `json:"id"`
Agent string `json:"agent"`
ProjectPath string `json:"project_path"`
StartedAt time.Time `json:"started_at"`
LastActivity time.Time `json:"last_activity"`
ContextBlocks []ContextBlock `json:"context_blocks"`
State SessionState `json:"state"`
Metadata SessionMetadata `json:"metadata"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
IsActive bool `json:"is_active"`
}
Session represents an active interaction session
type SessionListOptions ¶
type SessionListOptions struct {
Agent string
ProjectPath string
ActiveOnly bool
Limit int
Offset int
}
SessionListOptions provides filtering for listing sessions
type SessionListResult ¶
type SessionListResult struct {
Sessions []Session `json:"sessions"`
Total int64 `json:"total"`
HasMore bool `json:"has_more"`
}
SessionListResult contains the result of a list operation
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages sessions and their state
func NewSessionManager ¶
func NewSessionManager() (*SessionManager, error)
NewSessionManager creates a new session manager
func (*SessionManager) AddContextBlock ¶
func (sm *SessionManager) AddContextBlock(blockType ContextBlockType, content string, tokens int) error
AddContextBlock adds a context block to the active session
func (*SessionManager) CleanupExpired ¶
func (sm *SessionManager) CleanupExpired() error
CleanupExpired removes expired sessions
func (*SessionManager) Close ¶
func (sm *SessionManager) Close() error
Close closes the session manager
func (*SessionManager) CreateSession ¶
func (sm *SessionManager) CreateSession(agent, projectPath string) (*Session, error)
CreateSession creates a new session
func (*SessionManager) CreateSnapshot ¶
func (sm *SessionManager) CreateSnapshot(sessionID string) (*SessionSnapshot, error)
CreateSnapshot creates a snapshot of the current session
func (*SessionManager) GetActiveSession ¶
func (sm *SessionManager) GetActiveSession() *Session
GetActiveSession returns the currently active session
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(id string) (*Session, error)
GetSession retrieves a session by ID
func (*SessionManager) PreCompact ¶
PreCompact executes PreCompact hooks and returns optimized context
func (*SessionManager) RegisterHook ¶
func (sm *SessionManager) RegisterHook(hookType HookType, hook Hook)
RegisterHook registers a hook for a specific event
func (*SessionManager) RestoreSnapshot ¶
func (sm *SessionManager) RestoreSnapshot(snapshotID int64) (*Session, error)
RestoreSnapshot restores a session from a snapshot
func (*SessionManager) SetActiveSession ¶
func (sm *SessionManager) SetActiveSession(id string) error
SetActiveSession sets the active session
type SessionMetadata ¶
type SessionMetadata struct {
TotalTurns int `json:"total_turns"`
TotalTokens int `json:"total_tokens"`
CompressionRatio float64 `json:"compression_ratio"`
}
SessionMetadata contains session statistics
type SessionSnapshot ¶
type SessionSnapshot struct {
ID int64 `json:"id"`
SessionID string `json:"session_id"`
CreatedAt time.Time `json:"created_at"`
Content string `json:"content"`
TokenCount int `json:"token_count"`
}
SessionSnapshot represents a saved session state
type SessionState ¶
type SessionState struct {
Variables map[string]interface{} `json:"variables"`
Focus string `json:"focus,omitempty"`
NextAction string `json:"next_action,omitempty"`
}
SessionState represents the current state of a session