tpmjs/packages/tools/unsandbox
Ajax Davis 48c41e8733 feat: add use cases marketing product with AI-generated content
Transform qualifying scenarios into marketing-ready use cases with:
- AI-generated titles, descriptions, ROI estimates, business value
- Persona/industry/category taxonomy for targeting
- Browseable feed with filtering and ranking
- SEO-optimized case study pages
- Daily cron job for generation and ranking

Database:
- Add Persona, Industry, Category lookup tables
- Add UseCase model with marketing content fields
- Add junction tables for personas/industries/categories
- Add SocialProof model for cached metrics

API:
- GET /api/use-cases - Global directory with filtering
- GET /api/use-cases/[id] - Individual use case details
- GET /api/public/users/[username]/collections/[slug]/use-cases
- POST /api/cron/use-cases - Nightly generation job

Frontend:
- /use-cases - Global feed with persona dropdown
- /use-cases/[slug] - SEO case study page
- /[username]/collections/[slug]/use-cases - Collection feed
- UseCasesFeed component - Sortable table component
- UseCaseCaseStudy component - Full case study layout
2026-01-20 16:17:35 +10:00
..
src feat: add use cases marketing product with AI-generated content 2026-01-20 16:17:35 +10:00
CHANGELOG.md feat: add @tpmjs/unsandbox package for secure code execution 2025-12-16 12:07:46 +10:00
package.json refactor: replace exportName with name throughout codebase 2026-01-14 14:18:36 +10:00
README.md chore: update dependencies and add unsandbox package 2025-12-16 12:00:22 +10:00
tsconfig.json chore: update dependencies and add unsandbox package 2025-12-16 12:00:22 +10:00

@tpmjs/unsandbox

AI SDK tools for secure code execution in 42+ programming languages via unsandbox.com.

Installation

npm install @tpmjs/unsandbox
# or
pnpm add @tpmjs/unsandbox

Setup

Get an API key at unsandbox.com/api-keys and set it as an environment variable:

export UNSANDBOX_API_KEY=your-api-key

Usage

import { streamText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { executeCode, listLanguages } from '@tpmjs/unsandbox';

const result = streamText({
  model: anthropic('claude-sonnet-4-20250514'),
  tools: {
    executeCode,
    listLanguages,
  },
  system: 'You can execute code in 42+ programming languages using a secure sandbox.',
  prompt: 'Write and run a Python script that calculates the first 10 Fibonacci numbers',
});

Tools

executeCode

Execute code synchronously in a secure sandbox.

import { executeCode } from '@tpmjs/unsandbox';

const result = await executeCode.execute({
  language: 'python',
  code: 'print("Hello, World!")',
});
// { stdout: "Hello, World!\n", stderr: "", exit_code: 0 }

Parameters:

Name Type Required Description
language string Yes Programming language (python, javascript, go, rust, etc.)
code string Yes Source code to execute
input_files array No Files to make available in /tmp/input/
network_mode string No 'zerotrust' (default) or 'semitrusted'
ttl number No Timeout in seconds (1-900, default 60)
return_artifact boolean No Return compiled binary for compiled languages
return_wasm_artifact boolean No Compile to WebAssembly (C, C++, Rust, Zig, Go)

executeCodeAsync

Execute code asynchronously, returning a job_id for tracking.

import { executeCodeAsync, getJob } from '@tpmjs/unsandbox';

const job = await executeCodeAsync.execute({
  language: 'rust',
  code: 'fn main() { println!("Hello from Rust!"); }',
});

// Check status later
const result = await getJob.execute({ job_id: job.job_id });

runCode

Execute code with automatic language detection from shebang.

import { runCode } from '@tpmjs/unsandbox';

const result = await runCode.execute({
  code: `#!/usr/bin/env python3
print("Auto-detected Python!")`,
});

runCodeAsync

Async version of runCode.

listJobs

List all active jobs for your API key.

import { listJobs } from '@tpmjs/unsandbox';

const jobs = await listJobs.execute({});

getJob

Get status and results of a specific async job.

import { getJob } from '@tpmjs/unsandbox';

const result = await getJob.execute({ job_id: 'abc123' });
// { status: 'completed', stdout: '...', stderr: '...' }

cancelJob

Cancel a running or pending async job.

import { cancelJob } from '@tpmjs/unsandbox';

await cancelJob.execute({ job_id: 'abc123' });

listLanguages

List all 42+ supported programming languages.

import { listLanguages } from '@tpmjs/unsandbox';

const languages = await listLanguages.execute({});

Supported Languages

42+ languages including:

  • Interpreted: Python, JavaScript, TypeScript, Ruby, Perl, PHP, Lua, Bash, R, Elixir, Erlang, Tcl, Scheme, PowerShell, Clojure, Common Lisp, Crystal, Groovy, Deno, AWK, Raku
  • Compiled: C, C++, Go, Rust, Java, Kotlin, COBOL, Fortran, D, Zig, Nim, V, Objective-C, Dart
  • Functional: Julia, Haskell, OCaml, F#, C#, Prolog, Forth

Environment Variables

Variable Required Description
UNSANDBOX_API_KEY Yes API key from unsandbox.com

License

MIT