session

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package session exposes TARS' file-backed chat session and transcript persistence for external agent applications. It is a thin alias layer over internal/session; the on-disk format (sessions/sessions.json index plus one sessions/{id}.jsonl transcript per session) is unchanged. Construct a Store with NewStore(dir); obtain a session's transcript path via (*Store).TranscriptPath(id); then append/read/load messages with the transcript helpers.

Index

Constants

This section is empty.

Variables

View Source
var ErrCwdNotEligible = internal.ErrCwdNotEligible

ErrCwdNotEligible is returned by SetCurrentDir when the supplied directory is not under a configured work_dirs entry.

View Source
var ErrSessionKindUnsupported = internal.ErrSessionKindUnsupported

ErrSessionKindUnsupported is returned by goal mutations when the session kind does not support goals.

View Source
var ErrSessionNotFound = internal.ErrSessionNotFound

ErrSessionNotFound is returned when a session ID does not resolve to an existing session.

Functions

func AppendMessage

func AppendMessage(path string, msg Message) error

AppendMessage appends one message as a JSON line to the transcript at path.

func EstimateMessageTokenCost

func EstimateMessageTokenCost(msg Message) int

EstimateMessageTokenCost returns the token estimate used for history budgeting.

func RewriteMessages

func RewriteMessages(path string, msgs []Message) error

RewriteMessages replaces the transcript contents with msgs.

Types

type HistorySnapshot

type HistorySnapshot = internal.HistorySnapshot

func LoadHistorySnapshot

func LoadHistorySnapshot(path string, maxTokens int) (HistorySnapshot, error)

LoadHistorySnapshot is LoadHistory plus token/compaction metadata.

type Message

type Message = internal.Message

func LoadHistory

func LoadHistory(path string, maxTokens int) ([]Message, error)

LoadHistory returns the most recent messages fitting within maxTokens, oldest-first.

func ReadMessages

func ReadMessages(path string) ([]Message, error)

ReadMessages reads all messages from the transcript at path (empty if absent).

type Session

type Session = internal.Session

type Store

type Store = internal.Store

func NewStore

func NewStore(dir string) *Store

NewStore returns a Store rooted at dir (transcripts live under dir/sessions).

Jump to

Keyboard shortcuts

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