transcript

package
v0.3.26-rc.7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transcript reads what agents said.

Every agent that keeps a record of its conversations keeps it somewhere of its own and in a shape of its own, and three parts of Flockdeck want to read it: restoring a layout, which resumes a conversation only when there is one to resume; the history overlay, which lists them; and a fan-out, which takes the plan an agent just wrote out of its last few replies rather than off the screen. Each of those asks a Reader, so an agent Flockdeck has never heard of costs them nothing: it gets the null reader and they all cope.

Index

Constants

View Source
const (
	KindPrompt     = "prompt"
	KindReply      = "reply"
	KindThinking   = "thinking"
	KindTool       = "tool"
	KindSubagent   = "subagent"
	KindCompaction = "compaction"
	KindNotice     = "notice"
	KindImage      = "image"
)

Kinds an Entry can be, per the protocol.

View Source
const (
	StatusRunning = "running"
	StatusOK      = "ok"
	StatusError   = "error"
)

Tool and subagent statuses.

View Source
const (
	ToolOutputCap = 4 << 10
	DiffCap       = 64 << 10
)

Size caps from the protocol contract: a tool result over ToolOutputCap never arrives inline, and a diff over DiffCap becomes a summary with detail fetched on demand.

View Source
const NoPrompt = "(no prompt recorded)"

NoPrompt stands in for the summary of a conversation that says nothing about itself: no prompt in its opening entries, and no name from the agent either. It is a label for a row in a list, not a name for anything.

Variables

View Source
var Agents = func() []agent.Spec { return agent.Load().Specs }

Agents is the catalog the history overlay lists conversations for: every agent, hidden ones included, since a hidden agent's conversations are still there to resume.

It was Claude alone until whoever assembled the catalog pointed it there, and nothing ever did, so an API agent's chats were recorded and never offered. It is still a variable, so a test can put a catalog of its own behind it.

Functions

func ClaudeHome added in v0.3.0

func ClaudeHome() string

ClaudeHome returns the directory Claude Code keeps its state in: its settings, and the login whose limits every Claude pane shares.

func ClaudeHomeFor added in v0.3.3

func ClaudeHomeFor(spec agent.Spec) string

ClaudeHomeFor returns the directory Claude Code keeps its state in for a pane running spec.

A catalog entry may set CLAUDE_CONFIG_DIR, which is the usual way to run a second Claude account, and the entry's environment is laid over Flockdeck's own in the pane, the last setting of a name winning. Reading Flockdeck's own instead looked for the pane's transcripts under the other account: a restart found nothing to resume and started the conversation again, task and all, and the history listed the wrong account's. The catalog has already expanded the variables in the value.

func EditDiff added in v0.3.9

func EditDiff(path, oldString, newString string) string

EditDiff, MultiEditDiff and WriteDiff let another package build the same inline diff a finished Edit, MultiEdit or Write tool row shows, straight from a call's own input -- in particular, a permission prompt built from a PreToolUse call before the tool has run at all, which has nothing else to diff against.

func Exists

func Exists(spec agent.Spec, sessionID string) bool

Exists reports whether an agent has a stored conversation worth resuming.

The file existing is not enough. A session interrupted before it recorded anything leaves an empty one behind, and an agent asked to resume that refuses and exits -- which, on a restored layout, is every such pane dying at once.

func MultiEditDiff added in v0.3.9

func MultiEditDiff(path string, edits []EditPair) string

MultiEditDiff renders every edit of a MultiEdit call as its own hunk, oldest first, the same order toolDiff already builds them in.

func WriteDiff added in v0.3.9

func WriteDiff(path, content string) string

WriteDiff renders a Write call as a diff against nothing: every line of content arrives as added.

Types

type Chat

type Chat struct{}

Chat reads the record Flockdeck's own chat client keeps: one JSONL file per session under the state directory, one object per entry.

It is the same reader for every API agent, because they are all the same program talking to different endpoints, and it is a great deal simpler than Claude Code's because Flockdeck writes it: the entries are small, they are all in one folder, and there is no derived folder name to reproduce.

func (Chat) Conversations

func (Chat) Conversations(spec agent.Spec, cwd string) ([]Conversation, error)

Conversations lists the chats that ran in a working directory, most recently used first, each labelled as spec's. All asks once for every API agent and works out which of them held each chat instead.

func (Chat) Path

func (Chat) Path(_ agent.Spec, sessionID string) string

func (Chat) Replies

func (c Chat) Replies(spec agent.Spec, sessionID string, n int) []string

Replies returns what the model said in its last few turns, newest first, turn by turn the way the Claude reader counts them.

func (Chat) Stream added in v0.3.13

func (Chat) Stream(_ agent.Spec, sessionID string) (Stream, bool)

Stream returns a live view of a pane running Flockdeck's own chat client, tailing its transcript (internal/chat/transcript.go) the same way Claude's does its own. It answers ok=true whenever a session id is given at all -- same reasoning as Claude's: a pane that has not been prompted yet has nothing to show, not an agent the phone should fall back to the terminal for.

The session id names a file in the chats folder, so it must be one plain name. It is whatever the pane's own process last reported through the hook, and a misbehaving one reporting "../x" must not point this at a transcript outside that folder.

type Claude

type Claude struct{}

Claude reads the transcripts Claude Code writes: one JSONL file per session, under a folder per working directory, below Claude Code's own state directory. Only where that state directory is comes from the Spec: the rest is Claude Code's arrangement rather than Flockdeck's, and Flockdeck only reproduces enough of it to find the files.

func (Claude) Conversations

func (Claude) Conversations(spec agent.Spec, cwd string) ([]Conversation, error)

func (Claude) Path

func (Claude) Path(spec agent.Spec, sessionID string) string

func (Claude) Replies

func (Claude) Replies(spec agent.Spec, sessionID string, n int) []string

func (Claude) Stream added in v0.3.8

func (Claude) Stream(spec agent.Spec, sessionID string) (Stream, bool)

Stream returns a live view of a Claude Code pane's conversation, tailing its transcript as the design's §1 describes. It answers ok=true whenever the pane's session id and Claude's own state directory are known, whether or not the transcript exists yet -- a pane that has not been prompted has nothing to show, not an agent the phone should fall back to the terminal for.

type Conversation

type Conversation struct {
	// ID is the session id, which is also the transcript's file name and what
	// the agent is given to reattach to it.
	ID string
	// Agent is the id of the agent that held the conversation. The history
	// overlay draws several agents' conversations in one list, and which agent
	// a row belongs to decides what happens when it is opened, so a row that
	// does not say is a row that cannot be resumed correctly.
	Agent   string
	Cwd     string
	Summary string
	// Title is the name the agent gave the conversation, when it gave it one.
	// It is what the summary falls back to, and what tells apart conversations
	// that were opened with the same prompt.
	Title    string
	Modified time.Time
	Messages int
	Size     int64
}

Conversation is a stored conversation that can be resumed.

func All

func All(specs []agent.Spec, cwd string) ([]Conversation, error)

All lists the stored conversations of every given agent for a working directory, most recently used first, each labelled with the agent that held it.

The error is the first an agent reported, and it comes back beside whatever the others found: one agent whose store cannot be read is a thing to say, not a reason to tell somebody that the conversations they know they had are gone.

type Detail added in v0.3.8

type Detail struct {
	Text    string  `json:"text,omitempty"`
	Diff    string  `json:"diff,omitempty"`
	Entries []Entry `json:"entries,omitempty"`
	// Data is an image entry's bytes, base64, in the entry's own mediaType --
	// never sent inline on the entry itself, so a page listing several
	// pictures stays small until one is actually drawn.
	Data string `json:"data,omitempty"`
}

Detail is the full body of an entry that arrived trimmed: a tool's full output or diff, a thinking block's text, a subagent's own transcript, or an image's own bytes.

type EditPair added in v0.3.9

type EditPair struct {
	OldString string
	NewString string
}

EditPair is one edit's old and new text, as MultiEdit's own input carries several of them for one file.

type Entry added in v0.3.8

type Entry struct {
	ID   string `json:"id"`
	Kind string `json:"kind"`
	// TS is RFC 3339, already formatted: adapters read a timestamp once and
	// hand it over as the wire wants it, rather than every caller downstream
	// converting it again.
	TS string `json:"ts"`

	// prompt.text, notice.text
	Text string `json:"text,omitempty"`
	// reply.markdown
	Markdown string `json:"markdown,omitempty"`
	// thinking.chars, thinking.seconds
	Chars   int  `json:"chars,omitempty"`
	Seconds *int `json:"seconds,omitempty"`

	// tool.name, tool.label, tool.status, tool.summary, tool.diff, tool.hasDetail
	// subagent.status, subagent.hasDetail (subagent.description, subagent.report below)
	Name      string `json:"name,omitempty"`
	Label     string `json:"label,omitempty"`
	Status    string `json:"status,omitempty"`
	Summary   string `json:"summary,omitempty"`
	Diff      string `json:"diff,omitempty"`
	HasDetail bool   `json:"hasDetail,omitempty"`

	// subagent.description, subagent.report
	Description string `json:"description,omitempty"`
	Report      string `json:"report,omitempty"`

	// compaction.turns
	Turns *int `json:"turns,omitempty"`

	// image.mediaType, image.bytes, image.width, image.height (image.hasDetail
	// is the shared HasDetail field above, and is always true for this kind).
	MediaType string `json:"mediaType,omitempty"`
	Bytes     int    `json:"bytes,omitempty"`
	Width     int    `json:"width,omitempty"`
	Height    int    `json:"height,omitempty"`
}

Entry is one agent-agnostic event out of a conversation: a prompt, a reply, a tool call, and the rest of the kinds the phone's chat view draws. It is the shape every adapter translates its own format into, and the shape the desktop-to-phone protocol carries -- see docs/plans/phone-conversation-view.md.

Fields are flat and named the same across kinds that share a name (both prompt and notice carry "text"), rather than nested under a kind-named object, matching the wire contract.

type Null

type Null struct{}

Null is the reader for an agent that records nothing Flockdeck can read.

It answers every question with "there is none", which is the answer each caller already has to cope with: a Claude pane that has not been prompted yet has no transcript either, so nothing downstream is new code.

func (Null) Conversations

func (Null) Conversations(agent.Spec, string) ([]Conversation, error)

func (Null) Path

func (Null) Path(agent.Spec, string) string

func (Null) Replies

func (Null) Replies(agent.Spec, string, int) []string

type Reader

type Reader interface {
	Path(spec agent.Spec, sessionID string) string // "" when unknown
	Replies(spec agent.Spec, sessionID string, n int) []string
	Conversations(spec agent.Spec, cwd string) ([]Conversation, error)
}

Reader finds and reads one agent's stored conversations.

func For

func For(spec agent.Spec) Reader

For returns the reader for an agent.

An agent that does not record what it said, or records it somewhere nobody here knows how to read, gets the null reader rather than a guess. Inventing a path for it would be worse than admitting there is none: a fan-out would draw its plan from a file that is not the conversation, and a restored pane would be told to resume something that is not there and die on the spot.

type Stream added in v0.3.8

type Stream interface {
	// Refresh reads whatever is new since the last call, and returns every
	// entry that is new or was updated in place (a tool call whose result
	// just arrived), oldest first.
	Refresh() []Entry
	// Snapshot returns every entry seen so far, oldest first. The slice is
	// the Stream's own and must not be modified.
	Snapshot() []Entry
	// Detail returns the full body of an entry that arrived trimmed: a tool's
	// full output, a thinking block's text, an oversized diff, or a
	// subagent's own transcript, addressed by the subagent tool's entry id.
	Detail(id string) (Detail, bool)
	// Reset reports whether the conversation was replaced in place since this
	// was last asked -- true once, the first time it is asked after the
	// replacement, then false again until another happens. This is for an
	// agent whose own /clear (or equivalent) keeps the same session id and
	// file rather than starting a new one, the way Flockdeck's own chat client's
	// does: Claude Code needs nothing here, because its /clear is already
	// caught by the session id changing under it (see
	// internal/server/conversation.go's refreshConversation), so its Stream
	// always answers false.
	Reset() bool

	// SetLight switches the stream between its two memory modes. Light
	// (true) is for a pane no client has open: Refresh still tails the file
	// and still returns every entry that is new or changed, so a caller
	// reading only the reply text off that return value (the inbox preview)
	// keeps working exactly as before, but nothing is retained -- there is
	// no whole conversation sitting in memory just to show 140 characters of
	// it. Full (false) is what a client's chat view needs: every entry seen
	// kept for paging and detail. Switching from light to full discards
	// whatever light mode did not keep and re-reads the transcript from the
	// start on the next Refresh, so a pane's first open after a stretch of
	// being unwatched still shows its whole history, not only what arrived
	// since. Calling SetLight with the mode it is already in is a no-op.
	SetLight(light bool)

	// EntryCount reports how many entries the stream currently retains --
	// zero for one in light mode, which is the point.
	EntryCount() int
}

Stream is a live, tailing view onto one agent's conversation, translating its own transcript format into Entry as new lines are written.

A Stream holds everything it has read so far -- entries are small, trimmed events, not raw transcript lines, so keeping the whole conversation in memory for as long as a pane's chat view might be open costs little next to the file itself. Paging (newest page, older, since-a-cursor) is done by the caller over Snapshot's slice; the Stream's own job is only turning bytes into Entry values and answering for the ones that arrived trimmed.

func StreamFor added in v0.3.8

func StreamFor(spec agent.Spec, sessionID string) (Stream, bool)

StreamFor returns a live Stream for a pane's conversation, or ok=false when the agent has no adapter for the phone's chat view.

type Streamer added in v0.3.8

type Streamer interface {
	Stream(spec agent.Spec, sessionID string) (Stream, bool)
}

Streamer is a Reader that can also tail its agent's conversation live. Only an agent verified against the real tool implements it; every other agent's Reader does not, and StreamFor answers false for it, which is what the phone shows as "no chat view for this pane, only the terminal."

Jump to

Keyboard shortcuts

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