turns

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const MaxMatrixEventBodyBytes = 60000

Variables

View Source
var (
	ErrClosed          = errors.New("stream session closed")
	ErrNoPublisher     = errors.New("stream session has no publisher")
	ErrNoRoomID        = errors.New("stream session has no room id")
	ErrNoTargetEventID = errors.New("stream session has no target event id")
)

Functions

func BuildConvertedEdit

func BuildConvertedEdit(content *event.MessageEventContent, topLevelExtra map[string]any) *bridgev2.ConvertedEdit

BuildConvertedEdit wraps a message content payload into a single-part Matrix edit.

func EnsureDontRenderEdited

func EnsureDontRenderEdited(edit *bridgev2.ConvertedEdit)

EnsureDontRenderEdited marks every edit part so clients can suppress "edited" UI chrome.

func ResolveTargetEventIDFromDB

func ResolveTargetEventIDFromDB(
	ctx context.Context,
	bridge *bridgev2.Bridge,
	receiver networkid.UserLoginID,
	target StreamTarget,
) (id.EventID, error)

func SplitAtMarkdownBoundary

func SplitAtMarkdownBoundary(text string, maxBytes int) (string, string)

SplitAtMarkdownBoundary splits text at a paragraph/line boundary near maxBytes. Returns (first, rest). If text fits, rest is empty.

Types

type EndReason

type EndReason string
const (
	EndReasonFinish     EndReason = "finish"
	EndReasonDisconnect EndReason = "disconnect"
	EndReasonError      EndReason = "error"
)

type StreamSession

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

func NewStreamSession

func NewStreamSession(params StreamSessionParams) *StreamSession

func (*StreamSession) Descriptor

func (s *StreamSession) Descriptor(ctx context.Context) (*event.BeeperStreamInfo, error)

func (*StreamSession) EmitPart

func (s *StreamSession) EmitPart(ctx context.Context, part map[string]any)

func (*StreamSession) End

func (s *StreamSession) End(ctx context.Context, _ EndReason)

func (*StreamSession) EnsureStarted

func (s *StreamSession) EnsureStarted(ctx context.Context) (bool, error)

func (*StreamSession) FlushPending

func (s *StreamSession) FlushPending(ctx context.Context) error

func (*StreamSession) IsClosed

func (s *StreamSession) IsClosed() bool

func (*StreamSession) Start

func (s *StreamSession) Start(ctx context.Context, targetEventID id.EventID) error

type StreamSessionParams

type StreamSessionParams struct {
	TurnID  string
	AgentID string

	GetStreamTarget      func() StreamTarget
	ResolveTargetEventID TargetEventResolver
	GetTargetEventID     func() id.EventID
	GetRoomID            func() id.RoomID
	GetSuppressSend      func() bool
	GetStreamType        func() string
	NextSeq              func() int

	GetStreamPublisher func(ctx context.Context) (bridgev2.BeeperStreamPublisher, bool)
	ClearTurnGate      func()
	SendHook           func(turnID string, seq int, content map[string]any, txnID string) bool
	Logger             *zerolog.Logger
}

type StreamTarget

type StreamTarget struct {
	NetworkMessageID networkid.MessageID
	PartID           networkid.PartID
}

StreamTarget identifies a bridgev2 message target using bridge-side message identity. Matrix event IDs are resolved from bridge DB rows when needed for Matrix-native relations.

func (StreamTarget) HasEditTarget

func (t StreamTarget) HasEditTarget() bool

type TargetEventResolver

type TargetEventResolver func(ctx context.Context, target StreamTarget) (id.EventID, error)

Jump to

Keyboard shortcuts

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