@langwatch/server 3.1.0-beta.1 → 3.1.0-beta.11
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 +453 -186
- 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
|
@@ -19071,6 +19071,37 @@ var init_cli_truncate = __esm({
|
|
|
19071
19071
|
}
|
|
19072
19072
|
});
|
|
19073
19073
|
|
|
19074
|
+
// src/shared/paths.ts
|
|
19075
|
+
var import_node_os7, import_node_path6, root, paths;
|
|
19076
|
+
var init_paths = __esm({
|
|
19077
|
+
"src/shared/paths.ts"() {
|
|
19078
|
+
"use strict";
|
|
19079
|
+
import_node_os7 = require("node:os");
|
|
19080
|
+
import_node_path6 = require("node:path");
|
|
19081
|
+
root = process.env.LANGWATCH_HOME?.length ? process.env.LANGWATCH_HOME : (0, import_node_path6.join)((0, import_node_os7.homedir)(), ".langwatch");
|
|
19082
|
+
paths = {
|
|
19083
|
+
root,
|
|
19084
|
+
bin: (0, import_node_path6.join)(root, "bin"),
|
|
19085
|
+
// The @langwatch/server tree (langwatch/, langwatch_nlp/, langevals/,
|
|
19086
|
+
// python-sdk/, etc.) is relocated here on first run. tsx 4.x bypasses
|
|
19087
|
+
// tsconfig path-alias resolution for any source file whose parent path
|
|
19088
|
+
// includes "/node_modules/" (its guard against transpiling 3rd-party
|
|
19089
|
+
// deps), and npx unpacks INTO node_modules — so we have to move the app
|
|
19090
|
+
// out before pnpm scripts that depend on `~/...` aliases can work.
|
|
19091
|
+
app: (0, import_node_path6.join)(root, "app"),
|
|
19092
|
+
data: (0, import_node_path6.join)(root, "data"),
|
|
19093
|
+
redisData: (0, import_node_path6.join)(root, "data", "redis"),
|
|
19094
|
+
postgresData: (0, import_node_path6.join)(root, "data", "postgres"),
|
|
19095
|
+
clickhouseData: (0, import_node_path6.join)(root, "data", "clickhouse"),
|
|
19096
|
+
logs: (0, import_node_path6.join)(root, "logs"),
|
|
19097
|
+
pidFile: (0, import_node_path6.join)(root, "run", "langwatch.pid"),
|
|
19098
|
+
lockFile: (0, import_node_path6.join)(root, "run", "langwatch.lock"),
|
|
19099
|
+
envFile: (0, import_node_path6.join)(root, ".env"),
|
|
19100
|
+
installManifest: (0, import_node_path6.join)(root, "install-manifest.json")
|
|
19101
|
+
};
|
|
19102
|
+
}
|
|
19103
|
+
});
|
|
19104
|
+
|
|
19074
19105
|
// ../../node_modules/.pnpm/tar@7.5.13/node_modules/tar/dist/esm/index.min.js
|
|
19075
19106
|
var index_min_exports = {};
|
|
19076
19107
|
__export(index_min_exports, {
|
|
@@ -22297,7 +22328,7 @@ function servicePaths(p2) {
|
|
|
22297
22328
|
};
|
|
22298
22329
|
}
|
|
22299
22330
|
var import_node_path23;
|
|
22300
|
-
var
|
|
22331
|
+
var init_paths2 = __esm({
|
|
22301
22332
|
"src/services/paths.ts"() {
|
|
22302
22333
|
"use strict";
|
|
22303
22334
|
import_node_path23 = require("node:path");
|
|
@@ -22433,11 +22464,77 @@ var init_aigateway = __esm({
|
|
|
22433
22464
|
"src/services/aigateway.ts"() {
|
|
22434
22465
|
"use strict";
|
|
22435
22466
|
init_health();
|
|
22436
|
-
|
|
22467
|
+
init_paths2();
|
|
22437
22468
|
init_spawn();
|
|
22438
22469
|
}
|
|
22439
22470
|
});
|
|
22440
22471
|
|
|
22472
|
+
// src/services/app-dir.ts
|
|
22473
|
+
function locatePackageSource() {
|
|
22474
|
+
const candidate = (0, import_node_path25.join)(__dirname, "..", "..", "..");
|
|
22475
|
+
if ((0, import_node_fs22.existsSync)((0, import_node_path25.join)(candidate, "langwatch", "package.json"))) {
|
|
22476
|
+
return candidate;
|
|
22477
|
+
}
|
|
22478
|
+
return null;
|
|
22479
|
+
}
|
|
22480
|
+
function isUnderNodeModules(p2) {
|
|
22481
|
+
return p2.split(/[\\/]/).includes("node_modules");
|
|
22482
|
+
}
|
|
22483
|
+
async function ensureAppDir(ctx, bus) {
|
|
22484
|
+
const src = locatePackageSource();
|
|
22485
|
+
if (!src) throw new Error("could not locate @langwatch/server package source");
|
|
22486
|
+
if (!isUnderNodeModules(src)) return;
|
|
22487
|
+
const dst = ctx.paths.app;
|
|
22488
|
+
const versionMarker = (0, import_node_path25.join)(dst, ".installed-version");
|
|
22489
|
+
if ((0, import_node_fs22.existsSync)(versionMarker)) {
|
|
22490
|
+
const installed = (0, import_node_fs22.readFileSync)(versionMarker, "utf8").trim();
|
|
22491
|
+
if (installed === ctx.version) return;
|
|
22492
|
+
}
|
|
22493
|
+
bus.emit({ type: "starting", service: "prepare:app" });
|
|
22494
|
+
const start = Date.now();
|
|
22495
|
+
(0, import_node_fs22.mkdirSync)(dst, { recursive: true });
|
|
22496
|
+
const rsyncProbe = await execa("which", ["rsync"], { reject: false });
|
|
22497
|
+
if (rsyncProbe.exitCode === 0) {
|
|
22498
|
+
await execa(
|
|
22499
|
+
"rsync",
|
|
22500
|
+
[
|
|
22501
|
+
"-a",
|
|
22502
|
+
"--delete",
|
|
22503
|
+
"--exclude=node_modules",
|
|
22504
|
+
"--exclude=.installed-version",
|
|
22505
|
+
"--exclude=.git",
|
|
22506
|
+
`${src}/`,
|
|
22507
|
+
`${dst}/`
|
|
22508
|
+
],
|
|
22509
|
+
{ stdio: "pipe" }
|
|
22510
|
+
);
|
|
22511
|
+
} else {
|
|
22512
|
+
await execa("sh", ["-c", `tar -cf - --exclude=node_modules --exclude=.git -C "${src}" . | tar -xf - -C "${dst}"`]);
|
|
22513
|
+
}
|
|
22514
|
+
(0, import_node_fs22.writeFileSync)(versionMarker, ctx.version);
|
|
22515
|
+
bus.emit({ type: "healthy", service: "prepare:app", durationMs: Date.now() - start });
|
|
22516
|
+
}
|
|
22517
|
+
function appRoot() {
|
|
22518
|
+
if ((0, import_node_fs22.existsSync)((0, import_node_path25.join)(paths.app, ".installed-version"))) {
|
|
22519
|
+
return paths.app;
|
|
22520
|
+
}
|
|
22521
|
+
const src = locatePackageSource();
|
|
22522
|
+
if (!src) throw new Error("@langwatch/server tree not found (neither relocated nor in source layout)");
|
|
22523
|
+
return src;
|
|
22524
|
+
}
|
|
22525
|
+
var import_node_fs22, import_node_path25, import_node_url4, __dirname;
|
|
22526
|
+
var init_app_dir = __esm({
|
|
22527
|
+
"src/services/app-dir.ts"() {
|
|
22528
|
+
"use strict";
|
|
22529
|
+
init_execa();
|
|
22530
|
+
import_node_fs22 = require("node:fs");
|
|
22531
|
+
import_node_path25 = require("node:path");
|
|
22532
|
+
import_node_url4 = require("node:url");
|
|
22533
|
+
init_paths();
|
|
22534
|
+
__dirname = (0, import_node_path25.dirname)((0, import_node_url4.fileURLToPath)(__cli_url));
|
|
22535
|
+
}
|
|
22536
|
+
});
|
|
22537
|
+
|
|
22441
22538
|
// src/services/clickhouse.ts
|
|
22442
22539
|
async function startClickhouse(ctx, bus) {
|
|
22443
22540
|
bus.emit({ type: "starting", service: "clickhouse" });
|
|
@@ -22445,8 +22542,8 @@ async function startClickhouse(ctx, bus) {
|
|
|
22445
22542
|
const resolvedPath = ctx.predeps.clickhouse?.resolvedPath;
|
|
22446
22543
|
if (!resolvedPath) throw new Error("clickhouse predep not resolved \u2014 run install first");
|
|
22447
22544
|
const sp = servicePaths(ctx.paths);
|
|
22448
|
-
const configFile = (0,
|
|
22449
|
-
if (!(0,
|
|
22545
|
+
const configFile = (0, import_node_path26.join)(sp.clickhouseConfigDir, "config.xml");
|
|
22546
|
+
if (!(0, import_node_fs23.existsSync)(configFile)) writeClickhouseConfig(configFile, ctx);
|
|
22450
22547
|
const handle = supervise({
|
|
22451
22548
|
spec: {
|
|
22452
22549
|
name: "clickhouse",
|
|
@@ -22485,13 +22582,13 @@ async function ensureDatabase(ctx) {
|
|
|
22485
22582
|
function writeClickhouseConfig(path6, ctx) {
|
|
22486
22583
|
const dataDir = ctx.paths.clickhouseData;
|
|
22487
22584
|
const logsDir = ctx.paths.logs;
|
|
22488
|
-
const tmpDir = (0,
|
|
22489
|
-
const userFiles = (0,
|
|
22490
|
-
(0,
|
|
22491
|
-
(0,
|
|
22492
|
-
(0,
|
|
22493
|
-
(0,
|
|
22494
|
-
(0,
|
|
22585
|
+
const tmpDir = (0, import_node_path26.join)(dataDir, "tmp");
|
|
22586
|
+
const userFiles = (0, import_node_path26.join)(dataDir, "user_files");
|
|
22587
|
+
(0, import_node_fs23.mkdirSync)(ctx.paths.clickhouseData, { recursive: true });
|
|
22588
|
+
(0, import_node_fs23.mkdirSync)(tmpDir, { recursive: true });
|
|
22589
|
+
(0, import_node_fs23.mkdirSync)(userFiles, { recursive: true });
|
|
22590
|
+
(0, import_node_fs23.mkdirSync)(logsDir, { recursive: true });
|
|
22591
|
+
(0, import_node_fs23.mkdirSync)(path6.replace(/\/[^/]+$/, ""), { recursive: true });
|
|
22495
22592
|
const xml = `<?xml version="1.0"?>
|
|
22496
22593
|
<clickhouse>
|
|
22497
22594
|
<listen_host>127.0.0.1</listen_host>
|
|
@@ -22525,16 +22622,16 @@ function writeClickhouseConfig(path6, ctx) {
|
|
|
22525
22622
|
<quotas><default/></quotas>
|
|
22526
22623
|
</clickhouse>
|
|
22527
22624
|
`;
|
|
22528
|
-
(0,
|
|
22625
|
+
(0, import_node_fs23.writeFileSync)(path6, xml);
|
|
22529
22626
|
}
|
|
22530
|
-
var
|
|
22627
|
+
var import_node_fs23, import_node_path26, DB_NAME;
|
|
22531
22628
|
var init_clickhouse = __esm({
|
|
22532
22629
|
"src/services/clickhouse.ts"() {
|
|
22533
22630
|
"use strict";
|
|
22534
|
-
|
|
22535
|
-
|
|
22631
|
+
import_node_fs23 = require("node:fs");
|
|
22632
|
+
import_node_path26 = require("node:path");
|
|
22536
22633
|
init_health();
|
|
22537
|
-
|
|
22634
|
+
init_paths2();
|
|
22538
22635
|
init_spawn();
|
|
22539
22636
|
DB_NAME = "langwatch";
|
|
22540
22637
|
}
|
|
@@ -22553,9 +22650,9 @@ var init_env2 = __esm({
|
|
|
22553
22650
|
|
|
22554
22651
|
// src/services/env-file.ts
|
|
22555
22652
|
function readEnvFile(path6) {
|
|
22556
|
-
if (!(0,
|
|
22653
|
+
if (!(0, import_node_fs24.existsSync)(path6)) return {};
|
|
22557
22654
|
const out = {};
|
|
22558
|
-
for (const rawLine of (0,
|
|
22655
|
+
for (const rawLine of (0, import_node_fs24.readFileSync)(path6, "utf8").split(/\r?\n/)) {
|
|
22559
22656
|
const line = rawLine.trim();
|
|
22560
22657
|
if (!line || line.startsWith("#")) continue;
|
|
22561
22658
|
const eq = line.indexOf("=");
|
|
@@ -22569,11 +22666,11 @@ function readEnvFile(path6) {
|
|
|
22569
22666
|
}
|
|
22570
22667
|
return out;
|
|
22571
22668
|
}
|
|
22572
|
-
var
|
|
22669
|
+
var import_node_fs24;
|
|
22573
22670
|
var init_env_file = __esm({
|
|
22574
22671
|
"src/services/env-file.ts"() {
|
|
22575
22672
|
"use strict";
|
|
22576
|
-
|
|
22673
|
+
import_node_fs24 = require("node:fs");
|
|
22577
22674
|
}
|
|
22578
22675
|
});
|
|
22579
22676
|
|
|
@@ -22642,7 +22739,7 @@ async function startLangevals(ctx, bus, envFromFile) {
|
|
|
22642
22739
|
projectDir,
|
|
22643
22740
|
"--no-sync",
|
|
22644
22741
|
"python",
|
|
22645
|
-
(0,
|
|
22742
|
+
(0, import_node_path27.join)("langevals", "server.py")
|
|
22646
22743
|
],
|
|
22647
22744
|
env: {
|
|
22648
22745
|
...process.env,
|
|
@@ -22657,8 +22754,11 @@ async function startLangevals(ctx, bus, envFromFile) {
|
|
|
22657
22754
|
bus
|
|
22658
22755
|
});
|
|
22659
22756
|
const ready = await pollUntilHealthy({
|
|
22757
|
+
// 120s — parity with langwatch_nlp. Langevals' fastapi boot + evaluator
|
|
22758
|
+
// discovery is normally ~25-30s but a parallel boot with nlp + langwatch
|
|
22759
|
+
// app can push it past the previous 60s ceiling under load.
|
|
22660
22760
|
check: httpGetCheck(`http://127.0.0.1:${ctx.ports.langevals}/`),
|
|
22661
|
-
timeoutMs:
|
|
22761
|
+
timeoutMs: 12e4
|
|
22662
22762
|
});
|
|
22663
22763
|
if (!ready.ok) {
|
|
22664
22764
|
await handle.stop();
|
|
@@ -22668,24 +22768,64 @@ async function startLangevals(ctx, bus, envFromFile) {
|
|
|
22668
22768
|
return handle;
|
|
22669
22769
|
}
|
|
22670
22770
|
function locateProject(name) {
|
|
22671
|
-
const
|
|
22672
|
-
|
|
22673
|
-
(0, import_node_path26.join)(__dirname, "..", "..", "..", name),
|
|
22674
|
-
(0, import_node_path26.join)(process.cwd(), name)
|
|
22675
|
-
];
|
|
22676
|
-
return candidates.find((p2) => (0, import_node_fs24.existsSync)((0, import_node_path26.join)(p2, "pyproject.toml"))) ?? null;
|
|
22771
|
+
const dir = (0, import_node_path27.join)(appRoot(), name);
|
|
22772
|
+
return (0, import_node_fs25.existsSync)((0, import_node_path27.join)(dir, "pyproject.toml")) ? dir : null;
|
|
22677
22773
|
}
|
|
22678
|
-
var
|
|
22774
|
+
var import_node_fs25, import_node_path27;
|
|
22679
22775
|
var init_langevals = __esm({
|
|
22680
22776
|
"src/services/langevals.ts"() {
|
|
22681
22777
|
"use strict";
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22778
|
+
import_node_fs25 = require("node:fs");
|
|
22779
|
+
import_node_path27 = require("node:path");
|
|
22780
|
+
init_app_dir();
|
|
22685
22781
|
init_health();
|
|
22686
|
-
|
|
22782
|
+
init_paths2();
|
|
22687
22783
|
init_spawn();
|
|
22688
|
-
|
|
22784
|
+
}
|
|
22785
|
+
});
|
|
22786
|
+
|
|
22787
|
+
// src/services/_pipe-to-bus.ts
|
|
22788
|
+
async function execAndPipe(bus, service, bin, args, options = {}) {
|
|
22789
|
+
const child = execa(bin, args, {
|
|
22790
|
+
...options,
|
|
22791
|
+
// ignore stdin (none of these install steps are interactive); pipe both
|
|
22792
|
+
// stdout and stderr so we can re-emit as bus log events. Even when an
|
|
22793
|
+
// installer is silent on stdout, error output (resolution failures,
|
|
22794
|
+
// build script crashes) lands on stderr — both must flow to the user.
|
|
22795
|
+
stdin: "ignore",
|
|
22796
|
+
stdout: "pipe",
|
|
22797
|
+
stderr: "pipe"
|
|
22798
|
+
});
|
|
22799
|
+
pipeStream(child.stdout, bus, service, "stdout");
|
|
22800
|
+
pipeStream(child.stderr, bus, service, "stderr");
|
|
22801
|
+
await child;
|
|
22802
|
+
}
|
|
22803
|
+
function pipeStream(stream, bus, service, kind) {
|
|
22804
|
+
if (!stream) return;
|
|
22805
|
+
let buf = "";
|
|
22806
|
+
stream.setEncoding("utf8");
|
|
22807
|
+
stream.on("data", (chunk) => {
|
|
22808
|
+
buf += chunk;
|
|
22809
|
+
let nl;
|
|
22810
|
+
while ((nl = buf.indexOf("\n")) >= 0) {
|
|
22811
|
+
const line = buf.slice(0, nl);
|
|
22812
|
+
buf = buf.slice(nl + 1);
|
|
22813
|
+
if (line.length > 0) {
|
|
22814
|
+
bus.emit({ type: "log", service, stream: kind, line });
|
|
22815
|
+
}
|
|
22816
|
+
}
|
|
22817
|
+
});
|
|
22818
|
+
stream.on("end", () => {
|
|
22819
|
+
if (buf.length > 0) {
|
|
22820
|
+
bus.emit({ type: "log", service, stream: kind, line: buf });
|
|
22821
|
+
buf = "";
|
|
22822
|
+
}
|
|
22823
|
+
});
|
|
22824
|
+
}
|
|
22825
|
+
var init_pipe_to_bus = __esm({
|
|
22826
|
+
"src/services/_pipe-to-bus.ts"() {
|
|
22827
|
+
"use strict";
|
|
22828
|
+
init_execa();
|
|
22689
22829
|
}
|
|
22690
22830
|
});
|
|
22691
22831
|
|
|
@@ -22693,31 +22833,62 @@ var init_langevals = __esm({
|
|
|
22693
22833
|
async function ensureLangwatchDeps(ctx, bus) {
|
|
22694
22834
|
const langwatchDir = locateLangwatchDir();
|
|
22695
22835
|
if (!langwatchDir) throw new Error("langwatch app dir not found");
|
|
22696
|
-
const nodeModulesPath = (0,
|
|
22697
|
-
const distPath = (0,
|
|
22698
|
-
|
|
22836
|
+
const nodeModulesPath = (0, import_node_path28.join)(langwatchDir, "node_modules");
|
|
22837
|
+
const distPath = (0, import_node_path28.join)(langwatchDir, "dist");
|
|
22838
|
+
const prismaClientPath = (0, import_node_path28.join)(nodeModulesPath, ".prisma", "client", "index.js");
|
|
22839
|
+
const lockfilePath = (0, import_node_path28.join)(langwatchDir, "pnpm-lock.yaml");
|
|
22840
|
+
const hashFile = (0, import_node_path28.join)(nodeModulesPath, ".install-hash");
|
|
22841
|
+
const distAlreadyBuilt = (0, import_node_fs26.existsSync)((0, import_node_path28.join)(distPath, "client"));
|
|
22842
|
+
const installKey = computeInstallKey(lockfilePath, (0, import_node_path28.join)(langwatchDir, "package.json"));
|
|
22843
|
+
const topLevelLinksOk = (0, import_node_fs26.existsSync)((0, import_node_path28.join)(nodeModulesPath, ".bin", "prisma"));
|
|
22844
|
+
const cachedHash = (0, import_node_fs26.existsSync)(hashFile) ? (0, import_node_fs26.readFileSync)(hashFile, "utf8").trim() : null;
|
|
22845
|
+
const installFresh = topLevelLinksOk && cachedHash === installKey;
|
|
22846
|
+
if (installFresh && (0, import_node_fs26.existsSync)(prismaClientPath) && distAlreadyBuilt) {
|
|
22699
22847
|
return;
|
|
22700
22848
|
}
|
|
22701
|
-
bus.emit({ type: "starting", service: "
|
|
22849
|
+
bus.emit({ type: "starting", service: "prepare:langwatch" });
|
|
22702
22850
|
const start = Date.now();
|
|
22703
22851
|
const pnpm = await resolvePnpm();
|
|
22704
|
-
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22852
|
+
if (!installFresh) {
|
|
22853
|
+
await execAndPipe(
|
|
22854
|
+
bus,
|
|
22855
|
+
"prepare:langwatch",
|
|
22856
|
+
pnpm.command,
|
|
22857
|
+
[...pnpm.args, "-C", langwatchDir, "install", "--prod=false", "--frozen-lockfile"]
|
|
22858
|
+
);
|
|
22859
|
+
(0, import_node_fs26.writeFileSync)(hashFile, installKey);
|
|
22860
|
+
}
|
|
22861
|
+
if (distAlreadyBuilt && !(0, import_node_fs26.existsSync)(prismaClientPath)) {
|
|
22862
|
+
await execAndPipe(
|
|
22863
|
+
bus,
|
|
22864
|
+
"prepare:langwatch",
|
|
22865
|
+
pnpm.command,
|
|
22866
|
+
[...pnpm.args, "-C", langwatchDir, "exec", "prisma", "generate"]
|
|
22867
|
+
);
|
|
22710
22868
|
}
|
|
22711
22869
|
if (!distAlreadyBuilt) {
|
|
22712
|
-
await
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22870
|
+
await execAndPipe(
|
|
22871
|
+
bus,
|
|
22872
|
+
"prepare:langwatch",
|
|
22873
|
+
pnpm.command,
|
|
22874
|
+
[...pnpm.args, "-C", langwatchDir, "run", "build"],
|
|
22875
|
+
{
|
|
22876
|
+
env: {
|
|
22877
|
+
...process.env,
|
|
22878
|
+
NODE_ENV: "production"
|
|
22879
|
+
}
|
|
22717
22880
|
}
|
|
22718
|
-
|
|
22881
|
+
);
|
|
22719
22882
|
}
|
|
22720
|
-
bus.emit({ type: "healthy", service: "
|
|
22883
|
+
bus.emit({ type: "healthy", service: "prepare:langwatch", durationMs: Date.now() - start });
|
|
22884
|
+
}
|
|
22885
|
+
function computeInstallKey(...files) {
|
|
22886
|
+
const h2 = (0, import_node_crypto5.createHash)("sha256");
|
|
22887
|
+
for (const f2 of files) {
|
|
22888
|
+
if ((0, import_node_fs26.existsSync)(f2)) h2.update((0, import_node_fs26.readFileSync)(f2));
|
|
22889
|
+
h2.update("\n--\n");
|
|
22890
|
+
}
|
|
22891
|
+
return h2.digest("hex");
|
|
22721
22892
|
}
|
|
22722
22893
|
async function resolvePnpm() {
|
|
22723
22894
|
const direct = await execa("pnpm", ["--version"], { reject: false });
|
|
@@ -22727,30 +22898,19 @@ async function resolvePnpm() {
|
|
|
22727
22898
|
throw new Error("pnpm not found on PATH and corepack is unavailable");
|
|
22728
22899
|
}
|
|
22729
22900
|
function locateLangwatchDir() {
|
|
22730
|
-
const
|
|
22731
|
-
|
|
22732
|
-
(0, import_node_path27.join)(process.cwd(), "langwatch")
|
|
22733
|
-
];
|
|
22734
|
-
for (const p2 of candidates) {
|
|
22735
|
-
const pkgPath = (0, import_node_path27.join)(p2, "package.json");
|
|
22736
|
-
if (!(0, import_node_fs25.existsSync)(pkgPath)) continue;
|
|
22737
|
-
try {
|
|
22738
|
-
const pkg = JSON.parse((0, import_node_fs25.readFileSync)(pkgPath, "utf8"));
|
|
22739
|
-
if (pkg.name === "langwatch") return p2;
|
|
22740
|
-
} catch {
|
|
22741
|
-
}
|
|
22742
|
-
}
|
|
22743
|
-
return null;
|
|
22901
|
+
const dir = (0, import_node_path28.join)(appRoot(), "langwatch");
|
|
22902
|
+
return (0, import_node_fs26.existsSync)((0, import_node_path28.join)(dir, "package.json")) ? dir : null;
|
|
22744
22903
|
}
|
|
22745
|
-
var
|
|
22904
|
+
var import_node_crypto5, import_node_fs26, import_node_path28;
|
|
22746
22905
|
var init_node_deps = __esm({
|
|
22747
22906
|
"src/services/node-deps.ts"() {
|
|
22748
22907
|
"use strict";
|
|
22749
22908
|
init_execa();
|
|
22750
|
-
|
|
22751
|
-
|
|
22752
|
-
|
|
22753
|
-
|
|
22909
|
+
import_node_crypto5 = require("node:crypto");
|
|
22910
|
+
import_node_fs26 = require("node:fs");
|
|
22911
|
+
import_node_path28 = require("node:path");
|
|
22912
|
+
init_app_dir();
|
|
22913
|
+
init_pipe_to_bus();
|
|
22754
22914
|
}
|
|
22755
22915
|
});
|
|
22756
22916
|
|
|
@@ -22797,23 +22957,23 @@ async function startLangwatch(ctx, bus, envFromFile) {
|
|
|
22797
22957
|
return handle;
|
|
22798
22958
|
}
|
|
22799
22959
|
async function ensureNodeModules(langwatchDir, bus) {
|
|
22800
|
-
if ((0,
|
|
22960
|
+
if ((0, import_node_fs27.existsSync)((0, import_node_path29.join)(langwatchDir, "node_modules"))) return;
|
|
22801
22961
|
bus.emit({ type: "log", service: "langwatch", stream: "stdout", line: "installing node_modules (one-time setup)..." });
|
|
22802
22962
|
await execa("pnpm", ["install", "--prod=false", "--frozen-lockfile"], {
|
|
22803
22963
|
cwd: langwatchDir,
|
|
22804
22964
|
stdio: "inherit"
|
|
22805
22965
|
});
|
|
22806
22966
|
}
|
|
22807
|
-
var
|
|
22967
|
+
var import_node_fs27, import_node_path29;
|
|
22808
22968
|
var init_langwatch = __esm({
|
|
22809
22969
|
"src/services/langwatch.ts"() {
|
|
22810
22970
|
"use strict";
|
|
22811
22971
|
init_execa();
|
|
22812
|
-
|
|
22813
|
-
|
|
22972
|
+
import_node_fs27 = require("node:fs");
|
|
22973
|
+
import_node_path29 = require("node:path");
|
|
22814
22974
|
init_health();
|
|
22815
22975
|
init_node_deps();
|
|
22816
|
-
|
|
22976
|
+
init_paths2();
|
|
22817
22977
|
init_spawn();
|
|
22818
22978
|
}
|
|
22819
22979
|
});
|
|
@@ -22858,8 +23018,12 @@ async function startLangwatchNlp(ctx, bus, envFromFile) {
|
|
|
22858
23018
|
bus
|
|
22859
23019
|
});
|
|
22860
23020
|
const ready = await pollUntilHealthy({
|
|
23021
|
+
// 120s — uvicorn boot + LiteLLM proxy init + 4-worker ProcessPool spawn
|
|
23022
|
+
// can hit ~50-60s on a cold cache, and a parallel dogfood run pushed
|
|
23023
|
+
// it past the previous 60s ceiling. langevals already polls a similar
|
|
23024
|
+
// service, but its app surface is smaller and starts faster.
|
|
22861
23025
|
check: httpGetCheck(`http://127.0.0.1:${ctx.ports.nlp}/health`),
|
|
22862
|
-
timeoutMs:
|
|
23026
|
+
timeoutMs: 12e4
|
|
22863
23027
|
});
|
|
22864
23028
|
if (!ready.ok) {
|
|
22865
23029
|
await handle.stop();
|
|
@@ -22869,24 +23033,19 @@ async function startLangwatchNlp(ctx, bus, envFromFile) {
|
|
|
22869
23033
|
return handle;
|
|
22870
23034
|
}
|
|
22871
23035
|
function locateProject2(name) {
|
|
22872
|
-
const
|
|
22873
|
-
|
|
22874
|
-
(0, import_node_path29.join)(__dirname3, "..", "..", "..", name),
|
|
22875
|
-
(0, import_node_path29.join)(process.cwd(), name)
|
|
22876
|
-
];
|
|
22877
|
-
return candidates.find((p2) => (0, import_node_fs27.existsSync)((0, import_node_path29.join)(p2, "pyproject.toml"))) ?? null;
|
|
23036
|
+
const dir = (0, import_node_path30.join)(appRoot(), name);
|
|
23037
|
+
return (0, import_node_fs28.existsSync)((0, import_node_path30.join)(dir, "pyproject.toml")) ? dir : null;
|
|
22878
23038
|
}
|
|
22879
|
-
var
|
|
23039
|
+
var import_node_fs28, import_node_path30;
|
|
22880
23040
|
var init_langwatch_nlp = __esm({
|
|
22881
23041
|
"src/services/langwatch-nlp.ts"() {
|
|
22882
23042
|
"use strict";
|
|
22883
|
-
|
|
22884
|
-
|
|
22885
|
-
|
|
23043
|
+
import_node_fs28 = require("node:fs");
|
|
23044
|
+
import_node_path30 = require("node:path");
|
|
23045
|
+
init_app_dir();
|
|
22886
23046
|
init_health();
|
|
22887
|
-
|
|
23047
|
+
init_paths2();
|
|
22888
23048
|
init_spawn();
|
|
22889
|
-
__dirname3 = (0, import_node_path29.dirname)((0, import_node_url6.fileURLToPath)(__cli_url));
|
|
22890
23049
|
}
|
|
22891
23050
|
});
|
|
22892
23051
|
|
|
@@ -22914,27 +23073,27 @@ async function runMigrations(ctx, bus, envFromFile) {
|
|
|
22914
23073
|
SKIP_PRISMA_MIGRATE: "false",
|
|
22915
23074
|
SKIP_CLICKHOUSE_MIGRATE: "false"
|
|
22916
23075
|
};
|
|
22917
|
-
await
|
|
22918
|
-
await
|
|
23076
|
+
await execAndPipe(bus, "migrate:prisma", "pnpm", ["run", "prisma:migrate"], { cwd: langwatchDir, env: env3 });
|
|
23077
|
+
await execAndPipe(bus, "migrate:clickhouse", "pnpm", ["run", "clickhouse:migrate"], { cwd: langwatchDir, env: env3 });
|
|
22919
23078
|
bus.emit({ type: "healthy", service: "postgres", durationMs: Date.now() - start });
|
|
22920
23079
|
}
|
|
22921
23080
|
var init_migrate = __esm({
|
|
22922
23081
|
"src/services/migrate.ts"() {
|
|
22923
23082
|
"use strict";
|
|
22924
|
-
init_execa();
|
|
22925
23083
|
init_node_deps();
|
|
23084
|
+
init_pipe_to_bus();
|
|
22926
23085
|
}
|
|
22927
23086
|
});
|
|
22928
23087
|
|
|
22929
23088
|
// src/services/postgres.ts
|
|
22930
23089
|
function postgresLayout(postgresBinPath) {
|
|
22931
|
-
const binDir = (0,
|
|
23090
|
+
const binDir = (0, import_node_path31.dirname)(postgresBinPath);
|
|
22932
23091
|
return {
|
|
22933
23092
|
postgresBin: postgresBinPath,
|
|
22934
|
-
initdb: (0,
|
|
22935
|
-
pgCtl: (0,
|
|
22936
|
-
psql: (0,
|
|
22937
|
-
createdb: (0,
|
|
23093
|
+
initdb: (0, import_node_path31.join)(binDir, "initdb"),
|
|
23094
|
+
pgCtl: (0, import_node_path31.join)(binDir, "pg_ctl"),
|
|
23095
|
+
psql: (0, import_node_path31.join)(binDir, "psql"),
|
|
23096
|
+
createdb: (0, import_node_path31.join)(binDir, "createdb")
|
|
22938
23097
|
};
|
|
22939
23098
|
}
|
|
22940
23099
|
async function startPostgres(ctx, bus) {
|
|
@@ -22945,7 +23104,7 @@ async function startPostgres(ctx, bus) {
|
|
|
22945
23104
|
const layout = postgresLayout(resolvedPath);
|
|
22946
23105
|
const dataDir = ctx.paths.postgresData;
|
|
22947
23106
|
const sp = servicePaths(ctx.paths);
|
|
22948
|
-
if (!(0,
|
|
23107
|
+
if (!(0, import_node_fs29.existsSync)((0, import_node_path31.join)(dataDir, "PG_VERSION"))) {
|
|
22949
23108
|
await initdb(layout, dataDir);
|
|
22950
23109
|
}
|
|
22951
23110
|
const handle = supervise({
|
|
@@ -22960,7 +23119,7 @@ async function startPostgres(ctx, bus) {
|
|
|
22960
23119
|
"-h",
|
|
22961
23120
|
"127.0.0.1",
|
|
22962
23121
|
"-c",
|
|
22963
|
-
"unix_socket_directories=" + (0,
|
|
23122
|
+
"unix_socket_directories=" + (0, import_node_path31.dirname)(sp.pid("postgres")),
|
|
22964
23123
|
"-c",
|
|
22965
23124
|
"log_destination=stderr",
|
|
22966
23125
|
"-c",
|
|
@@ -22994,7 +23153,7 @@ async function startPostgres(ctx, bus) {
|
|
|
22994
23153
|
return handle;
|
|
22995
23154
|
}
|
|
22996
23155
|
async function initdb(layout, dataDir) {
|
|
22997
|
-
(0,
|
|
23156
|
+
(0, import_node_fs29.mkdirSync)(dataDir, { recursive: true });
|
|
22998
23157
|
await execa(
|
|
22999
23158
|
layout.initdb,
|
|
23000
23159
|
[
|
|
@@ -23063,15 +23222,15 @@ async function ensureDatabase2(layout, port) {
|
|
|
23063
23222
|
{ stdio: "ignore" }
|
|
23064
23223
|
);
|
|
23065
23224
|
}
|
|
23066
|
-
var
|
|
23225
|
+
var import_node_fs29, import_node_path31, DB_USER, DB_NAME2;
|
|
23067
23226
|
var init_postgres = __esm({
|
|
23068
23227
|
"src/services/postgres.ts"() {
|
|
23069
23228
|
"use strict";
|
|
23070
23229
|
init_execa();
|
|
23071
|
-
|
|
23072
|
-
|
|
23230
|
+
import_node_fs29 = require("node:fs");
|
|
23231
|
+
import_node_path31 = require("node:path");
|
|
23073
23232
|
init_health();
|
|
23074
|
-
|
|
23233
|
+
init_paths2();
|
|
23075
23234
|
init_spawn();
|
|
23076
23235
|
DB_USER = "langwatch";
|
|
23077
23236
|
DB_NAME2 = "langwatch_db";
|
|
@@ -23086,7 +23245,7 @@ async function startRedis(ctx, bus) {
|
|
|
23086
23245
|
if (!resolvedPath) throw new Error("redis predep not resolved \u2014 run install first");
|
|
23087
23246
|
const sp = servicePaths(ctx.paths);
|
|
23088
23247
|
const conf = sp.redisConf;
|
|
23089
|
-
if (!(0,
|
|
23248
|
+
if (!(0, import_node_fs30.existsSync)(conf)) writeRedisConf(conf, ctx.ports.redis, ctx.paths.redisData);
|
|
23090
23249
|
const handle = supervise({
|
|
23091
23250
|
spec: {
|
|
23092
23251
|
name: "redis",
|
|
@@ -23115,8 +23274,8 @@ async function startRedis(ctx, bus) {
|
|
|
23115
23274
|
return handle;
|
|
23116
23275
|
}
|
|
23117
23276
|
function writeRedisConf(path6, port, dataDir) {
|
|
23118
|
-
(0,
|
|
23119
|
-
(0,
|
|
23277
|
+
(0, import_node_fs30.mkdirSync)((0, import_node_path32.dirname)(path6), { recursive: true });
|
|
23278
|
+
(0, import_node_fs30.mkdirSync)(dataDir, { recursive: true });
|
|
23120
23279
|
const lines = [
|
|
23121
23280
|
`port ${port}`,
|
|
23122
23281
|
"bind 127.0.0.1",
|
|
@@ -23130,16 +23289,16 @@ function writeRedisConf(path6, port, dataDir) {
|
|
|
23130
23289
|
"maxmemory-policy allkeys-lru",
|
|
23131
23290
|
""
|
|
23132
23291
|
];
|
|
23133
|
-
(0,
|
|
23292
|
+
(0, import_node_fs30.writeFileSync)(path6, lines.join("\n"));
|
|
23134
23293
|
}
|
|
23135
|
-
var
|
|
23294
|
+
var import_node_fs30, import_node_path32;
|
|
23136
23295
|
var init_redis = __esm({
|
|
23137
23296
|
"src/services/redis.ts"() {
|
|
23138
23297
|
"use strict";
|
|
23139
|
-
|
|
23140
|
-
|
|
23298
|
+
import_node_fs30 = require("node:fs");
|
|
23299
|
+
import_node_path32 = require("node:path");
|
|
23141
23300
|
init_health();
|
|
23142
|
-
|
|
23301
|
+
init_paths2();
|
|
23143
23302
|
init_spawn();
|
|
23144
23303
|
}
|
|
23145
23304
|
});
|
|
@@ -23153,72 +23312,62 @@ async function syncVenvs(ctx, bus) {
|
|
|
23153
23312
|
await Promise.all(
|
|
23154
23313
|
specs.map(async (spec) => {
|
|
23155
23314
|
const venvDir = sp.venv(spec.name);
|
|
23156
|
-
const hashFile = (0,
|
|
23315
|
+
const hashFile = (0, import_node_path33.join)(venvDir, ".lock-hash");
|
|
23157
23316
|
const expected = hashFileSafely(spec.lockFile);
|
|
23158
|
-
if ((0,
|
|
23159
|
-
bus.emit({ type: "starting", service: `
|
|
23317
|
+
if ((0, import_node_fs31.existsSync)(venvDir) && readFileSafely(hashFile) === expected) return;
|
|
23318
|
+
bus.emit({ type: "starting", service: `prepare:${spec.name}` });
|
|
23160
23319
|
const start = Date.now();
|
|
23161
|
-
(0,
|
|
23162
|
-
await
|
|
23320
|
+
(0, import_node_fs31.mkdirSync)(venvDir, { recursive: true });
|
|
23321
|
+
await execAndPipe(
|
|
23322
|
+
bus,
|
|
23323
|
+
`prepare:${spec.name}`,
|
|
23163
23324
|
uvBin,
|
|
23164
23325
|
["sync", "--project", spec.projectDir],
|
|
23165
23326
|
{
|
|
23166
23327
|
env: {
|
|
23167
23328
|
...process.env,
|
|
23168
23329
|
UV_PROJECT_ENVIRONMENT: venvDir
|
|
23169
|
-
}
|
|
23170
|
-
stdio: "inherit"
|
|
23330
|
+
}
|
|
23171
23331
|
}
|
|
23172
23332
|
);
|
|
23173
|
-
(0,
|
|
23174
|
-
bus.emit({ type: "healthy", service: `
|
|
23333
|
+
(0, import_node_fs31.writeFileSync)(hashFile, expected);
|
|
23334
|
+
bus.emit({ type: "healthy", service: `prepare:${spec.name}`, durationMs: Date.now() - start });
|
|
23175
23335
|
})
|
|
23176
23336
|
);
|
|
23177
23337
|
}
|
|
23178
23338
|
function resolveVenvSpecs() {
|
|
23179
|
-
const root2 =
|
|
23339
|
+
const root2 = appRoot();
|
|
23180
23340
|
return [
|
|
23181
23341
|
{
|
|
23182
23342
|
name: "langwatch_nlp",
|
|
23183
|
-
projectDir: (0,
|
|
23184
|
-
lockFile: (0,
|
|
23343
|
+
projectDir: (0, import_node_path33.join)(root2, "langwatch_nlp"),
|
|
23344
|
+
lockFile: (0, import_node_path33.join)(root2, "langwatch_nlp", "uv.lock")
|
|
23185
23345
|
},
|
|
23186
23346
|
{
|
|
23187
23347
|
name: "langevals",
|
|
23188
|
-
projectDir: (0,
|
|
23189
|
-
lockFile: (0,
|
|
23348
|
+
projectDir: (0, import_node_path33.join)(root2, "langevals"),
|
|
23349
|
+
lockFile: (0, import_node_path33.join)(root2, "langevals", "uv.lock")
|
|
23190
23350
|
}
|
|
23191
23351
|
];
|
|
23192
23352
|
}
|
|
23193
|
-
function locateMonorepoRoot() {
|
|
23194
|
-
const candidates = [
|
|
23195
|
-
(0, import_node_path32.join)(__dirname4, "..", "..", "..", ".."),
|
|
23196
|
-
(0, import_node_path32.join)(__dirname4, "..", "..", ".."),
|
|
23197
|
-
process.cwd()
|
|
23198
|
-
];
|
|
23199
|
-
const fallback = candidates[0];
|
|
23200
|
-
if (!fallback) throw new Error("monorepo root candidates list is empty (impossible)");
|
|
23201
|
-
return candidates.find((p2) => (0, import_node_fs30.existsSync)((0, import_node_path32.join)(p2, "langwatch_nlp", "uv.lock"))) ?? fallback;
|
|
23202
|
-
}
|
|
23203
23353
|
function hashFileSafely(file) {
|
|
23204
|
-
if (!(0,
|
|
23205
|
-
return (0,
|
|
23354
|
+
if (!(0, import_node_fs31.existsSync)(file)) return "missing";
|
|
23355
|
+
return (0, import_node_crypto6.createHash)("sha256").update((0, import_node_fs31.readFileSync)(file)).digest("hex");
|
|
23206
23356
|
}
|
|
23207
23357
|
function readFileSafely(file) {
|
|
23208
|
-
if (!(0,
|
|
23209
|
-
return (0,
|
|
23358
|
+
if (!(0, import_node_fs31.existsSync)(file)) return null;
|
|
23359
|
+
return (0, import_node_fs31.readFileSync)(file, "utf8").trim();
|
|
23210
23360
|
}
|
|
23211
|
-
var
|
|
23361
|
+
var import_node_fs31, import_node_crypto6, import_node_path33;
|
|
23212
23362
|
var init_venvs = __esm({
|
|
23213
23363
|
"src/services/venvs.ts"() {
|
|
23214
23364
|
"use strict";
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
__dirname4 = (0, import_node_path32.dirname)((0, import_node_url7.fileURLToPath)(__cli_url));
|
|
23365
|
+
import_node_fs31 = require("node:fs");
|
|
23366
|
+
import_node_crypto6 = require("node:crypto");
|
|
23367
|
+
import_node_path33 = require("node:path");
|
|
23368
|
+
init_app_dir();
|
|
23369
|
+
init_paths2();
|
|
23370
|
+
init_pipe_to_bus();
|
|
23222
23371
|
}
|
|
23223
23372
|
});
|
|
23224
23373
|
|
|
@@ -23251,6 +23400,7 @@ var init_runtime = __esm({
|
|
|
23251
23400
|
"src/services/runtime.ts"() {
|
|
23252
23401
|
"use strict";
|
|
23253
23402
|
init_aigateway();
|
|
23403
|
+
init_app_dir();
|
|
23254
23404
|
init_clickhouse();
|
|
23255
23405
|
init_env2();
|
|
23256
23406
|
init_env_file();
|
|
@@ -23270,6 +23420,7 @@ var init_runtime = __esm({
|
|
|
23270
23420
|
},
|
|
23271
23421
|
async installServices(ctx) {
|
|
23272
23422
|
const bus = busFor(ctx);
|
|
23423
|
+
await ensureAppDir(ctx, bus);
|
|
23273
23424
|
await Promise.all([
|
|
23274
23425
|
syncVenvs(ctx, bus),
|
|
23275
23426
|
ensureLangwatchDeps(ctx, bus)
|
|
@@ -23917,9 +24068,15 @@ var COLORS2 = {
|
|
|
23917
24068
|
postgres: source_default.dim,
|
|
23918
24069
|
redis: source_default.dim,
|
|
23919
24070
|
clickhouse: source_default.dim,
|
|
23920
|
-
bullboard: source_default.gray
|
|
24071
|
+
bullboard: source_default.gray,
|
|
24072
|
+
"prepare:app": source_default.blue,
|
|
24073
|
+
"prepare:langwatch": source_default.green,
|
|
24074
|
+
"prepare:langwatch_nlp": source_default.cyan,
|
|
24075
|
+
"prepare:langevals": source_default.magenta,
|
|
24076
|
+
"migrate:prisma": source_default.dim,
|
|
24077
|
+
"migrate:clickhouse": source_default.dim
|
|
23921
24078
|
};
|
|
23922
|
-
var LABEL_WIDTH =
|
|
24079
|
+
var LABEL_WIDTH = 22;
|
|
23923
24080
|
function paint(service) {
|
|
23924
24081
|
const fn2 = COLORS2[service] ?? source_default.white;
|
|
23925
24082
|
return fn2(service.padEnd(LABEL_WIDTH));
|
|
@@ -23940,8 +24097,10 @@ function renderEvent(ev) {
|
|
|
23940
24097
|
return null;
|
|
23941
24098
|
}
|
|
23942
24099
|
}
|
|
23943
|
-
async function streamEventsToTTY(events) {
|
|
24100
|
+
async function streamEventsToTTY(events, options = {}) {
|
|
24101
|
+
const { intercept } = options;
|
|
23944
24102
|
for await (const ev of events) {
|
|
24103
|
+
if (intercept && intercept(ev)) continue;
|
|
23945
24104
|
const line = renderEvent(ev);
|
|
23946
24105
|
if (line) {
|
|
23947
24106
|
process.stdout.write(`${line}
|
|
@@ -25854,27 +26013,117 @@ var Listr = class {
|
|
|
25854
26013
|
}
|
|
25855
26014
|
};
|
|
25856
26015
|
|
|
26016
|
+
// src/animation/install-panels.ts
|
|
26017
|
+
var RING_SIZE = 5;
|
|
26018
|
+
var INSTALL_TASKS = [
|
|
26019
|
+
{ title: "preparing langwatch app", service: "prepare:app" },
|
|
26020
|
+
{ title: "installing langwatch_nlp deps", service: "prepare:langwatch_nlp" },
|
|
26021
|
+
{ title: "installing langevals deps", service: "prepare:langevals" },
|
|
26022
|
+
{ title: "installing langwatch deps", service: "prepare:langwatch" }
|
|
26023
|
+
];
|
|
26024
|
+
var INSTALL_SERVICES = new Set(INSTALL_TASKS.map((t) => t.service));
|
|
26025
|
+
function isInstallEvent(ev) {
|
|
26026
|
+
return INSTALL_SERVICES.has(ev.service);
|
|
26027
|
+
}
|
|
26028
|
+
function makeInstallPanelRouter() {
|
|
26029
|
+
const buffered = /* @__PURE__ */ new Map();
|
|
26030
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
26031
|
+
const finishedListeners = /* @__PURE__ */ new Set();
|
|
26032
|
+
let finished7 = false;
|
|
26033
|
+
return {
|
|
26034
|
+
subscribe(service, fn2) {
|
|
26035
|
+
listeners.set(service, fn2);
|
|
26036
|
+
const queue = buffered.get(service);
|
|
26037
|
+
if (queue) {
|
|
26038
|
+
for (const ev of queue) fn2(ev);
|
|
26039
|
+
buffered.delete(service);
|
|
26040
|
+
}
|
|
26041
|
+
},
|
|
26042
|
+
feed(ev) {
|
|
26043
|
+
if (!INSTALL_SERVICES.has(ev.service)) return;
|
|
26044
|
+
const fn2 = listeners.get(ev.service);
|
|
26045
|
+
if (fn2) {
|
|
26046
|
+
fn2(ev);
|
|
26047
|
+
return;
|
|
26048
|
+
}
|
|
26049
|
+
const queue = buffered.get(ev.service) ?? [];
|
|
26050
|
+
queue.push(ev);
|
|
26051
|
+
buffered.set(ev.service, queue);
|
|
26052
|
+
},
|
|
26053
|
+
installFinished() {
|
|
26054
|
+
if (finished7) return;
|
|
26055
|
+
finished7 = true;
|
|
26056
|
+
for (const fn2 of finishedListeners) fn2();
|
|
26057
|
+
finishedListeners.clear();
|
|
26058
|
+
},
|
|
26059
|
+
// exposed via prototype-style closure: tasks call back through subscribe()
|
|
26060
|
+
// for events, and (separately) await an install-finished signal so cached
|
|
26061
|
+
// steps that never emit can complete.
|
|
26062
|
+
onInstallFinished(fn2) {
|
|
26063
|
+
if (finished7) {
|
|
26064
|
+
fn2();
|
|
26065
|
+
return;
|
|
26066
|
+
}
|
|
26067
|
+
finishedListeners.add(fn2);
|
|
26068
|
+
}
|
|
26069
|
+
};
|
|
26070
|
+
}
|
|
26071
|
+
function renderInstallPanels(router) {
|
|
26072
|
+
const tasks = new Listr(
|
|
26073
|
+
INSTALL_TASKS.map((spec) => ({
|
|
26074
|
+
title: spec.title,
|
|
26075
|
+
task: (_2, task) => new Promise((resolve, reject) => {
|
|
26076
|
+
const ring = [];
|
|
26077
|
+
let started = false;
|
|
26078
|
+
router.subscribe(spec.service, (ev) => {
|
|
26079
|
+
if (ev.type === "starting") {
|
|
26080
|
+
started = true;
|
|
26081
|
+
return;
|
|
26082
|
+
}
|
|
26083
|
+
if (ev.type === "log") {
|
|
26084
|
+
const trimmed = ev.line.replace(/\r/g, "").trim();
|
|
26085
|
+
if (trimmed.length === 0) return;
|
|
26086
|
+
ring.push(trimmed);
|
|
26087
|
+
if (ring.length > RING_SIZE) ring.shift();
|
|
26088
|
+
task.output = ring.join("\n");
|
|
26089
|
+
return;
|
|
26090
|
+
}
|
|
26091
|
+
if (ev.type === "healthy") {
|
|
26092
|
+
resolve();
|
|
26093
|
+
return;
|
|
26094
|
+
}
|
|
26095
|
+
if (ev.type === "crashed") {
|
|
26096
|
+
reject(new Error(`${spec.service} crashed (exit ${ev.code})`));
|
|
26097
|
+
return;
|
|
26098
|
+
}
|
|
26099
|
+
});
|
|
26100
|
+
router.onInstallFinished(
|
|
26101
|
+
() => {
|
|
26102
|
+
if (!started) {
|
|
26103
|
+
task.skip("(cached)");
|
|
26104
|
+
resolve();
|
|
26105
|
+
}
|
|
26106
|
+
}
|
|
26107
|
+
);
|
|
26108
|
+
})
|
|
26109
|
+
})),
|
|
26110
|
+
{
|
|
26111
|
+
concurrent: true,
|
|
26112
|
+
exitOnError: false,
|
|
26113
|
+
collectErrors: "minimal",
|
|
26114
|
+
rendererOptions: { collapseSubtasks: false }
|
|
26115
|
+
}
|
|
26116
|
+
);
|
|
26117
|
+
return tasks.run().then(
|
|
26118
|
+
() => void 0,
|
|
26119
|
+
() => void 0
|
|
26120
|
+
);
|
|
26121
|
+
}
|
|
26122
|
+
|
|
25857
26123
|
// src/predeps/runner.ts
|
|
25858
26124
|
var import_node_fs19 = require("node:fs");
|
|
25859
26125
|
var import_prompts = __toESM(require_prompts3(), 1);
|
|
25860
|
-
|
|
25861
|
-
// src/shared/paths.ts
|
|
25862
|
-
var import_node_os7 = require("node:os");
|
|
25863
|
-
var import_node_path6 = require("node:path");
|
|
25864
|
-
var root = process.env.LANGWATCH_HOME?.length ? process.env.LANGWATCH_HOME : (0, import_node_path6.join)((0, import_node_os7.homedir)(), ".langwatch");
|
|
25865
|
-
var paths = {
|
|
25866
|
-
root,
|
|
25867
|
-
bin: (0, import_node_path6.join)(root, "bin"),
|
|
25868
|
-
data: (0, import_node_path6.join)(root, "data"),
|
|
25869
|
-
redisData: (0, import_node_path6.join)(root, "data", "redis"),
|
|
25870
|
-
postgresData: (0, import_node_path6.join)(root, "data", "postgres"),
|
|
25871
|
-
clickhouseData: (0, import_node_path6.join)(root, "data", "clickhouse"),
|
|
25872
|
-
logs: (0, import_node_path6.join)(root, "logs"),
|
|
25873
|
-
pidFile: (0, import_node_path6.join)(root, "run", "langwatch.pid"),
|
|
25874
|
-
lockFile: (0, import_node_path6.join)(root, "run", "langwatch.lock"),
|
|
25875
|
-
envFile: (0, import_node_path6.join)(root, ".env"),
|
|
25876
|
-
installManifest: (0, import_node_path6.join)(root, "install-manifest.json")
|
|
25877
|
-
};
|
|
26126
|
+
init_paths();
|
|
25878
26127
|
|
|
25879
26128
|
// src/predeps/aigateway.ts
|
|
25880
26129
|
init_execa();
|
|
@@ -25985,17 +26234,20 @@ function makeAigatewayPredep(version) {
|
|
|
25985
26234
|
const v2 = await resolveVersion(out) ?? version;
|
|
25986
26235
|
return { version: v2, resolvedPath: out };
|
|
25987
26236
|
} catch (err) {
|
|
25988
|
-
|
|
25989
|
-
|
|
25990
|
-
|
|
25991
|
-
|
|
25992
|
-
|
|
25993
|
-
|
|
25994
|
-
|
|
26237
|
+
const is404 = err instanceof Error && /HTTP 404/.test(err.message);
|
|
26238
|
+
if (!is404) throw err;
|
|
26239
|
+
if (process.env.LANGWATCH_AIGATEWAY_DEV_BUILD === "1") {
|
|
26240
|
+
const repoRoot = findRepoRoot();
|
|
26241
|
+
if (repoRoot) {
|
|
26242
|
+
await buildFromCheckout(repoRoot, paths2.bin, task);
|
|
26243
|
+
const v2 = await resolveVersion(out) ?? `${version}+local-build`;
|
|
26244
|
+
return { version: v2, resolvedPath: out };
|
|
26245
|
+
}
|
|
26246
|
+
}
|
|
26247
|
+
throw new Error(
|
|
26248
|
+
`ai-gateway prebuilt monobinary for v${version} not found at ${url} (HTTP 404). The v${version} release must publish aigateway-${platform5.replace("x64", "amd64")} for npx installs to work. Devs working from a checkout can opt into a local Go build via LANGWATCH_AIGATEWAY_DEV_BUILD=1.`
|
|
26249
|
+
);
|
|
25995
26250
|
}
|
|
25996
|
-
throw new Error(
|
|
25997
|
-
`aigateway download failed for v${version} (${url}). No local checkout found to build from. The v${version} release must publish aigateway-${platform5.replace("x64", "amd64")} for npx-only installs to work.`
|
|
25998
|
-
);
|
|
25999
26251
|
}
|
|
26000
26252
|
};
|
|
26001
26253
|
}
|
|
@@ -26025,7 +26277,7 @@ async function resolveVersion2(bin) {
|
|
|
26025
26277
|
}
|
|
26026
26278
|
var clickhousePredep = {
|
|
26027
26279
|
id: "clickhouse",
|
|
26028
|
-
label: "clickhouse
|
|
26280
|
+
label: "clickhouse",
|
|
26029
26281
|
required: true,
|
|
26030
26282
|
// Always use the embedded clickhouse. NOT checking `which clickhouse` —
|
|
26031
26283
|
// version drift between a user's system clickhouse and the schema /
|
|
@@ -26079,7 +26331,7 @@ async function resolveVersion3(bin) {
|
|
|
26079
26331
|
}
|
|
26080
26332
|
var goosePredep = {
|
|
26081
26333
|
id: "goose",
|
|
26082
|
-
label: "goose
|
|
26334
|
+
label: "goose",
|
|
26083
26335
|
required: true,
|
|
26084
26336
|
async detect(paths2) {
|
|
26085
26337
|
const bundled = (0, import_node_path9.join)(paths2.bin, "goose");
|
|
@@ -26157,7 +26409,7 @@ async function sha256OfFile(path6) {
|
|
|
26157
26409
|
}
|
|
26158
26410
|
var postgresPredep = {
|
|
26159
26411
|
id: "postgres",
|
|
26160
|
-
label: `postgresql ${PG_MAJOR}
|
|
26412
|
+
label: `postgresql ${PG_MAJOR}`,
|
|
26161
26413
|
required: true,
|
|
26162
26414
|
async detect(paths2) {
|
|
26163
26415
|
const bundled = (0, import_node_path19.join)(paths2.bin, "postgres", "bin", "postgres");
|
|
@@ -26234,7 +26486,7 @@ async function sha256OfFile2(path6) {
|
|
|
26234
26486
|
}
|
|
26235
26487
|
var redisPredep = {
|
|
26236
26488
|
id: "redis",
|
|
26237
|
-
label: "redis-server
|
|
26489
|
+
label: "redis-server",
|
|
26238
26490
|
required: true,
|
|
26239
26491
|
// Always use the embedded redis. NOT checking `which redis-server` —
|
|
26240
26492
|
// a user with a system redis installed (debian's redis 6.x, brew's
|
|
@@ -26301,7 +26553,7 @@ async function resolveVersion6(bin) {
|
|
|
26301
26553
|
}
|
|
26302
26554
|
var uvPredep = {
|
|
26303
26555
|
id: "uv",
|
|
26304
|
-
label: "uv
|
|
26556
|
+
label: "uv",
|
|
26305
26557
|
required: true,
|
|
26306
26558
|
async detect(paths2) {
|
|
26307
26559
|
const candidates = [
|
|
@@ -26478,6 +26730,7 @@ function collectResult(predeps, detection, installResults) {
|
|
|
26478
26730
|
}
|
|
26479
26731
|
|
|
26480
26732
|
// src/predeps/detect-only.ts
|
|
26733
|
+
init_paths();
|
|
26481
26734
|
async function inspectPredeps({ version }) {
|
|
26482
26735
|
const predeps = predepRegistry({ version });
|
|
26483
26736
|
const rows = [];
|
|
@@ -26562,6 +26815,7 @@ function printConflicts(report) {
|
|
|
26562
26815
|
}
|
|
26563
26816
|
|
|
26564
26817
|
// src/cli.ts
|
|
26818
|
+
init_paths();
|
|
26565
26819
|
init_ports();
|
|
26566
26820
|
init_env();
|
|
26567
26821
|
|
|
@@ -26582,7 +26836,7 @@ var placeholderRuntime = {
|
|
|
26582
26836
|
};
|
|
26583
26837
|
|
|
26584
26838
|
// src/cli.ts
|
|
26585
|
-
var VERSION = true ? "3.1.0-beta.
|
|
26839
|
+
var VERSION = true ? "3.1.0-beta.11" : "0.0.0-dev";
|
|
26586
26840
|
async function loadRuntime() {
|
|
26587
26841
|
try {
|
|
26588
26842
|
const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
|
|
@@ -26633,8 +26887,21 @@ program2.command("start", { isDefault: true }).description("install missing pred
|
|
|
26633
26887
|
userEnv: captureUserEnv()
|
|
26634
26888
|
};
|
|
26635
26889
|
ensureEnvFile(ctx);
|
|
26636
|
-
|
|
26637
|
-
const
|
|
26890
|
+
const installRouter = makeInstallPanelRouter();
|
|
26891
|
+
const panelsPromise = renderInstallPanels(installRouter);
|
|
26892
|
+
const eventsStream = streamEventsToTTY(runtime2.events(ctx), {
|
|
26893
|
+
intercept: (ev) => {
|
|
26894
|
+
if (!isInstallEvent(ev)) return false;
|
|
26895
|
+
installRouter.feed(ev);
|
|
26896
|
+
return true;
|
|
26897
|
+
}
|
|
26898
|
+
});
|
|
26899
|
+
try {
|
|
26900
|
+
await runtime2.installServices(ctx);
|
|
26901
|
+
} finally {
|
|
26902
|
+
installRouter.installFinished();
|
|
26903
|
+
}
|
|
26904
|
+
await panelsPromise;
|
|
26638
26905
|
const handles = await runtime2.startAll(ctx);
|
|
26639
26906
|
await runtime2.waitForHealth(ctx, { timeoutMs: 6e4 });
|
|
26640
26907
|
const url = `http://localhost:${ports.langwatch}`;
|