envelope

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT 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 envelope defines the immutable message envelope (RFC 5.1) and the limits checked at ingress.

Index

Constants

View Source
const (
	MaxBody            = 32 << 10
	MaxData            = 64 << 10
	MaxAttachment      = 25 << 20
	MaxAttachmentTotal = 100 << 20
	MaxSubject         = 512
	MaxSummary         = 280
)

Limits from RFC 5.1.

View Source
const (
	OriginInteractive = "interactive"
	OriginWorker      = "worker"
	OriginCLI         = "cli"
	OriginHuman       = "human"
	OriginDaemon      = "daemon"
)

Origins of a message (RFC 4.5).

Variables

This section is empty.

Functions

func NewID

func NewID() string

NewID mints a ULID.

func SanitizeName

func SanitizeName(n string) string

SanitizeName turns any string into a safe file name.

func Short

func Short(id string) string

Short returns the last 8 chars of a ULID, used in branch names.

func ValidName

func ValidName(n string) error

ValidName rejects attachment names that could escape a directory.

Types

type Attachment

type Attachment struct {
	Name   string `json:"name"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
	MIME   string `json:"mime"`
}

Attachment is a content-addressed blob reference.

type Draft

type Draft struct {
	To          string          `json:"to"`
	Kind        string          `json:"kind"`
	Intent      string          `json:"intent"`
	Priority    string          `json:"priority,omitempty"`
	Subject     string          `json:"subject"`
	Body        string          `json:"body,omitempty"`
	Data        json.RawMessage `json:"data,omitempty"`
	Attachments []Attachment    `json:"attachments,omitempty"`
	DedupeKey   string          `json:"dedupe_key,omitempty"`
	Deadline    *time.Time      `json:"deadline,omitempty"`
	ThreadID    string          `json:"thread_id,omitempty"`
}

Draft is what a client submits. It has no id, thread, sender or hop: those are minted or stamped by the daemon.

func (*Draft) Validate

func (d *Draft) Validate() error

Validate checks a draft against RFC 5.1 limits.

type Envelope

type Envelope struct {
	ID          string          `json:"id"`
	ThreadID    string          `json:"thread_id"`
	ParentID    *string         `json:"parent_id"`
	From        From            `json:"from"`
	To          string          `json:"to"`
	Kind        string          `json:"kind"`
	Intent      string          `json:"intent"`
	Priority    string          `json:"priority"`
	Subject     string          `json:"subject"`
	Body        string          `json:"body"`
	Data        json.RawMessage `json:"data,omitempty"`
	Attachments []Attachment    `json:"attachments,omitempty"`
	DedupeKey   string          `json:"dedupe_key,omitempty"`
	Hop         int             `json:"hop"`
	Deadline    *time.Time      `json:"deadline,omitempty"`
	CreatedAt   time.Time       `json:"created_at"`
	// Status is set on replies: "ok", "timeout", "rejected", "failed".
	Status string `json:"status,omitempty"`
}

Envelope is the message as stored and handed to handlers.

type From

type From struct {
	Agent  string `json:"agent"`
	Origin string `json:"origin"`
	RunID  string `json:"run_id,omitempty"`
}

From is stamped by the daemon from the authenticated connection.

Jump to

Keyboard shortcuts

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