x: request access for all commands, add welcome message (#13662)

This commit is contained in:
Parth Sareen
2026-01-09 18:20:39 -08:00
committed by GitHub
parent 68fafd3002
commit 1ef4241727
5 changed files with 77 additions and 13 deletions

View File

@@ -38,6 +38,22 @@ func (r *Registry) Register(tool Tool) {
r.tools[tool.Name()] = tool
}
// Unregister removes a tool from the registry by name.
func (r *Registry) Unregister(name string) {
delete(r.tools, name)
}
// Has checks if a tool with the given name is registered.
func (r *Registry) Has(name string) bool {
_, ok := r.tools[name]
return ok
}
// RegisterBash adds the bash tool to the registry.
func (r *Registry) RegisterBash() {
r.Register(&BashTool{})
}
// Get retrieves a tool by name.
func (r *Registry) Get(name string) (Tool, bool) {
tool, ok := r.tools[name]

View File

@@ -177,3 +177,47 @@ func TestWebSearchTool_Schema(t *testing.T) {
t.Error("expected 'query' property in schema")
}
}
func TestRegistry_Unregister(t *testing.T) {
r := NewRegistry()
r.Register(&BashTool{})
if r.Count() != 1 {
t.Errorf("expected 1 tool, got %d", r.Count())
}
r.Unregister("bash")
if r.Count() != 0 {
t.Errorf("expected 0 tools after unregister, got %d", r.Count())
}
_, ok := r.Get("bash")
if ok {
t.Error("expected bash tool to be removed")
}
}
func TestRegistry_Has(t *testing.T) {
r := NewRegistry()
if r.Has("bash") {
t.Error("expected Has to return false for unregistered tool")
}
r.Register(&BashTool{})
if !r.Has("bash") {
t.Error("expected Has to return true for registered tool")
}
}
func TestRegistry_RegisterBash(t *testing.T) {
r := NewRegistry()
r.RegisterBash()
if !r.Has("bash") {
t.Error("expected bash tool to be registered")
}
}