@pocketenv/cli 0.2.1 → 0.2.3
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/dist/index.js +97 -73
- package/package.json +2 -1
- package/src/cmd/env.ts +11 -7
- package/src/cmd/secret.ts +13 -9
- package/src/cmd/sshkeys.ts +22 -18
- package/src/cmd/start.ts +16 -12
- package/src/cmd/stop.ts +13 -9
- package/src/index.ts +22 -17
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
|
22
22
|
import { password, editor, input } from '@inquirer/prompts';
|
|
23
23
|
import sodium from 'libsodium-wrappers';
|
|
24
24
|
|
|
25
|
-
var version = "0.2.
|
|
25
|
+
var version = "0.2.2";
|
|
26
26
|
|
|
27
27
|
async function getAccessToken() {
|
|
28
28
|
const tokenPath = path.join(os.homedir(), ".pocketenv", "token.json");
|
|
@@ -67,18 +67,22 @@ const client = axios.create({
|
|
|
67
67
|
|
|
68
68
|
async function start(name) {
|
|
69
69
|
const token = await getAccessToken();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
try {
|
|
71
|
+
await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", void 0, {
|
|
72
|
+
params: {
|
|
73
|
+
id: name
|
|
74
|
+
},
|
|
75
|
+
headers: {
|
|
76
|
+
Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
consola.success(`Sandbox ${chalk.greenBright(name)} started`);
|
|
80
|
+
consola.log(
|
|
81
|
+
`Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`
|
|
82
|
+
);
|
|
83
|
+
} catch {
|
|
84
|
+
consola.error("Failed to start sandbox");
|
|
85
|
+
}
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
async function login(handle) {
|
|
@@ -528,15 +532,19 @@ async function listSandboxes() {
|
|
|
528
532
|
|
|
529
533
|
async function stop(name) {
|
|
530
534
|
const token = await getAccessToken();
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
535
|
+
try {
|
|
536
|
+
await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", void 0, {
|
|
537
|
+
params: {
|
|
538
|
+
id: name
|
|
539
|
+
},
|
|
540
|
+
headers: {
|
|
541
|
+
Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
|
|
545
|
+
} catch {
|
|
546
|
+
consola.error("Failed to stop sandbox");
|
|
547
|
+
}
|
|
540
548
|
}
|
|
541
549
|
|
|
542
550
|
async function createSandbox(name, {
|
|
@@ -708,15 +716,19 @@ async function putSecret(sandbox, key) {
|
|
|
708
716
|
}
|
|
709
717
|
async function deleteSecret(id) {
|
|
710
718
|
const token = await getAccessToken();
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
719
|
+
try {
|
|
720
|
+
await client.post("/xrpc/io.pocketenv.secret.deleteSecret", void 0, {
|
|
721
|
+
params: {
|
|
722
|
+
id
|
|
723
|
+
},
|
|
724
|
+
headers: {
|
|
725
|
+
Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
consola.success("Secret deleted successfully");
|
|
729
|
+
} catch {
|
|
730
|
+
consola.error("Failed to delete secret");
|
|
731
|
+
}
|
|
720
732
|
}
|
|
721
733
|
|
|
722
734
|
async function listEnvs(sandbox) {
|
|
@@ -816,13 +828,17 @@ async function putEnv(sandbox, key, value) {
|
|
|
816
828
|
}
|
|
817
829
|
async function deleteEnv(id) {
|
|
818
830
|
const token = await getAccessToken();
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
831
|
+
try {
|
|
832
|
+
await client.post("/xrpc/io.pocketenv.variable.deleteVariable", void 0, {
|
|
833
|
+
params: { id },
|
|
834
|
+
headers: {
|
|
835
|
+
Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
consola.success("Variable deleted successfully");
|
|
839
|
+
} catch {
|
|
840
|
+
consola.error("Failed to delete variable");
|
|
841
|
+
}
|
|
826
842
|
}
|
|
827
843
|
|
|
828
844
|
function u32(n) {
|
|
@@ -1029,25 +1045,29 @@ async function putKeys(sandbox, options) {
|
|
|
1029
1045
|
})() : body;
|
|
1030
1046
|
return `${header}${maskedBody}${footer}`.replace(/\n/g, "\\n");
|
|
1031
1047
|
})();
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1048
|
+
try {
|
|
1049
|
+
await client.post(
|
|
1050
|
+
"/xrpc/io.pocketenv.sandbox.putSshKeys",
|
|
1051
|
+
{
|
|
1052
|
+
id: data.sandbox.id,
|
|
1053
|
+
privateKey: encryptedPrivateKey,
|
|
1054
|
+
publicKey,
|
|
1055
|
+
redacted
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
headers: {
|
|
1059
|
+
Authorization: `Bearer ${env$1.POCKETENV_TOKEN || token}`
|
|
1060
|
+
}
|
|
1043
1061
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1062
|
+
);
|
|
1063
|
+
consola.log("\nPrivate Key:");
|
|
1064
|
+
consola.log(redacted.replace(/\\n/g, "\n"));
|
|
1065
|
+
consola.log("\nPublic Key:");
|
|
1066
|
+
consola.log(publicKey, "\n");
|
|
1067
|
+
consola.success("SSH keys saved successfully!");
|
|
1068
|
+
} catch {
|
|
1069
|
+
consola.error("Failed to save SSH keys");
|
|
1070
|
+
}
|
|
1051
1071
|
}
|
|
1052
1072
|
|
|
1053
1073
|
async function putAuthKey(sandbox) {
|
|
@@ -1129,31 +1149,35 @@ async function getTailscaleAuthKey(sandbox) {
|
|
|
1129
1149
|
}
|
|
1130
1150
|
}
|
|
1131
1151
|
|
|
1152
|
+
const c = {
|
|
1153
|
+
primary: (s) => chalk.rgb(0, 232, 198)(s),
|
|
1154
|
+
secondary: (s) => chalk.rgb(0, 198, 232)(s),
|
|
1155
|
+
accent: (s) => chalk.rgb(130, 100, 255)(s),
|
|
1156
|
+
highlight: (s) => chalk.rgb(100, 232, 130)(s),
|
|
1157
|
+
muted: (s) => chalk.rgb(200, 210, 220)(s),
|
|
1158
|
+
link: (s) => chalk.rgb(255, 160, 100)(s),
|
|
1159
|
+
sky: (s) => chalk.rgb(0, 210, 255)(s)
|
|
1160
|
+
};
|
|
1132
1161
|
const program = new Command();
|
|
1133
1162
|
program.name("pocketenv").description(
|
|
1134
|
-
`
|
|
1135
|
-
___ __ __
|
|
1136
|
-
/ _ \\___ ____/ /_____ / /____ ___ _ __
|
|
1137
|
-
/ ___/ _ \\/ __/ '_/ -_) __/ -_) _ \\ |/ /
|
|
1138
|
-
/_/ \\___/\\__/_/\\_\\__/\\__/\\__/_/ /_/___/
|
|
1139
|
-
|
|
1140
|
-
Open, interoperable sandbox platform for agents and humans \u{1F4E6} \u2728
|
|
1141
|
-
`
|
|
1163
|
+
`${chalk.bold.rgb(0, 232, 198)(`pocketenv v${version}`)} ${c.muted("\u2500")} ${c.muted("Open, interoperable sandbox platform for agents and humans")}`
|
|
1142
1164
|
).version(version);
|
|
1143
1165
|
program.configureHelp({
|
|
1144
|
-
styleTitle: (str) => chalk.bold.
|
|
1145
|
-
styleCommandText: (str) =>
|
|
1146
|
-
styleDescriptionText: (str) =>
|
|
1147
|
-
styleOptionText: (str) =>
|
|
1148
|
-
styleArgumentText: (str) =>
|
|
1149
|
-
styleSubcommandText: (str) =>
|
|
1166
|
+
styleTitle: (str) => chalk.bold.rgb(0, 210, 255)(str),
|
|
1167
|
+
styleCommandText: (str) => c.secondary(str),
|
|
1168
|
+
styleDescriptionText: (str) => c.muted(str),
|
|
1169
|
+
styleOptionText: (str) => c.highlight(str),
|
|
1170
|
+
styleArgumentText: (str) => c.accent(str),
|
|
1171
|
+
styleSubcommandText: (str) => c.secondary(str)
|
|
1150
1172
|
});
|
|
1151
1173
|
program.addHelpText(
|
|
1152
1174
|
"after",
|
|
1153
1175
|
`
|
|
1154
|
-
${chalk.bold(
|
|
1155
|
-
${chalk.bold(
|
|
1156
|
-
${chalk.bold("
|
|
1176
|
+
${chalk.bold.rgb(0, 210, 255)("\u2500".repeat(90))}
|
|
1177
|
+
${chalk.bold.rgb(0, 232, 198)("Learn more:")} ${c.link("https://docs.pocketenv.io")}
|
|
1178
|
+
${chalk.bold.rgb(0, 232, 198)("Discord:")} ${c.link("https://discord.gg/9ada4pFUFS")}
|
|
1179
|
+
${chalk.bold.rgb(0, 232, 198)("Report bugs:")} ${c.link("https://github.com/pocketenv-io/pocketenv/issues")}
|
|
1180
|
+
${chalk.bold.rgb(0, 210, 255)("\u2500".repeat(90))}
|
|
1157
1181
|
`
|
|
1158
1182
|
);
|
|
1159
1183
|
program.command("login").argument("<handle>", "your AT Proto handle (e.g., <username>.bsky.social)").description("login with your AT Proto account and get a session token").action(login);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"bin": {
|
|
5
5
|
"pocketenv": "dist/index.js"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.3",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"sandbox",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"openclaw",
|
|
16
16
|
"microvm"
|
|
17
17
|
],
|
|
18
|
+
"description": "Open, interoperable sandbox platform for agents and humans 📦 ✨",
|
|
18
19
|
"author": "Tsiry Sandratraina <tsiry.sndr@pocketenv.io>",
|
|
19
20
|
"license": "MPL-2.0",
|
|
20
21
|
"repository": {
|
package/src/cmd/env.ts
CHANGED
|
@@ -115,12 +115,16 @@ export async function putEnv(sandbox: string, key: string, value: string) {
|
|
|
115
115
|
export async function deleteEnv(id: string) {
|
|
116
116
|
const token = await getAccessToken();
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
try {
|
|
119
|
+
await client.post("/xrpc/io.pocketenv.variable.deleteVariable", undefined, {
|
|
120
|
+
params: { id },
|
|
121
|
+
headers: {
|
|
122
|
+
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
consola.success("Variable deleted successfully");
|
|
127
|
+
} catch {
|
|
128
|
+
consola.error("Failed to delete variable");
|
|
129
|
+
}
|
|
126
130
|
}
|
package/src/cmd/secret.ts
CHANGED
|
@@ -114,14 +114,18 @@ export async function putSecret(sandbox: string, key: string) {
|
|
|
114
114
|
export async function deleteSecret(id: string) {
|
|
115
115
|
const token = await getAccessToken();
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
try {
|
|
118
|
+
await client.post("/xrpc/io.pocketenv.secret.deleteSecret", undefined, {
|
|
119
|
+
params: {
|
|
120
|
+
id,
|
|
121
|
+
},
|
|
122
|
+
headers: {
|
|
123
|
+
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
consola.success("Secret deleted successfully");
|
|
128
|
+
} catch {
|
|
129
|
+
consola.error("Failed to delete secret");
|
|
130
|
+
}
|
|
127
131
|
}
|
package/src/cmd/sshkeys.ts
CHANGED
|
@@ -152,25 +152,29 @@ export async function putKeys(
|
|
|
152
152
|
return `${header}${maskedBody}${footer}`.replace(/\n/g, "\\n");
|
|
153
153
|
})();
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
headers: {
|
|
165
|
-
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
155
|
+
try {
|
|
156
|
+
await client.post(
|
|
157
|
+
"/xrpc/io.pocketenv.sandbox.putSshKeys",
|
|
158
|
+
{
|
|
159
|
+
id: data.sandbox.id,
|
|
160
|
+
privateKey: encryptedPrivateKey,
|
|
161
|
+
publicKey,
|
|
162
|
+
redacted,
|
|
166
163
|
},
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
{
|
|
165
|
+
headers: {
|
|
166
|
+
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
);
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
consola.log("\nPrivate Key:");
|
|
172
|
+
consola.log(redacted.replace(/\\n/g, "\n"));
|
|
173
|
+
consola.log("\nPublic Key:");
|
|
174
|
+
consola.log(publicKey, "\n");
|
|
174
175
|
|
|
175
|
-
|
|
176
|
+
consola.success("SSH keys saved successfully!");
|
|
177
|
+
} catch {
|
|
178
|
+
consola.error("Failed to save SSH keys");
|
|
179
|
+
}
|
|
176
180
|
}
|
package/src/cmd/start.ts
CHANGED
|
@@ -7,19 +7,23 @@ import { env } from "../lib/env";
|
|
|
7
7
|
async function start(name: string) {
|
|
8
8
|
const token = await getAccessToken();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
try {
|
|
11
|
+
await client.post("/xrpc/io.pocketenv.sandbox.startSandbox", undefined, {
|
|
12
|
+
params: {
|
|
13
|
+
id: name,
|
|
14
|
+
},
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
consola.success(`Sandbox ${chalk.greenBright(name)} started`);
|
|
21
|
+
consola.log(
|
|
22
|
+
`Run ${chalk.greenBright(`pocketenv console ${name}`)} to access the sandbox`,
|
|
23
|
+
);
|
|
24
|
+
} catch {
|
|
25
|
+
consola.error("Failed to start sandbox");
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export default start;
|
package/src/cmd/stop.ts
CHANGED
|
@@ -7,16 +7,20 @@ import { env } from "../lib/env";
|
|
|
7
7
|
async function stop(name: string) {
|
|
8
8
|
const token = await getAccessToken();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
try {
|
|
11
|
+
await client.post("/xrpc/io.pocketenv.sandbox.stopSandbox", undefined, {
|
|
12
|
+
params: {
|
|
13
|
+
id: name,
|
|
14
|
+
},
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${env.POCKETENV_TOKEN || token}`,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
consola.success(`Sandbox ${chalk.greenBright(name)} stopped`);
|
|
21
|
+
} catch {
|
|
22
|
+
consola.error("Failed to stop sandbox");
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export default stop;
|
package/src/index.ts
CHANGED
|
@@ -15,37 +15,42 @@ import { deleteEnv, listEnvs, putEnv } from "./cmd/env";
|
|
|
15
15
|
import { getSshKey, putKeys } from "./cmd/sshkeys";
|
|
16
16
|
import { getTailscaleAuthKey, putAuthKey } from "./cmd/tailscale";
|
|
17
17
|
|
|
18
|
+
const c = {
|
|
19
|
+
primary: (s: string) => chalk.rgb(0, 232, 198)(s),
|
|
20
|
+
secondary: (s: string) => chalk.rgb(0, 198, 232)(s),
|
|
21
|
+
accent: (s: string) => chalk.rgb(130, 100, 255)(s),
|
|
22
|
+
highlight: (s: string) => chalk.rgb(100, 232, 130)(s),
|
|
23
|
+
muted: (s: string) => chalk.rgb(200, 210, 220)(s),
|
|
24
|
+
link: (s: string) => chalk.rgb(255, 160, 100)(s),
|
|
25
|
+
sky: (s: string) => chalk.rgb(0, 210, 255)(s),
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
const program = new Command();
|
|
19
29
|
|
|
20
30
|
program
|
|
21
31
|
.name("pocketenv")
|
|
22
32
|
.description(
|
|
23
|
-
`
|
|
24
|
-
___ __ __
|
|
25
|
-
/ _ \\___ ____/ /_____ / /____ ___ _ __
|
|
26
|
-
/ ___/ _ \\/ __/ '_/ -_) __/ -_) _ \\ |/ /
|
|
27
|
-
/_/ \\___/\\__/_/\\_\\__/\\__/\\__/_/ /_/___/
|
|
28
|
-
|
|
29
|
-
Open, interoperable sandbox platform for agents and humans 📦 ✨
|
|
30
|
-
`,
|
|
33
|
+
`${chalk.bold.rgb(0, 232, 198)(`pocketenv v${version}`)} ${c.muted("─")} ${c.muted("Open, interoperable sandbox platform for agents and humans")}`,
|
|
31
34
|
)
|
|
32
35
|
.version(version);
|
|
33
36
|
|
|
34
37
|
program.configureHelp({
|
|
35
|
-
styleTitle: (str) => chalk.bold.
|
|
36
|
-
styleCommandText: (str) =>
|
|
37
|
-
styleDescriptionText: (str) =>
|
|
38
|
-
styleOptionText: (str) =>
|
|
39
|
-
styleArgumentText: (str) =>
|
|
40
|
-
styleSubcommandText: (str) =>
|
|
38
|
+
styleTitle: (str) => chalk.bold.rgb(0, 210, 255)(str),
|
|
39
|
+
styleCommandText: (str) => c.secondary(str),
|
|
40
|
+
styleDescriptionText: (str) => c.muted(str),
|
|
41
|
+
styleOptionText: (str) => c.highlight(str),
|
|
42
|
+
styleArgumentText: (str) => c.accent(str),
|
|
43
|
+
styleSubcommandText: (str) => c.secondary(str),
|
|
41
44
|
});
|
|
42
45
|
|
|
43
46
|
program.addHelpText(
|
|
44
47
|
"after",
|
|
45
48
|
`
|
|
46
|
-
${chalk.bold(
|
|
47
|
-
${chalk.bold(
|
|
48
|
-
${chalk.bold("
|
|
49
|
+
${chalk.bold.rgb(0, 210, 255)("─".repeat(90))}
|
|
50
|
+
${chalk.bold.rgb(0, 232, 198)("Learn more:")} ${c.link("https://docs.pocketenv.io")}
|
|
51
|
+
${chalk.bold.rgb(0, 232, 198)("Discord:")} ${c.link("https://discord.gg/9ada4pFUFS")}
|
|
52
|
+
${chalk.bold.rgb(0, 232, 198)("Report bugs:")} ${c.link("https://github.com/pocketenv-io/pocketenv/issues")}
|
|
53
|
+
${chalk.bold.rgb(0, 210, 255)("─".repeat(90))}
|
|
49
54
|
`,
|
|
50
55
|
);
|
|
51
56
|
|