Documentation Index
Fetch the complete documentation index at: https://docs.stacyide.xyz/llms.txt
Use this file to discover all available pages before exploring further.
The TypeScript SDK works in Node.js 18+ and exposes the same sandbox lifecycle as the REST API.
Prerequisites
- Node.js 18+.
- A running StacyVM server.
- An API key when auth is enabled.
Install
Connect
import { Client } from "stacyvm";
const client = new Client({
baseUrl: process.env.STACYVM_URL ?? "http://localhost:7423",
apiKey: process.env.STACYVM_API_KEY,
userId: "user_123",
timeout: 60_000,
});
StacyVM server URL. Defaults to http://localhost:7423.
API key sent as X-API-Key when server auth is enabled.
Tenant or owner identity sent as X-User-ID for quota and audit attribution.
Per-request HTTP timeout in milliseconds.
Run A Task
import { Client } from "stacyvm";
const client = new Client({
baseUrl: "http://localhost:7423",
apiKey: "sk_test_YOUR_API_KEY",
});
await client.withSandbox({ image: "node:20", ttl: "10m" }, async (sandbox) => {
await sandbox.writeFile("/app/main.js", "console.log(40 + 2);\n");
const result = await sandbox.exec("node /app/main.js", { timeout: "10s" });
if (result.exit_code !== 0) {
throw new Error(result.stderr);
}
console.log(result.stdout);
});
Process exit code returned by the runtime provider.
Captured standard output.
Provider-reported execution duration.
Stream Output
for await (const chunk of sandbox.execStream("npm test")) {
if (chunk.stream === "stdout") {
process.stdout.write(chunk.data);
} else {
process.stderr.write(chunk.data);
}
}
Handle Errors
import { Client, ForgevmError } from "stacyvm";
const client = new Client("http://localhost:7423");
try {
await client.withSandbox({ image: "node:20", ttl: "10m" }, async (sandbox) => {
await sandbox.exec("node /missing.js", { timeout: "10s" });
});
} catch (error) {
if (error instanceof ForgevmError) {
console.error(error.message);
} else {
throw error;
}
}