Changeset 0.25.0 (#160)

This commit is contained in:
2026-03-08 16:54:17 +00:00
parent 937be26578
commit 2b01d540d6
63 changed files with 6942 additions and 2773 deletions

View File

@@ -38,16 +38,31 @@ func AllDefinitions() []ToolDef {
// AllDefinitionsFiltered returns tool definitions excluding any names in the
// disabled set. Used when the frontend sends a disabled_tools list.
//
// Deprecated: use AvailableFor() for context-aware filtering. This wrapper
// remains for call sites that don't yet have a ToolContext.
func AllDefinitionsFiltered(disabled map[string]bool) []ToolDef {
if len(disabled) == 0 {
return AllDefinitions()
}
return AvailableFor(ToolContext{}, disabled)
}
// AvailableFor returns tool definitions available in the given context,
// excluding any names in the disabled set. Tools that implement
// ContextualTool have their Availability() predicate evaluated against
// tctx. Tools that only implement Tool (no predicate) are always included.
func AvailableFor(tctx ToolContext, disabled map[string]bool) []ToolDef {
defs := make([]ToolDef, 0, len(registry))
for _, t := range registry {
def := t.Definition()
if !disabled[def.Name] {
defs = append(defs, def)
if disabled[def.Name] {
continue
}
// Check context-aware availability if the tool declares it
if ct, ok := t.(ContextualTool); ok {
if !ct.Availability()(tctx) {
continue
}
}
defs = append(defs, def)
}
return defs
}