Custom Executors
Deploy your own executor to run TPMJS tools on your infrastructure with full control over environment, secrets, and data.
What is an Executor?
An executor is a service that runs TPMJS tools. When you use a collection or agent, TPMJS sends tool execution requests to an executor, which dynamically loads the npm package and calls the tool's execute() function.
By default, TPMJS uses a shared executor. Deploying your own gives you complete control over the execution environment.
Why Deploy Your Own Executor?
Privacy
Keep tool execution data on your own servers. No data passes through TPMJS.
Custom Environment
Inject your own API keys, database connections, and secrets into tool execution.
Full Control
Choose your infrastructure, scale resources, and customize the execution environment.
No Timeouts
Run long-running tools without hitting shared executor time limits.
Choose Your Platform
We provide deployment templates for multiple platforms. Choose the one that fits your needs:
Railway
Always-on with auto-scaling and a $5/month free tier. One-click deploy.
Unsandbox
Always-on container execution with automatic HTTPS. Deploy with one CLI command.
Vercel
Serverless execution with VM-level isolation using Vercel Sandbox.
Agent Sandbox
Stateful sessions with persistent filesystem across tool calls within a conversation.
You can also build your own executor on any platform that runs Node.js. Just implement the API specification below.
Platform Comparison
| Feature | Railway | Unsandbox | Vercel |
|---|---|---|---|
| Deploy method | One-click / CLI | CLI command | One-click button |
| Isolation | Container-level | Container-level | VM-level (Sandbox) |
| Cold starts | None (always-on) | None (always-on) | Yes (serverless) |
| Max runtime | Unlimited | Unlimited | 45min (Hobby) / 5hr (Pro) |
| Free tier | $5/month credit | None | Limited |
| Pricing | Per usage | Per uptime | Per compute time |
| Auto-scaling | Yes | Manual | Yes |
| Custom domains | Yes | Yes | Yes |
| Docker support | Yes | Yes | No |
Need stateful execution? The Agent Sandbox provides persistent filesystem across tool calls within a conversation. It can be deployed on any of the platforms above or used with the TPMJS default sandbox.
Connecting to Your Executor
Once deployed, configure your collections or agents to use your executor:
- Go to your collection or agent settings
- In "Executor Configuration", select "Custom Executor"
- Enter your executor URL (e.g.,
https://my-executor.on.unsandbox.com) - Add your API key if authentication is enabled
- Click "Verify Connection" to test
Security: Always set EXECUTOR_API_KEY to require authentication. Without it, anyone can execute tools on your executor.
Executor API Specification
All executors must implement these endpoints. Use this spec if building a custom executor.
POST /execute-tool
Execute a TPMJS tool. The executor should install the npm package, find the named export, and call its execute(params) function.
Request Body:
// POST /execute-tool
{
"packageName": "@tpmjs/hello",
"name": "helloWorld",
"version": "latest",
"params": { "name": "World" },
"env": { "MY_API_KEY": "..." }
}Response:
// Response
{
"success": true,
"output": "Hello, World!",
"executionTimeMs": 123
}GET /health
Health check endpoint. TPMJS uses this to verify the executor is reachable and working.
Response:
// GET /health
{
"status": "ok",
"version": "1.0.0"
}Note: Both /api/health and /health paths should work (same for /execute-tool). Our templates support both.
Executor Cascade
When a tool is executed, TPMJS resolves which executor to use in this order:
- • If an agent has an executor configured, all tools in that agent use it
- • If the agent has no executor but a collection does, tools from that collection use the collection's executor
- • If neither has an executor configured, the TPMJS default executor is used
FAQ
Which platform should I choose?
Railway is our official recommendation. It offers one-click deployment, no cold starts, auto-scaling, and a generous $5/month free tier. Use Unsandbox if you prefer CLI deployment, or Vercel if you're already on Vercel and prefer pay-per-use serverless pricing.
Can I use other platforms?
Yes! Any platform that runs Node.js and exposes HTTP endpoints works. AWS Lambda, Google Cloud Run, Render, Fly.io—just implement the API specification above.
How do tools get loaded?
The executor runs npm install for the requested package, then dynamically imports it and calls the tool's execute() function. Each execution uses a fresh temporary directory.
Are environment variables secure?
Yes. Environment variables are stored encrypted by the platform (Vercel/Unsandbox) and only available during execution. You can also pass per-request environment variables in the env field of the execute-tool request.
Need Help?
If you run into issues deploying or configuring your executor, we're here to help.