@magpiecloud/mags 1.8.9 → 1.8.11
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 +79 -26
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -15,18 +15,10 @@ Mags is a CLI and SDK for running scripts on ephemeral microVMs. Each execution
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
### npm (recommended)
|
|
19
|
-
|
|
20
18
|
```bash
|
|
21
19
|
npm install -g @magpiecloud/mags
|
|
22
20
|
```
|
|
23
21
|
|
|
24
|
-
### Go CLI
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
go install github.com/magpiecloud/mags/cmd/mags@latest
|
|
28
|
-
```
|
|
29
|
-
|
|
30
22
|
## Authentication
|
|
31
23
|
|
|
32
24
|
### Interactive Login (Recommended)
|
|
@@ -261,15 +253,80 @@ const Mags = require('@magpiecloud/mags');
|
|
|
261
253
|
const mags = new Mags({
|
|
262
254
|
apiToken: process.env.MAGS_API_TOKEN
|
|
263
255
|
});
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### SDK Methods
|
|
264
259
|
|
|
260
|
+
#### Jobs
|
|
261
|
+
|
|
262
|
+
| Method | Description |
|
|
263
|
+
|--------|-------------|
|
|
264
|
+
| `run(script, options)` | Submit a job. Options: `name`, `workspaceId`, `baseWorkspaceId`, `persistent`, `noSleep`, `ephemeral`, `startupCommand`, `environment`, `fileIds`, `diskGb` |
|
|
265
|
+
| `runAndWait(script, options)` | Submit and block until done. Extra options: `timeout`, `pollInterval` |
|
|
266
|
+
| `new(name, options)` | Create a persistent VM and wait until running. Options: `baseWorkspaceId`, `diskGb`, `timeout` |
|
|
267
|
+
| `status(requestId)` | Get job status |
|
|
268
|
+
| `logs(requestId)` | Get job logs |
|
|
269
|
+
| `list({page, pageSize})` | List recent jobs (paginated) |
|
|
270
|
+
| `findJob(nameOrId)` | Find job by name, workspace ID, or request ID |
|
|
271
|
+
| `updateJob(requestId, {startupCommand, noSleep})` | Update job settings |
|
|
272
|
+
| `stop(nameOrId)` | Stop a job (accepts name, workspace ID, or request ID) |
|
|
273
|
+
| `exec(nameOrId, command, {timeout})` | Execute a command on a running/sleeping VM via SSH |
|
|
274
|
+
| `sync(requestId)` | Sync workspace to S3 without stopping |
|
|
275
|
+
| `resize(workspace, diskGb)` | Resize workspace disk (stops VM, creates new one) |
|
|
276
|
+
| `usage({windowDays})` | Get aggregated usage summary |
|
|
277
|
+
|
|
278
|
+
#### URL & Access
|
|
279
|
+
|
|
280
|
+
| Method | Description |
|
|
281
|
+
|--------|-------------|
|
|
282
|
+
| `enableAccess(requestId, port)` | Enable SSH (port 22) or HTTP access (default 8080) |
|
|
283
|
+
| `url(nameOrId, port)` | Enable public URL and return the full URL |
|
|
284
|
+
| `urlAliasCreate(subdomain, workspaceId, domain)` | Create a stable URL alias for a workspace |
|
|
285
|
+
| `urlAliasList()` | List all URL aliases |
|
|
286
|
+
| `urlAliasDelete(subdomain)` | Delete a URL alias |
|
|
287
|
+
|
|
288
|
+
#### Workspaces
|
|
289
|
+
|
|
290
|
+
| Method | Description |
|
|
291
|
+
|--------|-------------|
|
|
292
|
+
| `listWorkspaces()` | List all workspaces |
|
|
293
|
+
| `deleteWorkspace(workspaceId)` | Delete a workspace and its S3 data |
|
|
294
|
+
|
|
295
|
+
#### Files
|
|
296
|
+
|
|
297
|
+
| Method | Description |
|
|
298
|
+
|--------|-------------|
|
|
299
|
+
| `uploadFiles(filePaths)` | Upload local files, returns array of file IDs |
|
|
300
|
+
|
|
301
|
+
#### Cron Jobs
|
|
302
|
+
|
|
303
|
+
| Method | Description |
|
|
304
|
+
|--------|-------------|
|
|
305
|
+
| `cronCreate({name, cronExpression, script, workspaceId, environment, persistent})` | Create a scheduled job |
|
|
306
|
+
| `cronList()` | List all cron jobs |
|
|
307
|
+
| `cronGet(id)` | Get a cron job |
|
|
308
|
+
| `cronUpdate(id, updates)` | Update a cron job |
|
|
309
|
+
| `cronDelete(id)` | Delete a cron job |
|
|
310
|
+
|
|
311
|
+
### SDK Examples
|
|
312
|
+
|
|
313
|
+
```javascript
|
|
265
314
|
// Run and wait for completion
|
|
266
315
|
const result = await mags.runAndWait('echo Hello World');
|
|
267
316
|
console.log(result.logs);
|
|
268
317
|
|
|
269
|
-
//
|
|
270
|
-
|
|
318
|
+
// Create a persistent VM
|
|
319
|
+
await mags.new('myproject');
|
|
320
|
+
|
|
321
|
+
// Execute command on existing VM
|
|
322
|
+
const { output } = await mags.exec('myproject', 'ls -la /root');
|
|
323
|
+
console.log(output);
|
|
324
|
+
|
|
325
|
+
// Run with workspace and options
|
|
326
|
+
const job = await mags.run('python script.py', {
|
|
271
327
|
workspaceId: 'myproject',
|
|
272
328
|
persistent: true,
|
|
329
|
+
diskGb: 5,
|
|
273
330
|
startupCommand: 'python server.py'
|
|
274
331
|
});
|
|
275
332
|
|
|
@@ -280,22 +337,18 @@ await mags.run('node server.js', {
|
|
|
280
337
|
noSleep: true
|
|
281
338
|
});
|
|
282
339
|
|
|
283
|
-
//
|
|
284
|
-
const
|
|
285
|
-
console.log(
|
|
286
|
-
|
|
287
|
-
// Get logs
|
|
288
|
-
const logs = await mags.logs(requestId);
|
|
289
|
-
logs.logs.forEach(l => console.log(l.message));
|
|
340
|
+
// Enable public URL
|
|
341
|
+
const { url } = await mags.url('my-api', 3000);
|
|
342
|
+
console.log(url); // https://abc123.apps.magpiecloud.com
|
|
290
343
|
|
|
291
|
-
//
|
|
292
|
-
await mags.
|
|
344
|
+
// Create stable URL alias
|
|
345
|
+
await mags.urlAliasCreate('my-app', 'my-api');
|
|
293
346
|
|
|
294
|
-
//
|
|
295
|
-
|
|
347
|
+
// Resize workspace disk
|
|
348
|
+
await mags.resize('myproject', 10); // 10GB
|
|
296
349
|
|
|
297
|
-
// Stop a job
|
|
298
|
-
await mags.stop(
|
|
350
|
+
// Stop a job by name
|
|
351
|
+
await mags.stop('myproject');
|
|
299
352
|
```
|
|
300
353
|
|
|
301
354
|
## API Endpoints
|
|
@@ -414,9 +467,9 @@ SSH connects through our proxy. If you have issues:
|
|
|
414
467
|
|
|
415
468
|
## Support
|
|
416
469
|
|
|
417
|
-
- Documentation: https://
|
|
418
|
-
-
|
|
419
|
-
- Dashboard: https://
|
|
470
|
+
- Documentation: https://mags.run
|
|
471
|
+
- API Reference: https://mags.run/api.html
|
|
472
|
+
- Dashboard: https://mags.run/tokens.html
|
|
420
473
|
|
|
421
474
|
## License
|
|
422
475
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpiecloud/mags",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.11",
|
|
4
4
|
"description": "Mags CLI - Execute scripts on Magpie's instant VM infrastructure",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,11 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"author": "Magpie Cloud",
|
|
22
22
|
"license": "MIT",
|
|
23
|
-
"
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/magpiecloud/mags"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://magpiecloud.com/docs/mags",
|
|
23
|
+
"homepage": "https://mags.run",
|
|
28
24
|
"engines": {
|
|
29
25
|
"node": ">=14.0.0"
|
|
30
26
|
}
|