Documentation
¶
Overview ¶
internal/session/browse.go
internal/session/compact.go
Index ¶
- type Node
- type Session
- func (s *Session) Append(msg ai.Message) *Node
- func (s *Session) AppendWithUsage(msg ai.Message, usage ai.Usage, durationMs int) *Node
- func (s *Session) Clone() *Session
- func (s *Session) Compact(ctx context.Context, instructions string, summarize Summarizer) error
- func (s *Session) Fork(target *Node)
- func (s *Session) Path() string
- func (s *Session) PathToActive() []ai.Message
- func (s *Session) PathToActiveNodes() []*Node
- func (s *Session) RecordFileRead(path string)
- func (s *Session) Save() error
- func (s *Session) SetEffort(effort string)
- func (s *Session) SetPath(p string)
- func (s *Session) SetSubagents(tasks []SubagentTask)
- func (s *Session) SubagentTasks() []SubagentTask
- func (s *Session) UsageStats() UsageStats
- type SubagentTask
- type Summarizer
- type Summary
- type UsageStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
ID string
Parent *Node `json:"-"`
Children []*Node
Message ai.Message
Usage ai.Usage
Created time.Time
// DurationMs is the wall-clock time of the turn that produced this node
// (request start to stream end), in milliseconds. 0 for non-assistant nodes.
DurationMs int
// CompactedCount > 0 marks this node as a compaction summary that
// replaced N prior messages along its branch.
CompactedCount int
}
type Session ¶
type Session struct {
ID string
Name string
Created time.Time
Updated time.Time
Provider string
Model string
Effort string
Cwd string
Root *Node
Active *Node
Subagents []SubagentTask
FilesRead []string
// contains filtered or unexported fields
}
func (*Session) AppendWithUsage ¶ added in v0.7.1
AppendWithUsage appends msg and records its token usage and turn duration in the same lock acquisition. Callers must not set Usage on the returned node themselves: once Append returns, the node is reachable by concurrent tree walkers (e.g. Save), so any later unlocked write races with them.
func (*Session) Compact ¶
Compact replaces the active path's prefix up to (but not including) the most recent user message with a single synthetic assistant summary message.
func (*Session) PathToActive ¶
PathToActive returns the messages from the first child of root down to Active (excluding root).
func (*Session) PathToActiveNodes ¶
PathToActiveNodes returns the nodes from the first child of root down to Active (excluding root). Use when callers need per-node metadata (e.g. CompactedCount) that PathToActive's []ai.Message strips away.
func (*Session) RecordFileRead ¶ added in v0.2.0
RecordFileRead prepends path to FilesRead, deduping and capping at 50. Called by tools/read.go on every successful read.
func (*Session) SetEffort ¶ added in v0.8.0
SetEffort records the reasoning-effort level used for the most recent turn.
func (*Session) SetPath ¶
SetPath assigns the file path used by Save. Callers in cmd/rune use this to place sessions under ~/.rune/sessions; tests use it to point at a temp dir.
func (*Session) SetSubagents ¶
func (s *Session) SetSubagents(tasks []SubagentTask)
SetSubagents replaces the persisted subagent task metadata for this session.
func (*Session) SubagentTasks ¶
func (s *Session) SubagentTasks() []SubagentTask
SubagentTasks returns a copy of the persisted subagent task metadata.
func (*Session) UsageStats ¶ added in v0.8.0
func (s *Session) UsageStats() UsageStats
UsageStats computes per-session usage metadata over the active branch.
type SubagentTask ¶
type SubagentTask struct {
ID string `json:"task_id"`
Name string `json:"name"`
FamiliarName string `json:"familiar_name,omitempty"`
AgentType string `json:"agent_type"`
Status string `json:"status"`
Dependencies []string `json:"dependencies,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
InputTokens int `json:"input_tokens,omitempty"`
OutputTokens int `json:"output_tokens,omitempty"`
Summary string `json:"summary,omitempty"`
Error string `json:"error,omitempty"`
}
SubagentTask is the durable, session-owned metadata for a subagent task. It intentionally omits full prompts/transcripts; those may contain large or sensitive context and can be added later as artifact references.
type Summarizer ¶
type Summary ¶
type Summary struct {
ID string
Name string
Preview string
Created time.Time
Updated time.Time
Path string
MessageCount int
Model string
Cwd string
}
func ListSessions ¶
func ListSessionsForCWD ¶ added in v0.1.16
type UsageStats ¶ added in v0.8.0
type UsageStats struct {
Provider string
Model string
Effort string
Created time.Time
Updated time.Time
Turns int
Input int
Output int
CacheRead int
DurationMs int
SubagentCount int
SubagentInput int
SubagentOutput int
}
UsageStats aggregates token, latency, and turn metadata across the active branch (root → Active), plus subagent token totals for the whole session.