connector

package
v0.6.87 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CardActionDecisionApprove = "approve"
	CardActionDecisionReject  = "reject"
)

Variables

View Source
var ErrIgnoreMessage = errors.New("ignore message")

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(cfg config.Config, processor *Processor) *App

func (*App) FlushRuntimeState

func (a *App) FlushRuntimeState() error

func (*App) FlushRuntimeStateIfDirty

func (a *App) FlushRuntimeStateIfDirty() error

func (*App) IsSessionActive added in v0.6.62

func (a *App) IsSessionActive(sessionKey string) bool

IsSessionActive reports whether any session matching the given sessionKey's visibility prefix is currently processing a user message. The automation engine calls this before executing a scheduled task to skip execution when the user is actively conversing, avoiding interruption.

Thread isolation: if either the query key or an active key carries a thread-specific token (seed or thread), only sessions in the *same* thread are considered a match. This prevents a conversation in one Feishu work-thread from blocking automation tasks that target a different thread in the same group.

func (*App) LoadRuntimeState

func (a *App) LoadRuntimeState(path string) error

func (*App) ReleaseSession added in v0.6.80

func (a *App) ReleaseSession(sessionKey string)

ReleaseSession removes a previously acquired automation session entry. It is a no-op if the session entry was already replaced by a newer user-message run (version != 0).

func (*App) Run

func (a *App) Run(ctx context.Context) error

func (*App) RunWithoutConnector added in v0.6.9

func (a *App) RunWithoutConnector(ctx context.Context) error

func (*App) SetAutomationRunner

func (a *App) SetAutomationRunner(runner AutomationRunner)

func (*App) SetBotOpenID added in v0.6.53

func (a *App) SetBotOpenID(openID string)

func (*App) SetCardActionHandler added in v0.6.13

func (a *App) SetCardActionHandler(handler CardActionHandler)

func (*App) SetPromptLoader

func (a *App) SetPromptLoader(loader *prompting.Loader)

func (*App) TryAcquireSession added in v0.6.80

func (a *App) TryAcquireSession(sessionKey string, cancel context.CancelCauseFunc) bool

TryAcquireSession atomically checks whether the session is inactive and, if so, registers it as active with version=0. Version 0 ensures that any real user message (version >= 1) will interrupt the task via the cancel function passed to this method (see enqueueJob).

func (*App) UpdateRuntimeConfig

func (a *App) UpdateRuntimeConfig(cfg config.Config)

type Attachment

type Attachment struct {
	SourceMessageID string
	Kind            string
	FileKey         string
	ImageKey        string
	FileName        string
	LocalPath       string
	DownloadError   string
}

type AttachmentDownloader

type AttachmentDownloader interface {
	DownloadAttachment(ctx context.Context, resourceScopeKey, sourceMessageID string, attachment *Attachment) error
}

type AutomationRunner

type AutomationRunner interface {
	Run(ctx context.Context)
}

type CardActionHandler added in v0.6.13

type CardActionHandler interface {
	HandleCardAction(ctx context.Context, req CardActionRequest) (CardActionResult, error)
}

type CardActionRequest added in v0.6.13

type CardActionRequest struct {
	Kind          string
	CampaignID    string
	PlanRound     int
	Decision      string
	ActorOpenID   string
	ActorUserID   string
	OpenMessageID string
}

type CardActionResult added in v0.6.13

type CardActionResult struct {
	Toast     string
	ToastType string
}

type ChatMemberNameResolver

type ChatMemberNameResolver interface {
	ResolveChatMemberName(ctx context.Context, chatID, openID, userID string) (string, error)
}

type Job

type Job struct {
	ReceiveID            string
	ReceiveIDType        string
	ChatType             string
	BotID                string
	BotName              string
	BotOpenID            string
	BotUserID            string
	SoulPath             string
	SenderName           string
	SenderOpenID         string
	SenderUserID         string
	SenderUnionID        string
	MentionedUsers       []MentionedUser
	SourceMessageID      string
	ReplyParentMessageID string
	ThreadID             string
	RootID               string
	MessageType          string
	Text                 string
	Attachments          []Attachment
	RawContent           string
	EventID              string
	ReceivedAt           time.Time
	ResourceScopeKey     string
	SessionKey           string
	SessionVersion       uint64
	Scene                string
	ResponseMode         string
	CreateFeishuThread   bool
	LLMProvider          string
	LLMModel             string
	LLMProfile           string
	LLMReasoningEffort   string
	LLMVariant           string
	LLMPersonality       string
	LLMPromptPrefix      string
	NoReplyToken         string
	SoulDoc              soulDocument
	DisableAck           bool
	WorkflowPhase        string
}

func BuildJob

func BuildJob(event *larkim.P2MessageReceiveV1) (*Job, error)

type JobProcessState

type JobProcessState string
const (
	JobProcessCompleted         JobProcessState = "completed"
	JobProcessRetryAfterRestart JobProcessState = "retry_after_restart"
)

type MentionedUser

type MentionedUser struct {
	Key     string
	Name    string
	OpenID  string
	UserID  string
	UnionID string
}

type Processor

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

func NewProcessor

func NewProcessor(
	backend agentbridge.Backend,
	sender Sender,
	failureMessage string,
	thinkingMessage string,
) *Processor

func (*Processor) FlushSessionState

func (p *Processor) FlushSessionState() error

func (*Processor) FlushSessionStateIfDirty

func (p *Processor) FlushSessionStateIfDirty() error

func (*Processor) LoadSessionState

func (p *Processor) LoadSessionState(path string) error

func (*Processor) ProcessJob

func (p *Processor) ProcessJob(ctx context.Context, job Job) bool

func (*Processor) ProcessJobState

func (p *Processor) ProcessJobState(ctx context.Context, job Job) JobProcessState

func (*Processor) SetBuiltinHelpConfig added in v0.3.12

func (p *Processor) SetBuiltinHelpConfig(cfg config.Config)

func (*Processor) SetImmediateFeedback

func (p *Processor) SetImmediateFeedback(mode, emojiType string)

func (*Processor) SetLLMBackend

func (p *Processor) SetLLMBackend(backend agentbridge.Backend)

func (*Processor) SetPromptLoader

func (p *Processor) SetPromptLoader(loader *prompting.Loader)

func (*Processor) SetReplyMessages

func (p *Processor) SetReplyMessages(failureMessage, thinkingMessage string)

func (*Processor) SetRuntimeAPI

func (p *Processor) SetRuntimeAPI(baseURL, token, runtimeBin string)

func (*Processor) SetStatusIdentity added in v0.5.27

func (p *Processor) SetStatusIdentity(botID, botName string)

func (*Processor) SetStatusStores added in v0.5.25

func (p *Processor) SetStatusStores(automationStore *automation.Store)

func (*Processor) SetStatusUsageSources added in v0.5.27

func (p *Processor) SetStatusUsageSources(sources []StatusUsageSource)

func (*Processor) SetWorkspaceDir added in v0.6.68

func (p *Processor) SetWorkspaceDir(workspaceDir string)

func (*Processor) TrySteerJob added in v0.6.83

func (p *Processor) TrySteerJob(ctx context.Context, job Job) (bool, error)

func (*Processor) UpdateRuntimeConfig added in v0.5.27

func (p *Processor) UpdateRuntimeConfig(update ProcessorRuntimeUpdate) error

type ProcessorRuntimeUpdate added in v0.5.27

type ProcessorRuntimeUpdate struct {
	Backend                agentbridge.Backend
	FailureMessage         string
	ThinkingMessage        string
	ImmediateFeedbackMode  string
	ImmediateFeedbackEmoji string
}

type ReplyContextProvider

type ReplyContextProvider interface {
	GetMessageText(ctx context.Context, messageID string) (string, error)
}

type Sender

type StatusUsageSource added in v0.5.27

type StatusUsageSource struct {
	BotID            string
	BotName          string
	SessionStatePath string
}

type UserNameResolver

type UserNameResolver interface {
	ResolveUserName(ctx context.Context, openID, userID string) (string, error)
}

Jump to

Keyboard shortcuts

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