peermsg

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 19 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

Index

Constants

View Source
const (
	ProtocolVersion = 1
)

Variables

This section is empty.

Functions

func DefaultRoot

func DefaultRoot() (string, error)

func WithInboundMessage

func WithInboundMessage(ctx context.Context, message InboundMessage) context.Context

WithInboundMessage carries a peer message's relay chain through the agent turn so a deliberate send_message reply or forward can extend it. Ordinary user turns have no chain and start a fresh one.

Types

type DeliveryStatus

type DeliveryStatus string
const (
	DeliveryAccepted  DeliveryStatus = "accepted"
	DeliveryHeld      DeliveryStatus = "held"
	DeliveryRefused   DeliveryStatus = "refused"
	DeliveryDelivered DeliveryStatus = "delivered"
	DeliveryDenied    DeliveryStatus = "denied"
	DeliveryExpired   DeliveryStatus = "expired"
)

type Handler

type Handler func(InboundMessage) bool

type HeldEvictionHandler

type HeldEvictionHandler func(string)

type HeldReleaseHandler

type HeldReleaseHandler func(InboundMessage)

type HoldCause

type HoldCause string
const (
	HoldCauseModeMismatch HoldCause = "mode-mismatch"
	HoldCauseExplicit     HoldCause = "explicit-setting"
	HoldCauseModeUnknown  HoldCause = "mode-unknown"
)

type Identity

type Identity struct {
	SessionID       string          `json:"sessionId,omitempty"`
	Name            string          `json:"name,omitempty"`
	Cwd             string          `json:"cwd,omitempty"`
	PermissionClass PermissionClass `json:"permissionClass"`
}

Identity is the model-independent identity published by one live Zero process. SessionID and Name are updated when the TUI creates, resumes, or renames its active session.

type InboundMessage

type InboundMessage struct {
	ID               string
	From             Peer
	Body             string
	Summary          string
	ReceivedAt       time.Time
	RequiresApproval bool
	HoldCause        HoldCause
	HopChain         []string
}

InboundMessage is delivered to the receiving application. RequiresApproval is true when local policy requires the user to approve delivery.

type InboundPolicy

type InboundPolicy string
const (
	InboundPolicyParity InboundPolicy = ""
	InboundPolicyAccept InboundPolicy = "accept"
	InboundPolicyHold   InboundPolicy = "hold"
	InboundPolicyRefuse InboundPolicy = "refuse"
)

type Options

type Options struct {
	RootDir       string
	Identity      Identity
	Now           func() time.Time
	Transport     localTransport
	PID           int
	InboundPolicy InboundPolicy
}

type Peer

type Peer struct {
	Identity
	Endpoint  string    `json:"endpoint"`
	PID       int       `json:"pid"`
	StartedAt time.Time `json:"startedAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Ref       string    `json:"ref"`
}

Peer is one reachable local Zero session.

type PermissionClass

type PermissionClass string
const (
	PermissionPrompting PermissionClass = "prompting"
	PermissionBypass    PermissionClass = "bypass"
)

type SendResult

type SendResult struct {
	MessageID string
	Peer      Peer
	Status    DeliveryStatus
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service owns one live peer endpoint plus the registry used to discover other local Zero sessions. The transport is platform-specific, while framing, identity resolution, limits, and delivery policy remain shared.

func New

func New(options Options) (*Service, error)

func (*Service) Close

func (service *Service) Close() error

func (*Service) List

func (service *Service) List(ctx context.Context) ([]Peer, error)

func (*Service) ResolveHeld

func (service *Service) ResolveHeld(ctx context.Context, messageID string, status DeliveryStatus) error

ResolveHeld settles a message that was parked for local approval and sends a terminal receipt back to its sender. Repeated or stale decisions are ignored.

func (*Service) Self

func (service *Service) Self() Peer

func (*Service) Send

func (service *Service) Send(ctx context.Context, to, summary, body string) (SendResult, error)

func (*Service) SetHeldEvictionHandler

func (service *Service) SetHeldEvictionHandler(handler HeldEvictionHandler)

func (*Service) SetHeldReleaseHandler

func (service *Service) SetHeldReleaseHandler(handler HeldReleaseHandler)

func (*Service) SetStatusHandler

func (service *Service) SetStatusHandler(handler StatusHandler)

func (*Service) Start

func (service *Service) Start(handler Handler) error

func (*Service) UpdateIdentity

func (service *Service) UpdateIdentity(identity Identity) error

type StatusEvent

type StatusEvent struct {
	MessageID string
	Peer      Peer
	Status    DeliveryStatus
}

type StatusHandler

type StatusHandler func(StatusEvent)

Jump to

Keyboard shortcuts

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