Documentation
¶
Overview ¶
Package session implements append-only JSONL rollouts plus parent-pointer tree reconstruction for bee sessions.
Index ¶
- func BuildTree(msgs []types.Message) *types.MessageNode
- func FirstUserText(id string) (string, error)
- func LinearPath(root *types.MessageNode, leafID string) []*types.MessageNode
- func List() ([]types.Session, error)
- func Path(id string) (string, error)
- func Read(id string) ([]types.Message, error)
- func ReadResume(id string) ([]types.Message, error)
- func SessionsDir() (string, error)
- type Rollout
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTree ¶
func BuildTree(msgs []types.Message) *types.MessageNode
BuildTree reconstructs the parent-pointer tree from a flat message slice. Returns the root node (first message with empty ParentID, or with a parent not present in the slice). If multiple roots exist, the first-seen wins and orphan subtrees are dropped — callers should ensure input is from one session. Returns nil if msgs is empty.
func FirstUserText ¶
FirstUserText returns the first user-role text block in a session, scanning at most maxScanLines lines. Empty if the session has no user text yet.
func LinearPath ¶
func LinearPath(root *types.MessageNode, leafID string) []*types.MessageNode
LinearPath walks from leafID up to root, returning the chain in root→leaf order. Returns nil if leafID isn't reachable.
func List ¶
List enumerates known sessions by scanning the sessions dir. Each session's metadata is derived from its first message (timestamp = session created, id from filename). Provider/model/cwd aren't in Message; downstream code can enrich Session as it pleases — we fill what we can.
func ReadResume ¶
ReadResume decodes a session like Read but collapses it at the last compaction checkpoint: the checkpoint's summary stands in for everything before PreserveFrom, so a resumed session sees the same shortened history the live session had instead of the full raw log. Falls back to the raw read when no checkpoint exists or PreserveFrom can't be located.
func SessionsDir ¶
SessionsDir returns the directory holding session JSONL files. Override via BEE_SESSIONS_DIR for tests / alt installs.
Types ¶
type Rollout ¶
type Rollout struct {
// contains filtered or unexported fields
}
Rollout is an append-only JSONL writer for one session. Single open handle, sync-on-append. Not safe for cross-process use; callers are expected to own the session.
func Fork ¶
Fork creates a new session rollout containing all messages up to and including fromMsgID. If fromMsgID is empty the entire source session is copied (Clone). The new rollout is returned open; caller is responsible for Close.