Why: The product needs a session mode and a place to show tool arguments on a confirmation card without inventing a second card type. Evidence: GOWORK=off go test . passed. New fields use omitempty, so existing golden JSON stays the same. Impact: Empty permission mode still means the profile policy. Clients that ignore unknown fields keep working. Refs: feature/permission-hooks Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
2.2 KiB
Go
54 lines
2.2 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"`
|
|
// Detail 是确认卡上的参数预览或其他补充说明。
|
|
Detail string `json:"detail,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"`
|
|
}
|