File tree Expand file tree Collapse file tree 3 files changed +6
-36
lines changed
test/scenarios/callbacks/permissions/go Expand file tree Collapse file tree 3 files changed +6
-36
lines changed Original file line number Diff line number Diff line change @@ -350,8 +350,8 @@ func TestTools(t *testing.T) {
350350 for _ , req := range permissionRequests {
351351 if req .Kind == "custom-tool" {
352352 customToolReqs ++
353- if toolName , ok := req .Extra [ "toolName" ].( string ); ! ok || toolName != "encrypt_string" {
354- t .Errorf ("Expected toolName 'encrypt_string', got '%v'" , req .Extra [ "toolName" ] )
353+ if req .ToolName == nil || * req . ToolName != "encrypt_string" {
354+ t .Errorf ("Expected toolName 'encrypt_string', got '%v'" , req .ToolName )
355355 }
356356 }
357357 }
Original file line number Diff line number Diff line change @@ -99,39 +99,6 @@ type SystemMessageConfig struct {
9999 Content string `json:"content,omitempty"`
100100}
101101
102- // PermissionRequest represents a permission request from the server
103- type PermissionRequest struct {
104- Kind string `json:"kind"`
105- ToolCallID string `json:"toolCallId,omitempty"`
106- Extra map [string ]any `json:"-"` // Additional fields vary by kind
107- }
108-
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-
135102// PermissionRequestResultKind represents the kind of a permission request result.
136103type PermissionRequestResultKind string
137104
Original file line number Diff line number Diff line change @@ -30,7 +30,10 @@ func main() {
3030 Model : "claude-haiku-4.5" ,
3131 OnPermissionRequest : func (req copilot.PermissionRequest , inv copilot.PermissionInvocation ) (copilot.PermissionRequestResult , error ) {
3232 permissionLogMu .Lock ()
33- toolName , _ := req .Extra ["toolName" ].(string )
33+ toolName := ""
34+ if req .ToolName != nil {
35+ toolName = * req .ToolName
36+ }
3437 permissionLog = append (permissionLog , fmt .Sprintf ("approved:%s" , toolName ))
3538 permissionLogMu .Unlock ()
3639 return copilot.PermissionRequestResult {Kind : "approved" }, nil
You can’t perform that action at this time.
0 commit comments