@mastra/react 1.7.3-alpha.3 → 1.8.0-alpha.4

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 (510) hide show
  1. package/dist/accumulator-B1MuNX3j.js +1668 -0
  2. package/dist/accumulator-B1MuNX3j.js.map +1 -0
  3. package/dist/accumulator-CsUGDUHk.cjs +1709 -0
  4. package/dist/accumulator-CsUGDUHk.cjs.map +1 -0
  5. package/dist/agent/hooks.d.ts.map +1 -1
  6. package/dist/agent/user-message.d.ts +4 -0
  7. package/dist/agent/user-message.d.ts.map +1 -0
  8. package/dist/chat/index.cjs +3 -0
  9. package/dist/chat/index.d.ts +3 -0
  10. package/dist/chat/index.d.ts.map +1 -0
  11. package/dist/chat/index.js +2 -0
  12. package/dist/feedback-refetch-interval-DLHzQoVV.js +12 -0
  13. package/dist/feedback-refetch-interval-DLHzQoVV.js.map +1 -0
  14. package/dist/feedback-refetch-interval-XD5FVc2k.cjs +17 -0
  15. package/dist/feedback-refetch-interval-XD5FVc2k.cjs.map +1 -0
  16. package/dist/hooks/agents/index.cjs +988 -0
  17. package/dist/hooks/agents/index.cjs.map +1 -0
  18. package/dist/hooks/agents/index.d.ts +19 -0
  19. package/dist/hooks/agents/index.d.ts.map +1 -0
  20. package/dist/hooks/agents/index.js +952 -0
  21. package/dist/hooks/agents/index.js.map +1 -0
  22. package/dist/hooks/agents/is-model-not-allowed.d.ts +15 -0
  23. package/dist/hooks/agents/is-model-not-allowed.d.ts.map +1 -0
  24. package/dist/hooks/agents/use-agent-messages.d.ts +18 -0
  25. package/dist/hooks/agents/use-agent-messages.d.ts.map +1 -0
  26. package/dist/hooks/agents/use-agent-plan.d.ts +14 -0
  27. package/dist/hooks/agents/use-agent-plan.d.ts.map +1 -0
  28. package/dist/hooks/agents/use-agent-skills.d.ts +2021 -0
  29. package/dist/hooks/agents/use-agent-skills.d.ts.map +1 -0
  30. package/dist/hooks/agents/use-agent-versions.d.ts +72 -0
  31. package/dist/hooks/agents/use-agent-versions.d.ts.map +1 -0
  32. package/dist/hooks/agents/use-agent-working-memory.d.ts +11 -0
  33. package/dist/hooks/agents/use-agent-working-memory.d.ts.map +1 -0
  34. package/dist/hooks/agents/use-agent-workspace.d.ts +2022 -0
  35. package/dist/hooks/agents/use-agent-workspace.d.ts.map +1 -0
  36. package/dist/hooks/agents/use-agent.d.ts +12 -0
  37. package/dist/hooks/agents/use-agent.d.ts.map +1 -0
  38. package/dist/hooks/agents/use-agents-model-providers.d.ts +9 -0
  39. package/dist/hooks/agents/use-agents-model-providers.d.ts.map +1 -0
  40. package/dist/hooks/agents/use-agents.d.ts +28 -0
  41. package/dist/hooks/agents/use-agents.d.ts.map +1 -0
  42. package/dist/hooks/agents/use-background-tasks.d.ts +51 -0
  43. package/dist/hooks/agents/use-background-tasks.d.ts.map +1 -0
  44. package/dist/hooks/agents/use-browser-session-probe.d.ts +34 -0
  45. package/dist/hooks/agents/use-browser-session-probe.d.ts.map +1 -0
  46. package/dist/hooks/agents/use-channels.d.ts +34 -0
  47. package/dist/hooks/agents/use-channels.d.ts.map +1 -0
  48. package/dist/hooks/agents/use-close-browser.d.ts +17 -0
  49. package/dist/hooks/agents/use-close-browser.d.ts.map +1 -0
  50. package/dist/hooks/agents/use-execute-agent-tool.d.ts +14 -0
  51. package/dist/hooks/agents/use-execute-agent-tool.d.ts.map +1 -0
  52. package/dist/hooks/agents/use-preview-instructions.d.ts +20 -0
  53. package/dist/hooks/agents/use-preview-instructions.d.ts.map +1 -0
  54. package/dist/hooks/agents/use-stored-agents.d.ts +8023 -0
  55. package/dist/hooks/agents/use-stored-agents.d.ts.map +1 -0
  56. package/dist/hooks/agents/use-stored-skills.d.ts +8 -0
  57. package/dist/hooks/agents/use-stored-skills.d.ts.map +1 -0
  58. package/dist/hooks/auth/fetch-with-refresh.d.ts +28 -0
  59. package/dist/hooks/auth/fetch-with-refresh.d.ts.map +1 -0
  60. package/dist/hooks/auth/get-client-query-key.d.ts +7 -0
  61. package/dist/hooks/auth/get-client-query-key.d.ts.map +1 -0
  62. package/dist/hooks/auth/index.cjs +492 -0
  63. package/dist/hooks/auth/index.cjs.map +1 -0
  64. package/dist/hooks/auth/index.d.ts +11 -0
  65. package/dist/hooks/auth/index.d.ts.map +1 -0
  66. package/dist/hooks/auth/index.js +474 -0
  67. package/dist/hooks/auth/index.js.map +1 -0
  68. package/dist/hooks/auth/sso-login.d.ts +8 -0
  69. package/dist/hooks/auth/sso-login.d.ts.map +1 -0
  70. package/dist/hooks/auth/types.d.ts +107 -0
  71. package/dist/hooks/auth/types.d.ts.map +1 -0
  72. package/dist/hooks/auth/use-auth-actions.d.ts +99 -0
  73. package/dist/hooks/auth/use-auth-actions.d.ts.map +1 -0
  74. package/dist/hooks/auth/use-auth-capabilities.d.ts +43 -0
  75. package/dist/hooks/auth/use-auth-capabilities.d.ts.map +1 -0
  76. package/dist/hooks/auth/use-credentials-login.d.ts +63 -0
  77. package/dist/hooks/auth/use-credentials-login.d.ts.map +1 -0
  78. package/dist/hooks/auth/use-credentials-signup.d.ts +66 -0
  79. package/dist/hooks/auth/use-credentials-signup.d.ts.map +1 -0
  80. package/dist/hooks/auth/use-current-user.d.ts +40 -0
  81. package/dist/hooks/auth/use-current-user.d.ts.map +1 -0
  82. package/dist/hooks/auth/use-permission-patterns.d.ts +24 -0
  83. package/dist/hooks/auth/use-permission-patterns.d.ts.map +1 -0
  84. package/dist/hooks/capabilities/index.cjs +47 -0
  85. package/dist/hooks/capabilities/index.cjs.map +1 -0
  86. package/dist/hooks/capabilities/index.d.ts +4 -0
  87. package/dist/hooks/capabilities/index.d.ts.map +1 -0
  88. package/dist/hooks/capabilities/index.js +44 -0
  89. package/dist/hooks/capabilities/index.js.map +1 -0
  90. package/dist/hooks/capabilities/use-feedback-available.d.ts +9 -0
  91. package/dist/hooks/capabilities/use-feedback-available.d.ts.map +1 -0
  92. package/dist/hooks/capabilities/use-observability-capabilities.d.ts +9 -0
  93. package/dist/hooks/capabilities/use-observability-capabilities.d.ts.map +1 -0
  94. package/dist/hooks/capabilities/use-trace-query-available.d.ts +9 -0
  95. package/dist/hooks/capabilities/use-trace-query-available.d.ts.map +1 -0
  96. package/dist/hooks/configuration/index.cjs +18 -0
  97. package/dist/hooks/configuration/index.cjs.map +1 -0
  98. package/dist/hooks/configuration/index.d.ts +2 -0
  99. package/dist/hooks/configuration/index.d.ts.map +1 -0
  100. package/dist/hooks/configuration/index.js +17 -0
  101. package/dist/hooks/configuration/index.js.map +1 -0
  102. package/dist/hooks/configuration/use-mastra-packages.d.ts +9 -0
  103. package/dist/hooks/configuration/use-mastra-packages.d.ts.map +1 -0
  104. package/dist/hooks/datasets/index.cjs +615 -0
  105. package/dist/hooks/datasets/index.cjs.map +1 -0
  106. package/dist/hooks/datasets/index.d.ts +10 -0
  107. package/dist/hooks/datasets/index.d.ts.map +1 -0
  108. package/dist/hooks/datasets/index.js +600 -0
  109. package/dist/hooks/datasets/index.js.map +1 -0
  110. package/dist/hooks/datasets/use-compare-experiments.d.ts +23 -0
  111. package/dist/hooks/datasets/use-compare-experiments.d.ts.map +1 -0
  112. package/dist/hooks/datasets/use-dataset-experiments.d.ts +49 -0
  113. package/dist/hooks/datasets/use-dataset-experiments.d.ts.map +1 -0
  114. package/dist/hooks/datasets/use-dataset-item-versions.d.ts +31 -0
  115. package/dist/hooks/datasets/use-dataset-item-versions.d.ts.map +1 -0
  116. package/dist/hooks/datasets/use-dataset-items.d.ts +38 -0
  117. package/dist/hooks/datasets/use-dataset-items.d.ts.map +1 -0
  118. package/dist/hooks/datasets/use-dataset-mutations.d.ts +362 -0
  119. package/dist/hooks/datasets/use-dataset-mutations.d.ts.map +1 -0
  120. package/dist/hooks/datasets/use-dataset-versions.d.ts +23 -0
  121. package/dist/hooks/datasets/use-dataset-versions.d.ts.map +1 -0
  122. package/dist/hooks/datasets/use-datasets.d.ts +44 -0
  123. package/dist/hooks/datasets/use-datasets.d.ts.map +1 -0
  124. package/dist/hooks/datasets/use-experiments.d.ts +16 -0
  125. package/dist/hooks/datasets/use-experiments.d.ts.map +1 -0
  126. package/dist/hooks/datasets/use-workflow-schema.d.ts +16 -0
  127. package/dist/hooks/datasets/use-workflow-schema.d.ts.map +1 -0
  128. package/dist/hooks/embedders/index.cjs +19 -0
  129. package/dist/hooks/embedders/index.cjs.map +1 -0
  130. package/dist/hooks/embedders/index.d.ts +2 -0
  131. package/dist/hooks/embedders/index.d.ts.map +1 -0
  132. package/dist/hooks/embedders/index.js +18 -0
  133. package/dist/hooks/embedders/index.js.map +1 -0
  134. package/dist/hooks/embedders/use-embedders.d.ts +17 -0
  135. package/dist/hooks/embedders/use-embedders.d.ts.map +1 -0
  136. package/dist/hooks/experiments/index.cjs +152 -0
  137. package/dist/hooks/experiments/index.cjs.map +1 -0
  138. package/dist/hooks/experiments/index.d.ts +5 -0
  139. package/dist/hooks/experiments/index.d.ts.map +1 -0
  140. package/dist/hooks/experiments/index.js +146 -0
  141. package/dist/hooks/experiments/index.js.map +1 -0
  142. package/dist/hooks/experiments/use-experiment-metrics.d.ts +30 -0
  143. package/dist/hooks/experiments/use-experiment-metrics.d.ts.map +1 -0
  144. package/dist/hooks/experiments/use-experiment-trace.d.ts +13 -0
  145. package/dist/hooks/experiments/use-experiment-trace.d.ts.map +1 -0
  146. package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts +22 -0
  147. package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts.map +1 -0
  148. package/dist/hooks/experiments/use-infinite-experiments.d.ts +22 -0
  149. package/dist/hooks/experiments/use-infinite-experiments.d.ts.map +1 -0
  150. package/dist/hooks/feedback/feedback-refetch-interval.d.ts +7 -0
  151. package/dist/hooks/feedback/feedback-refetch-interval.d.ts.map +1 -0
  152. package/dist/hooks/feedback/index.cjs +22 -0
  153. package/dist/hooks/feedback/index.cjs.map +1 -0
  154. package/dist/hooks/feedback/index.d.ts +3 -0
  155. package/dist/hooks/feedback/index.d.ts.map +1 -0
  156. package/dist/hooks/feedback/index.js +20 -0
  157. package/dist/hooks/feedback/index.js.map +1 -0
  158. package/dist/hooks/feedback/use-feedback.d.ts +56 -0
  159. package/dist/hooks/feedback/use-feedback.d.ts.map +1 -0
  160. package/dist/hooks/llm/index.cjs +17 -0
  161. package/dist/hooks/llm/index.cjs.map +1 -0
  162. package/dist/hooks/llm/index.d.ts +2 -0
  163. package/dist/hooks/llm/index.d.ts.map +1 -0
  164. package/dist/hooks/llm/index.js +16 -0
  165. package/dist/hooks/llm/index.js.map +1 -0
  166. package/dist/hooks/llm/use-llm-providers.d.ts +7 -0
  167. package/dist/hooks/llm/use-llm-providers.d.ts.map +1 -0
  168. package/dist/hooks/logs/index.cjs +84 -0
  169. package/dist/hooks/logs/index.cjs.map +1 -0
  170. package/dist/hooks/logs/index.d.ts +4 -0
  171. package/dist/hooks/logs/index.d.ts.map +1 -0
  172. package/dist/hooks/logs/index.js +82 -0
  173. package/dist/hooks/logs/index.js.map +1 -0
  174. package/dist/hooks/logs/types.d.ts +36 -0
  175. package/dist/hooks/logs/types.d.ts.map +1 -0
  176. package/dist/hooks/logs/use-logs.d.ts +79 -0
  177. package/dist/hooks/logs/use-logs.d.ts.map +1 -0
  178. package/dist/hooks/mcps/index.cjs +215 -0
  179. package/dist/hooks/mcps/index.cjs.map +1 -0
  180. package/dist/hooks/mcps/index.d.ts +7 -0
  181. package/dist/hooks/mcps/index.d.ts.map +1 -0
  182. package/dist/hooks/mcps/index.js +208 -0
  183. package/dist/hooks/mcps/index.js.map +1 -0
  184. package/dist/hooks/mcps/use-mcp-app-tools.d.ts +21 -0
  185. package/dist/hooks/mcps/use-mcp-app-tools.d.ts.map +1 -0
  186. package/dist/hooks/mcps/use-mcp-server-tool.d.ts +25 -0
  187. package/dist/hooks/mcps/use-mcp-server-tool.d.ts.map +1 -0
  188. package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts +13 -0
  189. package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts.map +1 -0
  190. package/dist/hooks/mcps/use-mcp-server-tools.d.ts +9 -0
  191. package/dist/hooks/mcps/use-mcp-server-tools.d.ts.map +1 -0
  192. package/dist/hooks/mcps/use-mcp-servers.d.ts +8 -0
  193. package/dist/hooks/mcps/use-mcp-servers.d.ts.map +1 -0
  194. package/dist/hooks/mcps/use-try-connect-mcp.d.ts +15 -0
  195. package/dist/hooks/mcps/use-try-connect-mcp.d.ts.map +1 -0
  196. package/dist/hooks/memory/index.cjs +328 -0
  197. package/dist/hooks/memory/index.cjs.map +1 -0
  198. package/dist/hooks/memory/index.d.ts +5 -0
  199. package/dist/hooks/memory/index.d.ts.map +1 -0
  200. package/dist/hooks/memory/index.js +312 -0
  201. package/dist/hooks/memory/index.js.map +1 -0
  202. package/dist/hooks/memory/use-memory-status.d.ts +12 -0
  203. package/dist/hooks/memory/use-memory-status.d.ts.map +1 -0
  204. package/dist/hooks/memory/use-memory-thread-messages.d.ts +13 -0
  205. package/dist/hooks/memory/use-memory-thread-messages.d.ts.map +1 -0
  206. package/dist/hooks/memory/use-memory.d.ts +159 -0
  207. package/dist/hooks/memory/use-memory.d.ts.map +1 -0
  208. package/dist/hooks/memory/use-observational-memory.d.ts +13 -0
  209. package/dist/hooks/memory/use-observational-memory.d.ts.map +1 -0
  210. package/dist/hooks/metrics/index.cjs +997 -0
  211. package/dist/hooks/metrics/index.cjs.map +1 -0
  212. package/dist/hooks/metrics/index.d.ts +16 -0
  213. package/dist/hooks/metrics/index.d.ts.map +1 -0
  214. package/dist/hooks/metrics/index.js +981 -0
  215. package/dist/hooks/metrics/index.js.map +1 -0
  216. package/dist/hooks/metrics/metrics-interval.d.ts +8 -0
  217. package/dist/hooks/metrics/metrics-interval.d.ts.map +1 -0
  218. package/dist/hooks/metrics/metrics-query-filters.d.ts +62 -0
  219. package/dist/hooks/metrics/metrics-query-filters.d.ts.map +1 -0
  220. package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts +12 -0
  221. package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts.map +1 -0
  222. package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts +12 -0
  223. package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts.map +1 -0
  224. package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts +9 -0
  225. package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts.map +1 -0
  226. package/dist/hooks/metrics/use-latency-metrics.d.ts +23 -0
  227. package/dist/hooks/metrics/use-latency-metrics.d.ts.map +1 -0
  228. package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts +14 -0
  229. package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts.map +1 -0
  230. package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts +16 -0
  231. package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts.map +1 -0
  232. package/dist/hooks/metrics/use-scores-metrics.d.ts +24 -0
  233. package/dist/hooks/metrics/use-scores-metrics.d.ts.map +1 -0
  234. package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts +15 -0
  235. package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts.map +1 -0
  236. package/dist/hooks/metrics/use-token-usage-timeseries.d.ts +22 -0
  237. package/dist/hooks/metrics/use-token-usage-timeseries.d.ts.map +1 -0
  238. package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts +21 -0
  239. package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts.map +1 -0
  240. package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts +20 -0
  241. package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts.map +1 -0
  242. package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts +13 -0
  243. package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts.map +1 -0
  244. package/dist/hooks/metrics/use-trace-volume-metrics.d.ts +17 -0
  245. package/dist/hooks/metrics/use-trace-volume-metrics.d.ts.map +1 -0
  246. package/dist/hooks/processors/index.cjs +43 -0
  247. package/dist/hooks/processors/index.cjs.map +1 -0
  248. package/dist/hooks/processors/index.d.ts +2 -0
  249. package/dist/hooks/processors/index.d.ts.map +1 -0
  250. package/dist/hooks/processors/index.js +40 -0
  251. package/dist/hooks/processors/index.js.map +1 -0
  252. package/dist/hooks/processors/use-processors.d.ts +64 -0
  253. package/dist/hooks/processors/use-processors.d.ts.map +1 -0
  254. package/dist/hooks/prompt-blocks/index.cjs +181 -0
  255. package/dist/hooks/prompt-blocks/index.cjs.map +1 -0
  256. package/dist/hooks/prompt-blocks/index.d.ts +3 -0
  257. package/dist/hooks/prompt-blocks/index.d.ts.map +1 -0
  258. package/dist/hooks/prompt-blocks/index.js +172 -0
  259. package/dist/hooks/prompt-blocks/index.js.map +1 -0
  260. package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts +59 -0
  261. package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts.map +1 -0
  262. package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts +180 -0
  263. package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts.map +1 -0
  264. package/dist/hooks/query/index.cjs +34 -0
  265. package/dist/hooks/query/index.cjs.map +1 -0
  266. package/dist/hooks/query/index.d.ts +4 -0
  267. package/dist/hooks/query/index.d.ts.map +1 -0
  268. package/dist/hooks/query/index.js +25 -0
  269. package/dist/hooks/query/index.js.map +1 -0
  270. package/dist/hooks/query/query-client-provider.d.ts +8 -0
  271. package/dist/hooks/query/query-client-provider.d.ts.map +1 -0
  272. package/dist/hooks/query/query-utils.d.ts +48 -0
  273. package/dist/hooks/query/query-utils.d.ts.map +1 -0
  274. package/dist/hooks/review/index.cjs +89 -0
  275. package/dist/hooks/review/index.cjs.map +1 -0
  276. package/dist/hooks/review/index.d.ts +4 -0
  277. package/dist/hooks/review/index.d.ts.map +1 -0
  278. package/dist/hooks/review/index.js +86 -0
  279. package/dist/hooks/review/index.js.map +1 -0
  280. package/dist/hooks/review/types.d.ts +21 -0
  281. package/dist/hooks/review/types.d.ts.map +1 -0
  282. package/dist/hooks/review/use-dataset-review-items.d.ts +19 -0
  283. package/dist/hooks/review/use-dataset-review-items.d.ts.map +1 -0
  284. package/dist/hooks/review/use-review-summary.d.ts +9 -0
  285. package/dist/hooks/review/use-review-summary.d.ts.map +1 -0
  286. package/dist/hooks/schedules/index.cjs +110 -0
  287. package/dist/hooks/schedules/index.cjs.map +1 -0
  288. package/dist/hooks/schedules/index.d.ts +5 -0
  289. package/dist/hooks/schedules/index.d.ts.map +1 -0
  290. package/dist/hooks/schedules/index.js +106 -0
  291. package/dist/hooks/schedules/index.js.map +1 -0
  292. package/dist/hooks/schedules/use-schedule-triggers.d.ts +18 -0
  293. package/dist/hooks/schedules/use-schedule-triggers.d.ts.map +1 -0
  294. package/dist/hooks/schedules/use-schedule.d.ts +11 -0
  295. package/dist/hooks/schedules/use-schedule.d.ts.map +1 -0
  296. package/dist/hooks/schedules/use-schedules.d.ts +7 -0
  297. package/dist/hooks/schedules/use-schedules.d.ts.map +1 -0
  298. package/dist/hooks/schedules/use-toggle-schedule.d.ts +13 -0
  299. package/dist/hooks/schedules/use-toggle-schedule.d.ts.map +1 -0
  300. package/dist/hooks/scores/index.cjs +339 -0
  301. package/dist/hooks/scores/index.cjs.map +1 -0
  302. package/dist/hooks/scores/index.d.ts +6 -0
  303. package/dist/hooks/scores/index.d.ts.map +1 -0
  304. package/dist/hooks/scores/index.js +323 -0
  305. package/dist/hooks/scores/index.js.map +1 -0
  306. package/dist/hooks/scores/use-scorer-versions.d.ts +71 -0
  307. package/dist/hooks/scores/use-scorer-versions.d.ts.map +1 -0
  308. package/dist/hooks/scores/use-scorers.d.ts +34 -0
  309. package/dist/hooks/scores/use-scorers.d.ts.map +1 -0
  310. package/dist/hooks/scores/use-stored-scorers.d.ts +151 -0
  311. package/dist/hooks/scores/use-stored-scorers.d.ts.map +1 -0
  312. package/dist/hooks/scores/use-trace-span-scores.d.ts +20 -0
  313. package/dist/hooks/scores/use-trace-span-scores.d.ts.map +1 -0
  314. package/dist/hooks/scores/use-trigger-scorer.d.ts +17 -0
  315. package/dist/hooks/scores/use-trigger-scorer.d.ts.map +1 -0
  316. package/dist/hooks/shared/cost.d.ts +7 -0
  317. package/dist/hooks/shared/cost.d.ts.map +1 -0
  318. package/dist/hooks/shared/date-format.d.ts +30 -0
  319. package/dist/hooks/shared/date-format.d.ts.map +1 -0
  320. package/dist/hooks/shared/map.d.ts +2 -0
  321. package/dist/hooks/shared/map.d.ts.map +1 -0
  322. package/dist/hooks/shared/query-options.d.ts +19 -0
  323. package/dist/hooks/shared/query-options.d.ts.map +1 -0
  324. package/dist/hooks/shared/use-in-view.d.ts +23 -0
  325. package/dist/hooks/shared/use-in-view.d.ts.map +1 -0
  326. package/dist/hooks/templates/index.cjs +464 -0
  327. package/dist/hooks/templates/index.cjs.map +1 -0
  328. package/dist/hooks/templates/index.d.ts +2 -0
  329. package/dist/hooks/templates/index.d.ts.map +1 -0
  330. package/dist/hooks/templates/index.js +456 -0
  331. package/dist/hooks/templates/index.js.map +1 -0
  332. package/dist/hooks/templates/use-templates.d.ts +139 -0
  333. package/dist/hooks/templates/use-templates.d.ts.map +1 -0
  334. package/dist/hooks/tool-providers/index.cjs +342 -0
  335. package/dist/hooks/tool-providers/index.cjs.map +1 -0
  336. package/dist/hooks/tool-providers/index.d.ts +10 -0
  337. package/dist/hooks/tool-providers/index.d.ts.map +1 -0
  338. package/dist/hooks/tool-providers/index.js +332 -0
  339. package/dist/hooks/tool-providers/index.js.map +1 -0
  340. package/dist/hooks/tool-providers/use-all-connections.d.ts +41 -0
  341. package/dist/hooks/tool-providers/use-all-connections.d.ts.map +1 -0
  342. package/dist/hooks/tool-providers/use-all-provider-tools.d.ts +25 -0
  343. package/dist/hooks/tool-providers/use-all-provider-tools.d.ts.map +1 -0
  344. package/dist/hooks/tool-providers/use-authorize.d.ts +45 -0
  345. package/dist/hooks/tool-providers/use-authorize.d.ts.map +1 -0
  346. package/dist/hooks/tool-providers/use-disconnect-connection.d.ts +24 -0
  347. package/dist/hooks/tool-providers/use-disconnect-connection.d.ts.map +1 -0
  348. package/dist/hooks/tool-providers/use-existing-connections.d.ts +33 -0
  349. package/dist/hooks/tool-providers/use-existing-connections.d.ts.map +1 -0
  350. package/dist/hooks/tool-providers/use-provider-tools.d.ts +17 -0
  351. package/dist/hooks/tool-providers/use-provider-tools.d.ts.map +1 -0
  352. package/dist/hooks/tool-providers/use-tool-providers.d.ts +23 -0
  353. package/dist/hooks/tool-providers/use-tool-providers.d.ts.map +1 -0
  354. package/dist/hooks/tool-providers/use-toolkits.d.ts +13 -0
  355. package/dist/hooks/tool-providers/use-toolkits.d.ts.map +1 -0
  356. package/dist/hooks/tool-providers/use-update-connection.d.ts +24 -0
  357. package/dist/hooks/tool-providers/use-update-connection.d.ts.map +1 -0
  358. package/dist/hooks/tools/index.cjs +49 -0
  359. package/dist/hooks/tools/index.cjs.map +1 -0
  360. package/dist/hooks/tools/index.d.ts +3 -0
  361. package/dist/hooks/tools/index.d.ts.map +1 -0
  362. package/dist/hooks/tools/index.js +46 -0
  363. package/dist/hooks/tools/index.js.map +1 -0
  364. package/dist/hooks/tools/use-all-tools.d.ts +16 -0
  365. package/dist/hooks/tools/use-all-tools.d.ts.map +1 -0
  366. package/dist/hooks/tools/use-execute-tool.d.ts +13 -0
  367. package/dist/hooks/tools/use-execute-tool.d.ts.map +1 -0
  368. package/dist/hooks/traces/discovery-cache.d.ts +12 -0
  369. package/dist/hooks/traces/discovery-cache.d.ts.map +1 -0
  370. package/dist/hooks/traces/index.cjs +1168 -0
  371. package/dist/hooks/traces/index.cjs.map +1 -0
  372. package/dist/hooks/traces/index.d.ts +22 -0
  373. package/dist/hooks/traces/index.d.ts.map +1 -0
  374. package/dist/hooks/traces/index.js +1129 -0
  375. package/dist/hooks/traces/index.js.map +1 -0
  376. package/dist/hooks/traces/types.d.ts +20 -0
  377. package/dist/hooks/traces/types.d.ts.map +1 -0
  378. package/dist/hooks/traces/use-branch.d.ts +18 -0
  379. package/dist/hooks/traces/use-branch.d.ts.map +1 -0
  380. package/dist/hooks/traces/use-create-feedback.d.ts +21 -0
  381. package/dist/hooks/traces/use-create-feedback.d.ts.map +1 -0
  382. package/dist/hooks/traces/use-delete-feedback.d.ts +21 -0
  383. package/dist/hooks/traces/use-delete-feedback.d.ts.map +1 -0
  384. package/dist/hooks/traces/use-entity-names.d.ts +14 -0
  385. package/dist/hooks/traces/use-entity-names.d.ts.map +1 -0
  386. package/dist/hooks/traces/use-environments.d.ts +10 -0
  387. package/dist/hooks/traces/use-environments.d.ts.map +1 -0
  388. package/dist/hooks/traces/use-service-names.d.ts +10 -0
  389. package/dist/hooks/traces/use-service-names.d.ts.map +1 -0
  390. package/dist/hooks/traces/use-span-detail.d.ts +14 -0
  391. package/dist/hooks/traces/use-span-detail.d.ts.map +1 -0
  392. package/dist/hooks/traces/use-span-feedback.d.ts +19 -0
  393. package/dist/hooks/traces/use-span-feedback.d.ts.map +1 -0
  394. package/dist/hooks/traces/use-tags.d.ts +10 -0
  395. package/dist/hooks/traces/use-tags.d.ts.map +1 -0
  396. package/dist/hooks/traces/use-thread-has-other-traces.d.ts +17 -0
  397. package/dist/hooks/traces/use-thread-has-other-traces.d.ts.map +1 -0
  398. package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts +6 -0
  399. package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts.map +1 -0
  400. package/dist/hooks/traces/use-trace-feedback.d.ts +16 -0
  401. package/dist/hooks/traces/use-trace-feedback.d.ts.map +1 -0
  402. package/dist/hooks/traces/use-trace-light-spans.d.ts +16 -0
  403. package/dist/hooks/traces/use-trace-light-spans.d.ts.map +1 -0
  404. package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts +36 -0
  405. package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts.map +1 -0
  406. package/dist/hooks/traces/use-trace-or-branch-spans.d.ts +39 -0
  407. package/dist/hooks/traces/use-trace-or-branch-spans.d.ts.map +1 -0
  408. package/dist/hooks/traces/use-trace-query.d.ts +57 -0
  409. package/dist/hooks/traces/use-trace-query.d.ts.map +1 -0
  410. package/dist/hooks/traces/use-trace-spans.d.ts +46 -0
  411. package/dist/hooks/traces/use-trace-spans.d.ts.map +1 -0
  412. package/dist/hooks/traces/use-trace-usage.d.ts +10 -0
  413. package/dist/hooks/traces/use-trace-usage.d.ts.map +1 -0
  414. package/dist/hooks/traces/use-traces.d.ts +292 -0
  415. package/dist/hooks/traces/use-traces.d.ts.map +1 -0
  416. package/dist/hooks/vectors/index.cjs +19 -0
  417. package/dist/hooks/vectors/index.cjs.map +1 -0
  418. package/dist/hooks/vectors/index.d.ts +2 -0
  419. package/dist/hooks/vectors/index.d.ts.map +1 -0
  420. package/dist/hooks/vectors/index.js +18 -0
  421. package/dist/hooks/vectors/index.js.map +1 -0
  422. package/dist/hooks/vectors/use-vectors.d.ts +14 -0
  423. package/dist/hooks/vectors/use-vectors.d.ts.map +1 -0
  424. package/dist/hooks/voice/index.cjs +87 -0
  425. package/dist/hooks/voice/index.cjs.map +1 -0
  426. package/dist/hooks/voice/index.d.ts +2 -0
  427. package/dist/hooks/voice/index.d.ts.map +1 -0
  428. package/dist/hooks/voice/index.js +86 -0
  429. package/dist/hooks/voice/index.js.map +1 -0
  430. package/dist/hooks/voice/use-read-aloud.d.ts +20 -0
  431. package/dist/hooks/voice/use-read-aloud.d.ts.map +1 -0
  432. package/dist/hooks/workflows/index.cjs +173 -0
  433. package/dist/hooks/workflows/index.cjs.map +1 -0
  434. package/dist/hooks/workflows/index.d.ts +7 -0
  435. package/dist/hooks/workflows/index.d.ts.map +1 -0
  436. package/dist/hooks/workflows/index.js +157 -0
  437. package/dist/hooks/workflows/index.js.map +1 -0
  438. package/dist/hooks/workflows/use-workflow-runs.d.ts +51 -0
  439. package/dist/hooks/workflows/use-workflow-runs.d.ts.map +1 -0
  440. package/dist/hooks/workflows/use-workflow.d.ts +14 -0
  441. package/dist/hooks/workflows/use-workflow.d.ts.map +1 -0
  442. package/dist/hooks/workflows/use-workflows-run-counts.d.ts +25 -0
  443. package/dist/hooks/workflows/use-workflows-run-counts.d.ts.map +1 -0
  444. package/dist/hooks/workflows/use-workflows.d.ts +10 -0
  445. package/dist/hooks/workflows/use-workflows.d.ts.map +1 -0
  446. package/dist/hooks/workspace/client-utils.d.ts +5 -0
  447. package/dist/hooks/workspace/client-utils.d.ts.map +1 -0
  448. package/dist/hooks/workspace/compatibility.d.ts +22 -0
  449. package/dist/hooks/workspace/compatibility.d.ts.map +1 -0
  450. package/dist/hooks/workspace/file-type.d.ts +7 -0
  451. package/dist/hooks/workspace/file-type.d.ts.map +1 -0
  452. package/dist/hooks/workspace/index.cjs +624 -0
  453. package/dist/hooks/workspace/index.cjs.map +1 -0
  454. package/dist/hooks/workspace/index.d.ts +11 -0
  455. package/dist/hooks/workspace/index.d.ts.map +1 -0
  456. package/dist/hooks/workspace/index.js +594 -0
  457. package/dist/hooks/workspace/index.js.map +1 -0
  458. package/dist/hooks/workspace/types.d.ts +199 -0
  459. package/dist/hooks/workspace/types.d.ts.map +1 -0
  460. package/dist/hooks/workspace/use-skills-sh.d.ts +104 -0
  461. package/dist/hooks/workspace/use-skills-sh.d.ts.map +1 -0
  462. package/dist/hooks/workspace/use-stored-workspaces.d.ts +12 -0
  463. package/dist/hooks/workspace/use-stored-workspaces.d.ts.map +1 -0
  464. package/dist/hooks/workspace/use-workspace-directory.d.ts +13 -0
  465. package/dist/hooks/workspace/use-workspace-directory.d.ts.map +1 -0
  466. package/dist/hooks/workspace/use-workspace-file-content.d.ts +15 -0
  467. package/dist/hooks/workspace/use-workspace-file-content.d.ts.map +1 -0
  468. package/dist/hooks/workspace/use-workspace-search.d.ts +20 -0
  469. package/dist/hooks/workspace/use-workspace-search.d.ts.map +1 -0
  470. package/dist/hooks/workspace/use-workspace-skills.d.ts +23 -0
  471. package/dist/hooks/workspace/use-workspace-skills.d.ts.map +1 -0
  472. package/dist/hooks/workspace/use-workspace.d.ts +56 -0
  473. package/dist/hooks/workspace/use-workspace.d.ts.map +1 -0
  474. package/dist/hooks-BFQK_s4g.js +1231 -0
  475. package/dist/hooks-BFQK_s4g.js.map +1 -0
  476. package/dist/hooks-CMjizg6y.cjs +1248 -0
  477. package/dist/hooks-CMjizg6y.cjs.map +1 -0
  478. package/dist/hooks-CjULNHpJ.js +252 -0
  479. package/dist/hooks-CjULNHpJ.js.map +1 -0
  480. package/dist/hooks-DsDYaJ3T.cjs +269 -0
  481. package/dist/hooks-DsDYaJ3T.cjs.map +1 -0
  482. package/dist/index.cjs +21 -3434
  483. package/dist/index.cjs.map +1 -1
  484. package/dist/index.d.ts +1 -0
  485. package/dist/index.d.ts.map +1 -1
  486. package/dist/index.js +6 -3419
  487. package/dist/index.js.map +1 -1
  488. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +3 -4
  489. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -1
  490. package/dist/map-CDv4fbu4.js +12 -0
  491. package/dist/map-CDv4fbu4.js.map +1 -0
  492. package/dist/map-wjmL1y5O.cjs +17 -0
  493. package/dist/map-wjmL1y5O.cjs.map +1 -0
  494. package/dist/mastra-client-context-Bx_g84YB.js +50 -0
  495. package/dist/mastra-client-context-Bx_g84YB.js.map +1 -0
  496. package/dist/mastra-client-context-DzX3f0RF.cjs +61 -0
  497. package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -0
  498. package/dist/query-utils-CcrChYgz.cjs +174 -0
  499. package/dist/query-utils-CcrChYgz.cjs.map +1 -0
  500. package/dist/query-utils-D1NgFnWU.js +127 -0
  501. package/dist/query-utils-D1NgFnWU.js.map +1 -0
  502. package/dist/use-in-view-B6eJO9Zi.cjs +37 -0
  503. package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -0
  504. package/dist/use-in-view-C9sYPGRm.js +32 -0
  505. package/dist/use-in-view-C9sYPGRm.js.map +1 -0
  506. package/dist/voice-BOtUdMi8.cjs +281 -0
  507. package/dist/voice-BOtUdMi8.cjs.map +1 -0
  508. package/dist/voice-DgirjEyH.js +264 -0
  509. package/dist/voice-DgirjEyH.js.map +1 -0
  510. package/package.json +32 -3
@@ -0,0 +1,1168 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
3
+ const require_use_in_view = require("../../use-in-view-B6eJO9Zi.cjs");
4
+ const require_query_utils = require("../../query-utils-CcrChYgz.cjs");
5
+ const require_map = require("../../map-wjmL1y5O.cjs");
6
+ const require_feedback_refetch_interval = require("../../feedback-refetch-interval-XD5FVc2k.cjs");
7
+ let _mastra_client_js = require("@mastra/client-js");
8
+ let react = require("react");
9
+ let _tanstack_react_query = require("@tanstack/react-query");
10
+ let _mastra_core_observability = require("@mastra/core/observability");
11
+ //#region src/hooks/traces/discovery-cache.ts
12
+ /**
13
+ * How long discovery results (tags, environments, service names, entity
14
+ * names) stay fresh on the client.
15
+ *
16
+ * Discovery values are filter suggestions that change slowly, and the server
17
+ * caches them for 5 minutes anyway. Without a staleTime, React Query refetches
18
+ * on every mount and window focus, which pushes those refetches straight
19
+ * through to the store's discovery refresh. Matching the server TTL keeps the
20
+ * client from asking more often than the answer can change.
21
+ */
22
+ const DISCOVERY_STALE_TIME = 300 * 1e3;
23
+ //#endregion
24
+ //#region src/hooks/traces/use-branch.ts
25
+ /**
26
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
27
+ */
28
+ function useBranch({ traceId, spanId, depth, queryOptions }) {
29
+ const client = require_mastra_client_context.useMastraClient();
30
+ return (0, _tanstack_react_query.useQuery)({
31
+ queryKey: [
32
+ "branch",
33
+ traceId,
34
+ spanId,
35
+ depth
36
+ ],
37
+ queryFn: async () => {
38
+ if (!traceId || !spanId) throw new Error("traceId and spanId are required");
39
+ return client.getBranch({
40
+ traceId,
41
+ spanId,
42
+ depth
43
+ });
44
+ },
45
+ staleTime: 0,
46
+ ...queryOptions
47
+ });
48
+ }
49
+ //#endregion
50
+ //#region src/hooks/traces/types.ts
51
+ const ROOT_ENTITY_TYPES = {
52
+ AGENT: "agent",
53
+ WORKFLOW: "workflow_run",
54
+ SCORER: "scorer",
55
+ INGEST: "rag_ingestion"
56
+ };
57
+ //#endregion
58
+ //#region src/hooks/traces/use-entity-names.ts
59
+ function resolveEntityType(entityType) {
60
+ return Object.values(_mastra_core_observability.EntityType).find((candidate) => candidate === entityType);
61
+ }
62
+ const useEntityNames = ({ entityType, rootOnly = false, queryOptions } = {}) => {
63
+ const client = require_mastra_client_context.useMastraClient();
64
+ return (0, _tanstack_react_query.useQuery)({
65
+ queryKey: entityType ? [
66
+ "observability-entity-names",
67
+ "by-type",
68
+ entityType
69
+ ] : [
70
+ "observability-entity-names",
71
+ "all",
72
+ rootOnly ? "root-only" : "all-types"
73
+ ],
74
+ queryFn: async () => {
75
+ try {
76
+ if (entityType) {
77
+ const resolvedEntityType = resolveEntityType(entityType);
78
+ if (!resolvedEntityType) return { names: [] };
79
+ return await client.getEntityNames({ entityType: resolvedEntityType });
80
+ }
81
+ if (!rootOnly) return await client.getEntityNames();
82
+ const responses = await Promise.all(Object.values(ROOT_ENTITY_TYPES).map((rootEntityType) => {
83
+ const resolvedEntityType = resolveEntityType(rootEntityType);
84
+ if (!resolvedEntityType) return { names: [] };
85
+ return client.getEntityNames({ entityType: resolvedEntityType });
86
+ }));
87
+ return { names: Array.from(new Set(responses.flatMap((response) => response?.names ?? []))).sort() };
88
+ } catch {
89
+ return { names: [] };
90
+ }
91
+ },
92
+ select: (data) => data?.names ?? [],
93
+ retry: false,
94
+ staleTime: DISCOVERY_STALE_TIME,
95
+ ...queryOptions
96
+ });
97
+ };
98
+ //#endregion
99
+ //#region src/hooks/traces/use-environments.ts
100
+ const useEnvironments = ({ queryOptions } = {}) => {
101
+ const client = require_mastra_client_context.useMastraClient();
102
+ return (0, _tanstack_react_query.useQuery)({
103
+ queryKey: ["observability-environments"],
104
+ queryFn: async () => {
105
+ try {
106
+ return await client.getEnvironments();
107
+ } catch {
108
+ return { environments: [] };
109
+ }
110
+ },
111
+ select: (data) => data?.environments ?? [],
112
+ retry: false,
113
+ staleTime: DISCOVERY_STALE_TIME,
114
+ ...queryOptions
115
+ });
116
+ };
117
+ //#endregion
118
+ //#region src/hooks/traces/use-service-names.ts
119
+ const useServiceNames = ({ queryOptions } = {}) => {
120
+ const client = require_mastra_client_context.useMastraClient();
121
+ return (0, _tanstack_react_query.useQuery)({
122
+ queryKey: ["observability-service-names"],
123
+ queryFn: async () => {
124
+ try {
125
+ return await client.getServiceNames();
126
+ } catch {
127
+ return { serviceNames: [] };
128
+ }
129
+ },
130
+ select: (data) => data?.serviceNames ?? [],
131
+ retry: false,
132
+ staleTime: DISCOVERY_STALE_TIME,
133
+ ...queryOptions
134
+ });
135
+ };
136
+ //#endregion
137
+ //#region src/hooks/traces/use-span-detail.ts
138
+ const IMMUTABLE_CACHE_TIME$1 = 1e3 * 60 * 60 * 24 * 30;
139
+ /**
140
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
141
+ */
142
+ function useSpanDetail({ traceId, spanId, queryOptions }) {
143
+ const client = require_mastra_client_context.useMastraClient();
144
+ return (0, _tanstack_react_query.useQuery)({
145
+ queryKey: [
146
+ "span-detail",
147
+ traceId,
148
+ spanId
149
+ ],
150
+ queryFn: async () => {
151
+ if (!traceId || !spanId) throw new Error("Trace ID and Span ID are required");
152
+ return client.getSpan(traceId, spanId);
153
+ },
154
+ staleTime: (query) => {
155
+ if (query.state.data?.span?.endedAt) return IMMUTABLE_CACHE_TIME$1;
156
+ return 0;
157
+ },
158
+ ...queryOptions
159
+ });
160
+ }
161
+ //#endregion
162
+ //#region src/hooks/traces/use-tags.ts
163
+ const useTags = ({ queryOptions } = {}) => {
164
+ const client = require_mastra_client_context.useMastraClient();
165
+ return (0, _tanstack_react_query.useQuery)({
166
+ queryKey: ["observability-tags"],
167
+ queryFn: async () => {
168
+ try {
169
+ return await client.getTags();
170
+ } catch {
171
+ return { tags: [] };
172
+ }
173
+ },
174
+ select: (data) => data?.tags ?? [],
175
+ retry: false,
176
+ staleTime: DISCOVERY_STALE_TIME,
177
+ ...queryOptions
178
+ });
179
+ };
180
+ //#endregion
181
+ //#region src/hooks/traces/use-thread-has-other-traces.ts
182
+ /**
183
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
184
+ */
185
+ function useThreadHasOtherTraces({ threadId, queryOptions }) {
186
+ const client = require_mastra_client_context.useMastraClient();
187
+ const { data } = (0, _tanstack_react_query.useQuery)({
188
+ queryKey: ["thread-trace-count", threadId],
189
+ queryFn: () => client.listTracesLight({
190
+ filters: { threadId: threadId ?? "" },
191
+ pagination: {
192
+ page: 0,
193
+ perPage: 25
194
+ }
195
+ }),
196
+ select: (response) => (response.spans?.length ?? 0) > 1,
197
+ ...queryOptions
198
+ });
199
+ return data ?? false;
200
+ }
201
+ //#endregion
202
+ //#region src/hooks/traces/use-trace-light-spans.ts
203
+ const IMMUTABLE_CACHE_TIME = 1e3 * 60 * 60 * 24 * 30;
204
+ /**
205
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
206
+ */
207
+ function useTraceLightSpans({ traceId, queryOptions }) {
208
+ const client = require_mastra_client_context.useMastraClient();
209
+ return (0, _tanstack_react_query.useQuery)({
210
+ queryKey: ["trace-light-spans", traceId],
211
+ queryFn: async () => {
212
+ if (!traceId) throw new Error("Trace ID is required");
213
+ return await client.getTraceLight(traceId);
214
+ },
215
+ staleTime: (query) => {
216
+ if (query.state.data?.spans.every((d) => Boolean(d.endedAt))) return IMMUTABLE_CACHE_TIME;
217
+ return 0;
218
+ },
219
+ ...queryOptions
220
+ });
221
+ }
222
+ //#endregion
223
+ //#region src/hooks/traces/use-trace-spans.ts
224
+ const traceSpansQueryOptions = (client, traceId) => (0, _tanstack_react_query.queryOptions)({
225
+ queryKey: ["trace-spans", traceId],
226
+ queryFn: async () => {
227
+ if (!traceId) throw new Error("Trace ID is required");
228
+ return await client.getTrace(traceId);
229
+ },
230
+ staleTime: 0
231
+ });
232
+ /**
233
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
234
+ */
235
+ function useTraceSpans({ traceId, passive = false, queryOptions }) {
236
+ const client = require_mastra_client_context.useMastraClient();
237
+ const { queryKey, queryFn, enabled, staleTime } = traceSpansQueryOptions(client, traceId);
238
+ return (0, _tanstack_react_query.useQuery)({
239
+ queryKey,
240
+ queryFn,
241
+ enabled,
242
+ staleTime,
243
+ refetchOnMount: !passive,
244
+ refetchOnWindowFocus: !passive,
245
+ refetchOnReconnect: !passive,
246
+ ...queryOptions
247
+ });
248
+ }
249
+ /**
250
+ * Returns a function that loads a full trace through the shared `trace-spans` cache, so an
251
+ * imperative read (e.g. an export) and the trace panel always see the same payload.
252
+ */
253
+ function useFetchTraceSpans() {
254
+ const client = require_mastra_client_context.useMastraClient();
255
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
256
+ return (traceId) => queryClient.fetchQuery(traceSpansQueryOptions(client, traceId));
257
+ }
258
+ /**
259
+ * Observes the `trace-spans` query of several traces at once and projects each one with `select`.
260
+ * Traces still loading (or failed) yield `fallback(traceId)` so the result always lines up with `traceIds`.
261
+ */
262
+ function useTraceSpansQueries({ traceIds, select, fallback, queryOptions }) {
263
+ const client = require_mastra_client_context.useMastraClient();
264
+ return (0, _tanstack_react_query.useQueries)({
265
+ queries: traceIds.map((traceId) => ({
266
+ ...traceSpansQueryOptions(client, traceId),
267
+ refetchOnMount: false,
268
+ refetchOnWindowFocus: false,
269
+ refetchOnReconnect: false,
270
+ select: (data) => select(traceId, data),
271
+ ...queryOptions
272
+ })),
273
+ combine: (results) => results.map((result, index) => result.data === void 0 ? fallback(traceIds[index] ?? "") : result.data)
274
+ });
275
+ }
276
+ //#endregion
277
+ //#region src/hooks/traces/use-trace-or-branch-spans.ts
278
+ /**
279
+ * Unified data source for the trace/span detail panel. Returns trace spans (full tree from the
280
+ * root) in traces mode, or branch spans (subtree rooted at `anchorSpanId`) in branches mode.
281
+ * Only the active query fires; the inactive one is disabled via its `enabled` flag.
282
+ *
283
+ * Both modes carry full span payloads: the panel renders and searches them, so a lightweight
284
+ * projection here would hide content from the reader looking straight at it.
285
+ */
286
+ function useTraceOrBranchSpans({ traceId, anchorSpanId, listMode, depth, queryOptions }) {
287
+ const isBranches = listMode === "branches";
288
+ const traceQuery = useTraceSpans({
289
+ traceId: isBranches ? null : traceId,
290
+ queryOptions: {
291
+ enabled: !isBranches && !!traceId,
292
+ ...queryOptions?.trace
293
+ }
294
+ });
295
+ const branchQuery = useBranch({
296
+ traceId: isBranches ? traceId : null,
297
+ spanId: isBranches ? anchorSpanId : null,
298
+ depth,
299
+ queryOptions: {
300
+ enabled: isBranches && !!traceId && !!anchorSpanId,
301
+ ...queryOptions?.branch
302
+ }
303
+ });
304
+ if (isBranches) return {
305
+ spans: branchQuery.data?.spans,
306
+ anchorSpanId: anchorSpanId ?? void 0,
307
+ isLoading: branchQuery.isLoading,
308
+ isError: branchQuery.isError,
309
+ error: branchQuery.error
310
+ };
311
+ return {
312
+ spans: traceQuery.data?.spans,
313
+ anchorSpanId: void 0,
314
+ isLoading: traceQuery.isLoading,
315
+ isError: traceQuery.isError,
316
+ error: traceQuery.error
317
+ };
318
+ }
319
+ //#endregion
320
+ //#region src/hooks/traces/use-trace-query.ts
321
+ const TRACE_QUERY_PER_PAGE = 25;
322
+ function getTraceQueryNextPageParam(lastPage) {
323
+ return lastPage?.page.next ?? void 0;
324
+ }
325
+ function selectTraceQueryTraces(data) {
326
+ const seen = /* @__PURE__ */ new Set();
327
+ return data.pages.flatMap((page) => page.traces.filter((trace) => {
328
+ if (seen.has(trace.traceId)) return false;
329
+ seen.add(trace.traceId);
330
+ return true;
331
+ }));
332
+ }
333
+ const toIsoString = (value) => typeof value === "string" ? value : value.toISOString();
334
+ /** Maps a legacy light root span to a trace-query row. The light record carries no
335
+ * environment, so it stays null. Running spans have no `endedAt` and may carry a
336
+ * status outside the query API's enum; both are kept as-is (the list view handles them), hence the
337
+ * assertion at this compatibility boundary. */
338
+ function lightSpanToTraceQueryTrace(span) {
339
+ return {
340
+ traceId: span.traceId,
341
+ rootSpanId: span.spanId,
342
+ name: span.name,
343
+ entityId: span.entityId ?? null,
344
+ parentSpanId: span.parentSpanId ?? null,
345
+ createdAt: toIsoString(span.createdAt),
346
+ metadata: span.metadata ?? null,
347
+ inputPreview: span.inputPreview ?? null,
348
+ threadId: span.threadId ?? null,
349
+ resourceId: span.resourceId ?? null,
350
+ startedAt: toIsoString(span.startedAt),
351
+ endedAt: span.endedAt == null ? span.endedAt : toIsoString(span.endedAt),
352
+ entityName: span.entityName ?? null,
353
+ entityType: span.entityType ?? null,
354
+ environment: null,
355
+ status: span.status
356
+ };
357
+ }
358
+ function selectLegacyTraceQueryTraces(data) {
359
+ const seen = /* @__PURE__ */ new Set();
360
+ return data.pages.flatMap((page) => page.spans.flatMap((span) => {
361
+ if (seen.has(span.traceId)) return [];
362
+ seen.add(span.traceId);
363
+ return [lightSpanToTraceQueryTrace(span)];
364
+ }));
365
+ }
366
+ function getLegacyTraceQueryNextPageParam(lastPage) {
367
+ return lastPage.pagination?.hasMore ? lastPage.pagination.page + 1 : void 0;
368
+ }
369
+ /** Queries traces with cursor pagination and viewport-driven loading. */
370
+ function useTraceQuery({ query, limit = 25, enabled = true, withQueryTrace = true, legacyFilters, queryOptions }) {
371
+ const client = require_mastra_client_context.useMastraClient();
372
+ const { inView, setRef: setEndOfListElement } = require_use_in_view.useInView();
373
+ const queryResult = (0, _tanstack_react_query.useInfiniteQuery)({
374
+ queryKey: [
375
+ "trace-query",
376
+ query,
377
+ limit
378
+ ],
379
+ queryFn: query ? async ({ pageParam }) => {
380
+ const response = await new _mastra_client_js.MastraClient({
381
+ ...client.options,
382
+ retries: 0
383
+ }).queryTraces({
384
+ ...query,
385
+ page: {
386
+ limit,
387
+ after: pageParam ?? null
388
+ }
389
+ });
390
+ if ("traces" in response && "page" in response) return response;
391
+ throw new Error("Expected a cursor-paginated trace query response");
392
+ } : _tanstack_react_query.skipToken,
393
+ initialPageParam: void 0,
394
+ getNextPageParam: getTraceQueryNextPageParam,
395
+ select: selectTraceQueryTraces,
396
+ retry: false,
397
+ placeholderData: _tanstack_react_query.keepPreviousData,
398
+ enabled: enabled && withQueryTrace,
399
+ ...queryOptions?.traceQuery
400
+ });
401
+ const orderBy = query?.orderBy;
402
+ const legacyDirection = orderBy?.[0]?.direction === "asc" ? "ASC" : "DESC";
403
+ const legacyResult = (0, _tanstack_react_query.useInfiniteQuery)({
404
+ queryKey: [
405
+ "trace-query-legacy",
406
+ legacyFilters,
407
+ limit,
408
+ orderBy
409
+ ],
410
+ queryFn: ({ pageParam }) => client.listTracesLight({
411
+ filters: legacyFilters,
412
+ pagination: {
413
+ page: pageParam,
414
+ perPage: limit
415
+ },
416
+ orderBy: {
417
+ field: "startedAt",
418
+ direction: legacyDirection
419
+ }
420
+ }),
421
+ initialPageParam: 0,
422
+ getNextPageParam: getLegacyTraceQueryNextPageParam,
423
+ select: selectLegacyTraceQueryTraces,
424
+ retry: false,
425
+ placeholderData: _tanstack_react_query.keepPreviousData,
426
+ enabled: enabled && !withQueryTrace,
427
+ ...queryOptions?.legacy
428
+ });
429
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isPlaceholderData, isFetching, isRefetching, fetchStatus, isError, error, refetch, isFetchNextPageError } = withQueryTrace ? queryResult : legacyResult;
430
+ (0, react.useEffect)(() => {
431
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
432
+ }, [
433
+ enabled,
434
+ inView,
435
+ hasNextPage,
436
+ isFetching,
437
+ isFetchNextPageError,
438
+ fetchNextPage
439
+ ]);
440
+ return {
441
+ data,
442
+ hasNextPage,
443
+ isFetchingNextPage,
444
+ fetchNextPage,
445
+ isLoading,
446
+ isPlaceholderData,
447
+ isFetching,
448
+ isRefetching,
449
+ fetchStatus,
450
+ isError,
451
+ error,
452
+ refetch,
453
+ setEndOfListElement
454
+ };
455
+ }
456
+ //#endregion
457
+ //#region src/hooks/traces/use-trace-usage.ts
458
+ const INPUT_TOKEN_METRIC = "mastra_model_total_input_tokens";
459
+ const OUTPUT_TOKEN_METRIC = "mastra_model_total_output_tokens";
460
+ const TRACE_IDS_PER_REQUEST = 500;
461
+ function chunkTraceIds(traceIds) {
462
+ const chunks = [];
463
+ for (let index = 0; index < traceIds.length; index += TRACE_IDS_PER_REQUEST) chunks.push(traceIds.slice(index, index + TRACE_IDS_PER_REQUEST));
464
+ return chunks;
465
+ }
466
+ function createTraceUsageAccumulator() {
467
+ return {
468
+ estimatedCost: 0,
469
+ hasEstimatedCost: false,
470
+ costUnits: /* @__PURE__ */ new Set(),
471
+ hasUnknownCostUnit: false
472
+ };
473
+ }
474
+ function addBreakdown(accumulators, response) {
475
+ for (const group of response.groups) {
476
+ const traceId = group.dimensions.traceId;
477
+ const metricName = group.dimensions.name;
478
+ if (!traceId || metricName !== INPUT_TOKEN_METRIC && metricName !== OUTPUT_TOKEN_METRIC) continue;
479
+ const accumulator = require_map.getOrCreate(accumulators, traceId, createTraceUsageAccumulator);
480
+ const tokenField = metricName === INPUT_TOKEN_METRIC ? "inputTokens" : "outputTokens";
481
+ accumulator[tokenField] = (accumulator[tokenField] ?? 0) + group.value;
482
+ if (group.estimatedCost == null) continue;
483
+ accumulator.estimatedCost += group.estimatedCost;
484
+ accumulator.hasEstimatedCost = true;
485
+ if (group.costUnit) accumulator.costUnits.add(group.costUnit.toLowerCase());
486
+ else accumulator.hasUnknownCostUnit = true;
487
+ }
488
+ }
489
+ function summarizeUsage(accumulators) {
490
+ const summaries = /* @__PURE__ */ new Map();
491
+ for (const [traceId, accumulator] of accumulators) {
492
+ const summary = {
493
+ inputTokens: accumulator.inputTokens,
494
+ outputTokens: accumulator.outputTokens
495
+ };
496
+ if (accumulator.hasEstimatedCost && !accumulator.hasUnknownCostUnit && accumulator.costUnits.size === 1) {
497
+ summary.estimatedCost = accumulator.estimatedCost;
498
+ summary.costUnit = [...accumulator.costUnits][0];
499
+ }
500
+ summaries.set(traceId, summary);
501
+ }
502
+ return summaries;
503
+ }
504
+ function useTraceUsage({ traceIds, enabled, autoRefetch, queryOptions }) {
505
+ const client = require_mastra_client_context.useMastraClient();
506
+ const uniqueTraceIds = [...new Set(traceIds)].toSorted();
507
+ const projectKey = `${client.options.baseUrl || (typeof window === "undefined" ? "local" : window.location.origin || "local")}:${client.options.apiPrefix ?? "/api"}`;
508
+ return (0, _tanstack_react_query.useQuery)({
509
+ queryKey: [
510
+ "trace-usage",
511
+ projectKey,
512
+ uniqueTraceIds
513
+ ],
514
+ enabled: enabled && uniqueTraceIds.length > 0,
515
+ queryFn: async () => {
516
+ const batches = chunkTraceIds(uniqueTraceIds);
517
+ const responses = await Promise.allSettled(batches.map((batch) => client.getMetricBreakdown({
518
+ name: [INPUT_TOKEN_METRIC, OUTPUT_TOKEN_METRIC],
519
+ aggregation: "sum",
520
+ groupBy: ["traceId", "name"],
521
+ filters: { traceIds: batch },
522
+ limit: batch.length * 2
523
+ })));
524
+ const accumulators = /* @__PURE__ */ new Map();
525
+ for (const response of responses) if (response.status === "fulfilled") addBreakdown(accumulators, response.value);
526
+ return summarizeUsage(accumulators);
527
+ },
528
+ placeholderData: (previousData, previousQuery) => previousQuery?.queryKey[1] === projectKey ? previousData : void 0,
529
+ refetchInterval: enabled && autoRefetch ? 1e4 : false,
530
+ ...queryOptions
531
+ });
532
+ }
533
+ //#endregion
534
+ //#region src/hooks/traces/use-traces.tsx
535
+ const deltaSupportByClient = /* @__PURE__ */ new WeakMap();
536
+ const lightListSupportByClient = /* @__PURE__ */ new WeakMap();
537
+ /** When the current run of light-endpoint 500s started, per client. Cleared by any light success. */
538
+ const lightListFirstServerErrorAtByClient = /* @__PURE__ */ new WeakMap();
539
+ /** A 500 is ambiguous — an old core's store throwing, or a transient fault (DB hiccup, timeout).
540
+ * Serve the request from the full endpoint either way, but only pin the session once the 500s
541
+ * have outlasted a blip; a hiccup would otherwise degrade the list until the tab is reloaded.
542
+ * Elapsed time, not a request count: the page refetch, the delta poll and the status refresh can
543
+ * fail in the same instant, and a fallback response still looks like a success to the delta query,
544
+ * so chase mode keeps re-polling every `deltaChaseIntervalMs` throughout the outage. */
545
+ const LIGHT_LIST_SERVER_ERROR_PIN_AFTER_MS = 1e4;
546
+ const DEFAULT_POLLING_CONFIG = {
547
+ deltaPollIntervalMs: 5e3,
548
+ deltaChaseIntervalMs: 100,
549
+ deltaLimit: 100,
550
+ pageModeRefetchIntervalMs: 1e4,
551
+ page0StatusRefreshIntervalMs: 6e4,
552
+ idleGuardThresholdMs: 15 * 6e4,
553
+ minRefetchSpinMs: 400,
554
+ deltaHighlightMs: 1e3
555
+ };
556
+ /** Returns true when the cursor should be considered stale and re-seeded.
557
+ * Exported for testing — pure function of timestamps. */
558
+ function shouldResetAfterIdle(lastSuccessAt, now, thresholdMs) {
559
+ if (lastSuccessAt === 0) return false;
560
+ return now - lastSuccessAt > thresholdMs;
561
+ }
562
+ function isHttp501(error) {
563
+ return error?.status === 501;
564
+ }
565
+ /** Only 404 and 500 can mean the light endpoint isn't served: 404 from servers without
566
+ * the route, 500 from cores whose store throws instead of serving the projection.
567
+ * Anything else (401, 403, 429, other 5xx, the 501 disabled-domain signal) is a
568
+ * condition the full endpoint would hit too, so it propagates instead of falling
569
+ * back — mirroring how the delta-support cache matches exactly 501. */
570
+ function lightListFallbackStatus(error) {
571
+ const status = error?.status;
572
+ return status === 404 || status === 500 ? status : void 0;
573
+ }
574
+ /** Whether a failed light-list request should pin the session to the full endpoint.
575
+ * `firstServerErrorAt` is undefined when this 500 opens a new run of them, so a single
576
+ * fault never pins. Exported for testing — pure function of the status and timestamps. */
577
+ function shouldPinLightList(status, firstServerErrorAt, now) {
578
+ if (status === 404) return true;
579
+ if (status !== 500) return false;
580
+ if (firstServerErrorAt === void 0) return false;
581
+ return now - firstServerErrorAt >= LIGHT_LIST_SERVER_ERROR_PIN_AFTER_MS;
582
+ }
583
+ const fetchTracesFn = async (args) => {
584
+ const { client, filters, listMode = "traces" } = args;
585
+ const params = args.mode === "delta" ? {
586
+ mode: "delta",
587
+ after: args.after,
588
+ limit: args.limit,
589
+ filters
590
+ } : {
591
+ pagination: {
592
+ page: args.page,
593
+ perPage: args.perPage
594
+ },
595
+ filters
596
+ };
597
+ if (listMode === "branches") return client.listBranches(params);
598
+ if (lightListSupportByClient.get(client) === "unsupported") return client.listTraces(params);
599
+ try {
600
+ const response = await client.listTracesLight(params);
601
+ if (args.mode !== "delta") {
602
+ const spans = response.spans ?? [];
603
+ if (spans.length > 0 && spans.every((span) => span.status === void 0)) {
604
+ lightListSupportByClient.set(client, "unsupported");
605
+ return client.listTraces(params);
606
+ }
607
+ }
608
+ lightListFirstServerErrorAtByClient.delete(client);
609
+ return response;
610
+ } catch (error) {
611
+ const status = lightListFallbackStatus(error);
612
+ if (status === void 0) throw error;
613
+ const now = Date.now();
614
+ const firstServerErrorAt = lightListFirstServerErrorAtByClient.get(client);
615
+ if (status === 500 && firstServerErrorAt === void 0) lightListFirstServerErrorAtByClient.set(client, now);
616
+ if (shouldPinLightList(status, firstServerErrorAt, now)) lightListSupportByClient.set(client, "unsupported");
617
+ return client.listTraces(params);
618
+ }
619
+ };
620
+ const TRACES_PER_PAGE = 25;
621
+ /** Returns the next page number if the server indicates more pages are available. */
622
+ function getTracesNextPageParam(lastPage, _allPages, lastPageParam) {
623
+ if (lastPage?.pagination?.hasMore) return lastPageParam + 1;
624
+ }
625
+ /** Branch rows are full spans and trace rows are lightweight; the list only reads the
626
+ * fields they share, so both are surfaced as `LightSpanRecord`. */
627
+ function getPageSpans(page) {
628
+ if ("branches" in page) return page.branches ?? [];
629
+ return page.spans ?? [];
630
+ }
631
+ /** Deduplicates trace/branch rows by traceId + spanId across all loaded pages.
632
+ * Also surfaces page 0's deltaCursor so the live-tail query can read it reactively. */
633
+ function selectUniqueTraces(data) {
634
+ const seen = /* @__PURE__ */ new Set();
635
+ return {
636
+ spans: data.pages.flatMap((page) => getPageSpans(page)).filter((span) => {
637
+ const key = `${span.traceId}:${span.spanId}`;
638
+ if (seen.has(key)) return false;
639
+ seen.add(key);
640
+ return true;
641
+ }),
642
+ deltaCursor: data.pages[0]?.deltaCursor
643
+ };
644
+ }
645
+ function rowKey(row) {
646
+ return `${row.traceId}:${row.spanId}`;
647
+ }
648
+ function indexRowsByKey(rows) {
649
+ return new Map(rows.map((row) => [rowKey(row), row]));
650
+ }
651
+ /** Replaces existing page-0 rows in place (keyed by traceId:spanId) with
652
+ * refreshed copies from the server. Rows the server doesn't return are kept
653
+ * as-is so delta-accumulated rows that have aged off the server's page 0
654
+ * aren't dropped from the UI. New rows aren't added here — delta polling
655
+ * delivers those. */
656
+ function refreshPage0Rows(old, refreshed, listMode) {
657
+ if (!old || old.pages.length === 0) return old;
658
+ const [firstPage, ...rest] = old.pages;
659
+ if (!firstPage) return old;
660
+ let updatedFirst;
661
+ if (listMode === "branches" && "branches" in firstPage && "branches" in refreshed) {
662
+ const refreshedByKey = indexRowsByKey(refreshed.branches ?? []);
663
+ if (refreshedByKey.size === 0) return old;
664
+ updatedFirst = {
665
+ ...firstPage,
666
+ branches: (firstPage.branches ?? []).map((existing) => refreshedByKey.get(rowKey(existing)) ?? existing)
667
+ };
668
+ } else if ("spans" in firstPage && "spans" in refreshed) {
669
+ const refreshedByKey = indexRowsByKey(refreshed.spans ?? []);
670
+ if (refreshedByKey.size === 0) return old;
671
+ updatedFirst = {
672
+ ...firstPage,
673
+ spans: (firstPage.spans ?? []).map((existing) => refreshedByKey.get(rowKey(existing)) ?? existing)
674
+ };
675
+ } else return old;
676
+ return {
677
+ ...old,
678
+ pages: [updatedFirst, ...rest]
679
+ };
680
+ }
681
+ /** Stable `startedAt DESC` sort matching the server's default page-mode
682
+ * ordering for both list endpoints. Rows missing `startedAt` sink to the
683
+ * bottom (compared as time 0). */
684
+ function sortRowsByStartedAtDesc(rows) {
685
+ return [...rows].sort((a, b) => {
686
+ const aTime = a.startedAt ? new Date(a.startedAt).getTime() : 0;
687
+ return (b.startedAt ? new Date(b.startedAt).getTime() : 0) - aTime;
688
+ });
689
+ }
690
+ /** Prepends delta-mode rows into page 0 and advances its deltaCursor.
691
+ * Delta responses come back in server cursor order (insertion order into
692
+ * the per-store delta index), not the `startedAt DESC` order page-mode
693
+ * uses — so we re-sort the merged page 0 to match what the user sees on
694
+ * a fresh page-mode load. Cross-page duplication is handled later by
695
+ * selectUniqueTraces. */
696
+ function mergeDeltaIntoPage0(old, delta, listMode) {
697
+ if (!old || old.pages.length === 0) return old;
698
+ const [firstPage, ...rest] = old.pages;
699
+ if (!firstPage) return old;
700
+ const nextCursor = delta.deltaCursor ?? firstPage.deltaCursor;
701
+ let updatedFirst;
702
+ if (listMode === "branches" && "branches" in firstPage) {
703
+ const newRows = delta.branches ?? [];
704
+ updatedFirst = {
705
+ ...firstPage,
706
+ branches: sortRowsByStartedAtDesc([...newRows, ...firstPage.branches ?? []]),
707
+ deltaCursor: nextCursor
708
+ };
709
+ } else if ("spans" in firstPage) {
710
+ const newRows = delta.spans ?? [];
711
+ updatedFirst = {
712
+ ...firstPage,
713
+ spans: sortRowsByStartedAtDesc([...newRows, ...firstPage.spans ?? []]),
714
+ deltaCursor: nextCursor
715
+ };
716
+ } else return old;
717
+ return {
718
+ ...old,
719
+ pages: [updatedFirst, ...rest]
720
+ };
721
+ }
722
+ const useTraces = ({ filters, listMode = "traces", polling = {}, enabled = true, queryOptions }) => {
723
+ const { deltaPollIntervalMs = DEFAULT_POLLING_CONFIG.deltaPollIntervalMs, deltaChaseIntervalMs = DEFAULT_POLLING_CONFIG.deltaChaseIntervalMs, deltaLimit = DEFAULT_POLLING_CONFIG.deltaLimit, pageModeRefetchIntervalMs = DEFAULT_POLLING_CONFIG.pageModeRefetchIntervalMs, page0StatusRefreshIntervalMs = DEFAULT_POLLING_CONFIG.page0StatusRefreshIntervalMs, idleGuardThresholdMs = DEFAULT_POLLING_CONFIG.idleGuardThresholdMs, minRefetchSpinMs = DEFAULT_POLLING_CONFIG.minRefetchSpinMs, deltaHighlightMs = DEFAULT_POLLING_CONFIG.deltaHighlightMs } = polling;
724
+ const client = require_mastra_client_context.useMastraClient();
725
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
726
+ const { inView: isEndOfListInView, setRef: setEndOfListElement } = require_use_in_view.useInView();
727
+ const [deltaSupport, setDeltaSupport] = (0, react.useState)(() => deltaSupportByClient.get(client) ?? "unknown");
728
+ const deltaUnsupported = deltaSupport === "unsupported";
729
+ const [autoRefetch, setAutoRefetch] = (0, react.useState)(true);
730
+ const [recentlyAddedKeys, setRecentlyAddedKeys] = (0, react.useState)(() => /* @__PURE__ */ new Set());
731
+ (0, react.useEffect)(() => {
732
+ setRecentlyAddedKeys(/* @__PURE__ */ new Set());
733
+ }, [listMode, filters]);
734
+ const tracesQueryKey = [
735
+ "traces",
736
+ listMode,
737
+ filters
738
+ ];
739
+ const query = (0, _tanstack_react_query.useInfiniteQuery)({
740
+ queryKey: tracesQueryKey,
741
+ enabled,
742
+ queryFn: ({ pageParam }) => fetchTracesFn({
743
+ client,
744
+ page: pageParam,
745
+ perPage: 25,
746
+ filters,
747
+ listMode
748
+ }),
749
+ initialPageParam: 0,
750
+ getNextPageParam: getTracesNextPageParam,
751
+ select: selectUniqueTraces,
752
+ retry: false,
753
+ refetchInterval: (q) => {
754
+ if (require_query_utils.is403ForbiddenError(q.state.error)) return false;
755
+ if (!autoRefetch) return false;
756
+ return deltaUnsupported ? pageModeRefetchIntervalMs : false;
757
+ },
758
+ ...queryOptions?.traces
759
+ });
760
+ const cursor = query.data?.deltaCursor;
761
+ (0, react.useEffect)(() => {
762
+ if (query.isSuccess && cursor === void 0 && deltaSupport === "unknown") {
763
+ deltaSupportByClient.set(client, "unsupported");
764
+ setDeltaSupport("unsupported");
765
+ }
766
+ }, [
767
+ query.isSuccess,
768
+ cursor,
769
+ deltaSupport,
770
+ client
771
+ ]);
772
+ const deltaQuery = (0, _tanstack_react_query.useQuery)({
773
+ queryKey: [
774
+ "traces-delta",
775
+ listMode,
776
+ filters
777
+ ],
778
+ queryFn: () => {
779
+ const current = queryClient.getQueryData(tracesQueryKey)?.pages[0]?.deltaCursor;
780
+ if (!current) return null;
781
+ return fetchTracesFn({
782
+ client,
783
+ mode: "delta",
784
+ after: current,
785
+ limit: deltaLimit,
786
+ filters,
787
+ listMode
788
+ });
789
+ },
790
+ enabled: enabled && !!cursor && !deltaUnsupported && autoRefetch,
791
+ retry: false,
792
+ refetchInterval: (q) => {
793
+ if (q.state.error) return false;
794
+ if (q.state.data?.delta?.hasMore) return deltaChaseIntervalMs;
795
+ return deltaPollIntervalMs;
796
+ },
797
+ ...queryOptions?.delta
798
+ });
799
+ (0, react.useEffect)(() => {
800
+ const result = deltaQuery.data;
801
+ if (!result) return;
802
+ queryClient.setQueryData(tracesQueryKey, (old) => mergeDeltaIntoPage0(old, result, listMode));
803
+ const newRows = listMode === "branches" && "branches" in result ? result.branches ?? [] : "spans" in result ? result.spans ?? [] : [];
804
+ if (newRows.length === 0) return;
805
+ const keys = newRows.map((r) => `${r.traceId}:${r.spanId ?? ""}`);
806
+ setRecentlyAddedKeys((prev) => {
807
+ const next = new Set(prev);
808
+ for (const k of keys) next.add(k);
809
+ return next;
810
+ });
811
+ setTimeout(() => {
812
+ setRecentlyAddedKeys((prev) => {
813
+ const next = new Set(prev);
814
+ for (const k of keys) next.delete(k);
815
+ return next;
816
+ });
817
+ }, deltaHighlightMs);
818
+ }, [
819
+ deltaQuery.data,
820
+ queryClient,
821
+ listMode,
822
+ filters,
823
+ deltaHighlightMs
824
+ ]);
825
+ (0, react.useEffect)(() => {
826
+ if (isHttp501(deltaQuery.error)) {
827
+ deltaSupportByClient.set(client, "unsupported");
828
+ setDeltaSupport("unsupported");
829
+ }
830
+ }, [deltaQuery.error, client]);
831
+ const statusRefreshQuery = (0, _tanstack_react_query.useQuery)({
832
+ queryKey: [
833
+ "traces-status-refresh",
834
+ listMode,
835
+ filters
836
+ ],
837
+ queryFn: () => fetchTracesFn({
838
+ client,
839
+ page: 0,
840
+ perPage: 25,
841
+ filters,
842
+ listMode
843
+ }),
844
+ enabled: enabled && !!cursor && !deltaUnsupported && autoRefetch,
845
+ refetchInterval: page0StatusRefreshIntervalMs,
846
+ refetchOnMount: false,
847
+ retry: false,
848
+ ...queryOptions?.statusRefresh
849
+ });
850
+ (0, react.useEffect)(() => {
851
+ const result = statusRefreshQuery.data;
852
+ if (!result) return;
853
+ queryClient.setQueryData(tracesQueryKey, (old) => refreshPage0Rows(old, result, listMode));
854
+ }, [
855
+ statusRefreshQuery.data,
856
+ queryClient,
857
+ listMode,
858
+ filters
859
+ ]);
860
+ const lastSuccessAtRef = (0, react.useRef)(0);
861
+ (0, react.useEffect)(() => {
862
+ const ts = Math.max(query.dataUpdatedAt, deltaQuery.dataUpdatedAt, statusRefreshQuery.dataUpdatedAt);
863
+ if (ts > lastSuccessAtRef.current) lastSuccessAtRef.current = ts;
864
+ }, [
865
+ query.dataUpdatedAt,
866
+ deltaQuery.dataUpdatedAt,
867
+ statusRefreshQuery.dataUpdatedAt
868
+ ]);
869
+ const autoRefetchRef = (0, react.useRef)(autoRefetch);
870
+ (0, react.useEffect)(() => {
871
+ autoRefetchRef.current = enabled && autoRefetch;
872
+ }, [enabled, autoRefetch]);
873
+ (0, react.useEffect)(() => {
874
+ const handler = () => {
875
+ if (document.visibilityState !== "visible") return;
876
+ if (!autoRefetchRef.current) return;
877
+ if (!shouldResetAfterIdle(lastSuccessAtRef.current, Date.now(), idleGuardThresholdMs)) return;
878
+ queryClient.resetQueries({ queryKey: [
879
+ "traces",
880
+ listMode,
881
+ filters
882
+ ] });
883
+ };
884
+ document.addEventListener("visibilitychange", handler);
885
+ return () => document.removeEventListener("visibilitychange", handler);
886
+ }, [
887
+ queryClient,
888
+ listMode,
889
+ filters,
890
+ idleGuardThresholdMs
891
+ ]);
892
+ const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;
893
+ (0, react.useEffect)(() => {
894
+ if (enabled && isEndOfListInView && hasNextPage && !isFetchingNextPage) fetchNextPage();
895
+ }, [
896
+ enabled,
897
+ isEndOfListInView,
898
+ hasNextPage,
899
+ isFetchingNextPage,
900
+ fetchNextPage
901
+ ]);
902
+ const isFetchingAny = query.isFetching || statusRefreshQuery.isFetching || deltaQuery.isFetching;
903
+ const lastActivityAt = Math.max(query.dataUpdatedAt, query.errorUpdatedAt, deltaQuery.dataUpdatedAt, deltaQuery.errorUpdatedAt, statusRefreshQuery.dataUpdatedAt, statusRefreshQuery.errorUpdatedAt);
904
+ const [pulse, setPulse] = (0, react.useState)(false);
905
+ const prevActivityAtRef = (0, react.useRef)(lastActivityAt);
906
+ (0, react.useEffect)(() => {
907
+ if (lastActivityAt > prevActivityAtRef.current) {
908
+ prevActivityAtRef.current = lastActivityAt;
909
+ setPulse(true);
910
+ const t = setTimeout(() => setPulse(false), minRefetchSpinMs);
911
+ return () => clearTimeout(t);
912
+ }
913
+ }, [lastActivityAt, minRefetchSpinMs]);
914
+ const isRefetching = isFetchingAny || pulse;
915
+ return {
916
+ ...query,
917
+ setEndOfListElement,
918
+ isRefetching,
919
+ autoRefetch,
920
+ setAutoRefetch,
921
+ recentlyAddedKeys
922
+ };
923
+ };
924
+ //#endregion
925
+ //#region src/hooks/traces/use-create-feedback.tsx
926
+ /**
927
+ * Submits a free-text comment as a feedback record, scoped to the trace or to a
928
+ * single span, then invalidates the matching feedback list so it refreshes.
929
+ */
930
+ const useCreateFeedback = ({ traceId, spanId, queryOptions }) => {
931
+ const client = require_mastra_client_context.useMastraClient();
932
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
933
+ return (0, _tanstack_react_query.useMutation)({
934
+ mutationFn: ({ text }) => client.createFeedback({ feedback: {
935
+ traceId,
936
+ ...spanId ? { spanId } : {},
937
+ feedbackType: "comment",
938
+ feedbackSource: "user",
939
+ value: text
940
+ } }),
941
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: spanId ? [
942
+ "span-feedback",
943
+ traceId,
944
+ spanId
945
+ ] : ["trace-feedback", traceId] }),
946
+ ...queryOptions
947
+ });
948
+ };
949
+ //#endregion
950
+ //#region src/hooks/traces/use-delete-feedback.tsx
951
+ /**
952
+ * Deletes a single feedback record by id, then invalidates the matching
953
+ * feedback list (trace- or span-scoped) so it refreshes.
954
+ */
955
+ const useDeleteFeedback = ({ traceId, spanId, queryOptions }) => {
956
+ const client = require_mastra_client_context.useMastraClient();
957
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
958
+ return (0, _tanstack_react_query.useMutation)({
959
+ mutationFn: ({ feedbackId }) => client.deleteFeedback({ feedbackIds: [feedbackId] }),
960
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: spanId ? [
961
+ "span-feedback",
962
+ traceId,
963
+ spanId
964
+ ] : ["trace-feedback", traceId] }),
965
+ ...queryOptions
966
+ });
967
+ };
968
+ //#endregion
969
+ //#region src/hooks/traces/use-span-feedback.tsx
970
+ /**
971
+ * Feedback scoped to a single span. Both identifiers are required: without a `spanId`
972
+ * the query stays disabled rather than falling back to trace-wide feedback.
973
+ *
974
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
975
+ */
976
+ const useSpanFeedback = ({ traceId = "", spanId = "", page, queryOptions }) => {
977
+ const client = require_mastra_client_context.useMastraClient();
978
+ const pageNumber = page ?? 0;
979
+ return (0, _tanstack_react_query.useQuery)({
980
+ queryKey: [
981
+ "span-feedback",
982
+ traceId,
983
+ spanId,
984
+ pageNumber
985
+ ],
986
+ queryFn: () => client.listFeedback({
987
+ filters: {
988
+ traceId,
989
+ spanId
990
+ },
991
+ pagination: {
992
+ page: pageNumber,
993
+ perPage: 10
994
+ }
995
+ }),
996
+ refetchInterval: require_feedback_refetch_interval.getFeedbackRefetchInterval,
997
+ gcTime: 0,
998
+ staleTime: 0,
999
+ ...queryOptions
1000
+ });
1001
+ };
1002
+ //#endregion
1003
+ //#region src/hooks/traces/use-trace-feedback.tsx
1004
+ /** Loads a page of trace-level feedback and stops polling when storage cannot serve feedback. */
1005
+ /**
1006
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
1007
+ */
1008
+ const useTraceFeedback = ({ traceId = "", page, queryOptions }) => {
1009
+ const client = require_mastra_client_context.useMastraClient();
1010
+ const pageNumber = page ?? 0;
1011
+ return (0, _tanstack_react_query.useQuery)({
1012
+ queryKey: [
1013
+ "trace-feedback",
1014
+ traceId,
1015
+ pageNumber
1016
+ ],
1017
+ queryFn: () => client.listFeedback({
1018
+ filters: { traceId },
1019
+ pagination: {
1020
+ page: pageNumber,
1021
+ perPage: 10
1022
+ }
1023
+ }),
1024
+ select: (data) => {
1025
+ const feedback = data.feedback.filter((item) => !item.spanId);
1026
+ if (!data.pagination) return {
1027
+ ...data,
1028
+ feedback
1029
+ };
1030
+ return {
1031
+ ...data,
1032
+ feedback,
1033
+ pagination: {
1034
+ ...data.pagination,
1035
+ total: feedback.length
1036
+ }
1037
+ };
1038
+ },
1039
+ refetchInterval: require_feedback_refetch_interval.getFeedbackRefetchInterval,
1040
+ gcTime: 0,
1041
+ staleTime: 0,
1042
+ ...queryOptions
1043
+ });
1044
+ };
1045
+ //#endregion
1046
+ //#region src/hooks/traces/use-trace-metadata-filter-fields.ts
1047
+ const DISCOVERY_LIMIT = 100;
1048
+ const EMPTY_FIELDS = {
1049
+ canonicalFields: [],
1050
+ observedFields: [],
1051
+ observedFieldsTruncated: false
1052
+ };
1053
+ const TRACE_QUERY_DISCOVERY_UNSUPPORTED = "TRACE_QUERY_DISCOVERY_UNSUPPORTED";
1054
+ const isDiscoveryUnsupportedError = (error) => error instanceof _mastra_client_js.MastraClientError && typeof error.body === "object" && error.body !== null && error.body.code === TRACE_QUERY_DISCOVERY_UNSUPPORTED;
1055
+ const traceQueryFieldsQueryKey = (timeRange) => [
1056
+ "trace-query-fields",
1057
+ timeRange.from,
1058
+ timeRange.to
1059
+ ];
1060
+ /** Lazy FilterBar suggestions resolver backed by the value-discovery endpoint for one
1061
+ * `predicateScope` + `path`. the caller owns debounce/abort; this only fetches. */
1062
+ const createTraceQueryValuesResolver = (client, timeRange, predicateScope, path) => {
1063
+ return async ({ query: search, signal }) => {
1064
+ const { values } = await client.getTraceQueryValues({
1065
+ timeRange,
1066
+ predicateScope,
1067
+ path,
1068
+ search: search.trim() || void 0,
1069
+ limit: DISCOVERY_LIMIT
1070
+ }, { signal });
1071
+ return values.map(({ value }) => ({ value }));
1072
+ };
1073
+ };
1074
+ /**
1075
+ * Discovers the `metadata.*` fields observed on traces in the given time range and returns
1076
+ * them as filter bar fields, each with a lazy `suggestions` resolver that fetches the field's
1077
+ * values when the user opens the value step (the caller owns debounce/abort).
1078
+ *
1079
+ * Resolves to an empty field list when the server or store does not support discovery
1080
+ * (`TRACE_QUERY_DISCOVERY_UNSUPPORTED`) so callers never stay blocked.
1081
+ */
1082
+ const useTraceMetadataFilterFields = ({ timeRange, queryOptions }) => {
1083
+ const client = require_mastra_client_context.useMastraClient();
1084
+ const query = (0, _tanstack_react_query.useQuery)({
1085
+ queryKey: traceQueryFieldsQueryKey(timeRange),
1086
+ queryFn: async ({ signal }) => {
1087
+ try {
1088
+ return await client.getTraceQueryFields({
1089
+ timeRange,
1090
+ predicateScope: "trace",
1091
+ limit: DISCOVERY_LIMIT
1092
+ }, { signal });
1093
+ } catch (error) {
1094
+ if (isDiscoveryUnsupportedError(error)) return EMPTY_FIELDS;
1095
+ throw error;
1096
+ }
1097
+ },
1098
+ retry: false,
1099
+ staleTime: DISCOVERY_STALE_TIME,
1100
+ placeholderData: _tanstack_react_query.keepPreviousData,
1101
+ ...queryOptions
1102
+ });
1103
+ const observedFields = query.data?.observedFields;
1104
+ return {
1105
+ fields: (0, react.useMemo)(() => (observedFields ?? []).map((field) => ({
1106
+ path: field.path,
1107
+ suggestions: createTraceQueryValuesResolver(client, timeRange, "trace", field.path)
1108
+ })), [
1109
+ observedFields,
1110
+ client,
1111
+ timeRange
1112
+ ]),
1113
+ isLoading: query.isLoading,
1114
+ error: query.error
1115
+ };
1116
+ };
1117
+ //#endregion
1118
+ //#region src/hooks/traces/use-trace-column-preferences-storage-key.ts
1119
+ /**
1120
+ * Storage key for the trace list column preferences, scoped to the Mastra server the client
1121
+ * talks to so each project keeps its own column layout.
1122
+ */
1123
+ function useTraceColumnPreferencesStorageKey() {
1124
+ const client = require_mastra_client_context.useMastraClient();
1125
+ return `mastra:traces:columns:${client.options.baseUrl || (typeof window === "undefined" ? "local" : window.location.origin || "local")}:${client.options.apiPrefix ?? "/api"}`;
1126
+ }
1127
+ //#endregion
1128
+ exports.DISCOVERY_STALE_TIME = DISCOVERY_STALE_TIME;
1129
+ exports.ROOT_ENTITY_TYPES = ROOT_ENTITY_TYPES;
1130
+ exports.TRACES_PER_PAGE = TRACES_PER_PAGE;
1131
+ exports.TRACE_QUERY_PER_PAGE = TRACE_QUERY_PER_PAGE;
1132
+ exports.createTraceQueryValuesResolver = createTraceQueryValuesResolver;
1133
+ exports.getLegacyTraceQueryNextPageParam = getLegacyTraceQueryNextPageParam;
1134
+ exports.getTraceQueryNextPageParam = getTraceQueryNextPageParam;
1135
+ exports.getTracesNextPageParam = getTracesNextPageParam;
1136
+ exports.lightSpanToTraceQueryTrace = lightSpanToTraceQueryTrace;
1137
+ exports.mergeDeltaIntoPage0 = mergeDeltaIntoPage0;
1138
+ exports.refreshPage0Rows = refreshPage0Rows;
1139
+ exports.selectLegacyTraceQueryTraces = selectLegacyTraceQueryTraces;
1140
+ exports.selectTraceQueryTraces = selectTraceQueryTraces;
1141
+ exports.selectUniqueTraces = selectUniqueTraces;
1142
+ exports.shouldPinLightList = shouldPinLightList;
1143
+ exports.shouldResetAfterIdle = shouldResetAfterIdle;
1144
+ exports.traceQueryFieldsQueryKey = traceQueryFieldsQueryKey;
1145
+ exports.traceSpansQueryOptions = traceSpansQueryOptions;
1146
+ exports.useBranch = useBranch;
1147
+ exports.useCreateFeedback = useCreateFeedback;
1148
+ exports.useDeleteFeedback = useDeleteFeedback;
1149
+ exports.useEntityNames = useEntityNames;
1150
+ exports.useEnvironments = useEnvironments;
1151
+ exports.useFetchTraceSpans = useFetchTraceSpans;
1152
+ exports.useServiceNames = useServiceNames;
1153
+ exports.useSpanDetail = useSpanDetail;
1154
+ exports.useSpanFeedback = useSpanFeedback;
1155
+ exports.useTags = useTags;
1156
+ exports.useThreadHasOtherTraces = useThreadHasOtherTraces;
1157
+ exports.useTraceColumnPreferencesStorageKey = useTraceColumnPreferencesStorageKey;
1158
+ exports.useTraceFeedback = useTraceFeedback;
1159
+ exports.useTraceLightSpans = useTraceLightSpans;
1160
+ exports.useTraceMetadataFilterFields = useTraceMetadataFilterFields;
1161
+ exports.useTraceOrBranchSpans = useTraceOrBranchSpans;
1162
+ exports.useTraceQuery = useTraceQuery;
1163
+ exports.useTraceSpans = useTraceSpans;
1164
+ exports.useTraceSpansQueries = useTraceSpansQueries;
1165
+ exports.useTraceUsage = useTraceUsage;
1166
+ exports.useTraces = useTraces;
1167
+
1168
+ //# sourceMappingURL=index.cjs.map