Implements a complete dynamic tool loading system that allows the playground to discover and load tools from the TPMJS registry at runtime. **Architecture:** - Search tool package (@tpmjs/search-registry) - Searches registry for tools - Search API endpoint (/api/tools/search) - Text-based search with scoring - Pre-flight tool loading - Automatically searches and loads tools on every message - Railway executor service (Deno) - Loads tools from esm.sh via HTTP imports - Dynamic tool loader - Calls Railway to load and execute tools remotely **Key Components:** 1. Railway Executor (apps/railway-executor/) - Deno-based service that natively supports HTTP imports - Endpoints: /load-and-describe, /execute-tool, /cache/stats, /cache/clear - Deploys to Railway with deno run --allow-net --allow-env server.ts 2. Search Tool Package (packages/tools/search-registry/) - AI SDK v6 tool for searching TPMJS registry - Uses jsonSchema + inputSchema pattern - Searches /api/tools/search endpoint 3. Search API (apps/web/src/app/api/tools/search/) - Text-based search with composite scoring - Scores: text relevance + quality boost + download boost - Returns tool metadata with importUrl for dynamic loading 4. Dynamic Tool Loader (apps/playground/src/lib/dynamic-tool-loader.ts) - Calls Railway service to load tools from esm.sh - Creates tool wrappers that execute remotely - Process-level module cache + per-conversation tracking 5. Pre-flight Loading (apps/playground/src/app/api/chat/route.ts) - Automatically searches for tools on every user message - Loads top 5 matching tools before agent processes request - Merges with static tools for seamless experience **Technical Decisions:** - Deno over Node.js: Native HTTP import support without flags - Remote execution: Tools run in Railway sandbox, not Vercel - Pre-flight loading: Better UX than two-turn search pattern - Text search: BM25 had dependency issues, simple scoring works well **Environment Variables:** - RAILWAY_SERVICE_URL: https://endearing-commitment-production.up.railway.app 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
52 lines
1.4 KiB
JSON
52 lines
1.4 KiB
JSON
{
|
|
"name": "@tpmjs/web",
|
|
"version": "0.0.0",
|
|
"private": true,
|
|
"scripts": {
|
|
"dev": "next dev",
|
|
"build": "next build",
|
|
"start": "next start",
|
|
"lint": "eslint .",
|
|
"type-check": "tsc --noEmit",
|
|
"clean": "rm -rf .next .turbo"
|
|
},
|
|
"dependencies": {
|
|
"@ai-sdk/openai": "3.0.0-beta.74",
|
|
"@tpmjs/db": "workspace:*",
|
|
"@tpmjs/env": "workspace:*",
|
|
"@tpmjs/npm-client": "workspace:*",
|
|
"@tpmjs/package-executor": "workspace:*",
|
|
"@tpmjs/types": "workspace:*",
|
|
"@tpmjs/ui": "workspace:*",
|
|
"@tpmjs/utils": "workspace:*",
|
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
"ai": "6.0.0-beta.124",
|
|
"bm25": "^0.1.1",
|
|
"next": "^16.0.4",
|
|
"next-themes": "^0.4.6",
|
|
"openai": "^6.9.1",
|
|
"react": "^19.0.0",
|
|
"react-dom": "^19.0.0",
|
|
"react-markdown": "^10.1.0",
|
|
"react-syntax-highlighter": "^16.1.0",
|
|
"rehype-raw": "^7.0.0",
|
|
"rehype-sanitize": "^6.0.0",
|
|
"remark-gfm": "^4.0.1",
|
|
"zod": "^4.0.0"
|
|
},
|
|
"devDependencies": {
|
|
"@tailwindcss/typography": "^0.5.19",
|
|
"@tpmjs/eslint-config": "workspace:*",
|
|
"@tpmjs/tailwind-config": "workspace:*",
|
|
"@tpmjs/tsconfig": "workspace:*",
|
|
"@types/node": "^22.10.2",
|
|
"@types/react": "^19.0.2",
|
|
"@types/react-dom": "^19.0.2",
|
|
"autoprefixer": "^10.4.20",
|
|
"eslint": "^9.39.1",
|
|
"eslint-config-next": "^16.0.4",
|
|
"postcss": "^8.5.1",
|
|
"tailwindcss": "^3.4.17",
|
|
"typescript": "^5.9.3"
|
|
}
|
|
}
|