Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAskUserResponse(req toolpkg.AskUserRequest, parsed []ParsedQuestionAnswer) toolpkg.AskUserResponse
- func DefaultBindingsPath() (string, error)
- func DefaultPCSessionStorePath() (string, error)
- func DefaultPairingStatePath() (string, error)
- func EscapeMarkdownV2(text string) string
- func FormatAskUserPrompt(lang string, req toolpkg.AskUserRequest) string
- func FormatIMStatus(lang ToolLanguage, activity, toolName, toolArg string) string
- func FormatToolInline(name, detail string) string
- func IsLocalFilePath(s string) bool
- func LastMessageID(b ChannelBinding) string
- func LocalizeIMProgress(lang ToolLanguage, text string) string
- func PCEncodeInviteToURI(invite PCInvite) (string, error)
- func ParseRemoteQuestionnaireAnswer(raw string, question toolpkg.AskUserQuestion) (selected map[string]struct{}, freeform string, err error)
- func SplitNonEmptyLines(text string) []string
- func StartNamedAdapter(parent context.Context, cfg config.IMConfig, name string, mgr *Manager) error
- type AdapterController
- func StartConfiguredAdapters(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)
- func StartCurrentBindingAdapter(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)
- func StartPCAdapterOnly(parent context.Context, cfg config.IMConfig, mgr *Manager) (*AdapterController, error)
- type AdapterDescriptor
- type AdapterState
- type ApprovalRequest
- type ApprovalResponse
- type ApprovalResult
- type ApprovalState
- type Attachment
- type AttachmentKind
- type BindingStore
- type Bridge
- type ChannelBinding
- type DaemonBridge
- type Envelope
- type ExtractedImage
- type IMEmitter
- func (e *IMEmitter) EmitAskUser(text string)
- func (e *IMEmitter) EmitEvent(event OutboundEvent)
- func (e *IMEmitter) EmitRoundSummary(text string, toolCalls, toolSuccesses, toolFailures int)
- func (e *IMEmitter) EmitStatus(status string)
- func (e *IMEmitter) EmitText(text string)
- func (e *IMEmitter) EmitToolStatus(toolName, rawArgs string)
- func (e *IMEmitter) EmitUserText(text string)
- func (e *IMEmitter) EmitUserTextExcept(text, excludeAdapter string)
- func (e *IMEmitter) FormatAskUserPrompt(rawArgs string) string
- func (e *IMEmitter) Language() string
- func (e *IMEmitter) TriggerTyping()
- type InboundMessage
- type JSONFileBindingStore
- func (s *JSONFileBindingStore) Delete(workspace, adapter string) error
- func (s *JSONFileBindingStore) List() ([]ChannelBinding, error)
- func (s *JSONFileBindingStore) ListByAdapter(adapter string) ([]ChannelBinding, error)
- func (s *JSONFileBindingStore) ListByWorkspace(workspace string) ([]ChannelBinding, error)
- func (s *JSONFileBindingStore) Save(binding ChannelBinding) error
- type JSONFilePCSessionStore
- type JSONFilePairingStore
- type Manager
- func (m *Manager) ActiveSession() *SessionBinding
- func (m *Manager) BindChannel(binding ChannelBinding) (ChannelBinding, error)
- func (m *Manager) BindSession(binding SessionBinding)
- func (m *Manager) ClearChannel(workspace string) error
- func (m *Manager) ClearChannelByAdapter(adapterName string) error
- func (m *Manager) ClearReplyWindow(workspace string) error
- func (m *Manager) CurrentBinding() *ChannelBinding
- func (m *Manager) CurrentBindings() []ChannelBinding
- func (m *Manager) DisableBinding(adapterName string) error
- func (m *Manager) DisabledBindings() []ChannelBinding
- func (m *Manager) Emit(ctx context.Context, event OutboundEvent) error
- func (m *Manager) EmitExcept(ctx context.Context, event OutboundEvent, excludeAdapter string) error
- func (m *Manager) EnableBinding(adapterName string) error
- func (m *Manager) GenerateShareLink(ctx context.Context, adapter, callbackData string) (string, error)
- func (m *Manager) HandleInbound(ctx context.Context, msg InboundMessage) error
- func (m *Manager) HandlePairingInbound(msg InboundMessage) (PairingResult, error)
- func (m *Manager) IsBindingDisabled(adapterName string) bool
- func (m *Manager) ListBindings() ([]ChannelBinding, error)
- func (m *Manager) PCAdapter() PCAdapterAPI
- func (m *Manager) PublishAdapterState(state AdapterState)
- func (m *Manager) RecordOutboundMessage(workspace, adapter, messageID string) error
- func (m *Manager) RecordPassiveReply(workspace, messageID string, sentAt time.Time) error
- func (m *Manager) RegisterApproval(req ApprovalRequest) (ApprovalRequest, <-chan permission.Decision)
- func (m *Manager) RegisterSink(sink Sink)
- func (m *Manager) RejectPendingPairing() (*PairingChallenge, bool, error)
- func (m *Manager) ResolveApproval(resp ApprovalResponse) (ApprovalResult, bool, error)
- func (m *Manager) SendDirect(ctx context.Context, binding ChannelBinding, event OutboundEvent) error
- func (m *Manager) SetBindingStore(store BindingStore) error
- func (m *Manager) SetBridge(bridge Bridge)
- func (m *Manager) SetOnUpdate(cb func(StatusSnapshot))
- func (m *Manager) SetPairingStore(store PairingStateStore) error
- func (m *Manager) Snapshot() StatusSnapshot
- func (m *Manager) SyncSessionHistory(ctx context.Context, messages []provider.Message) error
- func (m *Manager) TriggerTyping(ctx context.Context)
- func (m *Manager) UnbindAdapter(adapterName string) error
- func (m *Manager) UnbindChannel(workspace string) error
- func (m *Manager) UnbindSession()
- func (m *Manager) UnregisterSink(name string)
- type MemoryBindingStore
- func (s *MemoryBindingStore) Delete(workspace, adapter string) error
- func (s *MemoryBindingStore) List() ([]ChannelBinding, error)
- func (s *MemoryBindingStore) ListByAdapter(adapter string) ([]ChannelBinding, error)
- func (s *MemoryBindingStore) ListByWorkspace(workspace string) ([]ChannelBinding, error)
- func (s *MemoryBindingStore) Save(binding ChannelBinding) error
- type MemoryPCSessionStore
- type MemoryPairingStore
- type OutboundEvent
- type OutboundEventKind
- type PCAdapterAPI
- type PCInvite
- type PCSessionInfo
- type PCSessionStore
- type PairingChallenge
- type PairingChannelState
- type PairingKind
- type PairingResult
- type PairingStateStore
- type ParsedQuestionAnswer
- type Platform
- type SessionBinding
- type ShareLinkProvider
- type Sink
- type StatusSnapshot
- type ToolCallInfo
- type ToolLanguage
- type ToolPresentation
- type ToolResultInfo
- type TypingIndicator
Constants ¶
const PCInviteURIPrefix = "privateclaw://connect?payload="
Variables ¶
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 DefaultPCSessionStorePath ¶ added in v1.1.34
func DefaultPairingStatePath ¶
func EscapeMarkdownV2 ¶ added in v1.1.34
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
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
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
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
SplitNonEmptyLines splits text into non-empty trimmed lines.
Types ¶
type AdapterController ¶
type AdapterController struct {
// contains filtered or unexported fields
}
func StartConfiguredAdapters ¶
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 AdapterState ¶
type ApprovalRequest ¶
type ApprovalResponse ¶
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 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 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
func (b *DaemonBridge) HandleAskUser(ctx context.Context, req toolpkg.AskUserRequest) (toolpkg.AskUserResponse, error)
HandleAskUser is the AskUserHandler for daemon mode — sends questions to IM one at a time and collects answers interactively.
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 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
NewIMEmitter creates a new IM emitter for the given manager, language, and working directory.
func (*IMEmitter) EmitAskUser ¶ added in v1.1.34
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
EmitRoundSummary sends the final round text to IM.
func (*IMEmitter) EmitStatus ¶ added in v1.1.34
EmitStatus sends a status update to IM. Duplicate consecutive statuses are suppressed.
func (*IMEmitter) EmitToolStatus ¶ added in v1.1.34
EmitToolStatus formats and sends a tool execution status using the shared DescribeTool pipeline.
func (*IMEmitter) EmitUserText ¶ added in v1.1.34
EmitUserText sends a user echo message to IM.
func (*IMEmitter) EmitUserTextExcept ¶ added in v1.1.34
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
FormatAskUserPrompt formats an ask_user request as an IM-friendly prompt string. Delegates to the shared FormatAskUserPrompt in ask_user_format.go.
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 (s *JSONFilePairingStore) LoadAll() (map[string]PairingChannelState, error)
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 (*Manager) ClearChannelByAdapter ¶ added in v1.1.34
func (*Manager) ClearReplyWindow ¶
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
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) EmitExcept ¶ added in v1.1.34
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
EnableBinding re-enables a previously disabled adapter binding. The binding is moved back to currentBindings so it resumes receiving messages.
func (*Manager) GenerateShareLink ¶
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
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
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 (*Manager) RegisterApproval ¶
func (m *Manager) RegisterApproval(req ApprovalRequest) (ApprovalRequest, <-chan permission.Decision)
func (*Manager) RegisterSink ¶
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) 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 (*Manager) TriggerTyping ¶ added in v1.1.34
TriggerTyping sends a typing indicator to all bound adapters that implement the TypingIndicator interface.
func (*Manager) UnbindAdapter ¶ added in v1.1.34
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 (*Manager) UnbindSession ¶
func (m *Manager) UnbindSession()
func (*Manager) UnregisterSink ¶
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 SessionBinding ¶
type ShareLinkProvider ¶
type ShareLinkProvider interface {
}
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 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 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.
Source Files
¶
- adapters.go
- ask_user_format.go
- ask_user_parse.go
- bindings.go
- daemon_bridge.go
- dingtalk_adapter.go
- discord_adapter.go
- emitter.go
- feishu_adapter.go
- history.go
- image_extract.go
- pairing.go
- pc_adapter.go
- pc_crypto.go
- pc_invite.go
- pc_protocol.go
- pc_relay_client.go
- pc_session.go
- pc_session_store.go
- qq_adapter.go
- runtime.go
- slack_adapter.go
- stt_helpers.go
- tg_adapter.go
- tg_markdown.go
- tool_format.go
- tool_status.go
- types.go