im

package
v1.1.32 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 DefaultBindingsPath

func DefaultBindingsPath() (string, error)

func DefaultPairingStatePath

func DefaultPairingStatePath() (string, error)

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 (*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 {
	Load(workspace string) (*ChannelBinding, error)
	Save(binding ChannelBinding) error
	Delete(workspace string) error
	List() ([]ChannelBinding, error)
}

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
	LastInboundAt         time.Time
	PassiveReplyCount     int
	PassiveReplyStartedAt time.Time
	BoundAt               time.Time
}

type Envelope

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

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
}

func NewJSONFileBindingStore

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

func (*JSONFileBindingStore) Delete

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

func (*JSONFileBindingStore) List

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

func (*JSONFileBindingStore) Load

func (s *JSONFileBindingStore) Load(workspace string) (*ChannelBinding, error)

func (*JSONFileBindingStore) Save

func (s *JSONFileBindingStore) Save(binding ChannelBinding) 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) ClearReplyWindow

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

func (*Manager) CurrentBinding

func (m *Manager) CurrentBinding() *ChannelBinding

func (*Manager) Emit

func (m *Manager) Emit(ctx context.Context, event OutboundEvent) error
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) ListBindings

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

func (*Manager) PublishAdapterState

func (m *Manager) PublishAdapterState(state AdapterState)

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) 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
}

func NewMemoryBindingStore

func NewMemoryBindingStore() *MemoryBindingStore

func (*MemoryBindingStore) Delete

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

func (*MemoryBindingStore) List

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

func (*MemoryBindingStore) Load

func (s *MemoryBindingStore) Load(workspace string) (*ChannelBinding, error)

func (*MemoryBindingStore) Save

func (s *MemoryBindingStore) Save(binding ChannelBinding) 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
	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"
	OutboundEventApprovalRequest OutboundEventKind = "approval_request"
	OutboundEventApprovalResult  OutboundEventKind = "approval_result"
)

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 Platform

type Platform string
const (
	PlatformUnknown  Platform = ""
	PlatformQQ       Platform = "qq"
	PlatformTelegram Platform = "telegram"
	PlatformDiscord  Platform = "discord"
	PlatformFeishu   Platform = "feishu"
)

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
	CurrentBinding   *ChannelBinding
	PendingPairing   *PairingChallenge
	Adapters         []AdapterState
	PendingApprovals []ApprovalState
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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