@struktoai/mirage-claude-managed-agents 0.0.8-alpha.1 → 0.0.8
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.
- package/README.md +140 -46
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
<img src="https://raw.githubusercontent.com/strukto-ai/mirage/main/assets/mirage-header-light.svg" width="100%" alt="Mirage: A Virtual Terminal for AI Agents" />
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
+
<a href="https://agentvfs.org">
|
|
9
|
+
<picture>
|
|
10
|
+
<source media="(max-width: 767px) and (prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/strukto-ai/mirage/main/assets/agentvfs-banner-narrow-dark.svg">
|
|
11
|
+
<source media="(max-width: 767px)" srcset="https://raw.githubusercontent.com/strukto-ai/mirage/main/assets/agentvfs-banner-narrow-light.svg">
|
|
12
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/strukto-ai/mirage/main/assets/agentvfs-banner-dark.svg">
|
|
13
|
+
<img src="https://raw.githubusercontent.com/strukto-ai/mirage/main/assets/agentvfs-banner-light.svg" width="100%" alt="AgentVFS: the open, vendor-neutral virtual filesystem interface for AI agents" />
|
|
14
|
+
</picture>
|
|
15
|
+
</a>
|
|
8
16
|
</h1>
|
|
9
17
|
|
|
10
18
|
<p align="center">
|
|
@@ -16,6 +24,8 @@
|
|
|
16
24
|
<img src="https://img.shields.io/badge/made by-strukto.ai-0C0C0C?labelColor=F0ECE2" /></a>
|
|
17
25
|
<a href="https://github.com/strukto-ai/mirage/blob/main/LICENSE" alt="License">
|
|
18
26
|
<img src="https://img.shields.io/badge/license-Apache--2.0-0C0C0C?labelColor=F0ECE2" /></a>
|
|
27
|
+
<a href="https://doi.org/10.5281/zenodo.23504502" alt="DOI">
|
|
28
|
+
<img src="https://img.shields.io/badge/DOI-10.5281%2Fzenodo.23504502-0C0C0C?labelColor=F0ECE2" alt="DOI 10.5281/zenodo.23504502" /></a>
|
|
19
29
|
<a href="https://discord.gg/u8BPQ65KsS" alt="Discord">
|
|
20
30
|
<img src="https://img.shields.io/badge/discord-join-0C0C0C?labelColor=F0ECE2&logo=discord&logoColor=0C0C0C" /></a>
|
|
21
31
|
<br/>
|
|
@@ -40,7 +50,7 @@
|
|
|
40
50
|
<a href="https://github.com/strukto-ai/mirage/blob/main/readme/README.ko.md"><img alt="README 한국어" src="https://img.shields.io/badge/%ED%95%9C%EA%B5%AD%EC%96%B4-F0ECE2"></a>
|
|
41
51
|
</p>
|
|
42
52
|
|
|
43
|
-
Mirage is **a Virtual Terminal for AI Agents
|
|
53
|
+
Mirage is **a Virtual Terminal for AI Agents**: one shell over data, CLIs and runtimes. Unix tools reach every service, and `grep` runs on each service's own search, such as Gmail's or Slack's. Mirage routes each command to the runtime that fits it, so most lines run in-process and only heavy work reaches a sandbox, which cuts infrastructure cost and tokens. The terminal itself is light: a workspace takes **about 100 KB** of memory and each new session **about 10 KB**, so one process serves many agents at once. Profiles decide what an agent can run and even what it can see, and scriptable policies refuse anything those rules cannot express.
|
|
44
54
|
|
|
45
55
|
<p align="center">
|
|
46
56
|
<picture>
|
|
@@ -54,24 +64,56 @@ Here is an example of launching Mirage inside an application:
|
|
|
54
64
|
```python
|
|
55
65
|
ws = Workspace(
|
|
56
66
|
{
|
|
57
|
-
"/
|
|
58
|
-
"/redis": (RedisVFS(url=redis_url), MountMode.WRITE),
|
|
67
|
+
"/s3": (S3VFS(S3Config(bucket="my-bucket")), MountMode.WRITE),
|
|
59
68
|
"/slack": (SlackVFS(SlackConfig(token=slack_bot_token)), MountMode.EXEC),
|
|
69
|
+
"/gmail": (GmailVFS(GmailConfig(**google_credentials)), MountMode.READ),
|
|
60
70
|
},
|
|
61
|
-
#
|
|
62
|
-
|
|
71
|
+
# Install the Slack CLI, run by name and listed by `man` and `which` like any program
|
|
72
|
+
clis={"slack": (SLACK, {"token": slack_bot_token})},
|
|
73
|
+
# the analyst profile hides /s3/secrets and denies posting to Slack and curl
|
|
74
|
+
profiles={
|
|
75
|
+
"analyst": {
|
|
76
|
+
"paths": {"hide": ["/s3/secrets"]},
|
|
77
|
+
"commands": {"deny": ["slack send-message", "curl"]},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
runtimes=[
|
|
81
|
+
MontyRuntime(captures=["python", "python3"]),
|
|
82
|
+
E2BRuntime(
|
|
83
|
+
captures=["python", "python3"],
|
|
84
|
+
config={"sandbox_id": sandbox_id, "mount_type": "ssh"},
|
|
85
|
+
),
|
|
86
|
+
],
|
|
87
|
+
# route the underlying computation: numpy lines run in the e2b sandbox, the rest on monty
|
|
88
|
+
route_policy=lambda ctx: "e2b" if "numpy" in ctx.line else None,
|
|
63
89
|
)
|
|
64
90
|
|
|
65
|
-
#
|
|
66
|
-
await ws.
|
|
91
|
+
# Add an agent using the analyst profile
|
|
92
|
+
alice = await ws.session("alice", profile="analyst")
|
|
93
|
+
|
|
94
|
+
# one grep sweeps S3, Slack and Gmail, on each service's own search where it has one
|
|
95
|
+
await alice.shell("grep -rlw invoice /s3 /slack /gmail")
|
|
67
96
|
|
|
68
|
-
# run a script that lives in Slack, file the report into
|
|
69
|
-
await
|
|
97
|
+
# run a script that lives in Slack on monty, file the report into S3
|
|
98
|
+
await alice.shell("python3 /slack/channels/general__C0123/2026-10-21/files/report__F0456.py > /s3/report.txt")
|
|
70
99
|
|
|
71
|
-
#
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
# numpy is not in monty, so the route policy sends this line to e2b
|
|
101
|
+
await alice.shell("python3 -c 'import numpy; print(numpy.arange(10).sum())'")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
And what `alice` sees in the shell:
|
|
105
|
+
|
|
106
|
+
```console
|
|
107
|
+
$ grep -rlw invoice /s3 /slack /gmail
|
|
108
|
+
/s3/billing/2026-10.csv
|
|
109
|
+
/gmail/INBOX/2026-10-21/Invoice_1042__18f3a9c2b7d1e0f4.gmail.json
|
|
110
|
+
$ ls /s3
|
|
111
|
+
billing
|
|
112
|
+
report.txt
|
|
113
|
+
$ cat /s3/secrets/aws.txt
|
|
114
|
+
cat: /s3/secrets/aws.txt: No such file or directory
|
|
115
|
+
$ slack send-message --channel general --text "report is up"
|
|
116
|
+
slack: Permission denied
|
|
75
117
|
```
|
|
76
118
|
|
|
77
119
|
## About
|
|
@@ -81,6 +123,7 @@ await ws.shell('slack send-message --channel general --text "report is up"')
|
|
|
81
123
|
- **Virtual command line tools (CLIs).** `git`, `slack` and `ntn` are answered by Mirage itself, so an agent drives the service with nothing installed, across different runtimes and machines, and one tool can be virtualized into two or more, each under its own name with its own credentials.
|
|
82
124
|
- **Routed, dynamic runtimes.** Python, JavaScript and any other command can be sent to a configured runtime, in process, sandboxed or remote, which decouples computation from storage and lets either change without touching the other.
|
|
83
125
|
- **The virtualized Mirage shell.** It binds the filesystem, the CLIs and the runtimes into one command line, so pipes, redirection, variables, jobs and history work across all three.
|
|
126
|
+
- **Lightweight by design.** A workspace, the virtual terminal itself, takes about 100 KB of memory and each new session about 10 KB, so one process serves many agents without a container or VM per agent.
|
|
84
127
|
- **Profiles designed for agents.** `allow`, `ask` and `deny` govern commands and CLIs, while `hide` and `show` govern files and folders, so a hidden path is not merely unreadable but absent from the filesystem the agent sees.
|
|
85
128
|
- **A scriptable policy engine.** A policy script can prohibit any dangerous action before it runs, and the same stack gates every VFS op and session write, so neither a file nor an environment variable leaks.
|
|
86
129
|
- **Notifications wired into the VFS and agents.** External changes become an event stream on the mount, so a new Slack reply surfaces as a change to the chat file in the virtual filesystem, and the agent reacts to it instead of rescanning the tree.
|
|
@@ -158,8 +201,8 @@ in Mirage can resolve straight to a credential held in one of them.
|
|
|
158
201
|
|
|
159
202
|
## Installation
|
|
160
203
|
|
|
161
|
-
- **Python** ≥ 3.
|
|
162
|
-
- **Node.js**
|
|
204
|
+
- **Python** ≥ 3.12 for the `mirage-ai` package and the `mirage` CLI
|
|
205
|
+
- **Node.js** 22.20+ on Node 22, 24.12+ on Node 24, or 25+ for the TypeScript SDK
|
|
163
206
|
|
|
164
207
|
### Python
|
|
165
208
|
|
|
@@ -181,58 +224,109 @@ Both runtime packages pull in `@struktoai/mirage-core` automatically.
|
|
|
181
224
|
### CLI
|
|
182
225
|
|
|
183
226
|
```bash
|
|
184
|
-
curl -fsSL https://strukto.ai/mirage/install.sh | sh
|
|
185
|
-
# or
|
|
186
227
|
npm install -g @struktoai/mirage-cli
|
|
187
228
|
# or
|
|
188
|
-
uvx mirage-ai
|
|
229
|
+
uvx --from mirage-ai mirage
|
|
189
230
|
# or
|
|
190
231
|
npx @struktoai/mirage-cli
|
|
191
232
|
```
|
|
192
233
|
|
|
193
|
-
|
|
234
|
+
To get started, see the quickstarts for
|
|
235
|
+
[Python](https://docs.mirage.strukto.ai/python/quickstart),
|
|
236
|
+
[TypeScript](https://docs.mirage.strukto.ai/typescript/quickstart) and the
|
|
237
|
+
[CLI](https://docs.mirage.strukto.ai/home/access/cli).
|
|
194
238
|
|
|
195
|
-
|
|
239
|
+
## Scriptable Policy
|
|
240
|
+
|
|
241
|
+
A profile can name policy scripts for what its rules cannot express. A script
|
|
242
|
+
reads the command as JSON, can open the files it names, and prints a deny, an
|
|
243
|
+
ask or nothing. This one disables `rm`, and a Python script whose code
|
|
244
|
+
deletes files:
|
|
196
245
|
|
|
197
246
|
```python
|
|
198
|
-
|
|
199
|
-
from mirage.vfs.ram import RAMVFS
|
|
200
|
-
from mirage.vfs.s3 import S3Config, S3VFS
|
|
247
|
+
import json, os
|
|
201
248
|
|
|
202
|
-
|
|
203
|
-
"/data": RAMVFS(),
|
|
204
|
-
"/s3": S3VFS(S3Config(bucket="my-bucket")),
|
|
205
|
-
})
|
|
249
|
+
ctx = json.loads(os.environ["MIRAGE_POLICY_CTX"])
|
|
206
250
|
|
|
207
|
-
await ws.shell("cp /s3/report.csv /data/report.csv")
|
|
208
|
-
await ws.shell("grep alert /s3/data/log.jsonl | wc -l")
|
|
209
251
|
|
|
210
|
-
|
|
211
|
-
|
|
252
|
+
def deletes(path):
|
|
253
|
+
try:
|
|
254
|
+
code = open(path).read()
|
|
255
|
+
except OSError:
|
|
256
|
+
return False
|
|
257
|
+
return any(call in code for call in ("os.remove", "os.unlink", "shutil.rmtree"))
|
|
212
258
|
|
|
213
|
-
### TypeScript
|
|
214
259
|
|
|
215
|
-
|
|
216
|
-
|
|
260
|
+
if ctx["command"] == "rm" or (
|
|
261
|
+
ctx["command"].startswith("python") and any(deletes(p) for p in ctx["paths"])
|
|
262
|
+
):
|
|
263
|
+
print(json.dumps({"kind": "deny", "reason": "deleting files is disabled"}))
|
|
264
|
+
```
|
|
217
265
|
|
|
218
|
-
|
|
219
|
-
'/data': new RAMVFS(),
|
|
220
|
-
'/s3': new S3VFS({ bucket: 'my-bucket' }),
|
|
221
|
-
})
|
|
266
|
+
Register it in a profile, here to run on Monty before every command:
|
|
222
267
|
|
|
223
|
-
|
|
224
|
-
|
|
268
|
+
```python
|
|
269
|
+
ws = Workspace(
|
|
270
|
+
{"/s3": (S3VFS(S3Config(bucket="my-bucket")), MountMode.WRITE)},
|
|
271
|
+
profiles={
|
|
272
|
+
"analyst": {
|
|
273
|
+
"policy": {
|
|
274
|
+
"pre_command": [{"script": ScriptSource(Path("guard.py").read_text()), "runtime": "monty"}],
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
profile="analyst",
|
|
279
|
+
)
|
|
280
|
+
```
|
|
225
281
|
|
|
226
|
-
|
|
282
|
+
```console
|
|
283
|
+
$ cat /s3/clean.py
|
|
284
|
+
import os
|
|
285
|
+
os.remove("/s3/report.txt")
|
|
286
|
+
$ rm /s3/report.txt
|
|
287
|
+
rm: Permission denied
|
|
288
|
+
$ python3 /s3/clean.py
|
|
289
|
+
python3: Permission denied
|
|
227
290
|
```
|
|
228
291
|
|
|
229
|
-
|
|
292
|
+
See [policy scripts](https://docs.mirage.strukto.ai/home/policy/scripts) for
|
|
293
|
+
the other stages a script can answer at.
|
|
294
|
+
|
|
295
|
+
## Embedded Terminal
|
|
296
|
+
|
|
297
|
+
Most of the time an agent does not need a sandbox, only a terminal-like
|
|
298
|
+
interface, and Mirage embeds one in an application server. Each terminal is a
|
|
299
|
+
Mirage session with its own working directory, environment and history, and Python
|
|
300
|
+
runs in-process on Monty, so a terminal starts with no container or VM. Here
|
|
301
|
+
it is in Express; the FastAPI version is in the
|
|
302
|
+
[docs](https://docs.mirage.strukto.ai/home/examples/embedded-terminal).
|
|
230
303
|
|
|
231
304
|
```bash
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
305
|
+
npm install @struktoai/mirage-node @pydantic/monty express
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
import express from 'express'
|
|
310
|
+
import { MontyRuntime, MountMode, RAMVFS, Workspace } from '@struktoai/mirage-node'
|
|
311
|
+
|
|
312
|
+
const ws = new Workspace(
|
|
313
|
+
{ '/work': new RAMVFS() },
|
|
314
|
+
{ mode: MountMode.EXEC, runtimes: [new MontyRuntime({ captures: ['python', 'python3'] })] },
|
|
315
|
+
)
|
|
316
|
+
const app = express()
|
|
317
|
+
app.use(express.json())
|
|
318
|
+
|
|
319
|
+
app.post('/sessions/:id', (req, res) => {
|
|
320
|
+
ws.createSession(req.params.id)
|
|
321
|
+
res.sendStatus(201)
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
app.post('/sessions/:id/run', async (req, res) => {
|
|
325
|
+
const r = await ws.shell(req.body.command, { sessionId: req.params.id })
|
|
326
|
+
res.json({ stdout: r.stdoutText, stderr: r.stderrText, exitCode: r.exitCode })
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
app.listen(3000, '127.0.0.1')
|
|
236
330
|
```
|
|
237
331
|
|
|
238
332
|
## Contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@struktoai/mirage-claude-managed-agents",
|
|
3
|
-
"version": "0.0.8
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Make a Mirage workspace the self-hosted environment of an agent on Claude Managed Agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mirage",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@struktoai/mirage-core": "0.0.8
|
|
41
|
+
"@struktoai/mirage-core": "0.0.8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@anthropic-ai/sdk": "
|
|
44
|
+
"@anthropic-ai/sdk": ">=0.124.0 <2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@anthropic-ai/sdk": "^
|
|
47
|
+
"@anthropic-ai/sdk": "^1.3.0",
|
|
48
48
|
"@types/node": "^22.0.0",
|
|
49
49
|
"tsup": "^8.5.0",
|
|
50
50
|
"typescript": "^6.0.0",
|
|
51
|
-
"vitest": "^4.1.
|
|
52
|
-
"@struktoai/mirage-node": "0.0.8
|
|
51
|
+
"vitest": "^4.1.12",
|
|
52
|
+
"@struktoai/mirage-node": "0.0.8"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
-
"build": "tsup",
|
|
55
|
+
"build": "tsup --config ../../tsup.base.config.ts",
|
|
56
56
|
"test": "vitest run",
|
|
57
57
|
"typecheck": "tsc --noEmit"
|
|
58
58
|
}
|