msgconv

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendUIMessageArtifacts

func AppendUIMessageArtifacts(uiMessage map[string]any, sourceParts, fileParts []map[string]any) map[string]any

AppendUIMessageArtifacts appends source/file parts to an existing UIMessage.

func BuildPlainMessageContent

func BuildPlainMessageContent(p PlainMessageContentParams) *event.Content

BuildPlainMessageContent builds event content for a plain assistant text message.

func BuildUIMessage

func BuildUIMessage(p UIMessageParams) map[string]any

BuildUIMessage builds the complete com.beeper.ai UIMessage payload.

func BuildUIMessageMetadata

func BuildUIMessageMetadata(p UIMessageMetadataParams) map[string]any

BuildUIMessageMetadata builds the metadata map for a com.beeper.ai UIMessage.

func ContentParts

func ContentParts(textContent, reasoningContent string) []map[string]any

ContentParts builds the standard text + reasoning parts for a UIMessage.

func ConvertAIResponse

func ConvertAIResponse(p AIResponseParams) (*bridgev2.ConvertedMessage, error)

ConvertAIResponse converts AI response parameters into a bridgev2 ConvertedMessage. This is the shared conversion path for non-streaming final messages.

func MapFinishReason

func MapFinishReason(reason string) string

MapFinishReason normalizes provider-specific finish reasons to standard values.

func MergeUIMessageMetadata

func MergeUIMessageMetadata(base, update map[string]any) map[string]any

MergeUIMessageMetadata deep-merges message-level metadata maps.

func RelatesToReplace

func RelatesToReplace(initialEventID id.EventID, replyTo id.EventID) map[string]any

RelatesToReplace builds a m.relates_to payload for an edit (m.replace) event.

func RelatesToThread

func RelatesToThread(threadRoot id.EventID, replyTo id.EventID) map[string]any

RelatesToThread builds a m.relates_to payload for threading with fallback reply.

func ToolCallPart

func ToolCallPart(tc bridgeadapter.ToolCallMetadata, providerToolType string, successStatus, deniedStatus string) map[string]any

ToolCallPart builds a single AI SDK UIMessage dynamic-tool part from tool call metadata.

func ToolCallParts

func ToolCallParts(toolCalls []bridgeadapter.ToolCallMetadata, providerToolType, successStatus, deniedStatus string) []map[string]any

ToolCallParts builds AI SDK UIMessage dynamic-tool parts from a list of tool call metadata.

Types

type AIResponseParams

type AIResponseParams struct {
	Content          string
	FormattedContent string
	ReplyToEventID   id.EventID
	Metadata         UIMessageMetadataParams
	ThinkingContent  string
	ToolCalls        []bridgeadapter.ToolCallMetadata
	PortalModel      string // Fallback model from portal metadata

	// Tool type constants from the connector package
	ProviderToolType string
	SuccessStatus    string
	DeniedStatus     string

	// DB metadata to attach
	DBMetadata any
}

AIResponseParams contains parameters for converting an AI response to a ConvertedMessage. Used by both OpenAIRemoteMessage.ConvertMessage and new AIRemoteMessage types.

type PlainMessageContentParams

type PlainMessageContentParams struct {
	Text         string
	RelatesTo    map[string]any
	UIMessage    map[string]any
	LinkPreviews []map[string]any
}

PlainMessageContentParams contains parameters for building a plain text message.

type UIMessageMetadataParams

type UIMessageMetadataParams struct {
	TurnID           string
	AgentID          string
	Model            string
	FinishReason     string
	CompletionID     string
	PromptTokens     int64
	CompletionTokens int64
	ReasoningTokens  int64
	TotalTokens      int64
	StartedAtMs      int64
	FirstTokenAtMs   int64
	CompletedAtMs    int64
	IncludeUsage     bool
}

UIMessageMetadataParams contains parameters for building UI message metadata.

type UIMessageParams

type UIMessageParams struct {
	TurnID     string
	Role       string // "assistant", "user"
	Metadata   map[string]any
	Parts      []map[string]any
	SourceURLs []map[string]any // Optional source-url and source-document parts
	FileParts  []map[string]any // Optional generated file parts
}

UIMessageParams contains parameters for building a full com.beeper.ai UIMessage.

Jump to

Keyboard shortcuts

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