{"id":50508905,"url":"https://github.com/sairam0424/ag-bash","last_synced_at":"2026-06-02T18:31:19.835Z","repository":{"id":358602520,"uuid":"1210828394","full_name":"sairam0424/ag-bash","owner":"sairam0424","description":"🐚 Ag-Bash: The AI-Native Shell Gateway. A production-grade, sandboxed Bash environment designed for AI agents. Features high-fidelity Tree-sitter AST parsing, automated agentic observability (AgTrace), and cross-platform MCP support.","archived":false,"fork":false,"pushed_at":"2026-06-01T19:21:27.000Z","size":13819,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"develop","last_synced_at":"2026-06-01T21:17:15.227Z","etag":null,"topics":["ag-bash","agentic-workflows","ai-agents","bash-shell","mcp-server","observability","sandboxing","tree-sitter","typescript","virtual-filesystem","webassembly"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sairam0424.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":"THREAT_MODEL.md","audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-14T19:51:23.000Z","updated_at":"2026-05-31T11:43:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/sairam0424/ag-bash","commit_stats":null,"previous_names":["sairam0424/ag-bash"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/sairam0424/ag-bash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sairam0424%2Fag-bash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sairam0424%2Fag-bash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sairam0424%2Fag-bash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sairam0424%2Fag-bash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sairam0424","download_url":"https://codeload.github.com/sairam0424/ag-bash/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sairam0424%2Fag-bash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33833277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-02T02:00:07.132Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ag-bash","agentic-workflows","ai-agents","bash-shell","mcp-server","observability","sandboxing","tree-sitter","typescript","virtual-filesystem","webassembly"],"created_at":"2026-06-02T18:31:18.861Z","updated_at":"2026-06-02T18:31:19.827Z","avatar_url":"https://github.com/sairam0424.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ag-Bash: The AI-Native Shell Monorepo\n\n[![NPM Version](https://img.shields.io/npm/v/@ag-bash/bash.svg)](https://www.npmjs.com/package/@ag-bash/bash)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/sairam0424/ag-bash/blob/main/LICENSE)\n\nAg-Bash is a production-grade, sandboxed Bash environment designed specifically for AI agents. It provides a virtualized Unix-like experience entirely in-process, featuring an in-memory filesystem, integrated runtimes for Python and JavaScript, and full support for modern agentic protocols.\n\n## 🏗️ Monorepo Architecture\n\nThis repository is organized into a modular monorepo to support independent versioning and consumption of core engine components and protocol adapters.\n\n| Package | Version | Description |\n| :--- | :--- | :--- |\n| [`@ag-bash/bash`](./packages/bash) | [![npm](https://img.shields.io/npm/v/@ag-bash/bash.svg)](https://www.npmjs.com/package/@ag-bash/bash) | **Core Engine**: The virtual shell, filesystem, and sandboxed runtimes. |\n| [`@ag-bash/mcp-server`](./packages/mcp-server) | [![npm](https://img.shields.io/npm/v/@ag-bash/mcp-server.svg)](https://www.npmjs.com/package/@ag-bash/mcp-server) | **MCP Server**: A standalone Model Context Protocol server for seamless agent integration. |\n| [`@ag-bash/agent-bridge`](./packages/agent-bridge) | [![npm](https://img.shields.io/npm/v/@ag-bash/agent-bridge.svg)](https://www.npmjs.com/package/@ag-bash/agent-bridge) | **Agent Bridge**: Terminal UI bridge for AI agent communication. |\n\n---\n\n## What's New in v6.0.0\n\n| Feature | Description |\n| :--- | :--- |\n| **ExecutionPipeline** | The composable 6-stage pipeline (normalize, parse, transform, sandbox, interpret, persist) is now the sole execution engine. The legacy monolith path has been removed. |\n| **Fork-Speculation** | `bash.fork()` creates isolated copy-on-write branches; `bash.speculate()` runs N candidates in parallel and keeps the winner. Core moat for agentic workflows. |\n| **Observations at Source** | Every command produces typed `Observation` objects with `code` and `confidence` fields, surfacing issues without blocking execution. |\n| **True Streaming** | `bash.execStream()` yields stdout/stderr chunks via AsyncGenerator as statements produce output, byte-identical to buffered exec. |\n| **RunLoop v2** | Extended with `mode`, `healer`, and `memory` configuration. AgentMemory now persists across sessions. |\n| **MCP 2025-06-18** | Protocol bumped to latest spec with back-compat preserved for 2024-11-05 clients. Code Mode slice for structured output. |\n| **Destructive Detection** | AST-based gate detects `rm -rf /`, fork bombs, and decode-pipe-to-shell patterns structurally. Default policy: WARN. |\n| **OTEL at Exec Level** | Optional `AgBashTracer` wraps each `exec()` call in an OpenTelemetry span. Zero overhead when `@opentelemetry/api` is absent. |\n\n---\n\n## Installation\n\n**Requires Node.js \u003e=20.6.0.** For full ESM-hook security hardening, Node.js \u003e=23.5 is recommended.\n\n```bash\n# Latest (recommended)\nnpm install @ag-bash/bash\n\n# With MCP server\nnpm install @ag-bash/mcp-server\n```\n\n**Subpath imports** for tree-shaking and targeted use:\n\n```typescript\nimport { Bash, createShell } from \"@ag-bash/bash\";\nimport { RunLoop } from \"@ag-bash/bash/agent-runtime\";\nimport { createTestBash } from \"@ag-bash/bash/testing\";\n```\n\n---\n\n## 🚀 Quick Start\n\n### For Developers (Library)\n\nIf you are building an application and want to embed a sandboxed shell:\n\n```bash\nnpm install @ag-bash/bash\n```\n\n```typescript\nimport { Bash, createShell } from \"@ag-bash/bash\";\n\n// Quick instantiation\nconst bash = new Bash();\nconst result = await bash.exec('echo \"Hello Ag-Bash\"');\nconsole.log(result.stdout); // \"Hello Ag-Bash\\n\"\n\n// Or use createShell for full configuration\nconst shell = createShell({ filesystem: \"overlay\", cwd: \"/workspace\" });\nawait shell.exec(\"ls -la\");\n```\n\n### 2. Standalone CLI \u0026 Shell (Global)\n\nFor human-in-the-loop debugging and interactive use, install the Ag-Bash suite globally.\n\n#### Via Homebrew (macOS)\n\n```bash\nbrew tap ag-bash/homebrew-tap\nbrew install ag-bash\n```\n\n#### Via NPM (Cross-platform)\n\n```bash\nnpm install -g @ag-bash/bash @ag-bash/mcp-server\n```\n\n---\n\n### For AI Agents (MCP)\n\nTo provide a bash environment to your agent (e.g., in Claude Desktop or Cursor):\n\n```bash\nnpm install -g @ag-bash/mcp-server\n```\n\nThen, add the server to your MCP configuration:\n\n```json\n{\n  \"mcpServers\": {\n    \"ag-bash\": {\n      \"command\": \"ag-bash-mcp\",\n      \"args\": []\n    }\n  }\n}\n```\n\n---\n\n## 🛡️ Key Features\n\n- **v6.0 Architecture**: ExecutionPipeline as sole engine, fork-speculation, observations-at-source, true streaming, OTEL tracing, destructive-detection gate.\n- **v6.0 RunLoop**: Autonomous LLM execution loop with observation forwarding, AgenticHealer self-correction, AgentMemory persistence, plan-mode write-gating, and BudgetManager stopping conditions.\n- **v3.0 DI** *(Breaking)*: Dependency Injection via `ServiceContainer`, restructured `BashOptions` API with grouped sub-objects, and zero singletons.\n- **FNV-1a ASTCache**: Non-cryptographic hashing with true LRU eviction for high-frequency script execution.\n- **Pipeline Early Termination**: Static AST analysis detects `head -N` patterns and truncates upstream output.\n- **Type-Safe Core**: Eliminated `any` types from core services, interpreter, and error hierarchy (`unknown` throughout).\n- **Hardened MCP Server**: Sanitized JSON-RPC error messages (path stripping, length cap), zero console leakage from library code.\n- **Project V-Next**: (v2.5.0+) Unified Permission Architecture, Real JSON-RPC MCP Client (Stdio/HTTP), and multi-step Planning Mode.\n- **Nexus Prime Suite**: (v2.0.0+) Intelligent semantic analysis (`ag-hover`, `ag-explain`), symbol discovery, and persistent project management.\n- **Agentic Healer 2.0**: (v2.4.0+) Tool-aware recovery loop with multi-keyword semantic scoring for automated remediation.\n- **High-Fidelity Observability**: (v2.4.0+) EventEmitter-driven tool tracking with `tool:start`, `tool:progress`, and `tool:end` hooks.\n- **Tree-sitter AST Parser**: High-fidelity shell parsing for complex scripts and security analysis.\n- **Virtual Filesystem**: Choose between `InMemoryFs`, `OverlayFs` (COW), or `ReadWriteFs`.\n- **Integrated Runtimes**: Out-of-the-box support for `jq`, `sqlite3`, `python3` (WASM), and `js-exec` (QuickJS).\n- **Protocol First**: Full Model Context Protocol (MCP) support with persistent session state.\n- **Defense in Depth**: Robust sandbox prevents prototype pollution and unauthorized filesystem access.\n- **No Dependencies**: The core engine is lightweight and runs in Node.js or the Browser.\n\n## 📖 Documentation\n\n- **[User Guide](./docs/user-guide.md)**: Narrative introduction to Ag-Bash, installation, and core concepts.\n- **[Command Registry](./docs/COMMAND_REGISTRY.md)**: Categorized reference for all 110+ supported tools.\n- **[Technical Architecture](./docs/ARCHITECTURE.md)**: Deep dive into the Nexus engine, performance, and resource accounting.\n- **[Shell Engine Deep-Dive](./packages/bash/README.md)**: Technical guide for filesystem options and custom commands.\n- **[MCP Server Configuration](./packages/mcp-server/README.md)**: Agentic integration patterns and configuration.\n- **[Security \u0026 Threat Model](./THREAT_MODEL.md)**: Detailed breakdown of the sandbox architecture.\n\n## Version History\n\n| Version | Codename | Highlights |\n| :--- | :--- | :--- |\n| **v6.0** | *Pipeline* | ExecutionPipeline default, fork-speculation, streaming, OTEL, destructive gate, Node \u003e=20.6 |\n| **v5.0** | *Hardened* | Lazy ServiceContainer, defense-in-depth default ON, SSRF prevention, ASTCache 64-bit FNV-1a |\n| **v4.1** | *Runtime* | Introduced Agent RunLoop, Trap signal handlers, Self-Healing recovery, and OpenTelemetry spans (default/extended in v6.0) |\n| **v3.0** | *Breaking Redesign* | ServiceContainer DI, new `BashOptions` grouped API, zero singletons |\n| **v2.x** | *Nexus Prime* | Agentic tools (`ag-hover`, `ag-explain`), MCP integration, Planning Mode |\n| **v1.x** | *Genesis* | Initial release, core interpreter, in-memory filesystem, basic builtins |\n\nSee the [CHANGELOG](./CHANGELOG.md) for detailed release notes.\n\n---\n\n## 📜 License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsairam0424%2Fag-bash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsairam0424%2Fag-bash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsairam0424%2Fag-bash/lists"}