Documentation
¶
Index ¶
- func New(cfg Config, deps Deps) (agentkit.Platform, error)
- type Config
- type Deps
- type Platform
- func (p *Platform) AddDoneReaction(rctx any)
- func (p *Platform) BuildRichCard(status cardStatus, title string, steps []toolStep, markdown string, ...) string
- func (p *Platform) ClearUserProfileCache() int
- func (p *Platform) DeletePreviewMessage(ctx context.Context, previewHandle any) error
- func (p *Platform) IsMessageRecalled(ctx context.Context, rctx any) (bool, error)
- func (p *Platform) PermissionCapability() permission.Capability
- func (p *Platform) PlatformID() string
- func (p *Platform) ReadChatHistory(ctx context.Context, req chathistory.Request) (chathistory.Result, error)
- func (p *Platform) Receive(ctx context.Context) (agentkit.MessageEvent, error)
- func (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error)
- func (p *Platform) RefreshCard(ctx context.Context, sessionKey string, card *common.Card) error
- func (p *Platform) Reply(ctx context.Context, rctx any, content string) error
- func (p *Platform) ReplyCard(ctx context.Context, rctx replyContext, card *common.Card) error
- func (p *Platform) Send(ctx context.Context, event agentkit.OutboundEvent) error
- func (p *Platform) SendAudio(ctx context.Context, rctx any, audio []byte, format string) error
- func (p *Platform) SendFile(ctx context.Context, rctx any, file common.FileAttachment) error
- func (p *Platform) SendImage(ctx context.Context, rctx any, img common.ImageAttachment) error
- func (p *Platform) SendPreviewStart(ctx context.Context, rctx any, content string) (any, error)
- func (p *Platform) SetPreviewStatus(previewHandle any, status cardStatus)
- func (p *Platform) SplitMarkdownByTables(md string, maxTables int) []string
- func (p *Platform) StartTyping(ctx context.Context, rctx any) (stop func())
- func (p *Platform) UpdateMessage(ctx context.Context, previewHandle any, content string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
common.AgentRoutingConfig
AppID string `json:"appId"`
AppSecret string `json:"appSecret"`
Domain string `json:"domain"`
AllowFrom string `json:"allowFrom"`
AllowChat string `json:"allowChat"`
GroupReplyAll bool `json:"groupReplyAll"`
ThreadIsolation bool `json:"threadIsolation"`
ReplyInThread *bool `json:"replyInThread"`
ThreadNoMention bool `json:"threadNoMention"` // 话题被 @bot 激活后,话题内消息(含纯文字)免 @;需 threadIsolation
ReactionEmoji string `json:"reactionEmoji"`
DoneEmoji string `json:"doneEmoji"`
CancelledEmoji string `json:"cancelledEmoji"`
ErrorEmoji string `json:"errorEmoji"`
GroupOnly bool `json:"groupOnly"`
RespondToAtEveryoneAndHere bool `json:"respondToAtEveryoneAndHere"`
ReplyToTrigger *bool `json:"replyToTrigger"`
// StopOnRecall 为 nil 时默认 true:用户撤回触发(或 steer 进)进行中
// turn 的消息时,平台自动按 /stop 取消该 turn;显式 false 关闭。
// 撤回与进行中 turn 无关的旧消息不影响执行。
StopOnRecall *bool `json:"stopOnRecall"`
ResolveMentions bool `json:"resolveMentions"`
PeerBots map[string]string `json:"peerBots"`
ShowThinking *bool `json:"showThinking"`
ShowToolProgress *bool `json:"showToolProgress"`
AsyncSubagentProgressCard *bool `json:"asyncSubagentProgressCard"`
EnableFeishuCard *bool `json:"enableFeishuCard"`
EncryptKey string `json:"encryptKey"`
Port string `json:"port"`
CallbackPath string `json:"callbackPath"`
UnknownCardAction string `json:"unknownCardAction"` // forward (default) | ignore
// ForwardEventsToAgent 列出直转 agent 处理的自定义事件类型
// (如 drive.file.created_v1)。事件序列化为一条 inbound 消息;
// 每条事件使用独立 session(按 event_id),避免同群/同用户事件共享历史。
// 回复仍按事件上下文:带 chat_id 回群,只带 user_id 回 p2p,都无则
// 无回复目标。妙记/会议等用户身份
// 订阅事件(minutes.minute.generated_v1、vc.*)按 subscriber_ids[0]
// 的 open_id 路由到该用户的 p2p 会话。事件类型需在 Lark 开发者后台
// 同步订阅;用户身份事件还需用户 OAuth 授权后用 user_access_token
// 调对应服务端订阅 API 注册(见 docs/guides/lark-user-events.zh.md)。
// 停机期间未 ack 的事件由飞书重推补送,重启后仍会投递(不按进程
// 启动时间丢弃),重复投递由 event_id 去重。
ForwardEventsToAgent []string `json:"forwardEventsToAgent,omitempty"`
}
func (*Config) SetDefaults ¶ added in v0.3.48
func (c *Config) SetDefaults()
SetDefaults implements pluginkit.Defaulter. Emoji 字段保留 "none" 哨兵语义: 仅在为空时填默认值,"none" 由 newPlatform 映射为空串(禁用)。
type Deps ¶
type Deps struct {
Commands agentkit.Commands `json:"commands,omitempty"`
SessionStore agentkit.SessionStore `json:"sessionStore,omitempty"`
Workspace workspace.Service `json:"workspace,omitempty"`
// EventHandlers 订阅自定义 Lark 事件的 handler 插件(cap/larkevent)。
// 每个 handler 自行声明 EventTypes(),平台按事件类型聚合后注册
// OnCustomizedEvent;同一事件类型可命中多个 handler。
EventHandlers []caplarkevent.Handler `json:"eventHandlers,omitempty"`
}
type Platform ¶
type Platform struct {
// contains filtered or unexported fields
}
func (*Platform) AddDoneReaction ¶
AddDoneReaction adds a "done" emoji reaction so the user gets a push notification when the agent finishes a multi-round turn in quiet mode.
func (*Platform) BuildRichCard ¶
func (p *Platform) BuildRichCard(status cardStatus, title string, steps []toolStep, markdown string, streaming bool, elapsed time.Duration) string
BuildRichCard implements core.RichCardSupporter. Feishu engine passes an elapsed duration via the preview handle; buildRichCard itself is the renderer and must be called with the duration from engine state.
func (*Platform) ClearUserProfileCache ¶ added in v0.3.52
ClearUserProfileCache removes all cached Contact API profile entries for this leaf. Call after fixing app scopes or when stale empty profiles were cached.
func (*Platform) DeletePreviewMessage ¶
DeletePreviewMessage removes a preview message so the caller can send a separate final message without leaving a stale interactive card behind.
func (*Platform) IsMessageRecalled ¶
func (*Platform) PermissionCapability ¶
func (p *Platform) PermissionCapability() permission.Capability
func (*Platform) PlatformID ¶
func (*Platform) ReadChatHistory ¶ added in v0.1.22
func (p *Platform) ReadChatHistory(ctx context.Context, req chathistory.Request) (chathistory.Result, error)
ReadChatHistory lists messages from Feishu/Lark IM for the given delivery session.
func (*Platform) ReconstructReplyCtx ¶
func (*Platform) RefreshCard ¶
func (*Platform) SendAudio ¶
SendAudio uploads audio bytes to Feishu and sends a voice message. Implements core.AudioSender interface. Feishu audio messages require opus format; non-opus input is converted via ffmpeg.
func (*Platform) SendPreviewStart ¶
SendPreviewStart sends a new card message and returns a handle for subsequent edits. Using card (interactive) type for both preview and final message so updates are in-place without needing to delete and resend.
func (*Platform) SetPreviewStatus ¶
SetPreviewStatus updates the card header color to reflect the agent's current state.
func (*Platform) SplitMarkdownByTables ¶
SplitMarkdownByTables implements core.MarkdownTableSplitter.
func (*Platform) StartTyping ¶
StartTyping adds an emoji reaction to the user's message and returns a stop function that removes the reaction when processing is complete.
func (*Platform) UpdateMessage ¶
UpdateMessage edits an existing card message identified by previewHandle. Uses the Patch API (HTTP PATCH) which is required for interactive card messages. 对外固定标准重试预算;需要其他预算的调用方走 updateMessageProfile。
Source Files
¶
- agentkit.go
- async_subagent_card.go
- audio.go
- bot_identity.go
- bot_menu.go
- card.go
- card_action_forward.go
- card_extract.go
- cardkit_stream.go
- delete_mode_form.go
- events.go
- feishu.go
- history.go
- media_download.go
- merge_forward.go
- message_send.go
- outbound_content.go
- outbound_media.go
- pending_attachments.go
- post_content.go
- profile_cache.go
- progress_card.go
- reactions.go
- recall.go
- register.go
- reply_chain.go
- reply_ctx.go
- rich_card.go
- sanitize_log.go
- session_key.go
- stream_card.go
- stream_state.go
- stream_turn.go
- token_retry.go
- user_profile.go