agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
37 lines • 1.4 kB
TypeScript
/**
* gatedTools — wrap any ToolProvider with a per-tool gating predicate.
*
* The DECORATOR for tool providers. Filters the inner provider's
* output by running the predicate against each tool name. Composes
* freely:
*
* gatedTools(
* gatedTools(staticTools(allTools), readOnlyPredicate),
* skillGatePredicate,
* )
*
* Reads as: "static list of all tools, filtered by readonly policy,
* then further filtered by the active skill's tool set." Each gate
* is one concern; composition handles the rest.
*
* Pattern: Decorator (GoF) — wraps any ToolProvider with an additional
* filter. Mirrors `withRetry` / `withFallback` over LLMProvider.
*
* @example Read-only enforcement
* const readOnly = gatedTools(
* staticTools([read, write]),
* (toolName) => toolName.startsWith('read_'),
* );
* readOnly.list(ctx); // → [read]
*
* @example Skill-gated dispatch (autoActivate use case)
* const skillGated = gatedTools(
* staticTools(allTools),
* (toolName, ctx) => ctx.activeSkillId
* ? skillToolMap[ctx.activeSkillId].includes(toolName)
* : alwaysVisible.includes(toolName),
* );
*/
import type { ToolProvider, ToolGatePredicate } from '../tools/toolProvider.js';
export declare function gatedTools(inner: ToolProvider, predicate: ToolGatePredicate): ToolProvider;
//# sourceMappingURL=gatedTools.d.ts.map