Files
Agent-System-Core/hitl.go
T
weichen a4ea66c41d Add activity card, card events, HITL anchoring and UI vocabulary extension
Why: Contract foundation for the inbox/command-bus/workspaces phase (proposal
  D28/D30): ActivityCard as the first-class state object behind the right-rail
  inbox, card.* stream events, inline-confirm anchoring (anchorMessageId +
  blocked/blockReason) on HITL, seven new UI schema vocabularies, plugin
  provides.commands/workspaces, workflow card step and workspace declarations.

Evidence: go vet clean; conformance goldens regenerated and verified — new
  activity_card / hitl_card_blocked / event_card_created / event_card_resolved /
  ui_vocabularies samples plus extended plugin_manifest; CardStatus.Terminal
  helper unit-covered via build; ts/types.ts mirrors all additions.

Impact: Additive only (omitempty fields, new types, new event types) — existing
  consumers ignore unknown values per forward-compat rule; vocabulary spec types
  carry a Spec suffix to avoid const-name collisions.

Refs: modules/documents docs/proposals/2026-09-30-ui-inbox-command-workspace.md
2026-09-30 06:22:00 +00:00

52 lines
2.1 KiB
Go

package core
import "encoding/json"
// HITL 卡片协议(4.5):choice | input | confirm | form 四种;
// 发起方必须给 Choices 提供 description 与 impact——用户在决策点需要上下文。
type HITLCard struct {
ID ID `json:"id"`
RunID ID `json:"runId"`
ConversationID ID `json:"conversationId"`
Question string `json:"question"`
Kind HITLKind `json:"kind"`
Choices []HITLChoice `json:"choices,omitempty"`
AllowFreeInput bool `json:"allowFreeInput"`
FreeInputHint string `json:"freeInputHint,omitempty"`
TimeoutSec *int `json:"timeoutSec,omitempty"`
Form []UINode `json:"form,omitempty"` // form kind 的字段(UI 词汇)
CreatedAt string `json:"createdAt"`
Resolved bool `json:"resolved"`
// AnchorMessageID:锚定的发起消息——未决卡内联渲染于该消息之后(对话流组成部分),
// 并在右栏收件箱生成投影卡(双现;任一侧响应即双侧销项)。
AnchorMessageID ID `json:"anchorMessageId,omitempty"`
// Blocked:阻断态(门禁不通过等)——确认入口禁用并给出出路;阻断本身进审计。
Blocked bool `json:"blocked,omitempty"`
BlockReason string `json:"blockReason,omitempty"`
}
type HITLKind string
const (
HITLKindChoice HITLKind = "choice"
HITLKindInput HITLKind = "input"
HITLKindConfirm HITLKind = "confirm"
HITLKindForm HITLKind = "form"
)
type HITLChoice struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
Impact string `json:"impact"` // 该选择可能造成的影响(必填)
Recommended bool `json:"recommended,omitempty"`
}
// HITLResponse 是用户对卡片的响应;自由输入时 ChoiceID 为空。
type HITLResponse struct {
CardID ID `json:"cardId"`
ChoiceID string `json:"choiceId,omitempty"`
FreeText string `json:"freeText,omitempty"`
FormData json.RawMessage `json:"formData,omitempty"`
}