@magpiecloud/mags 1.8.11 → 1.8.13
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 +16 -12
- package/bin/mags.js +31 -5
- package/index.js +7 -2
- package/nodejs/README.md +10 -4
- package/package.json +1 -1
- package/python/README.md +7 -3
- package/python/dist/magpie_mags-1.3.5-py3-none-any.whl +0 -0
- package/python/dist/magpie_mags-1.3.5.tar.gz +0 -0
- package/python/pyproject.toml +1 -1
- package/python/src/magpie_mags.egg-info/PKG-INFO +2 -2
- package/python/src/mags/client.py +13 -3
- package/website/api.html +137 -8
- package/website/cookbook.html +1 -1
- package/website/index.html +149 -95
- package/website/llms.txt +76 -31
- package/website/mags.md +3 -2
- package/python/dist/magpie_mags-1.3.4-py3-none-any.whl +0 -0
- package/python/dist/magpie_mags-1.3.4.tar.gz +0 -0
package/website/llms.txt
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Mags
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> Secure cloud sandboxes for AI agents and developers
|
|
4
4
|
|
|
5
|
-
Mags is a CLI, SDK, and API for running scripts on isolated microVMs with
|
|
5
|
+
Mags is a CLI, SDK, and API for running scripts on isolated microVMs with workspaces, file upload, cron scheduling, and optional URL access.
|
|
6
6
|
|
|
7
7
|
## Quickstart
|
|
8
8
|
|
|
@@ -26,32 +26,55 @@ mags run 'echo Hello World'
|
|
|
26
26
|
- `mags login` — Authenticate and save credentials
|
|
27
27
|
- `mags logout` — Remove saved credentials
|
|
28
28
|
- `mags whoami` — Check auth status
|
|
29
|
-
- `mags new <
|
|
29
|
+
- `mags new <name> [-p]` — Create a VM sandbox (add -p for S3 data persistence)
|
|
30
30
|
- `mags run <script>` — Execute a script on a microVM
|
|
31
|
-
- `mags ssh <
|
|
32
|
-
- `mags exec <
|
|
33
|
-
- `mags url <job-id>` — Enable public URL access for a running job
|
|
31
|
+
- `mags ssh <name>` — Open an SSH session into a sandbox (auto-starts if needed)
|
|
32
|
+
- `mags exec <name> <command>` — Run a command on an existing sandbox
|
|
34
33
|
- `mags list` — List recent jobs
|
|
35
|
-
- `mags logs <
|
|
36
|
-
- `mags status <
|
|
37
|
-
- `mags stop <
|
|
34
|
+
- `mags logs <name|id>` — View job logs
|
|
35
|
+
- `mags status <name|id>` — Check job status
|
|
36
|
+
- `mags stop <name|id>` — Stop a running job
|
|
37
|
+
- `mags sync <name|id>` — Sync workspace to S3 without stopping the VM
|
|
38
|
+
- `mags resize <name> --disk <GB>` — Resize disk for a workspace
|
|
39
|
+
- `mags url <name|id> [port]` — Enable public URL access for a running job
|
|
40
|
+
- `mags url alias <subdomain> <name>` — Create a stable URL alias
|
|
41
|
+
- `mags url alias list` — List URL aliases
|
|
42
|
+
- `mags url alias remove <subdomain>` — Remove a URL alias
|
|
38
43
|
- `mags set <name|id> --no-sleep` — Never auto-sleep this VM
|
|
39
44
|
- `mags set <name|id> --sleep` — Re-enable auto-sleep
|
|
45
|
+
- `mags workspace list` — List persistent workspaces
|
|
46
|
+
- `mags workspace delete <id>` — Delete workspace and cloud data
|
|
47
|
+
- `mags browser [name]` — Start a Chromium browser session (CDP access)
|
|
40
48
|
|
|
41
49
|
## Run Options
|
|
42
50
|
|
|
51
|
+
`-w` and `-n` are aliases — both set the job name and workspace ID to the same value.
|
|
52
|
+
|
|
43
53
|
| Flag | Description |
|
|
44
54
|
|------|-------------|
|
|
45
|
-
| `-w, --workspace <
|
|
46
|
-
| `-n, --name <name>` |
|
|
47
|
-
| `-p, --persistent` | Keep VM alive after script for URL
|
|
55
|
+
| `-w, --workspace <name>` | Name the job and workspace. Data stays local to the VM only (not synced to S3). Useful for data analysis where you don't need artifacts to persist. Combine with `-p` to sync to S3 and persist. |
|
|
56
|
+
| `-n, --name <name>` | Alias for `-w` |
|
|
57
|
+
| `-p, --persistent` | Keep VM alive after script and sync workspace to S3. Files persist across runs indefinitely. Required for URL, SSH, and cloud persistence. |
|
|
58
|
+
| `--base <workspace>` | Mount an existing workspace read-only as a starting point (OverlayFS). Use with `-w` to fork into a new workspace. |
|
|
48
59
|
| `--no-sleep` | Never auto-sleep this VM (requires -p) |
|
|
49
|
-
| `-e, --ephemeral` | No workspace, no
|
|
60
|
+
| `-e, --ephemeral` | No workspace, no sync (fastest). Cannot combine with -w, -p, or --base |
|
|
50
61
|
| `-f, --file <path>` | Upload a local file into /root/ in the VM (repeatable) |
|
|
51
62
|
| `--url` | Enable public URL (requires -p) |
|
|
52
63
|
| `--port <port>` | Port to expose (default: 8080) |
|
|
53
64
|
| `--disk <GB>` | Custom disk size in GB (default: 2) |
|
|
54
|
-
| `--startup-command <cmd>` | Command to run when a VM wakes |
|
|
65
|
+
| `--startup-command <cmd>` | Command to run when a VM wakes from sleep |
|
|
66
|
+
|
|
67
|
+
## Workspace Modes
|
|
68
|
+
|
|
69
|
+
| Flags | Behavior |
|
|
70
|
+
|-------|----------|
|
|
71
|
+
| (none) | Ephemeral. No workspace, no persistence. |
|
|
72
|
+
| `-w myproject` | Local workspace. Data stays on the VM only (~5 min warm cache after job completes). Not synced to S3. Good for data analysis and throwaway work. |
|
|
73
|
+
| `-w myproject -p` | Persistent workspace. VM stays alive, data synced to S3. Files survive across runs indefinitely. |
|
|
74
|
+
| `--base golden` | Read-only base image. Changes discarded after run. |
|
|
75
|
+
| `--base golden -w fork-1` | Fork: starts from golden, saves changes to fork-1 (local only without -p). |
|
|
76
|
+
| `--base golden -w fork-1 -p` | Fork with persistence: starts from golden, saves to fork-1 in S3. |
|
|
77
|
+
| `-e` | Explicit ephemeral. Same as no flags but cannot accidentally combine with -w or -p. |
|
|
55
78
|
|
|
56
79
|
## File Upload
|
|
57
80
|
|
|
@@ -64,8 +87,8 @@ mags run -f script.py 'python3 script.py'
|
|
|
64
87
|
# Multiple files
|
|
65
88
|
mags run -f analyze.py -f data.csv 'python3 analyze.py'
|
|
66
89
|
|
|
67
|
-
# With workspace
|
|
68
|
-
mags run -w my-project -f config.json -f app.js 'cp *.js *.json /root/ && cd /root && npm install'
|
|
90
|
+
# With persistent workspace
|
|
91
|
+
mags run -w my-project -p -f config.json -f app.js 'cp *.js *.json /root/ && cd /root && npm install'
|
|
69
92
|
```
|
|
70
93
|
|
|
71
94
|
## Cron Scheduling
|
|
@@ -96,24 +119,20 @@ mags cron disable <id>
|
|
|
96
119
|
|------|-------------|
|
|
97
120
|
| `-n, --name` | Cron job name (required) |
|
|
98
121
|
| `-s, --schedule` | Cron expression, e.g. "0 */2 * * *" (required) |
|
|
99
|
-
| `-w, --workspace` | Workspace ID for
|
|
122
|
+
| `-w, --workspace` | Workspace ID for storage |
|
|
100
123
|
| `-p, --persistent` | Keep VM alive after script |
|
|
101
124
|
|
|
102
|
-
## Workspaces
|
|
103
|
-
|
|
104
|
-
Workspaces persist files, installed packages, and configuration between runs. Running processes, in-memory state, and open ports reset between sessions.
|
|
105
|
-
|
|
106
125
|
## Complex Project Workflow
|
|
107
126
|
|
|
108
|
-
For multi-file projects, the recommended pattern is: create files locally, upload them, then run.
|
|
127
|
+
For multi-file projects, the recommended pattern is: create files locally, upload them, then run persistently.
|
|
109
128
|
|
|
110
129
|
```
|
|
111
|
-
# Step 1: Upload files and install deps in a workspace
|
|
112
|
-
mags run -w my-project -f server.js -f package.json \
|
|
130
|
+
# Step 1: Upload files and install deps in a persistent workspace
|
|
131
|
+
mags run -w my-project -p -f server.js -f package.json \
|
|
113
132
|
'cp *.js *.json /root/ && cd /root && npm install'
|
|
114
133
|
|
|
115
|
-
# Step 2: Test run
|
|
116
|
-
mags run -w my-project 'cd /root && node server.js'
|
|
134
|
+
# Step 2: Test run (reuses the persistent workspace)
|
|
135
|
+
mags run -w my-project -p 'cd /root && node server.js'
|
|
117
136
|
|
|
118
137
|
# Step 3: Run with public URL
|
|
119
138
|
mags run -w my-project -p --url --port 3000 'cd /root && node server.js'
|
|
@@ -123,9 +142,27 @@ mags cron add --name "my-server" --schedule "0 */6 * * *" -w my-project \
|
|
|
123
142
|
'cd /root && node server.js'
|
|
124
143
|
```
|
|
125
144
|
|
|
145
|
+
## Data Analysis Workflow
|
|
146
|
+
|
|
147
|
+
For throwaway analysis where you need a workspace but don't care about persisting artifacts:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
# Upload data and analyze — workspace is local only, no S3 overhead
|
|
151
|
+
mags run -w analysis -f data.csv 'python3 -c "
|
|
152
|
+
import csv
|
|
153
|
+
with open(\"/root/data.csv\") as f:
|
|
154
|
+
reader = csv.reader(f)
|
|
155
|
+
for row in reader:
|
|
156
|
+
print(row)
|
|
157
|
+
"'
|
|
158
|
+
|
|
159
|
+
# Results printed to stdout (use `mags logs` to retrieve)
|
|
160
|
+
# VM and data cleaned up automatically after ~5 minutes
|
|
161
|
+
```
|
|
162
|
+
|
|
126
163
|
## Ephemeral Mode
|
|
127
164
|
|
|
128
|
-
For the fastest runs with no workspace
|
|
165
|
+
For the fastest runs with no workspace at all:
|
|
129
166
|
```
|
|
130
167
|
mags run -e 'uname -a && df -h'
|
|
131
168
|
```
|
|
@@ -150,12 +187,17 @@ Generate tokens at https://mags.run/tokens or via `mags login`.
|
|
|
150
187
|
- `GET /mags-jobs/{id}/status` — Get job status
|
|
151
188
|
- `GET /mags-jobs/{id}/logs` — Get job logs
|
|
152
189
|
- `POST /mags-jobs/{id}/access` — Enable URL or SSH access
|
|
153
|
-
- `PATCH /mags-jobs/{id}` — Update
|
|
190
|
+
- `PATCH /mags-jobs/{id}` — Update job settings (startup_command, no_sleep)
|
|
154
191
|
|
|
155
192
|
### File Endpoints
|
|
156
193
|
|
|
157
194
|
- `POST /mags-files` — Upload file(s) via multipart/form-data (max 100MB)
|
|
158
195
|
|
|
196
|
+
### Workspace Endpoints
|
|
197
|
+
|
|
198
|
+
- `GET /mags-workspaces` — List workspaces
|
|
199
|
+
- `DELETE /mags-workspaces/{id}` — Delete workspace and S3 data
|
|
200
|
+
|
|
159
201
|
### Cron Endpoints
|
|
160
202
|
|
|
161
203
|
- `POST /mags-cron` — Create a cron job
|
|
@@ -193,9 +235,12 @@ mags = Mags() # uses MAGS_API_TOKEN env var
|
|
|
193
235
|
result = mags.run_and_wait('echo Hello World')
|
|
194
236
|
print(result['logs'])
|
|
195
237
|
|
|
196
|
-
# Create a
|
|
238
|
+
# Create a sandbox (local disk)
|
|
197
239
|
mags.new('my-project')
|
|
198
240
|
|
|
241
|
+
# Create with S3 persistence
|
|
242
|
+
mags.new('my-project', persistent=True)
|
|
243
|
+
|
|
199
244
|
# Execute a command on an existing sandbox
|
|
200
245
|
result = mags.exec('my-project', 'ls -la /root')
|
|
201
246
|
print(result['output'])
|
|
@@ -265,8 +310,8 @@ Then use `/mags <description>` in Claude Code to run scripts in microVMs.
|
|
|
265
310
|
|
|
266
311
|
- Alpine Linux base image
|
|
267
312
|
- Hostname: `mags-vm`
|
|
268
|
-
-
|
|
269
|
-
- JuiceFS mount: `/jfs`
|
|
313
|
+
- Home directory: `/root`
|
|
314
|
+
- JuiceFS mount: `/jfs` (persistent workspaces only)
|
|
270
315
|
- Package manager: `apk`
|
|
271
316
|
- Pre-installed: curl, wget, git, python3, node, vim, nano
|
|
272
317
|
|
package/website/mags.md
CHANGED
|
@@ -31,9 +31,10 @@ mags run -p --url '<script>'
|
|
|
31
31
|
mags run -w <workspace> -p --url --port 3000 '<script>'
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
### Create a new
|
|
34
|
+
### Create a new VM sandbox (stays alive for SSH)
|
|
35
35
|
```bash
|
|
36
|
-
mags new <name>
|
|
36
|
+
mags new <name> # Local disk only
|
|
37
|
+
mags new <name> -p # With S3 data persistence
|
|
37
38
|
```
|
|
38
39
|
|
|
39
40
|
### Execute a command on an existing sandbox
|
|
Binary file
|
|
Binary file
|