/** * Society Protocol - Skills Engine v1.0 * * Sistema de skills/plugins avançado: * - skill.md: Skills Society Protocol (YAML + Markdown) * - claw.md: Skills OpenClaw específicas * - Integração multi-runtime (OpenClaw, Claude, Ollama, etc) * - Auto-discovery e hot-reload de skills * - Composição de skills (skills chamando skills) */ import { EventEmitter } from 'events'; import { type Storage } from '../storage.js'; import { type Identity } from '../identity.js'; export type SkillId = string; export type RuntimeType = 'openclaw' | 'claude' | 'ollama' | 'openai' | 'local' | 'docker' | 'http'; export interface SkillManifest { skill: { id: string; name: string; version: string; description: string; author?: string; license?: string; homepage?: string; repository?: string; tags?: string[]; icon?: string; }; runtime: { type: RuntimeType; openclaw?: { model?: string; tools?: string[]; mcp?: boolean; autoApprove?: string[]; }; claude?: { model?: string; maxTokens?: number; systemPrompt?: string; }; ollama?: { model: string; parameters?: Record; }; http?: { endpoint: string; method?: 'GET' | 'POST' | 'PUT' | 'DELETE'; headers?: Record; timeout?: number; }; docker?: { image: string; command?: string; env?: Record; volumes?: string[]; }; }; triggers: Array<{ type: 'webhook' | 'cron' | 'event' | 'file' | 'manual' | 'api' | 'mention'; config: Record; }>; capabilities: { inputs: Array<{ name: string; type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'file'; description?: string; required?: boolean; default?: any; validation?: { pattern?: string; min?: number; max?: number; enum?: any[]; }; }>; outputs: Array<{ name: string; type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'file'; description?: string; }>; }; actions: Array<{ name: string; description: string; type: 'summon' | 'message' | 'notify' | 'export' | 'http' | 'execute' | 'compose'; config: Record; condition?: string; }>; compose?: { skills: string[]; sequence: 'parallel' | 'sequential' | 'conditional'; mapping?: Record; }; society: { room?: string; federation?: string; template?: string; assignees?: string[]; requireConsensus?: boolean; reputationThreshold?: number; }; knowledge?: { space?: string; indexResults?: boolean; requiredConcepts?: string[]; }; security: { sandbox: 'none' | 'light' | 'strict' | 'vm'; permissions: string[]; maxExecutionTime?: number; maxMemory?: string; allowNetwork?: boolean; allowFilesystem?: boolean; }; meta: { created: string; updated: string; version: number; changelog?: string[]; }; } export interface ClawSkill { claw: { name: string; version: string; description: string; }; instructions: { system: string; user?: string; context?: string[]; examples?: Array<{ input: string; output: string; explanation?: string; }>; }; tools: { available: string[]; required: string[]; autoApprove?: string[]; }; workflow: { steps: Array<{ id: string; tool: string; params: Record; condition?: string; output?: string; }>; errorHandling: 'stop' | 'continue' | 'retry'; maxIterations?: number; }; validation: { preConditions?: string[]; postConditions?: string[]; assertions?: Array<{ condition: string; errorMessage: string; }>; }; integrations: { society?: { enabled: boolean; room?: string; shareResults?: boolean; }; github?: { enabled: boolean; repos?: string[]; events?: string[]; }; mcp?: { enabled: boolean; servers?: string[]; }; }; } export interface SkillRuntime { id: string; skillId: SkillId; status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'; startedAt: number; finishedAt?: number; inputs: Record; outputs: Record; logs: string[]; error?: string; artifacts: string[]; } export declare class SkillExecutionError extends Error { readonly code: 'validation' | 'runtime' | 'timeout' | 'network' | 'not_found'; readonly runtimeType?: RuntimeType; readonly details?: Record; constructor(code: 'validation' | 'runtime' | 'timeout' | 'network' | 'not_found', message: string, runtimeType?: RuntimeType, details?: Record); } export declare class SkillsEngine extends EventEmitter { private storage; private identity; private skills; private clawSkills; private runtimes; private skillDir; private watchers; private skillParser; constructor(storage: Storage, identity: Identity, skillDir?: string); private loadSkills; private loadSkillFromDir; private loadSkillFromFile; private loadClawSkillFromFile; private parseSkillMd; private parseClawMd; executeSkill(skillId: SkillId, inputs: Record, context?: { room?: string; federation?: string; trigger?: string; }): Promise; private runRuntimeWithRetries; private executeRuntime; private getMaxRetries; private getRuntimeTimeoutMs; private normalizeExecutionError; private executeOpenClaw; private executeClaude; private executeOllama; private executeHttp; private executeDocker; private executeLocal; private executeActions; private executeComposedSkills; composeSkills(name: string, skillIds: string[], options: { sequence?: 'parallel' | 'sequential' | 'conditional'; mapping?: Record; }): SkillManifest; private normalizeTrigger; private normalizeInputCapability; private normalizeOutputCapability; private mapExternalTypeToInputType; private mapExternalTypeToOutputType; private validateInputs; private evaluateCondition; private buildOpenClawInstructions; private applyComposeMapping; private executeSummonAction; private executeMessageAction; private runCommand; private setupWatchers; private generateSkillId; getSkill(id: SkillId): SkillManifest | undefined; getClawSkill(id: SkillId): ClawSkill | undefined; listSkills(): SkillManifest[]; listClawSkills(): Array<{ id: string; skill: ClawSkill; }>; searchSkills(query: string): SkillManifest[]; getRuntime(id: string): SkillRuntime | undefined; listRuntimes(): SkillRuntime[]; stop(): void; } //# sourceMappingURL=engine.d.ts.map