@exedev/sdk 0.0.6
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 +86 -0
- package/dist/client.d.ts +64 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +109 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @exedev/sdk
|
|
2
|
+
|
|
3
|
+
Official JavaScript/TypeScript SDK for the [exe.dev](https://exe.dev) HTTPS API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @exedev/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import exedev from "@exedev/sdk";
|
|
15
|
+
|
|
16
|
+
const exe = exedev({ token: process.env.EXE_TOKEN! });
|
|
17
|
+
|
|
18
|
+
// List all VMs
|
|
19
|
+
const vms = await exe.ls();
|
|
20
|
+
console.log(vms);
|
|
21
|
+
|
|
22
|
+
// Get your identity
|
|
23
|
+
const me = await exe.whoami();
|
|
24
|
+
console.log(me.email);
|
|
25
|
+
|
|
26
|
+
// Create a VM
|
|
27
|
+
await exe.new("my-vm", { region: "lon" });
|
|
28
|
+
|
|
29
|
+
// Get VM details
|
|
30
|
+
const info = await exe.stat("my-vm");
|
|
31
|
+
console.log(info);
|
|
32
|
+
|
|
33
|
+
// Run any command
|
|
34
|
+
const result = await exe.exec("help");
|
|
35
|
+
console.log(result.body);
|
|
36
|
+
|
|
37
|
+
// Delete a VM
|
|
38
|
+
await exe.rm("my-vm");
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Authentication
|
|
42
|
+
|
|
43
|
+
Generate an API token via SSH:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
ssh exe.dev token
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
See the [HTTPS API docs](https://exe.dev/docs/https-api) for full details on
|
|
50
|
+
authentication, token permissions, and scoping.
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
### `exedev(options)`
|
|
55
|
+
|
|
56
|
+
| Option | Type | Required | Default |
|
|
57
|
+
| --------- | ------ | -------- | ------------------- |
|
|
58
|
+
| `token` | string | Yes | |
|
|
59
|
+
| `baseURL` | string | No | `https://exe.dev` |
|
|
60
|
+
|
|
61
|
+
### Methods
|
|
62
|
+
|
|
63
|
+
| Method | Description |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `exec(command)` | Run any command (raw) |
|
|
66
|
+
| `ls()` | List VMs |
|
|
67
|
+
| `whoami()` | Get authenticated user |
|
|
68
|
+
| `stat(vmName)` | Get VM details |
|
|
69
|
+
| `new(name, options?)` | Create a VM |
|
|
70
|
+
| `rm(vmName)` | Delete a VM |
|
|
71
|
+
| `restart(vmName)` | Restart a VM |
|
|
72
|
+
| `rename(oldName, newName)` | Rename a VM |
|
|
73
|
+
| `sshKeyList()` | List SSH keys |
|
|
74
|
+
| `shareShow(vmName)` | Show sharing settings |
|
|
75
|
+
|
|
76
|
+
All methods accept an optional `{ signal: AbortSignal }` as the last argument for cancellation.
|
|
77
|
+
|
|
78
|
+
### Named import
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { exedev } from "@exedev/sdk";
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { VM, WhoamiResponse, StatResponse } from "./types.js";
|
|
2
|
+
export interface ExedevOptions {
|
|
3
|
+
/** Bearer token (exe0.* or exe1.*). */
|
|
4
|
+
token: string;
|
|
5
|
+
/** Base URL for the API. Defaults to "https://exe.dev". */
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ExecOptions {
|
|
9
|
+
/** AbortSignal for cancellation. */
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface ExecResult {
|
|
13
|
+
/** HTTP status code. */
|
|
14
|
+
status: number;
|
|
15
|
+
/** Raw response body. */
|
|
16
|
+
body: string;
|
|
17
|
+
/** Whether the request succeeded (2xx). */
|
|
18
|
+
ok: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ExedevClient {
|
|
21
|
+
/** Execute a raw command against the exe.dev API. */
|
|
22
|
+
exec(command: string, opts?: ExecOptions): Promise<ExecResult>;
|
|
23
|
+
/** List all VMs. */
|
|
24
|
+
ls(opts?: ExecOptions): Promise<VM[]>;
|
|
25
|
+
/** Get the authenticated user's identity. */
|
|
26
|
+
whoami(opts?: ExecOptions): Promise<WhoamiResponse>;
|
|
27
|
+
/** Get detailed status of a VM. */
|
|
28
|
+
stat(vmName: string, opts?: ExecOptions): Promise<StatResponse>;
|
|
29
|
+
/** Create a new VM. Returns the VM name. */
|
|
30
|
+
"new"(name: string, options?: {
|
|
31
|
+
region?: string;
|
|
32
|
+
}, opts?: ExecOptions): Promise<string>;
|
|
33
|
+
/** Delete a VM. */
|
|
34
|
+
rm(vmName: string, opts?: ExecOptions): Promise<void>;
|
|
35
|
+
/** Restart a VM. */
|
|
36
|
+
restart(vmName: string, opts?: ExecOptions): Promise<void>;
|
|
37
|
+
/** Rename a VM. */
|
|
38
|
+
rename(oldName: string, newName: string, opts?: ExecOptions): Promise<void>;
|
|
39
|
+
/** List SSH keys. */
|
|
40
|
+
sshKeyList(opts?: ExecOptions): Promise<string>;
|
|
41
|
+
/** Show sharing settings for a VM. */
|
|
42
|
+
shareShow(vmName: string, opts?: ExecOptions): Promise<string>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create an exe.dev API client.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import exedev from "@exedev/sdk";
|
|
50
|
+
*
|
|
51
|
+
* const exe = exedev({ token: process.env.EXE_TOKEN! });
|
|
52
|
+
* const vms = await exe.ls();
|
|
53
|
+
* console.log(vms);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export default function exedev(opts: ExedevOptions): ExedevClient;
|
|
57
|
+
/** Error thrown when the exe.dev API returns a non-2xx status. */
|
|
58
|
+
export declare class ExeAPIError extends Error {
|
|
59
|
+
readonly command: string;
|
|
60
|
+
readonly status: number;
|
|
61
|
+
readonly body: string;
|
|
62
|
+
constructor(command: string, status: number, body: string);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAkB,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnF,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,EAAE,EAAE,OAAO,CAAC;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IA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IACpC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAO1D"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create an exe.dev API client.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import exedev from "@exedev/sdk";
|
|
7
|
+
*
|
|
8
|
+
* const exe = exedev({ token: process.env.EXE_TOKEN! });
|
|
9
|
+
* const vms = await exe.ls();
|
|
10
|
+
* console.log(vms);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export default function exedev(opts) {
|
|
14
|
+
if (!opts.token) {
|
|
15
|
+
throw new Error("exedev: token is required");
|
|
16
|
+
}
|
|
17
|
+
const token = opts.token;
|
|
18
|
+
const baseURL = (opts.baseURL ?? "https://exe.dev").replace(/\/$/, "");
|
|
19
|
+
async function exec(command, execOpts) {
|
|
20
|
+
const res = await fetch(`${baseURL}/exec`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: `Bearer ${token}`,
|
|
24
|
+
"Content-Type": "text/plain",
|
|
25
|
+
},
|
|
26
|
+
body: command,
|
|
27
|
+
signal: execOpts?.signal,
|
|
28
|
+
});
|
|
29
|
+
const body = await res.text();
|
|
30
|
+
return { status: res.status, body, ok: res.ok };
|
|
31
|
+
}
|
|
32
|
+
async function execJSON(command, execOpts) {
|
|
33
|
+
const result = await exec(command, execOpts);
|
|
34
|
+
if (!result.ok) {
|
|
35
|
+
throw new ExeAPIError(command, result.status, result.body);
|
|
36
|
+
}
|
|
37
|
+
return JSON.parse(result.body);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
exec,
|
|
41
|
+
async ls(execOpts) {
|
|
42
|
+
const res = await execJSON("ls", execOpts);
|
|
43
|
+
return res.vms;
|
|
44
|
+
},
|
|
45
|
+
async whoami(execOpts) {
|
|
46
|
+
return execJSON("whoami", execOpts);
|
|
47
|
+
},
|
|
48
|
+
async stat(vmName, execOpts) {
|
|
49
|
+
return execJSON(`stat ${vmName}`, execOpts);
|
|
50
|
+
},
|
|
51
|
+
async new(name, options, execOpts) {
|
|
52
|
+
let cmd = `new ${name}`;
|
|
53
|
+
if (options?.region) {
|
|
54
|
+
cmd += ` --region=${options.region}`;
|
|
55
|
+
}
|
|
56
|
+
const result = await exec(cmd, execOpts);
|
|
57
|
+
if (!result.ok) {
|
|
58
|
+
throw new ExeAPIError(cmd, result.status, result.body);
|
|
59
|
+
}
|
|
60
|
+
return result.body.trim();
|
|
61
|
+
},
|
|
62
|
+
async rm(vmName, execOpts) {
|
|
63
|
+
const result = await exec(`rm ${vmName}`, execOpts);
|
|
64
|
+
if (!result.ok) {
|
|
65
|
+
throw new ExeAPIError(`rm ${vmName}`, result.status, result.body);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async restart(vmName, execOpts) {
|
|
69
|
+
const result = await exec(`restart ${vmName}`, execOpts);
|
|
70
|
+
if (!result.ok) {
|
|
71
|
+
throw new ExeAPIError(`restart ${vmName}`, result.status, result.body);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
async rename(oldName, newName, execOpts) {
|
|
75
|
+
const result = await exec(`rename ${oldName} ${newName}`, execOpts);
|
|
76
|
+
if (!result.ok) {
|
|
77
|
+
throw new ExeAPIError(`rename ${oldName} ${newName}`, result.status, result.body);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
async sshKeyList(execOpts) {
|
|
81
|
+
const result = await exec("ssh-key list", execOpts);
|
|
82
|
+
if (!result.ok) {
|
|
83
|
+
throw new ExeAPIError("ssh-key list", result.status, result.body);
|
|
84
|
+
}
|
|
85
|
+
return result.body;
|
|
86
|
+
},
|
|
87
|
+
async shareShow(vmName, execOpts) {
|
|
88
|
+
const result = await exec(`share show ${vmName}`, execOpts);
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
throw new ExeAPIError(`share show ${vmName}`, result.status, result.body);
|
|
91
|
+
}
|
|
92
|
+
return result.body;
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Error thrown when the exe.dev API returns a non-2xx status. */
|
|
97
|
+
export class ExeAPIError extends Error {
|
|
98
|
+
command;
|
|
99
|
+
status;
|
|
100
|
+
body;
|
|
101
|
+
constructor(command, status, body) {
|
|
102
|
+
super(`exe.dev API error (${status}): ${body.trim()}`);
|
|
103
|
+
this.name = "ExeAPIError";
|
|
104
|
+
this.command = command;
|
|
105
|
+
this.status = status;
|
|
106
|
+
this.body = body;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AA8CA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAmB;IAChD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,iBAAiB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvE,KAAK,UAAU,IAAI,CAAC,OAAe,EAAE,QAAsB;QACzD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,OAAO,EAAE;YACzC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,YAAY;aAC7B;YACD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js";
|
|
2
|
+
export { default as exedev } from "./client.js";
|
|
3
|
+
export { ExeAPIError } from "./client.js";
|
|
4
|
+
export type { ExedevOptions, ExedevClient, ExecOptions, ExecResult } from "./client.js";
|
|
5
|
+
export type { VM, VMListResponse, WhoamiResponse, StatResponse } from "./types.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EAAE,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** A VM as returned by `ls --json`. */
|
|
2
|
+
export interface VM {
|
|
3
|
+
vm_name: string;
|
|
4
|
+
ssh_dest: string;
|
|
5
|
+
https_url: string;
|
|
6
|
+
status: string;
|
|
7
|
+
region: string;
|
|
8
|
+
region_display: string;
|
|
9
|
+
}
|
|
10
|
+
export interface VMListResponse {
|
|
11
|
+
vms: VM[];
|
|
12
|
+
}
|
|
13
|
+
export interface WhoamiResponse {
|
|
14
|
+
email: string;
|
|
15
|
+
user_id: string;
|
|
16
|
+
}
|
|
17
|
+
export interface StatResponse {
|
|
18
|
+
vm_name: string;
|
|
19
|
+
status: string;
|
|
20
|
+
region: string;
|
|
21
|
+
region_display: string;
|
|
22
|
+
cpus: number;
|
|
23
|
+
memory_mb: number;
|
|
24
|
+
disk_gb: number;
|
|
25
|
+
ssh_dest: string;
|
|
26
|
+
https_url: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,WAAW,EAAE;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,EAAE,EAAE,CAAC;CACX;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exedev/sdk",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Official JavaScript/TypeScript SDK for the exe.dev API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"exe.dev",
|
|
24
|
+
"exedev",
|
|
25
|
+
"cloud",
|
|
26
|
+
"vm",
|
|
27
|
+
"api",
|
|
28
|
+
"sdk"
|
|
29
|
+
],
|
|
30
|
+
"author": "exe.dev",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"homepage": "https://exe.dev/docs/https-api",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/nicehash/exe",
|
|
36
|
+
"directory": "sdk/js"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.8.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"readme": "# @exedev/sdk\n\nOfficial JavaScript/TypeScript SDK for the [exe.dev](https://exe.dev) HTTPS API.\n\n## Install\n\n```sh\nnpm install @exedev/sdk\n```\n\n## Quick start\n\n```ts\nimport exedev from \"@exedev/sdk\";\n\nconst exe = exedev({ token: process.env.EXE_TOKEN! });\n\n// List all VMs\nconst vms = await exe.ls();\nconsole.log(vms);\n\n// Get your identity\nconst me = await exe.whoami();\nconsole.log(me.email);\n\n// Create a VM\nawait exe.new(\"my-vm\", { region: \"lon\" });\n\n// Get VM details\nconst info = await exe.stat(\"my-vm\");\nconsole.log(info);\n\n// Run any command\nconst result = await exe.exec(\"help\");\nconsole.log(result.body);\n\n// Delete a VM\nawait exe.rm(\"my-vm\");\n```\n\n## Authentication\n\nGenerate an API token via SSH:\n\n```sh\nssh exe.dev token\n```\n\nSee the [HTTPS API docs](https://exe.dev/docs/https-api) for full details on\nauthentication, token permissions, and scoping.\n\n## API\n\n### `exedev(options)`\n\n| Option | Type | Required | Default |\n| --------- | ------ | -------- | ------------------- |\n| `token` | string | Yes | |\n| `baseURL` | string | No | `https://exe.dev` |\n\n### Methods\n\n| Method | Description |\n| --- | --- |\n| `exec(command)` | Run any command (raw) |\n| `ls()` | List VMs |\n| `whoami()` | Get authenticated user |\n| `stat(vmName)` | Get VM details |\n| `new(name, options?)` | Create a VM |\n| `rm(vmName)` | Delete a VM |\n| `restart(vmName)` | Restart a VM |\n| `rename(oldName, newName)` | Rename a VM |\n| `sshKeyList()` | List SSH keys |\n| `shareShow(vmName)` | Show sharing settings |\n\nAll methods accept an optional `{ signal: AbortSignal }` as the last argument for cancellation.\n\n### Named import\n\n```ts\nimport { exedev } from \"@exedev/sdk\";\n```\n\n## License\n\nMIT\n"
|
|
45
|
+
}
|