@langwatch/server 3.1.0-beta.5 → 3.1.0-beta.7

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 (213) hide show
  1. package/langwatch/package.json +1 -1
  2. package/langwatch/pnpm-workspace.yaml +0 -1
  3. package/mcp-server/.env.example +2 -0
  4. package/mcp-server/.eslintrc.cjs +36 -0
  5. package/mcp-server/CHANGELOG.md +165 -0
  6. package/mcp-server/CONTRIBUTING.md +96 -0
  7. package/mcp-server/README.md +172 -0
  8. package/mcp-server/dist/archive-scenario-WJ2A7ETN.js +19 -0
  9. package/mcp-server/dist/archive-suite-4JOM4SSL.js +15 -0
  10. package/mcp-server/dist/assign-prompt-tag-GL7EAAF3.js +19 -0
  11. package/mcp-server/dist/chunk-2GT7IFWK.js +40 -0
  12. package/mcp-server/dist/chunk-2WPLXEKF.js +127 -0
  13. package/mcp-server/dist/chunk-4AUB2BIA.js +71 -0
  14. package/mcp-server/dist/chunk-BWWY5KEF.js +71 -0
  15. package/mcp-server/dist/chunk-CCWCIJJ3.js +22 -0
  16. package/mcp-server/dist/chunk-EGH5RPXM.js +25 -0
  17. package/mcp-server/dist/chunk-EUQDVOSU.js +39 -0
  18. package/mcp-server/dist/chunk-HYMIWO3U.js +44 -0
  19. package/mcp-server/dist/chunk-IE4M5OGE.js +42 -0
  20. package/mcp-server/dist/chunk-LUMEZEHL.js +48 -0
  21. package/mcp-server/dist/chunk-NUFPTHKU.js +9 -0
  22. package/mcp-server/dist/chunk-UDHJYT6P.js +1567 -0
  23. package/mcp-server/dist/chunk-WQG2DFHX.js +86 -0
  24. package/mcp-server/dist/chunk-WVI5CJ6S.js +21 -0
  25. package/mcp-server/dist/chunk-ZVS4UKN2.js +35 -0
  26. package/mcp-server/dist/chunk-ZXKLPC2E.js +27 -0
  27. package/mcp-server/dist/config.d.ts +17 -0
  28. package/mcp-server/dist/config.js +13 -0
  29. package/mcp-server/dist/create-agent-MBOOT3XK.js +23 -0
  30. package/mcp-server/dist/create-annotation-XMV6A7ED.js +24 -0
  31. package/mcp-server/dist/create-dashboard-VRKLFVZJ.js +18 -0
  32. package/mcp-server/dist/create-dataset-7HQPZCRE.js +22 -0
  33. package/mcp-server/dist/create-dataset-records-2NIVFYTV.js +22 -0
  34. package/mcp-server/dist/create-evaluator-WYFRFLRC.js +27 -0
  35. package/mcp-server/dist/create-mcp-server.d.ts +8 -0
  36. package/mcp-server/dist/create-mcp-server.js +8 -0
  37. package/mcp-server/dist/create-prompt-IEN7O6JT.js +39 -0
  38. package/mcp-server/dist/create-prompt-tag-CAEZ45VO.js +17 -0
  39. package/mcp-server/dist/create-scenario-6YHSMGLP.js +26 -0
  40. package/mcp-server/dist/create-suite-H5XOFDE5.js +38 -0
  41. package/mcp-server/dist/delete-agent-JKTNBWAA.js +18 -0
  42. package/mcp-server/dist/delete-annotation-ACMDV6QO.js +17 -0
  43. package/mcp-server/dist/delete-dashboard-VJSR7CRU.js +18 -0
  44. package/mcp-server/dist/delete-dataset-RTTTWP4D.js +20 -0
  45. package/mcp-server/dist/delete-dataset-records-KNQTIPQK.js +21 -0
  46. package/mcp-server/dist/delete-evaluator-7FVC5WM4.js +15 -0
  47. package/mcp-server/dist/delete-prompt-tag-ZMZUAGFW.js +17 -0
  48. package/mcp-server/dist/delete-workflow-EYQ3T4RQ.js +17 -0
  49. package/mcp-server/dist/discover-evaluator-schema-H23XCLNE.js +1402 -0
  50. package/mcp-server/dist/discover-scenario-schema-MEEEVND7.js +65 -0
  51. package/mcp-server/dist/discover-schema-3T52ORPB.js +446 -0
  52. package/mcp-server/dist/get-agent-E3QSTVKG.js +28 -0
  53. package/mcp-server/dist/get-analytics-2OHV763I.js +72 -0
  54. package/mcp-server/dist/get-dashboard-PC7JDHH6.js +29 -0
  55. package/mcp-server/dist/get-dataset-H5IK5FVU.js +48 -0
  56. package/mcp-server/dist/get-evaluator-UWVUPYTM.js +47 -0
  57. package/mcp-server/dist/get-prompt-WZUOLLQC.js +45 -0
  58. package/mcp-server/dist/get-scenario-Q6LCNUYN.js +33 -0
  59. package/mcp-server/dist/get-simulation-run-Z2XKO256.js +56 -0
  60. package/mcp-server/dist/get-suite-BXK5TN7P.js +44 -0
  61. package/mcp-server/dist/get-trace-4EJAYVBG.js +50 -0
  62. package/mcp-server/dist/get-workflow-O34QJLHD.js +25 -0
  63. package/mcp-server/dist/http-server-RSTXN4CN.js +224 -0
  64. package/mcp-server/dist/index.d.ts +2 -0
  65. package/mcp-server/dist/index.js +67774 -0
  66. package/mcp-server/dist/langwatch-api-annotations-ERBG27RF.js +17 -0
  67. package/mcp-server/dist/langwatch-api-dashboards-G6TR7VVO.js +17 -0
  68. package/mcp-server/dist/langwatch-api-monitors-WSXZLS2B.js +52 -0
  69. package/mcp-server/dist/langwatch-api-secrets-RR5DKG2X.js +40 -0
  70. package/mcp-server/dist/langwatch-api-triggers-2RTNSWQY.js +30 -0
  71. package/mcp-server/dist/langwatch-api-workflows-VJRIIDZ7.js +15 -0
  72. package/mcp-server/dist/list-agents-AW3P6FJV.js +32 -0
  73. package/mcp-server/dist/list-annotations-QNCGWPQ3.js +33 -0
  74. package/mcp-server/dist/list-dashboards-R7RK2IXL.js +32 -0
  75. package/mcp-server/dist/list-dataset-records-WVCSQP7P.js +39 -0
  76. package/mcp-server/dist/list-datasets-KEXRLDEU.js +60 -0
  77. package/mcp-server/dist/list-evaluators-7R2LB4JH.js +34 -0
  78. package/mcp-server/dist/list-model-providers-OBYJCKBX.js +35 -0
  79. package/mcp-server/dist/list-prompt-tags-6LY3ZPYI.js +23 -0
  80. package/mcp-server/dist/list-prompts-VWEZ4CDE.js +32 -0
  81. package/mcp-server/dist/list-scenarios-TXD4W2ZJ.js +40 -0
  82. package/mcp-server/dist/list-simulation-runs-RHPOLMFI.js +43 -0
  83. package/mcp-server/dist/list-suites-FSGBX27Z.js +42 -0
  84. package/mcp-server/dist/list-workflows-VRGEZ3EN.js +35 -0
  85. package/mcp-server/dist/rename-prompt-tag-VOJJLX4M.js +18 -0
  86. package/mcp-server/dist/run-agent-KTCC7TB7.js +36 -0
  87. package/mcp-server/dist/run-evaluation-2X3V3Q6L.js +64 -0
  88. package/mcp-server/dist/run-suite-BTMHGI2D.js +29 -0
  89. package/mcp-server/dist/run-workflow-IGAYGKJL.js +36 -0
  90. package/mcp-server/dist/search-traces-VYFUIMXH.js +72 -0
  91. package/mcp-server/dist/set-model-provider-W5IUI326.js +33 -0
  92. package/mcp-server/dist/update-agent-4BB7EYLR.js +20 -0
  93. package/mcp-server/dist/update-dataset-CXBKZ4W3.js +22 -0
  94. package/mcp-server/dist/update-dataset-record-HOHAMHXG.js +19 -0
  95. package/mcp-server/dist/update-evaluator-IVOR6FTR.js +24 -0
  96. package/mcp-server/dist/update-prompt-OWQAKE7K.js +24 -0
  97. package/mcp-server/dist/update-scenario-GDFVILPN.js +27 -0
  98. package/mcp-server/dist/update-suite-BXYUYSPT.js +39 -0
  99. package/mcp-server/package.json +79 -0
  100. package/mcp-server/pnpm-lock.yaml +6103 -0
  101. package/mcp-server/pnpm-workspace.yaml +2 -0
  102. package/mcp-server/pyproject.toml +17 -0
  103. package/mcp-server/src/__tests__/all-tools.integration.test.ts +1681 -0
  104. package/mcp-server/src/__tests__/config.unit.test.ts +169 -0
  105. package/mcp-server/src/__tests__/datasets.integration.test.ts +603 -0
  106. package/mcp-server/src/__tests__/datasets.unit.test.ts +240 -0
  107. package/mcp-server/src/__tests__/date-parsing.unit.test.ts +78 -0
  108. package/mcp-server/src/__tests__/discover-evaluator-schema.unit.test.ts +89 -0
  109. package/mcp-server/src/__tests__/discover-schema.unit.test.ts +118 -0
  110. package/mcp-server/src/__tests__/docker.integration.test.ts +234 -0
  111. package/mcp-server/src/__tests__/evaluator-tools.unit.test.ts +262 -0
  112. package/mcp-server/src/__tests__/http-transport.integration.test.ts +397 -0
  113. package/mcp-server/src/__tests__/integration.integration.test.ts +288 -0
  114. package/mcp-server/src/__tests__/langwatch-api.unit.test.ts +455 -0
  115. package/mcp-server/src/__tests__/model-provider-tools.unit.test.ts +190 -0
  116. package/mcp-server/src/__tests__/scenario-tools.integration.test.ts +286 -0
  117. package/mcp-server/src/__tests__/scenario-tools.unit.test.ts +185 -0
  118. package/mcp-server/src/__tests__/schemas.unit.test.ts +85 -0
  119. package/mcp-server/src/__tests__/tools.unit.test.ts +900 -0
  120. package/mcp-server/src/config.d.ts +15 -0
  121. package/mcp-server/src/config.ts +107 -0
  122. package/mcp-server/src/create-mcp-server.d.ts +6 -0
  123. package/mcp-server/src/create-mcp-server.ts +1799 -0
  124. package/mcp-server/src/http-server.ts +329 -0
  125. package/mcp-server/src/index.ts +46 -0
  126. package/mcp-server/src/langwatch-api-agents.ts +108 -0
  127. package/mcp-server/src/langwatch-api-annotations.ts +49 -0
  128. package/mcp-server/src/langwatch-api-dashboards.ts +48 -0
  129. package/mcp-server/src/langwatch-api-datasets.ts +191 -0
  130. package/mcp-server/src/langwatch-api-evaluators.ts +80 -0
  131. package/mcp-server/src/langwatch-api-model-providers.ts +41 -0
  132. package/mcp-server/src/langwatch-api-monitors.ts +82 -0
  133. package/mcp-server/src/langwatch-api-scenarios.ts +67 -0
  134. package/mcp-server/src/langwatch-api-secrets.ts +48 -0
  135. package/mcp-server/src/langwatch-api-simulation-runs.ts +51 -0
  136. package/mcp-server/src/langwatch-api-suites.ts +118 -0
  137. package/mcp-server/src/langwatch-api-triggers.ts +48 -0
  138. package/mcp-server/src/langwatch-api-workflows.ts +41 -0
  139. package/mcp-server/src/langwatch-api.ts +299 -0
  140. package/mcp-server/src/schemas/analytics-groups.ts +78 -0
  141. package/mcp-server/src/schemas/analytics-metrics.ts +179 -0
  142. package/mcp-server/src/schemas/create-dataset.ts +48 -0
  143. package/mcp-server/src/schemas/filter-fields.ts +119 -0
  144. package/mcp-server/src/schemas/index.ts +4 -0
  145. package/mcp-server/src/tools/archive-scenario.ts +19 -0
  146. package/mcp-server/src/tools/archive-suite.ts +12 -0
  147. package/mcp-server/src/tools/assign-prompt-tag.ts +16 -0
  148. package/mcp-server/src/tools/create-agent.ts +15 -0
  149. package/mcp-server/src/tools/create-annotation.ts +18 -0
  150. package/mcp-server/src/tools/create-dashboard.ts +7 -0
  151. package/mcp-server/src/tools/create-dataset-records.ts +23 -0
  152. package/mcp-server/src/tools/create-dataset.ts +22 -0
  153. package/mcp-server/src/tools/create-evaluator.ts +33 -0
  154. package/mcp-server/src/tools/create-prompt-tag.ts +12 -0
  155. package/mcp-server/src/tools/create-prompt.ts +58 -0
  156. package/mcp-server/src/tools/create-scenario.ts +30 -0
  157. package/mcp-server/src/tools/create-suite.ts +42 -0
  158. package/mcp-server/src/tools/delete-agent.ts +7 -0
  159. package/mcp-server/src/tools/delete-annotation.ts +7 -0
  160. package/mcp-server/src/tools/delete-dashboard.ts +7 -0
  161. package/mcp-server/src/tools/delete-dataset-records.ts +22 -0
  162. package/mcp-server/src/tools/delete-dataset.ts +20 -0
  163. package/mcp-server/src/tools/delete-evaluator.ts +12 -0
  164. package/mcp-server/src/tools/delete-prompt-tag.ts +12 -0
  165. package/mcp-server/src/tools/delete-workflow.ts +7 -0
  166. package/mcp-server/src/tools/discover-evaluator-schema.ts +143 -0
  167. package/mcp-server/src/tools/discover-scenario-schema.ts +71 -0
  168. package/mcp-server/src/tools/discover-schema.ts +106 -0
  169. package/mcp-server/src/tools/format-dataset-mutation.ts +25 -0
  170. package/mcp-server/src/tools/get-agent.ts +21 -0
  171. package/mcp-server/src/tools/get-analytics.ts +98 -0
  172. package/mcp-server/src/tools/get-dashboard.ts +22 -0
  173. package/mcp-server/src/tools/get-dataset.ts +63 -0
  174. package/mcp-server/src/tools/get-evaluator.ts +53 -0
  175. package/mcp-server/src/tools/get-prompt.ts +54 -0
  176. package/mcp-server/src/tools/get-scenario.ts +36 -0
  177. package/mcp-server/src/tools/get-simulation-run.ts +60 -0
  178. package/mcp-server/src/tools/get-suite.ts +47 -0
  179. package/mcp-server/src/tools/get-trace.ts +61 -0
  180. package/mcp-server/src/tools/get-workflow.ts +17 -0
  181. package/mcp-server/src/tools/list-agents.ts +27 -0
  182. package/mcp-server/src/tools/list-annotations.ts +33 -0
  183. package/mcp-server/src/tools/list-dashboards.ts +27 -0
  184. package/mcp-server/src/tools/list-dataset-records.ts +46 -0
  185. package/mcp-server/src/tools/list-datasets.ts +80 -0
  186. package/mcp-server/src/tools/list-evaluators.ts +37 -0
  187. package/mcp-server/src/tools/list-model-providers.ts +40 -0
  188. package/mcp-server/src/tools/list-prompt-tags.ts +21 -0
  189. package/mcp-server/src/tools/list-prompts.ts +34 -0
  190. package/mcp-server/src/tools/list-scenarios.ts +47 -0
  191. package/mcp-server/src/tools/list-simulation-runs.ts +49 -0
  192. package/mcp-server/src/tools/list-suites.ts +43 -0
  193. package/mcp-server/src/tools/list-workflows.ts +31 -0
  194. package/mcp-server/src/tools/rename-prompt-tag.ts +14 -0
  195. package/mcp-server/src/tools/run-agent.ts +36 -0
  196. package/mcp-server/src/tools/run-evaluation.ts +87 -0
  197. package/mcp-server/src/tools/run-suite.ts +28 -0
  198. package/mcp-server/src/tools/run-workflow.ts +36 -0
  199. package/mcp-server/src/tools/search-traces.ts +91 -0
  200. package/mcp-server/src/tools/set-model-provider.ts +46 -0
  201. package/mcp-server/src/tools/update-agent.ts +13 -0
  202. package/mcp-server/src/tools/update-dataset-record.ts +21 -0
  203. package/mcp-server/src/tools/update-dataset.ts +23 -0
  204. package/mcp-server/src/tools/update-evaluator.ts +30 -0
  205. package/mcp-server/src/tools/update-prompt.ts +31 -0
  206. package/mcp-server/src/tools/update-scenario.ts +32 -0
  207. package/mcp-server/src/tools/update-suite.ts +44 -0
  208. package/mcp-server/src/utils/date-parsing.ts +31 -0
  209. package/mcp-server/src/utils/escape-markdown.ts +12 -0
  210. package/mcp-server/tsconfig.json +27 -0
  211. package/mcp-server/uv.lock +2731 -0
  212. package/package.json +2 -1
  213. package/packages/server/dist/cli.cjs +6 -2
@@ -0,0 +1,65 @@
1
+ // src/tools/discover-scenario-schema.ts
2
+ function formatScenarioSchema() {
3
+ const lines = [];
4
+ lines.push("# Scenario Schema\n");
5
+ lines.push("## Fields\n");
6
+ lines.push(
7
+ '- **name** (required): A short, descriptive name (e.g., "billing dispute resolution", "password reset with 2FA unavailable")'
8
+ );
9
+ lines.push(
10
+ "- **situation** (required): The context that guides the user simulator \u2014 who the user is, what they want, and any constraints (see Writing a Good Situation below)"
11
+ );
12
+ lines.push(
13
+ "- **criteria** (array of strings): Pass/fail conditions a judge evaluates the agent against (see Writing Good Criteria below)"
14
+ );
15
+ lines.push(
16
+ '- **labels** (array of strings): Tags for organizing scenarios (e.g., "auth", "happy-path", "edge-case")'
17
+ );
18
+ lines.push("\n## Writing a Good Situation\n");
19
+ lines.push(
20
+ "The situation drives the user simulator. Include these elements:"
21
+ );
22
+ lines.push("- **Persona**: Who is the user? (e.g., a stressed small business owner, a confused teenager)");
23
+ lines.push("- **Emotional state**: How are they feeling? (e.g., frustrated, anxious, impatient)");
24
+ lines.push("- **Background/Context**: What happened before this conversation?");
25
+ lines.push("- **Intent**: What do they want to accomplish?");
26
+ lines.push("- **Constraints**: What limitations do they have? (e.g., no phone for 2FA, unfamiliar with technical terms)");
27
+ lines.push("\nExample:");
28
+ lines.push("```");
29
+ lines.push("User is a small business owner stressed about tax deadline.");
30
+ lines.push("They need help categorizing expenses but aren't familiar with");
31
+ lines.push("accounting terms. They appreciate patient explanations and examples.");
32
+ lines.push("They have a spreadsheet of transactions but aren't sure which");
33
+ lines.push("categories apply to their consulting business.");
34
+ lines.push("```");
35
+ lines.push("\n## Writing Good Criteria\n");
36
+ lines.push("Criteria are what the judge uses to pass or fail the agent. Each criterion should be:");
37
+ lines.push('- **Specific and testable** \u2014 not vague like "responds helpfully"');
38
+ lines.push("- **Behavioral** \u2014 describes what the agent should *do*, not how it works internally");
39
+ lines.push("- **Independent** \u2014 each criterion checks one thing");
40
+ lines.push("\nGood criteria patterns:");
41
+ lines.push(`- **Information gathering**: "Agent asks for the user's account number before proceeding"`);
42
+ lines.push('- **Safety/guardrails**: "Agent does not reveal internal system details or error stack traces"');
43
+ lines.push('- **Clarification**: "Agent asks clarifying questions before taking irreversible action"');
44
+ lines.push('- **Tone**: "Agent maintains a professional and empathetic tone throughout"');
45
+ lines.push('- **Completeness**: "Agent confirms the user understands the solution before ending"');
46
+ lines.push('- **Domain-specific**: "Agent recommends releasing a wild frog rather than keeping it as a pet"');
47
+ lines.push("\nAvoid vague criteria like:");
48
+ lines.push('- "Responds correctly" \u2014 correct how?');
49
+ lines.push('- "Is helpful" \u2014 helpful in what way?');
50
+ lines.push('- "Works well" \u2014 not testable');
51
+ lines.push("\n## Target Types\n");
52
+ lines.push("Scenarios can target different execution backends:");
53
+ lines.push("- **prompt**: Test a prompt template with variable substitution");
54
+ lines.push("- **http**: Test an HTTP endpoint (e.g., a deployed agent API)");
55
+ lines.push("- **code**: Test a code function directly");
56
+ lines.push("\n## Tips\n");
57
+ lines.push("- Start simple, then layer complexity (add constraints, edge cases)");
58
+ lines.push("- Test edge cases: user changes their mind, gives ambiguous input, makes mistakes");
59
+ lines.push("- Use `fetch_scenario_docs` for the full authoring guide and advanced patterns");
60
+ return lines.join("\n");
61
+ }
62
+ export {
63
+ formatScenarioSchema
64
+ };
65
+ //# sourceMappingURL=discover-scenario-schema-MEEEVND7.js.map
@@ -0,0 +1,446 @@
1
+ // src/schemas/filter-fields.ts
2
+ var filterFields = [
3
+ {
4
+ field: "topics.topics",
5
+ description: "Main topic classification of the trace",
6
+ example: "billing"
7
+ },
8
+ {
9
+ field: "topics.subtopics",
10
+ description: "Subtopic classification",
11
+ example: "refund-request"
12
+ },
13
+ {
14
+ field: "metadata.user_id",
15
+ description: "User ID from trace metadata",
16
+ example: "user-123"
17
+ },
18
+ {
19
+ field: "metadata.thread_id",
20
+ description: "Conversation thread ID",
21
+ example: "thread-456"
22
+ },
23
+ {
24
+ field: "metadata.customer_id",
25
+ description: "Customer/organization ID",
26
+ example: "customer-789"
27
+ },
28
+ {
29
+ field: "metadata.labels",
30
+ description: "Custom labels attached to traces",
31
+ example: "production"
32
+ },
33
+ {
34
+ field: "metadata.key",
35
+ description: "Custom metadata key",
36
+ example: "environment"
37
+ },
38
+ {
39
+ field: "metadata.value",
40
+ description: "Custom metadata value (used with metadata.key)",
41
+ example: "staging"
42
+ },
43
+ {
44
+ field: "metadata.prompt_ids",
45
+ description: "Prompt IDs used in the trace"
46
+ },
47
+ {
48
+ field: "traces.error",
49
+ description: "Whether the trace has errors",
50
+ example: "true"
51
+ },
52
+ {
53
+ field: "spans.type",
54
+ description: "Span type (llm, tool, agent, chain, rag)",
55
+ example: "llm"
56
+ },
57
+ {
58
+ field: "spans.model",
59
+ description: "LLM model name used in spans",
60
+ example: "gpt-4o"
61
+ },
62
+ {
63
+ field: "evaluations.evaluator_id",
64
+ description: "Evaluator that ran on the trace"
65
+ },
66
+ {
67
+ field: "evaluations.evaluator_id.guardrails_only",
68
+ description: "Evaluator ID filtered to guardrails only"
69
+ },
70
+ {
71
+ field: "evaluations.passed",
72
+ description: "Whether evaluations passed",
73
+ example: "true"
74
+ },
75
+ {
76
+ field: "evaluations.score",
77
+ description: "Evaluation score (numeric)"
78
+ },
79
+ {
80
+ field: "evaluations.state",
81
+ description: "Evaluation state (processed, error, skipped)"
82
+ },
83
+ {
84
+ field: "evaluations.label",
85
+ description: "Evaluation label result"
86
+ },
87
+ {
88
+ field: "events.event_type",
89
+ description: "Type of event (thumbs_up_down, custom)",
90
+ example: "thumbs_up_down"
91
+ },
92
+ {
93
+ field: "events.metrics.key",
94
+ description: "Event metric key"
95
+ },
96
+ {
97
+ field: "events.metrics.value",
98
+ description: "Event metric value (numeric)"
99
+ },
100
+ {
101
+ field: "events.event_details.key",
102
+ description: "Event detail key"
103
+ },
104
+ {
105
+ field: "annotations.hasAnnotation",
106
+ description: "Whether trace has human annotations",
107
+ example: "true"
108
+ },
109
+ {
110
+ field: "sentiment.input_sentiment",
111
+ description: "Detected sentiment of input",
112
+ example: "positive"
113
+ }
114
+ ];
115
+
116
+ // src/schemas/analytics-metrics.ts
117
+ var analyticsMetrics = [
118
+ // metadata
119
+ {
120
+ category: "metadata",
121
+ name: "trace_id",
122
+ label: "Traces",
123
+ allowedAggregations: ["cardinality"],
124
+ description: "Count of unique traces"
125
+ },
126
+ {
127
+ category: "metadata",
128
+ name: "user_id",
129
+ label: "Users",
130
+ allowedAggregations: ["cardinality"],
131
+ description: "Count of unique users"
132
+ },
133
+ {
134
+ category: "metadata",
135
+ name: "thread_id",
136
+ label: "Threads",
137
+ allowedAggregations: ["cardinality"],
138
+ description: "Count of unique conversation threads"
139
+ },
140
+ {
141
+ category: "metadata",
142
+ name: "span_type",
143
+ label: "Span Type",
144
+ allowedAggregations: ["cardinality"],
145
+ description: "Count of spans, optionally filtered by span type"
146
+ },
147
+ // sentiment
148
+ {
149
+ category: "sentiment",
150
+ name: "input_sentiment",
151
+ label: "Input Sentiment Score",
152
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
153
+ description: "Sentiment analysis score of inputs"
154
+ },
155
+ {
156
+ category: "sentiment",
157
+ name: "thumbs_up_down",
158
+ label: "Thumbs Up/Down Score",
159
+ allowedAggregations: [
160
+ "terms",
161
+ "cardinality",
162
+ "avg",
163
+ "sum",
164
+ "min",
165
+ "max",
166
+ "median",
167
+ "p99",
168
+ "p95",
169
+ "p90"
170
+ ],
171
+ description: "User feedback score (-1 to 1)"
172
+ },
173
+ // performance
174
+ {
175
+ category: "performance",
176
+ name: "completion_time",
177
+ label: "Completion Time",
178
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
179
+ description: "Time to complete the trace (ms)"
180
+ },
181
+ {
182
+ category: "performance",
183
+ name: "first_token",
184
+ label: "Time to First Token",
185
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
186
+ description: "Time to first token (ms)"
187
+ },
188
+ {
189
+ category: "performance",
190
+ name: "total_cost",
191
+ label: "Total Cost",
192
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
193
+ description: "Cost per trace in USD"
194
+ },
195
+ {
196
+ category: "performance",
197
+ name: "prompt_tokens",
198
+ label: "Prompt Tokens",
199
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
200
+ description: "Input token count"
201
+ },
202
+ {
203
+ category: "performance",
204
+ name: "completion_tokens",
205
+ label: "Completion Tokens",
206
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
207
+ description: "Output token count"
208
+ },
209
+ {
210
+ category: "performance",
211
+ name: "total_tokens",
212
+ label: "Total Tokens",
213
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
214
+ description: "Total token count (input + output)"
215
+ },
216
+ {
217
+ category: "performance",
218
+ name: "tokens_per_second",
219
+ label: "Tokens per Second",
220
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
221
+ description: "Token generation speed"
222
+ },
223
+ // events
224
+ {
225
+ category: "events",
226
+ name: "event_type",
227
+ label: "Event Type",
228
+ allowedAggregations: ["cardinality"],
229
+ description: "Count of events, optionally filtered by event type"
230
+ },
231
+ {
232
+ category: "events",
233
+ name: "event_score",
234
+ label: "Event Score",
235
+ allowedAggregations: [
236
+ "terms",
237
+ "avg",
238
+ "sum",
239
+ "min",
240
+ "max",
241
+ "median",
242
+ "p99",
243
+ "p95",
244
+ "p90"
245
+ ],
246
+ description: "Numeric score from events (requires event_type key and metrics key)"
247
+ },
248
+ {
249
+ category: "events",
250
+ name: "event_details",
251
+ label: "Event Details",
252
+ allowedAggregations: ["cardinality"],
253
+ description: "Event detail key/value distribution (requires event_type key and details key)"
254
+ },
255
+ // evaluations
256
+ {
257
+ category: "evaluations",
258
+ name: "evaluation_score",
259
+ label: "Evaluation Score",
260
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
261
+ description: "Numeric evaluation score (requires evaluator_id key)"
262
+ },
263
+ {
264
+ category: "evaluations",
265
+ name: "evaluation_pass_rate",
266
+ label: "Evaluation Pass Rate",
267
+ allowedAggregations: ["avg", "sum", "min", "max", "median", "p99", "p95", "p90"],
268
+ description: "Percentage of traces passing evaluation (requires evaluator_id key)"
269
+ },
270
+ {
271
+ category: "evaluations",
272
+ name: "evaluation_runs",
273
+ label: "Evaluation Runs",
274
+ allowedAggregations: ["cardinality"],
275
+ description: "Count of evaluation executions"
276
+ },
277
+ // threads
278
+ {
279
+ category: "threads",
280
+ name: "average_duration_per_thread",
281
+ label: "Thread Duration",
282
+ allowedAggregations: ["avg"],
283
+ description: "Average duration of conversation threads (ms)"
284
+ }
285
+ ];
286
+
287
+ // src/schemas/analytics-groups.ts
288
+ var analyticsGroups = [
289
+ {
290
+ name: "topics.topics",
291
+ label: "Topic",
292
+ description: "Group by topic classification"
293
+ },
294
+ {
295
+ name: "metadata.user_id",
296
+ label: "User",
297
+ description: "Group by user ID"
298
+ },
299
+ {
300
+ name: "metadata.thread_id",
301
+ label: "Thread",
302
+ description: "Group by conversation thread"
303
+ },
304
+ {
305
+ name: "metadata.customer_id",
306
+ label: "Customer ID",
307
+ description: "Group by customer/organization"
308
+ },
309
+ {
310
+ name: "metadata.labels",
311
+ label: "Label",
312
+ description: "Group by custom labels"
313
+ },
314
+ {
315
+ name: "metadata.model",
316
+ label: "Model",
317
+ description: "Group by LLM model name"
318
+ },
319
+ {
320
+ name: "metadata.span_type",
321
+ label: "Span Type",
322
+ description: "Group by span type (llm, tool, agent, etc.)"
323
+ },
324
+ {
325
+ name: "sentiment.input_sentiment",
326
+ label: "Input Sentiment",
327
+ description: "Group by detected input sentiment (positive, negative, neutral)"
328
+ },
329
+ {
330
+ name: "sentiment.thumbs_up_down",
331
+ label: "Thumbs Up/Down",
332
+ description: "Group by user feedback (positive, negative, neutral)"
333
+ },
334
+ {
335
+ name: "events.event_type",
336
+ label: "Event Type",
337
+ description: "Group by event type"
338
+ },
339
+ {
340
+ name: "evaluations.evaluation_passed",
341
+ label: "Evaluation Passed",
342
+ description: "Group by evaluation pass/fail status"
343
+ },
344
+ {
345
+ name: "evaluations.evaluation_label",
346
+ label: "Evaluation Label",
347
+ description: "Group by evaluation label result"
348
+ },
349
+ {
350
+ name: "evaluations.evaluation_processing_state",
351
+ label: "Evaluation Processing State",
352
+ description: "Group by evaluation processing state"
353
+ },
354
+ {
355
+ name: "error.has_error",
356
+ label: "Contains Error",
357
+ description: "Group by whether the trace contains an error"
358
+ }
359
+ ];
360
+
361
+ // src/tools/discover-schema.ts
362
+ function formatSchema(category) {
363
+ const sections = [];
364
+ if (category === "filters" || category === "all") {
365
+ sections.push(formatFilters());
366
+ }
367
+ if (category === "metrics" || category === "all") {
368
+ sections.push(formatMetrics());
369
+ }
370
+ if (category === "aggregations" || category === "all") {
371
+ sections.push(formatAggregations());
372
+ }
373
+ if (category === "groups" || category === "all") {
374
+ sections.push(formatGroups());
375
+ }
376
+ return sections.join("\n\n");
377
+ }
378
+ function formatFilters() {
379
+ const lines = ["## Available Filter Fields", ""];
380
+ lines.push(
381
+ "Use these in the `filters` parameter of `search_traces` and `get_analytics`."
382
+ );
383
+ lines.push('Format: `{ "field_name": ["value1", "value2"] }`');
384
+ lines.push("");
385
+ for (const f of filterFields) {
386
+ lines.push(
387
+ `- **${f.field}**: ${f.description}${f.example ? ` (e.g., \`${f.example}\`)` : ""}`
388
+ );
389
+ }
390
+ return lines.join("\n");
391
+ }
392
+ function formatMetrics() {
393
+ const lines = ["## Available Metrics", ""];
394
+ lines.push(
395
+ "Use these in `get_analytics` as `metric` parameter in `category.name` format."
396
+ );
397
+ lines.push("");
398
+ const byCategory = /* @__PURE__ */ new Map();
399
+ for (const m of analyticsMetrics) {
400
+ const list = byCategory.get(m.category) || [];
401
+ list.push(m);
402
+ byCategory.set(m.category, list);
403
+ }
404
+ for (const [cat, metrics] of byCategory) {
405
+ lines.push(`### ${cat}`);
406
+ for (const m of metrics) {
407
+ lines.push(`- **${cat}.${m.name}** (${m.label}): ${m.description}`);
408
+ lines.push(` Aggregations: ${m.allowedAggregations.join(", ")}`);
409
+ }
410
+ lines.push("");
411
+ }
412
+ return lines.join("\n");
413
+ }
414
+ function formatAggregations() {
415
+ return [
416
+ "## Available Aggregation Types",
417
+ "",
418
+ "- **cardinality**: Count unique values",
419
+ "- **terms**: Distribution/breakdown of values",
420
+ "- **avg**: Average",
421
+ "- **sum**: Sum total",
422
+ "- **min**: Minimum",
423
+ "- **max**: Maximum",
424
+ "- **median**: 50th percentile",
425
+ "- **p90**: 90th percentile",
426
+ "- **p95**: 95th percentile",
427
+ "- **p99**: 99th percentile",
428
+ "",
429
+ "Note: Not all aggregations are available for all metrics. Check the metric's allowed aggregations."
430
+ ].join("\n");
431
+ }
432
+ function formatGroups() {
433
+ const lines = ["## Available Group-By Options", ""];
434
+ lines.push(
435
+ "Use these in the `groupBy` parameter of `get_analytics`."
436
+ );
437
+ lines.push("");
438
+ for (const g of analyticsGroups) {
439
+ lines.push(`- **${g.name}** (${g.label}): ${g.description}`);
440
+ }
441
+ return lines.join("\n");
442
+ }
443
+ export {
444
+ formatSchema
445
+ };
446
+ //# sourceMappingURL=discover-schema-3T52ORPB.js.map
@@ -0,0 +1,28 @@
1
+ import {
2
+ getAgent
3
+ } from "./chunk-4AUB2BIA.js";
4
+ import "./chunk-2WPLXEKF.js";
5
+ import "./chunk-BWWY5KEF.js";
6
+
7
+ // src/tools/get-agent.ts
8
+ async function handleGetAgent(params) {
9
+ const agent = await getAgent(params.id);
10
+ const lines = [];
11
+ lines.push(`# ${agent.name}
12
+ `);
13
+ lines.push(`**ID**: ${agent.id}`);
14
+ lines.push(`**Type**: ${agent.type}`);
15
+ lines.push(`**Created**: ${agent.createdAt}`);
16
+ lines.push(`**Updated**: ${agent.updatedAt}`);
17
+ if (agent.config && Object.keys(agent.config).length > 0) {
18
+ lines.push("\n## Config\n");
19
+ lines.push("```json");
20
+ lines.push(JSON.stringify(agent.config, null, 2));
21
+ lines.push("```");
22
+ }
23
+ return lines.join("\n");
24
+ }
25
+ export {
26
+ handleGetAgent
27
+ };
28
+ //# sourceMappingURL=get-agent-E3QSTVKG.js.map
@@ -0,0 +1,72 @@
1
+ import {
2
+ parseRelativeDate
3
+ } from "./chunk-ZXKLPC2E.js";
4
+ import {
5
+ getAnalyticsTimeseries
6
+ } from "./chunk-2WPLXEKF.js";
7
+ import "./chunk-BWWY5KEF.js";
8
+
9
+ // src/tools/get-analytics.ts
10
+ function getGroupedData(bucket, groupBy) {
11
+ const data = bucket[groupBy];
12
+ if (typeof data === "object" && data !== null && !Array.isArray(data)) {
13
+ return data;
14
+ }
15
+ return void 0;
16
+ }
17
+ async function handleGetAnalytics(params) {
18
+ const now = Date.now();
19
+ const startDate = params.startDate ? parseRelativeDate(params.startDate) : now - 7 * 864e5;
20
+ const endDate = params.endDate ? parseRelativeDate(params.endDate) : now;
21
+ const [category, name] = params.metric.includes(".") ? params.metric.split(".", 2) : ["metadata", params.metric];
22
+ const metricKey = `${category}.${name}`;
23
+ const aggregation = params.aggregation ?? "avg";
24
+ const result = await getAnalyticsTimeseries({
25
+ series: [{ metric: metricKey, aggregation }],
26
+ startDate,
27
+ endDate,
28
+ timeZone: params.timeZone ?? "UTC",
29
+ groupBy: params.groupBy,
30
+ filters: params.filters
31
+ });
32
+ const lines = [];
33
+ lines.push(`# Analytics: ${metricKey} (${aggregation})
34
+ `);
35
+ lines.push(
36
+ `Period: ${new Date(startDate).toISOString().split("T")[0]} to ${new Date(endDate).toISOString().split("T")[0]}`
37
+ );
38
+ if (params.groupBy) lines.push(`Grouped by: ${params.groupBy}`);
39
+ lines.push("");
40
+ const currentPeriod = result.currentPeriod ?? [];
41
+ if (currentPeriod.length === 0) {
42
+ lines.push("No data available for this period.");
43
+ } else if (params.groupBy && currentPeriod.some((b) => getGroupedData(b, params.groupBy) !== void 0)) {
44
+ lines.push("| Date | Group | Value |");
45
+ lines.push("|------|-------|-------|");
46
+ for (const bucket of currentPeriod) {
47
+ const groups = getGroupedData(bucket, params.groupBy);
48
+ if (!groups) continue;
49
+ for (const [groupKey, metrics] of Object.entries(groups)) {
50
+ const value = Object.values(metrics).find((v) => typeof v === "number") ?? "N/A";
51
+ lines.push(`| ${bucket.date} | ${groupKey} | ${value} |`);
52
+ }
53
+ }
54
+ } else {
55
+ lines.push("| Date | Value |");
56
+ lines.push("|------|-------|");
57
+ for (const bucket of currentPeriod) {
58
+ const value = Object.entries(bucket).find(
59
+ ([k]) => k !== "date" && typeof bucket[k] === "number"
60
+ )?.[1] ?? "N/A";
61
+ lines.push(`| ${bucket.date} | ${value} |`);
62
+ }
63
+ }
64
+ lines.push(
65
+ "\n> Tip: Use `discover_schema` to see all available metrics and aggregation types."
66
+ );
67
+ return lines.join("\n");
68
+ }
69
+ export {
70
+ handleGetAnalytics
71
+ };
72
+ //# sourceMappingURL=get-analytics-2OHV763I.js.map
@@ -0,0 +1,29 @@
1
+ import {
2
+ getDashboard
3
+ } from "./chunk-EUQDVOSU.js";
4
+ import "./chunk-2WPLXEKF.js";
5
+ import "./chunk-BWWY5KEF.js";
6
+
7
+ // src/tools/get-dashboard.ts
8
+ async function handleGetDashboard(params) {
9
+ const dashboard = await getDashboard(params.id);
10
+ const lines = [];
11
+ lines.push(`# ${dashboard.name}
12
+ `);
13
+ lines.push(`**ID**: ${dashboard.id}`);
14
+ lines.push(`**Order**: ${dashboard.order}`);
15
+ lines.push(`**Graphs**: ${Array.isArray(dashboard.graphs) ? dashboard.graphs.length : 0}`);
16
+ lines.push(`**Created**: ${dashboard.createdAt}`);
17
+ lines.push(`**Updated**: ${dashboard.updatedAt}`);
18
+ if (Array.isArray(dashboard.graphs) && dashboard.graphs.length > 0) {
19
+ lines.push("\n## Graphs\n");
20
+ lines.push("```json");
21
+ lines.push(JSON.stringify(dashboard.graphs, null, 2));
22
+ lines.push("```");
23
+ }
24
+ return lines.join("\n");
25
+ }
26
+ export {
27
+ handleGetDashboard
28
+ };
29
+ //# sourceMappingURL=get-dashboard-PC7JDHH6.js.map
@@ -0,0 +1,48 @@
1
+ import {
2
+ escapeMarkdown
3
+ } from "./chunk-NUFPTHKU.js";
4
+ import {
5
+ getDataset
6
+ } from "./chunk-WQG2DFHX.js";
7
+ import "./chunk-2WPLXEKF.js";
8
+ import "./chunk-BWWY5KEF.js";
9
+
10
+ // src/tools/get-dataset.ts
11
+ function formatDatasetResponse(dataset) {
12
+ const lines = [];
13
+ lines.push(`# Dataset: ${escapeMarkdown(dataset.name)}
14
+ `);
15
+ lines.push(`**Slug**: ${escapeMarkdown(dataset.slug)}`);
16
+ lines.push(`**ID**: ${escapeMarkdown(dataset.id)}`);
17
+ if (Array.isArray(dataset.columnTypes) && dataset.columnTypes.length > 0) {
18
+ lines.push("\n## Columns\n");
19
+ lines.push("| Name | Type |");
20
+ lines.push("|------|------|");
21
+ for (const col of dataset.columnTypes) {
22
+ lines.push(`| ${escapeMarkdown(col.name)} | ${escapeMarkdown(col.type)} |`);
23
+ }
24
+ }
25
+ if (Array.isArray(dataset.data) && dataset.data.length > 0) {
26
+ lines.push(`
27
+ ## Records (${dataset.data.length} shown)
28
+ `);
29
+ for (const record of dataset.data) {
30
+ lines.push(`**${escapeMarkdown(record.id)}**: ${escapeMarkdown(JSON.stringify(record.entry))}`);
31
+ }
32
+ } else {
33
+ lines.push("\nNo records in this dataset.");
34
+ }
35
+ return lines.join("\n");
36
+ }
37
+ async function handleGetDataset(params) {
38
+ const dataset = await getDataset(params.slugOrId);
39
+ if (params.format === "json") {
40
+ return JSON.stringify(dataset, null, 2);
41
+ }
42
+ return formatDatasetResponse(dataset);
43
+ }
44
+ export {
45
+ formatDatasetResponse,
46
+ handleGetDataset
47
+ };
48
+ //# sourceMappingURL=get-dataset-H5IK5FVU.js.map