/** * Custom Skills - A meta-skill that registers user-defined tools from configuration. * * Tier 2 built-in skill: no external dependencies required. * Allows users to define arbitrary tools via config without writing skill classes. * Each tool definition in the config specifies its name, description, parameters, * and a handler function body (executed via Function constructor). * * This is useful for rapid prototyping, simple integrations, and cases where * creating a full skill class would be overkill. */ import { SkillBase } from '../SkillBase.js'; import type { SkillToolDefinition, SkillPromptSection, SkillConfig, ParameterSchemaEntry } from '../SkillBase.js'; /** * A meta-skill that registers user-defined tools from configuration. * * Tier 2 built-in skill with no external dependencies. Allows users to define * arbitrary tools via config without writing skill classes. Each tool definition * specifies a name, description, parameters, and a JavaScript handler function * body that is compiled via the Function constructor at instantiation time. * * **Security warning:** This skill uses `new Function()` to compile user-provided * code at runtime. It is gated behind the `SWML_ALLOW_CUSTOM_HANDLER_CODE=true` * environment variable to prevent unintended code execution. * * @example * ```ts * // Requires SWML_ALLOW_CUSTOM_HANDLER_CODE=true * agent.addSkill('custom_skills', { * tools: [ * { * name: 'echo', * description: 'Echo back the caller-supplied message.', * parameters: { type: 'object', properties: { msg: { type: 'string' } } }, * handlerBody: 'return new FunctionResult(args.msg);', * }, * ], * }); * ``` */ export declare class CustomSkillsSkill extends SkillBase { static SKILL_NAME: string; static SKILL_DESCRIPTION: string; private _compiledHandlers; private _compilationErrors; /** * @param config - Configuration object containing a `tools` array of custom tool definitions. */ constructor(config?: SkillConfig); static getParameterSchema(): Record; /** * Pre-compile handler code into functions during construction. * This catches syntax errors early and avoids re-compilation on each call. */ private _compileHandlers; /** * Get the raw tool definitions from config. */ private _getToolDefs; /** @returns Array of dynamically generated tools from the configuration, with compiled handlers. */ getTools(): SkillToolDefinition[]; /** @returns Prompt section listing all custom tools and their descriptions. */ protected _getPromptSections(): SkillPromptSection[]; /** * Build tool parameters from the custom tool definition. */ private _buildParameters; /** * Get handler compilation errors for diagnostic purposes. * @returns A copy of the map from tool name to error message. */ getCompilationErrors(): Map; } /** * Factory function for creating CustomSkillsSkill instances. * @param config - Configuration containing a `tools` array of custom tool definitions. * @returns A new CustomSkillsSkill instance. */ export declare function createSkill(config?: SkillConfig): CustomSkillsSkill;