messaging

package
v1.1.58 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package messaging defines the messaging platform abstraction for Hermes mode. Each platform (WeChat, Feishu, etc.) implements the Platform interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InboundMessage

type InboundMessage struct {
	Platform  string    // "wechat", "feishu", etc.
	ChatID    string    // Conversation/chat identifier
	UserID    string    // Sender user ID
	UserName  string    // Sender display name
	Text      string    // Message text content
	Timestamp time.Time // When the message was sent

	// ProgressFunc is called to send intermediate progress updates during agent execution.
	// If nil, no progress updates are sent.
	ProgressFunc func(text string)
}

InboundMessage represents a message received from a messaging platform.

type MessageHandler

type MessageHandler func(ctx context.Context, msg InboundMessage) (string, error)

MessageHandler is called for each incoming message. It returns the response text to send back to the user.

type Platform

type Platform interface {
	// Name returns the platform identifier (e.g. "wechat", "feishu").
	Name() string
	// Start begins receiving messages. Blocks until ctx is cancelled or Stop is called.
	Start(ctx context.Context, handler MessageHandler) error
	// Stop gracefully shuts down the platform connection.
	Stop() error
	// SendMessage sends a text message to a specific chat.
	SendMessage(ctx context.Context, chatID string, text string) error
	// IsConnected reports whether the platform is currently connected.
	IsConnected() bool
}

Platform defines the interface that all messaging platform adapters must implement.

type ProgressBuffer

type ProgressBuffer struct {
	// contains filtered or unexported fields
}

ProgressBuffer collects progress lines and flushes them in batches. Designed for messaging platforms with per-message reply limits (e.g., WeChat: 10 replies per user message).

Usage:

buf := NewProgressBuffer(maxLines, sendFunc)
// During agent execution:
buf.Add("[read]: file.go ✅")   // buffered
buf.Add("[bash]: go build ✅")  // buffered, auto-flushes if full
// After agent completes:
buf.Flush()                      // send remaining lines

func NewProgressBuffer

func NewProgressBuffer(maxLines int, sendFunc func(string)) *ProgressBuffer

NewProgressBuffer creates a progress buffer.

maxLines: max progress lines to collect before auto-flushing (e.g., 7)
reserve: lines reserved for final summary, subtracted from platform limit (e.g., 3)
sendFunc: function to send combined text (e.g., WeChat SendMessage)

func (*ProgressBuffer) Add

func (b *ProgressBuffer) Add(line string)

Add adds a progress line. Auto-flushes when buffer is full.

func (*ProgressBuffer) Flush

func (b *ProgressBuffer) Flush()

Flush sends any remaining buffered lines. Call after agent completes.

Directories

Path Synopsis
Package feishu implements the Feishu (Lark) messaging platform adapter.
Package feishu implements the Feishu (Lark) messaging platform adapter.
Package wechat implements the WeChat iLink Bot messaging platform adapter.
Package wechat implements the WeChat iLink Bot messaging platform adapter.

Jump to

Keyboard shortcuts

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