Documentation
¶
Index ¶
- Constants
- Variables
- func BuildAgentSessionKey(agentID string, channel string, chatType string, ref string, threadID string) string
- func BuildRoomAgentSessionKey(conversationID string, agentID string, roomType string) string
- func BuildRoomSharedSessionKey(conversationID string) string
- func GetSessionKeyValidationError(raw string) string
- func HasChatInput(content string, attachments []ChatAttachment) bool
- func IsRoomSharedSessionKey(raw string) bool
- func IsStructuredSessionKey(raw string) bool
- func IsTranscriptNativeMessage(message Message) bool
- func MessageRole(message Message) string
- func MessageRoundID(message Message) string
- func NormalizeOverlapPolicy(policy string) string
- func NormalizeSessionChatType(chatType string) string
- func NormalizeSessionKeyChannelSegment(channel string) string
- func NormalizeStoredChannelType(channel string) string
- func ParseRoomConversationID(raw string) string
- func RequireStructuredSessionKey(raw string) (string, error)
- func ShouldGuideRunningRound(policy ChatDeliveryPolicy) bool
- func ShouldQueueRunningRound(policy ChatDeliveryPolicy) bool
- func TypeScriptDefinitions() string
- type AddRoomMemberRequest
- type Agent
- type ChatAttachment
- func ChatAttachmentFromMap(value map[string]any) ChatAttachment
- func ChatAttachmentsFromAny(value any) []ChatAttachment
- func NormalizeChatAttachment(value ChatAttachment, defaultAgentID string) ChatAttachment
- func NormalizeChatAttachments(values []ChatAttachment, defaultAgentID string) []ChatAttachment
- type ChatAttachmentKind
- type ChatAttachmentScope
- type ChatDeliveryPolicy
- type ConversationContextAggregate
- type ConversationRecord
- type CreateConversationRequest
- type CreateJobInput
- type CreateRequest
- type CreateRoomActionRequest
- type CreateRoomRequest
- type CronJob
- type CronRun
- type DeliveryTarget
- type EventMessage
- func NewChatAckEvent(sessionKey string, reqID string, roundID string, pending []map[string]any) EventMessage
- func NewErrorEvent(sessionKey string, message string) EventMessage
- func NewEvent(eventType EventType, data map[string]any) EventMessage
- func NewInputQueueEvent(sessionKey string, items []InputQueueItem) EventMessage
- func NewPermissionRequestResolvedEvent(sessionKey string, requestID string, status string) EventMessage
- func NewPongEvent(sessionKey string) EventMessage
- func NewRoundStatusEvent(sessionKey string, roundID string, status string, resultSubtype string) EventMessage
- type EventType
- type ExecutionResult
- type HeartbeatConfig
- type HeartbeatStatus
- type HeartbeatUpdateInput
- type HeartbeatWakeRequest
- type HeartbeatWakeResult
- type InboundWebSocketMessage
- type InputQueueItem
- type InputQueueScope
- type InputQueueSource
- type MemberRecord
- type Message
- type MessagePage
- type Options
- type RoomActionRecord
- type RoomActionType
- type RoomAggregate
- type RoomRecord
- type RoomReplyTarget
- type RoomWakePolicy
- type RoundStatusData
- type Schedule
- type Session
- type SessionKey
- type SessionKeyKind
- type SessionRecord
- type SessionStatusData
- type SessionTarget
- type Source
- type StructuredSessionKeyError
- type SystemEvent
- type UpdateConversationRequest
- type UpdateJobInput
- type UpdateRequest
- type UpdateRoomRequest
- type ValidateNameResponse
- type WorkspaceFileArtifactBlock
Constants ¶
const ( // OptionRuntimeProvider 表示创建/续用 SDK session 时使用的 provider key。 OptionRuntimeProvider = "runtime_provider" // OptionRuntimeModel 表示创建/续用 SDK session 时使用的模型。 OptionRuntimeModel = "runtime_model" )
const ( // ScheduleKindEvery 表示固定间隔调度。 ScheduleKindEvery = "every" // ScheduleKindCron 表示 cron 表达式调度。 ScheduleKindCron = "cron" // ScheduleKindAt 表示单次定时。 ScheduleKindAt = "at" // SessionTargetIsolated 表示每次运行都创建新会话。 SessionTargetIsolated = "isolated" // SessionTargetMain 表示写入主自动化会话。 SessionTargetMain = "main" // SessionTargetBound 表示绑定到现有结构化会话。 SessionTargetBound = "bound" // SessionTargetNamed 表示绑定到命名自动化会话。 SessionTargetNamed = "named" // WakeModeNow 表示立即唤醒。 WakeModeNow = "now" // WakeModeNextHeartbeat 表示在下一次 heartbeat 时消费。 WakeModeNextHeartbeat = "next-heartbeat" // DeliveryModeNone 表示不做外部投递。 DeliveryModeNone = "none" // DeliveryModeLast 表示投递到最近通道。 DeliveryModeLast = "last" // DeliveryModeExplicit 表示投递到显式目标。 DeliveryModeExplicit = "explicit" // SourceKindUserPage 表示来自页面创建。 SourceKindUserPage = "user_page" // SourceKindAgent 表示来自 Agent 创建。 SourceKindAgent = "agent" // SourceKindCLI 表示来自 CLI 创建。 SourceKindCLI = "cli" // SourceKindSystem 表示来自系统创建。 SourceKindSystem = "system" // RunStatusPending 表示已登记但未开始执行。 RunStatusPending = "pending" // RunStatusRunning 表示执行中。 RunStatusRunning = "running" // RunStatusSucceeded 表示执行成功。 RunStatusSucceeded = "succeeded" // RunStatusFailed 表示执行失败。 RunStatusFailed = "failed" // RunStatusCancelled 表示执行取消。 RunStatusCancelled = "cancelled" // RunStatusQueuedToMain 表示已排入主会话队列。 RunStatusQueuedToMain = "queued_to_main_session" // RunStatusSkipped 表示因重叠策略跳过本次触发。 RunStatusSkipped = "skipped" // OverlapPolicySkip 表示已有执行时跳过新触发。 OverlapPolicySkip = "skip" // OverlapPolicyAllow 表示允许同一任务并发执行。 OverlapPolicyAllow = "allow" // HeartbeatTargetNone 表示不投递。 HeartbeatTargetNone = "none" // HeartbeatTargetLast 表示投递到最近通道。 HeartbeatTargetLast = "last" // HeartbeatTargetExplicit 表示投递到显式目标。 HeartbeatTargetExplicit = "explicit" )
const ( ChatAttachmentKindText ChatAttachmentKind = "text" ChatAttachmentKindImage ChatAttachmentKind = "image" ChatAttachmentKindFile ChatAttachmentKind = "file" ChatAttachmentScopeAgentWorkspace ChatAttachmentScope = "agent_workspace" ChatAttachmentScopeRoomConversation ChatAttachmentScope = "room_conversation" )
const ( // RoomTypeDM 表示单成员直聊房间。 RoomTypeDM = "dm" // RoomTypeGroup 表示多人协作房间。 RoomTypeGroup = "room" // ConversationTypeDM 表示 DM 主对话。 ConversationTypeDM = "dm" // ConversationTypeMain 表示 Room 主对话。 ConversationTypeMain = "room_main" // ConversationTypeTopic 表示 Room 话题对话。 ConversationTypeTopic = "topic" // MemberTypeUser 表示用户成员。 MemberTypeUser = "user" // MemberTypeAgent 表示 Agent 成员。 MemberTypeAgent = "agent" )
const ( RoomActionVisibilityPublic = "public" RoomActionVisibilityPrivate = "private" )
const ( // SessionChannelWebSocketSegment 表示 session_key 中的 WebSocket 通道段。 SessionChannelWebSocketSegment = "ws" // SessionChannelDiscordSegment 表示 session_key 中的 Discord 通道段。 SessionChannelDiscordSegment = "dg" // SessionChannelTelegramSegment 表示 session_key 中的 Telegram 通道段。 SessionChannelTelegramSegment = "tg" // SessionChannelDingTalkSegment 表示 session_key 中的钉钉通道段。 SessionChannelDingTalkSegment = "dt" // SessionChannelWeChatSegment 表示 session_key 中的微信通道段。 SessionChannelWeChatSegment = "wx" // SessionChannelFeishuSegment 表示 session_key 中的飞书通道段。 SessionChannelFeishuSegment = "fs" // SessionChannelInternalSegment 表示 session_key 中的内部通道段。 SessionChannelInternalSegment = "internal" // SessionChannelWebSocket 表示持久化后的 WebSocket 通道类型。 SessionChannelWebSocket = "websocket" // SessionChannelDiscord 表示持久化后的 Discord 通道类型。 SessionChannelDiscord = "discord" // SessionChannelTelegram 表示持久化后的 Telegram 通道类型。 SessionChannelTelegram = "telegram" // SessionChannelDingTalk 表示持久化后的钉钉通道类型。 SessionChannelDingTalk = "dingtalk" // SessionChannelWeChat 表示持久化后的微信通道类型。 SessionChannelWeChat = "wechat" // SessionChannelFeishu 表示持久化后的飞书通道类型。 SessionChannelFeishu = "feishu" )
const ( WorkspaceFileArtifactOperationWrite = "write" WorkspaceFileArtifactOperationUpdate = "update" )
const ( WorkspaceFileArtifactKindFile = "file" WorkspaceFileArtifactKindImage = "image" WorkspaceFileArtifactKindMarkdown = "markdown" WorkspaceFileArtifactKindHTML = "html" WorkspaceFileArtifactKindMermaid = "mermaid" WorkspaceFileArtifactKindSVG = "svg" WorkspaceFileArtifactKindPDF = "pdf" )
const ChatAckTimeoutMS = 10000
ChatAckTimeoutMS 是客户端等待 chat_ack 的上限(毫秒)。 服务端不强制该窗口,但承诺在此之前回 ack; 前端据此设置本地超时,两侧同源避免漂移。
const (
// ContentBlockTypeWorkspaceFileArtifact 表示 Agent 在工作区生成或更新的文件产物。
ContentBlockTypeWorkspaceFileArtifact = "workspace_file_artifact"
)
const (
WorkspaceFileArtifactScopeAgentWorkspace = "agent_workspace"
)
Variables ¶
var ( // ErrJobNotFound 表示任务不存在。 ErrJobNotFound = errors.New("scheduled task not found") // ErrHeartbeatConfigInvalid 表示 heartbeat 配置非法。 ErrHeartbeatConfigInvalid = errors.New("heartbeat config is invalid") )
var ErrInvalidSessionKey = errors.New("invalid structured session_key")
ErrInvalidSessionKey 表示 session_key 不符合结构化协议。
Functions ¶
func BuildAgentSessionKey ¶
func BuildAgentSessionKey(agentID string, channel string, chatType string, ref string, threadID string) string
BuildAgentSessionKey 构建 agent 作用域 key。
func BuildRoomAgentSessionKey ¶
BuildRoomAgentSessionKey 构建 Room 成员侧的 agent session_key。
func BuildRoomSharedSessionKey ¶
BuildRoomSharedSessionKey 构建共享 room key。
func GetSessionKeyValidationError ¶
GetSessionKeyValidationError 返回结构化 session_key 校验错误。
func HasChatInput ¶ added in v0.1.6
func HasChatInput(content string, attachments []ChatAttachment) bool
HasChatInput 判断一次用户输入是否包含正文或附件。
func IsRoomSharedSessionKey ¶
IsRoomSharedSessionKey 判断是否为 Room 共享消息流 key。
func IsStructuredSessionKey ¶
IsStructuredSessionKey 判断是否合法。
func IsTranscriptNativeMessage ¶
IsTranscriptNativeMessage 表示该 durable message 是否属于 cc transcript 原生真相。 当前只有 assistant 正文快照属于 transcript 原生消息; result / system / task_progress 等都需要由 Nexus overlay 补齐。
func NormalizeOverlapPolicy ¶ added in v0.1.2
NormalizeOverlapPolicy 返回重叠触发策略的默认值。
func NormalizeSessionChatType ¶
NormalizeSessionChatType 统一 chat_type 的默认值和枚举。
func NormalizeSessionKeyChannelSegment ¶
NormalizeSessionKeyChannelSegment 把外部输入统一成 session_key 使用的 channel 段。
func NormalizeStoredChannelType ¶
NormalizeStoredChannelType 把 channel 归一成持久化和运行时使用的名称。
func ParseRoomConversationID ¶
ParseRoomConversationID 读取 Room 共享流里的 conversation_id。
func RequireStructuredSessionKey ¶
RequireStructuredSessionKey 要求必须是结构化 session_key。
func ShouldGuideRunningRound ¶ added in v0.1.2
func ShouldGuideRunningRound(policy ChatDeliveryPolicy) bool
ShouldGuideRunningRound 判断运行中会话是否接收 hook 引导输入。
func ShouldQueueRunningRound ¶ added in v0.1.2
func ShouldQueueRunningRound(policy ChatDeliveryPolicy) bool
ShouldQueueRunningRound 判断运行中会话默认是否接收排队输入。
func TypeScriptDefinitions ¶
func TypeScriptDefinitions() string
TypeScriptDefinitions 返回生成前端类型定义所需内容。
Types ¶
type AddRoomMemberRequest ¶
type AddRoomMemberRequest struct {
AgentID string `json:"agent_id"`
}
AddRoomMemberRequest 表示追加成员请求。
type Agent ¶
type Agent struct {
AgentID string `json:"agent_id"`
Name string `json:"name"`
WorkspacePath string `json:"workspace_path"`
IsMain bool `json:"is_main,omitempty"`
DisplayName string `json:"display_name,omitempty"`
Headline string `json:"headline,omitempty"`
ProfileMarkdown string `json:"profile_markdown,omitempty"`
Options Options `json:"options"`
CreatedAt time.Time `json:"created_at"`
Status string `json:"status"`
Avatar string `json:"avatar,omitempty"`
Description string `json:"description,omitempty"`
VibeTags []string `json:"vibe_tags,omitempty"`
SkillsCount int `json:"skills_count"`
OwnerUserID string `json:"-"`
}
Agent 表示对外 Agent 模型。
type ChatAttachment ¶ added in v0.1.6
type ChatAttachment struct {
FileName string `json:"file_name"`
WorkspacePath string `json:"workspace_path"`
WorkspaceAgentID string `json:"workspace_agent_id,omitempty"`
RoomID string `json:"room_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
Scope ChatAttachmentScope `json:"scope,omitempty"`
Kind ChatAttachmentKind `json:"kind"`
MIMEType string `json:"mime_type,omitempty"`
Size int64 `json:"size,omitempty"`
}
ChatAttachment 表示一次用户输入绑定的应用层附件。
func ChatAttachmentFromMap ¶ added in v0.1.6
func ChatAttachmentFromMap(value map[string]any) ChatAttachment
ChatAttachmentFromMap 从 map payload 中解析单个附件。
func ChatAttachmentsFromAny ¶ added in v0.1.6
func ChatAttachmentsFromAny(value any) []ChatAttachment
ChatAttachmentsFromAny 从弱类型 payload 中解析附件列表。
func NormalizeChatAttachment ¶ added in v0.1.6
func NormalizeChatAttachment(value ChatAttachment, defaultAgentID string) ChatAttachment
NormalizeChatAttachment 归一化单个聊天附件。
func NormalizeChatAttachments ¶ added in v0.1.6
func NormalizeChatAttachments(values []ChatAttachment, defaultAgentID string) []ChatAttachment
NormalizeChatAttachments 归一化并过滤无效附件。
type ChatAttachmentKind ¶ added in v0.1.6
type ChatAttachmentKind string
ChatAttachmentKind 表示聊天附件的粗粒度类型。
func NormalizeChatAttachmentKind ¶ added in v0.1.6
func NormalizeChatAttachmentKind(value string) ChatAttachmentKind
NormalizeChatAttachmentKind 归一化附件类型。
type ChatAttachmentScope ¶ added in v0.1.6
type ChatAttachmentScope string
func NormalizeChatAttachmentScope ¶ added in v0.1.6
func NormalizeChatAttachmentScope(value string, conversationID string) ChatAttachmentScope
NormalizeChatAttachmentScope 归一化附件存储作用域。
type ChatDeliveryPolicy ¶ added in v0.1.2
type ChatDeliveryPolicy string
ChatDeliveryPolicy 表示新输入遇到运行中会话时的投递策略。
const ( // ChatDeliveryPolicyQueue 表示把新输入排入当前流式会话,不中断正在执行的 round。 ChatDeliveryPolicyQueue ChatDeliveryPolicy = "queue" // ChatDeliveryPolicyGuide 表示把新输入暂存在运行时,等待 PostToolUse hook 注入当前 round。 ChatDeliveryPolicyGuide ChatDeliveryPolicy = "guide" // ChatDeliveryPolicyInterrupt 表示先中断当前运行,再启动新的 round。 ChatDeliveryPolicyInterrupt ChatDeliveryPolicy = "interrupt" // ChatDeliveryPolicyAuto 预留给后续智能选择;当前等价于 queue。 ChatDeliveryPolicyAuto ChatDeliveryPolicy = "auto" )
func NormalizeChatDeliveryPolicy ¶ added in v0.1.2
func NormalizeChatDeliveryPolicy(value string) ChatDeliveryPolicy
NormalizeChatDeliveryPolicy 归一化前端传入的投递策略。
type ConversationContextAggregate ¶
type ConversationContextAggregate struct {
Room RoomRecord `json:"room"`
Members []MemberRecord `json:"members"`
MemberAgents []Agent `json:"member_agents,omitempty"`
Conversation ConversationRecord `json:"conversation"`
Sessions []SessionRecord `json:"sessions"`
}
ConversationContextAggregate 表示房间对话上下文聚合。
type ConversationRecord ¶
type ConversationRecord struct {
ID string `json:"id"`
RoomID string `json:"room_id"`
ConversationType string `json:"conversation_type"`
Title string `json:"title,omitempty"`
MessageCount int `json:"message_count"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
ConversationRecord 表示房间对话记录。
type CreateConversationRequest ¶
type CreateConversationRequest struct {
Title string `json:"title,omitempty"`
}
CreateConversationRequest 表示创建话题请求。
type CreateJobInput ¶ added in v0.1.2
type CreateJobInput struct {
Name string `json:"name"`
AgentID string `json:"agent_id"`
Schedule Schedule `json:"schedule"`
Instruction string `json:"instruction"`
SessionTarget SessionTarget `json:"session_target"`
Delivery DeliveryTarget `json:"delivery"`
Source Source `json:"source"`
OverlapPolicy string `json:"overlap_policy,omitempty"`
Enabled bool `json:"enabled"`
}
CreateJobInput 表示创建请求。
func (CreateJobInput) Normalized ¶ added in v0.1.2
func (i CreateJobInput) Normalized() CreateJobInput
Normalized 返回标准化副本。
func (CreateJobInput) Validate ¶ added in v0.1.2
func (i CreateJobInput) Validate() error
Validate 校验创建请求。
type CreateRequest ¶
type CreateRequest struct {
Name string `json:"name"`
Options *Options `json:"options,omitempty"`
Avatar string `json:"avatar,omitempty"`
Description string `json:"description,omitempty"`
VibeTags []string `json:"vibe_tags,omitempty"`
}
CreateRequest 表示创建 Agent 请求。
type CreateRoomActionRequest ¶ added in v0.1.3
type CreateRoomActionRequest struct {
ActionType RoomActionType `json:"action_type"`
// SourceAgentID 只能由受控运行时注入,不能从 action JSON body 写入。
SourceAgentID string `json:"-"`
TargetAgentID string `json:"target_agent_id,omitempty"`
AudienceAgentIDs []string `json:"audience_agent_ids,omitempty"`
Content string `json:"content"`
Visibility string `json:"visibility,omitempty"`
ReplyTarget RoomReplyTarget `json:"reply_target,omitempty"`
WakePolicy RoomWakePolicy `json:"wake_policy,omitempty"`
DelaySeconds int `json:"delay_seconds,omitempty"`
}
CreateRoomActionRequest 表示创建 Room action 的请求。
type CreateRoomRequest ¶
type CreateRoomRequest struct {
AgentIDs []string `json:"agent_ids"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
Avatar string `json:"avatar,omitempty"`
SkillNames []string `json:"skill_names,omitempty"`
HostAgentID string `json:"host_agent_id,omitempty"`
HostAutoReplyEnabled bool `json:"host_auto_reply_enabled,omitempty"`
}
CreateRoomRequest 表示创建房间请求。
type CronJob ¶ added in v0.1.2
type CronJob struct {
JobID string `json:"job_id"`
OwnerUserID string `json:"-"`
Name string `json:"name"`
AgentID string `json:"agent_id"`
Schedule Schedule `json:"schedule"`
Instruction string `json:"instruction"`
SessionTarget SessionTarget `json:"session_target"`
Delivery DeliveryTarget `json:"delivery"`
Source Source `json:"source"`
OverlapPolicy string `json:"overlap_policy,omitempty"`
Enabled bool `json:"enabled"`
NextRunAt *time.Time `json:"next_run_at,omitempty"`
Running bool `json:"running"`
LastRunAt *time.Time `json:"last_run_at,omitempty"`
}
CronJob 表示对外暴露的定时任务视图。
type CronRun ¶ added in v0.1.2
type CronRun struct {
RunID string `json:"run_id"`
JobID string `json:"job_id"`
OwnerUserID string `json:"-"`
Status string `json:"status"`
TriggerKind string `json:"trigger_kind,omitempty"`
SessionKey string `json:"session_key,omitempty"`
RoundID string `json:"round_id,omitempty"`
SessionID *string `json:"session_id,omitempty"`
MessageCount int `json:"message_count,omitempty"`
DeliveryMode string `json:"delivery_mode,omitempty"`
DeliveryTo string `json:"delivery_to,omitempty"`
ScheduledFor *time.Time `json:"scheduled_for,omitempty"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
Attempts int `json:"attempts"`
ErrorMessage *string `json:"error_message,omitempty"`
ResultSummary *string `json:"result_summary,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
CronRun 表示 run ledger 条目。
type DeliveryTarget ¶ added in v0.1.2
type DeliveryTarget struct {
Mode string `json:"mode"`
Channel string `json:"channel,omitempty"`
To string `json:"to,omitempty"`
AccountID string `json:"account_id,omitempty"`
ThreadID string `json:"thread_id,omitempty"`
}
DeliveryTarget 表示自动化外部投递目标。
func (DeliveryTarget) Normalized ¶ added in v0.1.2
func (d DeliveryTarget) Normalized() DeliveryTarget
Normalized 返回带默认值的投递目标副本。
func (DeliveryTarget) Validate ¶ added in v0.1.2
func (d DeliveryTarget) Validate() error
Validate 校验投递目标。
type EventMessage ¶
type EventMessage struct {
EnvelopeID string `json:"envelope_id,omitempty"`
ProtocolVersion int `json:"protocol_version"`
DeliveryMode string `json:"delivery_mode,omitempty"`
EventType EventType `json:"event_type"`
SessionKey string `json:"session_key,omitempty"`
SessionSeq *int64 `json:"session_seq,omitempty"`
RoomID string `json:"room_id,omitempty"`
RoomSeq *int64 `json:"room_seq,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
MessageID string `json:"message_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
CausedBy string `json:"caused_by,omitempty"`
Data map[string]any `json:"data"`
Timestamp int64 `json:"timestamp"`
}
EventMessage 对齐前后端统一 envelope。
func NewChatAckEvent ¶
func NewChatAckEvent(sessionKey string, reqID string, roundID string, pending []map[string]any) EventMessage
NewChatAckEvent 构造 chat_ack 事件。
func NewErrorEvent ¶
func NewErrorEvent(sessionKey string, message string) EventMessage
NewErrorEvent 构造错误事件。
func NewEvent ¶
func NewEvent(eventType EventType, data map[string]any) EventMessage
NewEvent 构造通用事件。
func NewInputQueueEvent ¶ added in v0.1.2
func NewInputQueueEvent(sessionKey string, items []InputQueueItem) EventMessage
NewInputQueueEvent 构造 input_queue 快照事件。
func NewPermissionRequestResolvedEvent ¶
func NewPermissionRequestResolvedEvent(sessionKey string, requestID string, status string) EventMessage
NewPermissionRequestResolvedEvent 构造权限请求结束事件。
func NewRoundStatusEvent ¶
func NewRoundStatusEvent(sessionKey string, roundID string, status string, resultSubtype string) EventMessage
NewRoundStatusEvent 构造 round_status 事件。
type EventType ¶
type EventType string
EventType 表示统一事件类型。
const ( EventTypeMessage EventType = "message" EventTypeStream EventType = "stream" EventTypeChatAck EventType = "chat_ack" EventTypeInputQueue EventType = "input_queue" EventTypeRoundStatus EventType = "round_status" EventTypeSessionStatus EventType = "session_status" EventTypePermissionRequest EventType = "permission_request" EventTypePermissionRequestResolved EventType = "permission_request_resolved" EventTypeAgentRuntimeEvent EventType = "agent_runtime_event" EventTypeWorkspaceEvent EventType = "workspace_event" EventTypeRoomMemberAdded EventType = "room_member_added" EventTypeRoomMemberRemoved EventType = "room_member_removed" EventTypeRoomDeleted EventType = "room_deleted" EventTypeRoomAction EventType = "room_action" EventTypeRoomActionConsumed EventType = "room_action_consumed" EventTypeRoomResyncRequired EventType = "room_resync_required" EventTypeSessionResyncRequired EventType = "session_resync_required" EventTypeStreamStart EventType = "stream_start" EventTypeStreamEnd EventType = "stream_end" EventTypeStreamCancelled EventType = "stream_cancelled" EventTypeError EventType = "error" EventTypePong EventType = "pong" )
type ExecutionResult ¶ added in v0.1.2
type ExecutionResult struct {
JobID string `json:"job_id"`
RunID *string `json:"run_id,omitempty"`
Status string `json:"status"`
SessionKey string `json:"session_key"`
ScheduledFor *time.Time `json:"scheduled_for,omitempty"`
RoundID *string `json:"round_id,omitempty"`
SessionID *string `json:"session_id,omitempty"`
MessageCount int `json:"message_count"`
ErrorMessage *string `json:"error_message,omitempty"`
}
ExecutionResult 表示一次手动触发或后台触发的返回体。
type HeartbeatConfig ¶ added in v0.1.2
type HeartbeatConfig struct {
AgentID string `json:"agent_id"`
Enabled bool `json:"enabled"`
EverySeconds int `json:"every_seconds"`
TargetMode string `json:"target_mode"`
AckMaxChars int `json:"ack_max_chars"`
}
HeartbeatConfig 表示持久化 heartbeat 配置。
func DefaultHeartbeatConfig ¶ added in v0.1.2
func DefaultHeartbeatConfig(agentID string) HeartbeatConfig
DefaultHeartbeatConfig 返回默认 heartbeat 配置。
func (HeartbeatConfig) Normalized ¶ added in v0.1.2
func (c HeartbeatConfig) Normalized() HeartbeatConfig
Normalized 返回带默认值的配置副本。
func (HeartbeatConfig) Validate ¶ added in v0.1.2
func (c HeartbeatConfig) Validate() error
Validate 校验配置。
type HeartbeatStatus ¶ added in v0.1.2
type HeartbeatStatus struct {
AgentID string `json:"agent_id"`
Enabled bool `json:"enabled"`
EverySeconds int `json:"every_seconds"`
TargetMode string `json:"target_mode"`
AckMaxChars int `json:"ack_max_chars"`
Running bool `json:"running"`
PendingWake bool `json:"pending_wake"`
NextRunAt *time.Time `json:"next_run_at,omitempty"`
LastHeartbeatAt *time.Time `json:"last_heartbeat_at,omitempty"`
LastAckAt *time.Time `json:"last_ack_at,omitempty"`
DeliveryError *string `json:"delivery_error,omitempty"`
}
HeartbeatStatus 表示运行态和配置快照。
type HeartbeatUpdateInput ¶ added in v0.1.2
type HeartbeatUpdateInput struct {
Enabled bool `json:"enabled"`
EverySeconds int `json:"every_seconds"`
TargetMode string `json:"target_mode"`
AckMaxChars int `json:"ack_max_chars"`
}
HeartbeatUpdateInput 表示 heartbeat 配置更新请求。
type HeartbeatWakeRequest ¶ added in v0.1.2
HeartbeatWakeRequest 表示唤醒请求。
type HeartbeatWakeResult ¶ added in v0.1.2
type HeartbeatWakeResult struct {
AgentID string `json:"agent_id"`
Mode string `json:"mode"`
Scheduled bool `json:"scheduled"`
}
HeartbeatWakeResult 表示手动唤醒返回。
type InboundWebSocketMessage ¶
type InboundWebSocketMessage struct {
Type string `json:"type"`
SessionKey string `json:"session_key,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
InboundWebSocketMessage 表示前端发送给服务端的基础消息。
type InputQueueItem ¶ added in v0.1.2
type InputQueueItem struct {
ID string `json:"id"`
Scope InputQueueScope `json:"scope"`
SessionKey string `json:"session_key"`
RoomID string `json:"room_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
SourceAgentID string `json:"source_agent_id,omitempty"`
SourceMessageID string `json:"source_message_id,omitempty"`
TargetAgentIDs []string `json:"target_agent_ids,omitempty"`
AudienceAgentIDs []string `json:"audience_agent_ids,omitempty"`
RequestID string `json:"request_id,omitempty"`
Source InputQueueSource `json:"source"`
Content string `json:"content"`
Attachments []ChatAttachment `json:"attachments,omitempty"`
DeliveryPolicy ChatDeliveryPolicy `json:"delivery_policy"`
ReplyTarget RoomReplyTarget `json:"reply_target,omitempty"`
OwnerUserID string `json:"owner_user_id,omitempty"`
RootRoundID string `json:"root_round_id,omitempty"`
HopIndex int `json:"hop_index,omitempty"`
QueueOrder int64 `json:"queue_order,omitempty"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
InputQueueItem 表示后端同步的待发送队列项。
type InputQueueScope ¶ added in v0.1.2
type InputQueueScope string
InputQueueScope 表示待发送队列所在的会话面。
const ( InputQueueScopeDM InputQueueScope = "dm" InputQueueScopeRoom InputQueueScope = "room" )
func NormalizeInputQueueScope ¶ added in v0.1.2
func NormalizeInputQueueScope(value string) InputQueueScope
NormalizeInputQueueScope 归一化队列作用域。
type InputQueueSource ¶ added in v0.1.2
type InputQueueSource string
InputQueueSource 表示队列项来源。
const ( InputQueueSourceUser InputQueueSource = "user" InputQueueSourceAgentPublicMention InputQueueSource = "agent_public_mention" InputQueueSourceAgentRoomAction InputQueueSource = "agent_room_action" )
func NormalizeInputQueueSource ¶ added in v0.1.2
func NormalizeInputQueueSource(value string) InputQueueSource
NormalizeInputQueueSource 归一化队列来源。
type MemberRecord ¶
type MemberRecord struct {
ID string `json:"id"`
RoomID string `json:"room_id"`
MemberType string `json:"member_type"`
MemberUserID string `json:"member_user_id,omitempty"`
MemberAgentID string `json:"member_agent_id,omitempty"`
JoinedAt time.Time `json:"joined_at,omitempty"`
}
MemberRecord 表示房间成员记录。
type MessagePage ¶
type MessagePage struct {
Items []Message `json:"items"`
HasMore bool `json:"has_more"`
NextBeforeRoundID *string `json:"next_before_round_id,omitempty"`
NextBeforeRoundTimestamp *int64 `json:"next_before_round_timestamp,omitempty"`
}
MessagePage 表示按 round 分页的消息历史结果。
type Options ¶
type Options struct {
Provider string `json:"provider,omitempty"`
PermissionMode string `json:"permission_mode,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
DisallowedTools []string `json:"disallowed_tools,omitempty"`
MaxTurns *int `json:"max_turns,omitempty"`
MaxThinkingTokens *int `json:"max_thinking_tokens,omitempty"`
MCPServers map[string]any `json:"mcp_servers,omitempty"`
SettingSources []string `json:"setting_sources,omitempty"`
}
Options 表示 Agent 运行时配置。
type RoomActionRecord ¶ added in v0.1.3
type RoomActionRecord struct {
ActionID string `json:"action_id"`
RoomID string `json:"room_id"`
ConversationID string `json:"conversation_id"`
ActionType RoomActionType `json:"action_type"`
RequestID string `json:"request_id,omitempty"`
SourceAgentID string `json:"source_agent_id"`
TargetAgentID string `json:"target_agent_id,omitempty"`
AudienceAgentIDs []string `json:"audience_agent_ids,omitempty"`
Content string `json:"content,omitempty"`
Visibility string `json:"visibility"`
ReplyTarget RoomReplyTarget `json:"reply_target"`
WakePolicy RoomWakePolicy `json:"wake_policy,omitempty"`
DelaySeconds int `json:"delay_seconds,omitempty"`
Timestamp int64 `json:"timestamp"`
}
RoomActionRecord 表示 Room action 的 append-only 持久化记录。
type RoomActionType ¶ added in v0.1.3
type RoomActionType string
RoomActionType 表示 Room 内部协作动作类型。
const ( RoomActionTypePrivateMessage RoomActionType = "private_message" RoomActionTypeRequestReply RoomActionType = "request_reply" RoomActionTypePrivateNote RoomActionType = "private_note" RoomActionTypeMarker RoomActionType = "marker" )
type RoomAggregate ¶
type RoomAggregate struct {
Room RoomRecord `json:"room"`
Members []MemberRecord `json:"members"`
}
RoomAggregate 表示房间聚合。
type RoomRecord ¶
type RoomRecord struct {
ID string `json:"id"`
OwnerUserID string `json:"-"`
RoomType string `json:"room_type"`
Name string `json:"name,omitempty"`
Description string `json:"description"`
Avatar string `json:"avatar,omitempty"`
SkillNames []string `json:"skill_names"`
HostAgentID string `json:"host_agent_id,omitempty"`
HostAutoReplyEnabled bool `json:"host_auto_reply_enabled"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
RoomRecord 表示房间记录。
type RoomReplyTarget ¶ added in v0.1.3
type RoomReplyTarget string
RoomReplyTarget 表示 Room action 后续回复投影位置。
const ( RoomReplyTargetPublicFeed RoomReplyTarget = "public_feed" RoomReplyTargetSenderPrivate RoomReplyTarget = "sender_private" RoomReplyTargetTargetPrivate RoomReplyTarget = "target_private" RoomReplyTargetAudience RoomReplyTarget = "audience" RoomReplyTargetNone RoomReplyTarget = "none" )
type RoomWakePolicy ¶ added in v0.1.3
type RoomWakePolicy string
RoomWakePolicy 表示 Room action 是否触发目标成员运行。
const ( RoomWakePolicyNone RoomWakePolicy = "none" RoomWakePolicyImmediate RoomWakePolicy = "immediate" RoomWakePolicyDelayed RoomWakePolicy = "delayed" )
type RoundStatusData ¶
type RoundStatusData struct {
RoundID string `json:"round_id"`
Status string `json:"status"`
IsTerminal bool `json:"is_terminal"`
ResultSubtype string `json:"result_subtype,omitempty"`
}
RoundStatusData 表示 round 生命周期事件。
type Schedule ¶ added in v0.1.2
type Schedule struct {
Kind string `json:"kind"`
RunAt *string `json:"run_at,omitempty"`
IntervalSeconds *int `json:"interval_seconds,omitempty"`
CronExpression *string `json:"cron_expression,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
Schedule 表示结构化调度定义。
func (Schedule) Normalized ¶ added in v0.1.2
Normalized 返回带默认值的调度副本。
type Session ¶
type Session struct {
SessionKey string `json:"session_key"`
AgentID string `json:"agent_id"`
SessionID *string `json:"session_id"`
RoomSessionID *string `json:"room_session_id"`
RoomID *string `json:"room_id"`
ConversationID *string `json:"conversation_id"`
ChannelType string `json:"channel_type"`
ChatType string `json:"chat_type"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
LastActivity time.Time `json:"last_activity"`
Title string `json:"title"`
MessageCount int `json:"message_count"`
Options map[string]any `json:"options"`
IsActive bool `json:"is_active"`
}
Session 表示对外暴露的统一会话模型。
type SessionKey ¶
type SessionKey struct {
Raw string `json:"raw"`
Kind SessionKeyKind `json:"kind"`
IsStructured bool `json:"is_structured"`
AgentID string `json:"agent_id,omitempty"`
Channel string `json:"channel,omitempty"`
ChatType string `json:"chat_type,omitempty"`
Ref string `json:"ref,omitempty"`
ThreadID string `json:"thread_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
RoomRef string `json:"room_ref,omitempty"`
}
SessionKey 表示结构化会话键。
type SessionKeyKind ¶
type SessionKeyKind string
SessionKeyKind 表示协议族。
const ( // SessionKeyKindAgent 表示 agent 私有运行时。 SessionKeyKindAgent SessionKeyKind = "agent" // SessionKeyKindRoom 表示共享 room 流。 SessionKeyKindRoom SessionKeyKind = "room" // SessionKeyKindUnknown 表示无法识别。 SessionKeyKindUnknown SessionKeyKind = "unknown" )
type SessionRecord ¶
type SessionRecord struct {
ID string `json:"id"`
ConversationID string `json:"conversation_id"`
AgentID string `json:"agent_id"`
RuntimeID string `json:"runtime_id"`
VersionNo int `json:"version_no"`
BranchKey string `json:"branch_key"`
IsPrimary bool `json:"is_primary"`
SDKSessionID string `json:"sdk_session_id,omitempty"`
Status string `json:"status"`
LastActivityAt time.Time `json:"last_activity_at,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
SessionRecord 表示房间内的运行时会话索引。
type SessionStatusData ¶
type SessionStatusData struct {
IsGenerating bool `json:"is_generating"`
RunningRoundIDs []string `json:"running_round_ids,omitempty"`
ControllerClient string `json:"controller_client_id,omitempty"`
ObserverCount int `json:"observer_count,omitempty"`
BoundClientCount int `json:"bound_client_count,omitempty"`
}
SessionStatusData 表示 session 生命周期事件。
type SessionTarget ¶ added in v0.1.2
type SessionTarget struct {
Kind string `json:"kind"`
BoundSessionKey string `json:"bound_session_key,omitempty"`
NamedSessionKey string `json:"named_session_key,omitempty"`
WakeMode string `json:"wake_mode,omitempty"`
}
SessionTarget 表示执行目标会话。
func (SessionTarget) Normalized ¶ added in v0.1.2
func (t SessionTarget) Normalized() SessionTarget
Normalized 返回带默认值的会话目标副本。
func (SessionTarget) Validate ¶ added in v0.1.2
func (t SessionTarget) Validate() error
Validate 校验会话目标。
type Source ¶ added in v0.1.2
type Source struct {
Kind string `json:"kind"`
CreatorAgentID string `json:"creator_agent_id,omitempty"`
ContextType string `json:"context_type,omitempty"`
ContextID string `json:"context_id,omitempty"`
ContextLabel string `json:"context_label,omitempty"`
SessionKey string `json:"session_key,omitempty"`
SessionLabel string `json:"session_label,omitempty"`
}
Source 表示任务来源元数据。
func (Source) Normalized ¶ added in v0.1.2
Normalized 返回带默认值的来源副本。
type StructuredSessionKeyError ¶
type StructuredSessionKeyError struct {
Message string
}
StructuredSessionKeyError 对齐前端 HTTP 入口的 422 校验错误。
func (StructuredSessionKeyError) Error ¶
func (e StructuredSessionKeyError) Error() string
type SystemEvent ¶ added in v0.1.2
type SystemEvent struct {
EventID string
EventType string
SourceType string
SourceID string
Payload string
Status string
CreatedAt time.Time
}
SystemEvent 表示 heartbeat/main-session 消费的系统事件。
type UpdateConversationRequest ¶
type UpdateConversationRequest struct {
Title string `json:"title,omitempty"`
}
UpdateConversationRequest 表示更新话题请求。
type UpdateJobInput ¶ added in v0.1.2
type UpdateJobInput struct {
Name *string `json:"name,omitempty"`
Schedule *Schedule `json:"schedule,omitempty"`
Instruction *string `json:"instruction,omitempty"`
SessionTarget *SessionTarget `json:"session_target,omitempty"`
Delivery *DeliveryTarget `json:"delivery,omitempty"`
Source *Source `json:"source,omitempty"`
OverlapPolicy *string `json:"overlap_policy,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
UpdateJobInput 表示更新请求。
type UpdateRequest ¶
type UpdateRequest struct {
Name *string `json:"name,omitempty"`
Options *Options `json:"options,omitempty"`
Avatar *string `json:"avatar,omitempty"`
Description *string `json:"description,omitempty"`
VibeTags []string `json:"vibe_tags,omitempty"`
}
UpdateRequest 表示更新 Agent 请求。
type UpdateRoomRequest ¶
type UpdateRoomRequest struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
Avatar *string `json:"avatar,omitempty"`
SkillNames *[]string `json:"skill_names,omitempty"`
HostAgentID *string `json:"host_agent_id,omitempty"`
HostAutoReplyEnabled *bool `json:"host_auto_reply_enabled,omitempty"`
}
UpdateRoomRequest 表示更新房间请求。
type ValidateNameResponse ¶
type ValidateNameResponse struct {
Name string `json:"name"`
NormalizedName string `json:"normalized_name"`
IsValid bool `json:"is_valid"`
IsAvailable bool `json:"is_available"`
WorkspacePath string `json:"workspace_path,omitempty"`
Reason string `json:"reason,omitempty"`
}
ValidateNameResponse 对齐当前校验协议。
type WorkspaceFileArtifactBlock ¶ added in v0.1.6
type WorkspaceFileArtifactBlock struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Path string `json:"path"`
DisplayPath string `json:"display_path,omitempty"`
Label string `json:"label,omitempty"`
Title string `json:"title,omitempty"`
ArtifactKind string `json:"artifact_kind,omitempty"`
MIMEType string `json:"mime_type,omitempty"`
Operation string `json:"operation,omitempty"`
Scope string `json:"scope,omitempty"`
WorkspaceAgentID string `json:"workspace_agent_id,omitempty"`
SourceToolUseID string `json:"source_tool_use_id,omitempty"`
SourceToolName string `json:"source_tool_name,omitempty"`
}
WorkspaceFileArtifactBlock 描述对话中可直接打开的工作区文件产物。
func (WorkspaceFileArtifactBlock) Map ¶ added in v0.1.6
func (b WorkspaceFileArtifactBlock) Map() map[string]any
Map 转成动态消息块,供现有 transcript map 写入链路复用。
Source Files
¶
- constant_session_option.go
- model_agent.go
- model_automation.go
- model_chat_attachment.go
- model_delivery_policy.go
- model_event.go
- model_input_queue.go
- model_room.go
- model_room_action.go
- model_room_request.go
- model_session.go
- model_session_key.go
- model_session_message.go
- model_workspace_file_artifact.go
- typescript_event.go