im

package
v1.1.37 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const PCInviteURIPrefix = "privateclaw://connect?payload="

Variables

View Source
var (
	ErrNoSessionBound       = errors.New("no active session bound")
	ErrNoChannelBound       = errors.New("no channel bound for active workspace")
	ErrNoBridge             = errors.New("no IM bridge configured")
	ErrApprovalNotFound     = errors.New("approval not found")
	ErrAdapterAlreadyBound  = errors.New("adapter already bound to another workspace")
	ErrInboundChannelDenied = errors.New("inbound message does not match active binding")
	ErrNoPendingPairing     = errors.New("no pending pairing challenge")
)

Functions

func BuildAskUserResponse added in v1.1.34

func BuildAskUserResponse(req toolpkg.AskUserRequest, parsed []ParsedQuestionAnswer) toolpkg.AskUserResponse

BuildAskUserResponse builds an AskUserResponse from parsed per-question answers. This is the shared implementation used by daemon (and can be used by TUI).

func DefaultBindingsPath

func DefaultBindingsPath() (string, error)

func DefaultPCSessionStorePath added in v1.1.34

func DefaultPCSessionStorePath() (string, error)

func DefaultPairingStatePath

func DefaultPairingStatePath() (string, error)

func EscapeMarkdownV2 added in v1.1.34

func EscapeMarkdownV2(text string) string

EscapeMarkdownV2 converts plain or markdown text to Telegram MarkdownV2 safe text.

It preserves markdown formatting structures (bold, italic, strikethrough, code, code blocks, links, images) while escaping all other MarkdownV2 special characters.

func FormatAskUserPrompt added in v1.1.34

func FormatAskUserPrompt(lang string, req toolpkg.AskUserRequest) string

FormatAskUserPrompt formats an AskUserRequest into an IM-friendly prompt with per-question-type reply guidance. Shared by TUI and daemon modes.

func FormatIMStatus added in v1.1.34

func FormatIMStatus(lang ToolLanguage, activity, toolName, toolArg string) string

FormatIMStatus produces the final status string for IM delivery, mirroring the TUI's formatIMStatus pipeline:

describeTool → formatToolInline → localizeIMProgress

func FormatToolInline added in v1.1.34

func FormatToolInline(name, detail string) string

FormatToolInline formats a tool name and detail as an inline status string, e.g. "读 chart.html" or just "编辑" if detail is trivial.

func IsLocalFilePath added in v1.1.34

func IsLocalFilePath(s string) bool

IsLocalFilePath checks if a string looks like a local file path.

func LastMessageID added in v1.1.34

func LastMessageID(b ChannelBinding) string

LastMessageID returns the most recent message ID for typing reaction targeting: prefers the user's inbound message, falls back to the bot's last outbound message.

func LocalizeIMProgress added in v1.1.34

func LocalizeIMProgress(lang ToolLanguage, text string) string

LocalizeIMProgress applies language-specific localization to an IM progress string, mirroring the TUI's localizeIMProgress function.

func PCEncodeInviteToURI added in v1.1.34

func PCEncodeInviteToURI(invite PCInvite) (string, error)

PCEncodeInviteToURI encodes an invite into a privateclaw:// URI (exported for TUI).

func ParseRemoteQuestionnaireAnswer added in v1.1.34

func ParseRemoteQuestionnaireAnswer(raw string, question toolpkg.AskUserQuestion) (selected map[string]struct{}, freeform string, err error)

ParseRemoteQuestionnaireAnswer parses a raw IM text reply against a single question definition. It returns the selected choice IDs (for single/multi), a freeform text (for text or unmatched input), and whether parsing succeeded.

This is the shared implementation used by both TUI and daemon modes.

func SplitNonEmptyLines added in v1.1.34

func SplitNonEmptyLines(text string) []string

SplitNonEmptyLines splits text into non-empty trimmed lines.

func StartNamedAdapter

func StartNamedAdapter(parent context.Context, cfg config.IMConfig, name string, mgr *Manager) error

Types

type AdapterController

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

func StartConfiguredAdapters

func StartConfiguredAdapters(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)

func StartCurrentBindingAdapter

func StartCurrentBindingAdapter(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)

func StartPCAdapterOnly added in v1.1.34

func StartPCAdapterOnly(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)

StartPCAdapterOnly starts only the built-in PrivateClaw adapter. Used when IM is not explicitly enabled but PC should still be available.

func (*AdapterController) Stop

func (c *AdapterController) Stop()

type AdapterDescriptor

type AdapterDescriptor struct {
	Name         string
	Platform     Platform
	Capabilities []string
}

type AdapterState

type AdapterState struct {
	Name      string
	Platform  Platform
	Healthy   bool
	Status    string
	LastError string
	UpdatedAt time.Time
}

type ApprovalRequest

type ApprovalRequest struct {
	ID          string
	ToolName    string
	Input       string
	RequestedAt time.Time
	Source      string
}

type ApprovalResponse

type ApprovalResponse struct {
	ApprovalID  string
	Decision    permission.Decision
	RespondedBy string
	RespondedAt time.Time
}

type ApprovalResult

type ApprovalResult struct {
	Request     ApprovalRequest
	Decision    permission.Decision
	RespondedBy string
	RespondedAt time.Time
}

type ApprovalState

type ApprovalState struct {
	Request     ApprovalRequest
	Resolved    bool
	Decision    permission.Decision
	RespondedBy string
	RespondedAt time.Time
}

type Attachment

type Attachment struct {
	ID         string
	Kind       AttachmentKind
	Name       string
	MIME       string
	Path       string
	URL        string
	DataBase64 string
	Transcript string
	Metadata   map[string]string
}

type AttachmentKind

type AttachmentKind string
const (
	AttachmentImage AttachmentKind = "image"
	AttachmentVoice AttachmentKind = "voice"
	AttachmentAudio AttachmentKind = "audio"
	AttachmentFile  AttachmentKind = "file"
)

type BindingStore

type BindingStore interface {
	Save(binding ChannelBinding) error
	Delete(workspace, adapter string) error
	List() ([]ChannelBinding, error)
	ListByWorkspace(workspace string) ([]ChannelBinding, error)
	ListByAdapter(adapter string) ([]ChannelBinding, error)
}

BindingStore persists channel bindings keyed by (workspace, adapter).

type Bridge

type Bridge interface {
	SubmitInboundMessage(ctx context.Context, msg InboundMessage) error
}

type ChannelBinding

type ChannelBinding struct {
	Workspace             string
	Platform              Platform
	Adapter               string
	TargetID              string
	ChannelID             string
	ThreadID              string
	LastInboundMessageID  string
	LastOutboundMessageID string
	LastInboundAt         time.Time
	PassiveReplyCount     int
	PassiveReplyStartedAt time.Time
	BoundAt               time.Time
}

type DaemonBridge added in v1.1.34

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

DaemonBridge implements the Bridge interface for headless (daemon) mode. IM inbound messages are submitted directly to the agent without a TUI.

func NewDaemonBridge added in v1.1.34

func NewDaemonBridge(mgr *Manager, ag *agent.Agent, emitter *IMEmitter, store session.Store, sess *session.Session) *DaemonBridge

NewDaemonBridge creates a bridge that submits IM messages directly to the agent.

func (*DaemonBridge) HandleAskUser added in v1.1.34

HandleAskUser is the AskUserHandler for daemon mode — sends question to IM and blocks until the user replies via IM.

func (*DaemonBridge) SetFollowSink added in v1.1.34

func (b *DaemonBridge) SetFollowSink(sink daemon.FollowSink)

SetFollowSink sets or clears the follow-mode display sink.

func (*DaemonBridge) SubmitInboundMessage added in v1.1.34

func (b *DaemonBridge) SubmitInboundMessage(ctx context.Context, msg InboundMessage) error

SubmitInboundMessage handles an inbound IM message by submitting it to the agent.

type Envelope

type Envelope struct {
	Adapter    string
	Platform   Platform
	ChannelID  string
	ThreadID   string
	SenderID   string
	SenderName string
	MessageID  string
	ReceivedAt time.Time
}

type ExtractedImage added in v1.1.34

type ExtractedImage struct {
	Kind string // "url", "data_url", "local_path"
	Data string // URL, base64 data URL, or local file path
}

ExtractedImage represents an image found in message text.

func ExtractImagesFromText added in v1.1.34

func ExtractImagesFromText(text string) ([]ExtractedImage, string)

ExtractImagesFromText finds markdown images, bare image URLs, and data URLs in text. Returns extracted images and the text with image references replaced by their alt text (for markdown images) or removed (for bare URLs and data URLs). Line breaks are preserved.

type IMEmitter added in v1.1.34

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

IMEmitter handles asynchronous outbound IM event emission with typing keepalive. It is framework-agnostic and can be used by both TUI and daemon modes.

func NewIMEmitter added in v1.1.34

func NewIMEmitter(mgr *Manager, lang, workDir string) *IMEmitter

NewIMEmitter creates a new IM emitter for the given manager, language, and working directory.

func (*IMEmitter) EmitAskUser added in v1.1.34

func (e *IMEmitter) EmitAskUser(text string)

EmitAskUser sends an ask_user prompt to IM.

func (*IMEmitter) EmitEvent added in v1.1.34

func (e *IMEmitter) EmitEvent(event OutboundEvent)

EmitEvent sends a raw outbound event to all bound IM channels.

func (*IMEmitter) EmitRoundSummary added in v1.1.34

func (e *IMEmitter) EmitRoundSummary(text string, toolCalls, toolSuccesses, toolFailures int)

EmitRoundSummary sends the final round text to IM.

func (*IMEmitter) EmitStatus added in v1.1.34

func (e *IMEmitter) EmitStatus(status string)

EmitStatus sends a status update to IM. Duplicate consecutive statuses are suppressed.

func (*IMEmitter) EmitText added in v1.1.34

func (e *IMEmitter) EmitText(text string)

EmitText sends a text message to IM.

func (*IMEmitter) EmitToolStatus added in v1.1.34

func (e *IMEmitter) EmitToolStatus(toolName, rawArgs string)

EmitToolStatus formats and sends a tool execution status using the shared DescribeTool pipeline.

func (*IMEmitter) EmitUserText added in v1.1.34

func (e *IMEmitter) EmitUserText(text string)

EmitUserText sends a user echo message to IM.

func (*IMEmitter) EmitUserTextExcept added in v1.1.34

func (e *IMEmitter) EmitUserTextExcept(text, excludeAdapter string)

EmitUserTextExcept sends a user echo message to all bound IM channels except the originating adapter. This prevents the user from seeing their own message echoed back on the channel they sent from.

func (*IMEmitter) FormatAskUserPrompt added in v1.1.34

func (e *IMEmitter) FormatAskUserPrompt(rawArgs string) string

FormatAskUserPrompt formats an ask_user request as an IM-friendly prompt string. Delegates to the shared FormatAskUserPrompt in ask_user_format.go.

func (*IMEmitter) Language added in v1.1.34

func (e *IMEmitter) Language() string

Language returns the emitter's configured language.

func (*IMEmitter) TriggerTyping added in v1.1.34

func (e *IMEmitter) TriggerTyping()

TriggerTyping sends typing indicators to all bound adapters with keepalive throttling.

type InboundMessage

type InboundMessage struct {
	Envelope    Envelope
	Text        string
	Attachments []Attachment
	Metadata    map[string]string
}

func (InboundMessage) ProviderContent

func (m InboundMessage) ProviderContent() []provider.ContentBlock

type JSONFileBindingStore

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

JSONFileBindingStore persists bindings to a JSON file with atomic writes.

func NewJSONFileBindingStore

func NewJSONFileBindingStore(path string) (*JSONFileBindingStore, error)

func (*JSONFileBindingStore) Delete

func (s *JSONFileBindingStore) Delete(workspace, adapter string) error

func (*JSONFileBindingStore) List

func (s *JSONFileBindingStore) List() ([]ChannelBinding, error)

func (*JSONFileBindingStore) ListByAdapter added in v1.1.34

func (s *JSONFileBindingStore) ListByAdapter(adapter string) ([]ChannelBinding, error)

func (*JSONFileBindingStore) ListByWorkspace added in v1.1.34

func (s *JSONFileBindingStore) ListByWorkspace(workspace string) ([]ChannelBinding, error)

func (*JSONFileBindingStore) Save

func (s *JSONFileBindingStore) Save(binding ChannelBinding) error

type JSONFilePCSessionStore added in v1.1.34

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

JSONFilePCSessionStore persists PC sessions to a JSON file.

func NewJSONFilePCSessionStore added in v1.1.34

func NewJSONFilePCSessionStore(path string) (*JSONFilePCSessionStore, error)

func (*JSONFilePCSessionStore) LoadAll added in v1.1.34

func (s *JSONFilePCSessionStore) LoadAll() ([]pcPersistedSession, error)

func (*JSONFilePCSessionStore) SaveAll added in v1.1.34

func (s *JSONFilePCSessionStore) SaveAll(sessions []pcPersistedSession) error

type JSONFilePairingStore

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

func NewJSONFilePairingStore

func NewJSONFilePairingStore(path string) (*JSONFilePairingStore, error)

func (*JSONFilePairingStore) LoadAll

func (*JSONFilePairingStore) SaveAll

func (s *JSONFilePairingStore) SaveAll(states map[string]PairingChannelState) error

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) ActiveSession

func (m *Manager) ActiveSession() *SessionBinding

func (*Manager) BindChannel

func (m *Manager) BindChannel(binding ChannelBinding) (ChannelBinding, error)

func (*Manager) BindSession

func (m *Manager) BindSession(binding SessionBinding)

func (*Manager) ClearChannel

func (m *Manager) ClearChannel(workspace string) error

func (*Manager) ClearChannelByAdapter added in v1.1.34

func (m *Manager) ClearChannelByAdapter(adapterName string) error

func (*Manager) ClearReplyWindow

func (m *Manager) ClearReplyWindow(workspace string) error

func (*Manager) CurrentBinding

func (m *Manager) CurrentBinding() *ChannelBinding

func (*Manager) CurrentBindings added in v1.1.34

func (m *Manager) CurrentBindings() []ChannelBinding

func (*Manager) DisableBinding added in v1.1.35

func (m *Manager) DisableBinding(adapterName string) error

DisableBinding temporarily disables an adapter's binding for the current session. The binding is moved from currentBindings to disabledBindings, so it will no longer receive outbound messages and inbound messages will be rejected. The persistent binding is NOT deleted, so it can be re-enabled later.

func (*Manager) DisabledBindings added in v1.1.35

func (m *Manager) DisabledBindings() []ChannelBinding

DisabledBindings returns a snapshot of currently disabled bindings.

func (*Manager) Emit

func (m *Manager) Emit(ctx context.Context, event OutboundEvent) error

func (*Manager) EmitExcept added in v1.1.34

func (m *Manager) EmitExcept(ctx context.Context, event OutboundEvent, excludeAdapter string) error

EmitExcept sends an event to all bound channels except those matching excludeAdapter. This is used to suppress user mirror echo on the originating IM channel while still delivering it to other bound channels.

func (*Manager) EnableBinding added in v1.1.35

func (m *Manager) EnableBinding(adapterName string) error

EnableBinding re-enables a previously disabled adapter binding. The binding is moved back to currentBindings so it resumes receiving messages.

func (m *Manager) GenerateShareLink(ctx context.Context, adapter, callbackData string) (string, error)

func (*Manager) HandleInbound

func (m *Manager) HandleInbound(ctx context.Context, msg InboundMessage) error

func (*Manager) HandlePairingInbound

func (m *Manager) HandlePairingInbound(msg InboundMessage) (PairingResult, error)

func (*Manager) IsBindingDisabled added in v1.1.35

func (m *Manager) IsBindingDisabled(adapterName string) bool

IsBindingDisabled returns true if the given adapter's binding is currently disabled.

func (*Manager) ListBindings

func (m *Manager) ListBindings() ([]ChannelBinding, error)

func (*Manager) PCAdapter added in v1.1.34

func (m *Manager) PCAdapter() PCAdapterAPI

PCAdapter returns the first registered PrivateClaw adapter, or nil.

func (*Manager) PublishAdapterState

func (m *Manager) PublishAdapterState(state AdapterState)

func (*Manager) RecordOutboundMessage added in v1.1.34

func (m *Manager) RecordOutboundMessage(workspace, adapter, messageID string) error

RecordOutboundMessage records the message ID of a bot reply so that typing indicator reactions can target it when no inbound message exists.

func (*Manager) RecordPassiveReply

func (m *Manager) RecordPassiveReply(workspace, messageID string, sentAt time.Time) error

func (*Manager) RegisterApproval

func (m *Manager) RegisterApproval(req ApprovalRequest) (ApprovalRequest, <-chan permission.Decision)

func (*Manager) RegisterSink

func (m *Manager) RegisterSink(sink Sink)

func (*Manager) RejectPendingPairing

func (m *Manager) RejectPendingPairing() (*PairingChallenge, bool, error)

func (*Manager) ResolveApproval

func (m *Manager) ResolveApproval(resp ApprovalResponse) (ApprovalResult, bool, error)

func (*Manager) SendDirect

func (m *Manager) SendDirect(ctx context.Context, binding ChannelBinding, event OutboundEvent) error

func (*Manager) SetBindingStore

func (m *Manager) SetBindingStore(store BindingStore) error

func (*Manager) SetBridge

func (m *Manager) SetBridge(bridge Bridge)

func (*Manager) SetOnUpdate

func (m *Manager) SetOnUpdate(cb func(StatusSnapshot))

func (*Manager) SetPairingStore

func (m *Manager) SetPairingStore(store PairingStateStore) error

func (*Manager) Snapshot

func (m *Manager) Snapshot() StatusSnapshot

func (*Manager) SyncSessionHistory

func (m *Manager) SyncSessionHistory(ctx context.Context, messages []provider.Message) error

func (*Manager) TriggerTyping added in v1.1.34

func (m *Manager) TriggerTyping(ctx context.Context)

TriggerTyping sends a typing indicator to all bound adapters that implement the TypingIndicator interface.

func (*Manager) UnbindAdapter added in v1.1.34

func (m *Manager) UnbindAdapter(adapterName string) error

UnbindAdapter removes the binding for whatever workspace has the given adapter name. This is needed when unbinding from a panel where the current session workspace may differ from the workspace that originally bound the adapter. Returns ErrNoChannelBound if no binding uses this adapter.

func (*Manager) UnbindChannel

func (m *Manager) UnbindChannel(workspace string) error

func (*Manager) UnbindSession

func (m *Manager) UnbindSession()

func (*Manager) UnregisterSink

func (m *Manager) UnregisterSink(name string)

type MemoryBindingStore

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

MemoryBindingStore is an in-memory BindingStore for tests.

func NewMemoryBindingStore

func NewMemoryBindingStore() *MemoryBindingStore

func (*MemoryBindingStore) Delete

func (s *MemoryBindingStore) Delete(workspace, adapter string) error

func (*MemoryBindingStore) List

func (s *MemoryBindingStore) List() ([]ChannelBinding, error)

func (*MemoryBindingStore) ListByAdapter added in v1.1.34

func (s *MemoryBindingStore) ListByAdapter(adapter string) ([]ChannelBinding, error)

func (*MemoryBindingStore) ListByWorkspace added in v1.1.34

func (s *MemoryBindingStore) ListByWorkspace(workspace string) ([]ChannelBinding, error)

func (*MemoryBindingStore) Save

func (s *MemoryBindingStore) Save(binding ChannelBinding) error

type MemoryPCSessionStore added in v1.1.34

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

MemoryPCSessionStore is an in-memory PC session store for testing.

func NewMemoryPCSessionStore added in v1.1.34

func NewMemoryPCSessionStore() *MemoryPCSessionStore

func (*MemoryPCSessionStore) LoadAll added in v1.1.34

func (s *MemoryPCSessionStore) LoadAll() ([]pcPersistedSession, error)

func (*MemoryPCSessionStore) SaveAll added in v1.1.34

func (s *MemoryPCSessionStore) SaveAll(sessions []pcPersistedSession) error

type MemoryPairingStore

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

func NewMemoryPairingStore

func NewMemoryPairingStore() *MemoryPairingStore

func (*MemoryPairingStore) LoadAll

func (s *MemoryPairingStore) LoadAll() (map[string]PairingChannelState, error)

func (*MemoryPairingStore) SaveAll

func (s *MemoryPairingStore) SaveAll(states map[string]PairingChannelState) error

type OutboundEvent

type OutboundEvent struct {
	Kind      OutboundEventKind
	Text      string
	Status    string
	ToolCall  *ToolCallInfo
	ToolRes   *ToolResultInfo
	Approval  *ApprovalRequest
	Result    *ApprovalResult
	CreatedAt time.Time
}

func SessionHistoryEvents

func SessionHistoryEvents(messages []provider.Message) []OutboundEvent

type OutboundEventKind

type OutboundEventKind string
const (
	OutboundEventText            OutboundEventKind = "text"
	OutboundEventStatus          OutboundEventKind = "status"
	OutboundEventToolCall        OutboundEventKind = "tool_call"
	OutboundEventToolResult      OutboundEventKind = "tool_result"
	OutboundEventApprovalRequest OutboundEventKind = "approval_request"
	OutboundEventApprovalResult  OutboundEventKind = "approval_result"
)

type PCAdapterAPI added in v1.1.34

type PCAdapterAPI interface {
	CreateSession(ctx context.Context, label string, groupMode bool) (*PCInvite, string, error)
	ListSessions() []PCSessionInfo
	GetSession(sessionID string) (*pcSession, bool)
	CloseSession(sessionID string) error
	RenewSession(ctx context.Context, sessionID string) error
	GetInviteURI(sessionID string) (string, error)
	KickParticipant(sessionID, appID string) error
}

PCAdapterAPI is the exported interface for PrivateClaw adapter operations (used by TUI).

type PCInvite added in v1.1.34

type PCInvite struct {
	Version       int    `json:"version"`
	SessionID     string `json:"sessionId"`
	SessionKey    string `json:"sessionKey"`
	AppWsURL      string `json:"appWsUrl"`
	ExpiresAt     string `json:"expiresAt"`
	GroupMode     bool   `json:"groupMode,omitempty"`
	ProviderLabel string `json:"providerLabel,omitempty"`
	RelayLabel    string `json:"relayLabel,omitempty"`
}

type PCSessionInfo added in v1.1.34

type PCSessionInfo struct {
	SessionID        string
	State            string
	GroupMode        bool
	Label            string
	ParticipantCount int
	ExpiresAt        time.Time
}

PCSessionInfo is a summary of a session for TUI display.

type PCSessionStore added in v1.1.34

type PCSessionStore interface {
	LoadAll() ([]pcPersistedSession, error)
	SaveAll(sessions []pcPersistedSession) error
}

PCSessionStore persists PC session data across restarts.

type PairingChallenge

type PairingChallenge struct {
	Kind                 PairingKind
	Workspace            string
	Adapter              string
	Platform             Platform
	ChannelID            string
	ThreadID             string
	SenderID             string
	SenderName           string
	Code                 string
	RequestedAt          time.Time
	LastInboundMessageID string
	LastInboundAt        time.Time
	ExistingBinding      *ChannelBinding
}

func (PairingChallenge) ReplyBinding

func (c PairingChallenge) ReplyBinding() ChannelBinding

type PairingChannelState

type PairingChannelState struct {
	Adapter       string
	Platform      Platform
	ChannelID     string
	RejectCount   int
	BlacklistedAt time.Time
	UpdatedAt     time.Time
}

func (PairingChannelState) IsBlacklisted

func (s PairingChannelState) IsBlacklisted() bool

type PairingKind

type PairingKind string
const (
	PairingKindBind   PairingKind = "bind"
	PairingKindRebind PairingKind = "rebind"
)

type PairingResult

type PairingResult struct {
	Consumed        bool
	Kind            PairingKind
	ReplyText       string
	Bound           bool
	PreviousBinding *ChannelBinding
	NewBinding      *ChannelBinding
}

type PairingStateStore

type PairingStateStore interface {
	LoadAll() (map[string]PairingChannelState, error)
	SaveAll(map[string]PairingChannelState) error
}

type ParsedQuestionAnswer added in v1.1.34

type ParsedQuestionAnswer struct {
	QuestionIndex int
	Selected      map[string]struct{}
	Freeform      string
	Error         error
}

ParsedQuestionAnswer holds the result of parsing a single question's reply.

func ParseMultiQuestionReply added in v1.1.34

func ParseMultiQuestionReply(raw string, questions []toolpkg.AskUserQuestion) []ParsedQuestionAnswer

ParseMultiQuestionReply splits a multi-line IM reply into per-question answers and parses each one. It returns a slice of results in the same order as the questions slice. If there are fewer lines than questions, remaining questions are left unanswered (empty results).

This is the shared implementation used by both TUI and daemon modes.

type Platform

type Platform string
const (
	PlatformUnknown  Platform = ""
	PlatformQQ       Platform = "qq"
	PlatformTelegram Platform = "telegram"
	PlatformDiscord  Platform = "discord"
	PlatformFeishu   Platform = "feishu"
	PlatformDingTalk Platform = "dingtalk"
	PlatformSlack    Platform = "slack"
)
const PlatformPrivateClaw Platform = "privateclaw"

type SessionBinding

type SessionBinding struct {
	SessionID string
	Workspace string
	BoundAt   time.Time
}

type ShareLinkProvider

type ShareLinkProvider interface {
	GenerateShareLink(context.Context, string) (string, error)
}

type Sink

type Sink interface {
	Name() string
	Send(context.Context, ChannelBinding, OutboundEvent) error
}

type StatusSnapshot

type StatusSnapshot struct {
	ActiveSession    *SessionBinding
	CurrentBindings  []ChannelBinding
	DisabledBindings []ChannelBinding
	PendingPairing   *PairingChallenge
	Adapters         []AdapterState
	PendingApprovals []ApprovalState
}

type ToolCallInfo added in v1.1.34

type ToolCallInfo struct {
	ToolName string
	Args     string
	Detail   string
}

type ToolLanguage added in v1.1.34

type ToolLanguage string

ToolLanguage represents the language for tool status formatting.

const (
	ToolLangZhCN ToolLanguage = "zh-CN"
	ToolLangEn   ToolLanguage = "en"
)

type ToolPresentation added in v1.1.34

type ToolPresentation struct {
	DisplayName string // e.g. "读", "编辑", "执行"
	Detail      string // e.g. file path, command preview
	Activity    string // e.g. "读取 chart.html", "执行 npm test"
}

ToolPresentation holds the formatted display information for a tool call.

func DescribeTool added in v1.1.34

func DescribeTool(lang ToolLanguage, toolName, rawArgs string) ToolPresentation

DescribeTool produces a human-readable presentation of a tool call, mirroring the TUI's describeTool pipeline (tool_labels.go).

type ToolResultInfo added in v1.1.34

type ToolResultInfo struct {
	ToolName string
	Args     string
	Result   string
	IsError  bool
	Detail   string // display text for the tool call (e.g. command line)
}

type TypingIndicator added in v1.1.34

type TypingIndicator interface {
	TriggerTyping(ctx context.Context, binding ChannelBinding) error
}

TypingIndicator is an optional interface that adapters can implement to show a native "bot is typing" indicator on the IM platform.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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