/** * Skill Executor Service * * Responsible for executing skills including script execution with * environment variable injection, browser automation coordination, * and MCP tool invocation. * * @module services/skill/skill-executor.service */ import { SkillWithPrompt, SkillExecutionContext, SkillExecutionResult } from '../../types/skill.types.js'; /** * A secret value captured for a given skill execution. stdout/stderr will * have this value replaced with `` before being returned * to callers (so the agent/LLM never sees raw credential values in output). * * @internal Exported for unit tests. */ export interface LiveSecret { value: string; label: string; } /** * Replace all occurrences of any live secret value in `text` with a * `` placeholder. * * @internal Exported for unit tests; not part of the public service API. */ export declare function redactSecrets(text: string, secrets: LiveSecret[]): string; /** * Service for executing skills * * Handles: * - Script execution with environment variable injection * - Browser automation via Claude's Chrome MCP * - MCP tool invocation * - Composite skill orchestration */ export declare class SkillExecutorService { private readonly defaultTimeoutMs; private readonly logger; /** Lazy-instantiated helpers for credential refresh. */ private geminiCliHelper; private getGeminiCliHelper; /** * Execute a skill by ID * * @param skillId - ID of the skill to execute * @param context - Execution context with agent and task information * @returns Execution result with success status and output */ executeSkill(skillId: string, context: SkillExecutionContext): Promise; /** * Execute a skill with the full skill object * * @param skill - Full skill object with prompt content * @param context - Execution context * @returns Execution result */ executeSkillInternal(skill: SkillWithPrompt, context: SkillExecutionContext): Promise; /** * Execute a script-based skill * * @param skill - Skill with script configuration * @param context - Execution context * @returns Execution result */ private executeScript; /** * Execute browser automation skill * * This returns instructions for Claude to use with the Chrome MCP. * The actual browser automation is performed by Claude using the * mcp__claude-in-chrome__* tools. * * @param skill - Skill with browser configuration * @param context - Execution context * @returns Execution result with browser automation prompt */ private executeBrowserAutomation; /** * Execute MCP tool skill * * Returns instructions for invoking the specified MCP tool. * * @param skill - Skill with MCP tool configuration * @param context - Execution context * @returns Execution result with MCP tool invocation prompt */ private executeMcpTool; /** * Execute composite skill (sequence of other skills) * * @param skill - Skill with composite configuration * @param context - Execution context * @returns Combined execution result */ private executeComposite; /** * Build environment variables for script execution * * @param skill - Skill with environment configuration * @param context - Execution context * @returns Environment variables object */ private buildEnvironment; /** * Build environment variables and collect the list of live secret values * that need to be redacted from the child process's output. Used by * `executeScript` to wire up per-execution output redaction. */ private buildEnvironmentWithSecrets; /** * For each credential requirement declared on the skill: * - Resolve it to a credential UUID (agent binding → skill default) * - Look up the credential, decrypt the payload * - Verify scopes (OAuth) * - Refresh tokens if near expiry * - Inject values into env vars named `CREWLY_CRED__*` * - Register secret values for output redaction */ private resolveAndInjectCredentials; /** * Slot name to env var prefix. `gmail-drive` → `CREWLY_CRED_GMAIL_DRIVE`. */ private credentialEnvPrefix; /** * Parse .env file content into key-value pairs * * @param content - Content of .env file * @returns Parsed environment variables */ private parseEnvFile; /** * Get interpreter command and arguments for script execution * * @param interpreter - Script interpreter type * @param scriptPath - Path to the script file * @returns Command and arguments */ private getInterpreterCommand; /** * Spawn a process and capture output * * @param command - Command to execute * @param args - Command arguments * @param options - Execution options * @returns Process result with stdout, stderr, and exit code */ private spawnProcess; /** * Build browser automation prompt for Claude * * @param config - Browser configuration * @param context - Execution context * @returns Formatted prompt for browser automation */ private buildBrowserAutomationPrompt; /** * Build MCP tool invocation prompt * * @param config - MCP tool configuration * @param context - Execution context * @returns Formatted prompt for MCP tool invocation */ private buildMcpToolPrompt; } /** * Get the singleton SkillExecutorService instance * * @returns The SkillExecutorService instance */ export declare function getSkillExecutorService(): SkillExecutorService; /** * Reset the singleton instance (for testing) */ export declare function resetSkillExecutorService(): void; //# sourceMappingURL=skill-executor.service.d.ts.map