/** * Skill Script Runner Module - Dedicated executor for skill-bundled scripts * * Purpose: * Provides a sandboxed, path-guarded script executor for files stored under * `{world-dir}/skills/{skill-name}/scripts/`. This is the ONLY entry point * for skill script execution — the generic `shell-cmd-tool.ts` must NEVER * be used for skill scripts. * * Features: * - Strict path guards: resolve + verify target stays within the skill's `scripts/` directory * - Runtime sandbox permissions: allowlist of allowed interpreters * - Execution controls: configurable timeout, max output size, exit code capture * - stdout/stderr capture with size limits * - Explicit error handling with structured results * * Notes: * - This module does NOT use `shell-cmd-tool.ts` — it is a separate executor * - Scripts are executed via child_process.spawn with explicit interpreter * - Path traversal is prevented by resolving + verifying all paths * - Only scripts under `{skill-dir}/scripts/` are allowed to execute * * Recent Changes: * - 2026-02-09: Initial implementation for world-level skills system */ /** Result of a skill script execution */ export interface SkillScriptResult { /** Exit code of the process (null if killed/timed out) */ exitCode: number | null; /** Signal that terminated the process, if any */ signal: string | null; /** Captured stdout (truncated to maxOutputSize) */ stdout: string; /** Captured stderr (truncated to maxOutputSize) */ stderr: string; /** Whether execution was killed due to timeout */ timedOut: boolean; /** Whether output was truncated */ truncated: boolean; /** Execution duration in milliseconds */ durationMs: number; } /** Options for script execution */ export interface SkillScriptOptions { /** Timeout in milliseconds (default: 30000 = 30 seconds) */ timeout?: number; /** Maximum output size in bytes for stdout/stderr each (default: 65536 = 64KB) */ maxOutputSize?: number; /** Environment variables to pass to the script */ env?: Record; /** Arguments to pass to the script */ args?: string[]; } /** * Build the scripts directory path for a skill. */ export declare function getSkillScriptsDir(rootPath: string, worldId: string, skillName: string): string; /** * Resolve and validate that a script path stays within the skill's scripts/ directory. * Throws if the resolved path escapes the boundary. */ export declare function resolveAndGuardScriptPath(scriptsDir: string, scriptName: string): string; /** * Determine the interpreter to use for a script based on its file extension. * Returns null if the extension is not in the allowlist. */ export declare function detectInterpreter(scriptPath: string): { command: string; extraArgs: string[]; } | null; /** * Execute a skill script with sandbox/permission guards. * * This function: * 1. Validates the script path stays within the skill's scripts/ directory * 2. Verifies the script file exists * 3. Detects the appropriate interpreter from file extension * 4. Executes with timeout, output size limits, and environment isolation * 5. Captures stdout, stderr, exit code, and timing * * @param rootPath - Root storage path (e.g., ~/agent-world) * @param worldId - World identifier * @param skillName - Skill name (kebab-case) * @param scriptName - Script filename (e.g., "run.sh", "analyze.py") * @param options - Execution options (timeout, max output, env, args) * @returns Structured execution result */ export declare function runSkillScript(rootPath: string, worldId: string, skillName: string, scriptName: string, options?: SkillScriptOptions): Promise; //# sourceMappingURL=skill-script-runner.d.ts.map