File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,32 @@ type PermissionRequest struct {
106106 Extra map [string ]any `json:"-"` // Additional fields vary by kind
107107}
108108
109+ // UnmarshalJSON implements custom JSON unmarshaling for PermissionRequest
110+ // to capture additional fields (varying by kind) into the Extra map.
111+ func (p * PermissionRequest ) UnmarshalJSON (data []byte ) error {
112+ // Unmarshal known fields via an alias to avoid infinite recursion
113+ type Alias PermissionRequest
114+ var alias Alias
115+ if err := json .Unmarshal (data , & alias ); err != nil {
116+ return err
117+ }
118+ * p = PermissionRequest (alias )
119+
120+ // Unmarshal all fields into a generic map
121+ var raw map [string ]any
122+ if err := json .Unmarshal (data , & raw ); err != nil {
123+ return err
124+ }
125+
126+ // Remove known fields, keep the rest as Extra
127+ delete (raw , "kind" )
128+ delete (raw , "toolCallId" )
129+ if len (raw ) > 0 {
130+ p .Extra = raw
131+ }
132+ return nil
133+ }
134+
109135// PermissionRequestResult represents the result of a permission request
110136type PermissionRequestResult struct {
111137 Kind string `json:"kind"`
You can’t perform that action at this time.
0 commit comments