diff --git a/apps/web/src/app/docs/api/scenarios/page.tsx b/apps/web/src/app/docs/api/scenarios/page.tsx new file mode 100644 index 0000000..e98f0bc --- /dev/null +++ b/apps/web/src/app/docs/api/scenarios/page.tsx @@ -0,0 +1,679 @@ +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@tpmjs/ui/Card/Card'; +import { CodeBlock } from '@tpmjs/ui/CodeBlock/CodeBlock'; +import type { Metadata } from 'next'; + +export const metadata: Metadata = { + title: 'Scenarios API | TPMJS Docs', + description: 'API reference for TPMJS scenarios endpoints', +}; + +export default function ScenariosApiPage(): React.ReactElement { + return ( +
+ The Scenarios API allows you to create, run, and manage test scenarios for your tool + collections. +
++ Retrieve a paginated list of public scenarios with optional filtering. +
+ +limit - Number of results (default: 20, max: 50)
+ offset - Pagination offset
+ collectionId - Filter by collection ID
+ tags - Filter by tags (comma-separated)
+ sortBy - Sort field: qualityScore, totalRuns,{' '}
+ createdAt, lastRunAt
+ + Retrieve detailed information about a specific scenario. +
+ +id - Scenario ID
+ + Retrieve all scenarios for a specific collection. +
+ +id - Collection ID
+ limit - Number of results (default: 20, max: 50)
+ offset - Pagination offset
+ + Create a new scenario manually. Requires authentication and collection ownership. +
+ ++ AI-generate scenarios based on the collection's tools. Requires authentication and + collection ownership. +
+ +id - Collection ID
+
+ When similarity.maxSimilarity exceeds 0.7, the scenario is similar to an
+ existing one. The mostSimilar field shows which scenario it overlaps
+ with.
+
+ Execute a scenario and return the results. Requires authentication. Consumes one run + from your daily quota. +
+ +id - Scenario ID
+ + Retrieve the run history for a scenario. Requires authentication if the scenario belongs + to a private collection. +
+ +id - Scenario ID
+ limit - Number of results (default: 10, max: 50)
+ offset - Pagination offset
+ + Check if a prompt is similar to existing scenarios in a collection. Useful before + creating manual scenarios to avoid duplicates. +
+ +
+ A maxSimilarity above 0.7 indicates significant overlap with existing
+ scenarios. Consider modifying your prompt to test different aspects of your tools.
+
+ Retrieve featured scenarios for the homepage showcase. Returns a mix of high-quality, + diverse, and recently successful scenarios. +
+ +limit - Number of results (default: 10, max: 20)
+ + Scenarios are AI-generated test cases for your tool collections. They automatically verify + that your tools work correctly and provide quality metrics over time. +
++ A Scenario is a test case that exercises your tool collection with a realistic user + prompt. When you run a scenario: +
++ This enables continuous testing of your tool collections, similar to unit tests for + code. +
++ Test data extraction from various webpage structures: +
++ Verify search accuracy and relevance: +
++ Test transformations and calculations: +
++ Verify file operations and content extraction: +
++ You need a TPMJS API key to run scenarios. Get one from your{' '} + + dashboard settings + + . +
++ AI-generate test scenarios based on your collection's tools. The generator analyzes + your tools and creates realistic prompts. +
+ ++ Generated scenarios are checked against existing ones using vector similarity. If a + scenario is >70% similar to an existing one, you'll see a warning. This helps + maintain diverse test coverage. +
++ View all scenarios for a collection or browse public scenarios. +
+ ++ Execute all scenarios for a collection. This is ideal for CI/CD pipelines or batch + testing. +
+ +0 - All scenarios passed
+ 1 - One or more scenarios failed
+ + Run a single scenario by its ID. Useful for debugging or re-testing specific failures. +
+ ++ View detailed information about a scenario including its run history and quality + metrics. +
+ ++ Quality scores help identify reliable scenarios and track improvement over time. Scores + range from 0% to 100%. +
+ ++ Scenarios earn bonus points for consecutive passes and lose points for consecutive + failures: +
+ ++ A scenario with 5 consecutive passes would have a quality score of approximately 85% + (5% × 5 + 1% × (1+2+3+4+5) = 25% + 15% = 40%, plus base score). High-quality scenarios + are featured on the TPMJS homepage showcase. +
++ Integrate scenario testing into your CI/CD pipeline to catch regressions early. +
+ ++ Scenario execution is subject to daily rate limits to ensure fair usage: +
+ ++ The remaining quota is shown after each scenario run. Plan your CI/CD schedules + accordingly to stay within limits. +
++ REST API endpoints for programmatic scenario management +
++ Create and manage tool collections for your scenarios +
++ Learn how scenarios use agents for execution +
++ Discover tools to add to your collections +
+