返回 DeepSeek-Reasonix
extension_surface.go
根目录 / internal / event / extension_surface.go
1 package event
2
3 // Extension surface kind values carried by ExtensionSurfacePayload.Kind. They
4 // mirror the extension protocol's structured surface kinds; "request" is
5 // reserved for extension request surfaces (blocking prompts route through the
6 // ordinary AskRequest channel instead).
7 const (
8 ExtensionSurfaceStatus = "status"
9 ExtensionSurfaceCard = "card"
10 ExtensionSurfaceForm = "form"
11 ExtensionSurfaceNotification = "notification"
12 ExtensionSurfaceRequest = "request"
13 )
14
15 // ExtensionSurfacePayload carries one extension sidecar's structured UI
16 // contribution for the ExtensionSurface / ExtensionStatus kinds. The structs
17 // mirror the Extension Protocol v2 UI payload DTOs field-for-field so any
18 // frontend can render them with native widgets; the protocol stays
19 // structured-only (no HTML/CSS/JS/URLs). All user-visible strings are already
20 // credential-redacted by the host UI hub before the event is emitted. Exactly
21 // one sub-struct is set, selected by Kind.
22 type ExtensionSurfacePayload struct {
23 PluginID string
24 SurfaceID string
25 SessionID string
26 Generation uint64
27 FormInstanceID string
28 Kind string // status | card | form | notification (request reserved)
29 Status *ExtensionStatusView
30 Card *ExtensionCardView
31 Form *ExtensionFormView
32 Notification *ExtensionNotificationView
33 }
34
35 // ExtensionStatusView is a one-line status contribution (mirrors the
36 // protocol's UIStatusPayload).
37 type ExtensionStatusView struct {
38 Label string
39 Detail string
40 Severity string // info | warn | error
41 Progress *float64
42 }
43
44 // ExtensionKeyValue is one labelled value row in a card (mirrors UIKeyValue).
45 type ExtensionKeyValue struct {
46 Key string
47 Value string
48 }
49
50 // ExtensionActionRef renders a button invoking a declared extension action
51 // (mirrors UIActionRef).
52 type ExtensionActionRef struct {
53 ActionID string
54 Label string
55 }
56
57 // ExtensionCardView is a rich read-only surface (mirrors UICardPayload).
58 type ExtensionCardView struct {
59 Title string
60 Markdown string
61 Text string
62 Fields []ExtensionKeyValue
63 Progress *float64
64 Actions []ExtensionActionRef
65 }
66
67 // ExtensionFormField is one input row of a form surface (mirrors UIFormField).
68 type ExtensionFormField struct {
69 Key string
70 Label string
71 Kind string // confirm | input | select | multiselect
72 Options []string
73 Default any
74 Required bool
75 }
76
77 // ExtensionFormView is an editable surface; submissions return to the
78 // extension through the UI hub (mirrors UIFormPayload).
79 type ExtensionFormView struct {
80 Title string
81 Message string
82 Fields []ExtensionFormField
83 }
84
85 // ExtensionNotificationView is a transient toast-style message (mirrors
86 // UINotificationPayload).
87 type ExtensionNotificationView struct {
88 Title string
89 Body string
90 Severity string // info | warn | error
91 }
92
92 lines GO