@framers/agentos-ext-cli-executor

中文文档
1.3.4发布于 2026/11/11Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2万

CLI executor extension for AgentOS - execute shell commands and manage files

原始使用文档
文档目录27 节
  1. Features
  2. Installation
  3. Quick Start
  4. Tools
  5. shell_execute
  6. file_read
  7. file_write
  8. list_directory
  9. read_document
  10. create_pdf
  11. create_spreadsheet
  12. create_document
  13. Security
  14. Dangerous Pattern Detection
  15. Custom Blocklists
  16. Disabling Safety Checks (Dangerous)
  17. Risk Assessment
  18. Configuration
  19. Filesystem Policy (Recommended)
  20. Per-Agent Workspace Helper
  21. Use Cases
  22. Code Generation and Execution
  23. Project Setup
  24. Log Analysis
  25. Document Processing Pipeline
  26. The Two Primitives Theory
  27. License

CLI Executor Extension for AgentOS

Execute shell commands, run scripts, and manage files for AgentOS agents. This is one of the two fundamental primitives (along with Web Browser) that enables recursive self-building agent capabilities.

Features

  • Shell Execution: Run any shell command with output capture
  • File Management: Read, write, and list files/directories
  • Document I/O: Read and write xlsx, csv, docx, and pdf files
  • Security Controls: Dangerous command detection and blocking
  • Cross-Platform: Works on Windows, macOS, and Linux

Installation

npm install @framers/agentos-ext-cli-executor

Quick Start

import { ExtensionManager } from '@framers/agentos';
import { createExtensionPack } from '@framers/agentos-ext-cli-executor';

const extensionManager = new ExtensionManager();

// Load the pack into the runtime
await extensionManager.loadPackFromFactory(
  createExtensionPack({
    options: {
      defaultShell: 'bash',
      timeout: 60000,
      blockedCommands: ['rm -rf /', 'format'],
      // Restrict file_* tools to a per-agent workspace
      filesystem: { allowRead: true, allowWrite: true },
      agentWorkspace: { agentId: 'my-agent' },
    },
    logger: console,
  }),
  '@framers/agentos-ext-cli-executor',
);

Tools

shell_execute

Execute a shell command.

const result = await gmi.executeTool('shell_execute', {
  command: 'npm install lodash',
  cwd: '/path/to/project',
  timeout: 30000
});
// Returns: { command, exitCode, stdout, stderr, duration, success }

file_read

Read file contents.

const result = await gmi.executeTool('file_read', {
  path: './package.json',
  encoding: 'utf-8'
});
// Returns: { path, content, size, truncated, encoding }

// Read last 50 lines
const logs = await gmi.executeTool('file_read', {
  path: './app.log',
  lines: 50,
  fromEnd: true
});

file_write

Write content to a file.

const result = await gmi.executeTool('file_write', {
  path: './config.json',
  content: JSON.stringify({ key: 'value' }),
  createDirs: true
});
// Returns: { path, bytesWritten, created, appended }

list_directory

List directory contents.

const result = await gmi.executeTool('list_directory', {
  path: './src',
  recursive: true,
  pattern: '*.ts',
  includeStats: true
});
// Returns: { path, entries: [{ name, path, type, size, ... }], count }

read_document

Read and extract text from binary document formats (xlsx, xls, csv, tsv, docx, pdf).

// Read an Excel spreadsheet
const result = await gmi.executeTool('read_document', {
  path: './data/report.xlsx',
  sheet: 'Q1 Revenue',  // optional: specific sheet
  maxRows: 200          // optional: limit rows (default: 500)
});
// Returns: { path, format, size, content (markdown tables), structured: { sheets }, metadata }

// Read a Word document
const doc = await gmi.executeTool('read_document', {
  path: './docs/proposal.docx'
});
// Returns: { path, format, size, content (extracted text), metadata }

// Read a PDF
const pdf = await gmi.executeTool('read_document', {
  path: './reports/annual.pdf'
});
// Returns: { path, format, size, content (extracted text), metadata: { pages, info } }

Note: file_read automatically redirects binary formats (.xlsx, .docx, .pdf) to read_document with a helpful error message.

create_pdf

Create a real PDF document from text content.

const result = await gmi.executeTool('create_pdf', {
  path: './output/report.pdf',
  content: 'Annual Report\n\nRevenue increased 25% year over year...',
  title: 'Annual Report 2026',
  author: 'Research Agent',
  fontSize: 11
});
// Returns: { path, pages, bytes }

create_spreadsheet

Create an Excel (.xlsx) or CSV file from structured data.

// From headers + rows (2D array)
const result = await gmi.executeTool('create_spreadsheet', {
  path: './output/data.xlsx',
  headers: ['Name', 'Age', 'City'],
  rows: [['Alice', 30, 'NYC'], ['Bob', 25, 'SF']],
  sheetName: 'Contacts'
});
// Returns: { path, format, rows, bytes }

// From array of objects
const result = await gmi.executeTool('create_spreadsheet', {
  path: './output/users.xlsx',
  data: [
    { name: 'Alice', age: 30, city: 'NYC' },
    { name: 'Bob', age: 25, city: 'SF' }
  ]
});

// From a markdown table
const result = await gmi.executeTool('create_spreadsheet', {
  path: './output/report.csv',
  markdown: '| Product | Sales |\n| --- | --- |\n| Widget | 1500 |\n| Gadget | 2300 |'
});

// CSV output (auto-detected from extension)
const csv = await gmi.executeTool('create_spreadsheet', {
  path: './output/export.csv',
  headers: ['id', 'value'],
  rows: [['1', '100'], ['2', '200']]
});

create_document

Create a Word document (.docx) from text or markdown content.

const result = await gmi.executeTool('create_document', {
  path: './output/report.docx',
  content: '# Quarterly Report\n\n## Summary\n\nRevenue was **$1.5M**, up *25%* from last quarter.\n\n- Widget sales: $800K\n- Gadget sales: $700K',
  title: 'Q1 Report',
  author: 'Research Agent'
});
// Returns: { path, paragraphs, bytes }

Supported markdown: # headings (H1-H6), **bold**, *italic*, - bullet lists.

Note: file_write automatically redirects .pdf, .xlsx, and .docx to the dedicated creation tools with a helpful error message.

Security

The extension includes built-in security controls:

Dangerous Pattern Detection

Commands matching these patterns are blocked by default:

  • rm -rf / (recursive delete root)
  • format C: (format drives)
  • Fork bombs
  • Direct disk writes
  • System shutdown/reboot commands

Custom Blocklists

createExtensionPack({
  options: {
    blockedCommands: ['sudo', 'su', 'chmod 777'],
    allowedCommands: ['npm', 'node', 'python', 'git'] // Whitelist mode
  }
});

Disabling Safety Checks (Dangerous)

If you need full control (for example, in a locked-down container or local dev), you can disable all command safety checks:

createExtensionPack({
  options: {
    dangerouslySkipSecurityChecks: true
  }
});

Risk Assessment

Each command is assessed for risk level:

Risk LevelExamples
safels, cat, npm list
lowecho "text" > file.txt
mediumrm file.txt, eval
highsudo, `curl
criticalrm -rf /, blocked patterns

Configuration

OptionTypeDefaultDescription
defaultShellstringautoShell to use (bash, powershell, cmd, zsh)
timeoutnumber60000Default timeout (ms)
workingDirectorystringprocess.cwd()Default working directory
filesystemobjectundefinedOptional policy for file_* tools (allowRead/allowWrite + roots)
agentWorkspaceobjectundefinedOptional per-agent workspace directory helper
allowedCommandsstring[][]Command whitelist (empty = all)
blockedCommandsstring[][]Command blacklist (additional to built-in dangerous patterns)
dangerouslySkipSecurityChecksbooleanfalseDisable all command safety checks (use only in trusted environments)
envobject{}Environment variables

By default, the file_* tools can access any path (legacy behavior). To enforce a safe filesystem sandbox, configure filesystem + roots:

createExtensionPack({
  options: {
    filesystem: {
      allowRead: true,
      allowWrite: true,
      readRoots: ['/Users/me/Documents/AgentOS/agents/my-agent'],
      writeRoots: ['/Users/me/Documents/AgentOS/agents/my-agent'],
    },
  },
});

Per-Agent Workspace Helper

To simplify safe defaults, you can configure agentWorkspace. When paired with filesystem.allowRead/allowWrite, the extension defaults roots to the workspace directory.

createExtensionPack({
  options: {
    filesystem: { allowRead: true, allowWrite: true },
    agentWorkspace: {
      agentId: 'my-agent',
      // baseDir defaults to ~/Documents/AgentOS
      subdirs: ['assets', 'exports', 'tmp'],
    },
  },
});

Use Cases

Code Generation and Execution

// Write generated code
await gmi.executeTool('file_write', {
  path: './generated/app.py',
  content: generatedPythonCode,
  createDirs: true
});

// Execute it
await gmi.executeTool('shell_execute', {
  command: 'python ./generated/app.py',
  timeout: 30000
});

Project Setup

// Create project structure
await gmi.executeTool('shell_execute', {
  command: 'npx create-react-app my-app --template typescript'
});

// Install dependencies
await gmi.executeTool('shell_execute', {
  command: 'npm install axios lodash',
  cwd: './my-app'
});

Log Analysis

// Read recent logs
const logs = await gmi.executeTool('file_read', {
  path: '/var/log/app.log',
  lines: 100,
  fromEnd: true
});

// Parse and analyze
const errorCount = logs.output.content.match(/ERROR/g)?.length || 0;

Document Processing Pipeline

// Read a spreadsheet, analyze it, write a report
const data = await gmi.executeTool('read_document', {
  path: './data/sales.xlsx',
  sheet: 'Q1'
});

// Create a summary report as Word doc
await gmi.executeTool('create_document', {
  path: './output/summary.docx',
  content: `# Sales Summary\n\n${data.output.content}`,
  title: 'Q1 Sales Summary'
});

// Export processed data as CSV
await gmi.executeTool('create_spreadsheet', {
  path: './output/processed.csv',
  headers: ['Region', 'Total'],
  rows: processedData
});

// Generate PDF invoice
await gmi.executeTool('create_pdf', {
  path: './output/invoice.pdf',
  content: invoiceText,
  title: 'Invoice #1234'
});

The Two Primitives Theory

This extension, combined with the Web Browser extension, provides the two fundamental capabilities needed for a recursive self-building agent:

  1. CLI Executor (this extension)

    • Execute arbitrary code
    • Manage files
    • Install dependencies
    • Run tests and builds
  2. Web Browser (see web-browser extension)

    • Search for information
    • Read documentation
    • Learn new techniques
    • Verify implementations

Together, an intelligent agent can:

  1. Identify what it needs to learn → Web search
  2. Find documentation/tutorials → Web scraping
  3. Write code → File write
  4. Execute and test → Shell execute
  5. Debug and iterate → Repeat

License

Apache-2.0 © Frame.dev

版本与发布记录

@framers/agentos-ext-cli-executor 共发布 8 个版本,首次发布于 2026/02/06;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.3.4latest2026/11/114 天前
1.3.32026/11/0115 天前
1.3.22026/10/2125 天前
1.3.12026/10/111 个月前
1.3.02026/10/081 个月前
1.2.02026/03/138 个月前

关于 @framers/agentos-ext-cli-executor 的常见问题

@framers/agentos-ext-cli-executor 是什么?

CLI executor extension for AgentOS - execute shell commands and manage files

如何安装 @framers/agentos-ext-cli-executor?

在项目目录运行 npm install @framers/agentos-ext-cli-executor,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@framers/agentos(>=0.10.40)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@framers/agentos-ext-cli-executor 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@framers/agentos-ext-cli-executor 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@framers/agentos-ext-cli-executor 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@framers/agentos-ext-cli-executor 可以商用吗?

@framers/agentos-ext-cli-executor 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@framers/agentos-ext-cli-executor 的下载量有多少?

根据 npm 官方下载统计,@framers/agentos-ext-cli-executor 在 2026/10/16 – 2026/11/14 这 30 天内被下载 20,278 次,日均约 676 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@framers/agentos-ext-cli-executor 还在维护吗?

最新版本 1.3.4 发布于 2026/11/11(4 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/02/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。