Documentation
¶
Index ¶
- Constants
- func ApplyCompaction(sess *Session, body string, at time.Time)
- func ApplyCompactionWithPendingMessages(sess *Session, body string, at time.Time, pending []Message)
- func ApplyTurnUsageDisplayToLastAssistant(s *Session, ctxTok, usrTok int64, ctxEst bool, ...) int
- func ApplyTurnUsageDisplayToLastSubAssistant(s *SubSession, ctxTok, usrTok int64, ctxEst bool, ...)
- func ArchiveUncompactedState(sess *Session, at time.Time)
- func AssistantDisplayParts(m Message) (reasoning string, visibleContent string)
- func BackfillAssistantUsageFromTextIfEmpty(m *Message, prior []Message)
- func BackfillSessionAssistantUsage(msgs []Message)
- func CacheTokenCount(value int64, reported bool) int64
- func ChatIDHex(title string, ts time.Time) string
- func ChatsDir(projectHex string) (string, error)
- func ConversationSummaryText(body string) string
- func DeleteResearchJob(projectHex, slug string) error
- func EnsureResearchDir(projectHex string) (string, error)
- func EstimatePromptContext(messages []Message) int64
- func FinishSessionLoad(s *Session) (repaired bool)
- func IsCapabilityTool(name string) bool
- func IsCompactionSummary(message Message) bool
- func IsPlaceholderChatID(id string) bool
- func ListResearchJobFiles(projectHex string) ([]string, error)
- func MessageCheckpointTagVisible(m Message) bool
- func MessageWireWeight(m Message, includeReasoning bool, model string) int64
- func MigrateImagePathsAfterChatRename(projectHex string, s *Session, oldChatID, newChatID string) error
- func MigrateLegacyCheckpointsToBase0(s *Session)
- func ModelToolContent(content string) string
- func NeutralizeLiteralImgPlaceholders(content string) string
- func NewPlaceholderChatID(t time.Time) string
- func NormalizeSummaryWhitespace(content string) string
- func PlansDir(projectHex string) (string, error)
- func ProjectWelcomeStats(projectHex string) (chatCount int, userSum, reasonSum, respSum int64, err error)
- func PruneUnreferencedSessionImages(s *Session)
- func ReadResearchJobFile(projectHex, slug string, dest any) error
- func ReconcileCheckpointLast(s *Session)
- func RememberTerminalChat(id, project, chat string) error
- func RemoveBrokenSessionImageFiles(s *Session) int
- func RemoveSessionPath(projectHex, chatID string) error
- func RenameSessionFile(projectHex, oldID, newID string) (err error)
- func RepairInterruptedToolCalls(s *Session) int
- func RepairSessionMalformedImages(s *Session) (brokenDropped int, userMsgsAdjusted int, emptyRewrites int, imgNeutralized int)
- func ResearchDir(projectHex string) (string, error)
- func ResearchHTMLPath(projectHex, slug string) (string, error)
- func ResearchJobPath(projectHex, slug string) (string, error)
- func RewriteEmptyUserMsgsAfterImageRepair(s *Session) int
- func RunChatMigration(ctx context.Context)
- func ScrubCompactSummaryContent(content string) string
- func ScrubLiteralImgPlaceholdersForAPI(content string) string
- func ScrubSummaryImgWorkflowLines(content string) string
- func SessionActivityTime(s *Session) time.Time
- func SessionImgFragmentCount(s *Session) int
- func SessionLockPath(projectHex, chatID string) (string, error)
- func SessionPath(projectHex, chatIDHex string) (string, error)
- func SessionRepairChanged(brokenDropped, userMsgsAdjusted, emptyRewrites, imgNeutralized int) bool
- func SessionValidImageTokenCount(s *Session) int
- func StoredUsageLineForTurnRange(msgs []Message, start, end int) (...)
- func StripAllImgPlaceholderLiterals(content string) string
- func StripFalseImgPlaceholdersFromNonUserSession(s *Session) int
- func StripStaleUserImgPlaceholdersFromSession(s *Session) int
- func StripUnresolvedImgPlaceholders(content string, imageFiles map[int]string) string
- func SubSessionPath(projectHex, origin, id string) (string, error)
- func SubSessionRunning(status string) bool
- func SubchatID(parentChatID string, tc ToolCall, spawn time.Time) string
- func SubchatPath(projectHex, idHex string) (string, error)
- func SubchatsDir(projectHex string) (string, error)
- func SumCacheTokens(a, b int64) int64
- func TempDir(projectHex string) (string, error)
- func ValidTerminalID(id string) bool
- func WriteActiveSubagents(f *ActiveSubagentsFile) (err error)
- func WriteMainMessageChange(project string, session *Session, previousLength, first int) error
- func WriteResearchJobFile(projectHex string, slug string, v any) error
- func WriteSession(projectHex string, s *Session) (err error)
- func WriteSubSession(projectHex string, s *SubSession) (err error)
- type ActiveSubagentEntry
- type ActiveSubagentsFile
- type BranchSegment
- type CapabilityRegistry
- func (r *CapabilityRegistry) Backfill(messages []Message)
- func (r *CapabilityRegistry) Capture(name, payload string)
- func (r *CapabilityRegistry) CaptureUser(m Message)
- func (r CapabilityRegistry) RestoreMessage() (Message, bool)
- func (r *CapabilityRegistry) SetSkillEnabled(name string, enabled bool)
- type FileChangeLedger
- type FileChangeSummary
- type LegacyChatDifference
- type Message
- type PendingSubagentSpawn
- type QueuedTask
- type Session
- func FindByTitle(projectHex, title string) (*Session, error)
- func ListRecent(projectHex string, n int) ([]*Session, error)
- func ListSidebarSummaries(project string, limit int) ([]*Session, error)
- func ListSummaries(projectHex string, limit int) ([]*Session, error)
- func ReadSession(projectHex, chatIDHex string) (sess *Session, err error)
- func ReadTerminalChat(id, project string) (*Session, error)
- func SessionWithLatestUserMessage(projectHex string) (*Session, error)
- type SessionFileLock
- type SubSession
- type ToolCall
- type UncompactedDump
Constants ¶
const ( SubOriginParent = "parent" SubOriginScheduled = "scheduled" )
const ( SubStatusRunning = "running" SubStatusPaused = "paused" SubStatusDone = "done" SubStatusCancelled = "cancelled" SubStatusQueued = "queued" )
Variables ¶
This section is empty.
Functions ¶
func ApplyCompaction ¶ added in v2026.608.0
func ApplyCompactionWithPendingMessages ¶ added in v2026.1114.0
func ApplyTurnUsageDisplayToLastSubAssistant ¶ added in v2026.615.0
func ApplyTurnUsageDisplayToLastSubAssistant(s *SubSession, ctxTok, usrTok int64, ctxEst bool, reasonTok, respTok, totalTok, cachedPromptTok, cacheCreationPromptTok int64, outputTPS, ttftSecs, promptTPS, turnWallSecs float64)
func ArchiveUncompactedState ¶ added in v2026.608.0
func AssistantDisplayParts ¶
func BackfillSessionAssistantUsage ¶
func BackfillSessionAssistantUsage(msgs []Message)
func CacheTokenCount ¶ added in v2026.1023.0
CacheTokenCount distinguishes legacy absent zero counters from reported zero.
func ConversationSummaryText ¶ added in v2026.1114.0
func DeleteResearchJob ¶ added in v2026.617.0
func EnsureResearchDir ¶ added in v2026.617.0
func EstimatePromptContext ¶ added in v2026.1121.0
func FinishSessionLoad ¶
func IsCapabilityTool ¶ added in v2026.1021.0
func IsCompactionSummary ¶ added in v2026.1021.0
IsCompactionSummary recognizes the stored summary envelope, rather than mentions of its marker in ordinary assistant explanations or tool output.
func IsPlaceholderChatID ¶
func ListResearchJobFiles ¶ added in v2026.617.0
func MessageWireWeight ¶ added in v2026.611.1
func MigrateLegacyCheckpointsToBase0 ¶
func MigrateLegacyCheckpointsToBase0(s *Session)
func ModelToolContent ¶ added in v2026.1121.0
func NeutralizeLiteralImgPlaceholders ¶ added in v2026.602.2
func NewPlaceholderChatID ¶
func NormalizeSummaryWhitespace ¶ added in v2026.602.2
func ProjectWelcomeStats ¶
func PruneUnreferencedSessionImages ¶
func PruneUnreferencedSessionImages(s *Session)
func ReadResearchJobFile ¶ added in v2026.617.0
func ReconcileCheckpointLast ¶
func ReconcileCheckpointLast(s *Session)
func RememberTerminalChat ¶ added in v2026.1023.0
RememberTerminalChat keeps each terminal's active chat separate, including when several terminals share the same project during an upgrade.
func RemoveSessionPath ¶
func RenameSessionFile ¶
func RepairInterruptedToolCalls ¶ added in v2026.1023.0
RepairInterruptedToolCalls closes calls whose results were lost before a new user turn. It never executes a tool or claims that its side effects failed.
func ResearchDir ¶ added in v2026.617.0
func ResearchHTMLPath ¶ added in v2026.617.0
func ResearchJobPath ¶ added in v2026.617.0
func RunChatMigration ¶ added in v2026.1121.0
func ScrubCompactSummaryContent ¶ added in v2026.602.2
func ScrubLiteralImgPlaceholdersForAPI ¶ added in v2026.602.2
func ScrubSummaryImgWorkflowLines ¶ added in v2026.602.2
func SessionActivityTime ¶ added in v2026.909.0
func SessionImgFragmentCount ¶ added in v2026.602.2
func SessionLockPath ¶ added in v2026.708.0
func SessionPath ¶
func SessionRepairChanged ¶ added in v2026.602.2
func SessionValidImageTokenCount ¶ added in v2026.602.2
func StripAllImgPlaceholderLiterals ¶ added in v2026.602.2
func StripFalseImgPlaceholdersFromNonUserSession ¶ added in v2026.602.2
func SubSessionPath ¶ added in v2026.615.0
func SubSessionRunning ¶ added in v2026.615.0
func SubchatPath ¶
func SubchatsDir ¶
func SumCacheTokens ¶ added in v2026.1023.0
SumCacheTokens returns unknown when any call lacks the counter.
func ValidTerminalID ¶ added in v2026.1023.0
func WriteActiveSubagents ¶ added in v2026.615.0
func WriteActiveSubagents(f *ActiveSubagentsFile) (err error)
func WriteMainMessageChange ¶ added in v2026.1121.0
func WriteResearchJobFile ¶ added in v2026.617.0
func WriteSession ¶
func WriteSubSession ¶ added in v2026.615.0
func WriteSubSession(projectHex string, s *SubSession) (err error)
Types ¶
type ActiveSubagentEntry ¶ added in v2026.615.0
type ActiveSubagentsFile ¶ added in v2026.615.0
type ActiveSubagentsFile struct {
Agents []ActiveSubagentEntry `json:"agents"`
}
func ReadActiveSubagents ¶ added in v2026.615.0
func ReadActiveSubagents() (*ActiveSubagentsFile, error)
type BranchSegment ¶ added in v2026.621.0
type CapabilityRegistry ¶ added in v2026.1021.0
type CapabilityRegistry struct {
DiscoveredTools map[string]json.RawMessage `json:"discovered_tools,omitempty"`
LoadedSkills map[string]json.RawMessage `json:"loaded_skills,omitempty"`
DisabledSkills map[string]bool `json:"disabled_skills,omitempty"`
SDK json.RawMessage `json:"sdk,omitempty"`
}
func (*CapabilityRegistry) Backfill ¶ added in v2026.1021.0
func (r *CapabilityRegistry) Backfill(messages []Message)
func (*CapabilityRegistry) Capture ¶ added in v2026.1021.0
func (r *CapabilityRegistry) Capture(name, payload string)
func (*CapabilityRegistry) CaptureUser ¶ added in v2026.1021.0
func (r *CapabilityRegistry) CaptureUser(m Message)
func (CapabilityRegistry) RestoreMessage ¶ added in v2026.1021.0
func (r CapabilityRegistry) RestoreMessage() (Message, bool)
func (*CapabilityRegistry) SetSkillEnabled ¶ added in v2026.1023.1
func (r *CapabilityRegistry) SetSkillEnabled(name string, enabled bool)
type FileChangeLedger ¶ added in v2026.1023.0
type FileChangeLedger struct {
AddedLines map[string]int `json:"added_lines,omitempty"`
RemovedLines map[string]int `json:"removed_lines,omitempty"`
Binary bool `json:"binary,omitempty"`
BeforeExists bool `json:"before_exists"`
AfterExists bool `json:"after_exists"`
}
FileChangeLedger stores only this chat's tool deltas, never workspace totals.
type FileChangeSummary ¶ added in v2026.1023.0
type FileChangeSummary struct {
Path string `json:"path"`
Added int `json:"added"`
Removed int `json:"removed"`
Binary bool `json:"binary,omitempty"`
AddedLines []string `json:"addedLines,omitempty"`
RemovedLines []string `json:"removedLines,omitempty"`
}
FileChangeSummary is a saved view of this chat's pending changes at turn end.
type LegacyChatDifference ¶ added in v2026.1121.0
type LegacyChatDifference struct {
Project string `json:"projectId"`
Chat string `json:"chatId"`
Status string `json:"status"`
Detail string `json:"detail,omitempty"`
}
func VerifyLegacyChats ¶ added in v2026.1121.0
func VerifyLegacyChats(ctx context.Context) ([]LegacyChatDifference, error)
type Message ¶
type Message struct {
FileChangesRecorded bool `json:"file_changes_recorded,omitempty"`
FileChanges []FileChangeSummary `json:"file_changes,omitempty"`
ContextKind string `json:"context_kind,omitempty"`
Provider string `json:"provider,omitempty"`
FastMode *bool `json:"fast_mode,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Model string `json:"model,omitempty"`
GUIHidden bool `json:"gui_hidden,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Role string `json:"role"`
Content string `json:"content"`
APIContent string `json:"api_content,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolImages []images.Attachment `json:"tool_images,omitempty"`
MediaPreviews []images.Attachment `json:"media_previews,omitempty"`
MediaRoot string `json:"media_root,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ReasoningText string `json:"reasoning_text,omitempty"`
ReasoningEncrypted string `json:"reasoning_encrypted,omitempty"`
ReasoningItem string `json:"reasoning_item,omitempty"`
AnthropicThinking []json.RawMessage `json:"anthropic_thinking,omitempty"`
CheckpointSeq int `json:"cp_seq,omitempty"`
CpSeqSet bool `json:"cp_set,omitempty"`
CheckpointBranchKey string `json:"cp_branch,omitempty"`
CommitOID string `json:"commit_oid,omitempty"`
UserPromptTokens int64 `json:"user_prompt_tokens"`
ReasoningTokens int64 `json:"reasoning_tokens"`
ResponseTokens int64 `json:"response_tokens"`
TurnTotalTokens int64 `json:"turn_total_tokens"`
PromptContextEstimate int64 `json:"prompt_context_estimate,omitempty"`
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CacheUsageTracked bool `json:"cache_usage_tracked,omitempty"`
CachedPromptTokens int64 `json:"cached_prompt_tokens,omitempty"`
CacheCreationPromptTokens int64 `json:"cache_creation_prompt_tokens,omitempty"`
OutputTPS float64 `json:"output_tps,omitempty"`
TTFTSecs float64 `json:"ttft_secs,omitempty"`
PromptTPS float64 `json:"prompt_tps,omitempty"`
ToolWallSecs float64 `json:"tool_wall_secs,omitempty"`
TurnWallSecs float64 `json:"turn_wall_secs,omitempty"`
TurnDisplaySaved bool `json:"turn_display_saved,omitempty"`
TurnContextTokens int64 `json:"turn_context_tokens,omitempty"`
TurnContextEst bool `json:"turn_context_est,omitempty"`
TurnUserTokens int64 `json:"turn_user_tokens,omitempty"`
TurnCachedPromptTokens int64 `json:"turn_cached_prompt_tokens,omitempty"`
TurnCacheCreationPromptTokens int64 `json:"turn_cache_creation_prompt_tokens,omitempty"`
TurnReasonTokens int64 `json:"turn_reason_tokens,omitempty"`
TurnRespTokens int64 `json:"turn_resp_tokens,omitempty"`
TurnTotalDisplay int64 `json:"turn_total_display,omitempty"`
TurnOutputTPS float64 `json:"turn_output_tps,omitempty"`
TurnTTFTSecs float64 `json:"turn_ttft_secs,omitempty"`
TurnPromptTPS float64 `json:"turn_prompt_tps,omitempty"`
TurnWallDisplay float64 `json:"turn_wall_display_secs,omitempty"`
}
func SummaryMessages ¶ added in v2026.1021.0
type PendingSubagentSpawn ¶ added in v2026.615.0
type PendingSubagentSpawn struct {
ParentSubchatID string `json:"parent_subchat_id,omitempty"`
Depth int `json:"depth,omitempty"`
RequesterSubchatID string `json:"requester_subchat_id"`
RequesterOrigin string `json:"requester_origin"`
ParentChatID string `json:"parent_chat_id,omitempty"`
ProjectHex string `json:"project_hex,omitempty"`
SysPromptPath string `json:"sys_prompt_path"`
Task string `json:"task"`
Resume string `json:"resume,omitempty"`
Interrupt bool `json:"interrupt,omitempty"`
RunInBackground bool `json:"run_in_background,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
RoleProvider string `json:"role_provider,omitempty"`
RoleModel string `json:"role_model,omitempty"`
ToolCall ToolCall `json:"tool_call"`
SpawnISO string `json:"spawn_iso"`
NotifyNewChat bool `json:"notify_new_chat,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type QueuedTask ¶ added in v2026.615.0
type Session ¶
type Session struct {
FileChanges map[string]FileChangeLedger `json:"file_changes,omitempty"`
FileChangesTurn int `json:"file_changes_turn,omitempty"`
ID string `json:"id"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
LastMessageAt time.Time `json:"last_message_at"`
LastUserMessageAt time.Time `json:"last_user_message_at,omitempty"`
Messages []Message `json:"messages"`
Capabilities CapabilityRegistry `json:"capabilities,omitempty"`
CheckpointLast int `json:"checkpoint_last"`
CheckpointCP0 bool `json:"cp0,omitempty"`
CheckpointBranchSuffix string `json:"cp_branch_suffix,omitempty"`
ForkChildCount map[int]int `json:"fork_child_count,omitempty"`
Branches []BranchSegment `json:"branches,omitempty"`
LastCommitOID string `json:"last_commit_oid,omitempty"`
ImageSeq int `json:"image_seq,omitempty"`
ImageFiles map[int]string `json:"image_files,omitempty"`
TerminalClips map[string]string `json:"terminal_clips,omitempty"`
ActivatedInstructionDirs []string `json:"activated_instruction_dirs,omitempty"`
UncompactedRaw []UncompactedDump `json:"uncompactedRaw,omitempty"`
PlanningActive bool `json:"planning_active,omitempty"`
ActivePlanName string `json:"active_plan_name,omitempty"`
PlanImplementing bool `json:"plan_implementing,omitempty"`
}
func FindByTitle ¶
func ListSidebarSummaries ¶ added in v2026.1121.0
func ListSummaries ¶ added in v2026.1114.0
func ReadSession ¶
func ReadTerminalChat ¶ added in v2026.1023.0
func (*Session) TruncateForRegeneration ¶ added in v2026.1030.0
Keep the original user message so expanded mentions, image references and checkpoint metadata remain identical on the new attempt.
func (*Session) UnmarshalJSON ¶ added in v2026.621.0
type SessionFileLock ¶ added in v2026.708.0
type SessionFileLock struct {
// contains filtered or unexported fields
}
func TryAcquireSessionFileLock ¶ added in v2026.708.0
func TryAcquireSessionFileLock(projectHex, chatID string) (*SessionFileLock, error)
func (*SessionFileLock) Release ¶ added in v2026.708.0
func (l *SessionFileLock) Release()
type SubSession ¶ added in v2026.615.0
type SubSession struct {
ParentSubchatID string `json:"parent_subchat_id,omitempty"`
Depth int `json:"depth,omitempty"`
FastMode *bool `json:"fast_mode,omitempty"`
Capabilities CapabilityRegistry `json:"capabilities,omitempty"`
ID string `json:"id"`
Title string `json:"title"`
CreatedAt time.Time `json:"created_at"`
LastMessageAt time.Time `json:"last_message_at"`
Messages []Message `json:"messages"`
ImageSeq int `json:"image_seq,omitempty"`
ImageFiles map[int]string `json:"image_files,omitempty"`
ParentChatID string `json:"parent_chat_id,omitempty"`
ParentToolCallID string `json:"parent_tool_call_id,omitempty"`
ProjectHex string `json:"project_hex,omitempty"`
SysPromptPath string `json:"sys_prompt_path,omitempty"`
Origin string `json:"origin"`
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
PersistContext bool `json:"persist_context,omitempty"`
Status string `json:"status"`
TaskQueue []QueuedTask `json:"task_queue,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
RoleProvider string `json:"role_provider,omitempty"`
RoleModel string `json:"role_model,omitempty"`
PendingSpawns []PendingSubagentSpawn `json:"pending_spawns,omitempty"`
}
func FindSubSessionByID ¶ added in v2026.615.0
func FindSubSessionByID(projectHex, id string) (*SubSession, error)
func ListSubSessions ¶ added in v2026.615.0
func ListSubSessions(projectHex string) ([]*SubSession, error)
func ReadSubSession ¶ added in v2026.615.0
func ReadSubSession(projectHex, origin, id string) (*SubSession, error)
type UncompactedDump ¶ added in v2026.608.0
type UncompactedDump struct {
CompactAt time.Time `json:"compact_at"`
Messages []Message `json:"messages"`
CheckpointLast int `json:"checkpoint_last"`
CheckpointCP0 bool `json:"cp0,omitempty"`
CheckpointBranchSuffix string `json:"cp_branch_suffix,omitempty"`
ForkChildCount map[int]int `json:"fork_child_count,omitempty"`
Branches []BranchSegment `json:"branches,omitempty"`
LastCommitOID string `json:"last_commit_oid,omitempty"`
}
func (*UncompactedDump) UnmarshalJSON ¶ added in v2026.621.0
func (d *UncompactedDump) UnmarshalJSON(data []byte) error
Source Files
¶
- agents.go
- assets.go
- capabilities.go
- change.go
- checkpoint_sync.go
- compaction.go
- database.go
- images.go
- membership.go
- migration.go
- models.go
- regenerate.go
- reportpersistance.go
- session_file.go
- session_file_other.go
- sidebar.go
- snapshots.go
- stats.go
- store.go
- streams.go
- subchat.go
- subsession.go
- summaries.go
- terminal_session.go
- tool_recovery.go
- usage.go
- verification.go