mirage README

项目的 README,来自 github.com/strukto-ai/mirage。合并为一个 markdown 文件:README.md。

Mirage: A Virtual Terminal for AI Agents AgentVFS: the open, vendor-neutral virtual filesystem interface for AI agents

Status: experimental DOI 10.5281/zenodo.23504502 WeChat community
Python docs
TypeScript docs

README in English 简体中文 README 繁體中文 README README en Français README auf Deutsch README Tiếng Việt README 한국어

LLMs are post-trained in terminal environments, so AI agents are most familiar with the terminal interface. But a terminal today is bound to a single machine and its operating system kernel, with its files and its computation on that same machine.

Mirage is a virtual terminal for AI agents that separates the terminal interface from the data storage and the computing machines. It virtualizes the shell, the filesystem, the CLIs and the machines. Each virtual terminal starts with only KBs of memory, so AI agents can use terminal environments everywhere, inside an application, a mobile app, a browser tab, a FastAPI or Express server, and even an edge device such as a Raspberry Pi.

Mirage over three virtual filesystems (S3, Slack, Google Drive), three virtual CLIs (gh, linear, deepwiki-mcp), three VMs (Monty, an E2B sandbox, an EC2 GPU) and a policy layer: one grep searches all three filesystems, the three CLIs feed one grep, one pipeline runs a stage on each VM, and policy refuses one line that reads a hidden .pem key, deletes from the read-only /s3 mount and merges a PR

Mirage architecture: agents and harness reach profiles and the Mirage shell, which resolve Unix-like commands, virtual CLIs and programming languages onto machines, runtimes and the virtual filesystem, with service credentials, the policy engine and notifications alongside

Here is an example of launching Mirage inside an application:

ws = Workspace(
    {
        "/s3":    (S3VFS(S3Config(bucket="my-bucket")), MountMode.WRITE),
        "/slack": (SlackVFS(SlackConfig(token=slack_bot_token)), MountMode.EXEC),
        "/gmail": (GmailVFS(GmailConfig(**google_credentials)), MountMode.READ),
    },
    # Install the Slack CLI, run by name and listed by `man` and `which` like any program
    clis={"slack": (SLACK, {"token": slack_bot_token})},
    # the analyst profile hides /s3/secrets and denies posting to Slack and curl
    profiles={
        "analyst": {
            "paths": {"hide": ["/s3/secrets"]},
            "commands": {"deny": ["slack send-message", "curl"]},
        },
    },
    # python runs in process on monty, or on the e2b sandbox
    machines={
        "py": {"provider": "in_process", "runtime": "monty"},
        "box": {"provider": "e2b", "sandbox_id": sandbox_id, "mount_type": "ssh", "captures": ["python", "python3"]},
    },
    # route the underlying computation: numpy lines run on the machine, the rest on monty
    route_policy=lambda ctx: "box" if "numpy" in ctx.line else None,
)

# Add an agent using the analyst profile
alice = await ws.session("alice", profile="analyst")

# one grep sweeps S3, Slack and Gmail, on each service's own search where it has one
await alice.shell("grep -rlw invoice /s3 /slack /gmail")

# run a script that lives in Slack on monty, file the report into S3
await alice.shell("python3 /slack/channels/general__C0123/2026-10-21/files/report__F0456.py > /s3/report.txt")

# numpy is not in monty, so the route policy sends this line to e2b
await alice.shell("python3 -c 'import numpy; print(numpy.arange(10).sum())'")

And what alice sees in the shell:

$ grep -rlw invoice /s3 /slack /gmail
/s3/billing/2026-10.csv
/gmail/INBOX/2026-10-21/Invoice_1042__18f3a9c2b7d1e0f4.gmail.json
$ ls /s3
billing
report.txt
$ cat /s3/secrets/aws.txt
cat: /s3/secrets/aws.txt: No such file or directory
$ slack send-message --channel general --text "report is up"
slack: Permission denied

About

Unified Virtual Filesystem

Everything Mirage "mounts" as one unified virtual filesystem for AI agents. Each service sits side-by-side under a single root and answers the same POSIX semantics.

VFS
Object Storage Amazon S3  Cloudflare R2  Google Cloud Storage  Oracle OCI  Supabase Storage  MinIO  Ceph  SeaweedFS  Wasabi  Backblaze B2  DigitalOcean Spaces  Alibaba Cloud OSS  Tencent Cloud COS  Scaleway  QingStor  Hugging Face Buckets  GridFS
Files and Documents Google Drive  Google Docs  Google Sheets  Google Slides  OneDrive  SharePoint  Box  Dropbox  Nextcloud TiDB Cloud Filesystem
Messaging and Work Slack  Discord  Gmail  IMAP / SMTP email  GitHub  Linear  Notion  Trello  Google Calendar
Databases and Data Platforms PostgreSQL  MongoDB  Redis Upstash Redis SQL Airtable  LanceDB  Qdrant  Chroma  Mem0  Hugging Face Datasets  Hugging Face Models  Hugging Face Spaces  Databricks Volumes  Dify
Observability Langfuse  Jaeger Weights & Biases
Local and Remote RAM  Disk  OPFS  SSH

Agents reach it through the Python and TypeScript SDKs, the mirage CLI, or a real mountpoint over FUSE and FSKit, then work it with the unix tools they already know, like ls, grep, find and jq.

Virtual CLIs

These command line tools are virtualized: Mirage answers git, slack or ntn itself, so an agent drives the service without that program being installed on the machine. Each one mimics the real tool, so an agent that knows the CLI needs nothing new. Because they are virtual, the same tool can be installed more than once under different names, each with its own credentials, so every agent gets exactly the accounts it is given.

CLIs
Code git  gh
Communication slack  discord  himalaya
Work and Data linear  ntn trello airtable  gws  hf office pdftotext pdfinfo

Virtual Machines

Machines are virtualized the same way, and not only for coding languages. Any command on the line can be sent to a configured machine, so Python might run in-process with Monty while another command, say kubectl, runs on a remote machine over SSH. Which machine serves a given line can be decided by a scripted machine router.

Machines
Python Monty  WASI CPython on wasmtime  Pyodide  sandlock  Host CPython
JavaScript QuickJS, serving node and js JavaScript TypeScript
Machines Docker Kubernetes  E2B  Daytona Cloudflare Container boxd  smolVM Microsandbox Apple Container  SSH

Security

A profile decides what a session may run and what it may see. Commands are governed by customizable allow, ask and deny rules, and paths by hide and show, so a hidden file is not merely unreadable but absent from the filesystem the agent sees. For anything those rules cannot express, a profile can name a policy script that runs at the gate on every command and answers allow, deny or ask itself, though like every rule it can only restrict and never grant. Separately, a host can register its own policies on the policy engine, an ordered stack the workspace consults on every command, VFS op and session write. See the policy docs.

Service Credentials

Service credentials integrate with the stores secrets already live in, including AWS Secrets Manager, 1Password and dotenv, so an environment variable in Mirage can resolve straight to a credential held in one of them.

Sources
Built in Environment dotenv
Custom 1Password AWS Secrets Manager

Installation

Python

uv add mirage-ai              # installs the `mirage` library and the `mirage` CLI binary
uv add 'mirage-ai[openai]'    # OpenAI Agents adapter; each agent framework is an extra
uv add 'mirage-ai[monty]'     # Monty, the in-process Python runtime the examples run on

TypeScript

npm install @struktoai/mirage-node      # Node.js servers and CLIs
npm install @struktoai/mirage-browser   # browser / edge runtimes

Both runtime packages pull in @struktoai/mirage-core automatically.

CLI

npm install -g @struktoai/mirage-cli
# or
uvx --from mirage-ai mirage
# or
npx @struktoai/mirage-cli

To get started, see the quickstarts for Python, TypeScript and the CLI.

Scriptable Policy

A profile can name policy scripts for what its rules cannot express. A script's pre_command takes the command, can open the files it names, and returns a deny, an ask or None. This one disables rm, and a Python script whose code deletes files:

def deletes(path):
    try:
        code = open(path).read()
    except OSError:
        return False
    return any(call in code for call in ("os.remove", "os.unlink", "shutil.rmtree"))


def pre_command(ctx):
    if ctx["command"] == "rm" or (
        ctx["command"].startswith("python") and any(deletes(p) for p in ctx["paths"])
    ):
        return {"kind": "deny", "reason": "deleting files is disabled"}

Register it in a profile, here to run on Monty before every command:

ws = Workspace(
    {"/s3": (S3VFS(S3Config(bucket="my-bucket")), MountMode.WRITE)},
    profiles={
        "analyst": {
            "policy": {
                "pre_command": [{"script": ScriptSource(Path("guard.py").read_text()), "runtime": "monty"}],
            },
        },
    },
    profile="analyst",
)
$ cat /s3/clean.py
import os
os.remove("/s3/report.txt")
$ rm /s3/report.txt
rm: Permission denied
$ python3 /s3/clean.py
python3: Permission denied

See policy scripts for the other stages a script can answer at.

Examples

Contributors

Thanks to everyone who has contributed to Mirage.

Mirage contributors

mirage (strukto-ai/mirage)

正在搜索数据库…

这是什么?Mirage 是一个面向 AI 代理的虚拟终端,它把 S3、Google Drive、Slack、Gmail 和 Redis 等服务挂载到一个统一的虚拟文件系统中,让代理用熟悉的 unix 工具(ls、grep、find、jq)访问一切、运行虚拟命令行、把代码路由到不同的运行时,并始终处于受策略控制的 shell 之内。
Mirage 是嵌入我应用里的框架,还是独立的命令行工具?它是你在自己的应用程序内启动的框架,而不是独立应用。它把虚拟文件系统、虚拟命令行和运行时绑定到一个由你的代理驱动的 shell 中。
怎么开始让我的代理使用 Mirage?你在应用程序内启动 Mirage,并把数据源(对象存储、文件、消息工具等)挂载到它唯一的虚拟文件系统根目录下;仓库的测试套件覆盖了 Python 和 TypeScript 两种集成。
代理要访问的每个服务都需要单独的 SDK 或 MCP 服务器吗?不需要。Mirage 用一个统一的虚拟终端接口取代了每个服务各自的 SDK 和 MCP 服务器,所有后端都说同一套文件系统语义。
代理能看到我想对它隐藏的文件或文件夹吗?不能——带 hide 和 show 规则的配置会把受限路径从代理可见范围内彻底移除,而不只是阻止读取;并且有一个可脚本化的策略引擎把关每一次文件系统操作和会话写入。
它能配合 Claude Code 或其他代理框架使用吗?可以——Mirage 以 dsh 插件的形式发布,其仓库主题标签列出了对 Claude Code 和 OpenAI Agents SDK 的支持,以及通用的 LLM 代理集成。
靠什么阻止代理执行删除文件这类危险操作?可脚本化的策略引擎可以在危险操作执行之前予以禁止,同一套机制还把关每一次虚拟文件系统操作和会话写入,确保什么都不泄露。
同一个底层工具能有带独立凭据的两个不同身份吗?可以——一个真实工具可以被虚拟化成两个或更多个命名的命令行,各自拥有独立凭据,代理会把它们看作不同的命令。
Mirage 如何应对外部变化,比如收到新的 Slack 消息?外部变化以事件的形式流入挂载点——一条新的 Slack 回复会体现为虚拟文件系统中聊天文件的变更,代理据此做出反应,而无需重新扫描整棵目录树。
代理执行的代码可以路由到哪些运行时?Python、JavaScript 和其他命令都可以发送到配置好的运行时——进程内、沙箱或远程——从而把计算与存储解耦。
有哪些类似的项目?xerj, deltabox-lite, cynative, capsule-fs, nono, treg, headroom, coop
大小
158.8 MB
星标
3.8K
时长
6个月
提交 · 90 天