aicomputer
v0.2.1
Published
High-level TypeScript SDK for AgentComputer computers and execution workflows.
Readme
aicomputer
TypeScript SDK for Agent Computer.
Install
pnpm add aicomputerAuthenticate
import { AgentComputer } from "aicomputer";
const client = new AgentComputer({
apiKey: process.env.AGENTCOMPUTER_API_KEY!,
});Quickstart
import { AgentComputer } from "aicomputer";
const client = new AgentComputer({
apiKey: process.env.AGENTCOMPUTER_API_KEY!,
});
const computer = await client.computers.create({
displayName: "Quickstart computer",
});
await computer.ensureRunning();
const result = await computer.commands.run(["node", "--version"]);
console.log(result.stdout.trim());
await computer.ensureStopped();Run a command
const result = await computer.commands.run(["python3", "-c", "print('hello')"]);
console.log(result.exitCode, result.stdout);For long-lived commands, use the typed command handle:
const server = await computer.commands.start(
["python3", "-m", "http.server", "3000"],
{
onStdout: (chunk) => process.stdout.write(chunk),
onStderr: (chunk) => process.stderr.write(chunk),
},
);
await server.wait({ rejectOnNonZero: false });Publish a port
await computer.waitForPort(3000);
const published = await computer.ports.publish({ port: 3000, name: "app" });
console.log(published.public_url);PTY sessions
const shell = await computer.pty.create({
cols: 120,
rows: 32,
onData: (chunk) => process.stdout.write(chunk),
});
await shell.sendInput("uname -a\n");
await shell.resize(140, 40);
await shell.kill();Docs
- Web docs:
https://agentcomputer.ai/docs/typescript-sdk - Generated API reference is published from the package source into the docs site.
