@@ -437,7 +437,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
437437 session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
438438 OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
439439 OnElicitationRequest : func (ctx copilot.ElicitationContext ) (copilot.ElicitationResult , error ) {
440- return copilot.ElicitationResult {Action : "accept" , Content : map [string ]any {}}, nil
440+ return copilot.ElicitationResult {Action : copilot . ElicitationActionAccept , Content : map [string ]any {}}, nil
441441 },
442442 })
443443 if err != nil {
@@ -481,7 +481,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
481481 t .Errorf ("Expected RequestedSchema to contain 'confirmed' property" )
482482 }
483483 return copilot.ElicitationResult {
484- Action : "accept" ,
484+ Action : copilot . ElicitationActionAccept ,
485485 Content : map [string ]any {"confirmed" : true },
486486 }, nil
487487 },
@@ -505,7 +505,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
505505 session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
506506 OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
507507 OnElicitationRequest : func (ec copilot.ElicitationContext ) (copilot.ElicitationResult , error ) {
508- return copilot.ElicitationResult {Action : "decline" }, nil
508+ return copilot.ElicitationResult {Action : copilot . ElicitationActionDecline }, nil
509509 },
510510 })
511511 if err != nil {
@@ -534,7 +534,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
534534 t .Errorf ("Expected RequestedSchema to contain 'selection' property" )
535535 }
536536 return copilot.ElicitationResult {
537- Action : "accept" ,
537+ Action : copilot . ElicitationActionAccept ,
538538 Content : map [string ]any {"selection" : "beta" },
539539 }, nil
540540 },
@@ -568,7 +568,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
568568 t .Errorf ("Expected RequestedSchema to contain 'value' property" )
569569 }
570570 return copilot.ElicitationResult {
571- Action : "accept" ,
571+ Action : copilot . ElicitationActionAccept ,
572572 Content : map [string ]any {"value" : "typed value" },
573573 }, nil
574574 },
@@ -601,9 +601,9 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
601601 ctx .ConfigureForTest (t )
602602
603603 responses := []copilot.ElicitationResult {
604- {Action : "accept" , Content : map [string ]any {"name" : "Mona" }},
605- {Action : "decline" },
606- {Action : "cancel" },
604+ {Action : copilot . ElicitationActionAccept , Content : map [string ]any {"name" : "Mona" }},
605+ {Action : copilot . ElicitationActionDecline },
606+ {Action : copilot . ElicitationActionCancel },
607607 }
608608 var idx int
609609
@@ -625,9 +625,8 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
625625 t .Fatalf ("CreateSession failed: %v" , err )
626626 }
627627
628- schema := rpc.UIElicitationSchema {
629- Type : rpc .UIElicitationSchemaTypeObject ,
630- Properties : map [string ]rpc.UIElicitationSchemaProperty {
628+ schema := copilot.ElicitationSchema {
629+ Properties : map [string ]any {
631630 "name" : & rpc.UIElicitationSchemaPropertyString {},
632631 },
633632 Required : []string {"name" },
@@ -637,26 +636,26 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
637636 if err != nil {
638637 t .Fatalf ("Elicitation accept call failed: %v" , err )
639638 }
640- if accept .Action != "accept" {
639+ if accept .Action != copilot . ElicitationActionAccept {
641640 t .Errorf ("Expected accept.Action='accept', got %q" , accept .Action )
642641 }
643- if accept .Content == nil || fmt . Sprintf ( "%v" , accept .Content ["name" ]) != "Mona" {
642+ if accept .Content == nil || accept .Content ["name" ] != "Mona" {
644643 t .Errorf ("Expected accept.Content[name]='Mona', got %v" , accept .Content )
645644 }
646645
647646 decline , err := session .UI ().Elicitation (t .Context (), "Name?" , schema )
648647 if err != nil {
649648 t .Fatalf ("Elicitation decline call failed: %v" , err )
650649 }
651- if decline .Action != "decline" {
650+ if decline .Action != copilot . ElicitationActionDecline {
652651 t .Errorf ("Expected decline.Action='decline', got %q" , decline .Action )
653652 }
654653
655654 cancel , err := session .UI ().Elicitation (t .Context (), "Name?" , schema )
656655 if err != nil {
657656 t .Fatalf ("Elicitation cancel call failed: %v" , err )
658657 }
659- if cancel .Action != "cancel" {
658+ if cancel .Action != copilot . ElicitationActionCancel {
660659 t .Errorf ("Expected cancel.Action='cancel', got %q" , cancel .Action )
661660 }
662661 })
@@ -681,7 +680,7 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
681680 session , err := client .CreateSession (t .Context (), & copilot.SessionConfig {
682681 OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
683682 OnElicitationRequest : func (ec copilot.ElicitationContext ) (copilot.ElicitationResult , error ) {
684- return copilot.ElicitationResult {Action : "accept" , Content : map [string ]any {}}, nil
683+ return copilot.ElicitationResult {Action : copilot . ElicitationActionAccept , Content : map [string ]any {}}, nil
685684 },
686685 })
687686 if err != nil {
@@ -694,29 +693,14 @@ func TestUIElicitationCallbackE2E(t *testing.T) {
694693 })
695694}
696695
697- // schemaHasProperty reports whether the elicitation schema map has a top-level
698- // property with the given name. RequestedSchema["properties"] is typically a
699- // map[string]rpc.UIElicitationSchemaProperty, but we accept any map[string]X.
700- func schemaHasProperty (schema map [string ]any , name string ) bool {
696+ // schemaHasProperty reports whether the elicitation schema has a top-level
697+ // property with the given name.
698+ func schemaHasProperty (schema * copilot.ElicitationSchema , name string ) bool {
701699 if schema == nil {
702700 return false
703701 }
704- props , ok := schema ["properties" ]
705- if ! ok || props == nil {
706- return false
707- }
708- switch p := props .(type ) {
709- case map [string ]any :
710- _ , found := p [name ]
711- return found
712- case map [string ]rpc.UIElicitationSchemaProperty :
713- _ , found := p [name ]
714- return found
715- default :
716- // Fallback: marshal/unmarshal via reflection-friendly route.
717- // For test diagnostic purposes we treat unknown shapes as not found.
718- return false
719- }
702+ _ , found := schema .Properties [name ]
703+ return found
720704}
721705
722706func TestUIElicitationMultiClientE2E (t * testing.T ) {
@@ -776,7 +760,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
776760 OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
777761 SuppressResumeEvent : true ,
778762 OnElicitationRequest : func (ctx copilot.ElicitationContext ) (copilot.ElicitationResult , error ) {
779- return copilot.ElicitationResult {Action : "accept" , Content : map [string ]any {}}, nil
763+ return copilot.ElicitationResult {Action : copilot . ElicitationActionAccept , Content : map [string ]any {}}, nil
780764 },
781765 })
782766 if err != nil {
@@ -836,7 +820,7 @@ func TestUIElicitationMultiClientE2E(t *testing.T) {
836820 OnPermissionRequest : copilot .PermissionHandler .ApproveAll ,
837821 SuppressResumeEvent : true ,
838822 OnElicitationRequest : func (ctx copilot.ElicitationContext ) (copilot.ElicitationResult , error ) {
839- return copilot.ElicitationResult {Action : "accept" , Content : map [string ]any {}}, nil
823+ return copilot.ElicitationResult {Action : copilot . ElicitationActionAccept , Content : map [string ]any {}}, nil
840824 },
841825 })
842826 if err != nil {
0 commit comments