@mastra/server 0.24.0-alpha.0 → 1.0.0-beta.0

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 (159) hide show
  1. package/CHANGELOG.md +309 -48
  2. package/README.md +1 -1
  3. package/dist/{chunk-OQPXME7E.js → chunk-2IS5WICF.js} +4569 -1062
  4. package/dist/chunk-2IS5WICF.js.map +1 -0
  5. package/dist/{chunk-SPRRK3P7.cjs → chunk-2YZH5PH6.cjs} +47 -47
  6. package/dist/chunk-2YZH5PH6.cjs.map +1 -0
  7. package/dist/{chunk-BATEJLED.js → chunk-3AMNUUZF.js} +20 -20
  8. package/dist/chunk-3AMNUUZF.js.map +1 -0
  9. package/dist/{chunk-AW5BU3RQ.js → chunk-3F52QCI4.js} +40 -40
  10. package/dist/chunk-3F52QCI4.js.map +1 -0
  11. package/dist/{chunk-PBXWFGEH.js → chunk-4JF5WXPL.js} +130 -207
  12. package/dist/chunk-4JF5WXPL.js.map +1 -0
  13. package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
  14. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  15. package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
  16. package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
  17. package/dist/{chunk-ABRFV4XP.js → chunk-73PAWDM5.js} +13 -13
  18. package/dist/chunk-73PAWDM5.js.map +1 -0
  19. package/dist/{chunk-2S4IMB6E.cjs → chunk-A24TSVEZ.cjs} +39 -39
  20. package/dist/chunk-A24TSVEZ.cjs.map +1 -0
  21. package/dist/{chunk-NT5XW5PI.cjs → chunk-A2NPD5N6.cjs} +176 -255
  22. package/dist/chunk-A2NPD5N6.cjs.map +1 -0
  23. package/dist/{chunk-QQXMIP6C.js → chunk-B3Z6J745.js} +17 -17
  24. package/dist/chunk-B3Z6J745.js.map +1 -0
  25. package/dist/{chunk-G4PUALCE.cjs → chunk-BTWIR2B7.cjs} +4 -4
  26. package/dist/{chunk-G4PUALCE.cjs.map → chunk-BTWIR2B7.cjs.map} +1 -1
  27. package/dist/{chunk-YWOK4F5A.js → chunk-D7T74TVR.js} +4 -6
  28. package/dist/chunk-D7T74TVR.js.map +1 -0
  29. package/dist/{chunk-IJSDPAUY.cjs → chunk-EHACNWDL.cjs} +156 -202
  30. package/dist/chunk-EHACNWDL.cjs.map +1 -0
  31. package/dist/{chunk-HPXAM2PG.js → chunk-FPBYKMIS.js} +13 -13
  32. package/dist/chunk-FPBYKMIS.js.map +1 -0
  33. package/dist/{chunk-3SNGNFUJ.cjs → chunk-GLAZTMX3.cjs} +37 -37
  34. package/dist/chunk-GLAZTMX3.cjs.map +1 -0
  35. package/dist/{chunk-TEOUDAN5.cjs → chunk-ID6JYDNL.cjs} +4590 -1080
  36. package/dist/chunk-ID6JYDNL.cjs.map +1 -0
  37. package/dist/{chunk-TRGAMKHX.cjs → chunk-KF3RI45U.cjs} +46 -41
  38. package/dist/chunk-KF3RI45U.cjs.map +1 -0
  39. package/dist/{chunk-TOP25AIO.cjs → chunk-KJIDZQRA.cjs} +14 -14
  40. package/dist/chunk-KJIDZQRA.cjs.map +1 -0
  41. package/dist/{chunk-MYR4PVGN.js → chunk-KWH5QBXP.js} +4 -4
  42. package/dist/{chunk-MYR4PVGN.js.map → chunk-KWH5QBXP.js.map} +1 -1
  43. package/dist/{chunk-AHB4JCIQ.js → chunk-ND5OKOMT.js} +31 -26
  44. package/dist/chunk-ND5OKOMT.js.map +1 -0
  45. package/dist/{chunk-XN74I6VW.cjs → chunk-PPMIB3FQ.cjs} +20 -20
  46. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  47. package/dist/{chunk-EP3JQDPD.cjs → chunk-S54HNARD.cjs} +18 -18
  48. package/dist/{chunk-EP3JQDPD.cjs.map → chunk-S54HNARD.cjs.map} +1 -1
  49. package/dist/{chunk-4QCXUEAT.js → chunk-SZIFSF4T.js} +3 -3
  50. package/dist/{chunk-4QCXUEAT.js.map → chunk-SZIFSF4T.js.map} +1 -1
  51. package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
  52. package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
  53. package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
  54. package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
  55. package/dist/{chunk-VY4ENABS.cjs → chunk-W2KMU354.cjs} +4 -6
  56. package/dist/chunk-W2KMU354.cjs.map +1 -0
  57. package/dist/{chunk-H33KYEMY.cjs → chunk-X3MICMI2.cjs} +140 -240
  58. package/dist/chunk-X3MICMI2.cjs.map +1 -0
  59. package/dist/{chunk-Y4VKB6KC.js → chunk-Z2O5YVHY.js} +121 -165
  60. package/dist/chunk-Z2O5YVHY.js.map +1 -0
  61. package/dist/{chunk-PY2K7VNW.js → chunk-ZJ6KEY6H.js} +67 -165
  62. package/dist/chunk-ZJ6KEY6H.js.map +1 -0
  63. package/dist/server/handlers/a2a.cjs +7 -7
  64. package/dist/server/handlers/a2a.d.ts +10 -10
  65. package/dist/server/handlers/a2a.d.ts.map +1 -1
  66. package/dist/server/handlers/a2a.js +1 -1
  67. package/dist/server/handlers/agent-builder.cjs +31 -19
  68. package/dist/server/handlers/agent-builder.d.ts +38 -47
  69. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  70. package/dist/server/handlers/agent-builder.js +1 -1
  71. package/dist/server/handlers/agents.cjs +22 -30
  72. package/dist/server/handlers/agents.d.ts +36 -55
  73. package/dist/server/handlers/agents.d.ts.map +1 -1
  74. package/dist/server/handlers/agents.js +1 -1
  75. package/dist/server/handlers/error.cjs +2 -2
  76. package/dist/server/handlers/error.js +1 -1
  77. package/dist/server/handlers/logs.cjs +7 -7
  78. package/dist/server/handlers/logs.d.ts +3 -3
  79. package/dist/server/handlers/logs.d.ts.map +1 -1
  80. package/dist/server/handlers/logs.js +1 -1
  81. package/dist/server/handlers/memory.cjs +17 -25
  82. package/dist/server/handlers/memory.d.ts +28 -34
  83. package/dist/server/handlers/memory.d.ts.map +1 -1
  84. package/dist/server/handlers/memory.js +1 -1
  85. package/dist/server/handlers/observability.cjs +8 -8
  86. package/dist/server/handlers/observability.d.ts +12 -12
  87. package/dist/server/handlers/observability.d.ts.map +1 -1
  88. package/dist/server/handlers/observability.js +1 -1
  89. package/dist/server/handlers/scores.cjs +11 -11
  90. package/dist/server/handlers/scores.d.ts +24 -24
  91. package/dist/server/handlers/scores.d.ts.map +1 -1
  92. package/dist/server/handlers/scores.js +1 -1
  93. package/dist/server/handlers/tools.cjs +7 -7
  94. package/dist/server/handlers/tools.d.ts +8 -8
  95. package/dist/server/handlers/tools.d.ts.map +1 -1
  96. package/dist/server/handlers/tools.js +1 -1
  97. package/dist/server/handlers/utils.cjs +3 -3
  98. package/dist/server/handlers/utils.js +1 -1
  99. package/dist/server/handlers/vector.cjs +7 -7
  100. package/dist/server/handlers/vector.js +1 -1
  101. package/dist/server/handlers/voice.cjs +5 -5
  102. package/dist/server/handlers/voice.d.ts +6 -6
  103. package/dist/server/handlers/voice.js +1 -1
  104. package/dist/server/handlers/workflows.cjs +21 -29
  105. package/dist/server/handlers/workflows.d.ts +27 -36
  106. package/dist/server/handlers/workflows.d.ts.map +1 -1
  107. package/dist/server/handlers/workflows.js +1 -1
  108. package/dist/server/handlers.cjs +26 -36
  109. package/dist/server/handlers.d.ts +0 -2
  110. package/dist/server/handlers.d.ts.map +1 -1
  111. package/dist/server/handlers.js +11 -13
  112. package/dist/server/http-exception.d.ts +0 -5
  113. package/dist/server/http-exception.d.ts.map +1 -1
  114. package/dist/server/utils.d.ts +3 -2
  115. package/dist/server/utils.d.ts.map +1 -1
  116. package/package.json +9 -13
  117. package/dist/chunk-2S4IMB6E.cjs.map +0 -1
  118. package/dist/chunk-3SNGNFUJ.cjs.map +0 -1
  119. package/dist/chunk-67GYDFSB.js +0 -160
  120. package/dist/chunk-67GYDFSB.js.map +0 -1
  121. package/dist/chunk-6ZR275MD.cjs +0 -165
  122. package/dist/chunk-6ZR275MD.cjs.map +0 -1
  123. package/dist/chunk-ABRFV4XP.js.map +0 -1
  124. package/dist/chunk-AHB4JCIQ.js.map +0 -1
  125. package/dist/chunk-AW5BU3RQ.js.map +0 -1
  126. package/dist/chunk-BATEJLED.js.map +0 -1
  127. package/dist/chunk-H33KYEMY.cjs.map +0 -1
  128. package/dist/chunk-HPXAM2PG.js.map +0 -1
  129. package/dist/chunk-I3C4ODGV.cjs +0 -335
  130. package/dist/chunk-I3C4ODGV.cjs.map +0 -1
  131. package/dist/chunk-IJSDPAUY.cjs.map +0 -1
  132. package/dist/chunk-LLUOPR3J.js +0 -323
  133. package/dist/chunk-LLUOPR3J.js.map +0 -1
  134. package/dist/chunk-MMROOK5J.js.map +0 -1
  135. package/dist/chunk-NT5XW5PI.cjs.map +0 -1
  136. package/dist/chunk-OQPXME7E.js.map +0 -1
  137. package/dist/chunk-PBXWFGEH.js.map +0 -1
  138. package/dist/chunk-PY2K7VNW.js.map +0 -1
  139. package/dist/chunk-QQXMIP6C.js.map +0 -1
  140. package/dist/chunk-SPRRK3P7.cjs.map +0 -1
  141. package/dist/chunk-TEOUDAN5.cjs.map +0 -1
  142. package/dist/chunk-TOP25AIO.cjs.map +0 -1
  143. package/dist/chunk-TRGAMKHX.cjs.map +0 -1
  144. package/dist/chunk-VY4ENABS.cjs.map +0 -1
  145. package/dist/chunk-XN74I6VW.cjs.map +0 -1
  146. package/dist/chunk-Y4VKB6KC.js.map +0 -1
  147. package/dist/chunk-YWOK4F5A.js.map +0 -1
  148. package/dist/server/handlers/legacyWorkflows.cjs +0 -48
  149. package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
  150. package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
  151. package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
  152. package/dist/server/handlers/legacyWorkflows.js +0 -3
  153. package/dist/server/handlers/legacyWorkflows.js.map +0 -1
  154. package/dist/server/handlers/telemetry.cjs +0 -20
  155. package/dist/server/handlers/telemetry.cjs.map +0 -1
  156. package/dist/server/handlers/telemetry.d.ts +0 -33
  157. package/dist/server/handlers/telemetry.d.ts.map +0 -1
  158. package/dist/server/handlers/telemetry.js +0 -3
  159. package/dist/server/handlers/telemetry.js.map +0 -1
@@ -35,5 +35,5 @@ var HTTPException = class extends Error {
35
35
  };
36
36
 
37
37
  exports.HTTPException = HTTPException;
38
- //# sourceMappingURL=chunk-7NADHFD2.cjs.map
39
- //# sourceMappingURL=chunk-7NADHFD2.cjs.map
38
+ //# sourceMappingURL=chunk-64ITUOXI.cjs.map
39
+ //# sourceMappingURL=chunk-64ITUOXI.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":";;;AA0GO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,GAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,MAAA,GAAqB,GAAA,EAAK,OAAA,EAAgC;AACpE,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,EAAS,KAAA,IAAS,IAAA,CAAK,KAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,GAAwB;AACtB,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF","file":"chunk-64ITUOXI.cjs","sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"]}
@@ -33,5 +33,5 @@ var HTTPException = class extends Error {
33
33
  };
34
34
 
35
35
  export { HTTPException };
36
- //# sourceMappingURL=chunk-MMROOK5J.js.map
37
- //# sourceMappingURL=chunk-MMROOK5J.js.map
36
+ //# sourceMappingURL=chunk-6QWQZI4Q.js.map
37
+ //# sourceMappingURL=chunk-6QWQZI4Q.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":";;;AAgHO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,GAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,MAAA,GAAqB,GAAA,EAAK,OAAA,EAAgC;AACpE,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,EAAS,KAAA,IAAS,IAAA,CAAK,KAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,GAAwB;AACtB,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF","file":"chunk-7NADHFD2.cjs","sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * @deprecated\n * Use `UnofficialStatusCode` instead.\n */\nexport type UnOfficalStatusCode = UnofficialStatusCode;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/server/http-exception.ts"],"names":[],"mappings":";AA0GO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAC9B,GAAA;AAAA,EACA,MAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT,WAAA,CAAY,MAAA,GAAqB,GAAA,EAAK,OAAA,EAAgC;AACpE,IAAA,KAAA,CAAM,SAAS,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,EAAS,OAAO,CAAA;AACjD,IAAA,IAAA,CAAK,MAAM,OAAA,EAAS,GAAA;AACpB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,KAAA,GAAQ,OAAA,EAAS,KAAA,IAAS,IAAA,CAAK,KAAA;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAA,GAAwB;AACtB,IAAA,IAAI,KAAK,GAAA,EAAK;AACZ,MAAA,MAAM,WAAA,GAAc,IAAI,QAAA,CAAS,IAAA,CAAK,IAAI,IAAA,EAAM;AAAA,QAC9C,QAAQ,IAAA,CAAK,MAAA;AAAA,QACb,OAAA,EAAS,KAAK,GAAA,CAAI;AAAA,OACnB,CAAA;AACD,MAAA,OAAO,WAAA;AAAA,IACT;AACA,IAAA,OAAO,IAAI,QAAA,CAAS,IAAA,CAAK,OAAA,EAAS;AAAA,MAChC,QAAQ,IAAA,CAAK;AAAA,KACd,CAAA;AAAA,EACH;AACF","file":"chunk-6QWQZI4Q.js","sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"]}
@@ -1,15 +1,15 @@
1
- import { validateBody } from './chunk-4QCXUEAT.js';
2
- import { handleError } from './chunk-CY4TP3FK.js';
1
+ import { validateBody } from './chunk-SZIFSF4T.js';
2
+ import { handleError } from './chunk-UXGQZUYZ.js';
3
3
  import { __export } from './chunk-PR4QN5HX.js';
4
4
 
5
5
  // src/server/handlers/logs.ts
6
6
  var logs_exports = {};
7
7
  __export(logs_exports, {
8
- getLogTransports: () => getLogTransports,
9
- getLogsByRunIdHandler: () => getLogsByRunIdHandler,
10
- getLogsHandler: () => getLogsHandler
8
+ listLogTransports: () => listLogTransports,
9
+ listLogsByRunIdHandler: () => listLogsByRunIdHandler,
10
+ listLogsHandler: () => listLogsHandler
11
11
  });
12
- async function getLogsHandler({
12
+ async function listLogsHandler({
13
13
  mastra,
14
14
  transportId,
15
15
  params
@@ -23,7 +23,7 @@ async function getLogsHandler({
23
23
  return [key, value];
24
24
  })
25
25
  ) : void 0;
26
- const logs = await mastra.getLogs(transportId, {
26
+ const logs = await mastra.listLogs(transportId, {
27
27
  fromDate,
28
28
  toDate,
29
29
  logLevel,
@@ -36,7 +36,7 @@ async function getLogsHandler({
36
36
  return handleError(error, "Error getting logs");
37
37
  }
38
38
  }
39
- async function getLogsByRunIdHandler({
39
+ async function listLogsByRunIdHandler({
40
40
  mastra,
41
41
  runId,
42
42
  transportId,
@@ -51,7 +51,7 @@ async function getLogsByRunIdHandler({
51
51
  return [key, value];
52
52
  })
53
53
  ) : void 0;
54
- const logs = await mastra.getLogsByRunId({
54
+ const logs = await mastra.listLogsByRunId({
55
55
  runId,
56
56
  transportId,
57
57
  fromDate,
@@ -66,7 +66,7 @@ async function getLogsByRunIdHandler({
66
66
  return handleError(error, "Error getting logs by run ID");
67
67
  }
68
68
  }
69
- async function getLogTransports({ mastra }) {
69
+ async function listLogTransports({ mastra }) {
70
70
  try {
71
71
  const logger = mastra.getLogger();
72
72
  const transports = logger.getTransports();
@@ -78,6 +78,6 @@ async function getLogTransports({ mastra }) {
78
78
  }
79
79
  }
80
80
 
81
- export { getLogTransports, getLogsByRunIdHandler, getLogsHandler, logs_exports };
82
- //# sourceMappingURL=chunk-ABRFV4XP.js.map
83
- //# sourceMappingURL=chunk-ABRFV4XP.js.map
81
+ export { listLogTransports, listLogsByRunIdHandler, listLogsHandler, logs_exports };
82
+ //# sourceMappingURL=chunk-73PAWDM5.js.map
83
+ //# sourceMappingURL=chunk-73PAWDM5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/logs.ts"],"names":[],"mappings":";;;;;AAAA,IAAA,YAAA,GAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAA,iBAAA,EAAA,MAAA,iBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,eAA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IAAA,OAAO,WAAA,CAAY,OAAO,8BAA8B,CAAA;AAAA,EAC1D;AACF","file":"chunk-73PAWDM5.js","sourcesContent":["import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ntype LogsContext = {\n mastra: Mastra;\n transportId?: string;\n runId?: string;\n params?: {\n fromDate?: Date;\n toDate?: Date;\n logLevel?: LogLevel;\n filters?: string | string[];\n page?: number;\n perPage?: number;\n };\n};\n\nexport async function listLogsHandler({\n mastra,\n transportId,\n params,\n}: Pick<LogsContext, 'mastra' | 'transportId' | 'params'>): Promise<{\n logs: BaseLogMessage[];\n total: number;\n page: number;\n perPage: number;\n hasMore: boolean;\n}> {\n try {\n validateBody({ transportId });\n\n const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};\n\n // Parse filter query parameter if present\n const filters = _filters\n ? Object.fromEntries(\n (Array.isArray(_filters) ? _filters : [_filters]).map(attr => {\n const [key, value] = attr.split(':');\n return [key, value];\n }),\n )\n : undefined;\n\n const logs = await mastra.listLogs(transportId!, {\n fromDate,\n toDate,\n logLevel,\n filters,\n page: page ? Number(page) : undefined,\n perPage: perPage ? Number(perPage) : undefined,\n });\n return logs;\n } catch (error) {\n return handleError(error, 'Error getting logs');\n }\n}\n\nexport async function listLogsByRunIdHandler({\n mastra,\n runId,\n transportId,\n params,\n}: Pick<LogsContext, 'mastra' | 'runId' | 'transportId' | 'params'>) {\n try {\n validateBody({ runId, transportId });\n\n const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};\n\n // Parse filter query parameter if present\n const filters = _filters\n ? Object.fromEntries(\n (Array.isArray(_filters) ? _filters : [_filters]).map(attr => {\n const [key, value] = attr.split(':');\n return [key, value];\n }),\n )\n : undefined;\n\n const logs = await mastra.listLogsByRunId({\n runId: runId!,\n transportId: transportId!,\n fromDate,\n toDate,\n logLevel,\n filters,\n page: page ? Number(page) : undefined,\n perPage: perPage ? Number(perPage) : undefined,\n });\n return logs;\n } catch (error) {\n return handleError(error, 'Error getting logs by run ID');\n }\n}\n\nexport async function listLogTransports({ mastra }: Pick<LogsContext, 'mastra'>) {\n try {\n const logger = mastra.getLogger();\n const transports = logger.getTransports();\n\n return {\n transports: transports ? [...transports.keys()] : [],\n };\n } catch (error) {\n return handleError(error, 'Error getting log Transports');\n }\n}\n"]}
@@ -1,92 +1,92 @@
1
1
  'use strict';
2
2
 
3
- var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
4
- var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
3
+ var chunkV5WWQN7P_cjs = require('./chunk-V5WWQN7P.cjs');
4
+ var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
5
5
  var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
6
- var scoreTraces = require('@mastra/core/scores/scoreTraces');
6
+ var scoreTraces = require('@mastra/core/evals/scoreTraces');
7
7
 
8
8
  // src/server/handlers/observability.ts
9
9
  var observability_exports = {};
10
10
  chunkO7I5CWRX_cjs.__export(observability_exports, {
11
- getAITraceHandler: () => getAITraceHandler,
12
- getAITracesPaginatedHandler: () => getAITracesPaginatedHandler,
13
- getScoresBySpan: () => getScoresBySpan,
11
+ getTraceHandler: () => getTraceHandler,
12
+ getTracesPaginatedHandler: () => getTracesPaginatedHandler,
13
+ listScoresBySpan: () => listScoresBySpan,
14
14
  scoreTracesHandler: () => scoreTracesHandler
15
15
  });
16
- async function getAITraceHandler({ mastra, traceId }) {
16
+ async function getTraceHandler({ mastra, traceId }) {
17
17
  try {
18
18
  if (!traceId) {
19
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Trace ID is required" });
19
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Trace ID is required" });
20
20
  }
21
21
  const storage = mastra.getStorage();
22
22
  if (!storage) {
23
- throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
23
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Storage is not available" });
24
24
  }
25
- const trace = await storage.getAITrace(traceId);
25
+ const trace = await storage.getTrace(traceId);
26
26
  if (!trace) {
27
- throw new chunk7NADHFD2_cjs.HTTPException(404, { message: `Trace with ID '${traceId}' not found` });
27
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Trace with ID '${traceId}' not found` });
28
28
  }
29
29
  return trace;
30
30
  } catch (error) {
31
- chunkRE4RPXT2_cjs.handleError(error, "Error getting AI trace");
31
+ chunkV5WWQN7P_cjs.handleError(error, "Error getting trace");
32
32
  }
33
33
  }
34
- async function getAITracesPaginatedHandler({ mastra, body }) {
34
+ async function getTracesPaginatedHandler({ mastra, body }) {
35
35
  try {
36
36
  const storage = mastra.getStorage();
37
37
  if (!storage) {
38
- throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
38
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Storage is not available" });
39
39
  }
40
40
  if (!body) {
41
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Request body is required" });
41
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Request body is required" });
42
42
  }
43
43
  const { filters, pagination } = body;
44
44
  if (pagination?.page && pagination.page < 0) {
45
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Page must be a non-negative integer" });
45
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Page must be a non-negative integer" });
46
46
  }
47
47
  if (pagination?.perPage && pagination.perPage < 0) {
48
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Per page must be a non-negative integer" });
48
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Per page must be a non-negative integer" });
49
49
  }
50
50
  if (pagination?.dateRange) {
51
51
  const { start, end } = pagination.dateRange;
52
52
  if (start && !(start instanceof Date)) {
53
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid date format in date range" });
53
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Invalid date format in date range" });
54
54
  }
55
55
  if (end && !(end instanceof Date)) {
56
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid date format in date range" });
56
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Invalid date format in date range" });
57
57
  }
58
58
  }
59
- return storage.getAITracesPaginated({
59
+ return storage.getTracesPaginated({
60
60
  pagination,
61
61
  filters
62
62
  });
63
63
  } catch (error) {
64
- chunkRE4RPXT2_cjs.handleError(error, "Error getting AI traces paginated");
64
+ chunkV5WWQN7P_cjs.handleError(error, "Error getting traces paginated");
65
65
  }
66
66
  }
67
67
  async function scoreTracesHandler({ mastra, body }) {
68
68
  try {
69
69
  if (!body) {
70
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Request body is required" });
70
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Request body is required" });
71
71
  }
72
72
  const { scorerName, targets } = body;
73
73
  if (!scorerName) {
74
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Scorer Name is required" });
74
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Scorer ID is required" });
75
75
  }
76
76
  if (!targets || targets.length === 0) {
77
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "At least one target is required" });
77
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "At least one target is required" });
78
78
  }
79
79
  const storage = mastra.getStorage();
80
80
  if (!storage) {
81
- throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
81
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Storage is not available" });
82
82
  }
83
- const scorer = mastra.getScorerByName(scorerName);
83
+ const scorer = mastra.getScorerById(scorerName);
84
84
  if (!scorer) {
85
- throw new chunk7NADHFD2_cjs.HTTPException(404, { message: `Scorer '${scorerName}' not found` });
85
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: `Scorer '${scorerName}' not found` });
86
86
  }
87
87
  const logger = mastra.getLogger();
88
88
  scoreTraces.scoreTraces({
89
- scorerName,
89
+ scorerId: scorer.config.id || scorer.config.name,
90
90
  targets,
91
91
  mastra
92
92
  }).catch((error) => {
@@ -98,10 +98,10 @@ async function scoreTracesHandler({ mastra, body }) {
98
98
  traceCount: targets.length
99
99
  };
100
100
  } catch (error) {
101
- chunkRE4RPXT2_cjs.handleError(error, "Error processing trace scoring");
101
+ chunkV5WWQN7P_cjs.handleError(error, "Error processing trace scoring");
102
102
  }
103
103
  }
104
- async function getScoresBySpan({
104
+ async function listScoresBySpan({
105
105
  mastra,
106
106
  traceId,
107
107
  spanId,
@@ -110,21 +110,21 @@ async function getScoresBySpan({
110
110
  try {
111
111
  const storage = mastra.getStorage();
112
112
  if (!storage) {
113
- throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Storage is not available" });
113
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Storage is not available" });
114
114
  }
115
115
  if (!traceId || !spanId) {
116
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Trace ID and span ID are required" });
116
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Trace ID and span ID are required" });
117
117
  }
118
- return await storage.getScoresBySpan({ traceId, spanId, pagination });
118
+ return await storage.listScoresBySpan({ traceId, spanId, pagination });
119
119
  } catch (error) {
120
- return chunkRE4RPXT2_cjs.handleError(error, "Error getting scores by span");
120
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting scores by span");
121
121
  }
122
122
  }
123
123
 
124
- exports.getAITraceHandler = getAITraceHandler;
125
- exports.getAITracesPaginatedHandler = getAITracesPaginatedHandler;
126
- exports.getScoresBySpan = getScoresBySpan;
124
+ exports.getTraceHandler = getTraceHandler;
125
+ exports.getTracesPaginatedHandler = getTracesPaginatedHandler;
126
+ exports.listScoresBySpan = listScoresBySpan;
127
127
  exports.observability_exports = observability_exports;
128
128
  exports.scoreTracesHandler = scoreTracesHandler;
129
- //# sourceMappingURL=chunk-2S4IMB6E.cjs.map
130
- //# sourceMappingURL=chunk-2S4IMB6E.cjs.map
129
+ //# sourceMappingURL=chunk-A24TSVEZ.cjs.map
130
+ //# sourceMappingURL=chunk-A24TSVEZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/observability.ts"],"names":["__export","HTTPException","handleError","scoreTraces"],"mappings":";;;;;;;;AAAA,IAAA,qBAAA,GAAA;AAAAA,0BAAA,CAAA,qBAAA,EAAA;AAAA,EAAA,eAAA,EAAA,MAAA,eAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,gBAAA,EAAA,MAAA,gBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AA0BA,eAAsB,eAAA,CAAgB,EAAE,MAAA,EAAQ,OAAA,EAAQ,EAA+C;AACrG,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIC,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,wBAAwB,CAAA;AAAA,IAClE;AAEA,IAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAClC,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,4BAA4B,CAAA;AAAA,IACtE;AAEA,IAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,QAAA,CAAS,OAAO,CAAA;AAE5C,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAIA,gCAAc,GAAA,EAAK,EAAE,SAAS,CAAA,eAAA,EAAkB,OAAO,eAAe,CAAA;AAAA,IAClF;AAEA,IAAA,OAAO,KAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAAC,6BAAA,CAAY,OAAO,qBAAqB,CAAA;AAAA,EAC1C;AACF;AAMA,eAAsB,yBAAA,CAA0B,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AACtF,EAAA,I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\nimport type { TracesPaginatedArg, StoragePagination } from '@mastra/core/storage';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface ObservabilityContext extends Context {\n traceId?: string;\n body?: TracesPaginatedArg;\n}\n\ninterface ScoreTracesContext extends Context {\n body?: {\n // scorer.id\n scorerName: string;\n targets: Array<{\n traceId: string;\n spanId?: string;\n }>;\n };\n}\n\n/**\n * Get a complete trace by trace ID\n * Returns all spans in the trace with their parent-child relationships\n */\nexport async function getTraceHandler({ mastra, traceId }: ObservabilityContext & { traceId: string }) {\n try {\n if (!traceId) {\n throw new HTTPException(400, { message: 'Trace ID is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const trace = await storage.getTrace(traceId);\n\n if (!trace) {\n throw new HTTPException(404, { message: `Trace with ID '${traceId}' not found` });\n }\n\n return trace;\n } catch (error) {\n handleError(error, 'Error getting trace');\n }\n}\n\n/**\n * Get paginated traces with filtering and pagination\n * Returns only root spans (parent spans) for pagination, not child spans\n */\nexport async function getTracesPaginatedHandler({ mastra, body }: ObservabilityContext) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { filters, pagination } = body;\n\n if (pagination?.page && pagination.page < 0) {\n throw new HTTPException(400, { message: 'Page must be a non-negative integer' });\n }\n\n if (pagination?.perPage && pagination.perPage < 0) {\n throw new HTTPException(400, { message: 'Per page must be a non-negative integer' });\n }\n\n if (pagination?.dateRange) {\n const { start, end } = pagination.dateRange;\n\n if (start && !(start instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n\n if (end && !(end instanceof Date)) {\n throw new HTTPException(400, { message: 'Invalid date format in date range' });\n }\n }\n\n return storage.getTracesPaginated({\n pagination,\n filters,\n });\n } catch (error) {\n handleError(error, 'Error getting traces paginated');\n }\n}\n\n/**\n * Score traces using a specified scorer\n * Fire-and-forget approach - returns immediately while scoring runs in background\n */\nexport async function scoreTracesHandler({ mastra, body }: ScoreTracesContext) {\n try {\n if (!body) {\n throw new HTTPException(400, { message: 'Request body is required' });\n }\n\n const { scorerName, targets } = body;\n\n if (!scorerName) {\n throw new HTTPException(400, { message: 'Scorer ID is required' });\n }\n\n if (!targets || targets.length === 0) {\n throw new HTTPException(400, { message: 'At least one target is required' });\n }\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n const scorer = mastra.getScorerById(scorerName);\n if (!scorer) {\n throw new HTTPException(404, { message: `Scorer '${scorerName}' not found` });\n }\n\n const logger = mastra.getLogger();\n\n scoreTraces({\n scorerId: scorer.config.id || scorer.config.name,\n targets,\n mastra,\n }).catch(error => {\n logger?.error(`Background trace scoring failed: ${error.message}`, error);\n });\n\n // Return immediate response\n return {\n status: 'success',\n message: `Scoring started for ${targets.length} ${targets.length === 1 ? 'trace' : 'traces'}`,\n traceCount: targets.length,\n };\n } catch (error) {\n handleError(error, 'Error processing trace scoring');\n }\n}\n\nexport async function listScoresBySpan({\n mastra,\n traceId,\n spanId,\n pagination,\n}: Context & { traceId: string; spanId: string; pagination: StoragePagination }) {\n try {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n\n if (!traceId || !spanId) {\n throw new HTTPException(400, { message: 'Trace ID and span ID are required' });\n }\n\n return await storage.listScoresBySpan({ traceId, spanId, pagination });\n } catch (error) {\n return handleError(error, 'Error getting scores by span');\n }\n}\n"]}