relay

package
v0.84.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 8 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 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

View Source
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

func AgentName

func AgentName(agent string) string

AgentName is how the brief and the dialog name an agent.

func Clip

func Clip(s string, n int) string

Clip cuts to n runes at a sentence boundary where one is near the end, so a passage does not stop mid-word. The SessionStart handoff uses it too.

func HumanAge

func HumanAge(d time.Duration) string

HumanAge is the coarse form a person reads: minutes, hours, or days. The SessionStart handoff uses it too.

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.

func Build

func Build(ctx context.Context, q store.Querier, sess store.Session, now time.Time) (Brief, error)

Build assembles the brief for a session. Nothing leaves the machine: the passage and the PRs are rows Caprock holds, and the diff is a local git call.

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

type PR struct {
	Number int    `json:"number"`
	URL    string `json:"url"`
}

PR is one pull request a session opened.

func PullRequests

func PullRequests(ctx context.Context, q store.Querier, sessionID string) ([]PR, error)

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.

Jump to

Keyboard shortcuts

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