types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package types holds the agent-owned message and session model.

Provider adapters translate to/from these — providers do NOT leak into the rest of the codebase. Keep this package small and stable; everything downstream depends on it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockType

type BlockType string
const (
	BlockText       BlockType = "text"
	BlockToolUse    BlockType = "tool_use"
	BlockToolResult BlockType = "tool_result"
	BlockImage      BlockType = "image"
	// BlockThinking carries provider-emitted chain-of-thought / reasoning
	// summaries. Stored locally for display but NEVER sent back to providers
	// (wire adapters drop unknown block types via their case-based switches).
	BlockThinking BlockType = "thinking"
)

type Checkpoint

type Checkpoint struct {
	// PreserveFrom is the id of the first message kept verbatim after the
	// summary. Everything before it is folded into the summary text.
	PreserveFrom string `json:"preserve_from"`
}

Checkpoint records where a compaction summary supersedes prior messages.

type ContentBlock

type ContentBlock struct {
	Type      BlockType   `json:"type"`
	Text      string      `json:"text,omitempty"`
	Use       *ToolUse    `json:"tool_use,omitempty"`
	Result    *ToolResult `json:"tool_result,omitempty"`
	MediaType string      `json:"media_type,omitempty"` // for BlockImage e.g. "image/png"
	Data      []byte      `json:"data,omitempty"`       // raw bytes (provider adapters base64-encode)
}

ContentBlock is a typed piece of message content. Assistant messages may contain a mix of text and tool_use blocks. User messages may carry text, tool_result, and image blocks.

type Message

type Message struct {
	ID       string         `json:"id"`
	ParentID string         `json:"parent_id,omitempty"`
	Role     Role           `json:"role"`
	Content  []ContentBlock `json:"content"`
	Time     time.Time      `json:"ts"`
	// Ephemeral marks a scrollback-only UI echo (slash-command confirmations,
	// queued/steer notices). Shown in the TUI but never replayed to the LLM,
	// so the model can't mistake "(/new done)" for a finish signal and parrot it.
	Ephemeral bool `json:"ephemeral,omitempty"`
	// Display is a render-only override for the user bubble. When set, the TUI
	// shows this instead of the concatenated Content text — used so a slash
	// skill renders as the typed command ("/plan build X") while Content still
	// carries the expanded skill body sent to the model. Never goes to the wire.
	Display string `json:"display,omitempty"`
	// Checkpoint, when non-nil, marks this message as a compaction boundary.
	// Its Content holds the summary that replaces every message from
	// PreserveFrom (inclusive) backwards. The disk log stays append-only and
	// keeps the raw history; resume reads collapse it at the last checkpoint so
	// `bee back` sees the same shortened history the live session had instead
	// of replaying everything.
	Checkpoint *Checkpoint `json:"checkpoint,omitempty"`
}

Message is one turn in the conversation. Content is an ordered list of blocks; concatenation of plain text blocks recreates the natural text.

type MessageNode

type MessageNode struct {
	Msg      Message
	Children []*MessageNode
}

MessageNode is a session-graph node held in memory during a live session. Children are computed by traversal; not persisted.

type Role

type Role string

Role of a message in the conversation.

const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

type Session

type Session struct {
	ID       string    `json:"id"`
	Created  time.Time `json:"created"`
	Cwd      string    `json:"cwd"`
	Model    string    `json:"model"`
	Provider string    `json:"provider"`
}

Session is a tree of messages. Each Message has a ParentID; the root has empty ParentID. Branches share a parent and let users explore alternate agent paths without losing prior work.

type ToolResult

type ToolResult struct {
	UseID   string `json:"use_id"`
	Content string `json:"content"`
	IsError bool   `json:"is_error,omitempty"`
}

ToolResult is the agent's response carrying the tool's output.

type ToolUse

type ToolUse struct {
	ID    string         `json:"id"`
	Name  string         `json:"name"`
	Input map[string]any `json:"input"`
}

ToolUse is the model's request to invoke a tool.

Jump to

Keyboard shortcuts

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