@@ -2,6 +2,7 @@ package registrybroker
22
33import (
44 "context"
5+ "encoding/json"
56 "net/http"
67 "time"
78)
@@ -107,6 +108,7 @@ type DelegationPlanCandidate struct {
107108 Reasons []string `json:"reasons,omitempty"`
108109 SuggestedMessage string `json:"suggestedMessage,omitempty"`
109110 Agent JSONObject `json:"agent,omitempty"`
111+ Extras JSONObject `json:"-"`
110112}
111113
112114type DelegationOpportunity struct {
@@ -122,6 +124,7 @@ type DelegationOpportunity struct {
122124 Languages []string `json:"languages,omitempty"`
123125 Artifacts []string `json:"artifacts,omitempty"`
124126 Candidates []DelegationPlanCandidate `json:"candidates,omitempty"`
127+ Extras JSONObject `json:"-"`
125128}
126129
127130type DelegationPlanResponse struct {
@@ -137,6 +140,118 @@ type DelegationPlanResponse struct {
137140 LocalFirstReason string `json:"localFirstReason,omitempty"`
138141 Recommendation * DelegationPlanRecommendation `json:"recommendation,omitempty"`
139142 Opportunities []DelegationOpportunity `json:"opportunities,omitempty"`
143+ Extras JSONObject `json:"-"`
144+ }
145+
146+ func (c * DelegationPlanCandidate ) UnmarshalJSON (data []byte ) error {
147+ type candidateAlias DelegationPlanCandidate
148+ aux := candidateAlias {}
149+ if err := json .Unmarshal (data , & aux ); err != nil {
150+ return err
151+ }
152+ candidate := DelegationPlanCandidate (aux )
153+ extras , err := extractUnknownFields (
154+ data ,
155+ "uaid" ,
156+ "label" ,
157+ "registry" ,
158+ "score" ,
159+ "trustScore" ,
160+ "verified" ,
161+ "communicationSupported" ,
162+ "availability" ,
163+ "explanation" ,
164+ "matchedQueries" ,
165+ "matchedRoles" ,
166+ "matchedProtocols" ,
167+ "matchedSurfaces" ,
168+ "matchedLanguages" ,
169+ "matchedArtifacts" ,
170+ "matchedTaskTags" ,
171+ "reasons" ,
172+ "suggestedMessage" ,
173+ "agent" ,
174+ )
175+ if err != nil {
176+ return err
177+ }
178+ candidate .Extras = extras
179+ * c = candidate
180+ return nil
181+ }
182+
183+ func (o * DelegationOpportunity ) UnmarshalJSON (data []byte ) error {
184+ type opportunityAlias DelegationOpportunity
185+ aux := opportunityAlias {}
186+ if err := json .Unmarshal (data , & aux ); err != nil {
187+ return err
188+ }
189+ opportunity := DelegationOpportunity (aux )
190+ extras , err := extractUnknownFields (
191+ data ,
192+ "id" ,
193+ "title" ,
194+ "reason" ,
195+ "role" ,
196+ "type" ,
197+ "suggestedMode" ,
198+ "searchQueries" ,
199+ "protocols" ,
200+ "surfaces" ,
201+ "languages" ,
202+ "artifacts" ,
203+ "candidates" ,
204+ )
205+ if err != nil {
206+ return err
207+ }
208+ opportunity .Extras = extras
209+ * o = opportunity
210+ return nil
211+ }
212+
213+ func (r * DelegationPlanResponse ) UnmarshalJSON (data []byte ) error {
214+ type responseAlias DelegationPlanResponse
215+ aux := responseAlias {}
216+ if err := json .Unmarshal (data , & aux ); err != nil {
217+ return err
218+ }
219+ response := DelegationPlanResponse (aux )
220+ extras , err := extractUnknownFields (
221+ data ,
222+ "task" ,
223+ "context" ,
224+ "summary" ,
225+ "intents" ,
226+ "surfaces" ,
227+ "protocols" ,
228+ "languages" ,
229+ "artifacts" ,
230+ "shouldDelegate" ,
231+ "localFirstReason" ,
232+ "recommendation" ,
233+ "opportunities" ,
234+ )
235+ if err != nil {
236+ return err
237+ }
238+ response .Extras = extras
239+ * r = response
240+ return nil
241+ }
242+
243+ func extractUnknownFields (data []byte , knownKeys ... string ) (JSONObject , error ) {
244+ var payload map [string ]any
245+ if err := json .Unmarshal (data , & payload ); err != nil {
246+ return nil , err
247+ }
248+ for _ , key := range knownKeys {
249+ delete (payload , key )
250+ }
251+ if len (payload ) == 0 {
252+ return nil , nil
253+ }
254+ return JSONObject (payload ), nil
140255}
141256
142257type VectorSearchFilter struct {
0 commit comments