@tpmjs/tools-sprites-exec
Execute a command inside a sprite and return the output. Supports stdin input for interactive commands. Returns exit code, stdout, stderr, and execution duration. IMPORTANT: If starting a web server, it must listen on port 8080 - this is the Sprites convention for public URLs (use sprites-url-set to make it publicly accessible).
Test @tpmjs/tools-sprites-exec (spritesExecTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-sprites-execpnpm add @tpmjs/tools-sprites-execyarn add @tpmjs/tools-sprites-execbun add @tpmjs/tools-sprites-execdeno add npm:@tpmjs/tools-sprites-execimport { spritesExecTool } from '@tpmjs/tools-sprites-exec';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { spritesExecTool } from '@tpmjs/tools-sprites-exec';
const result = await generateText({
model: openai('gpt-4o'),
tools: { spritesExecTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
namestringName of the sprite to execute command in
cmdstringCommand to execute (e.g., 'ls -la', 'python script.py')
stdinstringOptional stdin input to pass to the command
timeoutMsnumberExecution timeout in milliseconds (default: 60000)
Schema extracted: 1/16/2026, 3:45:29 AM
Execute a command inside a sprite and return the output.
npm install @tpmjs/sprites-exec
SPRITES_TOKEN environment variable - Get your token from https://sprites.devimport { spritesExecTool } from '@tpmjs/sprites-exec'; // Run a simple command const result = await spritesExecTool.execute({ name: 'my-sandbox', cmd: 'ls -la /home' }); console.log(result); // { // exitCode: 0, // stdout: 'total 4\ndrwxr-xr-x 2 root root 4096 Jan 15 10:30 .\n...', // stderr: '', // duration: 45 // } // Run with stdin input const pythonResult = await spritesExecTool.execute({ name: 'my-sandbox', cmd: 'python3', stdin: 'print("Hello from stdin!")' }); // For shell features (pipes, redirects, etc), use bash -c const shellResult = await spritesExecTool.execute({ name: 'my-sandbox', cmd: 'bash -c "echo hello > /tmp/test.txt && cat /tmp/test.txt"' });
Commands are executed directly (like exec.Command in Go), not through a shell. This means shell operators like |, >, >>, && won't work directly.
For shell features, wrap your command with bash -c:
// Won't work: cmd: 'echo hello > file.txt' // Use instead: cmd: 'bash -c "echo hello > file.txt"'
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name of the sprite to execute command in |
cmd | string | Yes | Command to execute (e.g., 'ls -la', 'python script.py') |
stdin | string | No | Optional stdin input to pass to the command |
timeoutMs | number | No | Execution timeout in milliseconds (default: 60000) |
| Field | Type | Description |
|---|---|---|
exitCode | number | Command exit code (0 = success) |
stdout | string | Standard output from the command |
stderr | string | Standard error from the command |
duration | number | Execution duration in milliseconds |
The tool throws errors in these cases:
SPRITES_TOKEN environment variable is not setMIT
Downloads/month
548
GitHub Stars
0
Quality Score