the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1import consola from "consola";
2import chalk from "chalk";
3import fs from "fs/promises";
4import path from "path";
5import os from "os";
6import { env } from "process";
7
8async function getAccessToken(): Promise<string> {
9 const tokenPath = path.join(os.homedir(), ".pocketenv", "token.json");
10 try {
11 await fs.access(tokenPath);
12 } catch (err) {
13 if (!env.POCKETENV_TOKEN) {
14 consola.error(
15 `You are not logged in. Please run ${chalk.greenBright(
16 "`pocketenv login <username>.bsky.social`",
17 )} first.`,
18 );
19 process.exit(1);
20 }
21 }
22
23 const tokenData = await fs.readFile(tokenPath, "utf-8");
24 const { token } = JSON.parse(tokenData);
25 if (!token) {
26 consola.error(
27 `You are not logged in. Please run ${chalk.greenBright(
28 "`rocksky login <username>.bsky.social`",
29 )} first.`,
30 );
31 process.exit(1);
32 }
33 return token;
34}
35
36export default getAccessToken;