format

package
v2.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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 (
	// DictationPromptMaxChars keeps the prompt under OpenAI's limit of 1024
	// characters; a longer prompt fails the whole session.
	DictationPromptMaxChars = 1000
)

Variables

This section is empty.

Functions

func AgentList

func AgentList(agents []AgentInfo, currentBotUserID string) string

AgentList formats discovered agents as a numbered list for LLM-facing text. When currentBotUserID matches an agent's ID, a marker line is added for that row.

func AuthoredPost

func AuthoredPost(post *model.Post, username string) string

AuthoredPost formats a post body with the username of its author for LLM consumption.

func BuildPostIndex

func BuildPostIndex(posts []*model.Post) map[string]int

BuildPostIndex creates a map from post ID to its 1-based display index. Used to generate "(reply to Post N)" annotations.

func DictationUserName added in v2.14.0

func DictationUserName(user *model.User, showFullName bool) string

DictationUserName is the name people are likely to say: the full name when the server shows full names, else the nickname, else the username.

func MemberRole

func MemberRole(schemeAdmin, schemeGuest, schemeUser bool) string

MemberRole converts scheme booleans to a readable role string. Works for both channel and team members.

func PostBody

func PostBody(post *model.Post) string

func ThreadData

func ThreadData(data *mmapi.ThreadData) string

func TimeFromMillis added in v2.6.0

func TimeFromMillis(millis int64) string

TimeFromMillis formats a Unix-milliseconds timestamp as RFC3339 UTC for LLM consumption. Returns "" for non-positive values so callers/templates can omit the attribute when the timestamp is unknown.

func UnavailableAttachment added in v2.11.0

func UnavailableAttachment(name string, reason UnavailableAttachmentReason) string

UnavailableAttachment renders a placeholder for an attachment the model cannot see. A forbidden attachment is never named, so the model cannot reveal files the requesting user has no access to.

func WriteBookmark

func WriteBookmark(w *strings.Builder, entry BookmarkEntry)

WriteBookmark writes a formatted channel bookmark entry to the builder.

func WriteBot

func WriteBot(w *strings.Builder, entry BotEntry)

WriteBot writes a bot account's details to the builder.

func WriteCPAField

func WriteCPAField(w *strings.Builder, entry CPAFieldEntry)

WriteCPAField writes a Custom Profile Attribute field definition to the builder.

func WriteChannel

func WriteChannel(w *strings.Builder, entry ChannelEntry)

WriteChannel writes a formatted channel entry to the builder.

func WriteChannelMember

func WriteChannelMember(w *strings.Builder, entry ChannelMemberEntry)

WriteChannelMember writes a channel membership record (roles, mute, last-viewed).

func WriteChannelModerations

func WriteChannelModerations(w *strings.Builder, moderations []*model.ChannelModeration)

WriteChannelModerations writes a channel's moderation settings to the builder.

func WriteChannelStats

func WriteChannelStats(w *strings.Builder, stats *model.ChannelStats)

WriteChannelStats writes a channel's statistics to the builder.

func WriteChannelUnread

func WriteChannelUnread(w *strings.Builder, unread *model.ChannelUnread)

WriteChannelUnread writes a channel's unread counts to the builder.

func WriteCustomStatus

func WriteCustomStatus(w *strings.Builder, userID string, cs *model.CustomStatus)

WriteCustomStatus writes a user's custom status (emoji + text + expiry).

func WriteDraft added in v2.12.0

func WriteDraft(w *strings.Builder, entry DraftEntry)

WriteDraft writes a formatted draft entry to the builder.

func WriteEmoji

func WriteEmoji(w *strings.Builder, entry EmojiEntry)

WriteEmoji writes a formatted custom emoji entry to the builder.

func WriteFileDescriptor

func WriteFileDescriptor(w *strings.Builder, entry FileDescriptorEntry)

WriteFileDescriptor writes a compact file metadata descriptor to the builder.

func WriteGroup

func WriteGroup(w *strings.Builder, entry GroupEntry)

WriteGroup writes a group's metadata to the builder.

func WriteIncomingWebhook

func WriteIncomingWebhook(w *strings.Builder, entry IncomingWebhookEntry)

WriteIncomingWebhook writes an incoming webhook's details to the builder.

func WriteOutgoingWebhook

func WriteOutgoingWebhook(w *strings.Builder, entry OutgoingWebhookEntry)

WriteOutgoingWebhook writes an outgoing webhook's details to the builder.

func WritePost

func WritePost(w *strings.Builder, entry PostEntry)

FormatPost writes a single formatted post entry to the builder.

func WritePostInfo

func WritePostInfo(w *strings.Builder, entry PostInfoEntry)

WritePostInfo writes a post's channel/team context metadata to the builder.

func WriteReactions

func WriteReactions(w *strings.Builder, postID string, reactions []*model.Reaction, usernames map[string]string)

WriteReactions writes a post's emoji reactions grouped by emoji, with the reacting usernames, to the builder. usernames maps user IDs to usernames.

func WriteRole

func WriteRole(w *strings.Builder, entry RoleEntry)

WriteRole writes a role definition and its permissions to the builder.

func WriteScheduledPost

func WriteScheduledPost(w *strings.Builder, entry ScheduledPostEntry)

WriteScheduledPost writes a formatted scheduled post entry to the builder.

func WriteSidebarCategory

func WriteSidebarCategory(w *strings.Builder, entry SidebarCategoryEntry)

WriteSidebarCategory writes a sidebar category and its channel IDs to the builder.

func WriteStatus

func WriteStatus(w *strings.Builder, entry StatusEntry)

WriteStatus writes a user's presence status to the builder.

func WriteTeam

func WriteTeam(w *strings.Builder, entry TeamEntry)

WriteTeam writes a formatted team entry to the builder.

func WriteTeamMember

func WriteTeamMember(w *strings.Builder, entry TeamMemberEntry)

WriteTeamMember writes a team membership record (roles) to the builder.

func WriteTeamStats

func WriteTeamStats(w *strings.Builder, stats *model.TeamStats)

WriteTeamStats writes a team's member statistics to the builder.

func WriteTeamUnread

func WriteTeamUnread(w *strings.Builder, unread *model.TeamUnread)

WriteTeamUnread writes a single team's unread counts to the builder.

func WriteThreadSummary

func WriteThreadSummary(w *strings.Builder, entry ThreadSummaryEntry)

WriteThreadSummary writes a collated-thread summary to the builder.

func WriteUser

func WriteUser(w *strings.Builder, entry UserEntry)

WriteUser writes a formatted user entry to the builder.

Types

type AgentInfo

type AgentInfo struct {
	ID          string
	DisplayName string
	Username    string
}

AgentInfo holds display fields for formatting an AI agent list (e.g. MCP tool output).

type BookmarkEntry

type BookmarkEntry struct {
	HeaderLabel string
	Bookmark    *model.ChannelBookmarkWithFileInfo
}

BookmarkEntry holds data for formatting a single channel bookmark.

type BotEntry

type BotEntry struct {
	HeaderLabel string
	Bot         *model.Bot
}

BotEntry holds data for formatting a single bot account.

type CPAFieldEntry

type CPAFieldEntry struct {
	HeaderLabel string
	Field       *model.PropertyField
}

CPAFieldEntry holds data for formatting a single Custom Profile Attribute field.

type ChannelEntry

type ChannelEntry struct {
	HeaderLabel string         // e.g. "Channel Information:", "1. **General**"; empty to omit
	Channel     *model.Channel // the source channel
	DisplayName string         // shown instead of Channel.DisplayName when set (e.g. a DM placeholder)
	TeamName    string         // resolved team display name
	TeamID      string         // team ID (shown when TeamName is empty but TeamID is set)
	MemberCount int64          // -1 means don't show
	Role        string         // requesting user's role: "admin" | "member" | "guest" | "not_member" | "" (omit)
}

ChannelEntry holds data for formatting a single channel.

type ChannelMemberEntry

type ChannelMemberEntry struct {
	HeaderLabel string
	Member      *model.ChannelMember
	Username    string // resolved, optional
}

ChannelMemberEntry holds data for formatting a single channel membership record.

type DictationContext added in v2.14.0

type DictationContext struct {
	Prompt   string
	Keywords []string
}

DictationContext is the prompt and keywords a transcription session gets for the conversation the user dictates into.

func DictationChannelContext added in v2.14.0

func DictationChannelContext(channelName string, names []string) DictationContext

DictationChannelContext builds the transcription hints from a channel name (empty for direct and group messages) and people's names in priority order. Names are cleaned, deduplicated and added until the prompt reaches DictationPromptMaxChars; the first name that doesn't fit ends the list, so a cut keeps the names that come first. Keywords are the channel name and the names that made it into the prompt.

type DraftEntry added in v2.12.0

type DraftEntry struct {
	HeaderLabel string // e.g. "Draft 1"; empty to omit
	Draft       *model.Draft
}

DraftEntry holds data for formatting a single message draft.

type EmojiEntry

type EmojiEntry struct {
	HeaderLabel string
	Emoji       *model.Emoji
	CreatorName string
}

EmojiEntry holds data for formatting a single custom emoji.

type FileDescriptorEntry

type FileDescriptorEntry struct {
	// Number is the 1-based position of the file in the attachment list; it
	// renders as an "Attached File N" header. A zero value omits the header.
	Number   int
	FileInfo *model.FileInfo // the source file
}

FileDescriptorEntry holds metadata for a file attachment surfaced to the LLM without inlining its contents. The File ID is included so the model can pass it to the read_file tool to fetch the contents on demand.

type GroupEntry

type GroupEntry struct {
	HeaderLabel string
	Group       *model.Group
}

GroupEntry holds data for formatting a single group.

type IncomingWebhookEntry

type IncomingWebhookEntry struct {
	HeaderLabel string
	Webhook     *model.IncomingWebhook
}

IncomingWebhookEntry holds data for formatting an incoming webhook.

type OutgoingWebhookEntry

type OutgoingWebhookEntry struct {
	HeaderLabel string
	Webhook     *model.OutgoingWebhook
}

OutgoingWebhookEntry holds data for formatting an outgoing webhook.

type PostEntry

type PostEntry struct {
	// Header components
	HeaderLabel     string  // e.g. "Post 1", "Result 3"
	Username        string  // resolved username; "" → "Unknown User"
	Score           float32 // >0 means show "(Score: X.XX)" — search only
	ReplyAnnotation string  // e.g. "(reply to Post 2)" — appended to header

	// The source post
	Post *model.Post

	// Optional context metadata (search results show per-result channel info)
	ChannelName string
	TeamName    string
	ShowChannel bool // show Channel ID line

}

PostEntry holds pre-resolved data for formatting a single post. Used by MCP tools and other callers that need structured post output.

type PostInfoEntry

type PostInfoEntry struct {
	PostID   string
	PostInfo *model.PostInfo
}

PostInfoEntry holds data for formatting a single post's metadata/context.

type RoleEntry

type RoleEntry struct {
	Role *model.Role
}

RoleEntry holds data for formatting a single role.

type ScheduledPostEntry

type ScheduledPostEntry struct {
	HeaderLabel   string // e.g. "Scheduled Post 1"; empty to omit
	ScheduledPost *model.ScheduledPost
	ChannelName   string // resolved channel display name, optional
}

ScheduledPostEntry holds data for formatting a single scheduled post.

type SidebarCategoryEntry

type SidebarCategoryEntry struct {
	HeaderLabel string
	Category    *model.SidebarCategoryWithChannels
}

SidebarCategoryEntry holds data for formatting a single sidebar category.

type StatusEntry

type StatusEntry struct {
	HeaderLabel string
	Status      *model.Status
	Username    string // resolved, optional
}

StatusEntry holds data for formatting a single user's presence status.

type TeamEntry

type TeamEntry struct {
	Team        *model.Team // the source team
	MemberCount int64       // -1 means don't show
}

TeamEntry holds data for formatting a single team.

type TeamMemberEntry

type TeamMemberEntry struct {
	HeaderLabel string
	Member      *model.TeamMember
	Username    string // resolved, optional
}

TeamMemberEntry holds data for formatting a single team membership record.

type ThreadSummaryEntry

type ThreadSummaryEntry struct {
	HeaderLabel string
	Thread      *model.ThreadResponse
	Username    string // root post author
}

ThreadSummaryEntry holds data for formatting a single thread from the inbox.

type UnavailableAttachmentReason added in v2.11.0

type UnavailableAttachmentReason int

UnavailableAttachmentReason says why an attachment's content is not in the conversation.

const (
	// AttachmentImageInputDisabled means the agent does not accept images.
	AttachmentImageInputDisabled UnavailableAttachmentReason = iota + 1
	// AttachmentLoadFailed means the file's metadata or bytes could not be read.
	AttachmentLoadFailed
	// AttachmentForbidden means the requesting user may not access the file.
	AttachmentForbidden
)

type UserEntry

type UserEntry struct {
	HeaderLabel string      // e.g. "User 1"; empty for member lists
	User        *model.User // the source user
	Role        string      // "admin", "member", "guest", "" — from MemberRole
}

UserEntry holds data for formatting a single user.

Jump to

Keyboard shortcuts

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