open, interoperable sandbox platform for agents and humans 📦 ✨
pocketenv.io
claude-code
atproto
sandbox
openclaw
agent
1import cors from "cors";
2import express from "express";
3import morgan from "morgan";
4import { consola } from "consola";
5import bsky from "bsky";
6import { contextMiddleware, ctx } from "context";
7import { createServer } from "lexicon";
8import chalk from "chalk";
9import API from "./xrpc";
10import ssh from "./ssh";
11import tty from "./tty";
12
13let server = createServer({
14 validateResponse: false,
15 payload: {
16 jsonLimit: 100 * 1024, // 100kb
17 textLimit: 100 * 1024, // 100kb
18 blobLimit: 5 * 1024 * 1024, // 5mb
19 },
20});
21
22server = API(server, ctx);
23
24const app = express();
25
26app.use(contextMiddleware);
27app.use(cors());
28app.use(morgan("dev"));
29
30const banner = `
31 ___ __ __
32 / _ \\___ ____/ /_____ / /____ ___ _ __
33 / ___/ _ \\/ __/ '_/ -_) __/ -_) _ \\ |/ /
34 /_/ \\___/\\__/_/\\_\\__/\\__/\\__/_/ /_/___/
35
36 `;
37
38app.get("/", (req, res) => {
39 const accept = req.headers.accept || "";
40 const wantsHTML = accept.includes("text/html");
41
42 if (wantsHTML) {
43 res.contentType("text/html");
44 res.send(`<pre>${banner}</pre>`);
45 return;
46 }
47 res.contentType("text/plain");
48 res.send(banner);
49});
50
51app.use(bsky);
52app.use(server.xrpc.router);
53app.use("/ssh", ssh);
54app.use("/tty", tty);
55
56app.listen(process.env.POCKETENV_XPRC_PORT || 8789, () => {
57 consola.log(chalk.greenBright(banner));
58 consola.info(
59 `Pocketenv XRPC API is running on port ${process.env.POCKETENV_XPRC_PORT || 8789}`,
60 );
61});