grok_session

package
v0.0.76 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromUpdatesJSONL

func FromUpdatesJSONL(lines []string) []types.AgentEvent

FromUpdatesJSONL walks wire lines through a converter, flushes at end, and returns all canonical events.

func TextContent

func TextContent(raw json.RawMessage) string

TextContent extracts user-visible text from a session update content field.

func ToWireLines

func ToWireLines(updates []SessionUpdate, opts ToOptions) []string

ToWireLines marshals session updates to JSONL strings.

Types

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

Converter converts grok session updates to AgentEvents with chunk coalescing.

func NewConverter

func NewConverter() *Converter

NewConverter creates a converter for one grok session stream.

func (*Converter) Flush

func (c *Converter) Flush() []types.AgentEvent

Flush emits any buffered chunk coalescence at end of stream.

func (*Converter) ProcessLine

func (c *Converter) ProcessLine(line string) []types.AgentEvent

ProcessLine parses one updates.jsonl line and returns AgentEvents to emit.

func (*Converter) SetTurnIndex added in v0.0.51

func (c *Converter) SetTurnIndex(idx int)

SetTurnIndex restores the converter turn counter from a grok-sync checkpoint.

func (*Converter) TurnIndex added in v0.0.51

func (c *Converter) TurnIndex() int

TurnIndex returns the current grok turn index stamped on emitted events.

type SessionUpdate

type SessionUpdate struct {
	SessionUpdate string          `json:"sessionUpdate"`
	Content       json.RawMessage `json:"content,omitempty"`
	ToolCallID    string          `json:"toolCallId,omitempty"`
	Kind          string          `json:"kind,omitempty"`
	Title         string          `json:"title,omitempty"`
	Status        string          `json:"status,omitempty"`
}

SessionUpdate is one ACP session update record from updates.jsonl.

func ParseLine

func ParseLine(line string) (SessionUpdate, bool)

ParseLine parses one updates.jsonl line in flat or grok wire envelope form.

func ToSession

func ToSession(events []types.AgentEvent, opts ToOptions) []SessionUpdate

ToSession converts canonical AgentEvents to grok session updates.

type ToOptions

type ToOptions struct {
	SessionID string
}

ToOptions controls reverse conversion wire shape. Zero value emits flat sessionUpdate objects.

Jump to

Keyboard shortcuts

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