Go SDK: Align hooks with SEP (#23)

The SEP spec and C# SDK use hooks (plural, JSON array) but the Go SDK
had hook (singular, single object). This meant the wire formats were
incompatible — Go would send `{"hook": {...}}` while everything else
expects `{"hooks": [...]}`.

Signed-off-by: Ukjae Jeong <jeongukjae@gmail.com>
This commit is contained in:
Ukjae Jeong 2026-06-16 15:49:49 +01:00 • committed by GitHub
commit 23d889254b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -190,10 +190,10 @@ func prefixMutator(name, tag string, phase interceptors.InterceptionPhase, prior
return &interceptors.Mutator{
Metadata: interceptors.Metadata{
Name: name,
Hook: interceptors.Hook{
Hooks: []interceptors.Hook{{
Events: []string{interceptors.EventToolsCall},
Phase: phase,
},
}},
Mode: mode,
PriorityHint: interceptors.NewPriority(priority),
},
@ -225,10 +225,10 @@ func failMutator(name string, phase interceptors.InterceptionPhase, priority int
return &interceptors.Mutator{
Metadata: interceptors.Metadata{
Name: name,
Hook: interceptors.Hook{
Hooks: []interceptors.Hook{{
Events: []string{interceptors.EventToolsCall},
Phase: phase,
},
}},
Mode: interceptors.ModeEnforce,
PriorityHint: interceptors.NewPriority(priority),
},
@ -243,10 +243,10 @@ func blockToolValidator(toolName string) *interceptors.Validator {
return &interceptors.Validator{
Metadata: interceptors.Metadata{
Name: "block-" + toolName,
Hook: interceptors.Hook{
Hooks: []interceptors.Hook{{
Events: []string{interceptors.EventToolsCall},
Phase: interceptors.PhaseRequest,
},
}},
Mode: interceptors.ModeEnforce,
},
Handler: func(_ context.Context, inv *interceptors.Invocation) (*interceptors.ValidationResult, error) {
@ -278,10 +278,10 @@ func allowAllValidator(name string) *interceptors.Validator {
return &interceptors.Validator{
Metadata: interceptors.Metadata{
Name: name,
Hook: interceptors.Hook{
Hooks: []interceptors.Hook{{
Events: []string{interceptors.EventToolsCall},
Phase: interceptors.PhaseRequest,
},
}},
Mode: interceptors.ModeEnforce,
},
Handler: func(_ context.Context, _ *interceptors.Invocation) (*interceptors.ValidationResult, error) {