@langwatch/server 3.1.0-beta.1 → 3.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/langwatch/ee/admin/ImpersonationBanner.tsx +61 -0
  2. package/langwatch/ee/admin/ImpersonationSwitchBackMenuItem.tsx +30 -0
  3. package/langwatch/ee/admin/__tests__/ImpersonationBanner.integration.test.tsx +82 -0
  4. package/langwatch/ee/admin/__tests__/impersonation.service.unit.test.ts +231 -0
  5. package/langwatch/ee/admin/backoffice/BackofficeTable.tsx +200 -0
  6. package/langwatch/ee/admin/backoffice/__tests__/adminClient.unit.test.ts +147 -0
  7. package/langwatch/ee/admin/backoffice/__tests__/dateInputToISO.unit.test.ts +42 -0
  8. package/langwatch/ee/admin/backoffice/__tests__/userVisibility.unit.test.ts +174 -0
  9. package/langwatch/ee/admin/backoffice/adminClient.ts +114 -0
  10. package/langwatch/ee/admin/backoffice/resources/OrganizationFeaturesView.tsx +373 -0
  11. package/langwatch/ee/admin/backoffice/resources/OrganizationsView.tsx +677 -0
  12. package/langwatch/ee/admin/backoffice/resources/ProjectsView.tsx +647 -0
  13. package/langwatch/ee/admin/backoffice/resources/SubscriptionsView.tsx +628 -0
  14. package/langwatch/ee/admin/backoffice/resources/UsersView.tsx +556 -0
  15. package/langwatch/ee/admin/backoffice/useAdminResource.ts +104 -0
  16. package/langwatch/ee/admin/backoffice/userVisibility.ts +105 -0
  17. package/langwatch/ee/admin/impersonation.service.ts +170 -0
  18. package/langwatch/ee/admin/isAdmin.ts +9 -0
  19. package/langwatch/ee/admin/routes/admin.ts +531 -0
  20. package/langwatch/ee/admin/safeSelects.ts +64 -0
  21. package/langwatch/ee/billing/__tests__/customerService.unit.test.ts +183 -0
  22. package/langwatch/ee/billing/__tests__/growthSeatEvent.unit.test.ts +213 -0
  23. package/langwatch/ee/billing/__tests__/licensePurchaseHandler.unit.test.ts +250 -0
  24. package/langwatch/ee/billing/__tests__/notification.service.unit.test.ts +768 -0
  25. package/langwatch/ee/billing/__tests__/planLimits.unit.test.ts +19 -0
  26. package/langwatch/ee/billing/__tests__/planProvider.unit.test.ts +440 -0
  27. package/langwatch/ee/billing/__tests__/planTypes.unit.test.ts +32 -0
  28. package/langwatch/ee/billing/__tests__/pricing.unit.test.ts +54 -0
  29. package/langwatch/ee/billing/__tests__/seatEventSubscription.unit.test.ts +717 -0
  30. package/langwatch/ee/billing/__tests__/stripe.integration.test.ts +344 -0
  31. package/langwatch/ee/billing/__tests__/stripePrices.types.unit.test.ts +27 -0
  32. package/langwatch/ee/billing/__tests__/stripePricesLoader.unit.test.ts +72 -0
  33. package/langwatch/ee/billing/__tests__/subscription.service.unit.test.ts +730 -0
  34. package/langwatch/ee/billing/__tests__/subscriptionItemCalculator.unit.test.ts +176 -0
  35. package/langwatch/ee/billing/__tests__/usage-limit.service.unit.test.ts +706 -0
  36. package/langwatch/ee/billing/__tests__/usageReportingService.integration.test.ts +421 -0
  37. package/langwatch/ee/billing/__tests__/usageReportingService.unit.test.ts +515 -0
  38. package/langwatch/ee/billing/__tests__/webhookService.unit.test.ts +958 -0
  39. package/langwatch/ee/billing/currencyRouter.ts +18 -0
  40. package/langwatch/ee/billing/errors.ts +129 -0
  41. package/langwatch/ee/billing/index.ts +67 -0
  42. package/langwatch/ee/billing/middleware.ts +17 -0
  43. package/langwatch/ee/billing/notifications/notification.service.ts +651 -0
  44. package/langwatch/ee/billing/notifications/repositories/notification.repository.ts +51 -0
  45. package/langwatch/ee/billing/notifications/types.ts +9 -0
  46. package/langwatch/ee/billing/notifications/usage-limit.service.ts +622 -0
  47. package/langwatch/ee/billing/nurturing/hooks/activityTracking.ts +90 -0
  48. package/langwatch/ee/billing/nurturing/hooks/activityTracking.unit.test.ts +237 -0
  49. package/langwatch/ee/billing/nurturing/hooks/featureAdoption.ts +120 -0
  50. package/langwatch/ee/billing/nurturing/hooks/featureAdoption.unit.test.ts +324 -0
  51. package/langwatch/ee/billing/nurturing/hooks/index.ts +17 -0
  52. package/langwatch/ee/billing/nurturing/hooks/productInterest.ts +68 -0
  53. package/langwatch/ee/billing/nurturing/hooks/productInterest.unit.test.ts +138 -0
  54. package/langwatch/ee/billing/nurturing/hooks/promptCreation.integration.test.ts +288 -0
  55. package/langwatch/ee/billing/nurturing/hooks/promptCreation.ts +131 -0
  56. package/langwatch/ee/billing/nurturing/hooks/promptCreation.unit.test.ts +134 -0
  57. package/langwatch/ee/billing/nurturing/hooks/signupIdentification.ts +101 -0
  58. package/langwatch/ee/billing/nurturing/hooks/signupIdentification.unit.test.ts +317 -0
  59. package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.ts +49 -0
  60. package/langwatch/ee/billing/nurturing/hooks/subscriptionSync.unit.test.ts +170 -0
  61. package/langwatch/ee/billing/nurturing/hooks/userSync.ts +143 -0
  62. package/langwatch/ee/billing/nurturing/hooks/userSync.unit.test.ts +307 -0
  63. package/langwatch/ee/billing/nurturing/nurturing.service.ts +179 -0
  64. package/langwatch/ee/billing/nurturing/nurturing.service.unit.test.ts +266 -0
  65. package/langwatch/ee/billing/nurturing/nurturing.service.wiring.unit.test.ts +109 -0
  66. package/langwatch/ee/billing/nurturing/types.ts +125 -0
  67. package/langwatch/ee/billing/planLimits.ts +190 -0
  68. package/langwatch/ee/billing/planProvider.ts +119 -0
  69. package/langwatch/ee/billing/planTypes.ts +53 -0
  70. package/langwatch/ee/billing/pricing.ts +57 -0
  71. package/langwatch/ee/billing/services/billableEventsQuery.ts +248 -0
  72. package/langwatch/ee/billing/services/customerService.ts +90 -0
  73. package/langwatch/ee/billing/services/licensePurchaseHandler.ts +73 -0
  74. package/langwatch/ee/billing/services/seatEventSubscription.ts +351 -0
  75. package/langwatch/ee/billing/services/seatSyncService.ts +34 -0
  76. package/langwatch/ee/billing/services/subscription.repository.ts +203 -0
  77. package/langwatch/ee/billing/services/subscription.service.ts +549 -0
  78. package/langwatch/ee/billing/services/subscriptionItemCalculator.ts +249 -0
  79. package/langwatch/ee/billing/services/usageReportingService.ts +301 -0
  80. package/langwatch/ee/billing/services/webhookService.ts +858 -0
  81. package/langwatch/ee/billing/stripe/stripeCatalog.json +1781 -0
  82. package/langwatch/ee/billing/stripe/stripeClient.ts +13 -0
  83. package/langwatch/ee/billing/stripe/stripePriceCatalog.ts +70 -0
  84. package/langwatch/ee/billing/stripe/stripePrices.types.ts +118 -0
  85. package/langwatch/ee/billing/subscriptionRouter.ts +202 -0
  86. package/langwatch/ee/billing/types.ts +102 -0
  87. package/langwatch/ee/billing/utils/currency.ts +99 -0
  88. package/langwatch/ee/billing/utils/growthSeatEvent.ts +137 -0
  89. package/langwatch/ee/licensing/__tests__/constants.unit.test.ts +56 -0
  90. package/langwatch/ee/licensing/__tests__/defaults.unit.test.ts +192 -0
  91. package/langwatch/ee/licensing/__tests__/fixtures/testKeys.ts +86 -0
  92. package/langwatch/ee/licensing/__tests__/fixtures/testLicenses.ts +92 -0
  93. package/langwatch/ee/licensing/__tests__/licenseGenerationService.unit.test.ts +232 -0
  94. package/langwatch/ee/licensing/__tests__/licenseHandler.integration.test.ts +419 -0
  95. package/langwatch/ee/licensing/__tests__/planMapping.unit.test.ts +195 -0
  96. package/langwatch/ee/licensing/__tests__/planTemplates.unit.test.ts +193 -0
  97. package/langwatch/ee/licensing/__tests__/signing.unit.test.ts +164 -0
  98. package/langwatch/ee/licensing/__tests__/validation.unit.test.ts +281 -0
  99. package/langwatch/ee/licensing/client.ts +29 -0
  100. package/langwatch/ee/licensing/constants.ts +195 -0
  101. package/langwatch/ee/licensing/defaults.ts +55 -0
  102. package/langwatch/ee/licensing/errors.ts +11 -0
  103. package/langwatch/ee/licensing/index.ts +52 -0
  104. package/langwatch/ee/licensing/licenseGenerationService.ts +87 -0
  105. package/langwatch/ee/licensing/licenseHandler.ts +308 -0
  106. package/langwatch/ee/licensing/planInfo.ts +46 -0
  107. package/langwatch/ee/licensing/planMapping.ts +37 -0
  108. package/langwatch/ee/licensing/planTemplates.ts +109 -0
  109. package/langwatch/ee/licensing/server.ts +43 -0
  110. package/langwatch/ee/licensing/signing.ts +43 -0
  111. package/langwatch/ee/licensing/types.ts +156 -0
  112. package/langwatch/ee/licensing/validation.ts +107 -0
  113. package/langwatch/ee/managed-providers/ManagedModelProviderAlert.tsx +29 -0
  114. package/langwatch/ee/managed-providers/managedBedrockConfig.ts +226 -0
  115. package/langwatch/ee/saas/ExtraFooterComponents.tsx +169 -0
  116. package/langwatch/package.json +1 -1
  117. package/langwatch/pnpm-workspace.yaml +0 -1
  118. package/langwatch_nlp/uv.lock +179 -5
  119. package/mcp-server/.env.example +2 -0
  120. package/mcp-server/.eslintrc.cjs +36 -0
  121. package/mcp-server/CHANGELOG.md +165 -0
  122. package/mcp-server/CONTRIBUTING.md +96 -0
  123. package/mcp-server/README.md +172 -0
  124. package/mcp-server/dist/archive-scenario-WJ2A7ETN.js +19 -0
  125. package/mcp-server/dist/archive-suite-4JOM4SSL.js +15 -0
  126. package/mcp-server/dist/assign-prompt-tag-GL7EAAF3.js +19 -0
  127. package/mcp-server/dist/chunk-2GT7IFWK.js +40 -0
  128. package/mcp-server/dist/chunk-2WPLXEKF.js +127 -0
  129. package/mcp-server/dist/chunk-4AUB2BIA.js +71 -0
  130. package/mcp-server/dist/chunk-BWWY5KEF.js +71 -0
  131. package/mcp-server/dist/chunk-CCWCIJJ3.js +22 -0
  132. package/mcp-server/dist/chunk-EGH5RPXM.js +25 -0
  133. package/mcp-server/dist/chunk-EUQDVOSU.js +39 -0
  134. package/mcp-server/dist/chunk-HYMIWO3U.js +44 -0
  135. package/mcp-server/dist/chunk-IE4M5OGE.js +42 -0
  136. package/mcp-server/dist/chunk-LUMEZEHL.js +48 -0
  137. package/mcp-server/dist/chunk-NUFPTHKU.js +9 -0
  138. package/mcp-server/dist/chunk-UDHJYT6P.js +1567 -0
  139. package/mcp-server/dist/chunk-WQG2DFHX.js +86 -0
  140. package/mcp-server/dist/chunk-WVI5CJ6S.js +21 -0
  141. package/mcp-server/dist/chunk-ZVS4UKN2.js +35 -0
  142. package/mcp-server/dist/chunk-ZXKLPC2E.js +27 -0
  143. package/mcp-server/dist/config.d.ts +17 -0
  144. package/mcp-server/dist/config.js +13 -0
  145. package/mcp-server/dist/create-agent-MBOOT3XK.js +23 -0
  146. package/mcp-server/dist/create-annotation-XMV6A7ED.js +24 -0
  147. package/mcp-server/dist/create-dashboard-VRKLFVZJ.js +18 -0
  148. package/mcp-server/dist/create-dataset-7HQPZCRE.js +22 -0
  149. package/mcp-server/dist/create-dataset-records-2NIVFYTV.js +22 -0
  150. package/mcp-server/dist/create-evaluator-WYFRFLRC.js +27 -0
  151. package/mcp-server/dist/create-mcp-server.d.ts +8 -0
  152. package/mcp-server/dist/create-mcp-server.js +8 -0
  153. package/mcp-server/dist/create-prompt-IEN7O6JT.js +39 -0
  154. package/mcp-server/dist/create-prompt-tag-CAEZ45VO.js +17 -0
  155. package/mcp-server/dist/create-scenario-6YHSMGLP.js +26 -0
  156. package/mcp-server/dist/create-suite-H5XOFDE5.js +38 -0
  157. package/mcp-server/dist/delete-agent-JKTNBWAA.js +18 -0
  158. package/mcp-server/dist/delete-annotation-ACMDV6QO.js +17 -0
  159. package/mcp-server/dist/delete-dashboard-VJSR7CRU.js +18 -0
  160. package/mcp-server/dist/delete-dataset-RTTTWP4D.js +20 -0
  161. package/mcp-server/dist/delete-dataset-records-KNQTIPQK.js +21 -0
  162. package/mcp-server/dist/delete-evaluator-7FVC5WM4.js +15 -0
  163. package/mcp-server/dist/delete-prompt-tag-ZMZUAGFW.js +17 -0
  164. package/mcp-server/dist/delete-workflow-EYQ3T4RQ.js +17 -0
  165. package/mcp-server/dist/discover-evaluator-schema-H23XCLNE.js +1402 -0
  166. package/mcp-server/dist/discover-scenario-schema-MEEEVND7.js +65 -0
  167. package/mcp-server/dist/discover-schema-3T52ORPB.js +446 -0
  168. package/mcp-server/dist/get-agent-E3QSTVKG.js +28 -0
  169. package/mcp-server/dist/get-analytics-2OHV763I.js +72 -0
  170. package/mcp-server/dist/get-dashboard-PC7JDHH6.js +29 -0
  171. package/mcp-server/dist/get-dataset-H5IK5FVU.js +48 -0
  172. package/mcp-server/dist/get-evaluator-UWVUPYTM.js +47 -0
  173. package/mcp-server/dist/get-prompt-WZUOLLQC.js +45 -0
  174. package/mcp-server/dist/get-scenario-Q6LCNUYN.js +33 -0
  175. package/mcp-server/dist/get-simulation-run-Z2XKO256.js +56 -0
  176. package/mcp-server/dist/get-suite-BXK5TN7P.js +44 -0
  177. package/mcp-server/dist/get-trace-4EJAYVBG.js +50 -0
  178. package/mcp-server/dist/get-workflow-O34QJLHD.js +25 -0
  179. package/mcp-server/dist/http-server-RSTXN4CN.js +224 -0
  180. package/mcp-server/dist/index.d.ts +2 -0
  181. package/mcp-server/dist/index.js +67774 -0
  182. package/mcp-server/dist/langwatch-api-annotations-ERBG27RF.js +17 -0
  183. package/mcp-server/dist/langwatch-api-dashboards-G6TR7VVO.js +17 -0
  184. package/mcp-server/dist/langwatch-api-monitors-WSXZLS2B.js +52 -0
  185. package/mcp-server/dist/langwatch-api-secrets-RR5DKG2X.js +40 -0
  186. package/mcp-server/dist/langwatch-api-triggers-2RTNSWQY.js +30 -0
  187. package/mcp-server/dist/langwatch-api-workflows-VJRIIDZ7.js +15 -0
  188. package/mcp-server/dist/list-agents-AW3P6FJV.js +32 -0
  189. package/mcp-server/dist/list-annotations-QNCGWPQ3.js +33 -0
  190. package/mcp-server/dist/list-dashboards-R7RK2IXL.js +32 -0
  191. package/mcp-server/dist/list-dataset-records-WVCSQP7P.js +39 -0
  192. package/mcp-server/dist/list-datasets-KEXRLDEU.js +60 -0
  193. package/mcp-server/dist/list-evaluators-7R2LB4JH.js +34 -0
  194. package/mcp-server/dist/list-model-providers-OBYJCKBX.js +35 -0
  195. package/mcp-server/dist/list-prompt-tags-6LY3ZPYI.js +23 -0
  196. package/mcp-server/dist/list-prompts-VWEZ4CDE.js +32 -0
  197. package/mcp-server/dist/list-scenarios-TXD4W2ZJ.js +40 -0
  198. package/mcp-server/dist/list-simulation-runs-RHPOLMFI.js +43 -0
  199. package/mcp-server/dist/list-suites-FSGBX27Z.js +42 -0
  200. package/mcp-server/dist/list-workflows-VRGEZ3EN.js +35 -0
  201. package/mcp-server/dist/rename-prompt-tag-VOJJLX4M.js +18 -0
  202. package/mcp-server/dist/run-agent-KTCC7TB7.js +36 -0
  203. package/mcp-server/dist/run-evaluation-2X3V3Q6L.js +64 -0
  204. package/mcp-server/dist/run-suite-BTMHGI2D.js +29 -0
  205. package/mcp-server/dist/run-workflow-IGAYGKJL.js +36 -0
  206. package/mcp-server/dist/search-traces-VYFUIMXH.js +72 -0
  207. package/mcp-server/dist/set-model-provider-W5IUI326.js +33 -0
  208. package/mcp-server/dist/update-agent-4BB7EYLR.js +20 -0
  209. package/mcp-server/dist/update-dataset-CXBKZ4W3.js +22 -0
  210. package/mcp-server/dist/update-dataset-record-HOHAMHXG.js +19 -0
  211. package/mcp-server/dist/update-evaluator-IVOR6FTR.js +24 -0
  212. package/mcp-server/dist/update-prompt-OWQAKE7K.js +24 -0
  213. package/mcp-server/dist/update-scenario-GDFVILPN.js +27 -0
  214. package/mcp-server/dist/update-suite-BXYUYSPT.js +39 -0
  215. package/mcp-server/package.json +79 -0
  216. package/mcp-server/pnpm-lock.yaml +6103 -0
  217. package/mcp-server/pnpm-workspace.yaml +2 -0
  218. package/mcp-server/pyproject.toml +17 -0
  219. package/mcp-server/src/__tests__/all-tools.integration.test.ts +1681 -0
  220. package/mcp-server/src/__tests__/config.unit.test.ts +169 -0
  221. package/mcp-server/src/__tests__/datasets.integration.test.ts +603 -0
  222. package/mcp-server/src/__tests__/datasets.unit.test.ts +240 -0
  223. package/mcp-server/src/__tests__/date-parsing.unit.test.ts +78 -0
  224. package/mcp-server/src/__tests__/discover-evaluator-schema.unit.test.ts +89 -0
  225. package/mcp-server/src/__tests__/discover-schema.unit.test.ts +118 -0
  226. package/mcp-server/src/__tests__/docker.integration.test.ts +234 -0
  227. package/mcp-server/src/__tests__/evaluator-tools.unit.test.ts +262 -0
  228. package/mcp-server/src/__tests__/http-transport.integration.test.ts +397 -0
  229. package/mcp-server/src/__tests__/integration.integration.test.ts +288 -0
  230. package/mcp-server/src/__tests__/langwatch-api.unit.test.ts +455 -0
  231. package/mcp-server/src/__tests__/model-provider-tools.unit.test.ts +190 -0
  232. package/mcp-server/src/__tests__/scenario-tools.integration.test.ts +286 -0
  233. package/mcp-server/src/__tests__/scenario-tools.unit.test.ts +185 -0
  234. package/mcp-server/src/__tests__/schemas.unit.test.ts +85 -0
  235. package/mcp-server/src/__tests__/tools.unit.test.ts +900 -0
  236. package/mcp-server/src/config.d.ts +15 -0
  237. package/mcp-server/src/config.ts +107 -0
  238. package/mcp-server/src/create-mcp-server.d.ts +6 -0
  239. package/mcp-server/src/create-mcp-server.ts +1799 -0
  240. package/mcp-server/src/http-server.ts +329 -0
  241. package/mcp-server/src/index.ts +46 -0
  242. package/mcp-server/src/langwatch-api-agents.ts +108 -0
  243. package/mcp-server/src/langwatch-api-annotations.ts +49 -0
  244. package/mcp-server/src/langwatch-api-dashboards.ts +48 -0
  245. package/mcp-server/src/langwatch-api-datasets.ts +191 -0
  246. package/mcp-server/src/langwatch-api-evaluators.ts +80 -0
  247. package/mcp-server/src/langwatch-api-model-providers.ts +41 -0
  248. package/mcp-server/src/langwatch-api-monitors.ts +82 -0
  249. package/mcp-server/src/langwatch-api-scenarios.ts +67 -0
  250. package/mcp-server/src/langwatch-api-secrets.ts +48 -0
  251. package/mcp-server/src/langwatch-api-simulation-runs.ts +51 -0
  252. package/mcp-server/src/langwatch-api-suites.ts +118 -0
  253. package/mcp-server/src/langwatch-api-triggers.ts +48 -0
  254. package/mcp-server/src/langwatch-api-workflows.ts +41 -0
  255. package/mcp-server/src/langwatch-api.ts +299 -0
  256. package/mcp-server/src/schemas/analytics-groups.ts +78 -0
  257. package/mcp-server/src/schemas/analytics-metrics.ts +179 -0
  258. package/mcp-server/src/schemas/create-dataset.ts +48 -0
  259. package/mcp-server/src/schemas/filter-fields.ts +119 -0
  260. package/mcp-server/src/schemas/index.ts +4 -0
  261. package/mcp-server/src/tools/archive-scenario.ts +19 -0
  262. package/mcp-server/src/tools/archive-suite.ts +12 -0
  263. package/mcp-server/src/tools/assign-prompt-tag.ts +16 -0
  264. package/mcp-server/src/tools/create-agent.ts +15 -0
  265. package/mcp-server/src/tools/create-annotation.ts +18 -0
  266. package/mcp-server/src/tools/create-dashboard.ts +7 -0
  267. package/mcp-server/src/tools/create-dataset-records.ts +23 -0
  268. package/mcp-server/src/tools/create-dataset.ts +22 -0
  269. package/mcp-server/src/tools/create-evaluator.ts +33 -0
  270. package/mcp-server/src/tools/create-prompt-tag.ts +12 -0
  271. package/mcp-server/src/tools/create-prompt.ts +58 -0
  272. package/mcp-server/src/tools/create-scenario.ts +30 -0
  273. package/mcp-server/src/tools/create-suite.ts +42 -0
  274. package/mcp-server/src/tools/delete-agent.ts +7 -0
  275. package/mcp-server/src/tools/delete-annotation.ts +7 -0
  276. package/mcp-server/src/tools/delete-dashboard.ts +7 -0
  277. package/mcp-server/src/tools/delete-dataset-records.ts +22 -0
  278. package/mcp-server/src/tools/delete-dataset.ts +20 -0
  279. package/mcp-server/src/tools/delete-evaluator.ts +12 -0
  280. package/mcp-server/src/tools/delete-prompt-tag.ts +12 -0
  281. package/mcp-server/src/tools/delete-workflow.ts +7 -0
  282. package/mcp-server/src/tools/discover-evaluator-schema.ts +143 -0
  283. package/mcp-server/src/tools/discover-scenario-schema.ts +71 -0
  284. package/mcp-server/src/tools/discover-schema.ts +106 -0
  285. package/mcp-server/src/tools/format-dataset-mutation.ts +25 -0
  286. package/mcp-server/src/tools/get-agent.ts +21 -0
  287. package/mcp-server/src/tools/get-analytics.ts +98 -0
  288. package/mcp-server/src/tools/get-dashboard.ts +22 -0
  289. package/mcp-server/src/tools/get-dataset.ts +63 -0
  290. package/mcp-server/src/tools/get-evaluator.ts +53 -0
  291. package/mcp-server/src/tools/get-prompt.ts +54 -0
  292. package/mcp-server/src/tools/get-scenario.ts +36 -0
  293. package/mcp-server/src/tools/get-simulation-run.ts +60 -0
  294. package/mcp-server/src/tools/get-suite.ts +47 -0
  295. package/mcp-server/src/tools/get-trace.ts +61 -0
  296. package/mcp-server/src/tools/get-workflow.ts +17 -0
  297. package/mcp-server/src/tools/list-agents.ts +27 -0
  298. package/mcp-server/src/tools/list-annotations.ts +33 -0
  299. package/mcp-server/src/tools/list-dashboards.ts +27 -0
  300. package/mcp-server/src/tools/list-dataset-records.ts +46 -0
  301. package/mcp-server/src/tools/list-datasets.ts +80 -0
  302. package/mcp-server/src/tools/list-evaluators.ts +37 -0
  303. package/mcp-server/src/tools/list-model-providers.ts +40 -0
  304. package/mcp-server/src/tools/list-prompt-tags.ts +21 -0
  305. package/mcp-server/src/tools/list-prompts.ts +34 -0
  306. package/mcp-server/src/tools/list-scenarios.ts +47 -0
  307. package/mcp-server/src/tools/list-simulation-runs.ts +49 -0
  308. package/mcp-server/src/tools/list-suites.ts +43 -0
  309. package/mcp-server/src/tools/list-workflows.ts +31 -0
  310. package/mcp-server/src/tools/rename-prompt-tag.ts +14 -0
  311. package/mcp-server/src/tools/run-agent.ts +36 -0
  312. package/mcp-server/src/tools/run-evaluation.ts +87 -0
  313. package/mcp-server/src/tools/run-suite.ts +28 -0
  314. package/mcp-server/src/tools/run-workflow.ts +36 -0
  315. package/mcp-server/src/tools/search-traces.ts +91 -0
  316. package/mcp-server/src/tools/set-model-provider.ts +46 -0
  317. package/mcp-server/src/tools/update-agent.ts +13 -0
  318. package/mcp-server/src/tools/update-dataset-record.ts +21 -0
  319. package/mcp-server/src/tools/update-dataset.ts +23 -0
  320. package/mcp-server/src/tools/update-evaluator.ts +30 -0
  321. package/mcp-server/src/tools/update-prompt.ts +31 -0
  322. package/mcp-server/src/tools/update-scenario.ts +32 -0
  323. package/mcp-server/src/tools/update-suite.ts +44 -0
  324. package/mcp-server/src/utils/date-parsing.ts +31 -0
  325. package/mcp-server/src/utils/escape-markdown.ts +12 -0
  326. package/mcp-server/tsconfig.json +27 -0
  327. package/mcp-server/uv.lock +2731 -0
  328. package/package.json +2 -6
  329. package/packages/server/dist/cli.cjs +299 -177
  330. package/cmd/service/main.go +0 -68
  331. package/go.mod +0 -117
  332. package/go.sum +0 -299
  333. package/pkg/breaker/breaker.go +0 -157
  334. package/pkg/breaker/breaker_test.go +0 -131
  335. package/pkg/clog/LICENSE +0 -26
  336. package/pkg/clog/clog.go +0 -90
  337. package/pkg/clog/clog_test.go +0 -56
  338. package/pkg/clog/panic.go +0 -39
  339. package/pkg/config/LICENSE +0 -26
  340. package/pkg/config/config.go +0 -86
  341. package/pkg/config/config_test.go +0 -70
  342. package/pkg/config/otel.go +0 -50
  343. package/pkg/config/server.go +0 -61
  344. package/pkg/config/validate.go +0 -80
  345. package/pkg/config/validate_test.go +0 -74
  346. package/pkg/contexts/contexts_test.go +0 -34
  347. package/pkg/contexts/request_id.go +0 -1
  348. package/pkg/contexts/service_info.go +0 -33
  349. package/pkg/errfuncs/errfuncs.go +0 -9
  350. package/pkg/errfuncs/errfuncs_test.go +0 -28
  351. package/pkg/forkedcontext/forkedcontext.go +0 -57
  352. package/pkg/health/health.go +0 -123
  353. package/pkg/health/health_test.go +0 -84
  354. package/pkg/herr/LICENSE +0 -26
  355. package/pkg/herr/code.go +0 -14
  356. package/pkg/herr/herr.go +0 -112
  357. package/pkg/herr/herr_test.go +0 -78
  358. package/pkg/herr/http.go +0 -133
  359. package/pkg/herr/http_test.go +0 -103
  360. package/pkg/herr/validate.go +0 -72
  361. package/pkg/herr/validate_test.go +0 -75
  362. package/pkg/httpmiddleware/bearer.go +0 -47
  363. package/pkg/httpmiddleware/httputil_test.go +0 -167
  364. package/pkg/httpmiddleware/inflight.go +0 -23
  365. package/pkg/httpmiddleware/maxbody.go +0 -30
  366. package/pkg/httpmiddleware/recover.go +0 -38
  367. package/pkg/httpmiddleware/requestid.go +0 -40
  368. package/pkg/httpmiddleware/telemetry.go +0 -96
  369. package/pkg/httpmiddleware/version.go +0 -16
  370. package/pkg/jwtverify/verifier.go +0 -72
  371. package/pkg/jwtverify/verifier_test.go +0 -134
  372. package/pkg/ksuid/LICENSE +0 -26
  373. package/pkg/ksuid/ksuid.go +0 -157
  374. package/pkg/ksuid/ksuid_test.go +0 -107
  375. package/pkg/ksuid/resources.go +0 -13
  376. package/pkg/lifecycle/group.go +0 -175
  377. package/pkg/lifecycle/group_test.go +0 -236
  378. package/pkg/lifecycle/service.go +0 -112
  379. package/pkg/netprobe/netprobe.go +0 -89
  380. package/pkg/netprobe/netprobe_test.go +0 -55
  381. package/pkg/otelsetup/otelsetup.go +0 -226
  382. package/pkg/otelsetup/otelsetup_test.go +0 -130
  383. package/pkg/ptr/LICENSE +0 -26
  384. package/pkg/ptr/ptr.go +0 -34
  385. package/pkg/ptr/ptr_test.go +0 -66
  386. package/pkg/retry/bench_test.go +0 -67
  387. package/pkg/retry/retry.go +0 -188
  388. package/pkg/retry/retry_test.go +0 -222
  389. package/pkg/slicefuncs/LICENSE +0 -26
  390. package/pkg/slicefuncs/slicefuncs.go +0 -10
  391. package/pkg/slicefuncs/slicefuncs_test.go +0 -29
  392. package/pkg/stacktrace/LICENSE +0 -26
  393. package/pkg/stacktrace/frames.go +0 -77
  394. package/pkg/stacktrace/frames_test.go +0 -73
  395. package/services/aigateway/BENCHMARKS.md +0 -110
  396. package/services/aigateway/README.md +0 -156
  397. package/services/aigateway/adapters/authresolver/bench_test.go +0 -13
  398. package/services/aigateway/adapters/authresolver/redis.go +0 -61
  399. package/services/aigateway/adapters/authresolver/service.go +0 -442
  400. package/services/aigateway/adapters/authresolver/service_test.go +0 -435
  401. package/services/aigateway/adapters/budget/bench_test.go +0 -50
  402. package/services/aigateway/adapters/budget/budget.go +0 -59
  403. package/services/aigateway/adapters/cacherules/evaluator.go +0 -134
  404. package/services/aigateway/adapters/cacherules/evaluator_test.go +0 -207
  405. package/services/aigateway/adapters/controlplane/bench_test.go +0 -40
  406. package/services/aigateway/adapters/controlplane/client.go +0 -213
  407. package/services/aigateway/adapters/controlplane/client_test.go +0 -73
  408. package/services/aigateway/adapters/controlplane/config_wire.go +0 -310
  409. package/services/aigateway/adapters/controlplane/guardrails.go +0 -88
  410. package/services/aigateway/adapters/controlplane/signer.go +0 -95
  411. package/services/aigateway/adapters/controlplane/signer_test.go +0 -64
  412. package/services/aigateway/adapters/customertracebridge/context.go +0 -48
  413. package/services/aigateway/adapters/customertracebridge/context_test.go +0 -24
  414. package/services/aigateway/adapters/customertracebridge/emitter.go +0 -329
  415. package/services/aigateway/adapters/customertracebridge/emitter_test.go +0 -93
  416. package/services/aigateway/adapters/customertracebridge/registry.go +0 -82
  417. package/services/aigateway/adapters/customertracebridge/transport.go +0 -122
  418. package/services/aigateway/adapters/gatewaytracer/attrs.go +0 -28
  419. package/services/aigateway/adapters/gatewaytracer/attrs_genai.go +0 -24
  420. package/services/aigateway/adapters/gatewaytracer/headers.go +0 -8
  421. package/services/aigateway/adapters/gatewaytracer/tracer.go +0 -101
  422. package/services/aigateway/adapters/httpapi/bench_test.go +0 -83
  423. package/services/aigateway/adapters/httpapi/middleware.go +0 -123
  424. package/services/aigateway/adapters/httpapi/router.go +0 -635
  425. package/services/aigateway/adapters/httpapi/router_test.go +0 -633
  426. package/services/aigateway/adapters/modelresolver/resolver.go +0 -107
  427. package/services/aigateway/adapters/modelresolver/resolver_test.go +0 -140
  428. package/services/aigateway/adapters/policy/matcher.go +0 -250
  429. package/services/aigateway/adapters/policy/matcher_test.go +0 -124
  430. package/services/aigateway/adapters/providers/bifrost.go +0 -798
  431. package/services/aigateway/adapters/providers/bifrost_parser.go +0 -201
  432. package/services/aigateway/adapters/providers/bifrost_test.go +0 -181
  433. package/services/aigateway/adapters/ratelimit/limiter.go +0 -122
  434. package/services/aigateway/adapters/ratelimit/limiter_test.go +0 -81
  435. package/services/aigateway/app/app.go +0 -104
  436. package/services/aigateway/app/dispatch.go +0 -89
  437. package/services/aigateway/app/dispatch_test.go +0 -475
  438. package/services/aigateway/app/handlers.go +0 -79
  439. package/services/aigateway/app/peek_bench_test.go +0 -21
  440. package/services/aigateway/app/pipeline/bench_test.go +0 -34
  441. package/services/aigateway/app/pipeline/budget.go +0 -55
  442. package/services/aigateway/app/pipeline/cache.go +0 -34
  443. package/services/aigateway/app/pipeline/cachecontrol.go +0 -86
  444. package/services/aigateway/app/pipeline/cachecontrol_test.go +0 -110
  445. package/services/aigateway/app/pipeline/guardrail.go +0 -121
  446. package/services/aigateway/app/pipeline/pipeline.go +0 -159
  447. package/services/aigateway/app/pipeline/policy.go +0 -23
  448. package/services/aigateway/app/pipeline/ratelimit.go +0 -21
  449. package/services/aigateway/app/pipeline/rawframing_test.go +0 -67
  450. package/services/aigateway/app/pipeline/resolve.go +0 -44
  451. package/services/aigateway/app/pipeline/trace.go +0 -129
  452. package/services/aigateway/app/ports.go +0 -61
  453. package/services/aigateway/cmd/root.go +0 -42
  454. package/services/aigateway/config.go +0 -86
  455. package/services/aigateway/deps.go +0 -177
  456. package/services/aigateway/domain/bundle.go +0 -203
  457. package/services/aigateway/domain/errors.go +0 -23
  458. package/services/aigateway/domain/model.go +0 -24
  459. package/services/aigateway/domain/provider.go +0 -38
  460. package/services/aigateway/domain/request.go +0 -65
  461. package/services/aigateway/domain/response.go +0 -56
  462. package/services/aigateway/domain/verdict.go +0 -55
  463. package/services/aigateway/serve.go +0 -45
  464. package/services/aigateway/tests/matrix/README.md +0 -71
  465. package/services/aigateway/tests/matrix/anthropic_test.go +0 -61
  466. package/services/aigateway/tests/matrix/azure_test.go +0 -52
  467. package/services/aigateway/tests/matrix/bedrock_test.go +0 -69
  468. package/services/aigateway/tests/matrix/gemini_test.go +0 -117
  469. package/services/aigateway/tests/matrix/matrix_test.go +0 -601
  470. package/services/aigateway/tests/matrix/openai_test.go +0 -66
  471. 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 init_paths = __esm({
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
- init_paths();
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: "app:relocate" });
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: "app:relocate", 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, import_node_path25.join)(sp.clickhouseConfigDir, "config.xml");
22449
- if (!(0, import_node_fs22.existsSync)(configFile)) writeClickhouseConfig(configFile, ctx);
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, import_node_path25.join)(dataDir, "tmp");
22489
- const userFiles = (0, import_node_path25.join)(dataDir, "user_files");
22490
- (0, import_node_fs22.mkdirSync)(ctx.paths.clickhouseData, { recursive: true });
22491
- (0, import_node_fs22.mkdirSync)(tmpDir, { recursive: true });
22492
- (0, import_node_fs22.mkdirSync)(userFiles, { recursive: true });
22493
- (0, import_node_fs22.mkdirSync)(logsDir, { recursive: true });
22494
- (0, import_node_fs22.mkdirSync)(path6.replace(/\/[^/]+$/, ""), { recursive: true });
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, import_node_fs22.writeFileSync)(path6, xml);
22625
+ (0, import_node_fs23.writeFileSync)(path6, xml);
22529
22626
  }
22530
- var import_node_fs22, import_node_path25, DB_NAME;
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
- import_node_fs22 = require("node:fs");
22535
- import_node_path25 = require("node:path");
22631
+ import_node_fs23 = require("node:fs");
22632
+ import_node_path26 = require("node:path");
22536
22633
  init_health();
22537
- init_paths();
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, import_node_fs23.existsSync)(path6)) return {};
22653
+ if (!(0, import_node_fs24.existsSync)(path6)) return {};
22557
22654
  const out = {};
22558
- for (const rawLine of (0, import_node_fs23.readFileSync)(path6, "utf8").split(/\r?\n/)) {
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 import_node_fs23;
22669
+ var import_node_fs24;
22573
22670
  var init_env_file = __esm({
22574
22671
  "src/services/env-file.ts"() {
22575
22672
  "use strict";
22576
- import_node_fs23 = require("node:fs");
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, import_node_path26.join)("langevals", "server.py")
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: 6e4
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 candidates = [
22672
- (0, import_node_path26.join)(__dirname, "..", "..", "..", "..", name),
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 import_node_fs24, import_node_path26, import_node_url4, __dirname;
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
- import_node_fs24 = require("node:fs");
22683
- import_node_path26 = require("node:path");
22684
- import_node_url4 = require("node:url");
22778
+ import_node_fs25 = require("node:fs");
22779
+ import_node_path27 = require("node:path");
22780
+ init_app_dir();
22685
22781
  init_health();
22686
- init_paths();
22782
+ init_paths2();
22687
22783
  init_spawn();
22688
- __dirname = (0, import_node_path26.dirname)((0, import_node_url4.fileURLToPath)(__cli_url));
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,29 +22833,44 @@ 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, import_node_path27.join)(langwatchDir, "node_modules");
22697
- const distPath = (0, import_node_path27.join)(langwatchDir, "dist");
22698
- if ((0, import_node_fs25.existsSync)(nodeModulesPath) && (0, import_node_fs25.existsSync)((0, import_node_path27.join)(nodeModulesPath, ".prisma")) && (0, import_node_fs25.existsSync)((0, import_node_path27.join)(distPath, "client"))) {
22836
+ const nodeModulesPath = (0, import_node_path28.join)(langwatchDir, "node_modules");
22837
+ const distPath = (0, import_node_path28.join)(langwatchDir, "dist");
22838
+ if ((0, import_node_fs26.existsSync)(nodeModulesPath) && (0, import_node_fs26.existsSync)((0, import_node_path28.join)(nodeModulesPath, ".prisma")) && (0, import_node_fs26.existsSync)((0, import_node_path28.join)(distPath, "client"))) {
22699
22839
  return;
22700
22840
  }
22701
22841
  bus.emit({ type: "starting", service: "pnpm:langwatch" });
22702
22842
  const start = Date.now();
22703
22843
  const pnpm = await resolvePnpm();
22704
- const distAlreadyBuilt = (0, import_node_fs25.existsSync)((0, import_node_path27.join)(distPath, "client"));
22705
- if (!(0, import_node_fs25.existsSync)(nodeModulesPath)) {
22706
- const installArgs = distAlreadyBuilt ? ["install", "--prod", "--frozen-lockfile"] : ["install", "--prod=false", "--frozen-lockfile"];
22707
- await execa(pnpm.command, [...pnpm.args, "-C", langwatchDir, ...installArgs], {
22708
- stdio: "inherit"
22709
- });
22844
+ const distAlreadyBuilt = (0, import_node_fs26.existsSync)((0, import_node_path28.join)(distPath, "client"));
22845
+ if (!(0, import_node_fs26.existsSync)(nodeModulesPath)) {
22846
+ await execAndPipe(
22847
+ bus,
22848
+ "pnpm:langwatch",
22849
+ pnpm.command,
22850
+ [...pnpm.args, "-C", langwatchDir, "install", "--prod=false", "--frozen-lockfile"]
22851
+ );
22852
+ if (distAlreadyBuilt) {
22853
+ await execAndPipe(
22854
+ bus,
22855
+ "pnpm:langwatch",
22856
+ pnpm.command,
22857
+ [...pnpm.args, "-C", langwatchDir, "exec", "prisma", "generate"]
22858
+ );
22859
+ }
22710
22860
  }
22711
22861
  if (!distAlreadyBuilt) {
22712
- await execa(pnpm.command, [...pnpm.args, "-C", langwatchDir, "run", "build"], {
22713
- stdio: "inherit",
22714
- env: {
22715
- ...process.env,
22716
- NODE_ENV: "production"
22862
+ await execAndPipe(
22863
+ bus,
22864
+ "pnpm:langwatch",
22865
+ pnpm.command,
22866
+ [...pnpm.args, "-C", langwatchDir, "run", "build"],
22867
+ {
22868
+ env: {
22869
+ ...process.env,
22870
+ NODE_ENV: "production"
22871
+ }
22717
22872
  }
22718
- });
22873
+ );
22719
22874
  }
22720
22875
  bus.emit({ type: "healthy", service: "pnpm:langwatch", durationMs: Date.now() - start });
22721
22876
  }
@@ -22727,30 +22882,18 @@ async function resolvePnpm() {
22727
22882
  throw new Error("pnpm not found on PATH and corepack is unavailable");
22728
22883
  }
22729
22884
  function locateLangwatchDir() {
22730
- const candidates = [
22731
- (0, import_node_path27.join)(__dirname2, "..", "..", "..", "langwatch"),
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;
22885
+ const dir = (0, import_node_path28.join)(appRoot(), "langwatch");
22886
+ return (0, import_node_fs26.existsSync)((0, import_node_path28.join)(dir, "package.json")) ? dir : null;
22744
22887
  }
22745
- var import_node_fs25, import_node_path27, import_node_url5, __dirname2;
22888
+ var import_node_fs26, import_node_path28;
22746
22889
  var init_node_deps = __esm({
22747
22890
  "src/services/node-deps.ts"() {
22748
22891
  "use strict";
22749
22892
  init_execa();
22750
- import_node_fs25 = require("node:fs");
22751
- import_node_path27 = require("node:path");
22752
- import_node_url5 = require("node:url");
22753
- __dirname2 = (0, import_node_path27.dirname)((0, import_node_url5.fileURLToPath)(__cli_url));
22893
+ import_node_fs26 = require("node:fs");
22894
+ import_node_path28 = require("node:path");
22895
+ init_app_dir();
22896
+ init_pipe_to_bus();
22754
22897
  }
22755
22898
  });
22756
22899
 
@@ -22797,23 +22940,23 @@ async function startLangwatch(ctx, bus, envFromFile) {
22797
22940
  return handle;
22798
22941
  }
22799
22942
  async function ensureNodeModules(langwatchDir, bus) {
22800
- if ((0, import_node_fs26.existsSync)((0, import_node_path28.join)(langwatchDir, "node_modules"))) return;
22943
+ if ((0, import_node_fs27.existsSync)((0, import_node_path29.join)(langwatchDir, "node_modules"))) return;
22801
22944
  bus.emit({ type: "log", service: "langwatch", stream: "stdout", line: "installing node_modules (one-time setup)..." });
22802
22945
  await execa("pnpm", ["install", "--prod=false", "--frozen-lockfile"], {
22803
22946
  cwd: langwatchDir,
22804
22947
  stdio: "inherit"
22805
22948
  });
22806
22949
  }
22807
- var import_node_fs26, import_node_path28;
22950
+ var import_node_fs27, import_node_path29;
22808
22951
  var init_langwatch = __esm({
22809
22952
  "src/services/langwatch.ts"() {
22810
22953
  "use strict";
22811
22954
  init_execa();
22812
- import_node_fs26 = require("node:fs");
22813
- import_node_path28 = require("node:path");
22955
+ import_node_fs27 = require("node:fs");
22956
+ import_node_path29 = require("node:path");
22814
22957
  init_health();
22815
22958
  init_node_deps();
22816
- init_paths();
22959
+ init_paths2();
22817
22960
  init_spawn();
22818
22961
  }
22819
22962
  });
@@ -22858,8 +23001,12 @@ async function startLangwatchNlp(ctx, bus, envFromFile) {
22858
23001
  bus
22859
23002
  });
22860
23003
  const ready = await pollUntilHealthy({
23004
+ // 120s — uvicorn boot + LiteLLM proxy init + 4-worker ProcessPool spawn
23005
+ // can hit ~50-60s on a cold cache, and a parallel dogfood run pushed
23006
+ // it past the previous 60s ceiling. langevals already polls a similar
23007
+ // service, but its app surface is smaller and starts faster.
22861
23008
  check: httpGetCheck(`http://127.0.0.1:${ctx.ports.nlp}/health`),
22862
- timeoutMs: 6e4
23009
+ timeoutMs: 12e4
22863
23010
  });
22864
23011
  if (!ready.ok) {
22865
23012
  await handle.stop();
@@ -22869,24 +23016,19 @@ async function startLangwatchNlp(ctx, bus, envFromFile) {
22869
23016
  return handle;
22870
23017
  }
22871
23018
  function locateProject2(name) {
22872
- const candidates = [
22873
- (0, import_node_path29.join)(__dirname3, "..", "..", "..", "..", name),
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;
23019
+ const dir = (0, import_node_path30.join)(appRoot(), name);
23020
+ return (0, import_node_fs28.existsSync)((0, import_node_path30.join)(dir, "pyproject.toml")) ? dir : null;
22878
23021
  }
22879
- var import_node_fs27, import_node_path29, import_node_url6, __dirname3;
23022
+ var import_node_fs28, import_node_path30;
22880
23023
  var init_langwatch_nlp = __esm({
22881
23024
  "src/services/langwatch-nlp.ts"() {
22882
23025
  "use strict";
22883
- import_node_fs27 = require("node:fs");
22884
- import_node_path29 = require("node:path");
22885
- import_node_url6 = require("node:url");
23026
+ import_node_fs28 = require("node:fs");
23027
+ import_node_path30 = require("node:path");
23028
+ init_app_dir();
22886
23029
  init_health();
22887
- init_paths();
23030
+ init_paths2();
22888
23031
  init_spawn();
22889
- __dirname3 = (0, import_node_path29.dirname)((0, import_node_url6.fileURLToPath)(__cli_url));
22890
23032
  }
22891
23033
  });
22892
23034
 
@@ -22914,27 +23056,27 @@ async function runMigrations(ctx, bus, envFromFile) {
22914
23056
  SKIP_PRISMA_MIGRATE: "false",
22915
23057
  SKIP_CLICKHOUSE_MIGRATE: "false"
22916
23058
  };
22917
- await execa("pnpm", ["run", "prisma:migrate"], { cwd: langwatchDir, env: env3, stdio: "inherit" });
22918
- await execa("pnpm", ["run", "clickhouse:migrate"], { cwd: langwatchDir, env: env3, stdio: "inherit" });
23059
+ await execAndPipe(bus, "migrate:prisma", "pnpm", ["run", "prisma:migrate"], { cwd: langwatchDir, env: env3 });
23060
+ await execAndPipe(bus, "migrate:clickhouse", "pnpm", ["run", "clickhouse:migrate"], { cwd: langwatchDir, env: env3 });
22919
23061
  bus.emit({ type: "healthy", service: "postgres", durationMs: Date.now() - start });
22920
23062
  }
22921
23063
  var init_migrate = __esm({
22922
23064
  "src/services/migrate.ts"() {
22923
23065
  "use strict";
22924
- init_execa();
22925
23066
  init_node_deps();
23067
+ init_pipe_to_bus();
22926
23068
  }
22927
23069
  });
22928
23070
 
22929
23071
  // src/services/postgres.ts
22930
23072
  function postgresLayout(postgresBinPath) {
22931
- const binDir = (0, import_node_path30.dirname)(postgresBinPath);
23073
+ const binDir = (0, import_node_path31.dirname)(postgresBinPath);
22932
23074
  return {
22933
23075
  postgresBin: postgresBinPath,
22934
- initdb: (0, import_node_path30.join)(binDir, "initdb"),
22935
- pgCtl: (0, import_node_path30.join)(binDir, "pg_ctl"),
22936
- psql: (0, import_node_path30.join)(binDir, "psql"),
22937
- createdb: (0, import_node_path30.join)(binDir, "createdb")
23076
+ initdb: (0, import_node_path31.join)(binDir, "initdb"),
23077
+ pgCtl: (0, import_node_path31.join)(binDir, "pg_ctl"),
23078
+ psql: (0, import_node_path31.join)(binDir, "psql"),
23079
+ createdb: (0, import_node_path31.join)(binDir, "createdb")
22938
23080
  };
22939
23081
  }
22940
23082
  async function startPostgres(ctx, bus) {
@@ -22945,7 +23087,7 @@ async function startPostgres(ctx, bus) {
22945
23087
  const layout = postgresLayout(resolvedPath);
22946
23088
  const dataDir = ctx.paths.postgresData;
22947
23089
  const sp = servicePaths(ctx.paths);
22948
- if (!(0, import_node_fs28.existsSync)((0, import_node_path30.join)(dataDir, "PG_VERSION"))) {
23090
+ if (!(0, import_node_fs29.existsSync)((0, import_node_path31.join)(dataDir, "PG_VERSION"))) {
22949
23091
  await initdb(layout, dataDir);
22950
23092
  }
22951
23093
  const handle = supervise({
@@ -22960,7 +23102,7 @@ async function startPostgres(ctx, bus) {
22960
23102
  "-h",
22961
23103
  "127.0.0.1",
22962
23104
  "-c",
22963
- "unix_socket_directories=" + (0, import_node_path30.dirname)(sp.pid("postgres")),
23105
+ "unix_socket_directories=" + (0, import_node_path31.dirname)(sp.pid("postgres")),
22964
23106
  "-c",
22965
23107
  "log_destination=stderr",
22966
23108
  "-c",
@@ -22994,7 +23136,7 @@ async function startPostgres(ctx, bus) {
22994
23136
  return handle;
22995
23137
  }
22996
23138
  async function initdb(layout, dataDir) {
22997
- (0, import_node_fs28.mkdirSync)(dataDir, { recursive: true });
23139
+ (0, import_node_fs29.mkdirSync)(dataDir, { recursive: true });
22998
23140
  await execa(
22999
23141
  layout.initdb,
23000
23142
  [
@@ -23063,15 +23205,15 @@ async function ensureDatabase2(layout, port) {
23063
23205
  { stdio: "ignore" }
23064
23206
  );
23065
23207
  }
23066
- var import_node_fs28, import_node_path30, DB_USER, DB_NAME2;
23208
+ var import_node_fs29, import_node_path31, DB_USER, DB_NAME2;
23067
23209
  var init_postgres = __esm({
23068
23210
  "src/services/postgres.ts"() {
23069
23211
  "use strict";
23070
23212
  init_execa();
23071
- import_node_fs28 = require("node:fs");
23072
- import_node_path30 = require("node:path");
23213
+ import_node_fs29 = require("node:fs");
23214
+ import_node_path31 = require("node:path");
23073
23215
  init_health();
23074
- init_paths();
23216
+ init_paths2();
23075
23217
  init_spawn();
23076
23218
  DB_USER = "langwatch";
23077
23219
  DB_NAME2 = "langwatch_db";
@@ -23086,7 +23228,7 @@ async function startRedis(ctx, bus) {
23086
23228
  if (!resolvedPath) throw new Error("redis predep not resolved \u2014 run install first");
23087
23229
  const sp = servicePaths(ctx.paths);
23088
23230
  const conf = sp.redisConf;
23089
- if (!(0, import_node_fs29.existsSync)(conf)) writeRedisConf(conf, ctx.ports.redis, ctx.paths.redisData);
23231
+ if (!(0, import_node_fs30.existsSync)(conf)) writeRedisConf(conf, ctx.ports.redis, ctx.paths.redisData);
23090
23232
  const handle = supervise({
23091
23233
  spec: {
23092
23234
  name: "redis",
@@ -23115,8 +23257,8 @@ async function startRedis(ctx, bus) {
23115
23257
  return handle;
23116
23258
  }
23117
23259
  function writeRedisConf(path6, port, dataDir) {
23118
- (0, import_node_fs29.mkdirSync)((0, import_node_path31.dirname)(path6), { recursive: true });
23119
- (0, import_node_fs29.mkdirSync)(dataDir, { recursive: true });
23260
+ (0, import_node_fs30.mkdirSync)((0, import_node_path32.dirname)(path6), { recursive: true });
23261
+ (0, import_node_fs30.mkdirSync)(dataDir, { recursive: true });
23120
23262
  const lines = [
23121
23263
  `port ${port}`,
23122
23264
  "bind 127.0.0.1",
@@ -23130,16 +23272,16 @@ function writeRedisConf(path6, port, dataDir) {
23130
23272
  "maxmemory-policy allkeys-lru",
23131
23273
  ""
23132
23274
  ];
23133
- (0, import_node_fs29.writeFileSync)(path6, lines.join("\n"));
23275
+ (0, import_node_fs30.writeFileSync)(path6, lines.join("\n"));
23134
23276
  }
23135
- var import_node_fs29, import_node_path31;
23277
+ var import_node_fs30, import_node_path32;
23136
23278
  var init_redis = __esm({
23137
23279
  "src/services/redis.ts"() {
23138
23280
  "use strict";
23139
- import_node_fs29 = require("node:fs");
23140
- import_node_path31 = require("node:path");
23281
+ import_node_fs30 = require("node:fs");
23282
+ import_node_path32 = require("node:path");
23141
23283
  init_health();
23142
- init_paths();
23284
+ init_paths2();
23143
23285
  init_spawn();
23144
23286
  }
23145
23287
  });
@@ -23153,72 +23295,62 @@ async function syncVenvs(ctx, bus) {
23153
23295
  await Promise.all(
23154
23296
  specs.map(async (spec) => {
23155
23297
  const venvDir = sp.venv(spec.name);
23156
- const hashFile = (0, import_node_path32.join)(venvDir, ".lock-hash");
23298
+ const hashFile = (0, import_node_path33.join)(venvDir, ".lock-hash");
23157
23299
  const expected = hashFileSafely(spec.lockFile);
23158
- if ((0, import_node_fs30.existsSync)(venvDir) && readFileSafely(hashFile) === expected) return;
23300
+ if ((0, import_node_fs31.existsSync)(venvDir) && readFileSafely(hashFile) === expected) return;
23159
23301
  bus.emit({ type: "starting", service: `uv:${spec.name}` });
23160
23302
  const start = Date.now();
23161
- (0, import_node_fs30.mkdirSync)(venvDir, { recursive: true });
23162
- await execa(
23303
+ (0, import_node_fs31.mkdirSync)(venvDir, { recursive: true });
23304
+ await execAndPipe(
23305
+ bus,
23306
+ `uv:${spec.name}`,
23163
23307
  uvBin,
23164
23308
  ["sync", "--project", spec.projectDir],
23165
23309
  {
23166
23310
  env: {
23167
23311
  ...process.env,
23168
23312
  UV_PROJECT_ENVIRONMENT: venvDir
23169
- },
23170
- stdio: "inherit"
23313
+ }
23171
23314
  }
23172
23315
  );
23173
- (0, import_node_fs30.writeFileSync)(hashFile, expected);
23316
+ (0, import_node_fs31.writeFileSync)(hashFile, expected);
23174
23317
  bus.emit({ type: "healthy", service: `uv:${spec.name}`, durationMs: Date.now() - start });
23175
23318
  })
23176
23319
  );
23177
23320
  }
23178
23321
  function resolveVenvSpecs() {
23179
- const root2 = locateMonorepoRoot();
23322
+ const root2 = appRoot();
23180
23323
  return [
23181
23324
  {
23182
23325
  name: "langwatch_nlp",
23183
- projectDir: (0, import_node_path32.join)(root2, "langwatch_nlp"),
23184
- lockFile: (0, import_node_path32.join)(root2, "langwatch_nlp", "uv.lock")
23326
+ projectDir: (0, import_node_path33.join)(root2, "langwatch_nlp"),
23327
+ lockFile: (0, import_node_path33.join)(root2, "langwatch_nlp", "uv.lock")
23185
23328
  },
23186
23329
  {
23187
23330
  name: "langevals",
23188
- projectDir: (0, import_node_path32.join)(root2, "langevals"),
23189
- lockFile: (0, import_node_path32.join)(root2, "langevals", "uv.lock")
23331
+ projectDir: (0, import_node_path33.join)(root2, "langevals"),
23332
+ lockFile: (0, import_node_path33.join)(root2, "langevals", "uv.lock")
23190
23333
  }
23191
23334
  ];
23192
23335
  }
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
23336
  function hashFileSafely(file) {
23204
- if (!(0, import_node_fs30.existsSync)(file)) return "missing";
23205
- return (0, import_node_crypto5.createHash)("sha256").update((0, import_node_fs30.readFileSync)(file)).digest("hex");
23337
+ if (!(0, import_node_fs31.existsSync)(file)) return "missing";
23338
+ return (0, import_node_crypto5.createHash)("sha256").update((0, import_node_fs31.readFileSync)(file)).digest("hex");
23206
23339
  }
23207
23340
  function readFileSafely(file) {
23208
- if (!(0, import_node_fs30.existsSync)(file)) return null;
23209
- return (0, import_node_fs30.readFileSync)(file, "utf8").trim();
23341
+ if (!(0, import_node_fs31.existsSync)(file)) return null;
23342
+ return (0, import_node_fs31.readFileSync)(file, "utf8").trim();
23210
23343
  }
23211
- var import_node_fs30, import_node_crypto5, import_node_path32, import_node_url7, __dirname4;
23344
+ var import_node_fs31, import_node_crypto5, import_node_path33;
23212
23345
  var init_venvs = __esm({
23213
23346
  "src/services/venvs.ts"() {
23214
23347
  "use strict";
23215
- init_execa();
23216
- import_node_fs30 = require("node:fs");
23348
+ import_node_fs31 = require("node:fs");
23217
23349
  import_node_crypto5 = require("node:crypto");
23218
- import_node_path32 = require("node:path");
23219
- import_node_url7 = require("node:url");
23220
- init_paths();
23221
- __dirname4 = (0, import_node_path32.dirname)((0, import_node_url7.fileURLToPath)(__cli_url));
23350
+ import_node_path33 = require("node:path");
23351
+ init_app_dir();
23352
+ init_paths2();
23353
+ init_pipe_to_bus();
23222
23354
  }
23223
23355
  });
23224
23356
 
@@ -23251,6 +23383,7 @@ var init_runtime = __esm({
23251
23383
  "src/services/runtime.ts"() {
23252
23384
  "use strict";
23253
23385
  init_aigateway();
23386
+ init_app_dir();
23254
23387
  init_clickhouse();
23255
23388
  init_env2();
23256
23389
  init_env_file();
@@ -23270,6 +23403,7 @@ var init_runtime = __esm({
23270
23403
  },
23271
23404
  async installServices(ctx) {
23272
23405
  const bus = busFor(ctx);
23406
+ await ensureAppDir(ctx, bus);
23273
23407
  await Promise.all([
23274
23408
  syncVenvs(ctx, bus),
23275
23409
  ensureLangwatchDeps(ctx, bus)
@@ -25857,24 +25991,7 @@ var Listr = class {
25857
25991
  // src/predeps/runner.ts
25858
25992
  var import_node_fs19 = require("node:fs");
25859
25993
  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
- };
25994
+ init_paths();
25878
25995
 
25879
25996
  // src/predeps/aigateway.ts
25880
25997
  init_execa();
@@ -25985,17 +26102,20 @@ function makeAigatewayPredep(version) {
25985
26102
  const v2 = await resolveVersion(out) ?? version;
25986
26103
  return { version: v2, resolvedPath: out };
25987
26104
  } catch (err) {
25988
- if (!(err instanceof Error) || !/HTTP 404/.test(err.message)) throw err;
25989
- }
25990
- const repoRoot = findRepoRoot();
25991
- if (repoRoot) {
25992
- await buildFromCheckout(repoRoot, paths2.bin, task);
25993
- const v2 = await resolveVersion(out) ?? `${version}+local-build`;
25994
- return { version: v2, resolvedPath: out };
26105
+ const is404 = err instanceof Error && /HTTP 404/.test(err.message);
26106
+ if (!is404) throw err;
26107
+ if (process.env.LANGWATCH_AIGATEWAY_DEV_BUILD === "1") {
26108
+ const repoRoot = findRepoRoot();
26109
+ if (repoRoot) {
26110
+ await buildFromCheckout(repoRoot, paths2.bin, task);
26111
+ const v2 = await resolveVersion(out) ?? `${version}+local-build`;
26112
+ return { version: v2, resolvedPath: out };
26113
+ }
26114
+ }
26115
+ throw new Error(
26116
+ `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.`
26117
+ );
25995
26118
  }
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
26119
  }
26000
26120
  };
26001
26121
  }
@@ -26025,7 +26145,7 @@ async function resolveVersion2(bin) {
26025
26145
  }
26026
26146
  var clickhousePredep = {
26027
26147
  id: "clickhouse",
26028
- label: "clickhouse (analytics)",
26148
+ label: "clickhouse",
26029
26149
  required: true,
26030
26150
  // Always use the embedded clickhouse. NOT checking `which clickhouse` —
26031
26151
  // version drift between a user's system clickhouse and the schema /
@@ -26079,7 +26199,7 @@ async function resolveVersion3(bin) {
26079
26199
  }
26080
26200
  var goosePredep = {
26081
26201
  id: "goose",
26082
- label: "goose (clickhouse migrations runner)",
26202
+ label: "goose",
26083
26203
  required: true,
26084
26204
  async detect(paths2) {
26085
26205
  const bundled = (0, import_node_path9.join)(paths2.bin, "goose");
@@ -26157,7 +26277,7 @@ async function sha256OfFile(path6) {
26157
26277
  }
26158
26278
  var postgresPredep = {
26159
26279
  id: "postgres",
26160
- label: `postgresql ${PG_MAJOR} (primary store)`,
26280
+ label: `postgresql ${PG_MAJOR}`,
26161
26281
  required: true,
26162
26282
  async detect(paths2) {
26163
26283
  const bundled = (0, import_node_path19.join)(paths2.bin, "postgres", "bin", "postgres");
@@ -26234,7 +26354,7 @@ async function sha256OfFile2(path6) {
26234
26354
  }
26235
26355
  var redisPredep = {
26236
26356
  id: "redis",
26237
- label: "redis-server (queue + fold cache backend)",
26357
+ label: "redis-server",
26238
26358
  required: true,
26239
26359
  // Always use the embedded redis. NOT checking `which redis-server` —
26240
26360
  // a user with a system redis installed (debian's redis 6.x, brew's
@@ -26301,7 +26421,7 @@ async function resolveVersion6(bin) {
26301
26421
  }
26302
26422
  var uvPredep = {
26303
26423
  id: "uv",
26304
- label: "uv (Python package manager)",
26424
+ label: "uv",
26305
26425
  required: true,
26306
26426
  async detect(paths2) {
26307
26427
  const candidates = [
@@ -26478,6 +26598,7 @@ function collectResult(predeps, detection, installResults) {
26478
26598
  }
26479
26599
 
26480
26600
  // src/predeps/detect-only.ts
26601
+ init_paths();
26481
26602
  async function inspectPredeps({ version }) {
26482
26603
  const predeps = predepRegistry({ version });
26483
26604
  const rows = [];
@@ -26562,6 +26683,7 @@ function printConflicts(report) {
26562
26683
  }
26563
26684
 
26564
26685
  // src/cli.ts
26686
+ init_paths();
26565
26687
  init_ports();
26566
26688
  init_env();
26567
26689
 
@@ -26582,7 +26704,7 @@ var placeholderRuntime = {
26582
26704
  };
26583
26705
 
26584
26706
  // src/cli.ts
26585
- var VERSION = true ? "3.1.0-beta.1" : "0.0.0-dev";
26707
+ var VERSION = true ? "3.1.0-beta.10" : "0.0.0-dev";
26586
26708
  async function loadRuntime() {
26587
26709
  try {
26588
26710
  const real = await Promise.resolve().then(() => (init_runtime(), runtime_exports));
@@ -26633,8 +26755,8 @@ program2.command("start", { isDefault: true }).description("install missing pred
26633
26755
  userEnv: captureUserEnv()
26634
26756
  };
26635
26757
  ensureEnvFile(ctx);
26636
- await runtime2.installServices(ctx);
26637
26758
  const eventsStream = streamEventsToTTY(runtime2.events(ctx));
26759
+ await runtime2.installServices(ctx);
26638
26760
  const handles = await runtime2.startAll(ctx);
26639
26761
  await runtime2.waitForHealth(ctx, { timeoutMs: 6e4 });
26640
26762
  const url = `http://localhost:${ports.langwatch}`;