@magpiecloud/mags 1.5.1 → 1.6.1

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.
Files changed (42) hide show
  1. package/API.md +381 -0
  2. package/Mags-API.postman_collection.json +374 -0
  3. package/QUICKSTART.md +283 -0
  4. package/README.md +287 -79
  5. package/bin/mags.js +151 -27
  6. package/deploy-page.sh +171 -0
  7. package/index.js +1 -163
  8. package/mags +0 -0
  9. package/mags.sh +270 -0
  10. package/nodejs/README.md +191 -0
  11. package/nodejs/bin/mags.js +1146 -0
  12. package/nodejs/index.js +326 -0
  13. package/nodejs/package.json +42 -0
  14. package/package.json +4 -15
  15. package/python/INTEGRATION.md +747 -0
  16. package/python/README.md +139 -0
  17. package/python/dist/magpie_mags-1.0.0-py3-none-any.whl +0 -0
  18. package/python/dist/magpie_mags-1.0.0.tar.gz +0 -0
  19. package/python/examples/demo.py +181 -0
  20. package/python/pyproject.toml +39 -0
  21. package/python/src/magpie_mags.egg-info/PKG-INFO +164 -0
  22. package/python/src/magpie_mags.egg-info/SOURCES.txt +9 -0
  23. package/python/src/magpie_mags.egg-info/dependency_links.txt +1 -0
  24. package/python/src/magpie_mags.egg-info/requires.txt +1 -0
  25. package/python/src/magpie_mags.egg-info/top_level.txt +1 -0
  26. package/python/src/mags/__init__.py +6 -0
  27. package/python/src/mags/client.py +283 -0
  28. package/skill.md +153 -0
  29. package/website/api.html +927 -0
  30. package/website/claude-skill.html +483 -0
  31. package/website/cookbook/hn-marketing.html +410 -0
  32. package/website/cookbook/hn-marketing.sh +50 -0
  33. package/website/cookbook.html +278 -0
  34. package/website/env.js +4 -0
  35. package/website/index.html +718 -0
  36. package/website/llms.txt +242 -0
  37. package/website/login.html +88 -0
  38. package/website/mags.md +171 -0
  39. package/website/script.js +425 -0
  40. package/website/styles.css +845 -0
  41. package/website/tokens.html +171 -0
  42. package/website/usage.html +187 -0
@@ -0,0 +1,278 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Mags Cookbook</title>
7
+ <meta
8
+ name="description"
9
+ content="Practical Mags recipes for running scripts, building workspaces, and exposing services."
10
+ />
11
+ <meta name="api-base" content="https://api.magpiecloud.com" />
12
+ <meta name="auth-base" content="https://api.magpiecloud.com" />
13
+ <link rel="stylesheet" href="styles.css?v=2" />
14
+ <script src="env.js"></script>
15
+ </head>
16
+ <body>
17
+ <div class="backdrop"></div>
18
+
19
+ <header class="site-header">
20
+ <div class="container nav">
21
+ <div class="brand">
22
+ <span class="logo">Mags</span>
23
+ <span class="tag">Cookbook</span>
24
+ </div>
25
+ <nav class="nav-links">
26
+ <a href="index.html">Home</a>
27
+ <a href="index.html#quickstart">Quickstart</a>
28
+ <a href="index.html#cli">CLI</a>
29
+ <a href="index.html#api">API</a>
30
+ <a href="login.html">Login</a>
31
+ <a href="usage.html">Usage</a>
32
+ <a href="tokens.html">Tokens</a>
33
+ <a href="claude-skill.html">Claude Skill</a>
34
+ </nav>
35
+ <div class="nav-cta">
36
+ <a class="button ghost" href="index.html#quickstart">Get started</a>
37
+ </div>
38
+ </div>
39
+ </header>
40
+
41
+ <main>
42
+ <section class="hero">
43
+ <div class="container hero-grid">
44
+ <div class="hero-copy">
45
+ <span class="pill">Recipes</span>
46
+ <h1>Hands-on workflows for developers and hobbyists.</h1>
47
+ <p class="lead">
48
+ Copy these recipes to bootstrap a new workspace, run tests, or expose a
49
+ service. Each example is built around real Mags commands.
50
+ </p>
51
+ <div class="hero-actions">
52
+ <a class="button" href="#recipes">Browse recipes</a>
53
+ <a class="button ghost" href="claude-skill.html">Claude integration</a>
54
+ </div>
55
+ </div>
56
+ <div class="hero-card">
57
+ <div class="card-header">
58
+ <span>Starter</span>
59
+ <span class="chip">Workflow</span>
60
+ </div>
61
+ <pre><code>mags new dev-env
62
+ mags ssh dev-env
63
+
64
+ # inside the VM
65
+ apk add git nodejs npm</code></pre>
66
+ <p class="card-note">Create a persistent dev environment with one command.</p>
67
+ </div>
68
+ </div>
69
+ </section>
70
+
71
+ <section class="section" id="recipes">
72
+ <div class="container">
73
+ <div class="section-title">
74
+ <p>Cookbook</p>
75
+ <h2>Recipes you can reuse today.</h2>
76
+ </div>
77
+ <div class="recipe-list">
78
+ <article class="recipe-item" data-reveal>
79
+ <div class="recipe-header">
80
+ <h3>Quick script run</h3>
81
+ <span class="pill">Starter</span>
82
+ </div>
83
+ <pre><code>mags run 'echo Hello World'</code></pre>
84
+ </article>
85
+ <article class="recipe-item" data-reveal>
86
+ <div class="recipe-header">
87
+ <h3>Persistent Python workspace</h3>
88
+ <span class="pill">Workspace</span>
89
+ </div>
90
+ <pre><code>mags run -w ml-project \
91
+ 'apk add python3 py3-pip && pip install numpy pandas'
92
+
93
+ mags run -w ml-project \
94
+ 'python3 train.py'</code></pre>
95
+ </article>
96
+ <article class="recipe-item" data-reveal>
97
+ <div class="recipe-header">
98
+ <h3>Run tests with cached deps</h3>
99
+ <span class="pill">CI</span>
100
+ </div>
101
+ <pre><code>mags run -w myapp 'npm ci'
102
+
103
+ mags run -w myapp 'npm test'</code></pre>
104
+ </article>
105
+ <article class="recipe-item" data-reveal>
106
+ <div class="recipe-header">
107
+ <h3>Expose a simple web server</h3>
108
+ <span class="pill">URL</span>
109
+ </div>
110
+ <pre><code>mags run -p --url \
111
+ 'python3 -m http.server 8080'</code></pre>
112
+ <p class="label">Remember: your app should listen on the same port.</p>
113
+ </article>
114
+ <article class="recipe-item" data-reveal>
115
+ <div class="recipe-header">
116
+ <h3>Node.js app with startup command</h3>
117
+ <span class="pill">Persistent</span>
118
+ </div>
119
+ <pre><code>mags run -w myapp -p --url --port 3000 \
120
+ --startup-command 'npm start' \
121
+ 'npm install && npm start'</code></pre>
122
+ </article>
123
+ <article class="recipe-item" data-reveal>
124
+ <div class="recipe-header">
125
+ <h3>Upload files and run</h3>
126
+ <span class="pill">File</span>
127
+ </div>
128
+ <pre><code># Upload a script and a data file, then run
129
+ mags run -f analyze.py -f data.csv \
130
+ 'python3 analyze.py'
131
+
132
+ # Upload into a workspace (files persist)
133
+ mags run -w analytics -f analyze.py -f data.csv \
134
+ 'cp *.py *.csv /root/ && python3 /root/analyze.py'</code></pre>
135
+ <p class="label">Files land in <code>/root/</code> before your script runs.</p>
136
+ </article>
137
+ <article class="recipe-item" data-reveal>
138
+ <div class="recipe-header">
139
+ <h3>Ephemeral run (fastest)</h3>
140
+ <span class="pill">Speed</span>
141
+ </div>
142
+ <pre><code>mags run -e 'uname -a && df -h'</code></pre>
143
+ <p class="label">No workspace sync. Best for quick one-off commands.</p>
144
+ </article>
145
+ <article class="recipe-item" data-reveal>
146
+ <div class="recipe-header">
147
+ <h3>Manage cron jobs</h3>
148
+ <span class="pill">Cron</span>
149
+ </div>
150
+ <pre><code># Schedule a health check every 5 minutes
151
+ mags cron add --name "health-check" \
152
+ --schedule "*/5 * * * *" -w monitors \
153
+ 'curl -sf https://myapp.com/health || echo FAIL &gt;&gt; /root/alerts.log'
154
+
155
+ # List all cron jobs
156
+ mags cron list
157
+
158
+ # Disable / enable / remove
159
+ mags cron disable &lt;id&gt;
160
+ mags cron enable &lt;id&gt;
161
+ mags cron remove &lt;id&gt;</code></pre>
162
+ </article>
163
+ <article class="recipe-item" data-reveal>
164
+ <div class="recipe-header">
165
+ <h3>Inspect job output</h3>
166
+ <span class="pill">Debug</span>
167
+ </div>
168
+ <pre><code>mags list
169
+ mags status &lt;job-id&gt;
170
+ mags logs &lt;job-id&gt;</code></pre>
171
+ </article>
172
+ <article class="recipe-item" data-reveal>
173
+ <div class="recipe-header">
174
+ <h3>HN Marketing Digest</h3>
175
+ <span class="pill">Cron</span>
176
+ </div>
177
+ <pre><code># Upload script + install deps
178
+ mags run -f cookbook/hn-marketing.sh -w hn-digest \
179
+ 'cp hn-marketing.sh /root/ && chmod +x /root/hn-marketing.sh && apk add -q curl jq'
180
+
181
+ # Activate cron (every 2 hours)
182
+ mags cron add --name "hn-marketing" \
183
+ --schedule "0 */2 * * *" -w hn-digest \
184
+ 'sh /root/hn-marketing.sh'</code></pre>
185
+ <p class="label"><a href="cookbook/hn-marketing.html">Full recipe + live demo →</a></p>
186
+ </article>
187
+ </div>
188
+ </div>
189
+ </section>
190
+
191
+ <section class="section">
192
+ <div class="container">
193
+ <div class="section-title">
194
+ <p>SDK + API</p>
195
+ <h2>Automate runs from code.</h2>
196
+ </div>
197
+ <div class="grid split">
198
+ <article class="panel" data-reveal>
199
+ <h3>Node.js SDK</h3>
200
+ <pre><code>const Mags = require('@magpiecloud/mags');
201
+
202
+ const mags = new Mags({
203
+ apiToken: process.env.MAGS_API_TOKEN
204
+ });
205
+
206
+ // Run a script
207
+ const result = await mags.runAndWait('echo Hello World');
208
+ console.log(result.logs);
209
+
210
+ // Upload files and run
211
+ const fileIds = await mags.uploadFiles(['script.py', 'data.csv']);
212
+ const res = await mags.run('python3 script.py', { fileIds });
213
+
214
+ // Schedule a cron job
215
+ await mags.cronCreate({
216
+ name: 'daily-backup',
217
+ cronExpression: '0 0 * * *',
218
+ script: 'tar czf backup.tar.gz /data',
219
+ workspaceId: 'my-workspace'
220
+ });
221
+ const { cron_jobs } = await mags.cronList();</code></pre>
222
+ </article>
223
+ <article class="panel" data-reveal>
224
+ <h3>REST API</h3>
225
+ <pre><code># Submit a job
226
+ curl -X POST https://api.magpiecloud.com/api/v1/mags-jobs \
227
+ -H "Authorization: Bearer $MAGS_API_TOKEN" \
228
+ -H "Content-Type: application/json" \
229
+ -d '{
230
+ "script": "echo Hello World",
231
+ "type": "inline",
232
+ "workspace_id": "myproject",
233
+ "persistent": true
234
+ }'
235
+
236
+ # Upload a file
237
+ curl -X POST https://api.magpiecloud.com/api/v1/mags-files \
238
+ -H "Authorization: Bearer $MAGS_API_TOKEN" \
239
+ -F "file=@script.py"
240
+
241
+ # Create a cron job
242
+ curl -X POST https://api.magpiecloud.com/api/v1/mags-cron \
243
+ -H "Authorization: Bearer $MAGS_API_TOKEN" \
244
+ -H "Content-Type: application/json" \
245
+ -d '{
246
+ "name": "health-check",
247
+ "cron_expression": "*/5 * * * *",
248
+ "script": "curl -sf https://myapp.com/health"
249
+ }'</code></pre>
250
+ </article>
251
+ </div>
252
+ </div>
253
+ </section>
254
+ </main>
255
+
256
+ <footer class="site-footer">
257
+ <div class="container footer-grid">
258
+ <div>
259
+ <div class="brand">
260
+ <span class="logo">Mags</span>
261
+ <span class="tag">Instant sandboxes and runtime environments</span>
262
+ </div>
263
+ <p>Build, test, and run from clean microVMs whenever you need them.</p>
264
+ </div>
265
+ <div class="footer-links">
266
+ <a href="index.html">Home</a>
267
+ <a href="login.html">Login</a>
268
+ <a href="usage.html">Usage</a>
269
+ <a href="tokens.html">Tokens</a>
270
+ <a href="claude-skill.html">Claude Skill</a>
271
+ <a href="https://magpiecloud.com/docs/mags" rel="noreferrer">Documentation</a>
272
+ </div>
273
+ </div>
274
+ </footer>
275
+
276
+ <script src="script.js"></script>
277
+ </body>
278
+ </html>
package/website/env.js ADDED
@@ -0,0 +1,4 @@
1
+ window.MAGS_ENV = {
2
+ API_BASE: "http://localhost:9090",
3
+ AUTH_BASE: "http://localhost:9090"
4
+ };