Documentation
¶
Index ¶
- Constants
- func IsHiddenSession(sessionID string) bool
- func NormalizeSessionID(raw string) string
- func OrchKey(projectID, sessionID string) string
- func ParseOrchKey(projectID, orch string) string
- type ContextBudget
- type ContextMessage
- type File
- type Message
- type SearchOptions
- type Session
- type Store
- func (s *Store) ActiveBrief(projectRoot, projectID string) (string, error)
- func (s *Store) Append(projectRoot, projectID, sessionID, role, content, taskID, feedforward string) (File, error)
- func (s *Store) Clear(projectRoot, projectID, sessionID string, deleteSession bool) (File, error)
- func (s *Store) Create(projectRoot, projectID, title string) (File, Session, error)
- func (s *Store) Ensure(projectRoot, projectID, sessionID, title string) error
- func (s *Store) FormatThreadBrief(projectRoot, projectID string, usersOnly bool, maxUser int) (string, error)
- func (s *Store) Rewind(projectRoot, projectID, sessionID string, keep int) (File, error)
- func (s *Store) Search(projectRoot, projectID string, opt SearchOptions) (string, error)
- func (s *Store) SetActive(projectRoot, projectID, sessionID string) (File, error)
- func (s *Store) Snapshot(projectRoot, projectID string) (File, error)
- func (s *Store) VisibleSnapshot(projectRoot, projectID string) (File, error)
- type ToolDigestLookup
Constants ¶
const MainSessionID = "main"
Variables ¶
This section is empty.
Functions ¶
func IsHiddenSession ¶
IsHiddenSession 系统/写手会话:不进侧栏历史列表。
func NormalizeSessionID ¶
NormalizeSessionID 空 / default → main。
func ParseOrchKey ¶
ParseOrchKey 从 orch:pid:sess 拆出 sessionId。
Types ¶
type ContextBudget ¶
type ContextBudget struct {
// RecentKeep 最近原文条数(默认 12)。
RecentKeep int
// MaxMsgRunes 单条最大 rune(默认 2400)。
MaxMsgRunes int
// OlderUserKeep 更早历史里保留的 user 要点条数(默认 8)。
OlderUserKeep int
// OlderUserRunes 每条旧 user 摘要 rune(默认 160)。
OlderUserRunes int
// OlderAssistKeep 折叠区保留的助理结论条数(默认 4)。
OlderAssistKeep int
// OlderAssistRunes 每条助理结论 rune(默认 120)。
OlderAssistRunes int
// OlderToolKeep 折叠区保留的工具足迹条数(默认 8)。
OlderToolKeep int
}
ContextBudget 构造 ContextMessages 预算(磁盘 sessions.json 仍全量保留)。
func DefaultContextBudget ¶
func DefaultContextBudget() ContextBudget
DefaultContextBudget 默认有界 ContextMessages。
type ContextMessage ¶
ContextMessage 喂给模型的一条进模上下文(与磁盘 Message 分离;可截断/摘要)。
func BuildContextMessages ¶
func BuildContextMessages(msgs []Message, budget ContextBudget, lookup ToolDigestLookup) []ContextMessage
BuildContextMessages 从全量会话消息构造有界 ContextMessages(不含本轮尚未 Append 的 user)。 助理正文不含工具行;交付足迹经 lookup(taskId) 进 system,避免模型仿写 `[Desk tools:…]`。
type Message ¶
type Message struct {
Role string `json:"role"` // user | assistant | system
Content string `json:"content"`
CreatedAt int64 `json:"createdAt"`
TaskID string `json:"taskId,omitempty"` // 助手回合对应 tasks 轨迹
Seq int `json:"seq,omitempty"`
InModelWindow bool `json:"inModelWindow"`
HasFeedforward bool `json:"hasFeedforward"`
}
Message 会话消息(工作记忆壳;正文进 ContextMessages;工具经 TaskID → tasks,禁止塞进 Content)。
type SearchOptions ¶
SearchOptions 会话对话检索(FTS5)。
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
OrchKey string `json:"orchKey"`
UpdatedAt int64 `json:"updatedAt"`
Messages []Message `json:"messages"`
}
Session 一条 UI/编排会话。
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 按项目 SQLite 会话。
func (*Store) ActiveBrief ¶
ActiveBrief 供 MCP / UI / Turn Snapshot 短摘要。
func (*Store) Append ¶
func (s *Store) Append(projectRoot, projectID, sessionID, role, content, taskID, feedforward string) (File, error)
Append 往 active(或指定)会话追加消息;写入 history_message(对话 SSOT)。
func (*Store) FormatThreadBrief ¶
func (s *Store) FormatThreadBrief(projectRoot, projectID string, usersOnly bool, maxUser int) (string, error)
FormatThreadBrief 最近用户原话。
func (*Store) Search ¶
func (s *Store) Search(projectRoot, projectID string, opt SearchOptions) (string, error)
Search 按 FTS5 检索 history_message;MySQL 无 FTS 时走 LIKE。
type ToolDigestLookup ¶
ToolDigestLookup 按 taskId 取交付足迹(write_file→path …)。真源在 runs,不进助理正文。