@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,281 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
isExpired,
|
|
4
|
+
parseLicenseKey,
|
|
5
|
+
validateLicense,
|
|
6
|
+
verifySignature,
|
|
7
|
+
} from "../validation";
|
|
8
|
+
import {
|
|
9
|
+
BASE_LICENSE,
|
|
10
|
+
VALID_LICENSE_KEY,
|
|
11
|
+
EXPIRED_LICENSE_KEY,
|
|
12
|
+
TAMPERED_LICENSE_KEY,
|
|
13
|
+
EMPTY_SIGNATURE_KEY,
|
|
14
|
+
MALFORMED_BASE64,
|
|
15
|
+
INVALID_JSON_BASE64,
|
|
16
|
+
GARBAGE_DATA,
|
|
17
|
+
} from "./fixtures/testLicenses";
|
|
18
|
+
import { TEST_PUBLIC_KEY, WRONG_PUBLIC_KEY } from "./fixtures/testKeys";
|
|
19
|
+
|
|
20
|
+
describe("parseLicenseKey", () => {
|
|
21
|
+
it("parses valid base64-encoded license key", () => {
|
|
22
|
+
const result = parseLicenseKey(VALID_LICENSE_KEY);
|
|
23
|
+
|
|
24
|
+
expect(result).not.toBeNull();
|
|
25
|
+
expect(result?.data.organizationName).toBe("Acme Corp");
|
|
26
|
+
expect(result?.signature).toBeDefined();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("returns null for malformed base64 input", () => {
|
|
30
|
+
const result = parseLicenseKey(MALFORMED_BASE64);
|
|
31
|
+
|
|
32
|
+
expect(result).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("returns null for valid base64 but invalid JSON", () => {
|
|
36
|
+
const result = parseLicenseKey(INVALID_JSON_BASE64);
|
|
37
|
+
|
|
38
|
+
expect(result).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("returns null for empty license key", () => {
|
|
42
|
+
const result = parseLicenseKey("");
|
|
43
|
+
|
|
44
|
+
expect(result).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("returns null for whitespace-only license key", () => {
|
|
48
|
+
const result = parseLicenseKey(" ");
|
|
49
|
+
|
|
50
|
+
expect(result).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("returns null for valid JSON but missing required fields", () => {
|
|
54
|
+
const invalidStructure = Buffer.from(
|
|
55
|
+
JSON.stringify({ foo: "bar" })
|
|
56
|
+
).toString("base64");
|
|
57
|
+
|
|
58
|
+
const result = parseLicenseKey(invalidStructure);
|
|
59
|
+
|
|
60
|
+
expect(result).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe("verifySignature", () => {
|
|
65
|
+
it("verifies valid RSA-SHA256 signature", () => {
|
|
66
|
+
const signedLicense = parseLicenseKey(VALID_LICENSE_KEY);
|
|
67
|
+
|
|
68
|
+
expect(signedLicense).not.toBeNull();
|
|
69
|
+
if (!signedLicense) throw new Error("Expected signedLicense to be defined");
|
|
70
|
+
const result = verifySignature(signedLicense, TEST_PUBLIC_KEY);
|
|
71
|
+
|
|
72
|
+
expect(result).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("rejects tampered license data", () => {
|
|
76
|
+
const signedLicense = parseLicenseKey(TAMPERED_LICENSE_KEY);
|
|
77
|
+
|
|
78
|
+
expect(signedLicense).not.toBeNull();
|
|
79
|
+
if (!signedLicense) throw new Error("Expected signedLicense to be defined");
|
|
80
|
+
const result = verifySignature(signedLicense, TEST_PUBLIC_KEY);
|
|
81
|
+
|
|
82
|
+
expect(result).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("rejects license verified with different public key", () => {
|
|
86
|
+
const signedLicense = parseLicenseKey(VALID_LICENSE_KEY);
|
|
87
|
+
|
|
88
|
+
expect(signedLicense).not.toBeNull();
|
|
89
|
+
if (!signedLicense) throw new Error("Expected signedLicense to be defined");
|
|
90
|
+
const result = verifySignature(signedLicense, WRONG_PUBLIC_KEY);
|
|
91
|
+
|
|
92
|
+
expect(result).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("rejects license with empty signature", () => {
|
|
96
|
+
const signedLicense = parseLicenseKey(EMPTY_SIGNATURE_KEY);
|
|
97
|
+
|
|
98
|
+
expect(signedLicense).not.toBeNull();
|
|
99
|
+
if (!signedLicense) throw new Error("Expected signedLicense to be defined");
|
|
100
|
+
const result = verifySignature(signedLicense, TEST_PUBLIC_KEY);
|
|
101
|
+
|
|
102
|
+
expect(result).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe("isExpired", () => {
|
|
107
|
+
it("returns false when expiration is in the future", () => {
|
|
108
|
+
const futureDate = "2030-12-31T23:59:59Z";
|
|
109
|
+
|
|
110
|
+
const result = isExpired(futureDate);
|
|
111
|
+
|
|
112
|
+
expect(result).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("returns true when expiration is in the past", () => {
|
|
116
|
+
const pastDate = "2020-01-01T00:00:00Z";
|
|
117
|
+
|
|
118
|
+
const result = isExpired(pastDate);
|
|
119
|
+
|
|
120
|
+
expect(result).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("returns true at exactly the expiration time", () => {
|
|
124
|
+
const now = new Date("2024-06-15T12:00:00Z");
|
|
125
|
+
const expiresAt = "2024-06-15T12:00:00Z";
|
|
126
|
+
|
|
127
|
+
const result = isExpired(expiresAt, now);
|
|
128
|
+
|
|
129
|
+
expect(result).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("returns false one millisecond before expiration", () => {
|
|
133
|
+
const now = new Date("2024-06-15T11:59:59.999Z");
|
|
134
|
+
const expiresAt = "2024-06-15T12:00:00Z";
|
|
135
|
+
|
|
136
|
+
const result = isExpired(expiresAt, now);
|
|
137
|
+
|
|
138
|
+
expect(result).toBe(false);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("returns true for invalid date string (security fallback)", () => {
|
|
142
|
+
const result = isExpired("not-a-valid-date");
|
|
143
|
+
|
|
144
|
+
expect(result).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe("validateLicense", () => {
|
|
149
|
+
it("validates complete license successfully", () => {
|
|
150
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
151
|
+
|
|
152
|
+
expect(result.valid).toBe(true);
|
|
153
|
+
if (result.valid) {
|
|
154
|
+
expect(result.planInfo.maxMembers).toBe(BASE_LICENSE.plan.maxMembers);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("fails validation for invalid format", () => {
|
|
159
|
+
const result = validateLicense(GARBAGE_DATA, TEST_PUBLIC_KEY);
|
|
160
|
+
|
|
161
|
+
expect(result.valid).toBe(false);
|
|
162
|
+
if (!result.valid) {
|
|
163
|
+
expect(result.error).toBe("Invalid license format");
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("fails validation for invalid signature", () => {
|
|
168
|
+
const result = validateLicense(TAMPERED_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
169
|
+
|
|
170
|
+
expect(result.valid).toBe(false);
|
|
171
|
+
if (!result.valid) {
|
|
172
|
+
expect(result.error).toBe("Invalid signature");
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("fails validation for expired license", () => {
|
|
177
|
+
const result = validateLicense(EXPIRED_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
178
|
+
|
|
179
|
+
expect(result.valid).toBe(false);
|
|
180
|
+
if (!result.valid) {
|
|
181
|
+
expect(result.error).toBe("License expired");
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
describe("extracts license fields correctly", () => {
|
|
186
|
+
it("extracts licenseId", () => {
|
|
187
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
188
|
+
|
|
189
|
+
expect(result.valid).toBe(true);
|
|
190
|
+
if (result.valid) {
|
|
191
|
+
expect(result.licenseData.licenseId).toBe(BASE_LICENSE.licenseId);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("extracts organizationName", () => {
|
|
196
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
197
|
+
|
|
198
|
+
expect(result.valid).toBe(true);
|
|
199
|
+
if (result.valid) {
|
|
200
|
+
expect(result.licenseData.organizationName).toBe(BASE_LICENSE.organizationName);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("extracts email", () => {
|
|
205
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
206
|
+
|
|
207
|
+
expect(result.valid).toBe(true);
|
|
208
|
+
if (result.valid) {
|
|
209
|
+
expect(result.licenseData.email).toBe(BASE_LICENSE.email);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("extracts plan.type", () => {
|
|
214
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
215
|
+
|
|
216
|
+
expect(result.valid).toBe(true);
|
|
217
|
+
if (result.valid) {
|
|
218
|
+
expect(result.licenseData.plan.type).toBe(BASE_LICENSE.plan.type);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("extracts plan.maxMembers", () => {
|
|
223
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
224
|
+
|
|
225
|
+
expect(result.valid).toBe(true);
|
|
226
|
+
if (result.valid) {
|
|
227
|
+
expect(result.licenseData.plan.maxMembers).toBe(BASE_LICENSE.plan.maxMembers);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("extracts plan.maxProjects", () => {
|
|
232
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
233
|
+
|
|
234
|
+
expect(result.valid).toBe(true);
|
|
235
|
+
if (result.valid) {
|
|
236
|
+
expect(result.licenseData.plan.maxProjects).toBe(BASE_LICENSE.plan.maxProjects);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("extracts plan.maxMessagesPerMonth", () => {
|
|
241
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
242
|
+
|
|
243
|
+
expect(result.valid).toBe(true);
|
|
244
|
+
if (result.valid) {
|
|
245
|
+
expect(result.licenseData.plan.maxMessagesPerMonth).toBe(BASE_LICENSE.plan.maxMessagesPerMonth);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("validates old licenses that include evaluationsCredit (backward compat)", () => {
|
|
250
|
+
// VALID_LICENSE_KEY contains evaluationsCredit in the signed payload.
|
|
251
|
+
// After making the field optional, old licenses must still parse and
|
|
252
|
+
// pass signature verification without error.
|
|
253
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
254
|
+
|
|
255
|
+
expect(result.valid).toBe(true);
|
|
256
|
+
if (result.valid) {
|
|
257
|
+
// The field is declared as optional on the schema, so Zod preserves its value on parse.
|
|
258
|
+
expect(result.licenseData.plan.evaluationsCredit).toBe(BASE_LICENSE.plan.evaluationsCredit);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("extracts plan.maxWorkflows", () => {
|
|
263
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
264
|
+
|
|
265
|
+
expect(result.valid).toBe(true);
|
|
266
|
+
if (result.valid) {
|
|
267
|
+
expect(result.licenseData.plan.maxWorkflows).toBe(BASE_LICENSE.plan.maxWorkflows);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("extracts plan.canPublish", () => {
|
|
272
|
+
const result = validateLicense(VALID_LICENSE_KEY, TEST_PUBLIC_KEY);
|
|
273
|
+
|
|
274
|
+
expect(result.valid).toBe(true);
|
|
275
|
+
if (result.valid) {
|
|
276
|
+
expect(result.licenseData.plan.canPublish).toBe(BASE_LICENSE.plan.canPublish);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-safe exports for the licensing module.
|
|
3
|
+
*
|
|
4
|
+
* This barrel re-exports only types and constants that do NOT depend on
|
|
5
|
+
* Node.js built-ins (crypto, Buffer, etc.). Use this for client-side
|
|
6
|
+
* imports. For server-side code, import from the main barrel or specific files.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Types (always client-safe)
|
|
10
|
+
export type {
|
|
11
|
+
LicenseData,
|
|
12
|
+
LicensePlanLimits,
|
|
13
|
+
LicenseStatus,
|
|
14
|
+
SignedLicense,
|
|
15
|
+
ValidationResult,
|
|
16
|
+
} from "./types";
|
|
17
|
+
|
|
18
|
+
// PlanInfo type (client-safe, no server dependencies)
|
|
19
|
+
export type { PlanInfo } from "./planInfo";
|
|
20
|
+
|
|
21
|
+
// Constants (plain objects, no Node.js dependencies)
|
|
22
|
+
export { FREE_PLAN, LICENSE_ERRORS, UNLIMITED_PLAN } from "./constants";
|
|
23
|
+
export type { LicenseError } from "./constants";
|
|
24
|
+
|
|
25
|
+
// Plan Templates (plain objects, client-safe)
|
|
26
|
+
export { PRO_TEMPLATE, ENTERPRISE_TEMPLATE, getPlanTemplate } from "./planTemplates";
|
|
27
|
+
|
|
28
|
+
// Errors (plain JS classes)
|
|
29
|
+
export { OrganizationNotFoundError } from "./errors";
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import type { PlanInfo } from "./planInfo";
|
|
2
|
+
|
|
3
|
+
export const CONTACT_SALES_URL =
|
|
4
|
+
"https://meetings-eu1.hubspot.com/manouk-draisma?uuid=3c29cf0c-03e5-4a53-81fd-94abb0b66cfd";
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_LICENSE_PURCHASE_URL =
|
|
7
|
+
"https://buy.stripe.com/dRm3cwaIDgXs6yK6sX0480f";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Default limit for fields not present in older licenses.
|
|
11
|
+
* Using a large number instead of Infinity for JSON serialization safety.
|
|
12
|
+
* Note: Infinity cannot be serialized to JSON (becomes null), so we use
|
|
13
|
+
* Number.MAX_SAFE_INTEGER which is serializable and effectively unlimited.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_LIMIT = Number.MAX_SAFE_INTEGER;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Default value for maxMembersLite when not specified in license.
|
|
19
|
+
*/
|
|
20
|
+
export const DEFAULT_MEMBERS_LITE = 1;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* LICENSE_ERRORS: Standardized error messages for license validation.
|
|
24
|
+
* Used across validation.ts and types.ts to ensure consistency.
|
|
25
|
+
*/
|
|
26
|
+
export const LICENSE_ERRORS = {
|
|
27
|
+
INVALID_FORMAT: "Invalid license format",
|
|
28
|
+
INVALID_SIGNATURE: "Invalid signature",
|
|
29
|
+
EXPIRED: "License expired",
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* User-friendly error messages for display in the UI.
|
|
34
|
+
* Maps technical errors to human-readable messages.
|
|
35
|
+
*/
|
|
36
|
+
export const LICENSE_ERROR_MESSAGES = {
|
|
37
|
+
[LICENSE_ERRORS.INVALID_FORMAT]:
|
|
38
|
+
"The license key is invalid or has been tampered with. Please check the key and try again.",
|
|
39
|
+
[LICENSE_ERRORS.INVALID_SIGNATURE]:
|
|
40
|
+
"The license key is invalid or has been tampered with. Please check the key and try again.",
|
|
41
|
+
[LICENSE_ERRORS.EXPIRED]:
|
|
42
|
+
"This license has expired. Please contact support to renew your license.",
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a user-friendly error message for a given license error.
|
|
47
|
+
* Falls back to the original error if not found in the mapping.
|
|
48
|
+
*/
|
|
49
|
+
export function getUserFriendlyLicenseError(error: string): string {
|
|
50
|
+
return (
|
|
51
|
+
LICENSE_ERROR_MESSAGES[error as keyof typeof LICENSE_ERROR_MESSAGES] ??
|
|
52
|
+
error
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type LicenseError = (typeof LICENSE_ERRORS)[keyof typeof LICENSE_ERRORS];
|
|
57
|
+
|
|
58
|
+
/** Free tier resource limits - designed for individual evaluation/POC use */
|
|
59
|
+
const FREE_TIER_LIMITS = {
|
|
60
|
+
/** Single operator model */
|
|
61
|
+
MEMBERS: 1,
|
|
62
|
+
/** Members Lite requires paid plan */
|
|
63
|
+
MEMBERS_LITE: 0,
|
|
64
|
+
/** Single team for individual use */
|
|
65
|
+
TEAMS: 1,
|
|
66
|
+
/** Enough for a small POC */
|
|
67
|
+
PROJECTS: 2,
|
|
68
|
+
/** Minimal experimentation allowance */
|
|
69
|
+
WORKFLOWS: 3,
|
|
70
|
+
/** Minimal experimentation allowance */
|
|
71
|
+
PROMPTS: 3,
|
|
72
|
+
/** Minimal experimentation allowance */
|
|
73
|
+
EVALUATORS: 3,
|
|
74
|
+
/** Minimal experimentation allowance */
|
|
75
|
+
SCENARIOS: 3,
|
|
76
|
+
/** Minimal experimentation allowance */
|
|
77
|
+
AGENTS: 3,
|
|
78
|
+
/** Minimal experimentation allowance */
|
|
79
|
+
EXPERIMENTS: 3,
|
|
80
|
+
/** Minimal experimentation allowance */
|
|
81
|
+
ONLINE_EVALUATIONS: 3,
|
|
82
|
+
/** Minimal experimentation allowance */
|
|
83
|
+
DATASETS: 3,
|
|
84
|
+
/** Minimal experimentation allowance */
|
|
85
|
+
DASHBOARDS: 3,
|
|
86
|
+
/** Minimal experimentation allowance */
|
|
87
|
+
CUSTOM_GRAPHS: 3,
|
|
88
|
+
/** Minimal experimentation allowance */
|
|
89
|
+
AUTOMATIONS: 3,
|
|
90
|
+
/** ~33 messages per day */
|
|
91
|
+
MESSAGES_PER_MONTH: 1_000,
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* UNLIMITED_PLAN: Default plan for self-hosted deployments without a license.
|
|
96
|
+
* Maintains backward compatibility with current OSS behavior.
|
|
97
|
+
*
|
|
98
|
+
* Uses Number.MAX_SAFE_INTEGER instead of Infinity because:
|
|
99
|
+
* - JSON.stringify(Infinity) returns null, causing silent failures in tRPC
|
|
100
|
+
* - Number.MAX_SAFE_INTEGER is effectively unlimited for practical purposes
|
|
101
|
+
* - The value is 9,007,199,254,740,991 - far beyond any real limit
|
|
102
|
+
*/
|
|
103
|
+
export const UNLIMITED_PLAN: PlanInfo = {
|
|
104
|
+
planSource: "free",
|
|
105
|
+
type: "OPEN_SOURCE",
|
|
106
|
+
name: "Open Source",
|
|
107
|
+
free: true,
|
|
108
|
+
overrideAddingLimitations: true,
|
|
109
|
+
maxMembers: Number.MAX_SAFE_INTEGER,
|
|
110
|
+
maxMembersLite: Number.MAX_SAFE_INTEGER,
|
|
111
|
+
maxTeams: Number.MAX_SAFE_INTEGER,
|
|
112
|
+
maxProjects: Number.MAX_SAFE_INTEGER,
|
|
113
|
+
maxMessagesPerMonth: Number.MAX_SAFE_INTEGER,
|
|
114
|
+
maxWorkflows: Number.MAX_SAFE_INTEGER,
|
|
115
|
+
maxPrompts: Number.MAX_SAFE_INTEGER,
|
|
116
|
+
maxEvaluators: Number.MAX_SAFE_INTEGER,
|
|
117
|
+
maxScenarios: Number.MAX_SAFE_INTEGER,
|
|
118
|
+
maxAgents: Number.MAX_SAFE_INTEGER,
|
|
119
|
+
maxExperiments: Number.MAX_SAFE_INTEGER,
|
|
120
|
+
maxOnlineEvaluations: Number.MAX_SAFE_INTEGER,
|
|
121
|
+
maxDatasets: Number.MAX_SAFE_INTEGER,
|
|
122
|
+
maxDashboards: Number.MAX_SAFE_INTEGER,
|
|
123
|
+
maxCustomGraphs: Number.MAX_SAFE_INTEGER,
|
|
124
|
+
maxAutomations: Number.MAX_SAFE_INTEGER,
|
|
125
|
+
canPublish: true,
|
|
126
|
+
usageUnit: "traces",
|
|
127
|
+
prices: {
|
|
128
|
+
USD: 0,
|
|
129
|
+
EUR: 0,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* FREE_PLAN: Fallback plan for expired or invalid licenses.
|
|
135
|
+
* Provides minimal access to encourage license renewal.
|
|
136
|
+
*/
|
|
137
|
+
export const FREE_PLAN: PlanInfo = {
|
|
138
|
+
planSource: "free",
|
|
139
|
+
type: "FREE",
|
|
140
|
+
name: "Free",
|
|
141
|
+
free: true,
|
|
142
|
+
overrideAddingLimitations: false,
|
|
143
|
+
|
|
144
|
+
maxMessagesPerMonth: FREE_TIER_LIMITS.MESSAGES_PER_MONTH,
|
|
145
|
+
|
|
146
|
+
maxMembers: FREE_TIER_LIMITS.MEMBERS,
|
|
147
|
+
maxMembersLite: FREE_TIER_LIMITS.MEMBERS_LITE,
|
|
148
|
+
maxTeams: FREE_TIER_LIMITS.TEAMS,
|
|
149
|
+
maxProjects: FREE_TIER_LIMITS.PROJECTS,
|
|
150
|
+
|
|
151
|
+
maxWorkflows: FREE_TIER_LIMITS.WORKFLOWS,
|
|
152
|
+
maxPrompts: FREE_TIER_LIMITS.PROMPTS,
|
|
153
|
+
maxEvaluators: FREE_TIER_LIMITS.EVALUATORS,
|
|
154
|
+
maxScenarios: FREE_TIER_LIMITS.SCENARIOS,
|
|
155
|
+
maxAgents: FREE_TIER_LIMITS.AGENTS,
|
|
156
|
+
maxExperiments: FREE_TIER_LIMITS.EXPERIMENTS,
|
|
157
|
+
maxOnlineEvaluations: FREE_TIER_LIMITS.ONLINE_EVALUATIONS,
|
|
158
|
+
maxDatasets: FREE_TIER_LIMITS.DATASETS,
|
|
159
|
+
maxDashboards: FREE_TIER_LIMITS.DASHBOARDS,
|
|
160
|
+
maxCustomGraphs: FREE_TIER_LIMITS.CUSTOM_GRAPHS,
|
|
161
|
+
maxAutomations: FREE_TIER_LIMITS.AUTOMATIONS,
|
|
162
|
+
canPublish: false,
|
|
163
|
+
usageUnit: "traces",
|
|
164
|
+
prices: {
|
|
165
|
+
USD: 0,
|
|
166
|
+
EUR: 0,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* * Embedded production public key used when no env var is configured.
|
|
172
|
+
* * Enables license verification out-of-the-box; override via env for rotation.
|
|
173
|
+
* DO NOT REPLACE WITH A PLACEHOLDER, LEAVE IT AS IS.
|
|
174
|
+
*/
|
|
175
|
+
// gitleaks:allow — public keys
|
|
176
|
+
|
|
177
|
+
const PLACEHOLDER_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
178
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvyNNiu5B0lretFaxowsu
|
|
179
|
+
fM907tHWnBITXVDfnpPAwUgzrODdjfTt73XW1S+EDd8AM0FzOpx0YolXipS4+SNK
|
|
180
|
+
axSXwNO0S0XjJGLW7wz9Nv8/PP9V23LtiLQQOj8eGol/texr5pIZy2CRjVeEYcBZ
|
|
181
|
+
GCNz8mT/4tEM8v/NaoTFngsRwNJTuRlro+MZF7eArdBmtIU1fNLchZEH2kojMHKj
|
|
182
|
+
8vMIyZoTXB4TF/9iXL40eJQUWrVM1llGzJrZ7GhD3lIeyiZz+cQvako1BIthRuUa
|
|
183
|
+
2qLWpbVP63RSjxphslVvXk1RycL3esr2cj0Pe8loWxeKoxWjnXdLJYWygQh8aUbZ
|
|
184
|
+
iQIDAQAB
|
|
185
|
+
-----END PUBLIC KEY-----`;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* PUBLIC_KEY: RSA public key for license signature verification.
|
|
189
|
+
* This key is used to verify that licenses are signed by LangWatch.
|
|
190
|
+
*
|
|
191
|
+
* Set via LANGWATCH_LICENSE_PUBLIC_KEY environment variable in production.
|
|
192
|
+
* Falls back to placeholder (which will fail validation) if not set.
|
|
193
|
+
*/
|
|
194
|
+
export const PUBLIC_KEY =
|
|
195
|
+
process.env.LANGWATCH_LICENSE_PUBLIC_KEY ?? PLACEHOLDER_PUBLIC_KEY;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { DEFAULT_LIMIT, DEFAULT_MEMBERS_LITE } from "./constants";
|
|
2
|
+
import type { LicensePlanLimits } from "./types";
|
|
3
|
+
|
|
4
|
+
const KNOWN_USAGE_UNITS = ["traces", "events"] as const;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ResolvedPlanLimits has all optional fields made required after defaults are applied.
|
|
8
|
+
* This provides compile-time safety that all limits have defined values.
|
|
9
|
+
*/
|
|
10
|
+
// TODO: remove the Omit when evaluationsCredit is dropped from LicensePlanLimitsSchema
|
|
11
|
+
export type ResolvedPlanLimits = Required<Omit<LicensePlanLimits, "evaluationsCredit">>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Applies default values to optional fields in LicensePlanLimits.
|
|
15
|
+
*
|
|
16
|
+
* This consolidates scattered nullish coalescing operations into a single function.
|
|
17
|
+
* Optional fields that may be missing in older licenses receive sensible defaults:
|
|
18
|
+
* - maxMembersLite: DEFAULT_MEMBERS_LITE (1)
|
|
19
|
+
* - maxPrompts: DEFAULT_LIMIT (Number.MAX_SAFE_INTEGER - effectively unlimited)
|
|
20
|
+
* - maxEvaluators: DEFAULT_LIMIT (effectively unlimited)
|
|
21
|
+
* - maxScenarios: DEFAULT_LIMIT (effectively unlimited)
|
|
22
|
+
* - usageUnit: "traces"
|
|
23
|
+
*
|
|
24
|
+
* @param plan - License plan limits with optional fields
|
|
25
|
+
* @returns Plan limits with all fields guaranteed to have values
|
|
26
|
+
*/
|
|
27
|
+
export function resolvePlanDefaults(plan: LicensePlanLimits): ResolvedPlanLimits {
|
|
28
|
+
return {
|
|
29
|
+
// Pass through required fields unchanged
|
|
30
|
+
type: plan.type,
|
|
31
|
+
name: plan.name,
|
|
32
|
+
maxMembers: plan.maxMembers,
|
|
33
|
+
maxProjects: plan.maxProjects,
|
|
34
|
+
maxMessagesPerMonth: plan.maxMessagesPerMonth,
|
|
35
|
+
maxWorkflows: plan.maxWorkflows,
|
|
36
|
+
canPublish: plan.canPublish,
|
|
37
|
+
|
|
38
|
+
// Apply defaults to optional fields
|
|
39
|
+
maxMembersLite: plan.maxMembersLite ?? DEFAULT_MEMBERS_LITE,
|
|
40
|
+
maxTeams: plan.maxTeams ?? DEFAULT_LIMIT,
|
|
41
|
+
maxPrompts: plan.maxPrompts ?? DEFAULT_LIMIT,
|
|
42
|
+
maxEvaluators: plan.maxEvaluators ?? DEFAULT_LIMIT,
|
|
43
|
+
maxScenarios: plan.maxScenarios ?? DEFAULT_LIMIT,
|
|
44
|
+
maxAgents: plan.maxAgents ?? DEFAULT_LIMIT,
|
|
45
|
+
maxExperiments: plan.maxExperiments ?? DEFAULT_LIMIT,
|
|
46
|
+
maxOnlineEvaluations: plan.maxOnlineEvaluations ?? DEFAULT_LIMIT,
|
|
47
|
+
maxDatasets: plan.maxDatasets ?? DEFAULT_LIMIT,
|
|
48
|
+
maxDashboards: plan.maxDashboards ?? DEFAULT_LIMIT,
|
|
49
|
+
maxCustomGraphs: plan.maxCustomGraphs ?? DEFAULT_LIMIT,
|
|
50
|
+
maxAutomations: plan.maxAutomations ?? DEFAULT_LIMIT,
|
|
51
|
+
usageUnit: KNOWN_USAGE_UNITS.includes(plan.usageUnit as any)
|
|
52
|
+
? plan.usageUnit!
|
|
53
|
+
: "traces",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error types for licensing domain.
|
|
3
|
+
* These are framework-agnostic and can be mapped to tRPC/HTTP errors in the router layer.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class OrganizationNotFoundError extends Error {
|
|
7
|
+
constructor(message = "Organization not found") {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "OrganizationNotFoundError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export type {
|
|
3
|
+
LicenseData,
|
|
4
|
+
LicensePlanLimits,
|
|
5
|
+
LicenseStatus,
|
|
6
|
+
RemoveLicenseResult,
|
|
7
|
+
SignedLicense,
|
|
8
|
+
StoreLicenseResult,
|
|
9
|
+
ValidationResult,
|
|
10
|
+
} from "./types";
|
|
11
|
+
|
|
12
|
+
// PlanInfo type (client-safe, no server dependencies)
|
|
13
|
+
export type { PlanInfo } from "./planInfo";
|
|
14
|
+
|
|
15
|
+
// Constants
|
|
16
|
+
export { FREE_PLAN, LICENSE_ERRORS, PUBLIC_KEY, UNLIMITED_PLAN } from "./constants";
|
|
17
|
+
export type { LicenseError } from "./constants";
|
|
18
|
+
|
|
19
|
+
// Validation
|
|
20
|
+
export {
|
|
21
|
+
parseLicenseKey,
|
|
22
|
+
verifySignature,
|
|
23
|
+
isExpired,
|
|
24
|
+
validateLicense,
|
|
25
|
+
} from "./validation";
|
|
26
|
+
|
|
27
|
+
// Plan Mapping
|
|
28
|
+
export { mapToPlanInfo } from "./planMapping";
|
|
29
|
+
|
|
30
|
+
// License Handler
|
|
31
|
+
export { LicenseHandler } from "./licenseHandler";
|
|
32
|
+
export type { ITraceUsageService } from "./licenseHandler";
|
|
33
|
+
|
|
34
|
+
// Repository type (re-exported for factory wiring)
|
|
35
|
+
// NOTE: The class LicenseEnforcementRepository is NOT exported here to avoid
|
|
36
|
+
// bundling server-side code (Prisma) into client components. Import directly
|
|
37
|
+
// from "~/server/license-enforcement/license-enforcement.repository" for server usage.
|
|
38
|
+
export type { ILicenseEnforcementRepository } from "~/server/license-enforcement/license-enforcement.repository";
|
|
39
|
+
|
|
40
|
+
// Errors
|
|
41
|
+
export { OrganizationNotFoundError } from "./errors";
|
|
42
|
+
|
|
43
|
+
// Plan Templates
|
|
44
|
+
export { PRO_TEMPLATE, ENTERPRISE_TEMPLATE, getPlanTemplate } from "./planTemplates";
|
|
45
|
+
|
|
46
|
+
// NOTE: Signing functions (signLicense, encodeLicenseKey, generateLicenseId) are NOT
|
|
47
|
+
// exported here to avoid bundling Node.js crypto in client bundles. Import directly
|
|
48
|
+
// from 'ee/licensing/signing' for server-side usage.
|
|
49
|
+
|
|
50
|
+
// NOTE: Server-side factory (createLicenseHandler) is in ./server.ts to avoid
|
|
51
|
+
// bundling Node.js-only dependencies (Elasticsearch, etc.) in client code.
|
|
52
|
+
// Import from 'ee/licensing/server' for server-side usage.
|