sessstore

package
v0.3.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const TenantToolWorkDir = "work"

TenantToolWorkDir is the L0 default work subtree name; runtime code should use workspace.Layout.

Variables

This section is empty.

Functions

func NewCommands

NewCommands registers session/commands: Session lifecycle slash commands backed by SessionStore.

func NewJSONL

func NewJSONL(cfg JSONLConfig) (agentkit.Session, error)

NewJSONL registers session/jsonl: Append-only JSONL event log for one session.

Best practices:

  • Reopening a file resumes event sequence numbering, so seq stays unique across restarts.

func NewMemory

func NewMemory(cfg MemoryConfig) (agentkit.Session, error)

NewMemory registers session/memory: Ephemeral in-memory session. Nothing survives the process.

func NewStatic

func NewStatic(_ StaticConfig, deps StaticDeps) (agentkit.SessionStore, error)

NewStatic registers session/static: Wrap one pre-built Session as a store that returns it for every id.

Best practices:

  • For tests and single-session hosts; every session id maps to the same log.

func NewStore

func NewStore(cfg StoreConfig, deps StoreDeps) (agentkit.SessionStore, error)

NewStore registers session/store: Resolve durable JSONL sessions by id.

func ScanSessionFile

func ScanSessionFile(path string, maxLoadedEvents int) ([]agentkit.SessionEvent, agentkit.EventSeq, bool, error)

ScanSessionFile loads one session JSONL file, folding compacted history the same way the store does. maxLoadedEvents <= 0 loads every retained event. Exported for the session index, which reads the same on-disk format.

func TrimCompacted

func TrimCompacted(s agentkit.Session, agentID agentkit.AgentID, beforeSeq agentkit.EventSeq)

TrimCompacted drops model-visible history superseded by a compaction marker.

func WorkDir

func WorkDir(storeDir string, id agentkit.SessionID) (string, error)

WorkDir returns the per-session directory under storeDir (runtime.json, current.json, etc.).

Types

type ActiveSessionData

type ActiveSessionData struct {
	SessionID agentkit.SessionID `json:"sessionId"`
}

type Commands

type Commands struct {
	// contains filtered or unexported fields
}

Commands contributes session lifecycle slash commands (/new, /session).

func (*Commands) Commands

func (c *Commands) Commands() []agentkit.Command

type CommandsConfig

type CommandsConfig struct{}

type CommandsDeps

type CommandsDeps struct {
	SessionStore agentkit.SessionStore `json:"sessionStore"`
}

type FileBacked

type FileBacked interface {
	FilePath() string
}

FileBacked is implemented by sessions that persist to a file path.

type JSONL

type JSONL struct {
	// contains filtered or unexported fields
}

JSONL persists session events as append-only JSON lines.

func (*JSONL) Append

func (s *JSONL) Append(ctx context.Context, event agentkit.SessionEvent) (agentkit.EventSeq, error)

func (*JSONL) DeriveMessages

func (s *JSONL) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)

func (*JSONL) FilePath

func (s *JSONL) FilePath() string

func (*JSONL) ID

func (s *JSONL) ID() agentkit.SessionID

func (*JSONL) LatestSeq

func (s *JSONL) LatestSeq() agentkit.EventSeq

LatestSeq returns the highest event sequence in the durable log.

func (*JSONL) Read

func (s *JSONL) Read(ctx context.Context, from agentkit.EventSeq) ([]agentkit.SessionEvent, error)

type JSONLConfig

type JSONLConfig struct {
	// Path is the log file itself, not a directory.
	Path string `json:"path"`
	// ID is fixed session id.
	ID agentkit.SessionID `json:"id"`
	// MaxLoadedEvents limits non-compaction events kept in memory on load. Zero loads the full file.
	MaxLoadedEvents int `json:"maxLoadedEvents"`
}

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

Memory is an in-memory session backend for tests and ephemeral runs.

func (*Memory) Append

func (*Memory) DeriveMessages

func (s *Memory) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)

func (*Memory) ID

func (s *Memory) ID() agentkit.SessionID

func (*Memory) LatestSeq

func (s *Memory) LatestSeq() agentkit.EventSeq

LatestSeq returns the highest event sequence issued by this session.

func (*Memory) Read

type MemoryConfig

type MemoryConfig struct {
	// ID is fixed session id.
	ID agentkit.SessionID `json:"id"`
	// MaxToolResultBytes caps tool result text in DeriveMessages (PruneToolResults).
	MaxToolResultBytes int `json:"maxToolResultBytes"`
}

type SessionRuntimeData

type SessionRuntimeData struct {
	AgentID agentkit.AgentID `json:"agentId,omitempty"`
	Model   string           `json:"model,omitempty"`
}

SessionRuntimeData holds per-session dynamic overrides (agent route, LLM model).

type StaticConfig

type StaticConfig struct{}

type StaticDeps

type StaticDeps struct {
	Session agentkit.Session `json:"session"`
}

type StaticStore

type StaticStore struct {
	// contains filtered or unexported fields
}

StaticStore returns one Session for matching IDs. Useful for CLI presets and tests where a single session instance is wired through pluginkit.

func NewStaticStore

func NewStaticStore(sess agentkit.Session) *StaticStore

func (*StaticStore) ActiveSession

func (s *StaticStore) ActiveSession(ctx context.Context, id agentkit.SessionID) (agentkit.SessionID, error)

func (*StaticStore) AgentBind

func (*StaticStore) Get

func (*StaticStore) ModelBind

func (s *StaticStore) ModelBind(ctx context.Context, id agentkit.SessionID) (string, error)

func (*StaticStore) SetActiveSession

func (s *StaticStore) SetActiveSession(ctx context.Context, id, active agentkit.SessionID) error

func (*StaticStore) SetAgentBind

func (s *StaticStore) SetAgentBind(ctx context.Context, id agentkit.SessionID, agent agentkit.AgentID) error

func (*StaticStore) SetModelBind

func (s *StaticStore) SetModelBind(ctx context.Context, id agentkit.SessionID, model string) error

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store opens one JSONL session file per SessionID under Dir. Suitable for IM platforms where each channel/thread maps to a distinct session.

func (*Store) ActiveSession

func (s *Store) ActiveSession(ctx context.Context, id agentkit.SessionID) (agentkit.SessionID, error)

func (*Store) AgentBind

func (s *Store) AgentBind(ctx context.Context, id agentkit.SessionID) (agentkit.AgentID, error)

func (*Store) Get

func (*Store) ModelBind

func (s *Store) ModelBind(ctx context.Context, id agentkit.SessionID) (string, error)

func (*Store) SetActiveSession

func (s *Store) SetActiveSession(ctx context.Context, id, active agentkit.SessionID) error

func (*Store) SetAgentBind

func (s *Store) SetAgentBind(ctx context.Context, id agentkit.SessionID, agent agentkit.AgentID) error

func (*Store) SetModelBind

func (s *Store) SetModelBind(ctx context.Context, id agentkit.SessionID, model string) error

type StoreConfig

type StoreConfig struct {
	// Dir is root directory holding one file per session, resolved through the workspace.
	Dir string `json:"dir"`
	// MaxCachedSessions limits in-memory hot sessions (LRU). Zero keeps every opened session cached.
	MaxCachedSessions int `json:"maxCachedSessions"`
	// CacheIdleTTL evicts sessions unused for this duration (for example "30m"). Empty disables idle eviction.
	CacheIdleTTL string `json:"cacheIdleTTL"`
	// MaxLoadedEvents limits non-compaction events kept in memory per session on load. Zero loads the full file.
	MaxLoadedEvents int `json:"maxLoadedEvents"`
}

type StoreDeps

type StoreDeps struct {
	Workspace workspace.Service `json:"workspace"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL