platform

package
v0.30.7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 3 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 (
	ToolDisplayFull    = "full"
	ToolDisplayCompact = "compact"
	ToolDisplayNone    = "none"
)

Tool display modes for ReactionsConfig.ToolDisplay.

Variables

This section is empty.

Functions

func DetectAgentError

func DetectAgentError(text string) bool

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

func FormatSessionFooter(mode, model string) string

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

func FormatToolTitle(title, mode string) (string, bool)

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

func IsCopilotReasoningEffortError(text string) bool

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

func PickFallbackModel(available []string, current string) (string, bool)

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:

  1. a non-current id that does not look like a Claude Haiku variant (Haiku is the usual culprit of the Copilot reasoning_effort clash),
  2. any non-current id,
  3. ("", 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

func SplitMessage(text string, limit int) []string

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

func StripAgentRetryNoise(text string) string

StripAgentRetryNoise removes Copilot CLI's transient retry notices from an accumulated agent reply. The output keeps any real content (including genuine error messages) untouched.

func TruncateUTF8

func TruncateUTF8(text string, limit int, suffix string) string

TruncateUTF8 truncates text to at most limit bytes without cutting multi-byte characters. If truncated, appends the suffix (e.g. "…").

Types

type FileAttachment

type FileAttachment struct {
	Filename    string
	ContentType string
	Size        int
	LocalPath   string
}

FileAttachment describes a non-image, non-audio file downloaded from a chat platform.

type Platform

type Platform interface {
	Start() error
	Stop() error
}

Platform is the interface every chat adapter (Discord, Telegram, Teams …) must implement.

Jump to

Keyboard shortcuts

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