render

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 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 render turns mail into the text a Claude session sees: a small batch in full, a large one as a digest of one line per message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batch

func Batch(to, owner string, msgs []Mail, maxMsgs, maxBytes int) string

Batch renders msgs for the endpoint named to, of owner: in full when there are at most maxMsgs and their bodies total at most maxBytes, otherwise as a digest. The first line is a short summary of the count and the senders, since Claude Code shows it as the terminal line after its own "← mash:".

func HookBatch added in v0.3.2

func HookBatch(to, owner string, msgs []Mail, maxMsgs, maxBytes int) string

HookBatch is Batch for the hook, whose digest says plainly that a listed message stays unread until the model reads it with the read tool (ADR 0046). A batch shown in full is the same as Batch's.

func IsDigest added in v0.3.2

func IsDigest(msgs []Mail, maxMsgs, maxBytes int) bool

IsDigest reports whether Batch and HookBatch render msgs as a digest, not in full.

func Line

func Line(m Mail) string

Line renders a message as one line: seq, sender, time, size, first line, kind.

func Num added in v0.4.0

func Num(stream string, seq uint64) string

Num is the text of a message number: "5" for the primary stream (Stream empty). A message of any other stream has no short form and is written "<stream>:<seq>", for a log line.

func One

func One(m Mail) string

One renders a message in full; the body is quoted.

func Plain added in v0.5.6

func Plain(b []byte) string

Plain is a message body safe to print as it is: valid UTF-8, every kind of line break as "\n", and every other control character shown as a visible \xNN escape.

func Preview added in v0.5.6

func Preview(b []byte) string

Preview is the first line of a body that is not blank, trimmed, safe to print (see Plain), whole: the caller cuts it.

func Quote added in v0.5.6

func Quote(b []byte) string

Quote is the body quoting of a message, for other text of a sender's that mash shows: every line, an empty one too, starts with "> ", and control characters are escaped.

func Sender

func Sender(owner string, m Mail) string

Sender is the one place a sender's name is shown, for a receiver of owner, by the sender's endpoint name:

  • a three-token sender: agent.owner.name, whatever its owner;
  • a sender whose owner is unknown (not in the directory): the name alone;
  • another owner than the receiver's: owner/name (devops/nats-ops);
  • otherwise: the name as is.

Types

type Mail

type Mail struct {
	Seq uint64
	// Stream names the stream Seq is a sequence of; empty for the endpoint's own (primary) stream, whose numbers are
	// shown bare. It is part of the message's identity (with Seq).
	Stream string
	From   string
	// Instance is the sender's verified instance id; empty when it sent none
	// or the binding did not verify.
	Instance string
	Trust    sap.Trust
	At       time.Time
	Body     []byte
	// Owner is the sender's owner (its directory record's owner); empty when the directory does not know it.
	Owner string
	// Urgent is a verified sender's signed urgent mark.
	Urgent bool
	// Kind is the sender's kind (blocker, question, task, result, fyi); the zero value reads as task.
	Kind kind.Kind
	// ReplyTo is the #seq the sender says this answers, only when its signature on it verified; 0 otherwise.
	ReplyTo uint64
	// Via is "<origin> #<seq>": the sender's signed declaration that this relays or quotes that message of its own
	// inbox, only when it verified; empty otherwise. Neither mark changes the trust label.
	Via string
	// Redelivered: a hook began to show this message and was interrupted, so it may already have been seen.
	Redelivered bool
}

Mail is one message as delivered.

func (Mail) Num added in v0.4.0

func (m Mail) Num() string

Num is the message's number as shown: "5".

Jump to

Keyboard shortcuts

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