@pocketenv/cli 0.2.0 → 0.2.2
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 +43 -28
- package/package.json +1 -1
- package/src/cmd/create.ts +12 -2
- 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 +4 -0
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) {
|
|
@@ -161,7 +165,7 @@ async function ssh$2(sandbox) {
|
|
|
161
165
|
let cols = process.stdout.columns ?? 220;
|
|
162
166
|
let rows = process.stdout.rows ?? 50;
|
|
163
167
|
consola.info(
|
|
164
|
-
`Connecting to ${chalk.cyanBright(sandbox.name)} via Cloudflare
|
|
168
|
+
`Connecting to ${chalk.cyanBright(sandbox.name)} via Cloudflare Sandbox\u2026`
|
|
165
169
|
);
|
|
166
170
|
const ws = new WebSocket(wsUrl.toString(), {
|
|
167
171
|
headers: { "User-Agent": "pocketenv-cli" }
|
|
@@ -528,18 +532,26 @@ 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
|
-
async function createSandbox(name, {
|
|
550
|
+
async function createSandbox(name, {
|
|
551
|
+
provider,
|
|
552
|
+
ssh: ssh$1,
|
|
553
|
+
base
|
|
554
|
+
}) {
|
|
543
555
|
const token = await getAccessToken();
|
|
544
556
|
if (["deno", "vercel", "daytona"].includes(provider || "")) {
|
|
545
557
|
consola.error(
|
|
@@ -552,7 +564,7 @@ async function createSandbox(name, { provider, ssh: ssh$1 }) {
|
|
|
552
564
|
"/xrpc/io.pocketenv.sandbox.createSandbox",
|
|
553
565
|
{
|
|
554
566
|
name,
|
|
555
|
-
base: "at://did:plc:aturpi2ls3yvsmhc6wybomun/io.pocketenv.sandbox/openclaw",
|
|
567
|
+
base: base ?? "at://did:plc:aturpi2ls3yvsmhc6wybomun/io.pocketenv.sandbox/openclaw",
|
|
556
568
|
provider: provider ?? "cloudflare"
|
|
557
569
|
},
|
|
558
570
|
{
|
|
@@ -1158,7 +1170,10 @@ program.command("console").aliases(["shell", "ssh", "s"]).argument("[sandbox]",
|
|
|
1158
1170
|
program.command("ls").description("list sandboxes").action(listSandboxes);
|
|
1159
1171
|
program.command("start").argument("<sandbox>", "the sandbox to start").description("start the given sandbox").action(start);
|
|
1160
1172
|
program.command("stop").argument("<sandbox>", "the sandbox to stop").description("stop the given sandbox").action(stop);
|
|
1161
|
-
program.command("create").aliases(["new"]).option("--provider, -p <provider>", "the provider to use for the sandbox").option(
|
|
1173
|
+
program.command("create").aliases(["new"]).option("--provider, -p <provider>", "the provider to use for the sandbox").option(
|
|
1174
|
+
"--base, -b <base>",
|
|
1175
|
+
"the base sandbox to use for the sandbox, e.g. openclaw, claude-code, codex, copilot ..."
|
|
1176
|
+
).option("--ssh, -s", "connect to the Sandbox and automatically open a shell").argument("[name]", "the name of the sandbox to create").description("create a new sandbox").action(createSandbox);
|
|
1162
1177
|
program.command("logout").description("logout (removes session token)").action(logout);
|
|
1163
1178
|
program.command("rm").aliases(["delete", "remove"]).argument("<sandbox>", "the sandbox to delete").description("delete the given sandbox").action(deleteSandbox);
|
|
1164
1179
|
const secret = program.command("secret").description("manage secrets");
|
|
@@ -1173,8 +1188,8 @@ const sshkeys = program.command("sshkeys").description("manage SSH keys");
|
|
|
1173
1188
|
sshkeys.command("put").argument("<sandbox>", "the sandbox to put the SSH key in").option("--private-key <path>", "the path to the SSH private key").option("--public-key <path>", "the path to the SSH public key").option("--generate, -g", "generate a new SSH key pair").description("put an SSH key in the given sandbox").action(putKeys);
|
|
1174
1189
|
sshkeys.command("get").argument("<sandbox>", "the sandbox to get the SSH key from").description("get an SSH key (public key only) from the given sandbox").action(getSshKey);
|
|
1175
1190
|
const tailscale = program.command("tailscale").description("manage Tailscale");
|
|
1176
|
-
tailscale.command("put").argument("<sandbox>", "the sandbox to put the Tailscale Auth Key in").description("put a Tailscale
|
|
1177
|
-
tailscale.command("get").argument("<sandbox>", "the sandbox to get the Tailscale
|
|
1191
|
+
tailscale.command("put").argument("<sandbox>", "the sandbox to put the Tailscale Auth Key in").description("put a Tailscale Auth Key in the given sandbox").action(putAuthKey);
|
|
1192
|
+
tailscale.command("get").argument("<sandbox>", "the sandbox to get the Tailscale Auth Key from").description("get a Tailscale Auth Key (redacted) from the given sandbox").action(getTailscaleAuthKey);
|
|
1178
1193
|
if (process.argv.length <= 2) {
|
|
1179
1194
|
program.help();
|
|
1180
1195
|
}
|
package/package.json
CHANGED
package/src/cmd/create.ts
CHANGED
|
@@ -7,7 +7,15 @@ import connectToSandbox from "./ssh";
|
|
|
7
7
|
|
|
8
8
|
async function createSandbox(
|
|
9
9
|
name: string,
|
|
10
|
-
{
|
|
10
|
+
{
|
|
11
|
+
provider,
|
|
12
|
+
ssh,
|
|
13
|
+
base,
|
|
14
|
+
}: {
|
|
15
|
+
provider: string | undefined;
|
|
16
|
+
ssh: boolean | undefined;
|
|
17
|
+
base: string | undefined;
|
|
18
|
+
},
|
|
11
19
|
) {
|
|
12
20
|
const token = await getAccessToken();
|
|
13
21
|
|
|
@@ -22,7 +30,9 @@ async function createSandbox(
|
|
|
22
30
|
"/xrpc/io.pocketenv.sandbox.createSandbox",
|
|
23
31
|
{
|
|
24
32
|
name,
|
|
25
|
-
base:
|
|
33
|
+
base:
|
|
34
|
+
base ??
|
|
35
|
+
"at://did:plc:aturpi2ls3yvsmhc6wybomun/io.pocketenv.sandbox/openclaw",
|
|
26
36
|
provider: provider ?? "cloudflare",
|
|
27
37
|
},
|
|
28
38
|
{
|
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
|
@@ -85,6 +85,10 @@ program
|
|
|
85
85
|
.command("create")
|
|
86
86
|
.aliases(["new"])
|
|
87
87
|
.option("--provider, -p <provider>", "the provider to use for the sandbox")
|
|
88
|
+
.option(
|
|
89
|
+
"--base, -b <base>",
|
|
90
|
+
"the base sandbox to use for the sandbox, e.g. openclaw, claude-code, codex, copilot ...",
|
|
91
|
+
)
|
|
88
92
|
.option("--ssh, -s", "connect to the Sandbox and automatically open a shell")
|
|
89
93
|
.argument("[name]", "the name of the sandbox to create")
|
|
90
94
|
.description("create a new sandbox")
|