/** * OpenClaw Tool Discovery — scans the openclaw submodule for built-in tools. * * ## Tool loading strategy * * The tool catalog metadata (names, descriptions, sections) is always available * with no dependencies. **Actual tool execution** uses pre-bundled JS modules: * * - **Bundled tools** (preferred): The build step (`npm run build`) produces * standalone ESM bundles in `dist/core-tools/`. These are compiled from * openclaw's TypeScript source at build time — no TypeScript runtime or * openclaw source tree is needed at runtime. * * - **Source fallback** (development): If bundles are not present and the * openclaw git submodule exists, tools can be loaded directly from `.ts` * source files. This requires a TypeScript-capable runtime (vitest, tsx, * ts-node). * * @module */ import type { ToolMeta, ToolSection } from "../types.js"; import { ToolRegistry } from "./registry.js"; export interface DiscoveryOptions { /** * Override the openclaw source root path (source fallback mode). * Only used when pre-built bundles are not available. * Must point at the openclaw **TypeScript source** directory (not a compiled bundle), * and the calling runtime must be capable of importing `.ts` files (vitest, tsx, ts-node). */ openclawRoot?: string; /** * Filter which tool IDs to include. If undefined, all tools are included. * Supports "group:" prefixes (e.g., "group:fs", "group:web"). */ include?: string[]; /** * Tool IDs to exclude from discovery. */ exclude?: string[]; /** * Called when tool modules cannot be loaded (missing openclaw source, * compiled JS environment without a TypeScript runtime, etc.). * If not provided, warnings are silently discarded. */ onLoadWarning?: (message: string) => void; } /** * Return the list of all core tool sections. */ export declare function getCoreSections(): ToolSection[]; /** * Return the full core tool catalog metadata (without loading any implementations). */ export declare function getCoreToolCatalog(): ToolMeta[]; /** * Discover and register all core OpenClaw tools into a registry. * * **Catalog/metadata use only.** This function immediately registers a * null-returning stub factory for every matching catalog entry — no module * loading occurs and no async I/O is performed. Because every factory always * returns `null`, calling {@link ToolRegistry.resolveAll} on a registry * populated solely by this function will return an empty array (`[]`). * * Use this only for catalog or metadata use-cases: listing tool names, * descriptions, and sections without needing executable tools. * For tools that can actually execute, use {@link discoverCoreToolsAsync} * instead. * * @param registry - The registry to populate. * @param options - Discovery options (filters, paths). Set {@link DiscoveryOptions.onLoadWarning} * to observe factory-load errors instead of having them silently discarded. * @see discoverCoreToolsAsync */ export declare function discoverCoreTools(registry: ToolRegistry, options?: DiscoveryOptions): void; /** * Async version of tool discovery that properly handles ESM dynamic imports. * * Loading strategy (in order of preference): * 1. **Bundled tools**: Loads from `dist/core-tools/` — pre-compiled standalone * ESM bundles produced by the build step. Works in any Node 18+ environment. * 2. **Source fallback**: Loads from the openclaw submodule's `.ts` source files. * Requires a TypeScript-capable runtime (vitest, tsx, ts-node). * * Tools whose modules cannot be loaded are still registered in the catalog * (metadata available) but their factories return `null` at call time. * * @param registry - The registry to populate. * @param options - Discovery options. Set {@link DiscoveryOptions.onLoadWarning} * to observe factory-load errors instead of having them silently discarded. */ export declare function discoverCoreToolsAsync(registry: ToolRegistry, options?: DiscoveryOptions): Promise; //# sourceMappingURL=discovery.d.ts.map