Documentation
¶
Index ¶
- Constants
- Variables
- func AllowList(allowFrom, userID string) bool
- func FormatAskUserPrompt(question string, options []string) string
- func FormatHelp(commands agentkit.Commands) string
- func FormatPermissionRequest(payload permission.RequestPayload) string
- func FormatUnknownCommand(name string) string
- func InboundFromContent(agentID agentkit.AgentID, sessionID agentkit.SessionID, ...) agentkit.MessageEvent
- func InboundMessage(agentID agentkit.AgentID, sessionID agentkit.SessionID, ...) agentkit.MessageEvent
- func IsImageAttachment(mimeType, filename string) bool
- func IsOldMessage(msgTime time.Time) bool
- func IsSlackChannelID(token string) bool
- func IsSlashCommand(text string) bool
- func MarkdownToSlackMrkdwn(md string) string
- func ModelMessageText(msg agentkit.ModelMessage) string
- func NormalizeDeliverySessionID(ctx context.Context, raw string) agentkit.SessionID
- func NormalizeSlackAPIURL(raw string) (string, error)
- func ParsePermissionCallback(data string) (requestID string, index int, ok bool)
- func ParseSlashCommand(line string) (name, args string, ok bool)
- func PermissionActionValue(index int) string
- func PermissionCallbackData(requestID string, index int) string
- func PermissionDecisionValue(decision string) string
- func PermissionReplyEvent(agentID agentkit.AgentID, sessionID agentkit.SessionID, ...) agentkit.MessageEvent
- func PermissionReplyFromAction(actionVal, userID string, extra map[string]string) (permission.Reply, bool)
- func ReadMediaPart(part agentkit.ContentPart) (data []byte, fileName string, err error)
- func RedactToken(text, token string) string
- func ResolveDomain(raw, defaultDomain string) (string, error)
- func UploadWorkRel() string
- func WarnAllowFromEmpty(platform, allowFrom string)
- type AgentRoutingConfig
- type AudioAttachment
- type ButtonOption
- type Card
- type CardActionLayout
- type CardActions
- type CardBuilder
- func (b *CardBuilder) Build() *Card
- func (b *CardBuilder) ListItemBtnExtra(desc, btnText, btnType, btnValue string, extra map[string]string) *CardBuilder
- func (b *CardBuilder) Markdown(content string) *CardBuilder
- func (b *CardBuilder) Note(text string) *CardBuilder
- func (b *CardBuilder) Title(title, color string) *CardBuilder
- type CardButton
- type CardDivider
- type CardElement
- type CardHeader
- type CardListItem
- type CardMarkdown
- type CardNote
- type CardSelect
- type CardSelectOption
- type ChatMessage
- type DeliveryRoute
- type DeliveryRouteInput
- type FileAttachment
- type ImageAttachment
- type InboundOpts
- type Inbox
- type InteractionOptions
- func (s *InteractionOptions) Clear(sessionID agentkit.SessionID)
- func (s *InteractionOptions) Reply(sessionID agentkit.SessionID, requestID, userID string, index int) (permission.Reply, bool)
- func (s *InteractionOptions) Set(sessionID agentkit.SessionID, requestID string, replies []permission.Reply)
- type MediaSender
- type MessageDedup
- type Outbound
- type ProgressCardEntry
- type ProgressCardEntryKind
- type ProgressCardPayload
- type ProgressCardState
- type SlashContext
- type SlashOutcome
- type SlashOutcomeKind
- type TextSender
Constants ¶
const (
// ProgressCardPayloadPrefix marks a structured payload for card-style progress.
ProgressCardPayloadPrefix = "__cc_connect_progress_card_v1__:"
)
Variables ¶
var ProcessStartTime = time.Now()
ProcessStartTime is set once at process startup. Platforms discard messages created before this time to avoid replay after restart.
Functions ¶
func AllowList ¶
AllowList returns true when userID is permitted by comma-separated allow_from. Empty or "*" means allow all.
func FormatAskUserPrompt ¶
FormatAskUserPrompt formats ask_user question and numbered options for display.
func FormatHelp ¶
FormatHelp renders a plain-text command list for IM platforms.
func FormatPermissionRequest ¶
func FormatPermissionRequest(payload permission.RequestPayload) string
FormatPermissionRequest formats a permission request as assistant-visible text.
func FormatUnknownCommand ¶
FormatUnknownCommand matches cc-connect's unknown slash forwarding notice.
func InboundFromContent ¶
func InboundFromContent(agentID agentkit.AgentID, sessionID agentkit.SessionID, platformID, userID, content, extraContent string, images []ImageAttachment, files []FileAttachment, audio *AudioAttachment, filePaths []string, opts *InboundOpts) agentkit.MessageEvent
InboundFromContent builds a MessageEvent from text and optional media. extraContent is prepended (e.g. quoted reply context). Non-image files are saved under the tenant work dir and referenced in the prompt for the read tool.
func InboundMessage ¶
func IsImageAttachment ¶ added in v0.1.12
IsImageAttachment reports whether an inbound attachment should be sent to the model as vision input instead of a read-tool file path.
func IsOldMessage ¶
IsOldMessage returns true if msgTime is before process start (with grace).
func IsSlackChannelID ¶ added in v0.1.22
IsSlackChannelID reports bare Slack conversation ids (C/G/D + alnum).
func IsSlashCommand ¶
IsSlashCommand reports whether text starts with a slash command.
func MarkdownToSlackMrkdwn ¶
MarkdownToSlackMrkdwn converts standard Markdown to Slack mrkdwn format.
func ModelMessageText ¶
func ModelMessageText(msg agentkit.ModelMessage) string
ModelMessageText joins non-empty text parts from a model message.
func NormalizeDeliverySessionID ¶ added in v0.1.22
NormalizeDeliverySessionID maps slash-style targets to delivery session ids.
func NormalizeSlackAPIURL ¶
NormalizeSlackAPIURL returns a slack-go compatible Web API base URL (trailing slash). Bare host URLs are normalized to end with /api/ like cc-connect.
func ParsePermissionCallback ¶
ParsePermissionCallback decodes Telegram callback_data.
func ParseSlashCommand ¶
ParseSlashCommand splits "/name args" into name and args.
func PermissionActionValue ¶
PermissionActionValue is the short action token stored in card button values.
func PermissionCallbackData ¶
PermissionCallbackData builds Telegram callback_data (perm:<requestID>:<index>).
func PermissionDecisionValue ¶
PermissionDecisionValue is the action token stored in allow/deny card buttons.
func PermissionReplyEvent ¶
func PermissionReplyEvent(agentID agentkit.AgentID, sessionID agentkit.SessionID, platformID, userID string, reply permission.Reply) agentkit.MessageEvent
func PermissionReplyFromAction ¶
func PermissionReplyFromAction(actionVal, userID string, extra map[string]string) (permission.Reply, bool)
PermissionReplyFromAction extracts a typed permission reply from card callback payloads.
func ReadMediaPart ¶ added in v0.1.6
func ReadMediaPart(part agentkit.ContentPart) (data []byte, fileName string, err error)
ReadMediaPart loads bytes for an outbound image or document content part. tool/send stores the resolved workspace path in URL.
func RedactToken ¶
RedactToken replaces a secret token in text with [REDACTED].
func ResolveDomain ¶
ResolveDomain returns trimmed raw when set, otherwise defaultDomain. Empty raw after trim uses defaultDomain without validation.
func UploadWorkRel ¶ added in v0.1.6
func UploadWorkRel() string
UploadWorkRel is the workspace-relative upload directory (under tool/fs-workspace root).
func WarnAllowFromEmpty ¶
func WarnAllowFromEmpty(platform, allowFrom string)
WarnAllowFromEmpty logs when allow_from is unset (permit-all).
Types ¶
type AgentRoutingConfig ¶
type AgentRoutingConfig struct {
AgentID agentkit.AgentID `json:"agentId"`
// SessionScope mirrors runner.config.sessionScope for platform-local slash
// commands (/new active-session mapping). Empty defaults to channel.
SessionScope string `json:"sessionScope"`
}
AgentRoutingConfig optionally pins inbound messages to a Loop agent. Empty agentId uses loop.defaultAgent.
func (AgentRoutingConfig) ResolveAgentID ¶
func (c AgentRoutingConfig) ResolveAgentID() agentkit.AgentID
type AudioAttachment ¶
AudioAttachment is an inbound voice message.
type ButtonOption ¶
type Card ¶
type Card struct {
Header *CardHeader
Elements []CardElement
Static bool // true after user answered; renderers must not emit interactive controls
}
Card is a platform-agnostic rich message (Slack Block Kit, Feishu interactive card, etc.).
func ConfirmedAllowDenyCard ¶ added in v0.1.12
ConfirmedAllowDenyCard updates an allow/deny card after the user decides.
func ConfirmedCardFromReply ¶ added in v0.1.12
func ConfirmedCardFromReply(reply permission.Reply, extra map[string]string) *Card
ConfirmedCardFromReply builds a non-interactive card after the user responds.
func ConfirmedPermissionCard ¶
ConfirmedPermissionCard updates the card after the user picks an option.
func PermissionCardFromPayload ¶
func PermissionCardFromPayload(payload permission.RequestPayload) *Card
PermissionCardFromPayload builds a card from Loop permission/request payload.
func (*Card) CollectButtons ¶
func (c *Card) CollectButtons() [][]ButtonOption
CollectButtons flattens list-item buttons for Telegram inline keyboards.
func (*Card) FallbackText ¶
type CardActionLayout ¶
type CardActionLayout string
const ( CardActionLayoutRow CardActionLayout = "row" CardActionLayoutEqualColumns CardActionLayout = "equal_columns" )
type CardActions ¶
type CardActions struct {
Buttons []CardButton
Layout CardActionLayout
}
type CardBuilder ¶
type CardBuilder struct {
// contains filtered or unexported fields
}
func NewCard ¶
func NewCard() *CardBuilder
func (*CardBuilder) Build ¶
func (b *CardBuilder) Build() *Card
func (*CardBuilder) ListItemBtnExtra ¶
func (b *CardBuilder) ListItemBtnExtra(desc, btnText, btnType, btnValue string, extra map[string]string) *CardBuilder
func (*CardBuilder) Markdown ¶
func (b *CardBuilder) Markdown(content string) *CardBuilder
func (*CardBuilder) Note ¶
func (b *CardBuilder) Note(text string) *CardBuilder
func (*CardBuilder) Title ¶
func (b *CardBuilder) Title(title, color string) *CardBuilder
type CardButton ¶
type CardDivider ¶
type CardDivider struct{}
type CardElement ¶
type CardElement interface {
// contains filtered or unexported methods
}
type CardHeader ¶
type CardListItem ¶
type CardMarkdown ¶
type CardMarkdown struct{ Content string }
type CardSelect ¶
type CardSelect struct {
Placeholder string
Options []CardSelectOption
InitValue string
}
type CardSelectOption ¶
type ChatMessage ¶
ChatMessage is a user-facing message derived from session events for IM / history UIs.
func MessageFromEvent ¶
func MessageFromEvent(ev agentkit.SessionEvent) *ChatMessage
MessageFromEvent maps one session event to a chat message when applicable.
func MessagesFromEvents ¶
func MessagesFromEvents(events []agentkit.SessionEvent) []ChatMessage
MessagesFromEvents derives chat-visible messages from session events.
func MessagesFromSession ¶
MessagesFromSession reads all session events and derives chat-visible messages.
type DeliveryRoute ¶ added in v0.1.22
type DeliveryRoute struct {
SessionID agentkit.SessionID
AgentID agentkit.AgentID
PlatformID string
UserID string
}
DeliveryRoute is the resolved outbound/inbox target for platform tools.
func ResolveDeliveryRoute ¶ added in v0.1.22
func ResolveDeliveryRoute(ctx context.Context, input DeliveryRouteInput) (DeliveryRoute, error)
ResolveDeliveryRoute resolves the delivery session and platform from context.
type DeliveryRouteInput ¶ added in v0.1.22
DeliveryRouteInput is shared by send, chat_history, and similar tools.
type FileAttachment ¶
FileAttachment is an inbound file from an IM platform.
type ImageAttachment ¶
type ImageAttachment struct {
MimeType string
Data []byte
FileName string
// WorkPath is workspace-relative under work/ (e.g. upload/foo.png).
WorkPath string
}
ImageAttachment is an inbound image from an IM platform.
type InboundOpts ¶ added in v0.1.6
type InboundOpts struct {
// Workspace resolves upload paths; when set, inbound files land under the
// same tenant root as session/store and tool/fs-workspace.
Workspace workspace.Service
}
InboundOpts configures optional inbound media handling.
func InboundOptsFor ¶ added in v0.1.6
func InboundOptsFor(ws workspace.Service) *InboundOpts
InboundOptsFor builds inbound media options from an optional workspace.
type Inbox ¶
type Inbox struct {
// contains filtered or unexported fields
}
Inbox bridges async platform events into blocking Receive.
type InteractionOptions ¶
type InteractionOptions struct {
// contains filtered or unexported fields
}
InteractionOptions remembers option labels for platforms with short callback payloads (Telegram).
func (*InteractionOptions) Clear ¶
func (s *InteractionOptions) Clear(sessionID agentkit.SessionID)
func (*InteractionOptions) Reply ¶
func (s *InteractionOptions) Reply(sessionID agentkit.SessionID, requestID, userID string, index int) (permission.Reply, bool)
func (*InteractionOptions) Set ¶
func (s *InteractionOptions) Set(sessionID agentkit.SessionID, requestID string, replies []permission.Reply)
type MediaSender ¶ added in v0.1.6
type MediaSender func(ctx context.Context, sessionID agentkit.SessionID, part agentkit.ContentPart) error
MediaSender delivers a non-text assistant content part (image or document).
type MessageDedup ¶
type MessageDedup struct {
// contains filtered or unexported fields
}
MessageDedup tracks recently seen message IDs to prevent duplicate processing.
func (*MessageDedup) IsDuplicate ¶
func (d *MessageDedup) IsDuplicate(msgID string) bool
IsDuplicate returns true if msgID was already seen within the TTL window.
type Outbound ¶
type Outbound struct {
// contains filtered or unexported fields
}
Outbound handles agentkit outbound events with per-session text buffering.
func NewOutbound ¶
func NewOutbound(send TextSender, media MediaSender) *Outbound
type ProgressCardEntry ¶
type ProgressCardEntryKind ¶
type ProgressCardEntryKind string
const ( ProgressEntryInfo ProgressCardEntryKind = "info" ProgressEntryThinking ProgressCardEntryKind = "thinking" ProgressEntryToolUse ProgressCardEntryKind = "tool_use" ProgressEntryToolResult ProgressCardEntryKind = "tool_result" ProgressEntryError ProgressCardEntryKind = "error" )
type ProgressCardPayload ¶
type ProgressCardPayload struct {
Version int `json:"version,omitempty"`
Agent string `json:"agent,omitempty"`
Lang string `json:"lang,omitempty"`
State ProgressCardState `json:"state,omitempty"`
Entries []string `json:"entries,omitempty"`
Items []ProgressCardEntry `json:"items,omitempty"`
Truncated bool `json:"truncated"`
}
ProgressCardPayload carries structured progress entries for platforms that render custom progress cards.
func ParseProgressCardPayload ¶
func ParseProgressCardPayload(content string) (*ProgressCardPayload, bool)
ParseProgressCardPayload decodes a structured progress payload.
type ProgressCardState ¶
type ProgressCardState string
const ( ProgressCardStateRunning ProgressCardState = "running" ProgressCardStateCompleted ProgressCardState = "completed" ProgressCardStateFailed ProgressCardState = "failed" )
type SlashContext ¶ added in v0.1.6
type SlashContext struct {
DeliverySessionID agentkit.SessionID
PlatformID string
SessionScope session.SessionScope
UserID string
}
SlashContext carries delivery routing and sessionScope for slash commands.
type SlashOutcome ¶
type SlashOutcome struct {
Kind SlashOutcomeKind
Reply string
}
SlashOutcome is the result of ProcessSlash.
func ProcessSlash ¶
func ProcessSlash(ctx context.Context, commands agentkit.Commands, slash SlashContext, text string) (SlashOutcome, error)
ProcessSlash resolves slash commands via the injected commands registry. Non-slash input returns SlashNotCommand.
type SlashOutcomeKind ¶
type SlashOutcomeKind int
SlashOutcomeKind describes how an inbound slash command was resolved.
const ( // SlashNotCommand means the text is not a slash command. SlashNotCommand SlashOutcomeKind = iota // SlashHandled means the platform should reply locally and not enqueue a turn. SlashHandled // SlashForward means the command is unknown; notify the user then forward to the agent. SlashForward )