session

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildConversation

func BuildConversation(events []Event) []llm.Message

func PruneExpired

func PruneExpired(root string, cutoff time.Time) error

Types

type AssistantTurnPayload

type AssistantTurnPayload struct {
	Transcript  []TranscriptItem `json:"transcript,omitempty"`
	Message     string           `json:"message,omitempty"`
	TurnMemory  *llm.TurnMemory  `json:"turn_memory,omitempty"`
	Interrupted bool             `json:"interrupted,omitempty"`
	Error       string           `json:"error,omitempty"`
}

type BashPayload

type BashPayload struct {
	Command    string `json:"command"`
	Summary    string `json:"summary,omitempty"`
	Output     string `json:"output,omitempty"`
	Error      string `json:"error,omitempty"`
	DurationNS int64  `json:"duration_ns,omitempty"`
}

type CompactionAppliedPayload

type CompactionAppliedPayload struct {
	Status     string           `json:"status"`
	Transcript []TranscriptItem `json:"transcript,omitempty"`
	Messages   []llm.Message    `json:"messages"`
}

type DiffPayload

type DiffPayload struct {
	Lines []tools.EditDiffLine `json:"lines"`
}

type Event

type Event struct {
	Seq  uint64    `json:"seq"`
	Kind EventKind `json:"kind"`

	SessionStarted    *SessionStartedPayload    `json:"session_started,omitempty"`
	UserMessage       *MessagePayload           `json:"user_message,omitempty"`
	AssistantTurn     *AssistantTurnPayload     `json:"assistant_turn,omitempty"`
	CompactionApplied *CompactionAppliedPayload `json:"compaction_applied,omitempty"`
}

type EventKind

type EventKind string
const (
	KindSessionStarted    EventKind = "session_started"
	KindUserMessage       EventKind = "user_message"
	KindAssistantTurn     EventKind = "assistant_turn"
	KindCompactionApplied EventKind = "compaction_applied"
)

type LoadedSession

type LoadedSession struct {
	Summary Summary
	Events  []Event
	Session *Session
}

type MessagePayload

type MessagePayload struct {
	Content string `json:"content"`
}

type Session

type Session struct {
	ID             string
	CreatedAt      time.Time
	Directory      string
	TranscriptPath string
	// contains filtered or unexported fields
}

type SessionStartedPayload

type SessionStartedPayload struct {
	SessionID string    `json:"session_id"`
	CreatedAt time.Time `json:"created_at"`
	CWD       string    `json:"cwd"`
}

type Store

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

func NewStore

func NewStore(workingDir string) (*Store, error)

func (*Store) Append

func (s *Store) Append(session *Session, event Event) error

func (*Store) AppendBatch

func (s *Store) AppendBatch(session *Session, events []Event) error

AppendBatch atomically persists events as one JSONL transcript update.

func (*Store) Create

func (s *Store) Create() (*Session, error)

func (*Store) List

func (s *Store) List() ([]Summary, error)

func (*Store) Load

func (s *Store) Load(summary Summary) (*LoadedSession, error)

type Summary

type Summary struct {
	ID              string
	CreatedAt       time.Time
	UpdatedAt       time.Time
	LastUserMessage string
	Directory       string
	TranscriptPath  string
	LastSeq         uint64
}

type ToolEndPayload

type ToolEndPayload struct {
	Name       string         `json:"name"`
	Input      map[string]any `json:"input,omitempty"`
	Output     any            `json:"output,omitempty"`
	Error      string         `json:"error,omitempty"`
	DurationNS int64          `json:"duration_ns,omitempty"`
}

type ToolStartPayload

type ToolStartPayload struct {
	Name  string         `json:"name"`
	Input map[string]any `json:"input,omitempty"`
}

type TranscriptItem

type TranscriptItem struct {
	Kind      TranscriptItemKind `json:"kind"`
	Content   string             `json:"content,omitempty"`
	ToolStart *ToolStartPayload  `json:"tool_start,omitempty"`
	ToolEnd   *ToolEndPayload    `json:"tool_end,omitempty"`
	Bash      *BashPayload       `json:"bash,omitempty"`
	Diff      *DiffPayload       `json:"diff,omitempty"`
}

type TranscriptItemKind

type TranscriptItemKind string
const (
	TranscriptItemText      TranscriptItemKind = "text"
	TranscriptItemReasoning TranscriptItemKind = "reasoning"
	TranscriptItemToolStart TranscriptItemKind = "tool_start"
	TranscriptItemToolEnd   TranscriptItemKind = "tool_end"
	TranscriptItemBash      TranscriptItemKind = "bash"
	TranscriptItemDiff      TranscriptItemKind = "diff"
)

Jump to

Keyboard shortcuts

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