message

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 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 message holds the subjects of the question, post and proposal gates: a turn's question, an agent's post, a proposal. The gate holds the decision; a message keeps what was asked and the answer as stored.

Index

Constants

View Source
const (
	OriginTurn     = "turn"
	OriginAgent    = "agent"
	OriginLedger   = "ledger"
	OriginCore     = "core"
	OriginWorkflow = "workflow"
)

The kinds of an Origin.

View Source
const TextMax = 4000

TextMax bounds a message's text in bytes.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conversation added in v0.3.0

type Conversation struct {
	Message Message
	Answers []turn.Answer
}

Conversation is an Inbox message and the user's answers to it, oldest first. Message is zero for the answers of a turn stored before each answer named its message.

type Kind

type Kind string // question (end of turn), agent_post (task_post), proposal (ledger proposals, workflow decisions; never for a draft)
const (
	Question  Kind = "question"
	AgentPost Kind = "agent_post"
	Proposal  Kind = "proposal"
)

func (Kind) Gate added in v0.3.0

func (k Kind) Gate() gate.Kind

Gate is the kind of the gate a message of kind k is the subject of.

type Message

type Message struct {
	ID        int64
	TaskID    string    // the task its gate is on
	Unit      unit.Unit // zero for a message on no unit
	Kind      Kind
	Text      string // <= 4000 bytes, no control characters
	Options   []record.Option
	Recommend string
	Confirm   bool // a yes/no question
	// Draft is the held draft a confirm's yes approves, at the rev the question pinned; nil for none.
	Draft  *record.DraftRef
	Origin Origin
	Answer string // the answer as stored, one line

	// ClosedAt is when its gate closed, zero while it is open.
	CreatedAt, ClosedAt time.Time
}

func (Message) Open added in v0.3.0

func (m Message) Open() bool

Open says whether m is open: its gate waits on the user.

type Origin

type Origin struct {
	Kind     string // turn, agent, ledger, core, workflow
	TurnSeq  int64  // 0 when no turn
	Session  string
	Workflow string // workflow or core rule name
	Proposal int64  // Kind ledger: the items.Proposal id
}

type Store

type Store interface {
	// Upsert keys a question by (Unit, Origin.Kind, Origin.TurnSeq), a ledger proposal by Origin.Proposal,
	// a workflow or core proposal by (Unit, Origin.Workflow) while open.
	Upsert(ctx context.Context, m Message) (Message, error)
	Message(ctx context.Context, id int64) (Message, bool, error)
	Open(ctx context.Context) ([]Message, error)
	// Close closes an open message with answer at at; on one closed with an answer, a new answer rewords it.
	Close(ctx context.Context, id int64, answer string, at time.Time) error
}

Jump to

Keyboard shortcuts

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