Documentation
¶
Overview ¶
Package session manages ACP session lifecycle, wrapping kodelet threads with ACP session semantics.
Index ¶
- type Manager
- func (m *Manager) Cancel(id acptypes.SessionID) error
- func (m *Manager) Close(ctx context.Context) error
- func (m *Manager) GetSession(id acptypes.SessionID) (*Session, error)
- func (m *Manager) LoadSession(ctx context.Context, req acptypes.LoadSessionRequest) (*Session, error)
- func (m *Manager) NewSession(ctx context.Context, req acptypes.NewSessionRequest) (*Session, error)
- type ManagerConfig
- type Session
- type SessionStorage
- type Storage
- func (s *Storage) AppendUpdate(sessionID acptypes.SessionID, update any) error
- func (s *Storage) Close() error
- func (s *Storage) CloseSession(sessionID acptypes.SessionID) error
- func (s *Storage) Delete(sessionID acptypes.SessionID) error
- func (s *Storage) Exists(sessionID acptypes.SessionID) bool
- func (s *Storage) Flush(sessionID acptypes.SessionID) error
- func (s *Storage) ReadUpdates(sessionID acptypes.SessionID) ([]StoredUpdate, error)
- type StorageOption
- type StoredUpdate
- type UpdateSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages ACP sessions
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new session manager
func (*Manager) GetSession ¶
GetSession returns a session by ID
func (*Manager) LoadSession ¶
func (m *Manager) LoadSession(ctx context.Context, req acptypes.LoadSessionRequest) (*Session, error)
LoadSession loads an existing session
func (*Manager) NewSession ¶
NewSession creates a new session
type ManagerConfig ¶
type ManagerConfig struct {
Provider string
Model string
MaxTokens int
NoSkills bool
NoExtensions bool
EnableFSSearchTools bool
MaxTurns int
CompactRatio float64
}
ManagerConfig holds configuration for the session Manager.
type Session ¶
type Session struct {
ID acptypes.SessionID
Thread llmtypes.Thread
State *tools.BasicState
Extensions *extensions.Runtime
CWD string
// contains filtered or unexported fields
}
Session represents an ACP session wrapping a kodelet thread
func (*Session) HandlePrompt ¶
func (s *Session) HandlePrompt(ctx context.Context, prompt []acptypes.ContentBlock, sender UpdateSender) (acptypes.StopReason, error)
HandlePrompt processes a prompt and returns the stop reason
func (*Session) IsCancelled ¶
IsCancelled returns whether the session has been cancelled
type SessionStorage ¶
type SessionStorage interface {
AppendUpdate(sessionID acptypes.SessionID, update any) error
ReadUpdates(sessionID acptypes.SessionID) ([]StoredUpdate, error)
Flush(sessionID acptypes.SessionID) error
Delete(sessionID acptypes.SessionID) error
CloseSession(sessionID acptypes.SessionID) error
Exists(sessionID acptypes.SessionID) bool
Close() error
}
SessionStorage defines the interface for ACP session update storage.
func GetDefaultStorage ¶
func GetDefaultStorage(ctx context.Context) (SessionStorage, error)
GetDefaultStorage returns the default storage implementation (SQLite).
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage handles persistence of ACP session updates using SQLite.
func NewStorage ¶
func NewStorage(ctx context.Context, opts ...StorageOption) (*Storage, error)
NewStorage creates a new SQLite-based session storage. Note: Migrations should be run via db.RunMigrations() at CLI startup before calling this.
func (*Storage) AppendUpdate ¶
AppendUpdate appends a session update, merging consecutive text chunks.
func (*Storage) CloseSession ¶
CloseSession flushes pending updates and removes the session from memory.
func (*Storage) ReadUpdates ¶
func (s *Storage) ReadUpdates(sessionID acptypes.SessionID) ([]StoredUpdate, error)
ReadUpdates reads all updates for a session for replay.
type StorageOption ¶
type StorageOption func(*Storage)
StorageOption configures a Storage instance.
func WithDBPath ¶
func WithDBPath(path string) StorageOption
WithDBPath sets a custom database path for session storage.
type StoredUpdate ¶
type StoredUpdate struct {
SessionID acptypes.SessionID `json:"sessionId"`
Update json.RawMessage `json:"update"`
}
StoredUpdate represents a stored session update for replay