vpsgui 1.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NotGamerPratham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # vpsgui
2
+
3
+ Official CLI and Node.js / TypeScript SDK for the
4
+ [VPSGUI](https://github.com/NotGamerPratham/vpsgui) agent REST API.
5
+
6
+ > Previously published as `vpsgui-sdk`. Same code, shorter name, and now with a `vpsgui` command.
7
+ > Change `from 'vpsgui-sdk'` to `from 'vpsgui'` and nothing else moves.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm i -g vpsgui # the CLI
13
+ npm install vpsgui # the library
14
+ ```
15
+
16
+ Requires Node.js 18+ (uses the built-in `fetch`).
17
+
18
+ ## The CLI
19
+
20
+ ```bash
21
+ vpsgui login vps.example.com
22
+ ```
23
+
24
+ `login` asks for the agent token with echo off, checks it against the agent, and only then writes
25
+ `~/.vpsgui/config.json` with mode `0600`. Nothing is saved if the credentials do not work.
26
+
27
+ | Command | What it does |
28
+ | --- | --- |
29
+ | `vpsgui login [url]` | Save credentials for a host, after checking they work |
30
+ | `vpsgui whoami` | Show the active profile and confirm the agent still accepts it |
31
+ | `vpsgui logout` | Forget this machine's copy of the token |
32
+ | `vpsgui status` | CPU, memory, disk, and any failing checks |
33
+ | `vpsgui health` | Every health check. Exits non-zero on a red one |
34
+ | `vpsgui ps` | Docker containers |
35
+ | `vpsgui ls [path]` | List a directory on the host |
36
+ | `vpsgui exec <command>` | Run a shell command. Exits non-zero when the command does |
37
+ | `vpsgui profiles` | List saved hosts |
38
+ | `vpsgui use <profile>` | Switch the default host |
39
+
40
+ Several hosts are several profiles; `--profile` works on every command.
41
+
42
+ ```bash
43
+ vpsgui login vps-2.example.com --profile staging
44
+ vpsgui exec --profile staging 'systemctl restart nginx'
45
+ ```
46
+
47
+ In CI, set `VPSGUI_API_URL` and `VPSGUI_AGENT_TOKEN` instead of logging in - they take precedence
48
+ over any saved profile, so nothing touches the disk.
49
+
50
+ The Python package `vpsgui` installs a CLI by the same name that reads the same config file, so it
51
+ does not matter which one wins on your `PATH`.
52
+
53
+ ## The agent token is a root password
54
+
55
+ Every endpoint except `health()` requires the agent token, and that token grants **root-equivalent
56
+ control of the host**: shell execution, package installs, and filesystem read/write. Read it from
57
+ the environment, never commit it, and only talk to the agent over HTTPS - it travels in the
58
+ `Authorization` header.
59
+
60
+ ## The library
61
+
62
+ ```ts
63
+ import { VpsguiClient } from 'vpsgui';
64
+
65
+ const client = new VpsguiClient({
66
+ baseUrl: 'https://vps.example.com/api/v1',
67
+ token: process.env.VPSGUI_AGENT_TOKEN,
68
+ });
69
+
70
+ const telemetry = await client.system.telemetry();
71
+ console.log(`CPU ${telemetry.cpuPercent}% across ${telemetry.cpuCores} cores`);
72
+
73
+ for (const c of await client.docker.listContainers()) {
74
+ console.log(c.name, c.state, c.image);
75
+ }
76
+ ```
77
+
78
+ ## API
79
+
80
+ | Resource | Methods |
81
+ | :--- | :--- |
82
+ | `client.nodes` | `get()`, `list()`, `topology()`, `health()` |
83
+ | `client.system` | `telemetry()`, `processes()`, `services()`, `serviceAction(name, action)`, `packages()`, `installPackage(name)`, `users()` |
84
+ | `client.docker` | `listContainers()`, `listImages()`, `containerAction(id, action)`, `removeImage(id, force?)` |
85
+ | `client.files` | `list(path)`, `read(path)`, `write(path, content)`, `mkdir(path)`, `delete(path, recursive?)`, `rename(from, to)` |
86
+ | `client.security` | `firewallRules()`, `applyFirewallRule(input)`, `sshKeys()`, `auditLogs()`, `listSecrets()`, `saveSecret(input)`, `deleteSecret(name)`, `revealSecret(name)` |
87
+ | `client.network` | `interfaces()`, `ipInfo(ip?)` |
88
+ | `client.storage` | `partitions()` |
89
+ | `client.backups` | `list()`, `create(sourcePath, label?)`, `delete(name)`, `restore(name, destination)` |
90
+ | `client.deployments` | `list()`, `pull(path)` |
91
+ | `client.catalog` | `list()` |
92
+ | `client.automation` | `workflows()` |
93
+ | `client.queue` | `jobs()` |
94
+ | `client.databases` | `list()` |
95
+ | `client.proxy` | `rules()` |
96
+ | `client.terminal` | `exec(command)` |
97
+ | top level | `health()`, `info()` |
98
+
99
+ ## Errors
100
+
101
+ ```ts
102
+ import { VpsguiClient, VpsguiError } from 'vpsgui-sdk';
103
+
104
+ try {
105
+ await client.system.telemetry();
106
+ } catch (error) {
107
+ if (error instanceof VpsguiError) {
108
+ // status is 0 for transport failures (timeout, DNS, connection refused).
109
+ console.error(error.status, error.endpoint, error.message);
110
+ if (error.isAuthError) console.error('Bad token, or locked out after repeated failures.');
111
+ }
112
+ }
113
+ ```
114
+
115
+ ## Nulls are deliberate
116
+
117
+ Fields the agent cannot determine are `null` rather than guessed. Check before formatting:
118
+
119
+ - `smartHealth` - needs `smartctl` and raw device access
120
+ - `cpuPercent` on a process - Windows `tasklist` reports none
121
+ - `city` / `region` from `ipInfo()` - only when the provider reports nothing (e.g. a bogon address)
122
+ - `size` / `tables` / `keys` on a database - would need per-engine credentials
123
+ - `downloadsCount` / `rating` on a catalog item - the agent queries no registry
124
+
125
+ `read()` also returns `truncated: true` and `editable: false` for a file that exceeded the read cap.
126
+ **Do not write that content back** - it would truncate the file on disk.
127
+
128
+ ## License
129
+
130
+ MIT © [NotGamerPratham](https://notgamerpratham.com)
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}