Documentation
¶
Index ¶
- Constants
- func DetectAgentError(text string) bool
- func FormatFileBlock(files []FileAttachment) string
- func FormatSessionFooter(mode, model string) string
- func FormatToolTitle(title, mode string) (string, bool)
- func IsCopilotReasoningEffortError(text string) bool
- func PickFallbackModel(available []string, current string) (string, bool)
- func SplitMessage(text string, limit int) []string
- func StripAgentRetryNoise(text string) string
- func TruncateUTF8(text string, limit int, suffix string) string
- type FileAttachment
- type Platform
Constants ¶
const ( ToolDisplayFull = "full" ToolDisplayCompact = "compact" ToolDisplayNone = "none" )
Tool display modes for ReactionsConfig.ToolDisplay.
Variables ¶
This section is empty.
Functions ¶
func DetectAgentError ¶
DetectAgentError reports whether `text` (already stripped of retry noise) looks like an agent-reported execution error that should be surfaced as a failure rather than a normal reply. Currently recognises Copilot CLI's "Error: Execution failed:" pattern.
func FormatFileBlock ¶
func FormatFileBlock(files []FileAttachment) string
FormatFileBlock renders a list of file attachments into the <attached_files> prompt block.
func FormatSessionFooter ¶
FormatSessionFooter returns a small footer showing the session's current mode / model for appending to the agent's reply. Returns empty string when both are blank, so callers can unconditionally concatenate it.
Deliberately avoids italic wrapping around inline code: Telegram's markdown-to-HTML conversion closes italic spans when it hits a backtick, so `_mode: \`x\` · model: \`y\`_` renders with broken spacing. Plain text + inline code works cleanly on Discord, Telegram-HTML and Teams alike.
func FormatToolTitle ¶
FormatToolTitle returns the title to render in the streamed chat message for an ACP tool-call event, based on the configured display mode.
The boolean return is false when the caller should skip rendering a tool line entirely (mode = "none", or the title is empty). The string return is empty in that case.
Empty titles always return (false) regardless of mode — otherwise a "match-by-substring" update loop could match every existing tool line (since strings.Contains(s, "") is always true) and silently overwrite the wrong entry.
Modes:
- "full" — return the title unchanged.
- "compact" — strip a leading generic status verb (e.g. "Running:"), then return the first whitespace-delimited token with trailing punctuation (":") stripped. Keeps callers informed *which* tool is running (e.g. "gh", "bash", "curl") without leaking long/sensitive argument lists. Falls back to the full title when it has no whitespace.
- "none" — skip the tool line.
Unrecognised modes fall back to "full" (safest — preserves existing behaviour for users who typo the config).
func IsCopilotReasoningEffortError ¶
IsCopilotReasoningEffortError reports whether `text` matches Copilot's "model … does not support reasoning effort" CAPIError. When true, switching the session's model to one that accepts reasoning effort (e.g. GPT-5 mini / GPT-4.1) is a reliable recovery path — the session state otherwise does not expose a way to downgrade reasoning_effort.
func PickFallbackModel ¶
PickFallbackModel chooses a non-current model id from `available` to use when the session's current model has been rejected by the agent. Preference order:
- a non-current id that does not look like a Claude Haiku variant (Haiku is the usual culprit of the Copilot reasoning_effort clash),
- any non-current id,
- ("", false) when the list has no alternative.
The comparison is case-insensitive on the id to catch "claude-haiku-4.5" / "Claude-Haiku" / future suffix variations without a hard-coded list.
func SplitMessage ¶
SplitMessage splits text into chunks at line boundaries, each <= limit bytes. Every chat platform has a message-size ceiling, so this lives in the shared package. Hard-splits for long lines are UTF-8 safe (never cuts mid-character).
func StripAgentRetryNoise ¶
StripAgentRetryNoise removes Copilot CLI's transient retry notices from an accumulated agent reply. The output keeps any real content (including genuine error messages) untouched.
Types ¶
type FileAttachment ¶
FileAttachment describes a non-image, non-audio file downloaded from a chat platform.