UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

31 lines • 1.2 kB
import { normalizeToolExposure } from "./extensions/types.js"; /** Activators belong to one extension generation; the host tool registry is resolved on each call. */ export class LazyToolActivation { #host; #activators = []; constructor(host) { this.#host = host; } register(activator) { this.#activators.push(activator); } reset() { this.#activators = []; } activate(toolName) { const definition = this.#host.getToolDefinition(toolName); if (!definition) return false; const exposure = normalizeToolExposure(definition); if (!exposure.allowLazyActivation) return false; if (this.#activators.some((activate) => activate(toolName))) return true; // Search tools remain callable without a catalog extension. Eval tools never use this fallback. if (exposure.exposure === "search" && !this.#host.getActiveTools().includes(toolName)) { this.#host.setActiveTools([...this.#host.getActiveTools(), toolName]); } return this.#host.getActiveTools().includes(toolName); } } //# sourceMappingURL=lazy-tool-activation.js.map