import { CodeBlock } from '@tpmjs/ui/CodeBlock/CodeBlock'; import { Icon } from '@tpmjs/ui/Icon/Icon'; import type { Metadata } from 'next'; import Link from 'next/link'; import { AppFooter } from '~/components/AppFooter'; import { AppHeader } from '~/components/AppHeader'; export const metadata: Metadata = { title: 'Custom Executors - TPMJS', description: 'Deploy your own executor to run TPMJS tools on your own infrastructure with full control and privacy.', }; const executeToolExample = `// POST /execute-tool { "packageName": "@tpmjs/hello", "name": "helloWorld", "version": "latest", "params": { "name": "World" }, "env": { "MY_API_KEY": "..." } }`; const executeToolResponse = `// Response { "success": true, "output": "Hello, World!", "executionTimeMs": 123 }`; const healthExample = `// GET /health { "status": "ok", "version": "1.0.0" }`; export default function ExecutorsDocsPage(): React.ReactElement { return (
{/* Header */}

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 */}

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.

{/* Benefits Grid */}

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 */}

Choose Your Platform

We provide deployment templates for multiple platforms. Choose the one that fits your needs:

{/* Unsandbox Card */}
un

Unsandbox

Always-on container execution with automatic HTTPS. Deploy with one CLI command.

Recommended No cold starts Unlimited runtime
{/* Vercel Card */}

Vercel

Serverless execution with VM-level isolation using Vercel Sandbox. One-click deploy.

One-click deploy Free tier available

You can also build your own executor on any platform that runs Node.js. Just implement the API specification below.

{/* Comparison Table */}

Platform Comparison

Feature Unsandbox Vercel
Deploy method CLI command One-click button
Isolation Container-level VM-level (Sandbox)
Cold starts None (always-on) Yes (serverless)
Max runtime Unlimited 45min (Hobby) / 5hr (Pro)
Pricing Per uptime Per compute time
Custom domains Yes Yes
Freeze/unfreeze Yes (save costs) N/A (serverless)
{/* Configuration Section */}

Connecting to Your Executor

Once deployed, configure your collections or agents to use your executor:

  1. Go to your collection or agent settings
  2. In "Executor Configuration", select "Custom Executor"
  3. Enter your executor URL (e.g.,{' '} https://my-executor.on.unsandbox.com )
  4. Add your API key if authentication is enabled
  5. Click "Verify Connection" to test

Security: Always set{' '} EXECUTOR_API_KEY to require authentication. Without it, anyone can execute tools on your executor.

{/* API Specification */}

Executor API Specification

All executors must implement these endpoints. Use this spec if building a custom executor.

{/* POST /execute-tool */}

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:

Response:

{/* GET /health */}

GET /health

Health check endpoint. TPMJS uses this to verify the executor is reachable and working.

Response:

Note: Both{' '} /api/health and{' '} /health paths should work (same for /execute-tool). Our templates support both.

{/* Executor Cascade */}

Executor Cascade

When a tool is executed, TPMJS resolves which executor to use in this order:

Agent Config Collection Config System Default
  • • 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 */}

FAQ

Which platform should I choose?

Unsandbox is recommended for most use cases. It has no cold starts, unlimited runtime, and simple CLI deployment. Use Vercel{' '} if you're already on Vercel or prefer one-click deployment and pay-per-use pricing.

Can I use other platforms?

Yes! Any platform that runs Node.js and exposes HTTP endpoints works. AWS Lambda, Google Cloud Run, Railway, 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.

{/* Support */}

Need Help?

If you run into issues deploying or configuring your executor, we're here to help.

); }