Configuration and tools
Reuse through configuration and processing handlers.
Configuration entry points
config/site.ts: name, default title/description, logo/OG, navigation/social/support.config/content.ts: bilingual copy, FAQ/steps/CTA/previews/features/company logos. Customer samples are hidden by default; only use real authorized content.config/billing.ts: cents, USD, credits and annual installments.constants/billing.tsre-exports compatibility; merchant product IDs are env-only.config/legal.ts: complete/review per product beforereviewed=true. Unreviewed legal templates are noindex and omitted from sitemap.
Add a tool
Register public form copy/input in config/tools.ts. Register strict Zod schema, server cost and run in lib/tools/handlers.ts and add it to getToolHandler. ToolPlayground handles loading, errors, text/JSON/CSV/image output, copying and downloads.
/api/tools/[toolId] enforces login/ban access, same-origin, bounded payload, validation, PostgreSQL rate limits (10/user/tool/minute), atomic pre-debit and failure compensation. Never trust browser userId/cost/provider.
File/image inputs use JSON base64 up to 128 KB; handlers must verify decoded size/MIME/content. The URL example does not fetch; add SSRF protection before remote fetch handlers. Use csvCell to prevent CSV formulas. Image results allow HTTPS and do not create an unrestricted server download proxy.
This synchronous wrapper is not a durable job queue. Long-running paid tasks need persisted idempotency/retry/refund recovery. Process crashes may require requestId ledger reconciliation. No anonymous execution: trial means 300 signup credits.
Six Hero presets
Select classic (default), prompt, upload, split, compare or gallery in config/hero.ts. Only the selected layout loads lazily; bilingual text lives in one configuration.
Use target { kind: 'tool', id: 'text-stats' } with a registered tool; { kind: 'demo', id: 'chat' } (also image/video); or a safe local { kind: 'page', href: '/pricing' }. interaction: 'entry' hands off to the workspace. Inline prompt/split reuses the real ToolPlayground, never invented output. Page targets offer a link, not a composer that discards input. Upload requires a compatible file tool or image/video workspace; entry files are selected in the workspace after login, not retained across navigation.
Bounded target-specific text drafts live in tab-local sessionStorage for 30 minutes, never URLs. No automatic submit/charge; successful use clears them. Storage denial keeps text visible and asks users to copy it. Drafts are not durable assets and are readable by same-origin scripts; never paste credentials.
Development previews /hero-preview and /zh/hero-preview provide six layouts, themes and side-by-side comparison with execution disabled and noindex; production returns 404. Configure media.preview (optional previewDark), media.comparison and media.gallery with local public images, descriptive alt and illustrative labels. Missing media shows guidance. Video products use posters, not autoplay backgrounds.
Video demos are not a queue. Uncertain supplier acceptance stays pending_review for operator/provider reconciliation. Durable retry, crash recovery and scheduled reconciliation remain deferred until a specific paid long-task product is designed.