Documentation
¶
Index ¶
- Constants
- func AppendMessage(path string, msg Message) error
- func ArchiveSummary(st SessionTasks) string
- func BuildCompactionSummary(messages []Message) string
- func BuildCompactionSummaryWithOptions(messages []Message, opts CompactionSummaryOptions) string
- func EstimateTokens(messages []Message) int
- func FormatTasksForInjection(st SessionTasks) string
- func NextTaskID(tasks []Task) string
- func NowRFC3339() string
- func RewriteMessages(path string, messages []Message) error
- func TaskSummary(tasks []Task) map[string]int
- func ValidTaskStatus(status string) bool
- type CompactOptions
- type CompactResult
- type CompactionSummaryOptions
- type HistorySnapshot
- type Message
- type Plan
- type Session
- type SessionTasks
- type SessionToolConfig
- type Store
- func (s *Store) Create(title string) (Session, error)
- func (s *Store) CreateWithOptions(title string, kind string, hidden bool) (Session, error)
- func (s *Store) Delete(id string) error
- func (s *Store) EnsureMain() (Session, error)
- func (s *Store) EnsureWorker(projectID string) (Session, error)
- func (s *Store) Get(id string) (Session, error)
- func (s *Store) GetTasks(sessionID string) (SessionTasks, error)
- func (s *Store) Latest() (Session, error)
- func (s *Store) LatestAll() (Session, error)
- func (s *Store) List() ([]Session, error)
- func (s *Store) ListAll() ([]Session, error)
- func (s *Store) SaveTasks(sessionID string, tasks SessionTasks) error
- func (s *Store) SetCurrentDir(id string, dir string) error
- func (s *Store) SetLastCompactionMode(id string, mode string) error
- func (s *Store) SetPromptOverride(id string, override string) error
- func (s *Store) SetTitle(id string, title string) error
- func (s *Store) SetToolConfig(id string, config *SessionToolConfig) error
- func (s *Store) SetWorkDirs(id string, dirs []string, currentDir string) error
- func (s *Store) Touch(id string, updatedAt time.Time) error
- func (s *Store) TranscriptPath(id string) string
- func (s *Store) WorkspaceDir() string
- type Task
Constants ¶
const ( DefaultKeepRecentMessages = 20 MinKeepRecentMessages = 5 MaxKeepRecentMessages = 200 DefaultKeepRecentTokens = 12000 MinKeepRecentTokens = 1 MaxKeepRecentTokens = 64000 DefaultKeepRecentFraction = 0.30 MinKeepRecentFraction = 0.05 MaxKeepRecentFraction = 0.90 )
Variables ¶
This section is empty.
Functions ¶
func AppendMessage ¶
AppendMessage appends a single message as one JSON line to the JSONL file at path.
func ArchiveSummary ¶ added in v0.20.0
func ArchiveSummary(st SessionTasks) string
ArchiveSummary returns a human-readable summary of the plan and tasks for memory archival.
func BuildCompactionSummary ¶
func BuildCompactionSummaryWithOptions ¶ added in v0.10.2
func BuildCompactionSummaryWithOptions(messages []Message, opts CompactionSummaryOptions) string
func EstimateTokens ¶
func FormatTasksForInjection ¶ added in v0.20.0
func FormatTasksForInjection(st SessionTasks) string
FormatTasksForInjection renders active tasks for system prompt injection after context compression. Only includes pending and in_progress tasks.
func NextTaskID ¶ added in v0.20.0
NextTaskID returns the next sequential task ID based on existing tasks.
func NowRFC3339 ¶ added in v0.20.0
func NowRFC3339() string
NowRFC3339 returns current time in RFC3339 format.
func RewriteMessages ¶
RewriteMessages replaces the transcript contents with the provided messages.
func TaskSummary ¶ added in v0.20.0
TaskSummary returns a compact summary of task statuses.
func ValidTaskStatus ¶ added in v0.20.0
ValidTaskStatus checks if a status string is valid.
Types ¶
type CompactOptions ¶
type CompactResult ¶
type CompactResult struct {
Compacted bool
OriginalCount int
FinalCount int
CompactedCount int
Summary string
}
func CompactTranscript ¶
func CompactTranscriptWithOptions ¶
func CompactTranscriptWithOptions(path string, keepRecent int, now time.Time, opts CompactOptions) (CompactResult, error)
type CompactionSummaryOptions ¶ added in v0.10.2
type CompactionSummaryOptions struct {
FocusInstructions string
}
type HistorySnapshot ¶
HistorySnapshot captures the portion of transcript loaded into model context.
func LoadHistorySnapshot ¶
func LoadHistorySnapshot(path string, maxTokens int) (HistorySnapshot, error)
LoadHistorySnapshot reads transcript history and returns the loaded messages together with token and compaction-boundary metadata.
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Timestamp time.Time `json:"timestamp"`
ToolName string `json:"tool_name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolArgs string `json:"tool_args,omitempty"`
}
Message represents a single chat message in a session transcript. Tool fields are optional (omitempty) for backward compatibility with existing transcripts.
func LoadHistory ¶
LoadHistory reads messages from a JSONL file, returning only the most recent messages that fit within the given token budget. Tokens are estimated as len(content)/4. Messages are returned in chronological order (oldest first). Returns an empty slice if the file does not exist.
func ReadMessages ¶
ReadMessages reads all messages from a JSONL file. Returns an empty slice if the file does not exist or is empty.
type Plan ¶ added in v0.20.0
type Plan struct {
Goal string `json:"goal"`
Constraints string `json:"constraints,omitempty"`
CreatedAt string `json:"created_at"`
}
Plan represents a high-level goal for the current session. At most one plan is active per session; setting a new plan archives the previous one.
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
Kind string `json:"kind,omitempty"`
Hidden bool `json:"hidden,omitempty"`
ToolConfig *SessionToolConfig `json:"tool_config,omitempty"`
LastCompactionMode string `json:"last_compaction_mode,omitempty"`
PromptOverride string `json:"prompt_override,omitempty"`
WorkDirs []string `json:"work_dirs,omitempty"`
CurrentDir string `json:"current_dir,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SessionTasks ¶ added in v0.20.0
SessionTasks holds the current plan and its associated tasks for a session.
func (SessionTasks) MarshalJSON ¶ added in v0.23.0
func (st SessionTasks) MarshalJSON() ([]byte, error)
MarshalJSON keeps the API contract stable by always emitting tasks as an array.
type SessionToolConfig ¶ added in v0.16.0
type SessionToolConfig struct {
ToolsEnabled []string `json:"tools_enabled,omitempty"`
ToolsCustom bool `json:"tools_custom,omitempty"`
ToolsDisabled []string `json:"tools_disabled,omitempty"`
ToolsAllowGroups []string `json:"tools_allow_groups,omitempty"`
ToolsDenyGroups []string `json:"tools_deny_groups,omitempty"`
SkillsEnabled []string `json:"skills_enabled,omitempty"`
SkillsCustom bool `json:"skills_custom,omitempty"`
MCPEnabled []string `json:"mcp_enabled,omitempty"`
}
SessionToolConfig holds per-session tool/skill/MCP configuration. nil slices mean "inherit all from system defaults".
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) CreateWithOptions ¶
func (*Store) EnsureMain ¶
func (*Store) GetTasks ¶ added in v0.20.0
func (s *Store) GetTasks(sessionID string) (SessionTasks, error)
GetTasks reads the tasks file for a session. Returns empty SessionTasks if not found.
func (*Store) SaveTasks ¶ added in v0.20.0
func (s *Store) SaveTasks(sessionID string, tasks SessionTasks) error
SaveTasks writes the tasks file for a session.
func (*Store) SetCurrentDir ¶ added in v0.22.0
SetCurrentDir updates only the current working directory for a session.
func (*Store) SetLastCompactionMode ¶ added in v0.25.0
func (*Store) SetPromptOverride ¶ added in v0.16.0
SetPromptOverride updates the per-session prompt override.
func (*Store) SetToolConfig ¶ added in v0.16.0
func (s *Store) SetToolConfig(id string, config *SessionToolConfig) error
SetToolConfig updates the per-session tool configuration.
func (*Store) SetWorkDirs ¶ added in v0.22.0
SetWorkDirs updates the per-session working directories and current directory.