Documentation
¶
Index ¶
- Constants
- Variables
- func NewGoalRunHelper(processor *Processor) automation.GoalRunHelper
- type App
- func (a *App) FlushRuntimeState() error
- func (a *App) FlushRuntimeStateIfDirty() error
- func (a *App) GetSessionMeta(sessionKey string) automation.SessionMeta
- func (a *App) GetSessionThreadID(sessionKey string) string
- func (a *App) GetSessionWorkDir(sessionKey string) string
- func (a *App) IsSessionActive(sessionKey string) bool
- func (a *App) LoadRuntimeState(path string) error
- func (a *App) RecordSessionUsage(sessionKey string, usage llm.Usage)
- func (a *App) ReleaseSession(sessionKey string)
- func (a *App) Run(ctx context.Context) error
- func (a *App) RunWithoutConnector(ctx context.Context) error
- func (a *App) SetAutomationRunner(runner AutomationRunner)
- func (a *App) SetBotOpenID(openID string)
- func (a *App) SetCardActionHandler(handler CardActionHandler)
- func (a *App) SetPromptLoader(loader *prompting.Loader)
- func (a *App) TryAcquireSession(sessionKey string, cancel context.CancelCauseFunc) bool
- func (a *App) UpdateRuntimeConfig(cfg config.Config)
- type Attachment
- type AttachmentDownloader
- type AutomationRunner
- type CardActionHandler
- type CardActionRequest
- type CardActionResult
- type ChatMemberNameResolver
- type Job
- type JobProcessState
- type MentionedUser
- type Processor
- func (p *Processor) FlushSessionState() error
- func (p *Processor) FlushSessionStateIfDirty() error
- func (p *Processor) LoadSessionState(path string) error
- func (p *Processor) ProcessJob(ctx context.Context, job Job) bool
- func (p *Processor) ProcessJobState(ctx context.Context, job Job) JobProcessState
- func (p *Processor) RunGoalMessage(ctx context.Context, threadID string, userText string, scene string, ...) (llm.RunResult, error)
- func (p *Processor) SetBuiltinHelpConfig(cfg config.Config)
- func (p *Processor) SetHeartbeatShowShellCommands(show bool)
- func (p *Processor) SetImmediateFeedback(mode, emojiType string)
- func (p *Processor) SetLLMBackend(backend llm.Backend)
- func (p *Processor) SetPromptLoader(loader *prompting.Loader)
- func (p *Processor) SetReplyMessages(failureMessage, thinkingMessage string)
- func (p *Processor) SetRuntimeAPI(baseURL, token, runtimeBin string)
- func (p *Processor) SetSceneIdentityHints(chatDisable, workDisable bool)
- func (p *Processor) SetStatusIdentity(botID, botName string)
- func (p *Processor) SetStatusStores(automationStore *automation.Store)
- func (p *Processor) SetStatusUsageSources(sources []StatusUsageSource)
- func (p *Processor) SetWorkspaceDir(workspaceDir string)
- func (p *Processor) TrySteerJob(ctx context.Context, job Job) (bool, error)
- func (p *Processor) UpdateRuntimeConfig(update ProcessorRuntimeUpdate) error
- type ProcessorRuntimeUpdate
- type ReplyContextProvider
- type Sender
- type StatusUsageSource
- type UserNameResolver
Constants ¶
const ( CardActionDecisionApprove = "approve" CardActionDecisionReject = "reject" )
Variables ¶
var ErrIgnoreMessage = errors.New("ignore message")
ErrIgnoreMessage is returned when a message should be silently dropped.
Functions ¶
func NewGoalRunHelper ¶ added in v0.6.117
func NewGoalRunHelper(processor *Processor) automation.GoalRunHelper
NewGoalRunHelper creates a GoalRunHelper that delegates to the Processor's RunGoalMessage pipeline, giving goals the same OnProgress and OnRawEvent dispatching that regular user messages receive.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App orchestrates message processing, session management, and LLM interaction for a single bot instance.
func (*App) FlushRuntimeState ¶
func (*App) FlushRuntimeStateIfDirty ¶
func (*App) GetSessionMeta ¶ added in v0.6.127
func (a *App) GetSessionMeta(sessionKey string) automation.SessionMeta
GetSessionMeta returns the LLM configuration for the given session key.
func (*App) GetSessionThreadID ¶ added in v0.6.110
GetSessionThreadID returns the current backend LLM thread ID for the given session key. Returns an empty string if the session has no thread yet.
func (*App) GetSessionWorkDir ¶ added in v0.6.127
GetSessionWorkDir returns the workspace directory for the given session key.
func (*App) IsSessionActive ¶ added in v0.6.62
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 (*App) RecordSessionUsage ¶ added in v0.6.127
RecordSessionUsage records LLM token usage for the given session key.
func (*App) ReleaseSession ¶ added in v0.6.80
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) RunWithoutConnector ¶ added in v0.6.9
func (*App) SetAutomationRunner ¶
func (a *App) SetAutomationRunner(runner AutomationRunner)
func (*App) SetBotOpenID ¶ added in v0.6.53
func (*App) SetCardActionHandler ¶ added in v0.6.13
func (a *App) SetCardActionHandler(handler CardActionHandler)
func (*App) SetPromptLoader ¶
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 ¶
type Attachment ¶
type Attachment struct {
SourceMessageID string
Kind string
FileKey string
ImageKey string
FileName string
LocalPath string
DownloadError string
}
Attachment represents a file or image attached to an incoming message.
type AttachmentDownloader ¶
type AttachmentDownloader interface {
DownloadAttachment(ctx context.Context, resourceScopeKey, sourceMessageID string, attachment *Attachment) error
}
AttachmentDownloader downloads attachments to the local filesystem.
type AutomationRunner ¶
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 CardActionResult ¶ added in v0.6.13
type ChatMemberNameResolver ¶
type ChatMemberNameResolver interface {
ResolveChatMemberName(ctx context.Context, chatID, openID, userID string) (string, error)
}
ChatMemberNameResolver resolves a user's display name within a specific chat.
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
}
Job is a unit of work dispatched to the connector's processing pipeline.
type JobProcessState ¶
type JobProcessState string
const ( JobProcessCompleted JobProcessState = "completed" JobProcessRetryAfterRestart JobProcessState = "retry_after_restart" )
type MentionedUser ¶
MentionedUser holds information about a user @-mentioned in a message.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor handles job execution, prompt building, session state, and reply dispatch for incoming connector messages.
func NewProcessor ¶
func NewProcessor( backend llm.Backend, sender Sender, failureMessage string, thinkingMessage string, ) *Processor
NewProcessor creates a Processor with the required dependencies.
func (*Processor) FlushSessionState ¶
func (*Processor) FlushSessionStateIfDirty ¶
func (*Processor) LoadSessionState ¶
func (*Processor) ProcessJobState ¶
func (p *Processor) ProcessJobState(ctx context.Context, job Job) JobProcessState
func (*Processor) RunGoalMessage ¶ added in v0.6.117
func (p *Processor) RunGoalMessage( ctx context.Context, threadID string, userText string, scene string, env map[string]string, workspaceDir string, meta automation.SessionMeta, onProgress llm.ProgressFunc, ) (llm.RunResult, error)
RunGoalMessage runs a goal prompt through the same LLM pipeline used for regular user messages, with full OnRawEvent (reasoning, tool_use, tool_call) debug logging. It returns the complete RunResult including GoalDone so the goal engine can decide whether to continue iteration or mark complete.
func (*Processor) SetBuiltinHelpConfig ¶ added in v0.3.12
func (*Processor) SetHeartbeatShowShellCommands ¶ added in v0.6.92
func (*Processor) SetImmediateFeedback ¶
func (*Processor) SetLLMBackend ¶
func (*Processor) SetPromptLoader ¶
func (*Processor) SetReplyMessages ¶
func (*Processor) SetRuntimeAPI ¶
func (*Processor) SetSceneIdentityHints ¶ added in v0.6.110
func (*Processor) SetStatusIdentity ¶ added in v0.5.27
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 (*Processor) TrySteerJob ¶ added in v0.6.83
func (*Processor) UpdateRuntimeConfig ¶ added in v0.5.27
func (p *Processor) UpdateRuntimeConfig(update ProcessorRuntimeUpdate) error
type ProcessorRuntimeUpdate ¶ added in v0.5.27
type ReplyContextProvider ¶
type ReplyContextProvider interface {
GetMessageText(ctx context.Context, messageID string) (string, error)
}
ReplyContextProvider provides the text of a previously sent reply message.
type Sender ¶
type Sender = messaging.ConversationSender
type StatusUsageSource ¶ added in v0.5.27
StatusUsageSource provides token usage data for status display.
Source Files
¶
- app.go
- app_automation.go
- app_queue.go
- app_state.go
- card.go
- card_action.go
- goal_run_helper.go
- group_scenes.go
- llm_heartbeat.go
- message.go
- message_identity.go
- message_mentions.go
- message_post.go
- message_session.go
- message_text.go
- message_trigger.go
- outgoing_hidden.go
- outgoing_mentions.go
- outgoing_plaintext.go
- processor.go
- processor_builtin_command.go
- processor_context.go
- processor_flow.go
- processor_runtime_update.go
- processor_status_service.go
- processor_status_usage.go
- processor_user_names.go
- prompt_templates.go
- reply_dispatcher.go
- runtime_store.go
- session_state.go
- session_state_persist.go
- soul_document.go
- types.go