Documentation
¶
Overview ¶
Package grok provides an adapter for Grok Build TUI sessions.
Sessions live under $GROK_HOME/sessions (default ~/.grok/sessions), organized by URL-encoded working directory:
~/.grok/sessions/<encoded-cwd>/<session-id>/ summary.json // metadata index (title, timestamps, model, parent) chat_history.jsonl // structured conversation for display events.jsonl // runtime telemetry updates.jsonl // ACP restore log
Encoding matches Python urllib.parse.quote(path, safe=”): every non-unreserved byte is percent-encoded, so "/" becomes "%2F".
Resume CLI: grok --resume <session-id>
Index ¶
- type Adapter
- func (a *Adapter) Capabilities() adapter.CapabilitySet
- func (a *Adapter) Detect(projectRoot string) (bool, error)
- func (a *Adapter) DiscoverRelatedProjectDirs(mainWorktreePath string) ([]string, error)
- func (a *Adapter) ID() string
- func (a *Adapter) Icon() string
- func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)
- func (a *Adapter) Name() string
- func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
- func (a *Adapter) SessionByID(sessionID string) (*adapter.Session, error)
- func (a *Adapter) SessionIDFromPath(path string) (string, error)
- func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)
- func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
- func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)
- func (a *Adapter) WatchForProjectDiscovery() bool
- func (a *Adapter) WatchScope() adapter.WatchScope
- type ChatLine
- type ContentBlock
- type Summary
- type SummaryText
- type ToolCall
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements adapter.Adapter for Grok Build sessions.
func NewWithSessionsDir ¶
NewWithSessionsDir creates an adapter rooted at sessionsDir (for tests).
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() adapter.CapabilitySet
Capabilities returns supported features.
func (*Adapter) DiscoverRelatedProjectDirs ¶
DiscoverRelatedProjectDirs finds other Grok-encoded project dirs under the same sessions root that look like worktrees of mainWorktreePath.
func (*Adapter) SearchMessages ¶
func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)
SearchMessages searches message content within a session. Implements adapter.MessageSearcher.
func (*Adapter) SessionByID ¶
SessionByID implements TargetedRefresher.
func (*Adapter) SessionIDFromPath ¶
SessionIDFromPath resolves a chat_history path to its session ID.
func (*Adapter) Usage ¶
func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)
Usage is not available from Grok chat history; returns empty stats.
func (*Adapter) WatchForProjectDiscovery ¶
WatchForProjectDiscovery keeps the watcher alive when the project has no sessions yet so the first session can appear without a restart.
func (*Adapter) WatchScope ¶
func (a *Adapter) WatchScope() adapter.WatchScope
WatchScope is global: all projects live under a single sessions root.
type ChatLine ¶
type ChatLine struct {
Type string `json:"type"`
ID string `json:"id"`
Content json.RawMessage `json:"content"`
ToolCallID string `json:"tool_call_id"`
ToolCalls []ToolCall `json:"tool_calls"`
ModelID string `json:"model_id"`
Summary []SummaryText `json:"summary"` // reasoning summaries
Status string `json:"status"`
SyntheticReason string `json:"synthetic_reason"`
}
ChatLine is one JSONL record from chat_history.jsonl. Content is heterogeneous (string or array of blocks) so it stays raw JSON.
type ContentBlock ¶
ContentBlock is a user content part (text or image).
type Summary ¶
type Summary struct {
Info struct {
ID string `json:"id"`
CWD string `json:"cwd"`
} `json:"info"`
SessionSummary string `json:"session_summary"`
GeneratedTitle string `json:"generated_title"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastActiveAt time.Time `json:"last_active_at"`
NumMessages int `json:"num_messages"`
NumChatMessages int `json:"num_chat_messages"`
CurrentModelID string `json:"current_model_id"`
GitRootDir string `json:"git_root_dir"`
AgentName string `json:"agent_name"`
SessionKind string `json:"session_kind"`
ParentSessionID string `json:"parent_session_id"`
}
Summary is the on-disk summary.json index for a Grok session.
type SummaryText ¶
SummaryText is a reasoning summary fragment.