Documentation
¶
Index ¶
- Constants
- Variables
- func ChunkMessageMarkdown(text string, limit int) []string
- func ExtractToolInfo(msg *base.ChatMessage) (toolName, input string)
- func FormatChannelAllMention() string
- func FormatChannelMention(channelID, channelName string) string
- func FormatChannelMentionByID(channelID string) string
- func FormatCommand(command string) string
- func FormatDate(timestamp int64) string
- func FormatDateLong(timestamp int64) string
- func FormatDateShort(timestamp int64) string
- func FormatDateTime(timestamp int64, format, fallback string) string
- func FormatDateTimeCombined(timestamp int64) string
- func FormatDateTimeWithLink(timestamp int64, format, linkURL, fallback string) string
- func FormatDuration(durationMs int64) string
- func FormatEmail(email string) string
- func FormatEveryoneMention() string
- func FormatHereMention() string
- func FormatObject(objectType, objectID, objectText string) string
- func FormatSpecialMention(mentionType string) string
- func FormatSubteamMention(subteamID, subteamHandle string) string
- func FormatTime(timestamp int64) string
- func FormatURL(url, text string) string
- func FormatUserMention(userID, userName string) string
- func FormatUserMentionByID(userID string) string
- func IsAllowedScheme(scheme string) bool
- func IsLongRunningTool(durationMs int64) bool
- func ParseProviderEventType(eventType provider.ProviderEventType) base.MessageType
- func RateLimitKey(userID, ip string) string
- func RuneCount(s string) int
- func SanitizeCommand(command string) string
- func SanitizeErrorMessage(err error) string
- func SanitizeForDisplay(content string, maxLength int) string
- func SanitizeForRegex(input string) string
- func SanitizeMarkdown(content string) string
- func TimeToSlackTimestamp(t time.Time) string
- func TruncateByRune(s string, maxRunes int) string
- func TruncateMrkdwn(text string, maxLen int) string
- func ValidateAccessibilityLabel(label string) error
- func ValidateActionID(actionID string) error
- func ValidateBlock(block map[string]any, index int) error
- func ValidateBlockID(blockID string) string
- func ValidateBlockWithDetails(block map[string]any, index int) []error
- func ValidateBlocks(blocks []map[string]any, isModal bool) error
- func ValidateButtonComplete(button map[string]any) error
- func ValidateButtonURL(buttonURL string) error
- func ValidateButtonURLLength(buttonURL string) error
- func ValidateButtonValue(value string) (string, string, string, error)
- func ValidateComplete(block map[string]any) error
- func ValidateConfirmationDialog(title, text, confirmText, denyText string) (string, string, string, string)
- func ValidateConfirmationDialogText(title, text, confirmText, denyText string) (string, string, string, string)
- func ValidateEmailFormat(email string) bool
- func ValidateEmoji(text string, allowEmoji bool) string
- func ValidateFileComplete(file map[string]any) error
- func ValidateFileInput(element map[string]any) error
- func ValidateImageComplete(image map[string]any) error
- func ValidateImageURL(imageURL string) error
- func ValidateInitialValue(initialValue string, maxLength int) string
- func ValidateInitialValueForInput(initialValue string, maxLength int) string
- func ValidateMentionFormat(mention string) bool
- func ValidateMrkdwnText(text string) string
- func ValidateOptionValue(value string) error
- func ValidatePlainText(text string, withEmoji bool) string
- func ValidatePlanBlock(block map[string]any) error
- func ValidateRegexPattern(pattern string) (string, error)
- func ValidateRichTextInput(element map[string]any) error
- func ValidateTableBlock(block map[string]any) error
- func ValidateTaskCardBlock(block map[string]any) error
- func ValidateTextObject(text map[string]any) error
- func ValidateTokenFormat(token string) bool
- func ValidateToolName(toolName string) string
- func ValidateURL(rawURL string) error
- func ValidateURLFormat(rawURL string) bool
- type Adapter
- func (a *Adapter) AddReaction(ctx context.Context, reaction base.Reaction) error
- func (a *Adapter) AddReactionSDK(ctx context.Context, reaction base.Reaction) error
- func (a *Adapter) DeleteMessage(ctx context.Context, channelID, messageTS string) error
- func (a *Adapter) DeleteMessageSDK(ctx context.Context, channelID, messageTS string) error
- func (a *Adapter) PostEphemeralSDK(ctx context.Context, channelID, userID, text string, blocks []slack.Block) error
- func (a *Adapter) PostTypingIndicator(ctx context.Context, channelID, threadTS string) error
- func (a *Adapter) RemoveReaction(ctx context.Context, reaction base.Reaction) error
- func (a *Adapter) RemoveReactionSDK(ctx context.Context, reaction base.Reaction) error
- func (a *Adapter) SendAttachment(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
- func (a *Adapter) SendAttachmentSDK(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
- func (a *Adapter) SendMessage(ctx context.Context, sessionID string, msg *base.ChatMessage) error
- func (a *Adapter) SendToChannel(ctx context.Context, channelID, text, threadTS string) error
- func (a *Adapter) SendToChannelSDK(ctx context.Context, channelID, text, threadTS string) error
- func (a *Adapter) SendTypingIndicatorForSession(ctx context.Context, sessionID string) error
- func (a *Adapter) SetEngine(eng *engine.Engine)
- func (a *Adapter) SetSender(fn func(ctx context.Context, sessionID string, msg *base.ChatMessage) error)
- func (a *Adapter) SetSlashCommandHandler(fn func(cmd SlashCommand))
- func (a *Adapter) Start(ctx context.Context) error
- func (a *Adapter) Stop() error
- func (a *Adapter) UpdateMessage(ctx context.Context, channelID, messageTS string, msg *base.ChatMessage) error
- func (a *Adapter) UpdateMessageSDK(ctx context.Context, channelID, messageTS string, blocks []slack.Block, ...) error
- type CallbackChannel
- type CallbackMessage
- type CallbackTeam
- type CallbackUser
- type Config
- type Event
- type MessageBuilder
- func (b *MessageBuilder) Build(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildAnswerMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildAskUserQuestionMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildCommandCompleteMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildCommandProgressMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildDangerBlockMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildEngineStartingMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildErrorMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildExitPlanModeMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildPermissionApprovedMessage(tool, input string) []slack.Block
- func (b *MessageBuilder) BuildPermissionDeniedMessage(tool, input, reason string) []slack.Block
- func (b *MessageBuilder) BuildPermissionRequestMessageFromChat(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildPlanApprovedBlock() []slack.Block
- func (b *MessageBuilder) BuildPlanCancelledBlock(reason string) []slack.Block
- func (b *MessageBuilder) BuildPlanModeMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildRawMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildSessionStartMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildSessionStatsMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildStepFinishMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildStepStartMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildSystemMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildThinkingMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildToolResultMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildToolUseMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildUserMessage(msg *base.ChatMessage) []slack.Block
- func (b *MessageBuilder) BuildUserMessageReceivedMessage(msg *base.ChatMessage) []slack.Block
- type MessageEvent
- type MrkdwnFormatter
- type SlackAction
- type SlackInteractionCallback
- type SlashCommand
- type SlashCommandRateLimiter
- type ValidationError
Constants ¶
const ( // CommandReset represents the /reset command CommandReset = "/reset" // CommandDisconnect represents the /dc command CommandDisconnect = "/dc" )
const ( MaxSectionTextLen = 3000 MaxBlocksLen = 50 MaxModalBlocksLen = 100 MaxFieldTextLen = 2000 MaxBlockIDLen = 255 MaxMarkdownBlockLen = 12000 MaxPlainTextLen = 150 MaxButtonActionIDLen = 255 MaxButtonTextLen = 75 )
Slack Block Kit character limits (from official documentation)
const SlackTextLimit = 4000
SlackTextLimit is the maximum character limit for a single Slack message
const ToolResultDurationThreshold = 500 // ms
ToolResultDurationThreshold is the threshold for showing duration
Variables ¶
var ActionIDPattern = regexp.MustCompile(`^[a-zA-Z0-9_-]{1,255}$`)
ActionIDPattern validates action_id format (alphanumeric + _ - only, max 255 chars)
var AllowedFileTypes = map[string]bool{ "pdf": true, "doc": true, "docx": true, "xls": true, "xlsx": true, "ppt": true, "pptx": true, "txt": true, "rtfd": true, "zip": true, "mp3": true, "mov": true, "mp4": true, "wav": true, "key": true, }
AllowedFileTypes defines Slack-supported file extensions for file_input
var AllowedURLSchemes = []string{"http://", "https://", "mailto:", "ftp://"}
AllowedURLSchemes defines which URL schemes are allowed in links
var ButtonValuePattern = regexp.MustCompile(`^[a-zA-Z0-9_-]+:[a-zA-Z0-9_-]+:[a-zA-Z0-9_-]+$`)
ButtonValuePattern validates permission button values Format: behavior:sessionID:messageID (alphanumeric + _ - only)
var SUPPORTED_COMMANDS = []string{CommandReset, CommandDisconnect}
SUPPORTED_COMMANDS lists all slash commands supported by the system. Used for matching #<command> prefix in messages (thread support).
Functions ¶
func ChunkMessageMarkdown ¶ added in v0.12.0
chunkMessageMarkdown splits a markdown message into chunks, keeping code blocks together as much as possible.
func ExtractToolInfo ¶ added in v0.13.0
func ExtractToolInfo(msg *base.ChatMessage) (toolName, input string)
ExtractToolInfo extracts tool name and input from ChatMessage metadata
func FormatChannelAllMention ¶ added in v0.12.0
func FormatChannelAllMention() string
FormatChannelMention creates a @channel mention
func FormatChannelMention ¶ added in v0.12.0
FormatChannelMention creates a channel mention: <#C123|channel-name>
func FormatChannelMentionByID ¶ added in v0.12.0
FormatChannelMentionByID creates a channel mention with just ID: <#C123>
func FormatCommand ¶ added in v0.12.0
FormatCommand creates a command formatting
func FormatDate ¶ added in v0.12.0
FormatDate creates a simple date formatting
func FormatDateLong ¶ added in v0.12.0
FormatDateLong creates a long date formatting (e.g., "Monday, January 1, 2024")
func FormatDateShort ¶ added in v0.12.0
FormatDateShort creates a short date formatting (e.g., "Jan 1, 2024")
func FormatDateTime ¶ added in v0.12.0
FormatDateTime creates a date formatting: <!date^timestamp^format|fallback> Reference: https://api.slack.com/reference/surfaces/formatting#date-formatting
func FormatDateTimeCombined ¶ added in v0.12.0
FormatDateTimeCombined creates combined date and time formatting
func FormatDateTimeWithLink ¶ added in v0.12.0
FormatDateTimeWithLink creates a date formatting with link: <!date^timestamp^format^link|fallback>
func FormatDuration ¶ added in v0.13.0
FormatDuration formats duration for display
func FormatEmail ¶ added in v0.12.0
FormatEmail creates an email link
func FormatEveryoneMention ¶ added in v0.12.0
func FormatEveryoneMention() string
FormatEveryoneMention creates a @everyone mention
func FormatHereMention ¶ added in v0.12.0
func FormatHereMention() string
FormatHereMention creates a @here mention
func FormatObject ¶ added in v0.12.0
FormatObject creates an object mention (for boards, clips, etc.)
func FormatSpecialMention ¶ added in v0.12.0
FormatSpecialMention creates a special mention: <!here>, <!channel>, <!everyone>
func FormatSubteamMention ¶ added in v0.12.0
FormatSubteamMention creates a user group mention: <!subteam^S123|@group>
func FormatTime ¶ added in v0.12.0
FormatTime creates a time formatting (e.g., "2:30 PM")
func FormatUserMention ¶ added in v0.12.0
FormatUserMention creates a user mention: <@U123|username>
func FormatUserMentionByID ¶ added in v0.12.0
FormatUserMentionByID creates a user mention with just ID: <@U123>
func IsAllowedScheme ¶ added in v0.12.0
IsAllowedScheme checks if a URL scheme is in the allowed list
func IsLongRunningTool ¶ added in v0.13.0
IsLongRunningTool checks if a tool is considered long-running
func ParseProviderEventType ¶ added in v0.13.0
func ParseProviderEventType(eventType provider.ProviderEventType) base.MessageType
ParseProviderEventType converts provider event type to base message type
func RateLimitKey ¶ added in v0.12.0
RateLimitKey generates a rate limit key based on user ID and IP
func SanitizeCommand ¶ added in v0.12.0
SanitizeCommand sanitizes command string for safe display in code blocks
func SanitizeErrorMessage ¶ added in v0.12.0
SanitizeErrorMessage removes potentially sensitive information from error messages
func SanitizeForDisplay ¶ added in v0.12.0
SanitizeForDisplay removes potentially dangerous content for display
func SanitizeForRegex ¶ added in v0.12.0
SanitizeForRegex escapes special regex characters in user input
func SanitizeMarkdown ¶ added in v0.12.0
SanitizeMarkdown removes potentially dangerous markdown patterns
func TimeToSlackTimestamp ¶ added in v0.13.0
TimeToSlackTimestamp converts time.Time to Slack timestamp format
func TruncateByRune ¶ added in v0.12.0
TruncateByRune truncates string by rune count, not byte count
func TruncateMrkdwn ¶ added in v0.12.0
TruncateMrkdwn truncates mrkdwn text to max length while preserving formatting It avoids cutting in the middle of code blocks or special syntax
func ValidateAccessibilityLabel ¶ added in v0.12.0
ValidateAccessibilityLabel validates accessibility label for button (max 75 chars)
func ValidateActionID ¶ added in v0.12.0
ValidateActionID validates action_id format
func ValidateBlock ¶ added in v0.12.0
ValidateBlock validates a single block
func ValidateBlockID ¶ added in v0.12.0
ValidateBlockID validates block_id length
func ValidateBlockWithDetails ¶ added in v0.12.0
ValidateBlockWithDetails returns detailed validation errors
func ValidateBlocks ¶ added in v0.12.0
ValidateBlocks validates an array of blocks
func ValidateButtonComplete ¶ added in v0.12.0
ValidateButtonComplete performs complete validation for button element
func ValidateButtonURL ¶ added in v0.12.0
ValidateButtonURL validates URL for button elements
func ValidateButtonURLLength ¶ added in v0.12.0
ValidateButtonURLLength validates button URL length (max 3000 chars)
func ValidateButtonValue ¶ added in v0.12.0
ValidateButtonValue validates permission button value format Returns (behavior, sessionID, messageID, error)
func ValidateComplete ¶ added in v0.12.0
ValidateComplete validates all fields in a block for comprehensive validation
func ValidateConfirmationDialog ¶ added in v0.12.0
func ValidateConfirmationDialog(title, text, confirmText, denyText string) (string, string, string, string)
ValidateConfirmationDialog validates confirmation dialog fields
func ValidateConfirmationDialogText ¶ added in v0.12.0
func ValidateConfirmationDialogText(title, text, confirmText, denyText string) (string, string, string, string)
ValidateConfirmationDialogText validates confirmation dialog text fields
func ValidateEmailFormat ¶ added in v0.12.0
ValidateEmailFormat performs basic email validation
func ValidateEmoji ¶ added in v0.12.0
ValidateEmoji validates and optionally removes emoji from text
func ValidateFileComplete ¶ added in v0.12.0
ValidateFileComplete performs complete validation for file block
func ValidateFileInput ¶ added in v0.12.0
ValidateFileInput validates file input element
func ValidateImageComplete ¶ added in v0.12.0
ValidateImageComplete performs complete validation for image block
func ValidateImageURL ¶ added in v0.12.0
ValidateImageURL validates URL for image blocks
func ValidateInitialValue ¶ added in v0.12.0
ValidateInitialValue validates initial_value for input elements
func ValidateInitialValueForInput ¶ added in v0.12.0
ValidateInitialValueForInput validates initial_value for input elements
func ValidateMentionFormat ¶ added in v0.12.0
ValidateMentionFormat validates Slack mention format
func ValidateMrkdwnText ¶ added in v0.12.0
ValidateMrkdwnText validates mrkdwn text content
func ValidateOptionValue ¶ added in v0.12.0
ValidateOptionValue validates option value in select menus
func ValidatePlainText ¶ added in v0.12.0
ValidatePlainText validates plain_text object content
func ValidatePlanBlock ¶ added in v0.12.0
ValidatePlanBlock validates plan block
func ValidateRegexPattern ¶ added in v0.12.0
ValidateRegexPattern validates regex pattern to prevent ReDoS
func ValidateRichTextInput ¶ added in v0.12.0
ValidateRichTextInput validates rich text input element
func ValidateTableBlock ¶ added in v0.12.0
ValidateTableBlock validates table block
func ValidateTaskCardBlock ¶ added in v0.12.0
ValidateTaskCardBlock validates task card block
func ValidateTextObject ¶ added in v0.12.0
ValidateTextObject validates a text object
func ValidateTokenFormat ¶ added in v0.12.0
ValidateTokenFormat validates Slack token format with safe regex
func ValidateToolName ¶ added in v0.12.0
ValidateToolName validates tool name for safe display
func ValidateURL ¶ added in v0.12.0
ValidateURL checks if a URL uses an allowed scheme
func ValidateURLFormat ¶ added in v0.12.0
ValidateURLFormat performs basic URL validation
Types ¶
type Adapter ¶
func NewAdapter ¶
func (*Adapter) AddReaction ¶ added in v0.11.1
AddReaction adds a reaction to a message
func (*Adapter) AddReactionSDK ¶ added in v0.13.0
AddReactionSDK adds a reaction using Slack SDK
func (*Adapter) DeleteMessage ¶ added in v0.15.5
DeleteMessage implements base.MessageOperations interface
func (*Adapter) DeleteMessageSDK ¶ added in v0.13.0
DeleteMessageSDK deletes a message using Slack SDK
func (*Adapter) PostEphemeralSDK ¶ added in v0.13.0
func (a *Adapter) PostEphemeralSDK(ctx context.Context, channelID, userID, text string, blocks []slack.Block) error
PostEphemeralSDK posts an ephemeral message using Slack SDK
func (*Adapter) PostTypingIndicator ¶ added in v0.13.0
PostTypingIndicator sends a visual indicator that the bot is processing Per spec: Triggered when user message received, during processing Note: Uses ephemeral context message as typing indicator alternative
func (*Adapter) RemoveReaction ¶ added in v0.15.5
RemoveReaction implements base.MessageOperations interface
func (*Adapter) RemoveReactionSDK ¶ added in v0.13.0
RemoveReactionSDK removes a reaction using Slack SDK
func (*Adapter) SendAttachment ¶
func (a *Adapter) SendAttachment(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
SendAttachment sends an attachment to a Slack channel
func (*Adapter) SendAttachmentSDK ¶ added in v0.13.0
func (a *Adapter) SendAttachmentSDK(ctx context.Context, channelID, threadTS string, attachment base.Attachment) error
SendAttachmentSDK sends an attachment using Slack SDK Note: Simplified implementation - uses existing custom method
func (*Adapter) SendMessage ¶
func (*Adapter) SendToChannel ¶
func (*Adapter) SendToChannelSDK ¶ added in v0.13.0
SendToChannelSDK sends a text message using Slack SDK
func (*Adapter) SendTypingIndicatorForSession ¶ added in v0.13.0
SendTypingIndicatorForSession sends typing indicator for a session Uses session to resolve channel ID
func (*Adapter) SetEngine ¶ added in v0.12.0
SetEngine sets the engine for the adapter (used for slash commands)
func (*Adapter) SetSlashCommandHandler ¶ added in v0.11.1
func (a *Adapter) SetSlashCommandHandler(fn func(cmd SlashCommand))
SetSlashCommandHandler sets the handler for slash commands
func (*Adapter) UpdateMessage ¶ added in v0.12.0
func (a *Adapter) UpdateMessage(ctx context.Context, channelID, messageTS string, msg *base.ChatMessage) error
UpdateMessage implements base.MessageOperations interface
type CallbackChannel ¶ added in v0.12.0
CallbackChannel represents the channel in a Slack callback.
type CallbackMessage ¶ added in v0.12.0
type CallbackMessage struct {
Ts string `json:"ts"`
Type string `json:"type"`
Text string `json:"text"`
}
CallbackMessage represents the message in a Slack callback.
type CallbackTeam ¶ added in v0.12.0
CallbackTeam represents the team in a Slack callback.
type CallbackUser ¶ added in v0.12.0
CallbackUser represents the user in a Slack callback.
type Config ¶
type Config struct {
BotToken string
AppToken string
SigningSecret string
SystemPrompt string
// Mode: "http" (default) or "socket" for WebSocket connection
Mode string
// ServerAddr: HTTP server address (e.g., ":8080")
ServerAddr string
// Permission Policy for Direct Messages
// "allow" - Allow all DMs (default)
// "pairing" - Only allow when user is paired
// "block" - Block all DMs
DMPolicy string
// Permission Policy for Group Messages
// "allow" - Allow all group messages (default)
// "mention" - Only allow when bot is mentioned
// "block" - Block all group messages
GroupPolicy string
// AllowedUsers: List of user IDs who can interact with the bot (whitelist)
AllowedUsers []string
// BlockedUsers: List of user IDs who cannot interact with the bot (blacklist)
BlockedUsers []string
// BotUserID: Bot's user ID (e.g., "U1234567890") - used for mention detection
BotUserID string
// SlashCommandRateLimit: Maximum requests per second per user for slash commands
// Default: 10.0 requests/second
SlashCommandRateLimit float64
// contains filtered or unexported fields
}
func (*Config) ContainsBotMention ¶ added in v0.12.0
ContainsBotMention checks if message text contains a bot mention Slack mention format: <@U1234567890> or <!here> or <!channel> Uses regex for exact matching to prevent false positives
func (*Config) IsSocketMode ¶
IsSocketMode returns true if Socket Mode is enabled
func (*Config) IsUserAllowed ¶ added in v0.12.0
IsUserAllowed checks if a user is allowed to interact with the bot
func (*Config) MarkPaired ¶ added in v0.12.0
MarkPaired marks a user as having an active DM with the bot
func (*Config) ShouldProcessChannel ¶ added in v0.12.0
ShouldProcessChannel checks if messages from a channel should be processed channelType: "dm", "im" (direct message), or "channel" or "group"
type MessageBuilder ¶ added in v0.13.0
type MessageBuilder struct {
// contains filtered or unexported fields
}
MessageBuilder builds Slack-specific messages from platform-agnostic ChatMessage
func NewMessageBuilder ¶ added in v0.13.0
func NewMessageBuilder() *MessageBuilder
NewMessageBuilder creates a new MessageBuilder
func (*MessageBuilder) Build ¶ added in v0.13.0
func (b *MessageBuilder) Build(msg *base.ChatMessage) []slack.Block
Build builds Slack blocks from a ChatMessage based on its type
func (*MessageBuilder) BuildAnswerMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildAnswerMessage(msg *base.ChatMessage) []slack.Block
BuildAnswerMessage builds a message for AI answer
func (*MessageBuilder) BuildAskUserQuestionMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildAskUserQuestionMessage(msg *base.ChatMessage) []slack.Block
BuildAskUserQuestionMessage builds a message for user questions
func (*MessageBuilder) BuildCommandCompleteMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildCommandCompleteMessage(msg *base.ChatMessage) []slack.Block
BuildCommandCompleteMessage builds a message for command completion Implements EventTypeCommandComplete per spec
func (*MessageBuilder) BuildCommandProgressMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildCommandProgressMessage(msg *base.ChatMessage) []slack.Block
BuildCommandProgressMessage builds a message for command progress updates Implements EventTypeCommandProgress per spec (17) Block type: section + context + actions
func (*MessageBuilder) BuildDangerBlockMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildDangerBlockMessage(msg *base.ChatMessage) []slack.Block
BuildDangerBlockMessage builds a message for dangerous operations
func (*MessageBuilder) BuildEngineStartingMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildEngineStartingMessage(msg *base.ChatMessage) []slack.Block
BuildEngineStartingMessage builds a message for engine starting Implements EventTypeEngineStarting per spec (0.5) Triggered during CLI cold start when engine is being initialized
func (*MessageBuilder) BuildErrorMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildErrorMessage(msg *base.ChatMessage) []slack.Block
BuildErrorMessage builds a message for errors Implements EventTypeError per spec - uses quote format for emphasis
func (*MessageBuilder) BuildExitPlanModeMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildExitPlanModeMessage(msg *base.ChatMessage) []slack.Block
BuildExitPlanModeMessage builds a message for exit plan mode Implements EventTypeExitPlanMode per spec (15) Block type: header + section + divider + actions
func (*MessageBuilder) BuildPermissionApprovedMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildPermissionApprovedMessage(tool, input string) []slack.Block
BuildPermissionApprovedMessage builds blocks to show after permission is approved
func (*MessageBuilder) BuildPermissionDeniedMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildPermissionDeniedMessage(tool, input, reason string) []slack.Block
BuildPermissionDeniedMessage builds blocks to show after permission is denied
func (*MessageBuilder) BuildPermissionRequestMessageFromChat ¶ added in v0.13.0
func (b *MessageBuilder) BuildPermissionRequestMessageFromChat(msg *base.ChatMessage) []slack.Block
BuildPermissionRequestMessageFromChat builds Slack blocks for a permission request from ChatMessage This is the main entry point for the Build() switch statement Implements EventTypePermissionRequest per spec (7)
func (*MessageBuilder) BuildPlanApprovedBlock ¶ added in v0.13.0
func (b *MessageBuilder) BuildPlanApprovedBlock() []slack.Block
BuildPlanApprovedBlock builds blocks to show after plan is approved
func (*MessageBuilder) BuildPlanCancelledBlock ¶ added in v0.13.0
func (b *MessageBuilder) BuildPlanCancelledBlock(reason string) []slack.Block
BuildPlanCancelledBlock builds blocks to show after plan is cancelled
func (*MessageBuilder) BuildPlanModeMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildPlanModeMessage(msg *base.ChatMessage) []slack.Block
BuildPlanModeMessage builds a message for plan mode Implements EventTypePlanMode per spec - uses context block for low visual weight
func (*MessageBuilder) BuildRawMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildRawMessage(msg *base.ChatMessage) []slack.Block
BuildRawMessage builds a message for raw/unparsed output Implements EventTypeRaw per spec - shows only type and length, not content
func (*MessageBuilder) BuildSessionStartMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildSessionStartMessage(msg *base.ChatMessage) []slack.Block
BuildSessionStartMessage builds a message for session start Implements EventTypeSessionStart per spec (0.4) Triggered when user sends first message or CLI needs cold start Block type: section + context
func (*MessageBuilder) BuildSessionStatsMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildSessionStatsMessage(msg *base.ChatMessage) []slack.Block
BuildSessionStatsMessage builds a message for session statistics Implements EventTypeResult (Turn Complete) per spec - compact single-line format
func (*MessageBuilder) BuildStepFinishMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildStepFinishMessage(msg *base.ChatMessage) []slack.Block
BuildStepFinishMessage builds a message for step completion Implements EventTypeStepFinish per spec
func (*MessageBuilder) BuildStepStartMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildStepStartMessage(msg *base.ChatMessage) []slack.Block
BuildStepStartMessage builds a message for step start Implements EventTypeStepStart per spec (11) Block type: section + context
func (*MessageBuilder) BuildSystemMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildSystemMessage(msg *base.ChatMessage) []slack.Block
BuildSystemMessage builds a message for system-level messages Implements EventTypeSystem per spec - uses context block for low visual weight
func (*MessageBuilder) BuildThinkingMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildThinkingMessage(msg *base.ChatMessage) []slack.Block
BuildThinkingMessage builds a status indicator for thinking state Implements EventTypeThinking per spec - uses context block for low visual weight
func (*MessageBuilder) BuildToolResultMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildToolResultMessage(msg *base.ChatMessage) []slack.Block
BuildToolResultMessage builds a message for tool execution result Implements EventTypeToolResult per spec - shows status, duration, and data length Supports aggregated messages: if metadata contains "_original_messages", builds blocks for each.
func (*MessageBuilder) BuildToolUseMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildToolUseMessage(msg *base.ChatMessage) []slack.Block
BuildToolUseMessage builds a message for tool invocation Implements EventTypeToolUse per spec - uses fields dual-column layout, parameter summary 12 chars Supports aggregated messages: if metadata contains "_original_messages", builds blocks for each.
func (*MessageBuilder) BuildUserMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildUserMessage(msg *base.ChatMessage) []slack.Block
BuildUserMessage builds a message for user message reflection Implements EventTypeUser per spec
func (*MessageBuilder) BuildUserMessageReceivedMessage ¶ added in v0.13.0
func (b *MessageBuilder) BuildUserMessageReceivedMessage(msg *base.ChatMessage) []slack.Block
BuildUserMessageReceivedMessage builds a message to acknowledge user message receipt Implements EventTypeUserMessageReceived per spec (0.6) Triggered immediately after user message is received
type MessageEvent ¶
type MessageEvent struct {
Type string `json:"type"`
Channel string `json:"channel"`
ChannelType string `json:"channel_type"`
User string `json:"user"`
Text string `json:"text"`
TS string `json:"ts"`
EventTS string `json:"event_ts"`
BotID string `json:"bot_id,omitempty"`
SubType string `json:"subtype,omitempty"`
ThreadTS string `json:"thread_ts,omitempty"` // Thread identifier
ParentUser string `json:"parent_user_id,omitempty"` // Parent message user
BotUserID string `json:"bot_user_id,omitempty"` // Bot user ID for mentions
}
type MrkdwnFormatter ¶ added in v0.12.0
type MrkdwnFormatter struct{}
MrkdwnFormatter provides utilities for converting Markdown to Slack mrkdwn format
func NewMrkdwnFormatter ¶ added in v0.12.0
func NewMrkdwnFormatter() *MrkdwnFormatter
NewMrkdwnFormatter creates a new MrkdwnFormatter
func (*MrkdwnFormatter) Format ¶ added in v0.12.0
func (f *MrkdwnFormatter) Format(text string) string
Format converts Markdown text to Slack mrkdwn format
Conversion order follows CommonMark specification precedence: 1. Block-level structures first (headings, lists, blockquotes, code blocks) 2. Code spans protected (highest inline precedence per CommonMark) 3. Links (before emphasis, as link content shouldn't be emphasized) 4. Emphasis (bold, italic, strikethrough) 5. Special character escaping (last, to avoid breaking syntax)
func (*MrkdwnFormatter) FormatCodeBlock ¶ added in v0.12.0
func (f *MrkdwnFormatter) FormatCodeBlock(code, language string) string
FormatCodeBlock formats a code block with optional language
type SlackAction ¶ added in v0.12.0
type SlackAction struct {
ActionID string `json:"action_id"`
BlockID string `json:"block_id"`
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
Style string `json:"style"`
}
SlackAction represents an action within a Slack interaction callback.
type SlackInteractionCallback ¶ added in v0.12.0
type SlackInteractionCallback struct {
Type string `json:"type"`
User CallbackUser `json:"user"`
Channel CallbackChannel `json:"channel"`
Message CallbackMessage `json:"message"`
ResponseURL string `json:"response_url"`
TriggerID string `json:"trigger_id"`
Actions []SlackAction `json:"actions"`
Team CallbackTeam `json:"team"`
}
SlackInteractionCallback represents a Slack interaction callback payload.
type SlashCommand ¶ added in v0.11.1
type SlashCommand struct {
Command string
Text string
UserID string
ChannelID string
ResponseURL string
}
SlashCommand represents a Slack slash command
type SlashCommandRateLimiter ¶ added in v0.12.0
type SlashCommandRateLimiter struct {
// contains filtered or unexported fields
}
SlashCommandRateLimiter provides per-user rate limiting using token bucket algorithm
func NewSlashCommandRateLimiter ¶ added in v0.12.0
func NewSlashCommandRateLimiter() *SlashCommandRateLimiter
NewSlashCommandRateLimiter creates a new rate limiter with default settings
func NewSlashCommandRateLimiterWithConfig ¶ added in v0.12.0
func NewSlashCommandRateLimiterWithConfig(rps float64, burst int) *SlashCommandRateLimiter
NewSlashCommandRateLimiterWithConfig creates a new rate limiter with custom settings If rps is 0 or negative, defaultRateLimit will be used
func (*SlashCommandRateLimiter) Allow ¶ added in v0.12.0
func (r *SlashCommandRateLimiter) Allow(userID string) bool
Allow checks if a request from the given user is allowed Returns true if the request is within rate limit, false if rate limited
func (*SlashCommandRateLimiter) Stop ¶ added in v0.12.0
func (r *SlashCommandRateLimiter) Stop()
Stop gracefully stops the rate limiter cleanup goroutine
type ValidationError ¶ added in v0.12.0
ValidationError represents a block validation error
func (*ValidationError) Error ¶ added in v0.12.0
func (e *ValidationError) Error() string