@elizaos/plugin-shell 1.2.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/actions/clearHistory.d.ts +4 -0
  2. package/dist/actions/clearHistory.d.ts.map +1 -0
  3. package/dist/actions/executeCommand.d.ts +6 -0
  4. package/dist/actions/executeCommand.d.ts.map +1 -0
  5. package/dist/actions/index.d.ts +3 -0
  6. package/dist/actions/index.d.ts.map +1 -0
  7. package/dist/build.d.ts +2 -0
  8. package/dist/build.d.ts.map +1 -0
  9. package/dist/generated/prompts/typescript/prompts.d.ts +12 -0
  10. package/dist/generated/prompts/typescript/prompts.d.ts.map +1 -0
  11. package/dist/generated/specs/spec-helpers.d.ts +49 -0
  12. package/dist/generated/specs/spec-helpers.d.ts.map +1 -0
  13. package/dist/generated/specs/specs.d.ts +83 -0
  14. package/dist/generated/specs/specs.d.ts.map +1 -0
  15. package/dist/index.browser.d.ts +4 -0
  16. package/dist/index.browser.d.ts.map +1 -0
  17. package/dist/index.d.ts +10 -106
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +779 -911
  20. package/dist/index.js.map +19 -1
  21. package/dist/providers/index.d.ts +2 -0
  22. package/dist/providers/index.d.ts.map +1 -0
  23. package/dist/providers/shellHistoryProvider.d.ts +4 -0
  24. package/dist/providers/shellHistoryProvider.d.ts.map +1 -0
  25. package/dist/services/index.d.ts +2 -0
  26. package/dist/services/index.d.ts.map +1 -0
  27. package/dist/services/shellService.d.ts +24 -0
  28. package/dist/services/shellService.d.ts.map +1 -0
  29. package/dist/types/index.d.ts +30 -0
  30. package/dist/types/index.d.ts.map +1 -0
  31. package/dist/utils/config.d.ts +4 -0
  32. package/dist/utils/config.d.ts.map +1 -0
  33. package/dist/utils/index.d.ts +3 -0
  34. package/dist/utils/index.d.ts.map +1 -0
  35. package/dist/utils/pathUtils.d.ts +5 -0
  36. package/dist/utils/pathUtils.d.ts.map +1 -0
  37. package/package.json +73 -19
  38. package/LICENSE +0 -21
  39. package/README.md +0 -352
package/dist/index.js.map CHANGED
@@ -1 +1,19 @@
1
- {"version":3,"sources":["../src/services/shellService.ts","../src/environment.ts","../src/utils/pathUtils.ts","../src/actions/executeCommand.ts","../src/actions/clearHistory.ts","../src/providers/shellHistoryProvider.ts","../src/index.ts"],"sourcesContent":["import {\n type IAgentRuntime,\n Service,\n logger,\n} from '@elizaos/core';\nimport spawn from 'cross-spawn';\nimport path from 'path';\nimport { loadShellConfig, type ShellConfig } from '../environment';\nimport {\n validatePath,\n isSafeCommand,\n isForbiddenCommand,\n} from '../utils/pathUtils';\n\nexport interface CommandResult {\n success: boolean;\n stdout: string;\n stderr: string;\n exitCode: number | null;\n error?: string;\n executedIn: string;\n}\n\nexport interface CommandHistoryEntry {\n command: string;\n stdout: string;\n stderr: string;\n exitCode: number | null;\n timestamp: number;\n workingDirectory: string;\n fileOperations?: FileOperation[];\n}\n\nexport interface FileOperation {\n type: 'create' | 'write' | 'read' | 'delete' | 'mkdir' | 'move' | 'copy';\n target: string;\n secondaryTarget?: string; // For move/copy operations\n}\n\nexport class ShellService extends Service {\n public static serviceType = 'shell';\n private shellConfig: ShellConfig;\n private currentDirectory: string;\n private commandHistory: Map<string, CommandHistoryEntry[]>; // conversationId -> history\n private maxHistoryPerConversation = 100;\n\n constructor(runtime: IAgentRuntime) {\n super();\n this.runtime = runtime;\n this.shellConfig = loadShellConfig();\n this.currentDirectory = this.shellConfig.allowedDirectory;\n this.commandHistory = new Map();\n }\n\n static async start(runtime: IAgentRuntime): Promise<ShellService> {\n const instance = new ShellService(runtime);\n logger.info('Shell service initialized with history tracking');\n return instance;\n }\n\n async stop(): Promise<void> {\n // Cleanup if needed\n logger.info('Shell service stopped');\n }\n\n get capabilityDescription(): string {\n return 'Execute shell commands within a restricted directory with history tracking';\n }\n\n /**\n * Executes a shell command within the allowed directory\n * @param command The command to execute\n * @param conversationId Optional conversation ID for history tracking\n * @returns The command execution result\n */\n async executeCommand(command: string, conversationId?: string): Promise<CommandResult> {\n // Check if shell is enabled\n if (!this.shellConfig.enabled) {\n return {\n success: false,\n stdout: '',\n stderr: 'Shell plugin is disabled. Set SHELL_ENABLED=true to enable.',\n exitCode: 1,\n error: 'Shell plugin disabled',\n executedIn: this.currentDirectory,\n };\n }\n\n // Basic command validation\n if (!command || typeof command !== 'string') {\n return {\n success: false,\n stdout: '',\n stderr: 'Invalid command',\n exitCode: 1,\n error: 'Command must be a non-empty string',\n executedIn: this.currentDirectory,\n };\n }\n\n const trimmedCommand = command.trim();\n\n // Check for dangerous patterns\n if (!isSafeCommand(trimmedCommand)) {\n return {\n success: false,\n stdout: '',\n stderr: 'Command contains forbidden patterns',\n exitCode: 1,\n error: 'Security policy violation',\n executedIn: this.currentDirectory,\n };\n }\n\n // Check for forbidden commands\n if (isForbiddenCommand(trimmedCommand, this.shellConfig.forbiddenCommands)) {\n return {\n success: false,\n stdout: '',\n stderr: `Command is forbidden by security policy`,\n exitCode: 1,\n error: 'Forbidden command',\n executedIn: this.currentDirectory,\n };\n }\n\n // Handle cd command specially to track directory changes\n if (trimmedCommand.startsWith('cd ')) {\n const result = await this.handleCdCommand(trimmedCommand);\n this.addToHistory(conversationId, trimmedCommand, result);\n return result;\n }\n\n // Execute the command\n const result = await this.runCommand(trimmedCommand);\n \n // Track file operations if successful\n if (result.success) {\n const fileOps = this.detectFileOperations(trimmedCommand, this.currentDirectory);\n if (fileOps && conversationId) {\n this.addToHistory(conversationId, trimmedCommand, result, fileOps);\n } else {\n this.addToHistory(conversationId, trimmedCommand, result);\n }\n } else {\n this.addToHistory(conversationId, trimmedCommand, result);\n }\n \n return result;\n }\n\n /**\n * Handles the cd command to change directory within allowed bounds\n * @param command The cd command\n * @returns The command result\n */\n private async handleCdCommand(command: string): Promise<CommandResult> {\n const parts = command.split(/\\s+/);\n if (parts.length < 2) {\n // cd without arguments goes to allowed directory\n this.currentDirectory = this.shellConfig.allowedDirectory;\n return {\n success: true,\n stdout: `Changed directory to: ${this.currentDirectory}`,\n stderr: '',\n exitCode: 0,\n executedIn: this.currentDirectory,\n };\n }\n\n const targetPath = parts.slice(1).join(' ');\n const validatedPath = validatePath(\n targetPath,\n this.shellConfig.allowedDirectory,\n this.currentDirectory\n );\n\n if (!validatedPath) {\n return {\n success: false,\n stdout: '',\n stderr: 'Cannot navigate outside allowed directory',\n exitCode: 1,\n error: 'Permission denied',\n executedIn: this.currentDirectory,\n };\n }\n\n // Update current directory\n this.currentDirectory = validatedPath;\n return {\n success: true,\n stdout: `Changed directory to: ${this.currentDirectory}`,\n stderr: '',\n exitCode: 0,\n executedIn: this.currentDirectory,\n };\n }\n\n /**\n * Runs a command using cross-spawn\n * @param command The command to run\n * @returns The command result\n */\n private async runCommand(command: string): Promise<CommandResult> {\n return new Promise((resolve) => {\n // For complex commands with redirects or quotes, we need to use shell\n const useShell = command.includes('>') || command.includes('<') || command.includes('|');\n \n let cmd: string;\n let args: string[];\n \n if (useShell) {\n // Use sh -c for commands with redirects/pipes\n cmd = 'sh';\n args = ['-c', command];\n logger.info(`Executing shell command: sh -c \"${command}\" in ${this.currentDirectory}`);\n } else {\n // For simple commands, split and execute directly\n const parts = command.split(/\\s+/);\n cmd = parts[0];\n args = parts.slice(1);\n logger.info(`Executing command: ${cmd} ${args.join(' ')} in ${this.currentDirectory}`);\n }\n\n let stdout = '';\n let stderr = '';\n let timedOut = false;\n\n // Spawn the process\n const child = spawn(cmd, args, {\n cwd: this.currentDirectory,\n env: process.env,\n // Only use shell: false for direct commands, not for sh -c\n shell: false,\n });\n\n // Set timeout\n const timeout = setTimeout(() => {\n timedOut = true;\n child.kill('SIGTERM');\n // Force kill after 5 seconds if process doesn't terminate\n setTimeout(() => {\n if (!child.killed) {\n child.kill('SIGKILL');\n }\n }, 5000);\n }, this.shellConfig.timeout);\n\n // Capture stdout\n if (child.stdout) {\n child.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n }\n\n // Capture stderr\n if (child.stderr) {\n child.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n }\n\n // Handle process exit\n child.on('exit', (code) => {\n clearTimeout(timeout);\n\n if (timedOut) {\n resolve({\n success: false,\n stdout,\n stderr: stderr + '\\nCommand timed out',\n exitCode: code,\n error: 'Command execution timeout',\n executedIn: this.currentDirectory,\n });\n return;\n }\n\n resolve({\n success: code === 0,\n stdout,\n stderr,\n exitCode: code,\n executedIn: this.currentDirectory,\n });\n });\n\n // Handle spawn errors\n child.on('error', (err) => {\n clearTimeout(timeout);\n resolve({\n success: false,\n stdout,\n stderr: err.message,\n exitCode: 1,\n error: 'Failed to execute command',\n executedIn: this.currentDirectory,\n });\n });\n });\n }\n\n /**\n * Adds a command to the history\n */\n private addToHistory(\n conversationId: string | undefined, \n command: string, \n result: CommandResult,\n fileOperations?: FileOperation[]\n ): void {\n if (!conversationId) return;\n\n const historyEntry: CommandHistoryEntry = {\n command,\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n timestamp: Date.now(),\n workingDirectory: result.executedIn,\n fileOperations\n };\n\n if (!this.commandHistory.has(conversationId)) {\n this.commandHistory.set(conversationId, []);\n }\n\n const history = this.commandHistory.get(conversationId)!;\n history.push(historyEntry);\n\n // Trim history if it exceeds max length\n if (history.length > this.maxHistoryPerConversation) {\n history.shift();\n }\n }\n\n /**\n * Detects file operations from a command\n */\n private detectFileOperations(command: string, cwd: string): FileOperation[] | undefined {\n const operations: FileOperation[] = [];\n const parts = command.trim().split(/\\s+/);\n const cmd = parts[0].toLowerCase();\n\n // File creation/writing\n if (cmd === 'touch' && parts.length > 1) {\n operations.push({\n type: 'create',\n target: this.resolvePath(parts[1], cwd)\n });\n } else if (cmd === 'echo' && command.includes('>')) {\n const match = command.match(/>\\s*([^\\s]+)$/);\n if (match) {\n operations.push({\n type: 'write',\n target: this.resolvePath(match[1], cwd)\n });\n }\n } else if (cmd === 'mkdir' && parts.length > 1) {\n operations.push({\n type: 'mkdir',\n target: this.resolvePath(parts[1], cwd)\n });\n } else if (cmd === 'cat' && parts.length > 1 && !command.includes('>')) {\n operations.push({\n type: 'read',\n target: this.resolvePath(parts[1], cwd)\n });\n } else if (cmd === 'mv' && parts.length > 2) {\n operations.push({\n type: 'move',\n target: this.resolvePath(parts[1], cwd),\n secondaryTarget: this.resolvePath(parts[2], cwd)\n });\n } else if (cmd === 'cp' && parts.length > 2) {\n operations.push({\n type: 'copy',\n target: this.resolvePath(parts[1], cwd),\n secondaryTarget: this.resolvePath(parts[2], cwd)\n });\n }\n\n return operations.length > 0 ? operations : undefined;\n }\n\n /**\n * Resolves a path relative to the current working directory\n */\n private resolvePath(filePath: string, cwd: string): string {\n if (path.isAbsolute(filePath)) {\n return filePath;\n }\n return path.join(cwd, filePath);\n }\n\n /**\n * Gets command history for a conversation\n */\n getCommandHistory(conversationId: string, limit?: number): CommandHistoryEntry[] {\n const history = this.commandHistory.get(conversationId) || [];\n if (limit && limit > 0) {\n return history.slice(-limit);\n }\n return history;\n }\n\n /**\n * Clears command history for a conversation\n */\n clearCommandHistory(conversationId: string): void {\n this.commandHistory.delete(conversationId);\n logger.info(`Cleared command history for conversation: ${conversationId}`);\n }\n\n /**\n * Gets the current working directory\n * @param conversationId Optional conversation ID to get conversation-specific directory\n * @returns The current directory path\n */\n getCurrentDirectory(_conversationId?: string): string {\n // For now, we use a global current directory\n // Could be enhanced to track per-conversation directories\n return this.currentDirectory;\n }\n\n /**\n * Gets the allowed directory\n * @returns The allowed directory path\n */\n getAllowedDirectory(): string {\n return this.shellConfig.allowedDirectory;\n }\n} ","import { logger } from '@elizaos/core';\nimport joi from 'joi';\nimport path from 'path';\nimport fs from 'fs';\n\n/**\n * Shell plugin environment configuration\n */\nexport interface ShellConfig {\n enabled: boolean;\n allowedDirectory: string;\n timeout: number;\n forbiddenCommands: string[];\n}\n\n// Environment validation schema\nconst configSchema = joi.object({\n enabled: joi.boolean().required(),\n allowedDirectory: joi.string().when('enabled', {\n is: true,\n then: joi.required(),\n otherwise: joi.optional(),\n }),\n timeout: joi.number().positive().default(30000),\n forbiddenCommands: joi.array().items(joi.string()).required(),\n});\n\n/**\n * Default forbidden commands for safety\n */\nconst DEFAULT_FORBIDDEN_COMMANDS = [\n 'rm -rf /', // Only block dangerous rm commands, not all rm\n 'rmdir',\n 'chmod 777', // Only block dangerous chmod, not all chmod\n 'chown',\n 'chgrp',\n 'shutdown',\n 'reboot',\n 'halt',\n 'poweroff',\n 'kill -9', // Only block force kill, not all kill\n 'killall',\n 'pkill',\n 'sudo rm -rf', // Block dangerous sudo commands\n 'su',\n 'passwd',\n 'useradd',\n 'userdel',\n 'groupadd',\n 'groupdel',\n 'format',\n 'fdisk',\n 'mkfs',\n 'dd if=/dev/zero', // Only block dangerous dd\n 'shred',\n ':(){:|:&};:', // Fork bomb\n];\n\n/**\n * Loads and validates the shell plugin configuration\n * @returns The validated configuration\n */\nexport function loadShellConfig(): ShellConfig {\n const enabled = process.env.SHELL_ENABLED === 'true';\n const allowedDirectory = process.env.SHELL_ALLOWED_DIRECTORY || process.cwd();\n const timeout = parseInt(process.env.SHELL_TIMEOUT || '30000', 10);\n \n // Parse forbidden commands\n const customForbidden = process.env.SHELL_FORBIDDEN_COMMANDS\n ? process.env.SHELL_FORBIDDEN_COMMANDS.split(',').map((cmd) => cmd.trim())\n : [];\n \n // Combine default and custom forbidden commands\n const forbiddenCommands = [...new Set([...DEFAULT_FORBIDDEN_COMMANDS, ...customForbidden])];\n\n const config: ShellConfig = {\n enabled,\n allowedDirectory,\n timeout,\n forbiddenCommands,\n };\n\n // Validate configuration\n const { error, value } = configSchema.validate(config);\n if (error) {\n throw new Error(`Shell plugin configuration error: ${error.message}`);\n }\n\n // Additional validation for allowed directory\n if (enabled && allowedDirectory) {\n try {\n // Check if directory exists\n const stats = fs.statSync(allowedDirectory);\n if (!stats.isDirectory()) {\n throw new Error(`SHELL_ALLOWED_DIRECTORY is not a directory: ${allowedDirectory}`);\n }\n \n // Resolve to absolute path\n value.allowedDirectory = path.resolve(allowedDirectory);\n \n logger.info(`Shell plugin enabled with allowed directory: ${value.allowedDirectory}`);\n } catch (error: any) {\n if (error.code === 'ENOENT') {\n throw new Error(`SHELL_ALLOWED_DIRECTORY does not exist: ${allowedDirectory}`);\n }\n throw error;\n }\n }\n\n if (!enabled) {\n logger.info('Shell plugin is disabled. Set SHELL_ENABLED=true to enable.');\n }\n\n return value as ShellConfig;\n} ","import path from 'path';\nimport { logger } from '@elizaos/core';\n\n/**\n * Normalizes a path and ensures it's within the allowed directory\n * @param commandPath The path from the command\n * @param allowedDir The allowed directory\n * @param currentDir The current working directory\n * @returns The normalized absolute path or null if invalid\n */\nexport function validatePath(\n commandPath: string,\n allowedDir: string,\n currentDir: string\n): string | null {\n try {\n // Resolve the path relative to current directory\n const resolvedPath = path.resolve(currentDir, commandPath);\n const normalizedPath = path.normalize(resolvedPath);\n const normalizedAllowed = path.normalize(allowedDir);\n\n // Check if the resolved path is within the allowed directory\n if (!normalizedPath.startsWith(normalizedAllowed)) {\n logger.warn(\n `Path validation failed: ${normalizedPath} is outside allowed directory ${normalizedAllowed}`\n );\n return null;\n }\n\n return normalizedPath;\n } catch (error) {\n logger.error('Error validating path:', error);\n return null;\n }\n}\n\n/**\n * Checks if a command contains path traversal attempts or dangerous patterns\n * @param command The command to check\n * @returns true if the command appears safe, false if it contains dangerous patterns\n */\nexport function isSafeCommand(command: string): boolean {\n // Check for path traversal patterns\n const pathTraversalPatterns = [\n /\\.\\.\\//g, // ../\n /\\.\\.\\\\/g, // ..\\\n /\\/\\.\\./g, // /..\n /\\\\\\.\\./g, // \\..\n ];\n\n // Check for dangerous command patterns (but allow safe file operations)\n const dangerousPatterns = [\n /\\$\\(/g, // Command substitution $(\n /`[^']*`/g, // Command substitution ` (but allow in quotes)\n /\\|\\s*sudo/g, // Pipe to sudo\n /;\\s*sudo/g, // Chain with sudo\n /&\\s*&/g, // && chaining\n /\\|\\s*\\|/g, // || chaining\n ];\n\n // First check for path traversal\n for (const pattern of pathTraversalPatterns) {\n if (pattern.test(command)) {\n logger.warn(`Path traversal detected in command: ${command}`);\n return false;\n }\n }\n\n // Then check for dangerous command patterns\n for (const pattern of dangerousPatterns) {\n if (pattern.test(command)) {\n logger.warn(`Dangerous pattern detected in command: ${command}`);\n return false;\n }\n }\n\n // Allow single pipes and redirects for file operations\n // but block multiple pipes or complex chains\n const pipeCount = (command.match(/\\|/g) || []).length;\n if (pipeCount > 1) {\n logger.warn(`Multiple pipes detected in command: ${command}`);\n return false;\n }\n\n return true;\n}\n\n/**\n * Extracts the base command from a full command string\n * @param fullCommand The full command string\n * @returns The base command\n */\nexport function extractBaseCommand(fullCommand: string): string {\n // Split by space and get the first part\n const parts = fullCommand.trim().split(/\\s+/);\n return parts[0] || '';\n}\n\n/**\n * Checks if a command is in the forbidden list\n * @param command The command to check\n * @param forbiddenCommands List of forbidden commands/patterns\n * @returns true if the command is forbidden\n */\nexport function isForbiddenCommand(\n command: string,\n forbiddenCommands: string[]\n): boolean {\n const normalizedCommand = command.trim().toLowerCase();\n \n // Check each forbidden pattern\n return forbiddenCommands.some((forbidden) => {\n const forbiddenLower = forbidden.toLowerCase();\n \n // Check if the command starts with the forbidden pattern\n if (normalizedCommand.startsWith(forbiddenLower)) {\n return true;\n }\n \n // Also check if it's the exact base command for single-word forbidden commands\n if (!forbidden.includes(' ')) {\n const baseCommand = extractBaseCommand(command);\n if (baseCommand.toLowerCase() === forbiddenLower) {\n return true;\n }\n }\n \n return false;\n });\n} ","import {\n type Action,\n type ActionExample,\n type Content,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n ModelType,\n type State,\n composePromptFromState,\n parseJSONObjectFromText,\n logger,\n} from '@elizaos/core';\nimport { ShellService } from '../services/shellService';\n\n/**\n * Template for extracting command from user input\n */\nexport const commandExtractionTemplate = `# Extracting shell command from request\n{{recentMessages}}\n\n# Instructions: {{senderName}} wants to execute a shell command. Extract the COMPLETE shell command they want to run.\n\nIMPORTANT: \n1. Always return the FULL executable shell command, not just the content or partial command.\n2. If the user mentions installing something, create the appropriate brew/npm/apt command.\n3. If the user directly provides a command (like \"brew install X\"), use it exactly as provided.\n4. ALWAYS extract a command if the user is asking for ANY kind of system operation.\n\nCommon patterns:\n- \"run ls -la\" -> command: \"ls -la\"\n- \"execute npm test\" -> command: \"npm test\"\n- \"show me the files\" or \"list files\" -> command: \"ls -la\"\n- \"what's in this directory\" -> command: \"ls -la\"\n- \"check git status\" -> command: \"git status\"\n- \"navigate to src folder\" -> command: \"cd src\"\n- \"create a file called test.txt\" -> command: \"touch test.txt\"\n- \"write hello world to a file\" -> command: \"echo 'hello world' > file.txt\"\n- \"create hello.js with javascript code\" -> command: \"echo 'console.log(\\\"Hello, World!\\\");' > hello.js\"\n- \"create hello_world.py and write a python hello world script inside\" -> command: \"echo 'print(\\\"Hello, World!\\\")' > hello_world.py\"\n- \"make a new directory\" -> command: \"mkdir newdir\"\n- \"list files inside your filesystem\" -> command: \"ls -la\"\n- \"install orbstack\" or \"brew install orbstack\" -> command: \"brew install orbstack\"\n- \"install mullvad vpn\" -> command: \"brew install --cask mullvad-vpn\"\n- \"get system info\" -> command: \"system_profiler SPHardwareDataType\"\n- \"check memory usage\" -> command: \"vm_stat\"\n- \"install package\" -> command: \"brew install <package>\"\n\nSpecial cases:\n- \"Run it in your shell\" or \"execute it\" -> Extract the command from previous context\n- \"Install these\" -> Look for package names in previous messages\n- Direct commands should be used exactly as provided\n\nKey rules:\n1. For file creation with content, use: echo 'content' > filename\n2. For listing files, use: ls -la (not just ls)\n3. Always include the echo command when writing to files\n4. Include all flags and arguments\n5. When user says \"run it\", \"execute it\", or similar, they want you to run the command\n\nYour response must be formatted as a JSON block:\n\\`\\`\\`json\n{\n \"command\": \"<complete shell command to execute>\"\n}\n\\`\\`\\`\n`;\n\n/**\n * Extracts the command from the message\n */\nconst extractCommand = async (\n runtime: IAgentRuntime,\n _message: Memory,\n state: State\n): Promise<{ command: string } | null> => {\n const prompt = composePromptFromState({\n state,\n template: commandExtractionTemplate,\n });\n\n for (let i = 0; i < 3; i++) {\n const response = await runtime.useModel(ModelType.TEXT_SMALL, {\n prompt,\n });\n\n const parsedResponse = parseJSONObjectFromText(response);\n if (parsedResponse?.command) {\n return { command: parsedResponse.command };\n }\n }\n return null;\n};\n\nexport const executeCommand: Action = {\n name: 'EXECUTE_COMMAND',\n similes: [\n 'RUN_COMMAND',\n 'SHELL_COMMAND',\n 'TERMINAL_COMMAND',\n 'EXEC',\n 'RUN',\n 'EXECUTE',\n 'CREATE_FILE',\n 'WRITE_FILE',\n 'MAKE_FILE',\n 'INSTALL',\n 'BREW_INSTALL',\n 'NPM_INSTALL',\n 'APT_INSTALL',\n ],\n description:\n 'Execute ANY shell command in the terminal. Use this to run ANY command including: brew install, npm install, apt-get, system commands, file operations (create, write, delete), navigate directories, execute scripts, or perform any other shell operation. I CAN and SHOULD execute commands when asked. This includes brew, npm, git, ls, cd, echo, touch, cat, mkdir, system_profiler, and literally ANY other terminal command.',\n validate: async (runtime: IAgentRuntime, message: Memory, _state: State) => {\n // Check if shell service is available\n const shellService = runtime.getService<ShellService>('shell');\n if (!shellService) {\n return false;\n }\n \n // This action should be used for ANY command execution request\n const text = message.content.text?.toLowerCase() || '';\n const commandKeywords = [\n 'run', 'execute', 'command', 'shell', 'install', 'brew', 'npm',\n 'create', 'file', 'directory', 'folder', 'list', 'show',\n 'system', 'info', 'check', 'status', 'cd', 'ls', 'mkdir',\n 'echo', 'cat', 'touch', 'git', 'build', 'test'\n ];\n \n // Be very permissive - if any command-related keyword is found, this action is valid\n const hasCommandKeyword = commandKeywords.some(keyword => text.includes(keyword));\n \n // Also check for direct commands\n const hasDirectCommand = /^(brew|npm|apt|git|ls|cd|echo|cat|touch|mkdir|rm|mv|cp)\\s/i.test(message.content.text || '');\n \n return hasCommandKeyword || hasDirectCommand;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n _options: any,\n callback: HandlerCallback\n ) => {\n const shellService = runtime.getService<ShellService>('shell');\n \n if (!shellService) {\n await callback({\n text: 'Shell service is not available.',\n source: message.content.source,\n });\n return;\n }\n\n // Extract command from message\n const commandInfo = await extractCommand(runtime, message, state);\n if (!commandInfo?.command) {\n logger.error('Failed to extract command from message:', message.content.text);\n await callback({\n text: \"I couldn't understand which command you want to execute. Please specify a shell command.\",\n source: message.content.source,\n });\n return;\n }\n\n logger.info(`User request: \"${message.content.text}\"`);\n logger.info(`Extracted command: \"${commandInfo.command}\"`);\n\n try {\n // Get conversation ID for history tracking\n const conversationId = message.roomId || message.agentId;\n \n // Execute the command with conversation tracking\n const result = await shellService.executeCommand(commandInfo.command, conversationId);\n \n // Format the response\n let responseText = '';\n \n if (result.success) {\n responseText = `Command executed successfully in ${result.executedIn}\\n\\n`;\n if (result.stdout) {\n responseText += `Output:\\n\\`\\`\\`\\n${result.stdout}\\n\\`\\`\\``;\n } else {\n responseText += 'Command completed with no output.';\n }\n } else {\n responseText = `Command failed with exit code ${result.exitCode} in ${result.executedIn}\\n\\n`;\n if (result.error) {\n responseText += `Error: ${result.error}\\n`;\n }\n if (result.stderr) {\n responseText += `\\nError output:\\n\\`\\`\\`\\n${result.stderr}\\n\\`\\`\\``;\n }\n }\n\n const response: Content = {\n text: responseText,\n source: message.content.source,\n };\n\n await callback(response);\n } catch (error) {\n logger.error('Error executing command:', error);\n await callback({\n text: `Failed to execute command: ${error instanceof Error ? error.message : 'Unknown error'}`,\n source: message.content.source,\n });\n }\n },\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'run ls -la',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll execute that command for you.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'show me what files are in this directory',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll list the files in the current directory.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'navigate to the src folder',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll change to the src directory.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'check the git status',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll check the git repository status.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'create a file called hello.txt',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll create hello.txt for you.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'create hello_world.py and write a python hello world script inside',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll create hello_world.py with a Python hello world script.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'write some content to a file',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll write content to a file for you.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'brew install orbstack',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll install orbstack using brew.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'install mullvad vpn',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll install Mullvad VPN for you.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'run the command brew install --cask docker',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: \"I'll run that brew install command for you.\",\n actions: ['EXECUTE_COMMAND'],\n },\n },\n ],\n ] as ActionExample[][],\n} as Action;\n\nexport default executeCommand; ","import {\n type Action,\n type ActionExample,\n type Content,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n logger,\n} from '@elizaos/core';\nimport { ShellService } from '../services/shellService';\n\nexport const clearHistory: Action = {\n name: 'CLEAR_SHELL_HISTORY',\n similes: ['RESET_SHELL', 'CLEAR_TERMINAL', 'CLEAR_HISTORY', 'RESET_HISTORY'],\n description: 'Clears the recorded history of shell commands for the current conversation',\n validate: async (runtime: IAgentRuntime, message: Memory, _state: State) => {\n // Check if shell service is available\n const shellService = runtime.getService<ShellService>('shell');\n if (!shellService) {\n return false;\n }\n \n // Check if message contains clear history intent\n const text = message.content.text?.toLowerCase() || '';\n const clearKeywords = ['clear', 'reset', 'delete', 'remove', 'clean'];\n const historyKeywords = ['history', 'terminal', 'shell', 'command'];\n \n // Must have at least one clear keyword and one history keyword\n const hasClearKeyword = clearKeywords.some(keyword => text.includes(keyword));\n const hasHistoryKeyword = historyKeywords.some(keyword => text.includes(keyword));\n \n return hasClearKeyword && hasHistoryKeyword;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State,\n _options: any,\n callback: HandlerCallback\n ) => {\n const shellService = runtime.getService<ShellService>('shell');\n \n if (!shellService) {\n await callback({\n text: 'Shell service is not available.',\n source: message.content.source,\n });\n return;\n }\n\n try {\n // Get conversation ID\n const conversationId = message.roomId || message.agentId;\n \n // Clear the history\n shellService.clearCommandHistory(conversationId);\n \n logger.info(`Cleared shell history for conversation: ${conversationId}`);\n\n const response: Content = {\n text: 'Shell command history has been cleared.',\n source: message.content.source,\n };\n\n await callback(response);\n } catch (error) {\n logger.error('Error clearing shell history:', error);\n await callback({\n text: `Failed to clear shell history: ${error instanceof Error ? error.message : 'Unknown error'}`,\n source: message.content.source,\n });\n }\n },\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'clear my shell history',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: 'Shell command history has been cleared.',\n actions: ['CLEAR_SHELL_HISTORY'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'reset the terminal history',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: 'Shell command history has been cleared.',\n actions: ['CLEAR_SHELL_HISTORY'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'delete command history',\n },\n },\n {\n name: '{{name2}}',\n content: {\n text: 'Shell command history has been cleared.',\n actions: ['CLEAR_SHELL_HISTORY'],\n },\n },\n ],\n ] as ActionExample[][],\n} as Action;\n\nexport default clearHistory; ","import {\n type IAgentRuntime,\n type Memory,\n type Provider,\n type State,\n addHeader,\n logger,\n} from '@elizaos/core';\nimport { ShellService } from '../services/shellService';\n\nconst MAX_OUTPUT_LENGTH = 8000; // Max length before truncating\nconst TRUNCATE_SEGMENT_LENGTH = 4000; // Length of head/tail segments\n\nexport const shellHistoryProvider: Provider = {\n name: 'SHELL_HISTORY',\n description: 'Provides recent shell command history, current working directory, and file operations within the restricted environment',\n position: 99,\n get: async (runtime: IAgentRuntime, message: Memory, _state: State) => {\n const shellService = runtime.getService<ShellService>('shell');\n\n if (!shellService) {\n logger.warn('[shellHistoryProvider] Shell service not found');\n return {\n values: {\n shellHistory: 'Shell service is not available',\n currentWorkingDirectory: 'N/A',\n allowedDirectory: 'N/A'\n },\n text: addHeader('# Shell Status', 'Shell service is not available'),\n data: { history: [], cwd: 'N/A', allowedDir: 'N/A' }\n };\n }\n\n // Get conversation ID from message context\n const conversationId = message.roomId || message.agentId;\n \n // Get history for this conversation (last 10 commands)\n const history = shellService.getCommandHistory(conversationId, 10);\n const cwd = shellService.getCurrentDirectory(conversationId);\n const allowedDir = shellService.getAllowedDirectory();\n\n let historyText = 'No commands in history.';\n if (history.length > 0) {\n historyText = history.map((entry) => {\n let entryStr = `[${new Date(entry.timestamp).toISOString()}] ${entry.workingDirectory}> ${entry.command}`;\n \n // Truncate long outputs\n if (entry.stdout) {\n if (entry.stdout.length > MAX_OUTPUT_LENGTH) {\n entryStr += `\\n Output: ${entry.stdout.substring(0, TRUNCATE_SEGMENT_LENGTH)}\\n ... [TRUNCATED] ...\\n ${entry.stdout.substring(entry.stdout.length - TRUNCATE_SEGMENT_LENGTH)}`;\n } else {\n entryStr += `\\n Output: ${entry.stdout}`;\n }\n }\n\n if (entry.stderr) {\n if (entry.stderr.length > MAX_OUTPUT_LENGTH) {\n entryStr += `\\n Error: ${entry.stderr.substring(0, TRUNCATE_SEGMENT_LENGTH)}\\n ... [TRUNCATED] ...\\n ${entry.stderr.substring(entry.stderr.length - TRUNCATE_SEGMENT_LENGTH)}`;\n } else {\n entryStr += `\\n Error: ${entry.stderr}`;\n }\n }\n\n entryStr += `\\n Exit Code: ${entry.exitCode}`;\n\n // Add file operations if any\n if (entry.fileOperations && entry.fileOperations.length > 0) {\n entryStr += '\\n File Operations:';\n entry.fileOperations.forEach(op => {\n if (op.secondaryTarget) {\n entryStr += `\\n - ${op.type}: ${op.target} → ${op.secondaryTarget}`;\n } else {\n entryStr += `\\n - ${op.type}: ${op.target}`;\n }\n });\n }\n\n return entryStr;\n }).join('\\n\\n');\n }\n\n // Get recent file operations\n const recentFileOps = history\n .filter(entry => entry.fileOperations && entry.fileOperations.length > 0)\n .flatMap(entry => entry.fileOperations!)\n .slice(-5); // Last 5 file operations\n\n let fileOpsText = '';\n if (recentFileOps.length > 0) {\n fileOpsText = '\\n\\n' + addHeader('# Recent File Operations', \n recentFileOps.map(op => {\n if (op.secondaryTarget) {\n return `- ${op.type}: ${op.target} → ${op.secondaryTarget}`;\n }\n return `- ${op.type}: ${op.target}`;\n }).join('\\n')\n );\n }\n\n const text = `Current Directory: ${cwd}\nAllowed Directory: ${allowedDir}\n\n${addHeader('# Shell History (Last 10)', historyText)}${fileOpsText}`;\n\n return {\n values: {\n shellHistory: historyText,\n currentWorkingDirectory: cwd,\n allowedDirectory: allowedDir,\n recentFileOperations: recentFileOps\n },\n text,\n data: {\n history,\n cwd,\n allowedDir,\n fileOperations: recentFileOps\n }\n };\n }\n};\n\nexport default shellHistoryProvider; ","import { Plugin } from '@elizaos/core';\nimport { ShellService } from './services/shellService';\nimport { executeCommand, clearHistory } from './actions';\nimport { shellHistoryProvider } from './providers';\n\nexport const shellPlugin: Plugin = {\n name: 'shell',\n description: 'Execute shell commands within a restricted directory with history tracking',\n services: [ShellService],\n actions: [executeCommand, clearHistory],\n providers: [shellHistoryProvider],\n};\n\nexport default shellPlugin;\n\n// Export types and utilities for external use\nexport { type CommandResult, ShellService } from './services/shellService';\nexport { executeCommand } from './actions/executeCommand';\nexport { type ShellConfig, loadShellConfig } from './environment'; "],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA,UAAAA;AAAA,OACK;AACP,OAAO,WAAW;AAClB,OAAOC,WAAU;;;ACNjB,SAAS,cAAc;AACvB,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,QAAQ;AAaf,IAAM,eAAe,IAAI,OAAO;AAAA,EAC9B,SAAS,IAAI,QAAQ,EAAE,SAAS;AAAA,EAChC,kBAAkB,IAAI,OAAO,EAAE,KAAK,WAAW;AAAA,IAC7C,IAAI;AAAA,IACJ,MAAM,IAAI,SAAS;AAAA,IACnB,WAAW,IAAI,SAAS;AAAA,EAC1B,CAAC;AAAA,EACD,SAAS,IAAI,OAAO,EAAE,SAAS,EAAE,QAAQ,GAAK;AAAA,EAC9C,mBAAmB,IAAI,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,EAAE,SAAS;AAC9D,CAAC;AAKD,IAAM,6BAA6B;AAAA,EACjC;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AACF;AAMO,SAAS,kBAA+B;AAC7C,QAAM,UAAU,QAAQ,IAAI,kBAAkB;AAC9C,QAAM,mBAAmB,QAAQ,IAAI,2BAA2B,QAAQ,IAAI;AAC5E,QA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,QACA;AAAA,QACA;AAAA,QACA,gBAAgB;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;;;ACnHO,IAAM,cAAsB;AAAA,EACjC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,UAAU,CAAC,YAAY;AAAA,EACvB,SAAS,CAAC,gBAAgB,YAAY;AAAA,EACtC,WAAW,CAAC,oBAAoB;AAClC;AAEA,IAAO,gBAAQ;","names":["logger","path","error","path","logger","logger","result","path","logger","logger","logger"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../actions/clearHistory.ts", "../generated/specs/specs.ts", "../generated/specs/spec-helpers.ts", "../actions/executeCommand.ts", "../generated/prompts/typescript/prompts.ts", "../providers/shellHistoryProvider.ts", "../services/shellService.ts", "../utils/config.ts", "../utils/pathUtils.ts", "../index.ts"],
4
+ "sourcesContent": [
5
+ "import {\n type Action,\n type ActionExample,\n type Content,\n type HandlerCallback,\n type HandlerOptions,\n type IAgentRuntime,\n logger,\n type Memory,\n type State,\n} from \"@elizaos/core\";\nimport { requireActionSpec } from \"../generated/specs/spec-helpers\";\nimport type { ShellService } from \"../services/shellService\";\n\nconst spec = requireActionSpec(\"CLEAR_HISTORY\");\n\nexport const clearHistory: Action = {\n name: spec.name,\n similes: spec.similes ? [...spec.similes] : [],\n description: spec.description,\n validate: async (runtime: IAgentRuntime, message: Memory, _state: State): Promise<boolean> => {\n const shellService = runtime.getService<ShellService>(\"shell\");\n if (!shellService) {\n return false;\n }\n\n const text = message.content.text?.toLowerCase() || \"\";\n const clearKeywords = [\"clear\", \"reset\", \"delete\", \"remove\", \"clean\"];\n const historyKeywords = [\"history\", \"terminal\", \"shell\", \"command\"];\n\n const hasClearKeyword = clearKeywords.some((keyword) => text.includes(keyword));\n const hasHistoryKeyword = historyKeywords.some((keyword) => text.includes(keyword));\n\n return hasClearKeyword && hasHistoryKeyword;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State,\n _options?: HandlerOptions,\n callback?: HandlerCallback\n ) => {\n const shellService = runtime.getService<ShellService>(\"shell\");\n\n if (!shellService) {\n if (callback) {\n await callback({\n text: \"Shell service is not available.\",\n source: message.content.source,\n });\n }\n return { success: false, error: \"Shell service is not available.\" };\n }\n\n const conversationId = message.roomId || message.agentId;\n if (!conversationId) {\n const errorMsg = \"No conversation ID available\";\n if (callback) {\n await callback({\n text: errorMsg,\n source: message.content.source,\n });\n }\n return { success: false, error: errorMsg };\n }\n shellService.clearCommandHistory(conversationId);\n\n logger.info(`Cleared shell history for conversation: ${conversationId}`);\n\n const response: Content = {\n text: \"Shell command history has been cleared.\",\n source: message.content.source,\n };\n\n if (callback) {\n await callback(response);\n }\n return { success: true, text: response.text };\n },\n examples: (spec.examples ?? []) as ActionExample[][],\n};\n\nexport default clearHistory;\n",
6
+ "/**\n * Auto-generated canonical action/provider/evaluator docs for plugin-shell.\n * DO NOT EDIT - Generated from prompts/specs/**.\n */\n\nexport type ActionDoc = {\n name: string;\n description: string;\n similes?: readonly string[];\n parameters?: readonly unknown[];\n examples?: readonly (readonly unknown[])[];\n};\n\nexport type ProviderDoc = {\n name: string;\n description: string;\n position?: number;\n dynamic?: boolean;\n};\n\nexport type EvaluatorDoc = {\n name: string;\n description: string;\n similes?: readonly string[];\n alwaysRun?: boolean;\n examples?: readonly unknown[];\n};\n\nexport const coreActionsSpec = {\n version: \"1.0.0\",\n actions: [\n {\n name: \"CLEAR_SHELL_HISTORY\",\n description: \"Clears the recorded history of shell commands for the current conversation\",\n similes: [\"RESET_SHELL\", \"CLEAR_TERMINAL\", \"CLEAR_HISTORY\", \"RESET_HISTORY\"],\n parameters: [],\n },\n {\n name: \"EXECUTE_COMMAND\",\n description:\n \"Execute shell commands including brew install, npm install, apt-get, system commands, file operations, directory navigation, and scripts.\",\n similes: [\n \"RUN_COMMAND\",\n \"SHELL_COMMAND\",\n \"TERMINAL_COMMAND\",\n \"EXEC\",\n \"RUN\",\n \"EXECUTE\",\n \"CREATE_FILE\",\n \"WRITE_FILE\",\n \"MAKE_FILE\",\n \"INSTALL\",\n \"BREW_INSTALL\",\n \"NPM_INSTALL\",\n \"APT_INSTALL\",\n ],\n parameters: [],\n },\n ],\n} as const;\nexport const allActionsSpec = {\n version: \"1.0.0\",\n actions: [\n {\n name: \"CLEAR_SHELL_HISTORY\",\n description: \"Clears the recorded history of shell commands for the current conversation\",\n similes: [\"RESET_SHELL\", \"CLEAR_TERMINAL\", \"CLEAR_HISTORY\", \"RESET_HISTORY\"],\n parameters: [],\n },\n {\n name: \"EXECUTE_COMMAND\",\n description:\n \"Execute shell commands including brew install, npm install, apt-get, system commands, file operations, directory navigation, and scripts.\",\n similes: [\n \"RUN_COMMAND\",\n \"SHELL_COMMAND\",\n \"TERMINAL_COMMAND\",\n \"EXEC\",\n \"RUN\",\n \"EXECUTE\",\n \"CREATE_FILE\",\n \"WRITE_FILE\",\n \"MAKE_FILE\",\n \"INSTALL\",\n \"BREW_INSTALL\",\n \"NPM_INSTALL\",\n \"APT_INSTALL\",\n ],\n parameters: [],\n },\n ],\n} as const;\nexport const coreProvidersSpec = {\n version: \"1.0.0\",\n providers: [\n {\n name: \"SHELL_HISTORY\",\n description:\n \"Provides recent shell command history, current working directory, and file operations within the restricted environment\",\n dynamic: true,\n },\n ],\n} as const;\nexport const allProvidersSpec = {\n version: \"1.0.0\",\n providers: [\n {\n name: \"SHELL_HISTORY\",\n description:\n \"Provides recent shell command history, current working directory, and file operations within the restricted environment\",\n dynamic: true,\n },\n ],\n} as const;\nexport const coreEvaluatorsSpec = {\n version: \"1.0.0\",\n evaluators: [],\n} as const;\nexport const allEvaluatorsSpec = {\n version: \"1.0.0\",\n evaluators: [],\n} as const;\n\nexport const coreActionDocs: readonly ActionDoc[] = coreActionsSpec.actions;\nexport const allActionDocs: readonly ActionDoc[] = allActionsSpec.actions;\nexport const coreProviderDocs: readonly ProviderDoc[] = coreProvidersSpec.providers;\nexport const allProviderDocs: readonly ProviderDoc[] = allProvidersSpec.providers;\nexport const coreEvaluatorDocs: readonly EvaluatorDoc[] = coreEvaluatorsSpec.evaluators;\nexport const allEvaluatorDocs: readonly EvaluatorDoc[] = allEvaluatorsSpec.evaluators;\n",
7
+ "/**\n * Helper functions to lookup action/provider/evaluator specs by name.\n * These allow language-specific implementations to import their text content\n * (description, similes, examples) from the centralized specs.\n *\n * DO NOT EDIT the spec data - update prompts/actions.json, prompts/providers.json, prompts/evaluators.json and regenerate.\n */\n\nimport {\n type ActionDoc,\n allActionDocs,\n allEvaluatorDocs,\n allProviderDocs,\n coreActionDocs,\n coreEvaluatorDocs,\n coreProviderDocs,\n type EvaluatorDoc,\n type ProviderDoc,\n} from \"./specs\";\n\n// Build lookup maps for O(1) access\nconst coreActionMap = new Map<string, ActionDoc>(coreActionDocs.map((doc) => [doc.name, doc]));\nconst allActionMap = new Map<string, ActionDoc>(allActionDocs.map((doc) => [doc.name, doc]));\nconst coreProviderMap = new Map<string, ProviderDoc>(\n coreProviderDocs.map((doc) => [doc.name, doc])\n);\nconst allProviderMap = new Map<string, ProviderDoc>(allProviderDocs.map((doc) => [doc.name, doc]));\nconst coreEvaluatorMap = new Map<string, EvaluatorDoc>(\n coreEvaluatorDocs.map((doc) => [doc.name, doc])\n);\nconst allEvaluatorMap = new Map<string, EvaluatorDoc>(\n allEvaluatorDocs.map((doc) => [doc.name, doc])\n);\n\n/**\n * Get an action spec by name from the core specs.\n * @param name - The action name\n * @returns The action spec or undefined if not found\n */\nexport function getActionSpec(name: string): ActionDoc | undefined {\n return coreActionMap.get(name) ?? allActionMap.get(name);\n}\n\n/**\n * Get an action spec by name, throwing if not found.\n * @param name - The action name\n * @returns The action spec\n * @throws Error if the action is not found\n */\nexport function requireActionSpec(name: string): ActionDoc {\n const spec = getActionSpec(name);\n if (!spec) {\n throw new Error(`Action spec not found: ${name}`);\n }\n return spec;\n}\n\n/**\n * Get a provider spec by name from the core specs.\n * @param name - The provider name\n * @returns The provider spec or undefined if not found\n */\nexport function getProviderSpec(name: string): ProviderDoc | undefined {\n return coreProviderMap.get(name) ?? allProviderMap.get(name);\n}\n\n/**\n * Get a provider spec by name, throwing if not found.\n * @param name - The provider name\n * @returns The provider spec\n * @throws Error if the provider is not found\n */\nexport function requireProviderSpec(name: string): ProviderDoc {\n const spec = getProviderSpec(name);\n if (!spec) {\n throw new Error(`Provider spec not found: ${name}`);\n }\n return spec;\n}\n\n/**\n * Get an evaluator spec by name from the core specs.\n * @param name - The evaluator name\n * @returns The evaluator spec or undefined if not found\n */\nexport function getEvaluatorSpec(name: string): EvaluatorDoc | undefined {\n return coreEvaluatorMap.get(name) ?? allEvaluatorMap.get(name);\n}\n\n/**\n * Get an evaluator spec by name, throwing if not found.\n * @param name - The evaluator name\n * @returns The evaluator spec\n * @throws Error if the evaluator is not found\n */\nexport function requireEvaluatorSpec(name: string): EvaluatorDoc {\n const spec = getEvaluatorSpec(name);\n if (!spec) {\n throw new Error(`Evaluator spec not found: ${name}`);\n }\n return spec;\n}\n\n// Re-export types for convenience\nexport type { ActionDoc, ProviderDoc, EvaluatorDoc };\n",
8
+ "import type { HandlerOptions } from \"@elizaos/core\";\nimport {\n type Action,\n type ActionExample,\n type Content,\n composePromptFromState,\n type HandlerCallback,\n type IAgentRuntime,\n logger,\n type Memory,\n ModelType,\n parseJSONObjectFromText,\n type State,\n} from \"@elizaos/core\";\nimport { commandExtractionTemplate } from \"../generated/prompts/typescript/prompts.js\";\nimport { requireActionSpec } from \"../generated/specs/spec-helpers\";\nimport type { ShellService } from \"../services/shellService\";\nexport { commandExtractionTemplate };\n\nconst extractCommand = async (\n runtime: IAgentRuntime,\n _message: Memory,\n state: State\n): Promise<{ command: string } | null> => {\n const prompt = composePromptFromState({\n state,\n template: commandExtractionTemplate,\n });\n\n for (let i = 0; i < 3; i++) {\n const response = await runtime.useModel(ModelType.TEXT_SMALL, {\n prompt,\n });\n\n const parsedResponse = parseJSONObjectFromText(response) as {\n command?: string;\n } | null;\n if (parsedResponse?.command) {\n return { command: parsedResponse.command };\n }\n }\n return null;\n};\n\nconst spec = requireActionSpec(\"EXECUTE_COMMAND\");\n\nexport const executeCommand: Action = {\n name: spec.name,\n similes: spec.similes ? [...spec.similes] : [],\n description: spec.description,\n validate: async (runtime: IAgentRuntime, message: Memory, _state: State): Promise<boolean> => {\n const shellService = runtime.getService<ShellService>(\"shell\");\n if (!shellService) {\n return false;\n }\n\n const text = message.content.text?.toLowerCase() || \"\";\n const commandKeywords = [\n \"run\",\n \"execute\",\n \"command\",\n \"shell\",\n \"install\",\n \"brew\",\n \"npm\",\n \"create\",\n \"file\",\n \"directory\",\n \"folder\",\n \"list\",\n \"show\",\n \"system\",\n \"info\",\n \"check\",\n \"status\",\n \"cd\",\n \"ls\",\n \"mkdir\",\n \"echo\",\n \"cat\",\n \"touch\",\n \"git\",\n \"build\",\n \"test\",\n ];\n\n const hasCommandKeyword = commandKeywords.some((keyword) => text.includes(keyword));\n const hasDirectCommand = /^(brew|npm|apt|git|ls|cd|echo|cat|touch|mkdir|rm|mv|cp)\\s/i.test(\n message.content.text || \"\"\n );\n\n return hasCommandKeyword || hasDirectCommand;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n _options?: HandlerOptions,\n callback?: HandlerCallback\n ) => {\n const shellService = runtime.getService<ShellService>(\"shell\");\n\n if (!shellService) {\n if (callback) {\n await callback({\n text: \"Shell service is not available.\",\n source: message.content.source,\n });\n }\n return { success: false, error: \"Shell service is not available.\" };\n }\n\n const commandInfo = await extractCommand(runtime, message, state);\n if (!commandInfo?.command) {\n logger.error(\"Failed to extract command from message:\", message.content.text);\n if (callback) {\n await callback({\n text: \"Could not determine which command to execute. Please specify a shell command.\",\n source: message.content.source,\n });\n }\n return { success: false, error: \"Could not extract command.\" };\n }\n\n logger.info(`Extracted command: \"${commandInfo.command}\"`);\n\n try {\n const conversationId = message.roomId || message.agentId;\n const result = await shellService.executeCommand(commandInfo.command, conversationId);\n\n let responseText = \"\";\n\n if (result.success) {\n responseText = `Command executed successfully in ${result.executedIn}\\n\\n`;\n if (result.stdout) {\n responseText += `Output:\\n\\`\\`\\`\\n${result.stdout}\\n\\`\\`\\``;\n } else {\n responseText += \"Command completed with no output.\";\n }\n } else {\n responseText = `Command failed with exit code ${result.exitCode} in ${result.executedIn}\\n\\n`;\n if (result.error) {\n responseText += `Error: ${result.error}\\n`;\n }\n if (result.stderr) {\n responseText += `\\nError output:\\n\\`\\`\\`\\n${result.stderr}\\n\\`\\`\\``;\n }\n }\n\n const response: Content = {\n text: responseText,\n source: message.content.source,\n };\n\n if (callback) {\n await callback(response);\n }\n return { success: result.success, text: responseText };\n } catch (error) {\n logger.error(\"Error executing command:\", error);\n const errorMessage = error instanceof Error ? error.message : String(error);\n if (callback) {\n await callback({\n text: `Failed to execute command: ${errorMessage}`,\n source: message.content.source,\n });\n }\n return { success: false, error: errorMessage };\n }\n },\n examples: (spec.examples ?? []) as ActionExample[][],\n};\n\nexport default executeCommand;\n",
9
+ "/**\n * Auto-generated prompt templates\n * DO NOT EDIT - Generated from ../../../../prompts/*.txt\n *\n * These prompts use Handlebars-style template syntax:\n * - {{variableName}} for simple substitution\n * - {{#each items}}...{{/each}} for iteration\n * - {{#if condition}}...{{/if}} for conditionals\n */\n\nexport const commandExtractionTemplate = `# Extracting shell command from request\n{{recentMessages}}\n\n# Instructions: {{senderName}} wants to execute a shell command. Extract the COMPLETE shell command they want to run.\n\nIMPORTANT: \n1. Always return the FULL executable shell command, not just the content or partial command.\n2. If the user mentions installing something, create the appropriate brew/npm/apt command.\n3. If the user directly provides a command (like \"brew install X\"), use it exactly as provided.\n4. ALWAYS extract a command if the user is asking for ANY kind of system operation.\n\nCommon patterns:\n- \"run ls -la\" -> command: \"ls -la\"\n- \"execute npm test\" -> command: \"npm test\"\n- \"show me the files\" or \"list files\" -> command: \"ls -la\"\n- \"what's in this directory\" -> command: \"ls -la\"\n- \"check git status\" -> command: \"git status\"\n- \"navigate to src folder\" -> command: \"cd src\"\n- \"create a file called test.txt\" -> command: \"touch test.txt\"\n- \"write hello world to a file\" -> command: \"echo 'hello world' > file.txt\"\n- \"create hello.js with javascript code\" -> command: \"echo 'console.log(\\\\\"Hello, World!\\\\\");' > hello.js\"\n- \"create hello_world.py and write a python hello world script inside\" -> command: \"echo 'print(\\\\\"Hello, World!\\\\\")' > hello_world.py\"\n- \"make a new directory\" -> command: \"mkdir newdir\"\n- \"list files inside your filesystem\" -> command: \"ls -la\"\n- \"install orbstack\" or \"brew install orbstack\" -> command: \"brew install orbstack\"\n- \"install mullvad vpn\" -> command: \"brew install --cask mullvad-vpn\"\n- \"get system info\" -> command: \"system_profiler SPHardwareDataType\"\n- \"check memory usage\" -> command: \"vm_stat\"\n- \"install package\" -> command: \"brew install <package>\"\n\nSpecial cases:\n- \"Run it in your shell\" or \"execute it\" -> Extract the command from previous context\n- \"Install these\" -> Look for package names in previous messages\n- Direct commands should be used exactly as provided\n\nKey rules:\n1. For file creation with content, use: echo 'content' > filename\n2. For listing files, use: ls -la (not just ls)\n3. Always include the echo command when writing to files\n4. Include all flags and arguments\n5. When user says \"run it\", \"execute it\", or similar, they want you to run the command\n\nYour response must be formatted as a JSON block:\n\\`\\`\\`json\n{\n \"command\": \"<complete shell command to execute>\"\n}\n\\`\\`\\``;\n\nexport const COMMAND_EXTRACTION_TEMPLATE = commandExtractionTemplate;\n\n",
10
+ "import {\n addHeader,\n type IAgentRuntime,\n logger,\n type Memory,\n type Provider,\n type State,\n} from \"@elizaos/core\";\nimport { requireProviderSpec } from \"../generated/specs/spec-helpers\";\nimport type { ShellService } from \"../services/shellService\";\nimport type { CommandHistoryEntry, FileOperation } from \"../types\";\n\nconst MAX_OUTPUT_LENGTH = 8000;\nconst TRUNCATE_SEGMENT_LENGTH = 4000;\n\nconst spec = requireProviderSpec(\"shellHistoryProvider\");\n\nexport const shellHistoryProvider: Provider = {\n name: spec.name,\n description:\n \"Provides recent shell command history, current working directory, and file operations within the restricted environment\",\n position: 99,\n get: async (runtime: IAgentRuntime, message: Memory, _state: State) => {\n const shellService = runtime.getService<ShellService>(\"shell\");\n\n if (!shellService) {\n logger.warn(\"[shellHistoryProvider] Shell service not found\");\n return {\n values: {\n shellHistory: \"Shell service is not available\",\n currentWorkingDirectory: \"N/A\",\n allowedDirectory: \"N/A\",\n },\n text: addHeader(\"# Shell Status\", \"Shell service is not available\"),\n data: { historyCount: 0, cwd: \"N/A\", allowedDir: \"N/A\" },\n };\n }\n\n const conversationId = message.roomId || message.agentId;\n if (!conversationId) {\n return {\n text: \"No conversation ID available\",\n values: { historyCount: 0, cwd: \"N/A\", allowedDir: \"N/A\" },\n data: { historyCount: 0, cwd: \"N/A\", allowedDir: \"N/A\" },\n };\n }\n const history = shellService.getCommandHistory(conversationId, 10);\n const cwd = shellService.getCurrentDirectory(conversationId);\n const allowedDir = shellService.getAllowedDirectory();\n\n let historyText = \"No commands in history.\";\n if (history.length > 0) {\n historyText = history\n .map((entry: CommandHistoryEntry) => {\n let entryStr = `[${new Date(entry.timestamp).toISOString()}] ${entry.workingDirectory}> ${entry.command}`;\n\n if (entry.stdout) {\n if (entry.stdout.length > MAX_OUTPUT_LENGTH) {\n entryStr += `\\n Output: ${entry.stdout.substring(0, TRUNCATE_SEGMENT_LENGTH)}\\n ... [TRUNCATED] ...\\n ${entry.stdout.substring(entry.stdout.length - TRUNCATE_SEGMENT_LENGTH)}`;\n } else {\n entryStr += `\\n Output: ${entry.stdout}`;\n }\n }\n\n if (entry.stderr) {\n if (entry.stderr.length > MAX_OUTPUT_LENGTH) {\n entryStr += `\\n Error: ${entry.stderr.substring(0, TRUNCATE_SEGMENT_LENGTH)}\\n ... [TRUNCATED] ...\\n ${entry.stderr.substring(entry.stderr.length - TRUNCATE_SEGMENT_LENGTH)}`;\n } else {\n entryStr += `\\n Error: ${entry.stderr}`;\n }\n }\n\n entryStr += `\\n Exit Code: ${entry.exitCode}`;\n\n if (entry.fileOperations && entry.fileOperations.length > 0) {\n entryStr += \"\\n File Operations:\";\n entry.fileOperations.forEach((op: FileOperation) => {\n if (op.secondaryTarget) {\n entryStr += `\\n - ${op.type}: ${op.target} → ${op.secondaryTarget}`;\n } else {\n entryStr += `\\n - ${op.type}: ${op.target}`;\n }\n });\n }\n\n return entryStr;\n })\n .join(\"\\n\\n\");\n }\n\n const recentFileOps = history\n .filter(\n (entry: CommandHistoryEntry) => entry.fileOperations && entry.fileOperations.length > 0\n )\n .flatMap((entry: CommandHistoryEntry) => entry.fileOperations ?? [])\n .slice(-5);\n\n let fileOpsText = \"\";\n if (recentFileOps.length > 0) {\n fileOpsText =\n \"\\n\\n\" +\n addHeader(\n \"# Recent File Operations\",\n recentFileOps\n .map((op: FileOperation) => {\n if (op.secondaryTarget) {\n return `- ${op.type}: ${op.target} → ${op.secondaryTarget}`;\n }\n return `- ${op.type}: ${op.target}`;\n })\n .join(\"\\n\")\n );\n }\n\n const text = `Current Directory: ${cwd}\nAllowed Directory: ${allowedDir}\n\n${addHeader(\"# Shell History (Last 10)\", historyText)}${fileOpsText}`;\n\n return {\n values: {\n shellHistory: historyText,\n currentWorkingDirectory: cwd,\n allowedDirectory: allowedDir,\n },\n text,\n data: {\n historyCount: history.length,\n cwd,\n allowedDir,\n },\n };\n },\n};\n\nexport default shellHistoryProvider;\n",
11
+ "import path from \"node:path\";\nimport { type IAgentRuntime, logger, Service } from \"@elizaos/core\";\nimport spawn from \"cross-spawn\";\nimport type {\n CommandHistoryEntry,\n CommandResult,\n FileOperation,\n FileOperationType,\n ShellConfig,\n} from \"../types\";\nimport { isForbiddenCommand, isSafeCommand, loadShellConfig, validatePath } from \"../utils\";\n\nexport class ShellService extends Service {\n public static serviceType = \"shell\";\n private shellConfig: ShellConfig;\n private currentDirectory: string;\n private commandHistory: Map<string, CommandHistoryEntry[]>;\n private maxHistoryPerConversation = 100;\n\n constructor(runtime: IAgentRuntime) {\n super(runtime);\n this.shellConfig = loadShellConfig();\n this.currentDirectory = this.shellConfig.allowedDirectory;\n this.commandHistory = new Map();\n }\n\n static async start(runtime: IAgentRuntime): Promise<ShellService> {\n const instance = new ShellService(runtime);\n logger.info(\"Shell service initialized with history tracking\");\n return instance;\n }\n\n async stop(): Promise<void> {\n logger.info(\"Shell service stopped\");\n }\n\n get capabilityDescription(): string {\n return \"Execute shell commands within a restricted directory with history tracking\";\n }\n\n async executeCommand(command: string, conversationId?: string): Promise<CommandResult> {\n if (!this.shellConfig.enabled) {\n return {\n success: false,\n stdout: \"\",\n stderr: \"Shell plugin is disabled. Set SHELL_ENABLED=true to enable.\",\n exitCode: 1,\n error: \"Shell plugin disabled\",\n executedIn: this.currentDirectory,\n };\n }\n\n if (!command || typeof command !== \"string\") {\n return {\n success: false,\n stdout: \"\",\n stderr: \"Invalid command\",\n exitCode: 1,\n error: \"Command must be a non-empty string\",\n executedIn: this.currentDirectory,\n };\n }\n\n const trimmedCommand = command.trim();\n\n if (!isSafeCommand(trimmedCommand)) {\n return {\n success: false,\n stdout: \"\",\n stderr: \"Command contains forbidden patterns\",\n exitCode: 1,\n error: \"Security policy violation\",\n executedIn: this.currentDirectory,\n };\n }\n\n if (isForbiddenCommand(trimmedCommand, this.shellConfig.forbiddenCommands)) {\n return {\n success: false,\n stdout: \"\",\n stderr: \"Command is forbidden by security policy\",\n exitCode: 1,\n error: \"Forbidden command\",\n executedIn: this.currentDirectory,\n };\n }\n\n if (trimmedCommand.startsWith(\"cd \")) {\n const result = await this.handleCdCommand(trimmedCommand);\n this.addToHistory(conversationId, trimmedCommand, result);\n return result;\n }\n\n const result = await this.runCommand(trimmedCommand);\n\n if (result.success) {\n const fileOps = this.detectFileOperations(trimmedCommand, this.currentDirectory);\n if (fileOps && conversationId) {\n this.addToHistory(conversationId, trimmedCommand, result, fileOps);\n } else {\n this.addToHistory(conversationId, trimmedCommand, result);\n }\n } else {\n this.addToHistory(conversationId, trimmedCommand, result);\n }\n\n return result;\n }\n\n private async handleCdCommand(command: string): Promise<CommandResult> {\n const parts = command.split(/\\s+/);\n if (parts.length < 2) {\n this.currentDirectory = this.shellConfig.allowedDirectory;\n return {\n success: true,\n stdout: `Changed directory to: ${this.currentDirectory}`,\n stderr: \"\",\n exitCode: 0,\n executedIn: this.currentDirectory,\n };\n }\n\n const targetPath = parts.slice(1).join(\" \");\n const validatedPath = validatePath(\n targetPath,\n this.shellConfig.allowedDirectory,\n this.currentDirectory\n );\n\n if (!validatedPath) {\n return {\n success: false,\n stdout: \"\",\n stderr: \"Cannot navigate outside allowed directory\",\n exitCode: 1,\n error: \"Permission denied\",\n executedIn: this.currentDirectory,\n };\n }\n\n this.currentDirectory = validatedPath;\n return {\n success: true,\n stdout: `Changed directory to: ${this.currentDirectory}`,\n stderr: \"\",\n exitCode: 0,\n executedIn: this.currentDirectory,\n };\n }\n\n private async runCommand(command: string): Promise<CommandResult> {\n return new Promise((resolve) => {\n const useShell = command.includes(\">\") || command.includes(\"<\") || command.includes(\"|\");\n\n let cmd: string;\n let args: string[];\n\n if (useShell) {\n cmd = \"sh\";\n args = [\"-c\", command];\n logger.info(`Executing shell command: sh -c \"${command}\" in ${this.currentDirectory}`);\n } else {\n const parts = command.split(/\\s+/);\n cmd = parts[0];\n args = parts.slice(1);\n logger.info(`Executing command: ${cmd} ${args.join(\" \")} in ${this.currentDirectory}`);\n }\n\n let stdout = \"\";\n let stderr = \"\";\n let timedOut = false;\n\n const child = spawn(cmd, args, {\n cwd: this.currentDirectory,\n env: process.env,\n shell: false,\n });\n\n const timeout = setTimeout(() => {\n timedOut = true;\n child.kill(\"SIGTERM\");\n setTimeout(() => {\n if (!child.killed) {\n child.kill(\"SIGKILL\");\n }\n }, 5000);\n }, this.shellConfig.timeout);\n\n if (child.stdout) {\n child.stdout.on(\"data\", (data: Buffer) => {\n stdout += data.toString();\n });\n }\n\n if (child.stderr) {\n child.stderr.on(\"data\", (data: Buffer) => {\n stderr += data.toString();\n });\n }\n\n child.on(\"exit\", (code) => {\n clearTimeout(timeout);\n\n if (timedOut) {\n resolve({\n success: false,\n stdout,\n stderr: `${stderr}\\nCommand timed out`,\n exitCode: code,\n error: \"Command execution timeout\",\n executedIn: this.currentDirectory,\n });\n return;\n }\n\n resolve({\n success: code === 0,\n stdout,\n stderr,\n exitCode: code,\n executedIn: this.currentDirectory,\n });\n });\n\n child.on(\"error\", (err: Error) => {\n clearTimeout(timeout);\n resolve({\n success: false,\n stdout,\n stderr: err.message,\n exitCode: 1,\n error: \"Failed to execute command\",\n executedIn: this.currentDirectory,\n });\n });\n });\n }\n\n private addToHistory(\n conversationId: string | undefined,\n command: string,\n result: CommandResult,\n fileOperations?: FileOperation[]\n ): void {\n if (!conversationId) return;\n\n const historyEntry: CommandHistoryEntry = {\n command,\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n timestamp: Date.now(),\n workingDirectory: result.executedIn,\n fileOperations,\n };\n\n if (!this.commandHistory.has(conversationId)) {\n this.commandHistory.set(conversationId, []);\n }\n\n const history = this.commandHistory.get(conversationId);\n if (!history) {\n throw new Error(`No history found for conversation ${conversationId}`);\n }\n history.push(historyEntry);\n\n if (history.length > this.maxHistoryPerConversation) {\n history.shift();\n }\n }\n\n private detectFileOperations(command: string, cwd: string): FileOperation[] | undefined {\n const operations: FileOperation[] = [];\n const parts = command.trim().split(/\\s+/);\n const cmd = parts[0].toLowerCase();\n\n if (cmd === \"touch\" && parts.length > 1) {\n operations.push({\n type: \"create\" as FileOperationType,\n target: this.resolvePath(parts[1], cwd),\n });\n } else if (cmd === \"echo\" && command.includes(\">\")) {\n const match = command.match(/>\\s*([^\\s]+)$/);\n if (match) {\n operations.push({\n type: \"write\" as FileOperationType,\n target: this.resolvePath(match[1], cwd),\n });\n }\n } else if (cmd === \"mkdir\" && parts.length > 1) {\n operations.push({\n type: \"mkdir\" as FileOperationType,\n target: this.resolvePath(parts[1], cwd),\n });\n } else if (cmd === \"cat\" && parts.length > 1 && !command.includes(\">\")) {\n operations.push({\n type: \"read\" as FileOperationType,\n target: this.resolvePath(parts[1], cwd),\n });\n } else if (cmd === \"mv\" && parts.length > 2) {\n operations.push({\n type: \"move\" as FileOperationType,\n target: this.resolvePath(parts[1], cwd),\n secondaryTarget: this.resolvePath(parts[2], cwd),\n });\n } else if (cmd === \"cp\" && parts.length > 2) {\n operations.push({\n type: \"copy\" as FileOperationType,\n target: this.resolvePath(parts[1], cwd),\n secondaryTarget: this.resolvePath(parts[2], cwd),\n });\n }\n\n return operations.length > 0 ? operations : undefined;\n }\n\n private resolvePath(filePath: string, cwd: string): string {\n if (path.isAbsolute(filePath)) {\n return filePath;\n }\n return path.join(cwd, filePath);\n }\n\n getCommandHistory(conversationId: string, limit?: number): CommandHistoryEntry[] {\n const history = this.commandHistory.get(conversationId) || [];\n if (limit && limit > 0) {\n return history.slice(-limit);\n }\n return history;\n }\n\n clearCommandHistory(conversationId: string): void {\n this.commandHistory.delete(conversationId);\n logger.info(`Cleared command history for conversation: ${conversationId}`);\n }\n\n getCurrentDirectory(_conversationId?: string): string {\n return this.currentDirectory;\n }\n\n getAllowedDirectory(): string {\n return this.shellConfig.allowedDirectory;\n }\n}\n",
12
+ "import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { logger } from \"@elizaos/core\";\nimport { z } from \"zod\";\nimport type { ShellConfig } from \"../types\";\n\nconst configSchema = z.object({\n enabled: z.boolean(),\n allowedDirectory: z.string(),\n timeout: z.number().positive().default(30000),\n forbiddenCommands: z.array(z.string()),\n});\n\nexport const DEFAULT_FORBIDDEN_COMMANDS: readonly string[] = [\n \"rm -rf /\",\n \"rmdir\",\n \"chmod 777\",\n \"chown\",\n \"chgrp\",\n \"shutdown\",\n \"reboot\",\n \"halt\",\n \"poweroff\",\n \"kill -9\",\n \"killall\",\n \"pkill\",\n \"sudo rm -rf\",\n \"su\",\n \"passwd\",\n \"useradd\",\n \"userdel\",\n \"groupadd\",\n \"groupdel\",\n \"format\",\n \"fdisk\",\n \"mkfs\",\n \"dd if=/dev/zero\",\n \"shred\",\n \":(){:|:&};:\",\n] as const;\n\nexport function loadShellConfig(): ShellConfig {\n const enabled = process.env.SHELL_ENABLED === \"true\";\n const allowedDirectory = process.env.SHELL_ALLOWED_DIRECTORY || process.cwd();\n const timeout = parseInt(process.env.SHELL_TIMEOUT || \"30000\", 10);\n\n const customForbidden = process.env.SHELL_FORBIDDEN_COMMANDS\n ? process.env.SHELL_FORBIDDEN_COMMANDS.split(\",\").map((cmd) => cmd.trim())\n : [];\n\n const forbiddenCommands = [...new Set([...DEFAULT_FORBIDDEN_COMMANDS, ...customForbidden])];\n\n const config: ShellConfig = {\n enabled,\n allowedDirectory,\n timeout,\n forbiddenCommands,\n };\n\n const parseResult = configSchema.safeParse(config);\n if (!parseResult.success) {\n const errorMessage = parseResult.error.issues?.[0]?.message || parseResult.error.toString();\n throw new Error(`Shell plugin configuration error: ${errorMessage}`);\n }\n\n if (enabled && allowedDirectory) {\n try {\n const stats = fs.statSync(allowedDirectory);\n if (!stats.isDirectory()) {\n throw new Error(`SHELL_ALLOWED_DIRECTORY is not a directory: ${allowedDirectory}`);\n }\n\n config.allowedDirectory = path.resolve(allowedDirectory);\n\n logger.info(`Shell plugin enabled with allowed directory: ${config.allowedDirectory}`);\n } catch (error) {\n if (\n error instanceof Error &&\n \"code\" in error &&\n (error as NodeJS.ErrnoException).code === \"ENOENT\"\n ) {\n throw new Error(`SHELL_ALLOWED_DIRECTORY does not exist: ${allowedDirectory}`);\n }\n throw error;\n }\n }\n\n if (!enabled) {\n logger.info(\"Shell plugin is disabled. Set SHELL_ENABLED=true to enable.\");\n }\n\n return config;\n}\n",
13
+ "import path from \"node:path\";\nimport { logger } from \"@elizaos/core\";\n\nexport function validatePath(\n commandPath: string,\n allowedDir: string,\n currentDir: string\n): string | null {\n const resolvedPath = path.resolve(currentDir, commandPath);\n const normalizedPath = path.normalize(resolvedPath);\n const normalizedAllowed = path.normalize(allowedDir);\n\n if (!normalizedPath.startsWith(normalizedAllowed)) {\n logger.warn(\n `Path validation failed: ${normalizedPath} is outside allowed directory ${normalizedAllowed}`\n );\n return null;\n }\n\n return normalizedPath;\n}\n\nexport function isSafeCommand(command: string): boolean {\n const pathTraversalPatterns = [/\\.\\.\\//g, /\\.\\.\\\\/g, /\\/\\.\\./g, /\\\\\\.\\./g];\n\n const dangerousPatterns = [/\\$\\(/g, /`[^']*`/g, /\\|\\s*sudo/g, /;\\s*sudo/g, /&\\s*&/g, /\\|\\s*\\|/g];\n\n for (const pattern of pathTraversalPatterns) {\n if (pattern.test(command)) {\n logger.warn(`Path traversal detected in command: ${command}`);\n return false;\n }\n }\n\n for (const pattern of dangerousPatterns) {\n if (pattern.test(command)) {\n logger.warn(`Dangerous pattern detected in command: ${command}`);\n return false;\n }\n }\n\n const pipeCount = (command.match(/\\|/g) || []).length;\n if (pipeCount > 1) {\n logger.warn(`Multiple pipes detected in command: ${command}`);\n return false;\n }\n\n return true;\n}\n\nexport function extractBaseCommand(fullCommand: string): string {\n const parts = fullCommand.trim().split(/\\s+/);\n return parts[0] || \"\";\n}\n\nexport function isForbiddenCommand(command: string, forbiddenCommands: string[]): boolean {\n const normalizedCommand = command.trim().toLowerCase();\n\n return forbiddenCommands.some((forbidden) => {\n const forbiddenLower = forbidden.toLowerCase();\n\n if (normalizedCommand.startsWith(forbiddenLower)) {\n return true;\n }\n\n if (!forbidden.includes(\" \")) {\n const baseCommand = extractBaseCommand(command);\n if (baseCommand.toLowerCase() === forbiddenLower) {\n return true;\n }\n }\n\n return false;\n });\n}\n",
14
+ "import type { Plugin } from \"@elizaos/core\";\nimport { clearHistory, executeCommand } from \"./actions\";\nimport { shellHistoryProvider } from \"./providers\";\nimport { ShellService } from \"./services/shellService\";\n\nexport const shellPlugin: Plugin = {\n name: \"shell\",\n description: \"Execute shell commands within a restricted directory with history tracking\",\n services: [ShellService],\n actions: [executeCommand, clearHistory],\n providers: [shellHistoryProvider],\n};\n\nexport default shellPlugin;\n\nexport { clearHistory } from \"./actions/clearHistory\";\nexport { executeCommand } from \"./actions/executeCommand\";\nexport { shellHistoryProvider } from \"./providers/shellHistoryProvider\";\nexport { ShellService } from \"./services/shellService\";\nexport type {\n CommandHistoryEntry,\n CommandResult,\n FileOperation,\n FileOperationType,\n ShellConfig,\n} from \"./types\";\nexport {\n DEFAULT_FORBIDDEN_COMMANDS,\n extractBaseCommand,\n isForbiddenCommand,\n isSafeCommand,\n loadShellConfig,\n validatePath,\n} from \"./utils\";\n"
15
+ ],
16
+ "mappings": ";AAAA;AAAA;AAAA;;;AC4BO,IAAM,kBAAkB;AAAA,EAC7B,SAAS;AAAA,EACT,SAAS;AAAA,IACP;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS,CAAC,eAAe,kBAAkB,iBAAiB,eAAe;AAAA,MAC3E,YAAY,CAAC;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aACE;AAAA,MACF,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AACF;AACO,IAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,EACT,SAAS;AAAA,IACP;AAAA,MACE,MAAM;AAAA,MACN,aAAa;AAAA,MACb,SAAS,CAAC,eAAe,kBAAkB,iBAAiB,eAAe;AAAA,MAC3E,YAAY,CAAC;AAAA,IACf;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,aACE;AAAA,MACF,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,YAAY,CAAC;AAAA,IACf;AAAA,EACF;AACF;AACO,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,WAAW;AAAA,IACT;AAAA,MACE,MAAM;AAAA,MACN,aACE;AAAA,MACF,SAAS;AAAA,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AAI,GAAG;AAAA,QACtC,iBAAiB,KAAK,YAAY,MAAM,IAAI,GAAG;AAAA,MACjD,CAAC;AAAA,IACH;AAAA,IAEA,OAAO,WAAW,SAAS,IAAI,aAAa;AAAA;AAAA,EAGtC,WAAW,CAAC,UAAkB,KAAqB;AAAA,IACzD,IAAI,MAAK,WAAW,QAAQ,GAAG;AAAA,MAC7B,OAAO;AAAA,IACT;AAAA,IACA,OAAO,MAAK,KAAK,KAAK,QAAQ;AAAA;AAAA,EAGhC,iBAAiB,CAAC,gBAAwB,OAAuC;AAAA,IAC/E,MAAM,UAAU,KAAK,eAAe,IAAI,cAAc,KAAK,CAAC;AAAA,IAC5D,IAAI,SAAS,QAAQ,GAAG;AAAA,MACtB,OAAO,QAAQ,MAAM,CAAC,KAAK;AAAA,IAC7B;AAAA,IACA,OAAO;AAAA;AAAA,EAGT,mBAAmB,CAAC,gBAA8B;AAAA,IAChD,KAAK,eAAe,OAAO,cAAc;AAAA,IACzC,QAAO,KAAK,6CAA6C,gBAAgB;AAAA;AAAA,EAG3E,mBAAmB,CAAC,iBAAkC;AAAA,IACpD,OAAO,KAAK;AAAA;AAAA,EAGd,mBAAmB,GAAW;AAAA,IAC5B,OAAO,KAAK,YAAY;AAAA;AAE5B;;;AGlVO,IAAM,cAAsB;AAAA,EACjC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,UAAU,CAAC,YAAY;AAAA,EACvB,SAAS,CAAC,gBAAgB,YAAY;AAAA,EACtC,WAAW,CAAC,oBAAoB;AAClC;AAEA,IAAe;",
17
+ "debugId": "1AD79E57D2FAFA7D64756E2164756E21",
18
+ "names": []
19
+ }
@@ -0,0 +1,2 @@
1
+ export { default, shellHistoryProvider } from "./shellHistoryProvider";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type Provider } from "@elizaos/core";
2
+ export declare const shellHistoryProvider: Provider;
3
+ export default shellHistoryProvider;
4
+ //# sourceMappingURL=shellHistoryProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shellHistoryProvider.d.ts","sourceRoot":"","sources":["../../providers/shellHistoryProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EAEd,MAAM,eAAe,CAAC;AAUvB,eAAO,MAAM,oBAAoB,EAAE,QAoHlC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { ShellService } from "./shellService";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type IAgentRuntime, Service } from "@elizaos/core";
2
+ import type { CommandHistoryEntry, CommandResult } from "../types";
3
+ export declare class ShellService extends Service {
4
+ static serviceType: string;
5
+ private shellConfig;
6
+ private currentDirectory;
7
+ private commandHistory;
8
+ private maxHistoryPerConversation;
9
+ constructor(runtime: IAgentRuntime);
10
+ static start(runtime: IAgentRuntime): Promise<ShellService>;
11
+ stop(): Promise<void>;
12
+ get capabilityDescription(): string;
13
+ executeCommand(command: string, conversationId?: string): Promise<CommandResult>;
14
+ private handleCdCommand;
15
+ private runCommand;
16
+ private addToHistory;
17
+ private detectFileOperations;
18
+ private resolvePath;
19
+ getCommandHistory(conversationId: string, limit?: number): CommandHistoryEntry[];
20
+ clearCommandHistory(conversationId: string): void;
21
+ getCurrentDirectory(_conversationId?: string): string;
22
+ getAllowedDirectory(): string;
23
+ }
24
+ //# sourceMappingURL=shellService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shellService.d.ts","sourceRoot":"","sources":["../../services/shellService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAU,OAAO,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EAId,MAAM,UAAU,CAAC;AAGlB,qBAAa,YAAa,SAAQ,OAAO;IACvC,OAAc,WAAW,SAAW;IACpC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,yBAAyB,CAAO;gBAE5B,OAAO,EAAE,aAAa;WAOrB,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAM3D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAEK,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;YAqExE,eAAe;YAyCf,UAAU;IAwFxB,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,oBAAoB;IA6C5B,OAAO,CAAC,WAAW;IAOnB,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,mBAAmB,EAAE;IAQhF,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAKjD,mBAAmB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrD,mBAAmB,IAAI,MAAM;CAG9B"}
@@ -0,0 +1,30 @@
1
+ export interface CommandResult {
2
+ success: boolean;
3
+ stdout: string;
4
+ stderr: string;
5
+ exitCode: number | null;
6
+ error?: string;
7
+ executedIn: string;
8
+ }
9
+ export interface CommandHistoryEntry {
10
+ command: string;
11
+ stdout: string;
12
+ stderr: string;
13
+ exitCode: number | null;
14
+ timestamp: number;
15
+ workingDirectory: string;
16
+ fileOperations?: FileOperation[];
17
+ }
18
+ export type FileOperationType = "create" | "write" | "read" | "delete" | "mkdir" | "move" | "copy";
19
+ export interface FileOperation {
20
+ type: FileOperationType;
21
+ target: string;
22
+ secondaryTarget?: string;
23
+ }
24
+ export interface ShellConfig {
25
+ enabled: boolean;
26
+ allowedDirectory: string;
27
+ timeout: number;
28
+ forbiddenCommands: string[];
29
+ }
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnG,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B"}
@@ -0,0 +1,4 @@
1
+ import type { ShellConfig } from "../types";
2
+ export declare const DEFAULT_FORBIDDEN_COMMANDS: readonly string[];
3
+ export declare function loadShellConfig(): ShellConfig;
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../utils/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAS5C,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EA0B9C,CAAC;AAEX,wBAAgB,eAAe,IAAI,WAAW,CAmD7C"}
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_FORBIDDEN_COMMANDS, loadShellConfig } from "./config";
2
+ export { extractBaseCommand, isForbiddenCommand, isSafeCommand, validatePath, } from "./pathUtils";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function validatePath(commandPath: string, allowedDir: string, currentDir: string): string | null;
2
+ export declare function isSafeCommand(command: string): boolean;
3
+ export declare function extractBaseCommand(fullCommand: string): string;
4
+ export declare function isForbiddenCommand(command: string, forbiddenCommands: string[]): boolean;
5
+ //# sourceMappingURL=pathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../utils/pathUtils.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAaf;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CA0BtD;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG9D;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,OAAO,CAmBxF"}
package/package.json CHANGED
@@ -1,39 +1,93 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-shell",
3
- "version": "1.2.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "Shell command execution plugin for ElizaOS with directory restrictions and history tracking",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
- "scripts": {
10
- "build": "tsup",
11
- "test": "vitest run",
12
- "test:watch": "vitest"
13
- },
14
- "keywords": ["eliza", "plugin", "shell", "terminal", "command", "history"],
15
- "author": "elizaOS",
16
- "license": "MIT",
9
+ "sideEffects": false,
17
10
  "repository": {
18
11
  "type": "git",
19
12
  "url": "https://github.com/elizaos/eliza.git"
20
13
  },
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "default": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "keywords": [
26
+ "eliza",
27
+ "plugin",
28
+ "shell",
29
+ "terminal",
30
+ "command",
31
+ "history"
32
+ ],
33
+ "author": "elizaOS",
34
+ "license": "MIT",
21
35
  "dependencies": {
22
- "@elizaos/core": "^1.2.0",
36
+ "@elizaos/core": "workspace:*",
23
37
  "cross-spawn": "^7.0.6",
24
- "joi": "^17.13.3"
38
+ "zod": "^4.3.5"
25
39
  },
26
40
  "devDependencies": {
27
41
  "@types/cross-spawn": "^6.0.6",
28
- "@types/node": "^20.11.16",
29
- "tsup": "^8.0.1",
30
- "typescript": "^5.3.3",
31
- "vitest": "^1.2.1"
42
+ "@types/node": "^25.0.3",
43
+ "typescript": "^5.9.3",
44
+ "vitest": "^4.0.0",
45
+ "@biomejs/biome": "^2.3.11"
46
+ },
47
+ "scripts": {
48
+ "build": "bun run build.ts",
49
+ "build:ts": "bun run build.ts",
50
+ "dev": "bun --hot build.ts",
51
+ "clean": "rm -rf dist .turbo node_modules",
52
+ "test": "vitest run",
53
+ "typecheck": "tsc --noEmit",
54
+ "lint": "bunx @biomejs/biome check --write --unsafe .",
55
+ "lint:check": "bunx @biomejs/biome check .",
56
+ "format": "bunx @biomejs/biome format --write .",
57
+ "format:check": "bunx @biomejs/biome format ."
32
58
  },
33
- "files": [
34
- "dist"
35
- ],
36
59
  "publishConfig": {
37
60
  "access": "public"
61
+ },
62
+ "agentConfig": {
63
+ "pluginType": "elizaos:plugin:1.0.0",
64
+ "pluginParameters": {
65
+ "SHELL_ENABLED": {
66
+ "type": "boolean",
67
+ "description": "Enable or disable the shell plugin (disabled by default for safety)",
68
+ "required": false,
69
+ "default": false,
70
+ "sensitive": false
71
+ },
72
+ "SHELL_ALLOWED_DIRECTORY": {
73
+ "type": "string",
74
+ "description": "The directory that shell commands are restricted to. Commands cannot execute outside this directory.",
75
+ "required": true,
76
+ "sensitive": false
77
+ },
78
+ "SHELL_TIMEOUT": {
79
+ "type": "number",
80
+ "description": "Maximum command execution timeout in milliseconds",
81
+ "required": false,
82
+ "default": 30000,
83
+ "sensitive": false
84
+ },
85
+ "SHELL_FORBIDDEN_COMMANDS": {
86
+ "type": "string",
87
+ "description": "Comma-separated list of additional forbidden commands",
88
+ "required": false,
89
+ "sensitive": false
90
+ }
91
+ }
38
92
  }
39
- }
93
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 ElizaOS Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.