@langwatch/server 3.1.0-beta.1 → 3.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/langwatch/ee/admin/ImpersonationBanner.tsx +61 -0
- package/langwatch/ee/admin/ImpersonationSwitchBackMenuItem.tsx +30 -0
- package/langwatch/ee/admin/__tests__/ImpersonationBanner.integration.test.tsx +82 -0
- package/langwatch/ee/admin/__tests__/impersonation.service.unit.test.ts +231 -0
- package/langwatch/ee/admin/backoffice/BackofficeTable.tsx +200 -0
- package/langwatch/ee/admin/backoffice/__tests__/adminClient.unit.test.ts +147 -0
- package/langwatch/ee/admin/backoffice/__tests__/dateInputToISO.unit.test.ts +42 -0
- package/langwatch/ee/admin/backoffice/__tests__/userVisibility.unit.test.ts +174 -0
- package/langwatch/ee/admin/backoffice/adminClient.ts +114 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationFeaturesView.tsx +373 -0
- package/langwatch/ee/admin/backoffice/resources/OrganizationsView.tsx +677 -0
- package/langwatch/ee/admin/backoffice/resources/ProjectsView.tsx +647 -0
- package/langwatch/ee/admin/backoffice/resources/SubscriptionsView.tsx +628 -0
- package/langwatch/ee/admin/backoffice/resources/UsersView.tsx +556 -0
- package/langwatch/ee/admin/backoffice/useAdminResource.ts +104 -0
- package/langwatch/ee/admin/backoffice/userVisibility.ts +105 -0
- package/langwatch/ee/admin/impersonation.service.ts +170 -0
- package/langwatch/ee/admin/isAdmin.ts +9 -0
- package/langwatch/ee/admin/routes/admin.ts +531 -0
- package/langwatch/ee/admin/safeSelects.ts +64 -0
- package/langwatch/ee/billing/__tests__/customerService.unit.test.ts +183 -0
- package/langwatch/ee/billing/__tests__/growthSeatEvent.unit.test.ts +213 -0
- package/langwatch/ee/billing/__tests__/licensePurchaseHandler.unit.test.ts +250 -0
- package/langwatch/ee/billing/__tests__/notification.service.unit.test.ts +768 -0
- package/langwatch/ee/billing/__tests__/planLimits.unit.test.ts +19 -0
- package/langwatch/ee/billing/__tests__/planProvider.unit.test.ts +440 -0
- package/langwatch/ee/billing/__tests__/planTypes.unit.test.ts +32 -0
- package/langwatch/ee/billing/__tests__/pricing.unit.test.ts +54 -0
- package/langwatch/ee/billing/__tests__/seatEventSubscription.unit.test.ts +717 -0
- package/langwatch/ee/billing/__tests__/stripe.integration.test.ts +344 -0
- package/langwatch/ee/billing/__tests__/stripePrices.types.unit.test.ts +27 -0
- package/langwatch/ee/billing/__tests__/stripePricesLoader.unit.test.ts +72 -0
- package/langwatch/ee/billing/__tests__/subscription.service.unit.test.ts +730 -0
- package/langwatch/ee/billing/__tests__/subscriptionItemCalculator.unit.test.ts +176 -0
- package/langwatch/ee/billing/__tests__/usage-limit.service.unit.test.ts +706 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.integration.test.ts +421 -0
- package/langwatch/ee/billing/__tests__/usageReportingService.unit.test.ts +515 -0
- package/langwatch/ee/billing/__tests__/webhookService.unit.test.ts +958 -0
- package/langwatch/ee/billing/currencyRouter.ts +18 -0
- package/langwatch/ee/billing/errors.ts +129 -0
- package/langwatch/ee/billing/index.ts +67 -0
- package/langwatch/ee/billing/middleware.ts +17 -0
- package/langwatch/ee/billing/notifications/notification.service.ts +651 -0
- package/langwatch/ee/billing/notifications/repositories/notification.repository.ts +51 -0
- package/langwatch/ee/billing/notifications/types.ts +9 -0
- package/langwatch/ee/billing/notifications/usage-limit.service.ts +622 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.ts +90 -0
- package/langwatch/ee/billing/nurturing/hooks/activityTracking.unit.test.ts +237 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.ts +120 -0
- package/langwatch/ee/billing/nurturing/hooks/featureAdoption.unit.test.ts +324 -0
- package/langwatch/ee/billing/nurturing/hooks/index.ts +17 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.ts +68 -0
- package/langwatch/ee/billing/nurturing/hooks/productInterest.unit.test.ts +138 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.integration.test.ts +288 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.ts +131 -0
- package/langwatch/ee/billing/nurturing/hooks/promptCreation.unit.test.ts +134 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.ts +101 -0
- package/langwatch/ee/billing/nurturing/hooks/signupIdentification.unit.test.ts +317 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.ts +49 -0
- package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.unit.test.ts +170 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.ts +143 -0
- package/langwatch/ee/billing/nurturing/hooks/userSync.unit.test.ts +307 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.ts +179 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.unit.test.ts +266 -0
- package/langwatch/ee/billing/nurturing/nurturing.service.wiring.unit.test.ts +109 -0
- package/langwatch/ee/billing/nurturing/types.ts +125 -0
- package/langwatch/ee/billing/planLimits.ts +190 -0
- package/langwatch/ee/billing/planProvider.ts +119 -0
- package/langwatch/ee/billing/planTypes.ts +53 -0
- package/langwatch/ee/billing/pricing.ts +57 -0
- package/langwatch/ee/billing/services/billableEventsQuery.ts +248 -0
- package/langwatch/ee/billing/services/customerService.ts +90 -0
- package/langwatch/ee/billing/services/licensePurchaseHandler.ts +73 -0
- package/langwatch/ee/billing/services/seatEventSubscription.ts +351 -0
- package/langwatch/ee/billing/services/seatSyncService.ts +34 -0
- package/langwatch/ee/billing/services/subscription.repository.ts +203 -0
- package/langwatch/ee/billing/services/subscription.service.ts +549 -0
- package/langwatch/ee/billing/services/subscriptionItemCalculator.ts +249 -0
- package/langwatch/ee/billing/services/usageReportingService.ts +301 -0
- package/langwatch/ee/billing/services/webhookService.ts +858 -0
- package/langwatch/ee/billing/stripe/stripeCatalog.json +1781 -0
- package/langwatch/ee/billing/stripe/stripeClient.ts +13 -0
- package/langwatch/ee/billing/stripe/stripePriceCatalog.ts +70 -0
- package/langwatch/ee/billing/stripe/stripePrices.types.ts +118 -0
- package/langwatch/ee/billing/subscriptionRouter.ts +202 -0
- package/langwatch/ee/billing/types.ts +102 -0
- package/langwatch/ee/billing/utils/currency.ts +99 -0
- package/langwatch/ee/billing/utils/growthSeatEvent.ts +137 -0
- package/langwatch/ee/licensing/__tests__/constants.unit.test.ts +56 -0
- package/langwatch/ee/licensing/__tests__/defaults.unit.test.ts +192 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testKeys.ts +86 -0
- package/langwatch/ee/licensing/__tests__/fixtures/testLicenses.ts +92 -0
- package/langwatch/ee/licensing/__tests__/licenseGenerationService.unit.test.ts +232 -0
- package/langwatch/ee/licensing/__tests__/licenseHandler.integration.test.ts +419 -0
- package/langwatch/ee/licensing/__tests__/planMapping.unit.test.ts +195 -0
- package/langwatch/ee/licensing/__tests__/planTemplates.unit.test.ts +193 -0
- package/langwatch/ee/licensing/__tests__/signing.unit.test.ts +164 -0
- package/langwatch/ee/licensing/__tests__/validation.unit.test.ts +281 -0
- package/langwatch/ee/licensing/client.ts +29 -0
- package/langwatch/ee/licensing/constants.ts +195 -0
- package/langwatch/ee/licensing/defaults.ts +55 -0
- package/langwatch/ee/licensing/errors.ts +11 -0
- package/langwatch/ee/licensing/index.ts +52 -0
- package/langwatch/ee/licensing/licenseGenerationService.ts +87 -0
- package/langwatch/ee/licensing/licenseHandler.ts +308 -0
- package/langwatch/ee/licensing/planInfo.ts +46 -0
- package/langwatch/ee/licensing/planMapping.ts +37 -0
- package/langwatch/ee/licensing/planTemplates.ts +109 -0
- package/langwatch/ee/licensing/server.ts +43 -0
- package/langwatch/ee/licensing/signing.ts +43 -0
- package/langwatch/ee/licensing/types.ts +156 -0
- package/langwatch/ee/licensing/validation.ts +107 -0
- package/langwatch/ee/managed-providers/ManagedModelProviderAlert.tsx +29 -0
- package/langwatch/ee/managed-providers/managedBedrockConfig.ts +226 -0
- package/langwatch/ee/saas/ExtraFooterComponents.tsx +169 -0
- package/langwatch/package.json +1 -1
- package/langwatch/pnpm-workspace.yaml +0 -1
- package/langwatch_nlp/uv.lock +179 -5
- package/mcp-server/.env.example +2 -0
- package/mcp-server/.eslintrc.cjs +36 -0
- package/mcp-server/CHANGELOG.md +165 -0
- package/mcp-server/CONTRIBUTING.md +96 -0
- package/mcp-server/README.md +172 -0
- package/mcp-server/dist/archive-scenario-WJ2A7ETN.js +19 -0
- package/mcp-server/dist/archive-suite-4JOM4SSL.js +15 -0
- package/mcp-server/dist/assign-prompt-tag-GL7EAAF3.js +19 -0
- package/mcp-server/dist/chunk-2GT7IFWK.js +40 -0
- package/mcp-server/dist/chunk-2WPLXEKF.js +127 -0
- package/mcp-server/dist/chunk-4AUB2BIA.js +71 -0
- package/mcp-server/dist/chunk-BWWY5KEF.js +71 -0
- package/mcp-server/dist/chunk-CCWCIJJ3.js +22 -0
- package/mcp-server/dist/chunk-EGH5RPXM.js +25 -0
- package/mcp-server/dist/chunk-EUQDVOSU.js +39 -0
- package/mcp-server/dist/chunk-HYMIWO3U.js +44 -0
- package/mcp-server/dist/chunk-IE4M5OGE.js +42 -0
- package/mcp-server/dist/chunk-LUMEZEHL.js +48 -0
- package/mcp-server/dist/chunk-NUFPTHKU.js +9 -0
- package/mcp-server/dist/chunk-UDHJYT6P.js +1567 -0
- package/mcp-server/dist/chunk-WQG2DFHX.js +86 -0
- package/mcp-server/dist/chunk-WVI5CJ6S.js +21 -0
- package/mcp-server/dist/chunk-ZVS4UKN2.js +35 -0
- package/mcp-server/dist/chunk-ZXKLPC2E.js +27 -0
- package/mcp-server/dist/config.d.ts +17 -0
- package/mcp-server/dist/config.js +13 -0
- package/mcp-server/dist/create-agent-MBOOT3XK.js +23 -0
- package/mcp-server/dist/create-annotation-XMV6A7ED.js +24 -0
- package/mcp-server/dist/create-dashboard-VRKLFVZJ.js +18 -0
- package/mcp-server/dist/create-dataset-7HQPZCRE.js +22 -0
- package/mcp-server/dist/create-dataset-records-2NIVFYTV.js +22 -0
- package/mcp-server/dist/create-evaluator-WYFRFLRC.js +27 -0
- package/mcp-server/dist/create-mcp-server.d.ts +8 -0
- package/mcp-server/dist/create-mcp-server.js +8 -0
- package/mcp-server/dist/create-prompt-IEN7O6JT.js +39 -0
- package/mcp-server/dist/create-prompt-tag-CAEZ45VO.js +17 -0
- package/mcp-server/dist/create-scenario-6YHSMGLP.js +26 -0
- package/mcp-server/dist/create-suite-H5XOFDE5.js +38 -0
- package/mcp-server/dist/delete-agent-JKTNBWAA.js +18 -0
- package/mcp-server/dist/delete-annotation-ACMDV6QO.js +17 -0
- package/mcp-server/dist/delete-dashboard-VJSR7CRU.js +18 -0
- package/mcp-server/dist/delete-dataset-RTTTWP4D.js +20 -0
- package/mcp-server/dist/delete-dataset-records-KNQTIPQK.js +21 -0
- package/mcp-server/dist/delete-evaluator-7FVC5WM4.js +15 -0
- package/mcp-server/dist/delete-prompt-tag-ZMZUAGFW.js +17 -0
- package/mcp-server/dist/delete-workflow-EYQ3T4RQ.js +17 -0
- package/mcp-server/dist/discover-evaluator-schema-H23XCLNE.js +1402 -0
- package/mcp-server/dist/discover-scenario-schema-MEEEVND7.js +65 -0
- package/mcp-server/dist/discover-schema-3T52ORPB.js +446 -0
- package/mcp-server/dist/get-agent-E3QSTVKG.js +28 -0
- package/mcp-server/dist/get-analytics-2OHV763I.js +72 -0
- package/mcp-server/dist/get-dashboard-PC7JDHH6.js +29 -0
- package/mcp-server/dist/get-dataset-H5IK5FVU.js +48 -0
- package/mcp-server/dist/get-evaluator-UWVUPYTM.js +47 -0
- package/mcp-server/dist/get-prompt-WZUOLLQC.js +45 -0
- package/mcp-server/dist/get-scenario-Q6LCNUYN.js +33 -0
- package/mcp-server/dist/get-simulation-run-Z2XKO256.js +56 -0
- package/mcp-server/dist/get-suite-BXK5TN7P.js +44 -0
- package/mcp-server/dist/get-trace-4EJAYVBG.js +50 -0
- package/mcp-server/dist/get-workflow-O34QJLHD.js +25 -0
- package/mcp-server/dist/http-server-RSTXN4CN.js +224 -0
- package/mcp-server/dist/index.d.ts +2 -0
- package/mcp-server/dist/index.js +67774 -0
- package/mcp-server/dist/langwatch-api-annotations-ERBG27RF.js +17 -0
- package/mcp-server/dist/langwatch-api-dashboards-G6TR7VVO.js +17 -0
- package/mcp-server/dist/langwatch-api-monitors-WSXZLS2B.js +52 -0
- package/mcp-server/dist/langwatch-api-secrets-RR5DKG2X.js +40 -0
- package/mcp-server/dist/langwatch-api-triggers-2RTNSWQY.js +30 -0
- package/mcp-server/dist/langwatch-api-workflows-VJRIIDZ7.js +15 -0
- package/mcp-server/dist/list-agents-AW3P6FJV.js +32 -0
- package/mcp-server/dist/list-annotations-QNCGWPQ3.js +33 -0
- package/mcp-server/dist/list-dashboards-R7RK2IXL.js +32 -0
- package/mcp-server/dist/list-dataset-records-WVCSQP7P.js +39 -0
- package/mcp-server/dist/list-datasets-KEXRLDEU.js +60 -0
- package/mcp-server/dist/list-evaluators-7R2LB4JH.js +34 -0
- package/mcp-server/dist/list-model-providers-OBYJCKBX.js +35 -0
- package/mcp-server/dist/list-prompt-tags-6LY3ZPYI.js +23 -0
- package/mcp-server/dist/list-prompts-VWEZ4CDE.js +32 -0
- package/mcp-server/dist/list-scenarios-TXD4W2ZJ.js +40 -0
- package/mcp-server/dist/list-simulation-runs-RHPOLMFI.js +43 -0
- package/mcp-server/dist/list-suites-FSGBX27Z.js +42 -0
- package/mcp-server/dist/list-workflows-VRGEZ3EN.js +35 -0
- package/mcp-server/dist/rename-prompt-tag-VOJJLX4M.js +18 -0
- package/mcp-server/dist/run-agent-KTCC7TB7.js +36 -0
- package/mcp-server/dist/run-evaluation-2X3V3Q6L.js +64 -0
- package/mcp-server/dist/run-suite-BTMHGI2D.js +29 -0
- package/mcp-server/dist/run-workflow-IGAYGKJL.js +36 -0
- package/mcp-server/dist/search-traces-VYFUIMXH.js +72 -0
- package/mcp-server/dist/set-model-provider-W5IUI326.js +33 -0
- package/mcp-server/dist/update-agent-4BB7EYLR.js +20 -0
- package/mcp-server/dist/update-dataset-CXBKZ4W3.js +22 -0
- package/mcp-server/dist/update-dataset-record-HOHAMHXG.js +19 -0
- package/mcp-server/dist/update-evaluator-IVOR6FTR.js +24 -0
- package/mcp-server/dist/update-prompt-OWQAKE7K.js +24 -0
- package/mcp-server/dist/update-scenario-GDFVILPN.js +27 -0
- package/mcp-server/dist/update-suite-BXYUYSPT.js +39 -0
- package/mcp-server/package.json +79 -0
- package/mcp-server/pnpm-lock.yaml +6103 -0
- package/mcp-server/pnpm-workspace.yaml +2 -0
- package/mcp-server/pyproject.toml +17 -0
- package/mcp-server/src/__tests__/all-tools.integration.test.ts +1681 -0
- package/mcp-server/src/__tests__/config.unit.test.ts +169 -0
- package/mcp-server/src/__tests__/datasets.integration.test.ts +603 -0
- package/mcp-server/src/__tests__/datasets.unit.test.ts +240 -0
- package/mcp-server/src/__tests__/date-parsing.unit.test.ts +78 -0
- package/mcp-server/src/__tests__/discover-evaluator-schema.unit.test.ts +89 -0
- package/mcp-server/src/__tests__/discover-schema.unit.test.ts +118 -0
- package/mcp-server/src/__tests__/docker.integration.test.ts +234 -0
- package/mcp-server/src/__tests__/evaluator-tools.unit.test.ts +262 -0
- package/mcp-server/src/__tests__/http-transport.integration.test.ts +397 -0
- package/mcp-server/src/__tests__/integration.integration.test.ts +288 -0
- package/mcp-server/src/__tests__/langwatch-api.unit.test.ts +455 -0
- package/mcp-server/src/__tests__/model-provider-tools.unit.test.ts +190 -0
- package/mcp-server/src/__tests__/scenario-tools.integration.test.ts +286 -0
- package/mcp-server/src/__tests__/scenario-tools.unit.test.ts +185 -0
- package/mcp-server/src/__tests__/schemas.unit.test.ts +85 -0
- package/mcp-server/src/__tests__/tools.unit.test.ts +900 -0
- package/mcp-server/src/config.d.ts +15 -0
- package/mcp-server/src/config.ts +107 -0
- package/mcp-server/src/create-mcp-server.d.ts +6 -0
- package/mcp-server/src/create-mcp-server.ts +1799 -0
- package/mcp-server/src/http-server.ts +329 -0
- package/mcp-server/src/index.ts +46 -0
- package/mcp-server/src/langwatch-api-agents.ts +108 -0
- package/mcp-server/src/langwatch-api-annotations.ts +49 -0
- package/mcp-server/src/langwatch-api-dashboards.ts +48 -0
- package/mcp-server/src/langwatch-api-datasets.ts +191 -0
- package/mcp-server/src/langwatch-api-evaluators.ts +80 -0
- package/mcp-server/src/langwatch-api-model-providers.ts +41 -0
- package/mcp-server/src/langwatch-api-monitors.ts +82 -0
- package/mcp-server/src/langwatch-api-scenarios.ts +67 -0
- package/mcp-server/src/langwatch-api-secrets.ts +48 -0
- package/mcp-server/src/langwatch-api-simulation-runs.ts +51 -0
- package/mcp-server/src/langwatch-api-suites.ts +118 -0
- package/mcp-server/src/langwatch-api-triggers.ts +48 -0
- package/mcp-server/src/langwatch-api-workflows.ts +41 -0
- package/mcp-server/src/langwatch-api.ts +299 -0
- package/mcp-server/src/schemas/analytics-groups.ts +78 -0
- package/mcp-server/src/schemas/analytics-metrics.ts +179 -0
- package/mcp-server/src/schemas/create-dataset.ts +48 -0
- package/mcp-server/src/schemas/filter-fields.ts +119 -0
- package/mcp-server/src/schemas/index.ts +4 -0
- package/mcp-server/src/tools/archive-scenario.ts +19 -0
- package/mcp-server/src/tools/archive-suite.ts +12 -0
- package/mcp-server/src/tools/assign-prompt-tag.ts +16 -0
- package/mcp-server/src/tools/create-agent.ts +15 -0
- package/mcp-server/src/tools/create-annotation.ts +18 -0
- package/mcp-server/src/tools/create-dashboard.ts +7 -0
- package/mcp-server/src/tools/create-dataset-records.ts +23 -0
- package/mcp-server/src/tools/create-dataset.ts +22 -0
- package/mcp-server/src/tools/create-evaluator.ts +33 -0
- package/mcp-server/src/tools/create-prompt-tag.ts +12 -0
- package/mcp-server/src/tools/create-prompt.ts +58 -0
- package/mcp-server/src/tools/create-scenario.ts +30 -0
- package/mcp-server/src/tools/create-suite.ts +42 -0
- package/mcp-server/src/tools/delete-agent.ts +7 -0
- package/mcp-server/src/tools/delete-annotation.ts +7 -0
- package/mcp-server/src/tools/delete-dashboard.ts +7 -0
- package/mcp-server/src/tools/delete-dataset-records.ts +22 -0
- package/mcp-server/src/tools/delete-dataset.ts +20 -0
- package/mcp-server/src/tools/delete-evaluator.ts +12 -0
- package/mcp-server/src/tools/delete-prompt-tag.ts +12 -0
- package/mcp-server/src/tools/delete-workflow.ts +7 -0
- package/mcp-server/src/tools/discover-evaluator-schema.ts +143 -0
- package/mcp-server/src/tools/discover-scenario-schema.ts +71 -0
- package/mcp-server/src/tools/discover-schema.ts +106 -0
- package/mcp-server/src/tools/format-dataset-mutation.ts +25 -0
- package/mcp-server/src/tools/get-agent.ts +21 -0
- package/mcp-server/src/tools/get-analytics.ts +98 -0
- package/mcp-server/src/tools/get-dashboard.ts +22 -0
- package/mcp-server/src/tools/get-dataset.ts +63 -0
- package/mcp-server/src/tools/get-evaluator.ts +53 -0
- package/mcp-server/src/tools/get-prompt.ts +54 -0
- package/mcp-server/src/tools/get-scenario.ts +36 -0
- package/mcp-server/src/tools/get-simulation-run.ts +60 -0
- package/mcp-server/src/tools/get-suite.ts +47 -0
- package/mcp-server/src/tools/get-trace.ts +61 -0
- package/mcp-server/src/tools/get-workflow.ts +17 -0
- package/mcp-server/src/tools/list-agents.ts +27 -0
- package/mcp-server/src/tools/list-annotations.ts +33 -0
- package/mcp-server/src/tools/list-dashboards.ts +27 -0
- package/mcp-server/src/tools/list-dataset-records.ts +46 -0
- package/mcp-server/src/tools/list-datasets.ts +80 -0
- package/mcp-server/src/tools/list-evaluators.ts +37 -0
- package/mcp-server/src/tools/list-model-providers.ts +40 -0
- package/mcp-server/src/tools/list-prompt-tags.ts +21 -0
- package/mcp-server/src/tools/list-prompts.ts +34 -0
- package/mcp-server/src/tools/list-scenarios.ts +47 -0
- package/mcp-server/src/tools/list-simulation-runs.ts +49 -0
- package/mcp-server/src/tools/list-suites.ts +43 -0
- package/mcp-server/src/tools/list-workflows.ts +31 -0
- package/mcp-server/src/tools/rename-prompt-tag.ts +14 -0
- package/mcp-server/src/tools/run-agent.ts +36 -0
- package/mcp-server/src/tools/run-evaluation.ts +87 -0
- package/mcp-server/src/tools/run-suite.ts +28 -0
- package/mcp-server/src/tools/run-workflow.ts +36 -0
- package/mcp-server/src/tools/search-traces.ts +91 -0
- package/mcp-server/src/tools/set-model-provider.ts +46 -0
- package/mcp-server/src/tools/update-agent.ts +13 -0
- package/mcp-server/src/tools/update-dataset-record.ts +21 -0
- package/mcp-server/src/tools/update-dataset.ts +23 -0
- package/mcp-server/src/tools/update-evaluator.ts +30 -0
- package/mcp-server/src/tools/update-prompt.ts +31 -0
- package/mcp-server/src/tools/update-scenario.ts +32 -0
- package/mcp-server/src/tools/update-suite.ts +44 -0
- package/mcp-server/src/utils/date-parsing.ts +31 -0
- package/mcp-server/src/utils/escape-markdown.ts +12 -0
- package/mcp-server/tsconfig.json +27 -0
- package/mcp-server/uv.lock +2731 -0
- package/package.json +2 -6
- package/packages/server/dist/cli.cjs +299 -177
- package/cmd/service/main.go +0 -68
- package/go.mod +0 -117
- package/go.sum +0 -299
- package/pkg/breaker/breaker.go +0 -157
- package/pkg/breaker/breaker_test.go +0 -131
- package/pkg/clog/LICENSE +0 -26
- package/pkg/clog/clog.go +0 -90
- package/pkg/clog/clog_test.go +0 -56
- package/pkg/clog/panic.go +0 -39
- package/pkg/config/LICENSE +0 -26
- package/pkg/config/config.go +0 -86
- package/pkg/config/config_test.go +0 -70
- package/pkg/config/otel.go +0 -50
- package/pkg/config/server.go +0 -61
- package/pkg/config/validate.go +0 -80
- package/pkg/config/validate_test.go +0 -74
- package/pkg/contexts/contexts_test.go +0 -34
- package/pkg/contexts/request_id.go +0 -1
- package/pkg/contexts/service_info.go +0 -33
- package/pkg/errfuncs/errfuncs.go +0 -9
- package/pkg/errfuncs/errfuncs_test.go +0 -28
- package/pkg/forkedcontext/forkedcontext.go +0 -57
- package/pkg/health/health.go +0 -123
- package/pkg/health/health_test.go +0 -84
- package/pkg/herr/LICENSE +0 -26
- package/pkg/herr/code.go +0 -14
- package/pkg/herr/herr.go +0 -112
- package/pkg/herr/herr_test.go +0 -78
- package/pkg/herr/http.go +0 -133
- package/pkg/herr/http_test.go +0 -103
- package/pkg/herr/validate.go +0 -72
- package/pkg/herr/validate_test.go +0 -75
- package/pkg/httpmiddleware/bearer.go +0 -47
- package/pkg/httpmiddleware/httputil_test.go +0 -167
- package/pkg/httpmiddleware/inflight.go +0 -23
- package/pkg/httpmiddleware/maxbody.go +0 -30
- package/pkg/httpmiddleware/recover.go +0 -38
- package/pkg/httpmiddleware/requestid.go +0 -40
- package/pkg/httpmiddleware/telemetry.go +0 -96
- package/pkg/httpmiddleware/version.go +0 -16
- package/pkg/jwtverify/verifier.go +0 -72
- package/pkg/jwtverify/verifier_test.go +0 -134
- package/pkg/ksuid/LICENSE +0 -26
- package/pkg/ksuid/ksuid.go +0 -157
- package/pkg/ksuid/ksuid_test.go +0 -107
- package/pkg/ksuid/resources.go +0 -13
- package/pkg/lifecycle/group.go +0 -175
- package/pkg/lifecycle/group_test.go +0 -236
- package/pkg/lifecycle/service.go +0 -112
- package/pkg/netprobe/netprobe.go +0 -89
- package/pkg/netprobe/netprobe_test.go +0 -55
- package/pkg/otelsetup/otelsetup.go +0 -226
- package/pkg/otelsetup/otelsetup_test.go +0 -130
- package/pkg/ptr/LICENSE +0 -26
- package/pkg/ptr/ptr.go +0 -34
- package/pkg/ptr/ptr_test.go +0 -66
- package/pkg/retry/bench_test.go +0 -67
- package/pkg/retry/retry.go +0 -188
- package/pkg/retry/retry_test.go +0 -222
- package/pkg/slicefuncs/LICENSE +0 -26
- package/pkg/slicefuncs/slicefuncs.go +0 -10
- package/pkg/slicefuncs/slicefuncs_test.go +0 -29
- package/pkg/stacktrace/LICENSE +0 -26
- package/pkg/stacktrace/frames.go +0 -77
- package/pkg/stacktrace/frames_test.go +0 -73
- package/services/aigateway/BENCHMARKS.md +0 -110
- package/services/aigateway/README.md +0 -156
- package/services/aigateway/adapters/authresolver/bench_test.go +0 -13
- package/services/aigateway/adapters/authresolver/redis.go +0 -61
- package/services/aigateway/adapters/authresolver/service.go +0 -442
- package/services/aigateway/adapters/authresolver/service_test.go +0 -435
- package/services/aigateway/adapters/budget/bench_test.go +0 -50
- package/services/aigateway/adapters/budget/budget.go +0 -59
- package/services/aigateway/adapters/cacherules/evaluator.go +0 -134
- package/services/aigateway/adapters/cacherules/evaluator_test.go +0 -207
- package/services/aigateway/adapters/controlplane/bench_test.go +0 -40
- package/services/aigateway/adapters/controlplane/client.go +0 -213
- package/services/aigateway/adapters/controlplane/client_test.go +0 -73
- package/services/aigateway/adapters/controlplane/config_wire.go +0 -310
- package/services/aigateway/adapters/controlplane/guardrails.go +0 -88
- package/services/aigateway/adapters/controlplane/signer.go +0 -95
- package/services/aigateway/adapters/controlplane/signer_test.go +0 -64
- package/services/aigateway/adapters/customertracebridge/context.go +0 -48
- package/services/aigateway/adapters/customertracebridge/context_test.go +0 -24
- package/services/aigateway/adapters/customertracebridge/emitter.go +0 -329
- package/services/aigateway/adapters/customertracebridge/emitter_test.go +0 -93
- package/services/aigateway/adapters/customertracebridge/registry.go +0 -82
- package/services/aigateway/adapters/customertracebridge/transport.go +0 -122
- package/services/aigateway/adapters/gatewaytracer/attrs.go +0 -28
- package/services/aigateway/adapters/gatewaytracer/attrs_genai.go +0 -24
- package/services/aigateway/adapters/gatewaytracer/headers.go +0 -8
- package/services/aigateway/adapters/gatewaytracer/tracer.go +0 -101
- package/services/aigateway/adapters/httpapi/bench_test.go +0 -83
- package/services/aigateway/adapters/httpapi/middleware.go +0 -123
- package/services/aigateway/adapters/httpapi/router.go +0 -635
- package/services/aigateway/adapters/httpapi/router_test.go +0 -633
- package/services/aigateway/adapters/modelresolver/resolver.go +0 -107
- package/services/aigateway/adapters/modelresolver/resolver_test.go +0 -140
- package/services/aigateway/adapters/policy/matcher.go +0 -250
- package/services/aigateway/adapters/policy/matcher_test.go +0 -124
- package/services/aigateway/adapters/providers/bifrost.go +0 -798
- package/services/aigateway/adapters/providers/bifrost_parser.go +0 -201
- package/services/aigateway/adapters/providers/bifrost_test.go +0 -181
- package/services/aigateway/adapters/ratelimit/limiter.go +0 -122
- package/services/aigateway/adapters/ratelimit/limiter_test.go +0 -81
- package/services/aigateway/app/app.go +0 -104
- package/services/aigateway/app/dispatch.go +0 -89
- package/services/aigateway/app/dispatch_test.go +0 -475
- package/services/aigateway/app/handlers.go +0 -79
- package/services/aigateway/app/peek_bench_test.go +0 -21
- package/services/aigateway/app/pipeline/bench_test.go +0 -34
- package/services/aigateway/app/pipeline/budget.go +0 -55
- package/services/aigateway/app/pipeline/cache.go +0 -34
- package/services/aigateway/app/pipeline/cachecontrol.go +0 -86
- package/services/aigateway/app/pipeline/cachecontrol_test.go +0 -110
- package/services/aigateway/app/pipeline/guardrail.go +0 -121
- package/services/aigateway/app/pipeline/pipeline.go +0 -159
- package/services/aigateway/app/pipeline/policy.go +0 -23
- package/services/aigateway/app/pipeline/ratelimit.go +0 -21
- package/services/aigateway/app/pipeline/rawframing_test.go +0 -67
- package/services/aigateway/app/pipeline/resolve.go +0 -44
- package/services/aigateway/app/pipeline/trace.go +0 -129
- package/services/aigateway/app/ports.go +0 -61
- package/services/aigateway/cmd/root.go +0 -42
- package/services/aigateway/config.go +0 -86
- package/services/aigateway/deps.go +0 -177
- package/services/aigateway/domain/bundle.go +0 -203
- package/services/aigateway/domain/errors.go +0 -23
- package/services/aigateway/domain/model.go +0 -24
- package/services/aigateway/domain/provider.go +0 -38
- package/services/aigateway/domain/request.go +0 -65
- package/services/aigateway/domain/response.go +0 -56
- package/services/aigateway/domain/verdict.go +0 -55
- package/services/aigateway/serve.go +0 -45
- package/services/aigateway/tests/matrix/README.md +0 -71
- package/services/aigateway/tests/matrix/anthropic_test.go +0 -61
- package/services/aigateway/tests/matrix/azure_test.go +0 -52
- package/services/aigateway/tests/matrix/bedrock_test.go +0 -69
- package/services/aigateway/tests/matrix/gemini_test.go +0 -117
- package/services/aigateway/tests/matrix/matrix_test.go +0 -601
- package/services/aigateway/tests/matrix/openai_test.go +0 -66
- package/services/aigateway/tests/matrix/vertex_test.go +0 -160
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getScenario as apiGetScenario } from "../langwatch-api-scenarios.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the get_scenario MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Retrieves a specific scenario by ID and formats it as
|
|
7
|
+
* AI-readable markdown or raw JSON.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleGetScenario(params: {
|
|
10
|
+
scenarioId: string;
|
|
11
|
+
format?: "digest" | "json";
|
|
12
|
+
}): Promise<string> {
|
|
13
|
+
const scenario = await apiGetScenario(params.scenarioId);
|
|
14
|
+
|
|
15
|
+
if (params.format === "json") {
|
|
16
|
+
return JSON.stringify(scenario, null, 2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const lines: string[] = [];
|
|
20
|
+
lines.push(`# Scenario: ${scenario.name}\n`);
|
|
21
|
+
lines.push(`**ID**: ${scenario.id}`);
|
|
22
|
+
lines.push(`**Situation**: ${scenario.situation}`);
|
|
23
|
+
|
|
24
|
+
if (Array.isArray(scenario.criteria) && scenario.criteria.length > 0) {
|
|
25
|
+
lines.push("\n## Criteria");
|
|
26
|
+
for (const criterion of scenario.criteria) {
|
|
27
|
+
lines.push(`- ${criterion}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (Array.isArray(scenario.labels) && scenario.labels.length > 0) {
|
|
32
|
+
lines.push(`\n**Labels**: ${scenario.labels.join(", ")}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getSimulationRun as apiGetSimulationRun } from "../langwatch-api-simulation-runs.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_get_simulation_run MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleGetSimulationRun(params: {
|
|
7
|
+
scenarioRunId: string;
|
|
8
|
+
format?: "digest" | "json";
|
|
9
|
+
}): Promise<string> {
|
|
10
|
+
const run = await apiGetSimulationRun(params.scenarioRunId);
|
|
11
|
+
|
|
12
|
+
if (params.format === "json") {
|
|
13
|
+
return JSON.stringify(run, null, 2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const lines: string[] = [];
|
|
17
|
+
lines.push(`# Simulation Run: ${run.name ?? run.scenarioRunId}\n`);
|
|
18
|
+
lines.push(`**Run ID**: ${run.scenarioRunId}`);
|
|
19
|
+
lines.push(`**Scenario ID**: ${run.scenarioId}`);
|
|
20
|
+
lines.push(`**Batch ID**: ${run.batchRunId}`);
|
|
21
|
+
lines.push(`**Status**: ${run.status}`);
|
|
22
|
+
|
|
23
|
+
const duration = run.durationInMs > 0 ? `${(run.durationInMs / 1000).toFixed(1)}s` : "—";
|
|
24
|
+
lines.push(`**Duration**: ${duration}`);
|
|
25
|
+
if (run.totalCost) {
|
|
26
|
+
lines.push(`**Cost**: $${run.totalCost.toFixed(4)}`);
|
|
27
|
+
}
|
|
28
|
+
lines.push(`**Started**: ${new Date(run.timestamp).toISOString()}`);
|
|
29
|
+
|
|
30
|
+
if (run.results) {
|
|
31
|
+
lines.push("\n## Results");
|
|
32
|
+
if (run.results.verdict) {
|
|
33
|
+
lines.push(`**Verdict**: ${run.results.verdict}`);
|
|
34
|
+
}
|
|
35
|
+
if (run.results.reasoning) {
|
|
36
|
+
lines.push(`**Reasoning**: ${run.results.reasoning}`);
|
|
37
|
+
}
|
|
38
|
+
if (run.results.metCriteria && run.results.metCriteria.length > 0) {
|
|
39
|
+
lines.push(`**Met Criteria**: ${run.results.metCriteria.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
if (run.results.unmetCriteria && run.results.unmetCriteria.length > 0) {
|
|
42
|
+
lines.push(`**Unmet Criteria**: ${run.results.unmetCriteria.join(", ")}`);
|
|
43
|
+
}
|
|
44
|
+
if (run.results.error) {
|
|
45
|
+
lines.push(`**Error**: ${run.results.error}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (run.messages && run.messages.length > 0) {
|
|
50
|
+
lines.push("\n## Conversation");
|
|
51
|
+
for (const msg of run.messages) {
|
|
52
|
+
const content = msg.content.length > 300
|
|
53
|
+
? msg.content.slice(0, 300) + "..."
|
|
54
|
+
: msg.content;
|
|
55
|
+
lines.push(`**[${msg.role}]**: ${content}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return lines.join("\n");
|
|
60
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getSuite as apiGetSuite } from "../langwatch-api-suites.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_get_suite MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleGetSuite(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
format?: "digest" | "json";
|
|
9
|
+
}): Promise<string> {
|
|
10
|
+
const suite = await apiGetSuite(params.id);
|
|
11
|
+
|
|
12
|
+
if (params.format === "json") {
|
|
13
|
+
return JSON.stringify(suite, null, 2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const lines: string[] = [];
|
|
17
|
+
lines.push(`# Suite: ${suite.name}\n`);
|
|
18
|
+
lines.push(`**ID**: ${suite.id}`);
|
|
19
|
+
lines.push(`**Slug**: ${suite.slug}`);
|
|
20
|
+
lines.push(`**Description**: ${suite.description ?? "—"}`);
|
|
21
|
+
lines.push(`**Repeat Count**: ${suite.repeatCount}`);
|
|
22
|
+
lines.push(`**Created**: ${suite.createdAt}`);
|
|
23
|
+
lines.push(`**Updated**: ${suite.updatedAt}`);
|
|
24
|
+
|
|
25
|
+
if (suite.labels.length > 0) {
|
|
26
|
+
lines.push(`**Labels**: ${suite.labels.join(", ")}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
lines.push("\n## Scenarios");
|
|
30
|
+
for (const id of suite.scenarioIds) {
|
|
31
|
+
lines.push(`- ${id}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
lines.push("\n## Targets");
|
|
35
|
+
for (const t of suite.targets) {
|
|
36
|
+
lines.push(`- ${t.type}:${t.referenceId}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const totalJobs = suite.scenarioIds.length * suite.targets.length * suite.repeatCount;
|
|
40
|
+
lines.push(`\n**Total jobs per run**: ${totalJobs}`);
|
|
41
|
+
|
|
42
|
+
lines.push(
|
|
43
|
+
"\n> Use `platform_run_suite` to trigger a run, or `platform_update_suite` to modify."
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getTraceById as apiGetTraceById } from "../langwatch-api.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the get_trace MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Retrieves a single trace by ID. In digest mode (default), returns the
|
|
7
|
+
* AI-readable formatted digest. In json mode, returns the full raw JSON.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleGetTrace(params: {
|
|
10
|
+
traceId: string;
|
|
11
|
+
format?: "digest" | "json";
|
|
12
|
+
}): Promise<string> {
|
|
13
|
+
const format = params.format ?? "digest";
|
|
14
|
+
const result = await apiGetTraceById(params.traceId, format);
|
|
15
|
+
|
|
16
|
+
if (format === "json") {
|
|
17
|
+
return JSON.stringify(result, null, 2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const lines: string[] = [];
|
|
21
|
+
lines.push(`# Trace: ${params.traceId}\n`);
|
|
22
|
+
|
|
23
|
+
if (result.timestamps) {
|
|
24
|
+
lines.push(`**Started**: ${result.timestamps.started_at}`);
|
|
25
|
+
if (result.timestamps.updated_at)
|
|
26
|
+
lines.push(`**Updated**: ${result.timestamps.updated_at}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (result.metadata) {
|
|
30
|
+
const meta = result.metadata;
|
|
31
|
+
if (meta.user_id) lines.push(`**User**: ${meta.user_id}`);
|
|
32
|
+
if (meta.thread_id) lines.push(`**Thread**: ${meta.thread_id}`);
|
|
33
|
+
if (meta.customer_id) lines.push(`**Customer**: ${meta.customer_id}`);
|
|
34
|
+
if (meta.labels?.length) lines.push(`**Labels**: ${meta.labels.join(", ")}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (result.evaluations && result.evaluations.length > 0) {
|
|
38
|
+
lines.push("\n## Evaluations");
|
|
39
|
+
for (const evaluation of result.evaluations) {
|
|
40
|
+
const status =
|
|
41
|
+
evaluation.passed === true
|
|
42
|
+
? "PASSED"
|
|
43
|
+
: evaluation.passed === false
|
|
44
|
+
? "FAILED"
|
|
45
|
+
: "N/A";
|
|
46
|
+
lines.push(
|
|
47
|
+
`- **${evaluation.name || evaluation.evaluator_id}**: ${status}${evaluation.score != null ? ` (score: ${evaluation.score})` : ""}${evaluation.label ? ` [${evaluation.label}]` : ""}`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (result.formatted_trace) {
|
|
53
|
+
lines.push(`\n## Trace Details\n${result.formatted_trace}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
lines.push(
|
|
57
|
+
'\n> Tip: Use `get_trace` with `format: "json"` to get the full raw trace data.'
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getWorkflow as apiGetWorkflow } from "../langwatch-api-workflows.js";
|
|
2
|
+
|
|
3
|
+
export async function handleGetWorkflow(params: { id: string }): Promise<string> {
|
|
4
|
+
const workflow = await apiGetWorkflow(params.id);
|
|
5
|
+
|
|
6
|
+
const lines: string[] = [];
|
|
7
|
+
lines.push(`# ${workflow.name}\n`);
|
|
8
|
+
lines.push(`**ID**: ${workflow.id}`);
|
|
9
|
+
if (workflow.description) lines.push(`**Description**: ${workflow.description}`);
|
|
10
|
+
if (workflow.icon) lines.push(`**Icon**: ${workflow.icon}`);
|
|
11
|
+
lines.push(`**Evaluator**: ${workflow.isEvaluator ? "yes" : "no"}`);
|
|
12
|
+
lines.push(`**Component**: ${workflow.isComponent ? "yes" : "no"}`);
|
|
13
|
+
lines.push(`**Created**: ${workflow.createdAt}`);
|
|
14
|
+
lines.push(`**Updated**: ${workflow.updatedAt}`);
|
|
15
|
+
|
|
16
|
+
return lines.join("\n");
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { listAgents as apiListAgents } from "../langwatch-api-agents.js";
|
|
2
|
+
|
|
3
|
+
export async function handleListAgents(): Promise<string> {
|
|
4
|
+
const result = await apiListAgents({ limit: 100 });
|
|
5
|
+
const agents = result.data;
|
|
6
|
+
|
|
7
|
+
if (!Array.isArray(agents) || agents.length === 0) {
|
|
8
|
+
return "No agents found in this project.\n\n> Tip: Use `platform_create_agent` to create your first agent.";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const lines: string[] = [];
|
|
12
|
+
lines.push(`# Agents (${result.pagination.total} total)\n`);
|
|
13
|
+
|
|
14
|
+
for (const a of agents) {
|
|
15
|
+
lines.push(`## ${a.name}`);
|
|
16
|
+
lines.push(`**ID**: ${a.id}`);
|
|
17
|
+
lines.push(`**Type**: ${a.type}`);
|
|
18
|
+
lines.push(`**Updated**: ${a.updatedAt}`);
|
|
19
|
+
lines.push("");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
lines.push(
|
|
23
|
+
"> Use `platform_get_agent` with the ID to see full agent details including config.",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return lines.join("\n");
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listAnnotations as apiListAnnotations,
|
|
3
|
+
getAnnotationsByTrace as apiGetByTrace,
|
|
4
|
+
} from "../langwatch-api-annotations.js";
|
|
5
|
+
|
|
6
|
+
export async function handleListAnnotations(params: {
|
|
7
|
+
traceId?: string;
|
|
8
|
+
}): Promise<string> {
|
|
9
|
+
const annotations = params.traceId
|
|
10
|
+
? await apiGetByTrace(params.traceId)
|
|
11
|
+
: await apiListAnnotations();
|
|
12
|
+
|
|
13
|
+
if (!Array.isArray(annotations) || annotations.length === 0) {
|
|
14
|
+
return params.traceId
|
|
15
|
+
? `No annotations found for trace "${params.traceId}".\n\n> Tip: Use \`platform_create_annotation\` to annotate a trace.`
|
|
16
|
+
: "No annotations found in this project.\n\n> Tip: Use `platform_create_annotation` to annotate a trace.";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const lines: string[] = [];
|
|
20
|
+
lines.push(`# Annotations (${annotations.length} total)\n`);
|
|
21
|
+
|
|
22
|
+
for (const a of annotations) {
|
|
23
|
+
const rating = a.isThumbsUp === true ? "👍" : a.isThumbsUp === false ? "👎" : "—";
|
|
24
|
+
lines.push(`## Annotation ${a.id ?? "—"}`);
|
|
25
|
+
lines.push(`**Trace ID**: ${a.traceId ?? "—"}`);
|
|
26
|
+
lines.push(`**Rating**: ${rating}`);
|
|
27
|
+
if (a.comment) lines.push(`**Comment**: ${a.comment}`);
|
|
28
|
+
if (a.email) lines.push(`**By**: ${a.email}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return lines.join("\n");
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { listDashboards as apiListDashboards } from "../langwatch-api-dashboards.js";
|
|
2
|
+
|
|
3
|
+
export async function handleListDashboards(): Promise<string> {
|
|
4
|
+
const result = await apiListDashboards();
|
|
5
|
+
const dashboards = result.data;
|
|
6
|
+
|
|
7
|
+
if (!Array.isArray(dashboards) || dashboards.length === 0) {
|
|
8
|
+
return "No dashboards found in this project.\n\n> Tip: Use `platform_create_dashboard` to create a new dashboard.";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const lines: string[] = [];
|
|
12
|
+
lines.push(`# Dashboards (${dashboards.length} total)\n`);
|
|
13
|
+
|
|
14
|
+
for (const d of dashboards) {
|
|
15
|
+
lines.push(`## ${d.name}`);
|
|
16
|
+
lines.push(`**ID**: ${d.id}`);
|
|
17
|
+
lines.push(`**Graphs**: ${d.graphCount}`);
|
|
18
|
+
lines.push(`**Updated**: ${d.updatedAt}`);
|
|
19
|
+
lines.push("");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
lines.push(
|
|
23
|
+
"> Use `platform_get_dashboard` with the ID to see dashboard details including graphs.",
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return lines.join("\n");
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listDatasetRecords as apiListDatasetRecords,
|
|
3
|
+
} from "../langwatch-api-datasets.js";
|
|
4
|
+
import { escapeMarkdown } from "../utils/escape-markdown.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles the platform_list_dataset_records MCP tool invocation.
|
|
8
|
+
*
|
|
9
|
+
* Lists records in a dataset with pagination support.
|
|
10
|
+
*/
|
|
11
|
+
export async function handleListDatasetRecords(params: {
|
|
12
|
+
slugOrId: string;
|
|
13
|
+
page?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
format?: "digest" | "json";
|
|
16
|
+
}): Promise<string> {
|
|
17
|
+
const response = await apiListDatasetRecords({
|
|
18
|
+
slugOrId: params.slugOrId,
|
|
19
|
+
page: params.page,
|
|
20
|
+
limit: params.limit,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (params.format === "json") {
|
|
24
|
+
return JSON.stringify(response, null, 2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { data: records, pagination } = response;
|
|
28
|
+
|
|
29
|
+
if (records.length === 0) {
|
|
30
|
+
return "No records found in this dataset.";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const lines: string[] = [];
|
|
34
|
+
lines.push(`# Records (page ${pagination.page} of ${pagination.totalPages}, ${pagination.total} total)\n`);
|
|
35
|
+
|
|
36
|
+
for (const record of records) {
|
|
37
|
+
lines.push(`**${escapeMarkdown(record.id)}**: ${escapeMarkdown(JSON.stringify(record.entry))}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (pagination.page < pagination.totalPages) {
|
|
41
|
+
lines.push("");
|
|
42
|
+
lines.push(`> Use \`platform_list_dataset_records\` with \`page: ${pagination.page + 1}\` to see the next page.`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return lines.join("\n");
|
|
46
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listDatasets as apiListDatasets,
|
|
3
|
+
type DatasetSummary,
|
|
4
|
+
} from "../langwatch-api-datasets.js";
|
|
5
|
+
import { escapeMarkdown } from "../utils/escape-markdown.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Fetches all datasets by paginating through the API until every page
|
|
9
|
+
* has been retrieved.
|
|
10
|
+
*
|
|
11
|
+
* Returns the accumulated dataset summaries along with the total count
|
|
12
|
+
* reported by the server.
|
|
13
|
+
*/
|
|
14
|
+
async function fetchAllDatasets(): Promise<{
|
|
15
|
+
datasets: DatasetSummary[];
|
|
16
|
+
total: number;
|
|
17
|
+
}> {
|
|
18
|
+
const PAGE_SIZE = 100;
|
|
19
|
+
const datasets: DatasetSummary[] = [];
|
|
20
|
+
let page = 1;
|
|
21
|
+
let total = 0;
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- loop until break
|
|
24
|
+
while (true) {
|
|
25
|
+
const response = await apiListDatasets({ page, limit: PAGE_SIZE });
|
|
26
|
+
total = response.pagination.total;
|
|
27
|
+
datasets.push(...response.data);
|
|
28
|
+
|
|
29
|
+
if (datasets.length >= total || response.data.length === 0) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
page++;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { datasets, total };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Handles the platform_list_datasets MCP tool invocation.
|
|
40
|
+
*
|
|
41
|
+
* Lists all datasets in the LangWatch project, formatted as an
|
|
42
|
+
* AI-readable digest or raw JSON.
|
|
43
|
+
*/
|
|
44
|
+
export async function handleListDatasets(params: {
|
|
45
|
+
format?: "digest" | "json";
|
|
46
|
+
} = {}): Promise<string> {
|
|
47
|
+
if (params.format === "json") {
|
|
48
|
+
const { datasets, total } = await fetchAllDatasets();
|
|
49
|
+
return JSON.stringify({ data: datasets, total }, null, 2);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { datasets, total } = await fetchAllDatasets();
|
|
53
|
+
|
|
54
|
+
if (datasets.length === 0) {
|
|
55
|
+
return "No datasets found in this project.\n\n> Tip: Use `platform_create_dataset` to create your first dataset.";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const lines: string[] = [];
|
|
59
|
+
lines.push(`# Datasets (${total} total)\n`);
|
|
60
|
+
|
|
61
|
+
for (const ds of datasets) {
|
|
62
|
+
lines.push(`## ${escapeMarkdown(ds.name)}`);
|
|
63
|
+
lines.push(`**Slug**: ${escapeMarkdown(ds.slug)}`);
|
|
64
|
+
lines.push(`**ID**: ${ds.id}`);
|
|
65
|
+
if (Array.isArray(ds.columnTypes) && ds.columnTypes.length > 0) {
|
|
66
|
+
const colNames = ds.columnTypes.map((c) => c.name).join(", ");
|
|
67
|
+
lines.push(`**Columns**: ${colNames}`);
|
|
68
|
+
}
|
|
69
|
+
lines.push(
|
|
70
|
+
`**Records**: ${ds.recordCount ?? "unknown"}`,
|
|
71
|
+
);
|
|
72
|
+
lines.push("");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
lines.push(
|
|
76
|
+
"> Use `platform_get_dataset` with the slug to see full dataset details and records.",
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return lines.join("\n");
|
|
80
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listEvaluators as apiListEvaluators,
|
|
3
|
+
getEvaluatorType,
|
|
4
|
+
} from "../langwatch-api-evaluators.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles the platform_list_evaluators MCP tool invocation.
|
|
8
|
+
*
|
|
9
|
+
* Lists all evaluators in the LangWatch project, formatted as an
|
|
10
|
+
* AI-readable digest.
|
|
11
|
+
*/
|
|
12
|
+
export async function handleListEvaluators(): Promise<string> {
|
|
13
|
+
const evaluators = await apiListEvaluators();
|
|
14
|
+
|
|
15
|
+
if (!Array.isArray(evaluators) || evaluators.length === 0) {
|
|
16
|
+
return "No evaluators found in this project.\n\n> Tip: Use `platform_create_evaluator` to create your first evaluator. Call `discover_schema({ category: 'evaluators' })` to see available evaluator types.";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const lines: string[] = [];
|
|
20
|
+
lines.push(`# Evaluators (${evaluators.length} total)\n`);
|
|
21
|
+
|
|
22
|
+
for (const e of evaluators) {
|
|
23
|
+
const evaluatorType = getEvaluatorType(e);
|
|
24
|
+
lines.push(`## ${e.name}`);
|
|
25
|
+
lines.push(`**ID**: ${e.id}`);
|
|
26
|
+
if (e.slug) lines.push(`**Slug**: ${e.slug}`);
|
|
27
|
+
if (evaluatorType) lines.push(`**Type**: ${evaluatorType}`);
|
|
28
|
+
lines.push(`**Kind**: ${e.type}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
lines.push(
|
|
33
|
+
"> Use `platform_get_evaluator` with the ID or slug to see full evaluator details.",
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return lines.join("\n");
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { listModelProviders as apiListModelProviders } from "../langwatch-api-model-providers.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_list_model_providers MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Lists all model providers for the project, showing provider name,
|
|
7
|
+
* enabled status, and which key fields are set (masked).
|
|
8
|
+
*/
|
|
9
|
+
export async function handleListModelProviders(): Promise<string> {
|
|
10
|
+
const providers = await apiListModelProviders();
|
|
11
|
+
|
|
12
|
+
const entries = Object.entries(providers);
|
|
13
|
+
if (entries.length === 0) {
|
|
14
|
+
return "No model providers configured for this project.\n\n> Tip: Use `platform_set_model_provider` to configure an API key for a model provider.";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const lines: string[] = [];
|
|
18
|
+
lines.push(`# Model Providers (${entries.length} total)\n`);
|
|
19
|
+
|
|
20
|
+
for (const [key, provider] of entries) {
|
|
21
|
+
const status = provider.enabled ? "enabled" : "disabled";
|
|
22
|
+
lines.push(`## ${key}`);
|
|
23
|
+
lines.push(`**Status**: ${status}`);
|
|
24
|
+
|
|
25
|
+
if (provider.customKeys) {
|
|
26
|
+
const keyFields = Object.entries(provider.customKeys)
|
|
27
|
+
.map(([k, v]) => `${k}: ${v ? "set" : "not set"}`)
|
|
28
|
+
.join(", ");
|
|
29
|
+
lines.push(`**Keys**: ${keyFields}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (provider.models && provider.models.length > 0) {
|
|
33
|
+
lines.push(`**Models**: ${provider.models.length} available`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
lines.push("");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return lines.join("\n");
|
|
40
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { listPromptTags as apiListPromptTags } from "../langwatch-api.js";
|
|
2
|
+
|
|
3
|
+
export async function handleListPromptTags(): Promise<string> {
|
|
4
|
+
const tags = (await apiListPromptTags()) as Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
createdAt?: string;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
if (!tags || tags.length === 0) {
|
|
11
|
+
return "No prompt tags found. The `latest` tag is always available.";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const lines: string[] = [];
|
|
15
|
+
lines.push("# Prompt Tags\n");
|
|
16
|
+
for (const tag of tags) {
|
|
17
|
+
const created = tag.createdAt ? ` (created ${tag.createdAt})` : "";
|
|
18
|
+
lines.push(`- **${tag.name}**${created}`);
|
|
19
|
+
}
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { listPrompts as apiListPrompts } from "../langwatch-api.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_list_prompts MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Lists all prompts in the LangWatch project, formatted as an
|
|
7
|
+
* AI-readable markdown table.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleListPrompts(): Promise<string> {
|
|
10
|
+
const prompts = await apiListPrompts();
|
|
11
|
+
|
|
12
|
+
if (!Array.isArray(prompts) || prompts.length === 0) {
|
|
13
|
+
return "No prompts found in this project.";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const lines: string[] = [];
|
|
17
|
+
lines.push(`# Prompts (${prompts.length} total)\n`);
|
|
18
|
+
lines.push("| Handle | Name | Latest Version |");
|
|
19
|
+
lines.push("|--------|------|----------------|");
|
|
20
|
+
|
|
21
|
+
for (const p of prompts) {
|
|
22
|
+
const handle = p.handle || p.id || "N/A";
|
|
23
|
+
const name = p.name || "Untitled";
|
|
24
|
+
const versionNum = p.latestVersionNumber ?? p.version;
|
|
25
|
+
const version = versionNum != null ? `v${versionNum}` : "N/A";
|
|
26
|
+
lines.push(`| ${handle} | ${name} | ${version} |`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
lines.push(
|
|
30
|
+
"\n> Use `platform_get_prompt` with the handle or ID to see full prompt details."
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return lines.join("\n");
|
|
34
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { listScenarios as apiListScenarios } from "../langwatch-api-scenarios.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_list_scenarios MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Lists all scenarios in the LangWatch project, formatted as an
|
|
7
|
+
* AI-readable digest or raw JSON.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleListScenarios(params: {
|
|
10
|
+
format?: "digest" | "json";
|
|
11
|
+
}): Promise<string> {
|
|
12
|
+
const scenarios = await apiListScenarios();
|
|
13
|
+
|
|
14
|
+
if (params.format === "json") {
|
|
15
|
+
return JSON.stringify(scenarios, null, 2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!Array.isArray(scenarios) || scenarios.length === 0) {
|
|
19
|
+
return "No scenarios found in this project.\n\n> Tip: Use `platform_create_scenario` to create your first scenario.";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const lines: string[] = [];
|
|
23
|
+
lines.push(`# Scenarios (${scenarios.length} total)\n`);
|
|
24
|
+
|
|
25
|
+
for (const s of scenarios) {
|
|
26
|
+
lines.push(`## ${s.name}`);
|
|
27
|
+
lines.push(`**ID**: ${s.id}`);
|
|
28
|
+
const preview =
|
|
29
|
+
s.situation && s.situation.length > 60
|
|
30
|
+
? s.situation.slice(0, 60) + "..."
|
|
31
|
+
: s.situation;
|
|
32
|
+
lines.push(`**Situation**: ${preview}`);
|
|
33
|
+
lines.push(
|
|
34
|
+
`**Criteria**: ${Array.isArray(s.criteria) ? s.criteria.length : 0} criteria`,
|
|
35
|
+
);
|
|
36
|
+
if (Array.isArray(s.labels) && s.labels.length > 0) {
|
|
37
|
+
lines.push(`**Labels**: ${s.labels.join(", ")}`);
|
|
38
|
+
}
|
|
39
|
+
lines.push("");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
lines.push(
|
|
43
|
+
"> Use `platform_get_scenario` with the ID to see full scenario details.",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { listSimulationRuns as apiListSimulationRuns } from "../langwatch-api-simulation-runs.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_list_simulation_runs MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleListSimulationRuns(params: {
|
|
7
|
+
scenarioSetId?: string;
|
|
8
|
+
batchRunId?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
format?: "digest" | "json";
|
|
11
|
+
}): Promise<string> {
|
|
12
|
+
const result = await apiListSimulationRuns({
|
|
13
|
+
scenarioSetId: params.scenarioSetId,
|
|
14
|
+
batchRunId: params.batchRunId,
|
|
15
|
+
limit: params.limit,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (params.format === "json") {
|
|
19
|
+
return JSON.stringify(result, null, 2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { runs } = result;
|
|
23
|
+
|
|
24
|
+
if (runs.length === 0) {
|
|
25
|
+
return "No simulation runs found.\n\n> Run a suite first with `platform_run_suite` to create simulation runs.";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const lines: string[] = [];
|
|
29
|
+
lines.push(`# Simulation Runs (${runs.length} results${result.hasMore ? ", more available" : ""})\n`);
|
|
30
|
+
|
|
31
|
+
for (const run of runs) {
|
|
32
|
+
const statusIcon = run.status === "SUCCESS" ? "pass" : run.status === "FAILED" ? "FAIL" : run.status;
|
|
33
|
+
const duration = run.durationInMs > 0 ? `${(run.durationInMs / 1000).toFixed(1)}s` : "—";
|
|
34
|
+
const verdict = run.results?.verdict ?? "";
|
|
35
|
+
|
|
36
|
+
lines.push(`## ${run.name ?? run.scenarioId} — ${statusIcon}${verdict ? ` (${verdict})` : ""}`);
|
|
37
|
+
lines.push(`**Run ID**: ${run.scenarioRunId}`);
|
|
38
|
+
lines.push(`**Batch**: ${run.batchRunId}`);
|
|
39
|
+
lines.push(`**Duration**: ${duration}`);
|
|
40
|
+
if (run.totalCost) {
|
|
41
|
+
lines.push(`**Cost**: $${run.totalCost.toFixed(4)}`);
|
|
42
|
+
}
|
|
43
|
+
lines.push("");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
lines.push("> Use `platform_get_simulation_run` with a run ID to see full details (messages, results).");
|
|
47
|
+
|
|
48
|
+
return lines.join("\n");
|
|
49
|
+
}
|