Documentation
¶
Overview ¶
Package relay builds the brief that carries a session's work into a new session, possibly in another agent.
A relay is not a continuation: the new session does not have the old one's conversation, only what this brief tells it. So the brief is built from what Caprock already holds, locally, and shown to the user to read and edit before it is sent — it is the user's first message, not something slipped in.
What goes in, and why:
- The last substantial passage the session's agent wrote. Recency, not a search: measured for the SessionStart handoff (internal/daemon/handoff.go) on the owner's database, the last passage answered "where were we" in 12 of 19 cases against 4 of 15 for a term search. A relay asks the same question.
- The state of the working tree, from the same diff the Diff panel shows (internal/gitdiff): the branch, what it changed since the trunk, and what is still uncommitted. This is now, not what the session saw — the files are the ground truth the new session will work on.
- The pull requests the session opened, from Claude Code's own record of them (the `gitOperation.pr` it attaches to a Bash result). Other agents do not record one, so their PRs are not listed rather than guessed from command text.
Index ¶
Constants ¶
const ( // PassageMaxRunes bounds the passage. Longer than the SessionStart // handoff's 1200, because here the user reads it first and can cut it, // and the passage is most of what the new session knows. PassageMaxRunes = 2400 // PassageMinRunes is the floor for a passage worth relaying, the same as // the handoff's: "Done." says nothing about where the work stood. When // the session never wrote one that long, its last passage is used anyway. PassageMinRunes = 400 // MaxFiles is how many changed files are listed by name. MaxFiles = 25 // MaxPromptRunes is the largest brief a spawn accepts, edits included. MaxPromptRunes = 8000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Brief ¶
type Brief struct {
SessionID string `json:"session_id"`
Agent string `json:"agent"`
Cwd string `json:"cwd"`
// CwdExists is false when the folder is gone; the new session then has
// nowhere to start.
CwdExists bool `json:"cwd_exists"`
// PassageAt is when the relayed passage was written (unix ms), 0 when the
// session left none.
PassageAt int64 `json:"passage_at,omitempty"`
Git *Git `json:"git,omitempty"`
PRs []PR `json:"prs"`
Text string `json:"text"`
}
Brief is everything the relay dialog shows, and the text it proposes.
type Git ¶
type Git struct {
Branch string `json:"branch,omitempty"`
// Base is what the changes are measured against ("since master"), empty
// for HEAD.
Base string `json:"base,omitempty"`
Files []string `json:"files"`
More int `json:"more,omitempty"`
Stat string `json:"stat,omitempty"`
NotRepo bool `json:"not_repo,omitempty"`
}
Git is the summary of the working tree.
type PR ¶
PR is one pull request a session opened.
func PullRequests ¶
PullRequests lists the PRs a session opened, oldest first, from Claude Code's own record on its Bash results (`tool_response.gitOperation.pr`, action "created"). Subagents' are included: the session opened them too.