/** * Plugin SDK — 第三方 Skill 开发者套件 * * 提供标准化接口,让第三方开发者可以: * 1. 快速创建 Skill 包 * 2. 定义工具 + 参数验证 * 3. 生命周期钩子 * 4. 测试框架 * 5. 打包发布辅助 * * 参考: LobeChat Plugin SDK */ import type { ToolResult, AgentConfig } from "../types.js"; import type { SkillMeta, SkillFactory } from "../skills/types.js"; /** 工具定义(SDK 简化格式) */ export interface ToolDefinition { name: string; description: string; category?: string; /** 参数 schema(简化格式) */ params: Record; /** 工具实现 */ handler: (params: Record, context: ToolContext) => Promise; } /** 工具执行上下文 */ export interface ToolContext { /** Agent 配置 */ config: AgentConfig; /** 日志 */ log: (message: string) => void; /** 发送事件 */ emit?: (event: string, data: unknown) => void; } /** Skill 定义(SDK 格式) */ export interface PluginDefinition { /** 基本信息 */ name: string; version: string; description: string; author: string; /** 分类 */ category?: SkillMeta["category"]; /** 标签 */ tags?: string[]; /** 触发词 */ triggers?: string[]; /** 权限需求 */ permissions?: SkillMeta["permissions"]; /** 配置要求 */ configKeys?: string[]; /** 工具列表 */ tools: ToolDefinition[]; /** 生命周期 */ onActivate?: (config: AgentConfig) => Promise; onDeactivate?: () => Promise; onHealthCheck?: () => Promise<{ healthy: boolean; message?: string; }>; } /** 测试用例 */ export interface ToolTestCase { name: string; tool: string; params: Record; expect: { success: boolean; resultContains?: string; resultMatch?: RegExp; }; } /** 测试报告 */ export interface TestReport { total: number; passed: number; failed: number; results: Array<{ name: string; tool: string; passed: boolean; error?: string; durationMs: number; }>; } export declare class PluginSDK { /** * 创建一个 Skill 插件 * SDK 用户调用此方法定义插件 */ static createPlugin(def: PluginDefinition): SkillFactory; /** * 运行测试用例 */ static runTests(plugin: SkillFactory, testCases: ToolTestCase[], config?: AgentConfig): Promise; /** * 生成 Skill 脚手架代码 */ static generateScaffold(name: string, tools: string[]): string; /** * 生成 package.json 模板 */ static generatePackageJson(name: string): string; /** 验证插件定义 */ private static validate; /** 验证工具参数 */ private static validateParams; } //# sourceMappingURL=plugin-sdk.d.ts.map