Documentation
¶
Index ¶
- func BundleFromAttachment(att Attachment) attachmentpkg.Bundle
- func ContainsMarkdown(text string) bool
- func IsSameConversation(session SessionContext, platform, target string) bool
- type Action
- type AssetMeta
- type AssetResolver
- type Attachment
- type AttachmentPromoter
- type AttachmentType
- type ChannelTypeResolver
- type Contact
- type ContactReader
- type Executor
- func (e *Executor) CanReact() bool
- func (e *Executor) CanSend() bool
- func (e *Executor) React(ctx context.Context, session SessionContext, args map[string]any) (*ReactResult, error)
- func (e *Executor) ResolveAttachments(ctx context.Context, botID string, bundles []attachmentpkg.Bundle) []Attachment
- func (e *Executor) Send(ctx context.Context, session SessionContext, args map[string]any) (*SendResult, error)
- func (e *Executor) SendDirect(ctx context.Context, session SessionContext, target string, ...) (*SendResult, error)
- type ForwardRef
- type Message
- type MessageFormat
- type MessagePart
- type MessagePartType
- type MessageTextStyle
- type Platform
- type ReactRequest
- type ReactResult
- type Reactor
- type ReplyRef
- type SendRequest
- type SendResult
- type Sender
- type SessionContext
- type ThreadRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BundleFromAttachment ¶
func BundleFromAttachment(att Attachment) attachmentpkg.Bundle
func ContainsMarkdown ¶
func IsSameConversation ¶
func IsSameConversation(session SessionContext, platform, target string) bool
IsSameConversation reports whether platform+target matches the session's current conversation.
Types ¶
type AssetResolver ¶
type AssetResolver interface {
Stat(ctx context.Context, botID, contentHash string) (media.Asset, error)
Open(ctx context.Context, botID, contentHash string) (io.ReadCloser, media.Asset, error)
Ingest(ctx context.Context, input media.IngestInput) (media.Asset, error)
GetByStorageKey(ctx context.Context, botID, storageKey string) (media.Asset, error)
AccessPath(ctx context.Context, asset media.Asset) string
IngestContainerFile(ctx context.Context, botID, containerPath string) (media.Asset, error)
}
type Attachment ¶
type Attachment struct {
Type AttachmentType `json:"type"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
PlatformKey string `json:"platform_key,omitempty"`
SourcePlatform string `json:"source_platform,omitempty"`
ContentHash string `json:"content_hash,omitempty"`
Base64 string `json:"base64,omitempty"`
Name string `json:"name,omitempty"`
Size int64 `json:"size,omitempty"`
Mime string `json:"mime,omitempty"`
DurationMs int64 `json:"duration_ms,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
Caption string `json:"caption,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
func AssetMetaToAttachment ¶
func AssetMetaToAttachment(asset media.Asset, botID, attType, name string) *Attachment
AssetMetaToAttachment converts an AssetMeta to a Attachment.
func AttachmentFromBundle ¶
func AttachmentFromBundle(bundle attachmentpkg.Bundle) Attachment
type AttachmentPromoter ¶
type AttachmentPromoter interface {
PromoteAttachments(ctx context.Context, botID string, platform Platform, msg Message) (Message, error)
}
AttachmentPromoter lets the Channel boundary convert container-local attachment references into durable outbound assets.
type AttachmentType ¶
type AttachmentType string
const ( AttachmentImage AttachmentType = "image" AttachmentAudio AttachmentType = "audio" AttachmentVideo AttachmentType = "video" AttachmentVoice AttachmentType = "voice" AttachmentFile AttachmentType = "file" AttachmentGIF AttachmentType = "gif" )
func InferAttachmentTypeFromExt ¶
func InferAttachmentTypeFromExt(path string) AttachmentType
InferAttachmentTypeFromExt infers attachment type from file extension.
func InferAttachmentTypeFromMime ¶
func InferAttachmentTypeFromMime(mime string) AttachmentType
InferAttachmentTypeFromMime infers attachment type from MIME type.
type ChannelTypeResolver ¶
type ContactReader ¶
type Executor ¶
type Executor struct {
Sender Sender
Reactor Reactor
Resolver ChannelTypeResolver
AssetResolver AssetResolver
Promoter AttachmentPromoter
Logger *slog.Logger
}
Executor provides send and react operations for channel messaging.
func (*Executor) CanReact ¶
CanReact returns true if the executor has a reactor and resolver configured.
func (*Executor) CanSend ¶
CanSend returns true if the executor has a sender and resolver configured.
func (*Executor) React ¶
func (e *Executor) React(ctx context.Context, session SessionContext, args map[string]any) (*ReactResult, error)
React executes a react action. args are the tool call arguments.
func (*Executor) ResolveAttachments ¶
func (e *Executor) ResolveAttachments(ctx context.Context, botID string, bundles []attachmentpkg.Bundle) []Attachment
ResolveAttachments converts raw attachment arguments into Attachment values.
func (*Executor) Send ¶
func (e *Executor) Send(ctx context.Context, session SessionContext, args map[string]any) (*SendResult, error)
Send executes a send-message action. args are the tool call arguments.
func (*Executor) SendDirect ¶
func (e *Executor) SendDirect(ctx context.Context, session SessionContext, target string, args map[string]any) (*SendResult, error)
SendDirect sends a message via the channel adapter without the same-conversation local shortcut. Used by discuss mode where there is no active stream emitter.
type ForwardRef ¶
type ForwardRef struct {
MessageID string `json:"message_id,omitempty"`
FromUserID string `json:"from_user_id,omitempty"`
FromConversationID string `json:"from_conversation_id,omitempty"`
Sender string `json:"sender,omitempty"`
Date int64 `json:"date,omitempty"`
AttachmentsKnown bool `json:"attachments_known,omitempty"`
}
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Format MessageFormat `json:"format,omitempty"`
Text string `json:"text,omitempty"`
Parts []MessagePart `json:"parts,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
Actions []Action `json:"actions,omitempty"`
Thread *ThreadRef `json:"thread,omitempty"`
Reply *ReplyRef `json:"reply,omitempty"`
Forward *ForwardRef `json:"forward,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
func ParseOutboundMessage ¶
ParseOutboundMessage parses a message from tool call arguments.
type MessageFormat ¶
type MessageFormat string
const ( MessageFormatPlain MessageFormat = "plain" MessageFormatMarkdown MessageFormat = "markdown" MessageFormatRich MessageFormat = "rich" )
type MessagePart ¶
type MessagePart struct {
Type MessagePartType `json:"type"`
Text string `json:"text,omitempty"`
URL string `json:"url,omitempty"`
Styles []MessageTextStyle `json:"styles,omitempty"`
Language string `json:"language,omitempty"`
ChannelIdentityID string `json:"channel_identity_id,omitempty"`
Emoji string `json:"emoji,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
type MessagePartType ¶
type MessagePartType string
const ( MessagePartText MessagePartType = "text" MessagePartLink MessagePartType = "link" MessagePartCodeBlock MessagePartType = "code_block" MessagePartMention MessagePartType = "mention" MessagePartEmoji MessagePartType = "emoji" MessagePartHeading MessagePartType = "heading" MessagePartBlockquote MessagePartType = "blockquote" MessagePartListItem MessagePartType = "list_item" )
type MessageTextStyle ¶
type MessageTextStyle string
const ( MessageStyleBold MessageTextStyle = "bold" MessageStyleItalic MessageTextStyle = "italic" MessageStyleStrikethrough MessageTextStyle = "strikethrough" MessageStyleCode MessageTextStyle = "code" MessageStyleUnderline MessageTextStyle = "underline" MessageStyleSpoiler MessageTextStyle = "spoiler" )
type Platform ¶
type Platform string
Platform is the delivery platform identifier used by Agent-facing messaging ports. Channel adapters translate it to their own ChannelType.
type ReactRequest ¶
type ReactResult ¶
type ReactResult struct {
BotID string
Platform string
Target string
MessageID string
Emoji string
Action string // "added" or "removed"
Local bool
Remove bool
}
ReactResult is the success payload returned after reacting.
type ReplyRef ¶
type ReplyRef struct {
Target string `json:"target,omitempty"`
MessageID string `json:"message_id,omitempty"`
Sender string `json:"sender,omitempty"`
Preview string `json:"preview,omitempty"`
Attachments []Attachment `json:"attachments,omitempty"`
AttachmentsKnown bool `json:"attachments_known,omitempty"`
}
type SendRequest ¶
type SendResult ¶
type SendResult struct {
BotID string
Platform string
Target string
MessageID string
// Local is true when the message targets the current conversation.
// The caller should emit the resolved attachments as stream events.
Local bool
LocalAttachments []Attachment
// LocalTextOmitted is true when the local shortcut delivered the
// attachments but dropped accompanying text/parts; the caller should tell
// the model to restate that text in its assistant reply.
LocalTextOmitted bool
}
SendResult is the success payload returned after sending a message.