tpmjs/packages
Ajax Davis ab46b6e116 feat: add interactive tool playground with AI-powered execution
Implement comprehensive tool testing environment with real package execution, AI agents, and token tracking.

**New Features:**
- Interactive playground UI with 4 tabs (Input, Output, Logs, Token Usage)
- Real npm package execution in VM2 sandbox with security constraints
- AI-powered tool execution using AI SDK v5 and GPT-4 Turbo
- Server-Sent Events (SSE) streaming for real-time progress updates
- Comprehensive 4-category token tracking (Input, Tool Description, Schema, Output)
- Visual token breakdown with colored progress bars
- IP-based rate limiting (10 executions/hour per IP)
- Database persistence of all simulations with full metadata

**Database Schema:**
- New `Simulation` model for execution records
- New `TokenUsage` model for detailed token metrics
- New `ExecutionLog` model for execution event tracking
- Added simulations relation to Tool model

**Package Executor (@tpmjs/package-executor):**
- VM2 sandbox with 5-second timeout
- Blocked dangerous modules (fs, net, http, https, child_process)
- LRU file system cache in /tmp/.tpmjs-cache
- Package installation and caching strategy

**AI Agent Service:**
- TPMJS parameter to Zod schema conversion
- AI SDK tool definition generation
- Token counting using tiktoken library
- GPT-4 Turbo pricing estimation
- Streaming text execution with callbacks

**API Endpoints:**
- POST /api/tools/[...slug]/execute - SSE streaming execution
- GET /api/tools/[...slug]/simulations - Execution history
- Rate limit headers (X-RateLimit-Limit, X-RateLimit-Remaining)

**Frontend Components:**
- ToolPlayground - Main playground UI with tabs
- TokenBreakdown - Visual token metrics with colored bars
- Integrated above README section on tool detail pages

**Security:**
- VM2 sandboxing prevents filesystem/network access
- Rate limiting prevents abuse
- IP tracking for usage monitoring
- Timeout protection (60s max API duration, 5s VM timeout)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 00:36:05 +10:00
..
config fix(biome): ignore Next.js auto-generated next-env.d.ts file 2025-11-26 22:59:32 +10:00
db feat: add interactive tool playground with AI-powered execution 2025-11-30 00:36:05 +10:00
env fix(lint): configure Biome to properly ignore build directories 2025-11-26 22:49:45 +10:00
mocks fix(lint): configure Biome to properly ignore build directories 2025-11-26 22:49:45 +10:00
npm-client feat: add README rendering and enhanced package metadata display 2025-11-29 22:41:50 +10:00
package-executor feat: add interactive tool playground with AI-powered execution 2025-11-30 00:36:05 +10:00
storybook fix(lint): configure Biome to properly ignore build directories 2025-11-26 22:49:45 +10:00
test fix(lint): configure Biome to properly ignore build directories 2025-11-26 22:49:45 +10:00
tools/createBlogPost chore: version @tpmjs/createblogpost to 0.2.0 2025-11-28 03:17:50 +10:00
types feat(types): add comprehensive TPMJS field schemas with validation 2025-11-28 02:12:11 +10:00
ui fix(ui): replace Tailwind classes with direct SVG attributes in FlowDiagram 2025-11-27 23:14:41 +10:00
utils fix(lint): configure Biome to properly ignore build directories 2025-11-26 22:49:45 +10:00