streamtransport

package
v0.0.0-...-f0e47c8 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxMatrixEventBodyBytes = 60000

Variables

This section is empty.

Functions

func BuildConvertedEdit

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

BuildConvertedEdit wraps rendered message content into a standard Matrix edit. The bridge layer will derive the Matrix edit fallback fields from Content via SetEdit, so TopLevelExtra should only contain custom top-level fields.

func BuildRenderedConvertedEdit

func BuildRenderedConvertedEdit(rendered RenderedMarkdownContent, topLevelExtra map[string]any) *bridgev2.ConvertedEdit

func EmitStreamEvent

func EmitStreamEvent(ctx context.Context, portal *bridgev2.Portal, state StreamEventState, part map[string]any)

EmitStreamEvent logs the stream start once and emits a part through a session.

func EmitStreamEventWithSession

func EmitStreamEventWithSession(
	ctx context.Context,
	portal *bridgev2.Portal,
	turnID string,
	suppressSend bool,
	loggedStart *bool,
	logger *zerolog.Logger,
	ensureSession func() *StreamSession,
	part map[string]any,
)

EmitStreamEventWithSession is a convenience wrapper for callers that only need to provide the common stream state fields.

func EnsureDontRenderEdited

func EnsureDontRenderEdited(edit *bridgev2.ConvertedEdit)

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

func ShouldFallbackToDebounced

func ShouldFallbackToDebounced(err error) bool

ShouldFallbackToDebounced returns true when an ephemeral stream send failure looks like server/client unsupported behavior (unknown/unrecognized/etc).

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 DebouncedEditContent

type DebouncedEditContent struct {
	Body          string
	FormattedBody string
	Format        event.Format
}

DebouncedEditContent is the rendered content for a debounced streaming edit.

func BuildDebouncedEditContent

func BuildDebouncedEditContent(p DebouncedEditParams) *DebouncedEditContent

BuildDebouncedEditContent validates inputs and renders the edit content. Returns nil if the edit should be skipped.

type DebouncedEditParams

type DebouncedEditParams struct {
	PortalMXID   string
	Force        bool
	SuppressSend bool
	VisibleBody  string
	FallbackBody string
}

DebouncedEditParams holds the inputs needed by BuildDebouncedEditContent.

type EndReason

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

type RenderedMarkdownContent

type RenderedMarkdownContent struct {
	Body          string
	Format        event.Format
	FormattedBody string
}

type StreamEventState

type StreamEventState struct {
	TurnID        string
	SuppressSend  bool
	LoggedStart   *bool
	EnsureSession func() *StreamSession
	Logger        *zerolog.Logger
}

type StreamSession

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

func NewStreamSession

func NewStreamSession(params StreamSessionParams) *StreamSession

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) IsClosed

func (s *StreamSession) IsClosed() bool

type StreamSessionParams

type StreamSessionParams struct {
	TurnID  string
	AgentID string

	GetTargetEventID func() string
	GetRoomID        func() id.RoomID
	GetSuppressSend  func() bool
	NextSeq          func() int

	RuntimeFallbackFlag *atomic.Bool
	GetEphemeralSender  func(ctx context.Context) (bridgev2.EphemeralSendingMatrixAPI, bool)
	SendDebouncedEdit   func(ctx context.Context, force bool) error
	ClearTurnGate       func()
	SendHook            func(turnID string, seq int, content map[string]any, txnID string) bool
	Logger              *zerolog.Logger
}

Jump to

Keyboard shortcuts

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