@langwatch/server 3.1.0-beta.4 → 3.1.0-beta.6
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/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 -1
- package/packages/server/dist/cli.cjs +1 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Organization, Project, Team, User } from "@prisma/client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prisma `include` shape used by the Backoffice Users list to resolve every
|
|
5
|
+
* project each user can see in the main app's project switcher.
|
|
6
|
+
*
|
|
7
|
+
* The visibility rule mirrors the main app (see
|
|
8
|
+
* `organization.prisma.repository.ts#getAllForUser`): a user's project
|
|
9
|
+
* visibility comes from their org memberships → org.teams → team.projects.
|
|
10
|
+
* A TeamUser row is NOT required. Historically the Backoffice walked
|
|
11
|
+
* teamMemberships instead, which meant users who had an OrganizationUser
|
|
12
|
+
* but no TeamUser rendered with an empty Projects column even though the
|
|
13
|
+
* main app happily showed those projects in their switcher.
|
|
14
|
+
*
|
|
15
|
+
* Non-archived teams and projects only — archived rows must not leak onto
|
|
16
|
+
* the admin table either.
|
|
17
|
+
*/
|
|
18
|
+
export const USER_BACKOFFICE_INCLUDE = {
|
|
19
|
+
orgMemberships: {
|
|
20
|
+
include: {
|
|
21
|
+
organization: {
|
|
22
|
+
include: {
|
|
23
|
+
teams: {
|
|
24
|
+
where: { archivedAt: null },
|
|
25
|
+
include: {
|
|
26
|
+
projects: { where: { archivedAt: null } },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Narrowed user shape after `USER_BACKOFFICE_INCLUDE` has been applied.
|
|
37
|
+
* Keeps the rest of the User fields intact so downstream code (like the
|
|
38
|
+
* ra-data-simple-prisma handler) can spread them through unchanged.
|
|
39
|
+
*/
|
|
40
|
+
export type UserWithBackofficeIncludes = User & {
|
|
41
|
+
orgMemberships: {
|
|
42
|
+
organization: Organization & {
|
|
43
|
+
teams: (Team & { projects: Project[] })[];
|
|
44
|
+
};
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface BackofficeOrganizationRef {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface BackofficeProjectRef {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
slug: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface BackofficeUserRow extends User {
|
|
60
|
+
organizations: BackofficeOrganizationRef[];
|
|
61
|
+
projects: BackofficeProjectRef[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Flatten a Prisma-loaded user into the row shape the Backoffice Users table
|
|
66
|
+
* renders. Dedupes across memberships so each org / project chip appears
|
|
67
|
+
* once, and traverses org → teams → projects so project visibility matches
|
|
68
|
+
* the main app's rule (org membership is enough; TeamUser is NOT required).
|
|
69
|
+
*
|
|
70
|
+
* Isolated from the Hono handler so the visibility rule can be pinned with
|
|
71
|
+
* a plain unit test — the regression we care about here is "a user with an
|
|
72
|
+
* OrganizationUser but no TeamUser still gets their projects", and having
|
|
73
|
+
* the traversal in a pure function means a test no longer needs the whole
|
|
74
|
+
* admin route + DB stack to prove that.
|
|
75
|
+
*/
|
|
76
|
+
export function mapUserToBackofficeRow(
|
|
77
|
+
user: UserWithBackofficeIncludes,
|
|
78
|
+
): BackofficeUserRow {
|
|
79
|
+
const orgMap = new Map<string, BackofficeOrganizationRef>();
|
|
80
|
+
const projectMap = new Map<string, BackofficeProjectRef>();
|
|
81
|
+
|
|
82
|
+
for (const membership of user.orgMemberships ?? []) {
|
|
83
|
+
const org = membership.organization;
|
|
84
|
+
if (!orgMap.has(org.id)) {
|
|
85
|
+
orgMap.set(org.id, { id: org.id, name: org.name });
|
|
86
|
+
}
|
|
87
|
+
for (const team of org.teams ?? []) {
|
|
88
|
+
for (const project of team.projects ?? []) {
|
|
89
|
+
if (!projectMap.has(project.id)) {
|
|
90
|
+
projectMap.set(project.id, {
|
|
91
|
+
id: project.id,
|
|
92
|
+
name: project.name,
|
|
93
|
+
slug: project.slug,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...user,
|
|
102
|
+
organizations: Array.from(orgMap.values()),
|
|
103
|
+
projects: Array.from(projectMap.values()),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Prisma, type PrismaClient } from "@prisma/client";
|
|
2
|
+
import { DomainError, NotFoundError } from "~/server/app-layer/domain-error";
|
|
3
|
+
import { isAdmin } from "./isAdmin";
|
|
4
|
+
|
|
5
|
+
/** Impersonation window handed to the UI once a start call succeeds. */
|
|
6
|
+
const IMPERSONATION_TTL_MS = 1000 * 60 * 60; // 1 hour
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when an admin attempts to impersonate a deactivated user. These
|
|
10
|
+
* accounts have had their sessions revoked intentionally — allowing an
|
|
11
|
+
* admin to re-enter them would defeat the revocation. Maps to HTTP 400
|
|
12
|
+
* because the request itself is well-formed; only the target state is wrong.
|
|
13
|
+
*/
|
|
14
|
+
export class CannotImpersonateDeactivatedUserError extends DomainError {
|
|
15
|
+
constructor(userId: string) {
|
|
16
|
+
super(
|
|
17
|
+
"cannot_impersonate_deactivated_user",
|
|
18
|
+
"Cannot impersonate a deactivated user",
|
|
19
|
+
{ httpStatus: 400, meta: { userId } },
|
|
20
|
+
);
|
|
21
|
+
this.name = "CannotImpersonateDeactivatedUserError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when an admin tries to impersonate another admin. Prevents a
|
|
27
|
+
* malicious (or compromised) admin from hopping between admin identities
|
|
28
|
+
* and washing out the audit trail. Maps to HTTP 403 because the action is
|
|
29
|
+
* deliberately denied, not a system failure — clients should render an
|
|
30
|
+
* "impersonation not permitted" message, not retry.
|
|
31
|
+
*/
|
|
32
|
+
export class CannotImpersonateAdminError extends DomainError {
|
|
33
|
+
constructor(userId: string) {
|
|
34
|
+
super(
|
|
35
|
+
"cannot_impersonate_admin",
|
|
36
|
+
"Cannot impersonate another admin",
|
|
37
|
+
{ httpStatus: 403, meta: { userId } },
|
|
38
|
+
);
|
|
39
|
+
this.name = "CannotImpersonateAdminError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Thrown when the requested impersonation target does not exist in the DB.
|
|
45
|
+
* Maps to HTTP 404.
|
|
46
|
+
*/
|
|
47
|
+
export class UserToImpersonateNotFoundError extends NotFoundError {
|
|
48
|
+
constructor(userId: string) {
|
|
49
|
+
super("user_to_impersonate_not_found", "User to impersonate", userId);
|
|
50
|
+
this.name = "UserToImpersonateNotFoundError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Minimum shape of the audit logger the service needs. Kept structural so
|
|
56
|
+
* tests can inject a stub without pulling the real ~/server/auditLog module
|
|
57
|
+
* and its transitive OTel/DB dependencies.
|
|
58
|
+
*/
|
|
59
|
+
export type AuditLogFn = (input: {
|
|
60
|
+
userId: string;
|
|
61
|
+
action: string;
|
|
62
|
+
args: Record<string, unknown>;
|
|
63
|
+
req: unknown;
|
|
64
|
+
}) => Promise<void>;
|
|
65
|
+
|
|
66
|
+
export interface StartImpersonationInput {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
impersonatorUserId: string;
|
|
69
|
+
userIdToImpersonate: string;
|
|
70
|
+
reason: string;
|
|
71
|
+
req: unknown;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface StopImpersonationInput {
|
|
75
|
+
sessionId: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Service that starts and stops Backoffice impersonation sessions.
|
|
80
|
+
*
|
|
81
|
+
* Lives under `ee/admin/` because impersonation is strictly an admin
|
|
82
|
+
* (Backoffice) operation — it is not exposed to regular tenants.
|
|
83
|
+
*
|
|
84
|
+
* Dependencies are injected through the constructor so both the Hono route
|
|
85
|
+
* and unit tests can supply their own `PrismaClient` and audit-log sink.
|
|
86
|
+
* Avoids reaching into the `prisma` global or the `auditLog` import from
|
|
87
|
+
* inside service logic (per the project's no-abstraction-leaks rule in
|
|
88
|
+
* `CLAUDE.md`).
|
|
89
|
+
*/
|
|
90
|
+
export class ImpersonationService {
|
|
91
|
+
constructor(
|
|
92
|
+
private readonly prisma: PrismaClient,
|
|
93
|
+
private readonly auditLog: AuditLogFn,
|
|
94
|
+
) {}
|
|
95
|
+
|
|
96
|
+
static create(prisma: PrismaClient, auditLog: AuditLogFn): ImpersonationService {
|
|
97
|
+
return new ImpersonationService(prisma, auditLog);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Start an impersonation window on an existing BetterAuth session.
|
|
102
|
+
*
|
|
103
|
+
* Validates the target user, writes an audit log entry, and stores the
|
|
104
|
+
* impersonating identity on the session row so the rest of the app can
|
|
105
|
+
* read `session.user.impersonator` through `getServerAuthSession`.
|
|
106
|
+
*
|
|
107
|
+
* Throws (and does NOT mutate the session) when:
|
|
108
|
+
* - The target user does not exist → {@link UserToImpersonateNotFoundError}
|
|
109
|
+
* - The target is deactivated → {@link CannotImpersonateDeactivatedUserError}
|
|
110
|
+
* - The target is an admin → {@link CannotImpersonateAdminError}
|
|
111
|
+
*
|
|
112
|
+
* The audit log is written before the session mutation so a DB failure
|
|
113
|
+
* during the update still leaves a trail of the *attempt* — matching the
|
|
114
|
+
* behaviour of the previous inline handler.
|
|
115
|
+
*/
|
|
116
|
+
async start(input: StartImpersonationInput): Promise<void> {
|
|
117
|
+
const target = await this.prisma.user.findUnique({
|
|
118
|
+
where: { id: input.userIdToImpersonate },
|
|
119
|
+
select: {
|
|
120
|
+
id: true,
|
|
121
|
+
name: true,
|
|
122
|
+
email: true,
|
|
123
|
+
image: true,
|
|
124
|
+
deactivatedAt: true,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (!target) {
|
|
129
|
+
throw new UserToImpersonateNotFoundError(input.userIdToImpersonate);
|
|
130
|
+
}
|
|
131
|
+
if (target.deactivatedAt) {
|
|
132
|
+
throw new CannotImpersonateDeactivatedUserError(target.id);
|
|
133
|
+
}
|
|
134
|
+
if (isAdmin(target)) {
|
|
135
|
+
throw new CannotImpersonateAdminError(target.id);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
await this.auditLog({
|
|
139
|
+
userId: input.impersonatorUserId,
|
|
140
|
+
action: "admin/impersonate",
|
|
141
|
+
args: { userIdToImpersonate: target.id, reason: input.reason },
|
|
142
|
+
req: input.req,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await this.prisma.session.update({
|
|
146
|
+
where: { id: input.sessionId },
|
|
147
|
+
data: {
|
|
148
|
+
impersonating: {
|
|
149
|
+
id: target.id,
|
|
150
|
+
name: target.name,
|
|
151
|
+
email: target.email,
|
|
152
|
+
image: target.image,
|
|
153
|
+
expires: new Date(Date.now() + IMPERSONATION_TTL_MS),
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* End the impersonation window on the given session. Idempotent at the
|
|
161
|
+
* Prisma level — clearing an already-empty `impersonating` column is a
|
|
162
|
+
* no-op.
|
|
163
|
+
*/
|
|
164
|
+
async stop(input: StopImpersonationInput): Promise<void> {
|
|
165
|
+
await this.prisma.session.update({
|
|
166
|
+
where: { id: input.sessionId },
|
|
167
|
+
data: { impersonating: Prisma.DbNull },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const isAdmin = (user: { email?: string | null }) => {
|
|
2
|
+
if (!user) return false;
|
|
3
|
+
const adminEmails = process.env.ADMIN_EMAILS;
|
|
4
|
+
if (!adminEmails || !user.email) return false;
|
|
5
|
+
const normalizedEmail = user.email.toLowerCase().trim();
|
|
6
|
+
return adminEmails
|
|
7
|
+
.split(",")
|
|
8
|
+
.some((e) => e.trim().toLowerCase() === normalizedEmail);
|
|
9
|
+
};
|