Documentation
¶
Overview ¶
Package convert renders a conversation read from one agent for another agent's writer: what the receiving agent should see (its own words and the user's as messages, the other agent's tool activity as clearly labelled text), within a budget, with a report of everything left out and a briefing at the end. Brief renders a briefing alone, for a target hopsesh cannot write to (a cloud session's first prompt). It never calls a model.
Index ¶
- Constants
- func Archive(nodes []ir.Node, r Request) ([]byte, error)
- func BoundText(s string, limit int) string
- func HistoryFile(nodes []ir.Node, from, title string) (string, int)
- func MergeArchives(parts ...[]byte) ([]byte, error)
- type BriefProfile
- type BriefRequest
- type BriefResult
- type Briefing
- type Fidelity
- type Report
- type Request
- type Result
- type Rules
- type Tally
Constants ¶
BudgetShare is the share of the target's context the converted history may use.
const CloudBudget = 2000
CloudBudget is a cloud briefing's size, in tokens: about what a sub-agent hands back as a distilled summary.
const HistoryBudget = 240 << 10
HistoryBudget is the most a committed history file holds, in bytes: about 30% of a 200,000-token window. The newest part is kept.
Variables ¶
This section is empty.
Functions ¶
func Archive ¶ added in v0.4.0
Archive retains portable history independently of working-context limits. Vendor private state, signed reasoning and attachment bytes never cross this boundary.
func BoundText ¶ added in v0.4.0
BoundText includes its marker in the byte limit and never splits a UTF-8 sequence.
func HistoryFile ¶ added in v0.4.0
HistoryFile renders a conversation as the Markdown file a hand-off can commit (.hopsesh/handoff.md): the user's and the agent's messages, each tool call as one line (never its output), in a frame that says it is quoted history, not instructions, cut to HistoryBudget from the oldest end, with secrets masked. It returns the text and how many secrets were masked.
func MergeArchives ¶ added in v0.4.0
MergeArchives deduplicates immutable portable records by their encoded content. It preserves differing renderings rather than silently dropping fork evidence.
Types ¶
type BriefProfile ¶ added in v0.4.0
type BriefProfile string
BriefProfile is what a briefing is for.
const ( // BriefContinue is the briefing a continuation in another agent ends with: what // Render writes with Fidelity Note. BriefContinue BriefProfile = "continue" // BriefCloud is the first prompt of a cloud session, all the cloud agent learns of the // conversation: within CloudBudget tokens, its quoted history framed as data, what // stayed on the machine, and secrets masked. BriefCloud BriefProfile = "cloud" )
type BriefRequest ¶ added in v0.4.0
type BriefRequest struct {
Profile BriefProfile
From string // the source agent's name ("Claude Code")
To string // the target agent's name ("Codex")
Briefing Briefing
}
BriefRequest is a briefing for a target hopsesh cannot write a session for.
type BriefResult ¶ added in v0.4.0
type BriefResult struct {
Text string `json:"text"`
Tokens int `json:"tokens"`
// Masked is how many secrets the scanner masked (cloud briefings).
Masked int `json:"masked,omitempty"`
// Shortened: parts were cut to fit the budget (cloud briefings).
Shortened bool `json:"shortened,omitempty"`
}
BriefResult is a rendered briefing.
func Brief ¶ added in v0.4.0
func Brief(nodes []ir.Node, r BriefRequest) BriefResult
Brief renders the briefing for nodes without a target writer. With BriefContinue it is the text Render puts in a continuation with Fidelity Note.
type Briefing ¶
type Briefing struct {
FromVersion string
SourceID string
SourceLoc string
TargetLoc string
TargetOS string
When time.Time
Branch string
Head string // the commit at transfer time
Dirty int
Plan []ir.PlanEntry
Missing []string // differences in instructions, skills, MCP servers
ToolNames string // the target's own tool names, to use instead of the history's
Note string // a handoff note the source agent wrote, if any
Rules []Rules // selected source instruction text, carried when asked
// For a cloud briefing (Brief with BriefCloud):
Title string // the session's title
Unpushed int // commits the cloud gets that were not on the remote
Withheld []string // files that stay on the machine (credential-like, or not chosen)
NotCarried []string // anything else the cloud does not get ("the user's personal CLAUDE.md")
HistoryFile string // the conversation committed on the branch (".hopsesh/handoff.md"), if it is
// Checkout: the cloud may start on another branch (its driver cannot choose one), so the
// briefing asks it to check out Branch of Repo (host/owner/repo) first.
Checkout bool
Repo string
}
Briefing is what the receiving agent is told at the end of the history.
type Report ¶
type Report struct {
Fidelity Fidelity `json:"fidelity"`
Method string `json:"method,omitempty"`
Capacity ir.Capacity `json:"capacity"`
Archive string `json:"archive,omitempty"`
BriefShortened bool `json:"briefShortened,omitempty"`
Blocked string `json:"blocked,omitempty"`
Budget int `json:"budgetTokens"`
Used int `json:"usedTokens"`
Messages int `json:"messages"`
ToolCalls int `json:"toolCalls"`
NativeCalls int `json:"nativeCalls,omitempty"`
Reasoning int `json:"reasoningDropped"`
Attachments int `json:"attachmentsAsPlaceholders,omitempty"`
Truncated int `json:"outputsShortened"`
Summarised int `json:"stepsSummarised"`
Redactions int `json:"redactions,omitempty"`
PathsMapped int `json:"pathsMapped"`
Summary string `json:"summary"`
}
Report is what a conversion keeps and leaves out.
func (Report) ContextSummary ¶ added in v0.4.0
ContextSummary exposes the same capacity evidence to text front ends, including vendor import plans whose conversion summary describes a different operation.
type Request ¶
type Request struct {
// IncludeGenerated carries a known cloud handoff briefing as context in a new session.
IncludeGenerated bool
Nodes []ir.Node
From string // the source agent's name ("Claude Code")
To string // the target agent's name ("Codex")
Fidelity Fidelity
Native bool // render exact tool calls natively (the target writer supports it)
Limit *int // optional remaining incoming allowance
Window int // the target's context, in tokens
Mappings []agent.Mapping // source paths → target paths
Briefing Briefing
Redact func([]byte) ([]byte, int)
}
Request is one rendering.