@mastra/react 0.0.0-studio-cli-20260504022012 → 0.0.0-sugared-octave-20261030170102

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 (647) hide show
  1. package/LICENSE.md +6 -4
  2. package/README.md +37 -0
  3. package/dist/accumulator-Bjfckb5t.cjs +1753 -0
  4. package/dist/accumulator-Bjfckb5t.cjs.map +1 -0
  5. package/dist/accumulator-DysrPe6U.js +1712 -0
  6. package/dist/accumulator-DysrPe6U.js.map +1 -0
  7. package/dist/agent/extract-tasks.d.ts +10 -0
  8. package/dist/agent/extract-tasks.d.ts.map +1 -0
  9. package/dist/agent/extractRunIdFromMessages.d.ts +9 -2
  10. package/dist/agent/extractRunIdFromMessages.d.ts.map +1 -1
  11. package/dist/agent/hooks.d.ts +77 -13
  12. package/dist/agent/hooks.d.ts.map +1 -1
  13. package/dist/agent/merge-history.d.ts +7 -0
  14. package/dist/agent/merge-history.d.ts.map +1 -0
  15. package/dist/agent/signal-data.d.ts +5 -0
  16. package/dist/agent/signal-data.d.ts.map +1 -0
  17. package/dist/agent/types.d.ts +15 -1
  18. package/dist/agent/types.d.ts.map +1 -1
  19. package/dist/agent/user-message.d.ts +4 -0
  20. package/dist/agent/user-message.d.ts.map +1 -0
  21. package/dist/chat/index.cjs +3 -0
  22. package/dist/chat/index.d.ts +3 -0
  23. package/dist/chat/index.d.ts.map +1 -0
  24. package/dist/chat/index.js +1 -0
  25. package/dist/combine-by-ids-C-0oe4eH.js +23 -0
  26. package/dist/combine-by-ids-C-0oe4eH.js.map +1 -0
  27. package/dist/combine-by-ids-ERVPXXBi.cjs +28 -0
  28. package/dist/combine-by-ids-ERVPXXBi.cjs.map +1 -0
  29. package/dist/experiments-Duv0RgkM.cjs +346 -0
  30. package/dist/experiments-Duv0RgkM.cjs.map +1 -0
  31. package/dist/experiments-DyecjEut.js +299 -0
  32. package/dist/experiments-DyecjEut.js.map +1 -0
  33. package/dist/feedback-refetch-interval-BBcT9r8s.cjs +16 -0
  34. package/dist/feedback-refetch-interval-BBcT9r8s.cjs.map +1 -0
  35. package/dist/feedback-refetch-interval-C12Nzb2r.js +11 -0
  36. package/dist/feedback-refetch-interval-C12Nzb2r.js.map +1 -0
  37. package/dist/hooks/agents/index.cjs +994 -0
  38. package/dist/hooks/agents/index.cjs.map +1 -0
  39. package/dist/hooks/agents/index.d.ts +19 -0
  40. package/dist/hooks/agents/index.d.ts.map +1 -0
  41. package/dist/hooks/agents/index.js +957 -0
  42. package/dist/hooks/agents/index.js.map +1 -0
  43. package/dist/hooks/agents/is-model-not-allowed.d.ts +15 -0
  44. package/dist/hooks/agents/is-model-not-allowed.d.ts.map +1 -0
  45. package/dist/hooks/agents/use-agent-messages.d.ts +18 -0
  46. package/dist/hooks/agents/use-agent-messages.d.ts.map +1 -0
  47. package/dist/hooks/agents/use-agent-plan.d.ts +14 -0
  48. package/dist/hooks/agents/use-agent-plan.d.ts.map +1 -0
  49. package/dist/hooks/agents/use-agent-skills.d.ts +2043 -0
  50. package/dist/hooks/agents/use-agent-skills.d.ts.map +1 -0
  51. package/dist/hooks/agents/use-agent-versions.d.ts +72 -0
  52. package/dist/hooks/agents/use-agent-versions.d.ts.map +1 -0
  53. package/dist/hooks/agents/use-agent-working-memory.d.ts +11 -0
  54. package/dist/hooks/agents/use-agent-working-memory.d.ts.map +1 -0
  55. package/dist/hooks/agents/use-agent-workspace.d.ts +2044 -0
  56. package/dist/hooks/agents/use-agent-workspace.d.ts.map +1 -0
  57. package/dist/hooks/agents/use-agent.d.ts +12 -0
  58. package/dist/hooks/agents/use-agent.d.ts.map +1 -0
  59. package/dist/hooks/agents/use-agents-model-providers.d.ts +9 -0
  60. package/dist/hooks/agents/use-agents-model-providers.d.ts.map +1 -0
  61. package/dist/hooks/agents/use-agents.d.ts +28 -0
  62. package/dist/hooks/agents/use-agents.d.ts.map +1 -0
  63. package/dist/hooks/agents/use-background-tasks.d.ts +51 -0
  64. package/dist/hooks/agents/use-background-tasks.d.ts.map +1 -0
  65. package/dist/hooks/agents/use-browser-session-probe.d.ts +34 -0
  66. package/dist/hooks/agents/use-browser-session-probe.d.ts.map +1 -0
  67. package/dist/hooks/agents/use-channels.d.ts +45 -0
  68. package/dist/hooks/agents/use-channels.d.ts.map +1 -0
  69. package/dist/hooks/agents/use-close-browser.d.ts +17 -0
  70. package/dist/hooks/agents/use-close-browser.d.ts.map +1 -0
  71. package/dist/hooks/agents/use-execute-agent-tool.d.ts +14 -0
  72. package/dist/hooks/agents/use-execute-agent-tool.d.ts.map +1 -0
  73. package/dist/hooks/agents/use-preview-instructions.d.ts +20 -0
  74. package/dist/hooks/agents/use-preview-instructions.d.ts.map +1 -0
  75. package/dist/hooks/agents/use-stored-agents.d.ts +8111 -0
  76. package/dist/hooks/agents/use-stored-agents.d.ts.map +1 -0
  77. package/dist/hooks/agents/use-stored-skills.d.ts +8 -0
  78. package/dist/hooks/agents/use-stored-skills.d.ts.map +1 -0
  79. package/dist/hooks/auth/fetch-with-refresh.d.ts +28 -0
  80. package/dist/hooks/auth/fetch-with-refresh.d.ts.map +1 -0
  81. package/dist/hooks/auth/get-client-query-key.d.ts +7 -0
  82. package/dist/hooks/auth/get-client-query-key.d.ts.map +1 -0
  83. package/dist/hooks/auth/index.cjs +482 -0
  84. package/dist/hooks/auth/index.cjs.map +1 -0
  85. package/dist/hooks/auth/index.d.ts +11 -0
  86. package/dist/hooks/auth/index.d.ts.map +1 -0
  87. package/dist/hooks/auth/index.js +464 -0
  88. package/dist/hooks/auth/index.js.map +1 -0
  89. package/dist/hooks/auth/sso-login.d.ts +8 -0
  90. package/dist/hooks/auth/sso-login.d.ts.map +1 -0
  91. package/dist/hooks/auth/types.d.ts +107 -0
  92. package/dist/hooks/auth/types.d.ts.map +1 -0
  93. package/dist/hooks/auth/use-auth-actions.d.ts +99 -0
  94. package/dist/hooks/auth/use-auth-actions.d.ts.map +1 -0
  95. package/dist/hooks/auth/use-auth-capabilities.d.ts +43 -0
  96. package/dist/hooks/auth/use-auth-capabilities.d.ts.map +1 -0
  97. package/dist/hooks/auth/use-credentials-login.d.ts +63 -0
  98. package/dist/hooks/auth/use-credentials-login.d.ts.map +1 -0
  99. package/dist/hooks/auth/use-credentials-signup.d.ts +66 -0
  100. package/dist/hooks/auth/use-credentials-signup.d.ts.map +1 -0
  101. package/dist/hooks/auth/use-current-user.d.ts +40 -0
  102. package/dist/hooks/auth/use-current-user.d.ts.map +1 -0
  103. package/dist/hooks/auth/use-permission-patterns.d.ts +24 -0
  104. package/dist/hooks/auth/use-permission-patterns.d.ts.map +1 -0
  105. package/dist/hooks/capabilities/index.cjs +139 -0
  106. package/dist/hooks/capabilities/index.cjs.map +1 -0
  107. package/dist/hooks/capabilities/index.d.ts +11 -0
  108. package/dist/hooks/capabilities/index.d.ts.map +1 -0
  109. package/dist/hooks/capabilities/index.js +129 -0
  110. package/dist/hooks/capabilities/index.js.map +1 -0
  111. package/dist/hooks/capabilities/use-feedback-available.d.ts +9 -0
  112. package/dist/hooks/capabilities/use-feedback-available.d.ts.map +1 -0
  113. package/dist/hooks/capabilities/use-observability-capabilities.d.ts +9 -0
  114. package/dist/hooks/capabilities/use-observability-capabilities.d.ts.map +1 -0
  115. package/dist/hooks/capabilities/use-span-aggregate-available.d.ts +9 -0
  116. package/dist/hooks/capabilities/use-span-aggregate-available.d.ts.map +1 -0
  117. package/dist/hooks/capabilities/use-span-query-available.d.ts +9 -0
  118. package/dist/hooks/capabilities/use-span-query-available.d.ts.map +1 -0
  119. package/dist/hooks/capabilities/use-thread-query-available.d.ts +9 -0
  120. package/dist/hooks/capabilities/use-thread-query-available.d.ts.map +1 -0
  121. package/dist/hooks/capabilities/use-trace-aggregate-available.d.ts +10 -0
  122. package/dist/hooks/capabilities/use-trace-aggregate-available.d.ts.map +1 -0
  123. package/dist/hooks/capabilities/use-trace-query-available.d.ts +9 -0
  124. package/dist/hooks/capabilities/use-trace-query-available.d.ts.map +1 -0
  125. package/dist/hooks/capabilities/use-trace-query-delta-polling-available.d.ts +10 -0
  126. package/dist/hooks/capabilities/use-trace-query-delta-polling-available.d.ts.map +1 -0
  127. package/dist/hooks/capabilities/use-trace-query-discovery-available.d.ts +10 -0
  128. package/dist/hooks/capabilities/use-trace-query-discovery-available.d.ts.map +1 -0
  129. package/dist/hooks/capabilities/use-trace-query-root-duration-available.d.ts +10 -0
  130. package/dist/hooks/capabilities/use-trace-query-root-duration-available.d.ts.map +1 -0
  131. package/dist/hooks/configuration/index.cjs +17 -0
  132. package/dist/hooks/configuration/index.cjs.map +1 -0
  133. package/dist/hooks/configuration/index.d.ts +2 -0
  134. package/dist/hooks/configuration/index.d.ts.map +1 -0
  135. package/dist/hooks/configuration/index.js +16 -0
  136. package/dist/hooks/configuration/index.js.map +1 -0
  137. package/dist/hooks/configuration/use-mastra-packages.d.ts +9 -0
  138. package/dist/hooks/configuration/use-mastra-packages.d.ts.map +1 -0
  139. package/dist/hooks/datasets/index.cjs +726 -0
  140. package/dist/hooks/datasets/index.cjs.map +1 -0
  141. package/dist/hooks/datasets/index.d.ts +10 -0
  142. package/dist/hooks/datasets/index.d.ts.map +1 -0
  143. package/dist/hooks/datasets/index.js +703 -0
  144. package/dist/hooks/datasets/index.js.map +1 -0
  145. package/dist/hooks/datasets/use-compare-experiments.d.ts +19 -0
  146. package/dist/hooks/datasets/use-compare-experiments.d.ts.map +1 -0
  147. package/dist/hooks/datasets/use-dataset-experiments.d.ts +92 -0
  148. package/dist/hooks/datasets/use-dataset-experiments.d.ts.map +1 -0
  149. package/dist/hooks/datasets/use-dataset-item-versions.d.ts +31 -0
  150. package/dist/hooks/datasets/use-dataset-item-versions.d.ts.map +1 -0
  151. package/dist/hooks/datasets/use-dataset-items.d.ts +38 -0
  152. package/dist/hooks/datasets/use-dataset-items.d.ts.map +1 -0
  153. package/dist/hooks/datasets/use-dataset-mutations.d.ts +315 -0
  154. package/dist/hooks/datasets/use-dataset-mutations.d.ts.map +1 -0
  155. package/dist/hooks/datasets/use-dataset-versions.d.ts +23 -0
  156. package/dist/hooks/datasets/use-dataset-versions.d.ts.map +1 -0
  157. package/dist/hooks/datasets/use-datasets.d.ts +51 -0
  158. package/dist/hooks/datasets/use-datasets.d.ts.map +1 -0
  159. package/dist/hooks/datasets/use-experiments.d.ts +24 -0
  160. package/dist/hooks/datasets/use-experiments.d.ts.map +1 -0
  161. package/dist/hooks/datasets/use-workflow-schema.d.ts +16 -0
  162. package/dist/hooks/datasets/use-workflow-schema.d.ts.map +1 -0
  163. package/dist/hooks/embedders/index.cjs +18 -0
  164. package/dist/hooks/embedders/index.cjs.map +1 -0
  165. package/dist/hooks/embedders/index.d.ts +2 -0
  166. package/dist/hooks/embedders/index.d.ts.map +1 -0
  167. package/dist/hooks/embedders/index.js +17 -0
  168. package/dist/hooks/embedders/index.js.map +1 -0
  169. package/dist/hooks/embedders/use-embedders.d.ts +17 -0
  170. package/dist/hooks/embedders/use-embedders.d.ts.map +1 -0
  171. package/dist/hooks/experiments/index.cjs +10 -0
  172. package/dist/hooks/experiments/index.d.ts +7 -0
  173. package/dist/hooks/experiments/index.d.ts.map +1 -0
  174. package/dist/hooks/experiments/index.js +1 -0
  175. package/dist/hooks/experiments/usage-accumulator.d.ts +25 -0
  176. package/dist/hooks/experiments/usage-accumulator.d.ts.map +1 -0
  177. package/dist/hooks/experiments/use-experiment-item-usage.d.ts +23 -0
  178. package/dist/hooks/experiments/use-experiment-item-usage.d.ts.map +1 -0
  179. package/dist/hooks/experiments/use-experiment-metrics.d.ts +30 -0
  180. package/dist/hooks/experiments/use-experiment-metrics.d.ts.map +1 -0
  181. package/dist/hooks/experiments/use-experiment-trace.d.ts +13 -0
  182. package/dist/hooks/experiments/use-experiment-trace.d.ts.map +1 -0
  183. package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts +22 -0
  184. package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts.map +1 -0
  185. package/dist/hooks/experiments/use-experiments-list-metrics.d.ts +19 -0
  186. package/dist/hooks/experiments/use-experiments-list-metrics.d.ts.map +1 -0
  187. package/dist/hooks/experiments/use-infinite-experiments.d.ts +22 -0
  188. package/dist/hooks/experiments/use-infinite-experiments.d.ts.map +1 -0
  189. package/dist/hooks/feedback/feedback-refetch-interval.d.ts +7 -0
  190. package/dist/hooks/feedback/feedback-refetch-interval.d.ts.map +1 -0
  191. package/dist/hooks/feedback/index.cjs +21 -0
  192. package/dist/hooks/feedback/index.cjs.map +1 -0
  193. package/dist/hooks/feedback/index.d.ts +3 -0
  194. package/dist/hooks/feedback/index.d.ts.map +1 -0
  195. package/dist/hooks/feedback/index.js +19 -0
  196. package/dist/hooks/feedback/index.js.map +1 -0
  197. package/dist/hooks/feedback/use-feedback.d.ts +56 -0
  198. package/dist/hooks/feedback/use-feedback.d.ts.map +1 -0
  199. package/dist/hooks/llm/index.cjs +16 -0
  200. package/dist/hooks/llm/index.cjs.map +1 -0
  201. package/dist/hooks/llm/index.d.ts +2 -0
  202. package/dist/hooks/llm/index.d.ts.map +1 -0
  203. package/dist/hooks/llm/index.js +15 -0
  204. package/dist/hooks/llm/index.js.map +1 -0
  205. package/dist/hooks/llm/use-llm-providers.d.ts +7 -0
  206. package/dist/hooks/llm/use-llm-providers.d.ts.map +1 -0
  207. package/dist/hooks/logs/index.cjs +83 -0
  208. package/dist/hooks/logs/index.cjs.map +1 -0
  209. package/dist/hooks/logs/index.d.ts +4 -0
  210. package/dist/hooks/logs/index.d.ts.map +1 -0
  211. package/dist/hooks/logs/index.js +81 -0
  212. package/dist/hooks/logs/index.js.map +1 -0
  213. package/dist/hooks/logs/types.d.ts +36 -0
  214. package/dist/hooks/logs/types.d.ts.map +1 -0
  215. package/dist/hooks/logs/use-logs.d.ts +79 -0
  216. package/dist/hooks/logs/use-logs.d.ts.map +1 -0
  217. package/dist/hooks/mcps/index.cjs +231 -0
  218. package/dist/hooks/mcps/index.cjs.map +1 -0
  219. package/dist/hooks/mcps/index.d.ts +8 -0
  220. package/dist/hooks/mcps/index.d.ts.map +1 -0
  221. package/dist/hooks/mcps/index.js +223 -0
  222. package/dist/hooks/mcps/index.js.map +1 -0
  223. package/dist/hooks/mcps/use-mcp-app-html.d.ts +17 -0
  224. package/dist/hooks/mcps/use-mcp-app-html.d.ts.map +1 -0
  225. package/dist/hooks/mcps/use-mcp-app-tools.d.ts +21 -0
  226. package/dist/hooks/mcps/use-mcp-app-tools.d.ts.map +1 -0
  227. package/dist/hooks/mcps/use-mcp-server-tool.d.ts +25 -0
  228. package/dist/hooks/mcps/use-mcp-server-tool.d.ts.map +1 -0
  229. package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts +13 -0
  230. package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts.map +1 -0
  231. package/dist/hooks/mcps/use-mcp-server-tools.d.ts +9 -0
  232. package/dist/hooks/mcps/use-mcp-server-tools.d.ts.map +1 -0
  233. package/dist/hooks/mcps/use-mcp-servers.d.ts +8 -0
  234. package/dist/hooks/mcps/use-mcp-servers.d.ts.map +1 -0
  235. package/dist/hooks/mcps/use-try-connect-mcp.d.ts +15 -0
  236. package/dist/hooks/mcps/use-try-connect-mcp.d.ts.map +1 -0
  237. package/dist/hooks/memory/index.cjs +324 -0
  238. package/dist/hooks/memory/index.cjs.map +1 -0
  239. package/dist/hooks/memory/index.d.ts +5 -0
  240. package/dist/hooks/memory/index.d.ts.map +1 -0
  241. package/dist/hooks/memory/index.js +308 -0
  242. package/dist/hooks/memory/index.js.map +1 -0
  243. package/dist/hooks/memory/use-memory-status.d.ts +12 -0
  244. package/dist/hooks/memory/use-memory-status.d.ts.map +1 -0
  245. package/dist/hooks/memory/use-memory-thread-messages.d.ts +13 -0
  246. package/dist/hooks/memory/use-memory-thread-messages.d.ts.map +1 -0
  247. package/dist/hooks/memory/use-memory.d.ts +159 -0
  248. package/dist/hooks/memory/use-memory.d.ts.map +1 -0
  249. package/dist/hooks/memory/use-observational-memory.d.ts +13 -0
  250. package/dist/hooks/memory/use-observational-memory.d.ts.map +1 -0
  251. package/dist/hooks/metrics/index.cjs +989 -0
  252. package/dist/hooks/metrics/index.cjs.map +1 -0
  253. package/dist/hooks/metrics/index.d.ts +16 -0
  254. package/dist/hooks/metrics/index.d.ts.map +1 -0
  255. package/dist/hooks/metrics/index.js +973 -0
  256. package/dist/hooks/metrics/index.js.map +1 -0
  257. package/dist/hooks/metrics/metrics-interval.d.ts +8 -0
  258. package/dist/hooks/metrics/metrics-interval.d.ts.map +1 -0
  259. package/dist/hooks/metrics/metrics-query-filters.d.ts +62 -0
  260. package/dist/hooks/metrics/metrics-query-filters.d.ts.map +1 -0
  261. package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts +12 -0
  262. package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts.map +1 -0
  263. package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts +12 -0
  264. package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts.map +1 -0
  265. package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts +9 -0
  266. package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts.map +1 -0
  267. package/dist/hooks/metrics/use-latency-metrics.d.ts +23 -0
  268. package/dist/hooks/metrics/use-latency-metrics.d.ts.map +1 -0
  269. package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts +14 -0
  270. package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts.map +1 -0
  271. package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts +17 -0
  272. package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts.map +1 -0
  273. package/dist/hooks/metrics/use-scores-metrics.d.ts +24 -0
  274. package/dist/hooks/metrics/use-scores-metrics.d.ts.map +1 -0
  275. package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts +15 -0
  276. package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts.map +1 -0
  277. package/dist/hooks/metrics/use-token-usage-timeseries.d.ts +22 -0
  278. package/dist/hooks/metrics/use-token-usage-timeseries.d.ts.map +1 -0
  279. package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts +21 -0
  280. package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts.map +1 -0
  281. package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts +20 -0
  282. package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts.map +1 -0
  283. package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts +13 -0
  284. package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts.map +1 -0
  285. package/dist/hooks/metrics/use-trace-volume-metrics.d.ts +17 -0
  286. package/dist/hooks/metrics/use-trace-volume-metrics.d.ts.map +1 -0
  287. package/dist/hooks/processors/index.cjs +42 -0
  288. package/dist/hooks/processors/index.cjs.map +1 -0
  289. package/dist/hooks/processors/index.d.ts +2 -0
  290. package/dist/hooks/processors/index.d.ts.map +1 -0
  291. package/dist/hooks/processors/index.js +39 -0
  292. package/dist/hooks/processors/index.js.map +1 -0
  293. package/dist/hooks/processors/use-processors.d.ts +64 -0
  294. package/dist/hooks/processors/use-processors.d.ts.map +1 -0
  295. package/dist/hooks/prompt-blocks/index.cjs +179 -0
  296. package/dist/hooks/prompt-blocks/index.cjs.map +1 -0
  297. package/dist/hooks/prompt-blocks/index.d.ts +3 -0
  298. package/dist/hooks/prompt-blocks/index.d.ts.map +1 -0
  299. package/dist/hooks/prompt-blocks/index.js +170 -0
  300. package/dist/hooks/prompt-blocks/index.js.map +1 -0
  301. package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts +59 -0
  302. package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts.map +1 -0
  303. package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts +180 -0
  304. package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts.map +1 -0
  305. package/dist/hooks/query/index.cjs +33 -0
  306. package/dist/hooks/query/index.cjs.map +1 -0
  307. package/dist/hooks/query/index.d.ts +4 -0
  308. package/dist/hooks/query/index.d.ts.map +1 -0
  309. package/dist/hooks/query/index.js +24 -0
  310. package/dist/hooks/query/index.js.map +1 -0
  311. package/dist/hooks/query/query-client-provider.d.ts +8 -0
  312. package/dist/hooks/query/query-client-provider.d.ts.map +1 -0
  313. package/dist/hooks/query/query-utils.d.ts +48 -0
  314. package/dist/hooks/query/query-utils.d.ts.map +1 -0
  315. package/dist/hooks/review/index.cjs +90 -0
  316. package/dist/hooks/review/index.cjs.map +1 -0
  317. package/dist/hooks/review/index.d.ts +4 -0
  318. package/dist/hooks/review/index.d.ts.map +1 -0
  319. package/dist/hooks/review/index.js +87 -0
  320. package/dist/hooks/review/index.js.map +1 -0
  321. package/dist/hooks/review/types.d.ts +24 -0
  322. package/dist/hooks/review/types.d.ts.map +1 -0
  323. package/dist/hooks/review/use-dataset-review-items.d.ts +19 -0
  324. package/dist/hooks/review/use-dataset-review-items.d.ts.map +1 -0
  325. package/dist/hooks/review/use-review-summary.d.ts +9 -0
  326. package/dist/hooks/review/use-review-summary.d.ts.map +1 -0
  327. package/dist/hooks/schedules/index.cjs +106 -0
  328. package/dist/hooks/schedules/index.cjs.map +1 -0
  329. package/dist/hooks/schedules/index.d.ts +5 -0
  330. package/dist/hooks/schedules/index.d.ts.map +1 -0
  331. package/dist/hooks/schedules/index.js +102 -0
  332. package/dist/hooks/schedules/index.js.map +1 -0
  333. package/dist/hooks/schedules/use-schedule-triggers.d.ts +18 -0
  334. package/dist/hooks/schedules/use-schedule-triggers.d.ts.map +1 -0
  335. package/dist/hooks/schedules/use-schedule.d.ts +11 -0
  336. package/dist/hooks/schedules/use-schedule.d.ts.map +1 -0
  337. package/dist/hooks/schedules/use-schedules.d.ts +7 -0
  338. package/dist/hooks/schedules/use-schedules.d.ts.map +1 -0
  339. package/dist/hooks/schedules/use-toggle-schedule.d.ts +13 -0
  340. package/dist/hooks/schedules/use-toggle-schedule.d.ts.map +1 -0
  341. package/dist/hooks/scores/index.cjs +334 -0
  342. package/dist/hooks/scores/index.cjs.map +1 -0
  343. package/dist/hooks/scores/index.d.ts +6 -0
  344. package/dist/hooks/scores/index.d.ts.map +1 -0
  345. package/dist/hooks/scores/index.js +318 -0
  346. package/dist/hooks/scores/index.js.map +1 -0
  347. package/dist/hooks/scores/use-scorer-versions.d.ts +71 -0
  348. package/dist/hooks/scores/use-scorer-versions.d.ts.map +1 -0
  349. package/dist/hooks/scores/use-scorers.d.ts +34 -0
  350. package/dist/hooks/scores/use-scorers.d.ts.map +1 -0
  351. package/dist/hooks/scores/use-stored-scorers.d.ts +151 -0
  352. package/dist/hooks/scores/use-stored-scorers.d.ts.map +1 -0
  353. package/dist/hooks/scores/use-trace-span-scores.d.ts +20 -0
  354. package/dist/hooks/scores/use-trace-span-scores.d.ts.map +1 -0
  355. package/dist/hooks/scores/use-trigger-scorer.d.ts +17 -0
  356. package/dist/hooks/scores/use-trigger-scorer.d.ts.map +1 -0
  357. package/dist/hooks/shared/combine-by-ids.d.ts +15 -0
  358. package/dist/hooks/shared/combine-by-ids.d.ts.map +1 -0
  359. package/dist/hooks/shared/cost.d.ts +7 -0
  360. package/dist/hooks/shared/cost.d.ts.map +1 -0
  361. package/dist/hooks/shared/date-format.d.ts +30 -0
  362. package/dist/hooks/shared/date-format.d.ts.map +1 -0
  363. package/dist/hooks/shared/map.d.ts +2 -0
  364. package/dist/hooks/shared/map.d.ts.map +1 -0
  365. package/dist/hooks/shared/query-options.d.ts +19 -0
  366. package/dist/hooks/shared/query-options.d.ts.map +1 -0
  367. package/dist/hooks/shared/use-in-view.d.ts +23 -0
  368. package/dist/hooks/shared/use-in-view.d.ts.map +1 -0
  369. package/dist/hooks/templates/index.cjs +465 -0
  370. package/dist/hooks/templates/index.cjs.map +1 -0
  371. package/dist/hooks/templates/index.d.ts +2 -0
  372. package/dist/hooks/templates/index.d.ts.map +1 -0
  373. package/dist/hooks/templates/index.js +457 -0
  374. package/dist/hooks/templates/index.js.map +1 -0
  375. package/dist/hooks/templates/use-templates.d.ts +139 -0
  376. package/dist/hooks/templates/use-templates.d.ts.map +1 -0
  377. package/dist/hooks/tool-providers/index.cjs +333 -0
  378. package/dist/hooks/tool-providers/index.cjs.map +1 -0
  379. package/dist/hooks/tool-providers/index.d.ts +10 -0
  380. package/dist/hooks/tool-providers/index.d.ts.map +1 -0
  381. package/dist/hooks/tool-providers/index.js +323 -0
  382. package/dist/hooks/tool-providers/index.js.map +1 -0
  383. package/dist/hooks/tool-providers/use-all-connections.d.ts +41 -0
  384. package/dist/hooks/tool-providers/use-all-connections.d.ts.map +1 -0
  385. package/dist/hooks/tool-providers/use-all-provider-tools.d.ts +25 -0
  386. package/dist/hooks/tool-providers/use-all-provider-tools.d.ts.map +1 -0
  387. package/dist/hooks/tool-providers/use-authorize.d.ts +45 -0
  388. package/dist/hooks/tool-providers/use-authorize.d.ts.map +1 -0
  389. package/dist/hooks/tool-providers/use-disconnect-connection.d.ts +24 -0
  390. package/dist/hooks/tool-providers/use-disconnect-connection.d.ts.map +1 -0
  391. package/dist/hooks/tool-providers/use-existing-connections.d.ts +33 -0
  392. package/dist/hooks/tool-providers/use-existing-connections.d.ts.map +1 -0
  393. package/dist/hooks/tool-providers/use-provider-tools.d.ts +17 -0
  394. package/dist/hooks/tool-providers/use-provider-tools.d.ts.map +1 -0
  395. package/dist/hooks/tool-providers/use-tool-providers.d.ts +23 -0
  396. package/dist/hooks/tool-providers/use-tool-providers.d.ts.map +1 -0
  397. package/dist/hooks/tool-providers/use-toolkits.d.ts +13 -0
  398. package/dist/hooks/tool-providers/use-toolkits.d.ts.map +1 -0
  399. package/dist/hooks/tool-providers/use-update-connection.d.ts +24 -0
  400. package/dist/hooks/tool-providers/use-update-connection.d.ts.map +1 -0
  401. package/dist/hooks/tools/index.cjs +47 -0
  402. package/dist/hooks/tools/index.cjs.map +1 -0
  403. package/dist/hooks/tools/index.d.ts +3 -0
  404. package/dist/hooks/tools/index.d.ts.map +1 -0
  405. package/dist/hooks/tools/index.js +44 -0
  406. package/dist/hooks/tools/index.js.map +1 -0
  407. package/dist/hooks/tools/use-all-tools.d.ts +16 -0
  408. package/dist/hooks/tools/use-all-tools.d.ts.map +1 -0
  409. package/dist/hooks/tools/use-execute-tool.d.ts +13 -0
  410. package/dist/hooks/tools/use-execute-tool.d.ts.map +1 -0
  411. package/dist/hooks/traces/discovery-cache.d.ts +12 -0
  412. package/dist/hooks/traces/discovery-cache.d.ts.map +1 -0
  413. package/dist/hooks/traces/index.cjs +1473 -0
  414. package/dist/hooks/traces/index.cjs.map +1 -0
  415. package/dist/hooks/traces/index.d.ts +26 -0
  416. package/dist/hooks/traces/index.d.ts.map +1 -0
  417. package/dist/hooks/traces/index.js +1424 -0
  418. package/dist/hooks/traces/index.js.map +1 -0
  419. package/dist/hooks/traces/types.d.ts +21 -0
  420. package/dist/hooks/traces/types.d.ts.map +1 -0
  421. package/dist/hooks/traces/use-branch.d.ts +18 -0
  422. package/dist/hooks/traces/use-branch.d.ts.map +1 -0
  423. package/dist/hooks/traces/use-create-feedback.d.ts +21 -0
  424. package/dist/hooks/traces/use-create-feedback.d.ts.map +1 -0
  425. package/dist/hooks/traces/use-delete-feedback.d.ts +21 -0
  426. package/dist/hooks/traces/use-delete-feedback.d.ts.map +1 -0
  427. package/dist/hooks/traces/use-entity-names.d.ts +14 -0
  428. package/dist/hooks/traces/use-entity-names.d.ts.map +1 -0
  429. package/dist/hooks/traces/use-environments.d.ts +10 -0
  430. package/dist/hooks/traces/use-environments.d.ts.map +1 -0
  431. package/dist/hooks/traces/use-query-spans.d.ts +27 -0
  432. package/dist/hooks/traces/use-query-spans.d.ts.map +1 -0
  433. package/dist/hooks/traces/use-query-threads.d.ts +30 -0
  434. package/dist/hooks/traces/use-query-threads.d.ts.map +1 -0
  435. package/dist/hooks/traces/use-service-names.d.ts +10 -0
  436. package/dist/hooks/traces/use-service-names.d.ts.map +1 -0
  437. package/dist/hooks/traces/use-span-aggregate.d.ts +16 -0
  438. package/dist/hooks/traces/use-span-aggregate.d.ts.map +1 -0
  439. package/dist/hooks/traces/use-span-detail.d.ts +14 -0
  440. package/dist/hooks/traces/use-span-detail.d.ts.map +1 -0
  441. package/dist/hooks/traces/use-span-feedback.d.ts +19 -0
  442. package/dist/hooks/traces/use-span-feedback.d.ts.map +1 -0
  443. package/dist/hooks/traces/use-tags.d.ts +10 -0
  444. package/dist/hooks/traces/use-tags.d.ts.map +1 -0
  445. package/dist/hooks/traces/use-thread-has-other-traces.d.ts +17 -0
  446. package/dist/hooks/traces/use-thread-has-other-traces.d.ts.map +1 -0
  447. package/dist/hooks/traces/use-trace-aggregate.d.ts +17 -0
  448. package/dist/hooks/traces/use-trace-aggregate.d.ts.map +1 -0
  449. package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts +8 -0
  450. package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts.map +1 -0
  451. package/dist/hooks/traces/use-trace-feedback.d.ts +16 -0
  452. package/dist/hooks/traces/use-trace-feedback.d.ts.map +1 -0
  453. package/dist/hooks/traces/use-trace-light-spans.d.ts +16 -0
  454. package/dist/hooks/traces/use-trace-light-spans.d.ts.map +1 -0
  455. package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts +42 -0
  456. package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts.map +1 -0
  457. package/dist/hooks/traces/use-trace-or-branch-spans.d.ts +39 -0
  458. package/dist/hooks/traces/use-trace-or-branch-spans.d.ts.map +1 -0
  459. package/dist/hooks/traces/use-trace-query.d.ts +106 -0
  460. package/dist/hooks/traces/use-trace-query.d.ts.map +1 -0
  461. package/dist/hooks/traces/use-trace-spans.d.ts +46 -0
  462. package/dist/hooks/traces/use-trace-spans.d.ts.map +1 -0
  463. package/dist/hooks/traces/use-trace-usage.d.ts +10 -0
  464. package/dist/hooks/traces/use-trace-usage.d.ts.map +1 -0
  465. package/dist/hooks/traces/use-traces.d.ts +244 -0
  466. package/dist/hooks/traces/use-traces.d.ts.map +1 -0
  467. package/dist/hooks/vectors/index.cjs +18 -0
  468. package/dist/hooks/vectors/index.cjs.map +1 -0
  469. package/dist/hooks/vectors/index.d.ts +2 -0
  470. package/dist/hooks/vectors/index.d.ts.map +1 -0
  471. package/dist/hooks/vectors/index.js +17 -0
  472. package/dist/hooks/vectors/index.js.map +1 -0
  473. package/dist/hooks/vectors/use-vectors.d.ts +14 -0
  474. package/dist/hooks/vectors/use-vectors.d.ts.map +1 -0
  475. package/dist/hooks/voice/index.cjs +86 -0
  476. package/dist/hooks/voice/index.cjs.map +1 -0
  477. package/dist/hooks/voice/index.d.ts +2 -0
  478. package/dist/hooks/voice/index.d.ts.map +1 -0
  479. package/dist/hooks/voice/index.js +85 -0
  480. package/dist/hooks/voice/index.js.map +1 -0
  481. package/dist/hooks/voice/use-read-aloud.d.ts +20 -0
  482. package/dist/hooks/voice/use-read-aloud.d.ts.map +1 -0
  483. package/dist/hooks/workflows/index.cjs +169 -0
  484. package/dist/hooks/workflows/index.cjs.map +1 -0
  485. package/dist/hooks/workflows/index.d.ts +7 -0
  486. package/dist/hooks/workflows/index.d.ts.map +1 -0
  487. package/dist/hooks/workflows/index.js +153 -0
  488. package/dist/hooks/workflows/index.js.map +1 -0
  489. package/dist/hooks/workflows/use-workflow-runs.d.ts +51 -0
  490. package/dist/hooks/workflows/use-workflow-runs.d.ts.map +1 -0
  491. package/dist/hooks/workflows/use-workflow.d.ts +14 -0
  492. package/dist/hooks/workflows/use-workflow.d.ts.map +1 -0
  493. package/dist/hooks/workflows/use-workflows-run-counts.d.ts +25 -0
  494. package/dist/hooks/workflows/use-workflows-run-counts.d.ts.map +1 -0
  495. package/dist/hooks/workflows/use-workflows.d.ts +10 -0
  496. package/dist/hooks/workflows/use-workflows.d.ts.map +1 -0
  497. package/dist/hooks/workspace/client-utils.d.ts +5 -0
  498. package/dist/hooks/workspace/client-utils.d.ts.map +1 -0
  499. package/dist/hooks/workspace/compatibility.d.ts +22 -0
  500. package/dist/hooks/workspace/compatibility.d.ts.map +1 -0
  501. package/dist/hooks/workspace/file-type.d.ts +7 -0
  502. package/dist/hooks/workspace/file-type.d.ts.map +1 -0
  503. package/dist/hooks/workspace/index.cjs +614 -0
  504. package/dist/hooks/workspace/index.cjs.map +1 -0
  505. package/dist/hooks/workspace/index.d.ts +11 -0
  506. package/dist/hooks/workspace/index.d.ts.map +1 -0
  507. package/dist/hooks/workspace/index.js +584 -0
  508. package/dist/hooks/workspace/index.js.map +1 -0
  509. package/dist/hooks/workspace/types.d.ts +199 -0
  510. package/dist/hooks/workspace/types.d.ts.map +1 -0
  511. package/dist/hooks/workspace/use-skills-sh.d.ts +104 -0
  512. package/dist/hooks/workspace/use-skills-sh.d.ts.map +1 -0
  513. package/dist/hooks/workspace/use-stored-workspaces.d.ts +12 -0
  514. package/dist/hooks/workspace/use-stored-workspaces.d.ts.map +1 -0
  515. package/dist/hooks/workspace/use-workspace-directory.d.ts +13 -0
  516. package/dist/hooks/workspace/use-workspace-directory.d.ts.map +1 -0
  517. package/dist/hooks/workspace/use-workspace-file-content.d.ts +15 -0
  518. package/dist/hooks/workspace/use-workspace-file-content.d.ts.map +1 -0
  519. package/dist/hooks/workspace/use-workspace-search.d.ts +20 -0
  520. package/dist/hooks/workspace/use-workspace-search.d.ts.map +1 -0
  521. package/dist/hooks/workspace/use-workspace-skills.d.ts +23 -0
  522. package/dist/hooks/workspace/use-workspace-skills.d.ts.map +1 -0
  523. package/dist/hooks/workspace/use-workspace.d.ts +56 -0
  524. package/dist/hooks/workspace/use-workspace.d.ts.map +1 -0
  525. package/dist/hooks-Bt15IwzP.cjs +266 -0
  526. package/dist/hooks-Bt15IwzP.cjs.map +1 -0
  527. package/dist/hooks-Btt7PyI-.js +249 -0
  528. package/dist/hooks-Btt7PyI-.js.map +1 -0
  529. package/dist/hooks-Czqwakn0.cjs +1347 -0
  530. package/dist/hooks-Czqwakn0.cjs.map +1 -0
  531. package/dist/hooks-MRtQ3GE8.js +1330 -0
  532. package/dist/hooks-MRtQ3GE8.js.map +1 -0
  533. package/dist/index.cjs +56 -3001
  534. package/dist/index.cjs.map +1 -1
  535. package/dist/index.d.ts +5 -2
  536. package/dist/index.d.ts.map +1 -1
  537. package/dist/index.js +39 -2936
  538. package/dist/index.js.map +1 -1
  539. package/dist/lib/mastra-db/accumulator.d.ts +42 -0
  540. package/dist/lib/mastra-db/accumulator.d.ts.map +1 -0
  541. package/dist/lib/mastra-db/formatCompletionFeedback.d.ts.map +1 -0
  542. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +13 -0
  543. package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -0
  544. package/dist/lib/mastra-db/index.d.ts +6 -0
  545. package/dist/lib/mastra-db/index.d.ts.map +1 -0
  546. package/dist/lib/mastra-db/types.d.ts +173 -0
  547. package/dist/lib/mastra-db/types.d.ts.map +1 -0
  548. package/dist/map-5-4U5rwA.js +11 -0
  549. package/dist/map-5-4U5rwA.js.map +1 -0
  550. package/dist/map-BGoWBTGy.cjs +16 -0
  551. package/dist/map-BGoWBTGy.cjs.map +1 -0
  552. package/dist/mastra-client-context-DQ5z_ze9.js +49 -0
  553. package/dist/mastra-client-context-DQ5z_ze9.js.map +1 -0
  554. package/dist/mastra-client-context-DX8wJM9p.cjs +60 -0
  555. package/dist/mastra-client-context-DX8wJM9p.cjs.map +1 -0
  556. package/dist/mastra-client-context.d.ts +1 -1
  557. package/dist/mastra-client-context.d.ts.map +1 -1
  558. package/dist/mastra-react-provider.d.ts +2 -2
  559. package/dist/mastra-react-provider.d.ts.map +1 -1
  560. package/dist/query-utils-BVgE_xxj.cjs +173 -0
  561. package/dist/query-utils-BVgE_xxj.cjs.map +1 -0
  562. package/dist/query-utils-DvMERIwf.js +126 -0
  563. package/dist/query-utils-DvMERIwf.js.map +1 -0
  564. package/dist/react.css +72 -127
  565. package/dist/ui/Code/Code.d.ts +3 -2
  566. package/dist/ui/Code/Code.d.ts.map +1 -1
  567. package/dist/ui/Entity/Entity.d.ts +4 -4
  568. package/dist/ui/Entity/Entity.d.ts.map +1 -1
  569. package/dist/ui/Entity/Entry.d.ts +2 -2
  570. package/dist/ui/Entity/Entry.d.ts.map +1 -1
  571. package/dist/ui/Entity/ToolApproval.d.ts +5 -5
  572. package/dist/ui/Entity/ToolApproval.d.ts.map +1 -1
  573. package/dist/ui/Icon/Icon.d.ts +1 -1
  574. package/dist/ui/Icon/Icon.d.ts.map +1 -1
  575. package/dist/ui/IconButton/IconButton.d.ts +1 -1
  576. package/dist/ui/IconButton/IconButton.d.ts.map +1 -1
  577. package/dist/ui/Icons/AgentIcon.d.ts +1 -1
  578. package/dist/ui/Icons/AgentIcon.d.ts.map +1 -1
  579. package/dist/ui/Icons/ToolsIcon.d.ts +1 -1
  580. package/dist/ui/Icons/ToolsIcon.d.ts.map +1 -1
  581. package/dist/ui/Icons/WorkflowIcon.d.ts +1 -1
  582. package/dist/ui/Icons/WorkflowIcon.d.ts.map +1 -1
  583. package/dist/ui/Message/Message.d.ts +9 -9
  584. package/dist/ui/Message/Message.d.ts.map +1 -1
  585. package/dist/ui/MessageFactory/MessageFactory.d.ts +24 -0
  586. package/dist/ui/MessageFactory/MessageFactory.d.ts.map +1 -0
  587. package/dist/ui/MessageFactory/index.d.ts +3 -0
  588. package/dist/ui/MessageFactory/index.d.ts.map +1 -0
  589. package/dist/ui/MessageFactory/types.d.ts +183 -0
  590. package/dist/ui/MessageFactory/types.d.ts.map +1 -0
  591. package/dist/ui/Tooltip/Tooltip.d.ts +3 -3
  592. package/dist/ui/Tooltip/Tooltip.d.ts.map +1 -1
  593. package/dist/ui/index.cjs +561 -0
  594. package/dist/ui/index.cjs.map +1 -0
  595. package/dist/ui/index.d.ts +1 -0
  596. package/dist/ui/index.d.ts.map +1 -1
  597. package/dist/ui/index.js +484 -0
  598. package/dist/ui/index.js.map +1 -0
  599. package/dist/use-in-view-BxdrrnCw.cjs +36 -0
  600. package/dist/use-in-view-BxdrrnCw.cjs.map +1 -0
  601. package/dist/use-in-view-CyjKdplM.js +31 -0
  602. package/dist/use-in-view-CyjKdplM.js.map +1 -0
  603. package/dist/voice/index.d.ts +5 -0
  604. package/dist/voice/index.d.ts.map +1 -0
  605. package/dist/voice/play-stream-with-web-audio.d.ts +2 -0
  606. package/dist/voice/play-stream-with-web-audio.d.ts.map +1 -0
  607. package/dist/voice/record-mic-to-file.d.ts +2 -0
  608. package/dist/voice/record-mic-to-file.d.ts.map +1 -0
  609. package/dist/voice/use-speech-recognition.d.ts +20 -0
  610. package/dist/voice/use-speech-recognition.d.ts.map +1 -0
  611. package/dist/voice-Didej2E1.cjs +278 -0
  612. package/dist/voice-Didej2E1.cjs.map +1 -0
  613. package/dist/voice-ugGu7VyA.js +261 -0
  614. package/dist/voice-ugGu7VyA.js.map +1 -0
  615. package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts +8 -0
  616. package/dist/workflows/WorkflowStepFactory/WorkflowStepFactory.d.ts.map +1 -0
  617. package/dist/workflows/WorkflowStepFactory/index.d.ts +3 -0
  618. package/dist/workflows/WorkflowStepFactory/index.d.ts.map +1 -0
  619. package/dist/workflows/WorkflowStepFactory/types.d.ts +96 -0
  620. package/dist/workflows/WorkflowStepFactory/types.d.ts.map +1 -0
  621. package/dist/workflows/hooks.d.ts.map +1 -1
  622. package/dist/workflows/index.d.ts +1 -0
  623. package/dist/workflows/index.d.ts.map +1 -1
  624. package/dist/workflows/types.d.ts +4 -0
  625. package/dist/workflows/types.d.ts.map +1 -1
  626. package/dist/workflows/use-stream-workflow.d.ts +1 -29
  627. package/dist/workflows/use-stream-workflow.d.ts.map +1 -1
  628. package/package.json +70 -38
  629. package/CHANGELOG.md +0 -2495
  630. package/dist/lib/ai-sdk/index.d.ts +0 -5
  631. package/dist/lib/ai-sdk/index.d.ts.map +0 -1
  632. package/dist/lib/ai-sdk/memory/resolveInitialMessages.d.ts +0 -13
  633. package/dist/lib/ai-sdk/memory/resolveInitialMessages.d.ts.map +0 -1
  634. package/dist/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts +0 -11
  635. package/dist/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts.map +0 -1
  636. package/dist/lib/ai-sdk/transformers/types.d.ts +0 -11
  637. package/dist/lib/ai-sdk/transformers/types.d.ts.map +0 -1
  638. package/dist/lib/ai-sdk/types.d.ts +0 -143
  639. package/dist/lib/ai-sdk/types.d.ts.map +0 -1
  640. package/dist/lib/ai-sdk/utils/formatCompletionFeedback.d.ts.map +0 -1
  641. package/dist/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.d.ts +0 -11
  642. package/dist/lib/ai-sdk/utils/fromCoreUserMessageToUIMessage.d.ts.map +0 -1
  643. package/dist/lib/ai-sdk/utils/toAssistantUIMessage.d.ts +0 -15
  644. package/dist/lib/ai-sdk/utils/toAssistantUIMessage.d.ts.map +0 -1
  645. package/dist/lib/ai-sdk/utils/toUIMessage.d.ts +0 -18
  646. package/dist/lib/ai-sdk/utils/toUIMessage.d.ts.map +0 -1
  647. /package/dist/lib/{ai-sdk/utils → mastra-db}/formatCompletionFeedback.d.ts +0 -0
@@ -0,0 +1,1424 @@
1
+ import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
2
+ import { t as useInView } from "../../use-in-view-CyjKdplM.js";
3
+ import { n as is403ForbiddenError } from "../../query-utils-DvMERIwf.js";
4
+ import { t as getFeedbackRefetchInterval } from "../../feedback-refetch-interval-C12Nzb2r.js";
5
+ import { t as getOrCreate } from "../../map-5-4U5rwA.js";
6
+ import { MastraClient, MastraClientError } from "@mastra/client-js";
7
+ import { useEffect, useMemo, useRef, useState } from "react";
8
+ import { keepPreviousData, queryOptions, skipToken, useInfiniteQuery, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
9
+ import { EntityType } from "@mastra/core/observability";
10
+ // src/hooks/traces/discovery-cache.ts
11
+ /**
12
+ * How long discovery results (tags, environments, service names, entity
13
+ * names) stay fresh on the client.
14
+ *
15
+ * Discovery values are filter suggestions that change slowly, and the server
16
+ * caches them for 5 minutes anyway. Without a staleTime, React Query refetches
17
+ * on every mount and window focus, which pushes those refetches straight
18
+ * through to the store's discovery refresh. Matching the server TTL keeps the
19
+ * client from asking more often than the answer can change.
20
+ */
21
+ const DISCOVERY_STALE_TIME = 3e5;
22
+ // src/hooks/traces/use-branch.ts
23
+ /**
24
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
25
+ */
26
+ function useBranch({ traceId, spanId, depth, queryOptions }) {
27
+ const client = useMastraClient();
28
+ return useQuery({
29
+ queryKey: [
30
+ "branch",
31
+ traceId,
32
+ spanId,
33
+ depth
34
+ ],
35
+ queryFn: async () => {
36
+ if (!traceId || !spanId) throw new Error("traceId and spanId are required");
37
+ return client.getBranch({
38
+ traceId,
39
+ spanId,
40
+ depth
41
+ });
42
+ },
43
+ staleTime: 0,
44
+ ...queryOptions
45
+ });
46
+ }
47
+ // src/hooks/traces/types.ts
48
+ const ROOT_ENTITY_TYPES = {
49
+ AGENT: "agent",
50
+ WORKFLOW: "workflow_run",
51
+ SCORER: "scorer",
52
+ INGEST: "rag_ingestion",
53
+ CLASSIFIER: "classifier"
54
+ };
55
+ // src/hooks/traces/use-entity-names.ts
56
+ function resolveEntityType(entityType) {
57
+ return Object.values(EntityType).find((candidate) => candidate === entityType);
58
+ }
59
+ const useEntityNames = ({ entityType, rootOnly = false, queryOptions } = {}) => {
60
+ const client = useMastraClient();
61
+ return useQuery({
62
+ queryKey: entityType ? [
63
+ "observability-entity-names",
64
+ "by-type",
65
+ entityType
66
+ ] : [
67
+ "observability-entity-names",
68
+ "all",
69
+ rootOnly ? "root-only" : "all-types"
70
+ ],
71
+ queryFn: async () => {
72
+ try {
73
+ if (entityType) {
74
+ const resolvedEntityType = resolveEntityType(entityType);
75
+ if (!resolvedEntityType) return { names: [] };
76
+ return await client.getEntityNames({ entityType: resolvedEntityType });
77
+ }
78
+ if (!rootOnly) return await client.getEntityNames();
79
+ const responses = await Promise.all(Object.values(ROOT_ENTITY_TYPES).map((rootEntityType) => {
80
+ const resolvedEntityType = resolveEntityType(rootEntityType);
81
+ if (!resolvedEntityType) return { names: [] };
82
+ return client.getEntityNames({ entityType: resolvedEntityType });
83
+ }));
84
+ return { names: Array.from(new Set(responses.flatMap((response) => response?.names ?? []))).sort() };
85
+ } catch {
86
+ return { names: [] };
87
+ }
88
+ },
89
+ select: (data) => data?.names ?? [],
90
+ retry: false,
91
+ staleTime: DISCOVERY_STALE_TIME,
92
+ ...queryOptions
93
+ });
94
+ };
95
+ // src/hooks/traces/use-environments.ts
96
+ const useEnvironments = ({ queryOptions } = {}) => {
97
+ const client = useMastraClient();
98
+ return useQuery({
99
+ queryKey: ["observability-environments"],
100
+ queryFn: async () => {
101
+ try {
102
+ return await client.getEnvironments();
103
+ } catch {
104
+ return { environments: [] };
105
+ }
106
+ },
107
+ select: (data) => data?.environments ?? [],
108
+ retry: false,
109
+ staleTime: DISCOVERY_STALE_TIME,
110
+ ...queryOptions
111
+ });
112
+ };
113
+ // src/hooks/traces/use-service-names.ts
114
+ const useServiceNames = ({ queryOptions } = {}) => {
115
+ const client = useMastraClient();
116
+ return useQuery({
117
+ queryKey: ["observability-service-names"],
118
+ queryFn: async () => {
119
+ try {
120
+ return await client.getServiceNames();
121
+ } catch {
122
+ return { serviceNames: [] };
123
+ }
124
+ },
125
+ select: (data) => data?.serviceNames ?? [],
126
+ retry: false,
127
+ staleTime: DISCOVERY_STALE_TIME,
128
+ ...queryOptions
129
+ });
130
+ };
131
+ // src/hooks/traces/use-span-detail.ts
132
+ const IMMUTABLE_CACHE_TIME$1 = 2592e6;
133
+ /**
134
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
135
+ */
136
+ function useSpanDetail({ traceId, spanId, queryOptions }) {
137
+ const client = useMastraClient();
138
+ return useQuery({
139
+ queryKey: [
140
+ "span-detail",
141
+ traceId,
142
+ spanId
143
+ ],
144
+ queryFn: async () => {
145
+ if (!traceId || !spanId) throw new Error("Trace ID and Span ID are required");
146
+ return client.getSpan(traceId, spanId);
147
+ },
148
+ staleTime: (query) => {
149
+ if (query.state.data?.span?.endedAt) return IMMUTABLE_CACHE_TIME$1;
150
+ return 0;
151
+ },
152
+ ...queryOptions
153
+ });
154
+ }
155
+ // src/hooks/traces/use-tags.ts
156
+ const useTags = ({ queryOptions } = {}) => {
157
+ const client = useMastraClient();
158
+ return useQuery({
159
+ queryKey: ["observability-tags"],
160
+ queryFn: async () => {
161
+ try {
162
+ return await client.getTags();
163
+ } catch {
164
+ return { tags: [] };
165
+ }
166
+ },
167
+ select: (data) => data?.tags ?? [],
168
+ retry: false,
169
+ staleTime: DISCOVERY_STALE_TIME,
170
+ ...queryOptions
171
+ });
172
+ };
173
+ // src/hooks/traces/use-thread-has-other-traces.ts
174
+ /**
175
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
176
+ */
177
+ function useThreadHasOtherTraces({ threadId, queryOptions }) {
178
+ const client = useMastraClient();
179
+ const { data } = useQuery({
180
+ queryKey: ["thread-trace-count", threadId],
181
+ queryFn: () => client.listTracesLight({
182
+ filters: { threadId: threadId ?? "" },
183
+ pagination: {
184
+ page: 0,
185
+ perPage: 25
186
+ }
187
+ }),
188
+ select: (response) => (response.spans?.length ?? 0) > 1,
189
+ ...queryOptions
190
+ });
191
+ return data ?? false;
192
+ }
193
+ // src/hooks/traces/use-trace-light-spans.ts
194
+ const IMMUTABLE_CACHE_TIME = 2592e6;
195
+ /**
196
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
197
+ */
198
+ function useTraceLightSpans({ traceId, queryOptions }) {
199
+ const client = useMastraClient();
200
+ return useQuery({
201
+ queryKey: ["trace-light-spans", traceId],
202
+ queryFn: async () => {
203
+ if (!traceId) throw new Error("Trace ID is required");
204
+ return await client.getTraceLight(traceId);
205
+ },
206
+ staleTime: (query) => {
207
+ if (query.state.data?.spans.every((d) => Boolean(d.endedAt))) return IMMUTABLE_CACHE_TIME;
208
+ return 0;
209
+ },
210
+ ...queryOptions
211
+ });
212
+ }
213
+ // src/hooks/traces/use-trace-spans.ts
214
+ const traceSpansQueryOptions = (client, traceId) => queryOptions({
215
+ queryKey: ["trace-spans", traceId],
216
+ queryFn: async () => {
217
+ if (!traceId) throw new Error("Trace ID is required");
218
+ return await client.getTrace(traceId);
219
+ },
220
+ staleTime: 0
221
+ });
222
+ /**
223
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
224
+ */
225
+ function useTraceSpans({ traceId, passive = false, queryOptions }) {
226
+ const client = useMastraClient();
227
+ const { queryKey, queryFn, enabled, staleTime } = traceSpansQueryOptions(client, traceId);
228
+ return useQuery({
229
+ queryKey,
230
+ queryFn,
231
+ enabled,
232
+ staleTime,
233
+ refetchOnMount: !passive,
234
+ refetchOnWindowFocus: !passive,
235
+ refetchOnReconnect: !passive,
236
+ ...queryOptions
237
+ });
238
+ }
239
+ /**
240
+ * Returns a function that loads a full trace through the shared `trace-spans` cache, so an
241
+ * imperative read (e.g. an export) and the trace panel always see the same payload.
242
+ */
243
+ function useFetchTraceSpans() {
244
+ const client = useMastraClient();
245
+ const queryClient = useQueryClient();
246
+ return (traceId) => queryClient.fetchQuery(traceSpansQueryOptions(client, traceId));
247
+ }
248
+ /**
249
+ * Observes the `trace-spans` query of several traces at once and projects each one with `select`.
250
+ * Traces still loading (or failed) yield `fallback(traceId)` so the result always lines up with `traceIds`.
251
+ */
252
+ function useTraceSpansQueries({ traceIds, select, fallback, queryOptions }) {
253
+ const client = useMastraClient();
254
+ return useQueries({
255
+ queries: traceIds.map((traceId) => ({
256
+ ...traceSpansQueryOptions(client, traceId),
257
+ refetchOnMount: false,
258
+ refetchOnWindowFocus: false,
259
+ refetchOnReconnect: false,
260
+ select: (data) => select(traceId, data),
261
+ ...queryOptions
262
+ })),
263
+ combine: (results) => results.map((result, index) => result.data === void 0 ? fallback(traceIds[index] ?? "") : result.data)
264
+ });
265
+ }
266
+ // src/hooks/traces/use-trace-or-branch-spans.ts
267
+ /**
268
+ * Unified data source for the trace/span detail panel. Returns trace spans (full tree from the
269
+ * root) in traces mode, or branch spans (subtree rooted at `anchorSpanId`) in branches mode.
270
+ * Only the active query fires; the inactive one is disabled via its `enabled` flag.
271
+ *
272
+ * Both modes carry full span payloads: the panel renders and searches them, so a lightweight
273
+ * projection here would hide content from the reader looking straight at it.
274
+ */
275
+ function useTraceOrBranchSpans({ traceId, anchorSpanId, listMode, depth, queryOptions }) {
276
+ const isBranches = listMode === "branches";
277
+ const traceQuery = useTraceSpans({
278
+ traceId: isBranches ? null : traceId,
279
+ queryOptions: {
280
+ enabled: !isBranches && !!traceId,
281
+ ...queryOptions?.trace
282
+ }
283
+ });
284
+ const branchQuery = useBranch({
285
+ traceId: isBranches ? traceId : null,
286
+ spanId: isBranches ? anchorSpanId : null,
287
+ depth,
288
+ queryOptions: {
289
+ enabled: isBranches && !!traceId && !!anchorSpanId,
290
+ ...queryOptions?.branch
291
+ }
292
+ });
293
+ if (isBranches) return {
294
+ spans: branchQuery.data?.spans,
295
+ anchorSpanId: anchorSpanId ?? void 0,
296
+ isLoading: branchQuery.isLoading,
297
+ isError: branchQuery.isError,
298
+ error: branchQuery.error
299
+ };
300
+ return {
301
+ spans: traceQuery.data?.spans,
302
+ anchorSpanId: void 0,
303
+ isLoading: traceQuery.isLoading,
304
+ isError: traceQuery.isError,
305
+ error: traceQuery.error
306
+ };
307
+ }
308
+ // src/hooks/traces/use-span-aggregate.ts
309
+ /**
310
+ * Runs `aggregateSpans()` for `request`. Check `useSpanAggregateAvailable()` before enabling it.
311
+ *
312
+ * Like `useTraceAggregate()`, it doesn't poll or retry: the client already retries server errors,
313
+ * and a rejected request (4xx) fails once.
314
+ */
315
+ function useSpanAggregate({ request, enabled = true, queryOptions }) {
316
+ const client = useMastraClient();
317
+ return useQuery({
318
+ queryKey: ["span-aggregate", request],
319
+ queryFn: () => client.aggregateSpans(request),
320
+ enabled,
321
+ retry: false,
322
+ refetchOnWindowFocus: false,
323
+ ...queryOptions
324
+ });
325
+ }
326
+ // src/hooks/traces/use-trace-aggregate.ts
327
+ /**
328
+ * Runs `aggregateTraces()` for `request`. Check `useTraceAggregateAvailable()` before enabling it.
329
+ *
330
+ * It doesn't poll: grouped requests over large tenants take seconds, so it refetches only when the
331
+ * request changes or the caller calls `refetch()`. The client already retries server errors, so
332
+ * React Query doesn't retry on top of it, and a rejected request (4xx) fails once.
333
+ */
334
+ function useTraceAggregate({ request, enabled = true, queryOptions }) {
335
+ const client = useMastraClient();
336
+ return useQuery({
337
+ queryKey: ["trace-aggregate", request],
338
+ queryFn: ({ signal }) => client.aggregateTraces(request, { signal }),
339
+ enabled,
340
+ retry: false,
341
+ refetchOnWindowFocus: false,
342
+ ...queryOptions
343
+ });
344
+ }
345
+ // src/hooks/traces/use-trace-query.ts
346
+ const TRACE_QUERY_PER_PAGE = 25;
347
+ /** Max traces per delta request; the server caps `limit` at 100. */
348
+ const TRACE_QUERY_DELTA_LIMIT = 100;
349
+ function getTraceQueryNextPageParam(lastPage) {
350
+ return lastPage?.page.next ?? void 0;
351
+ }
352
+ function selectTraceQueryTraces(data) {
353
+ const seen = /* @__PURE__ */ new Set();
354
+ return data.pages.flatMap((page) => page.traces.filter((trace) => {
355
+ if (seen.has(trace.traceId)) return false;
356
+ seen.add(trace.traceId);
357
+ return true;
358
+ }));
359
+ }
360
+ const toIsoString = (value) => typeof value === "string" ? value : value.toISOString();
361
+ /** Maps a legacy light root span to a trace-query row. The light record carries no
362
+ * environment, so it stays null. Running spans have no `endedAt` and may carry a
363
+ * status outside the query API's enum; both are kept as-is (the list view handles them), hence the
364
+ * assertion at this compatibility boundary. */
365
+ function lightSpanToTraceQueryTrace(span) {
366
+ return {
367
+ traceId: span.traceId,
368
+ rootSpanId: span.spanId,
369
+ name: span.name,
370
+ entityId: span.entityId ?? null,
371
+ parentSpanId: span.parentSpanId ?? null,
372
+ createdAt: toIsoString(span.createdAt),
373
+ metadata: span.metadata ?? null,
374
+ inputPreview: span.inputPreview ?? null,
375
+ outputPreview: span.outputPreview ?? null,
376
+ errorPreview: span.errorPreview ?? null,
377
+ threadId: span.threadId ?? null,
378
+ resourceId: span.resourceId ?? null,
379
+ startedAt: toIsoString(span.startedAt),
380
+ endedAt: span.endedAt == null ? span.endedAt : toIsoString(span.endedAt),
381
+ entityName: span.entityName ?? null,
382
+ entityType: span.entityType ?? null,
383
+ environment: null,
384
+ status: span.status
385
+ };
386
+ }
387
+ function selectLegacyTraceQueryTraces(data) {
388
+ const seen = /* @__PURE__ */ new Set();
389
+ return data.pages.flatMap((page) => page.spans.flatMap((span) => {
390
+ if (seen.has(span.traceId)) return [];
391
+ seen.add(span.traceId);
392
+ return [lightSpanToTraceQueryTrace(span)];
393
+ }));
394
+ }
395
+ function getLegacyTraceQueryNextPageParam(lastPage) {
396
+ return lastPage.pagination?.hasMore ? lastPage.pagination.page + 1 : void 0;
397
+ }
398
+ /** Cache key of `useTraceQuery`'s trace-query list. Pass the same `query` and `limit` to share it. */
399
+ const traceQueryKey = (query, limit = 25) => [
400
+ "trace-query",
401
+ query,
402
+ limit
403
+ ];
404
+ function traceSortValue(trace, field) {
405
+ if (field === "timeToFirstChunkMs" || field === "timeToFirstTokenMs") return trace[field] ?? null;
406
+ const value = trace[field];
407
+ return value == null ? null : Date.parse(value);
408
+ }
409
+ /** Mirrors the server's keyset order: empty values last in both directions, ties by ascending `traceId`. */
410
+ function compareTraces(orderBy) {
411
+ return (a, b) => {
412
+ const va = traceSortValue(a, orderBy.field);
413
+ const vb = traceSortValue(b, orderBy.field);
414
+ if (va !== vb) {
415
+ if (va === null) return 1;
416
+ if (vb === null) return -1;
417
+ return orderBy.direction === "asc" ? va - vb : vb - va;
418
+ }
419
+ return a.traceId < b.traceId ? -1 : a.traceId > b.traceId ? 1 : 0;
420
+ };
421
+ }
422
+ /**
423
+ * Merges delta-polled traces into the pages of a `useTraceQuery` list, without mutating `data`.
424
+ * A trace already on a page is replaced in place when its sort value is unchanged; otherwise it is
425
+ * removed and placed again like a new trace (sorting by `endedAt`, a running trace moves once it
426
+ * ends). A new trace goes into the first page whose last row sorts after it; when no loaded page does, it is
427
+ * appended to the last page if that is the end of the list, and skipped otherwise, since keyset
428
+ * pagination returns it once the user scrolls there. Page cursors are kept as they are, and `data`
429
+ * itself is returned when nothing changed.
430
+ */
431
+ function mergeTraceQueryDelta(data, traces, orderBy) {
432
+ if (traces.length === 0 || data.pages.length === 0) return data;
433
+ const incoming = new Map(traces.map((trace) => [trace.traceId, trace]));
434
+ const rows = data.pages.map((page) => page.traces);
435
+ const changed = /* @__PURE__ */ new Set();
436
+ const write = (pageIndex, next) => {
437
+ rows[pageIndex] = next;
438
+ changed.add(pageIndex);
439
+ };
440
+ const sortBy = orderBy?.[0] ?? {
441
+ field: "startedAt",
442
+ direction: "desc"
443
+ };
444
+ const compare = compareTraces(sortBy);
445
+ const replacedInPlace = /* @__PURE__ */ new Set();
446
+ rows.forEach((pageRows, pageIndex) => {
447
+ if (!pageRows.some((row) => incoming.has(row.traceId))) return;
448
+ const next = [];
449
+ for (const row of pageRows) {
450
+ const update = incoming.get(row.traceId);
451
+ if (!update) next.push(row);
452
+ else if (traceSortValue(update, sortBy.field) === traceSortValue(row, sortBy.field)) {
453
+ next.push(update);
454
+ replacedInPlace.add(row.traceId);
455
+ }
456
+ }
457
+ write(pageIndex, next);
458
+ });
459
+ for (const traceId of replacedInPlace) incoming.delete(traceId);
460
+ const lastIndex = rows.length - 1;
461
+ for (const trace of incoming.values()) {
462
+ let pageIndex = rows.findIndex((pageRows) => {
463
+ const last = pageRows[pageRows.length - 1];
464
+ return last !== void 0 && compare(trace, last) < 0;
465
+ });
466
+ if (pageIndex === -1) {
467
+ if (data.pages[lastIndex].page.next !== null) continue;
468
+ pageIndex = lastIndex;
469
+ }
470
+ const pageRows = rows[pageIndex];
471
+ const at = pageRows.findIndex((row) => compare(trace, row) < 0);
472
+ write(pageIndex, at === -1 ? [...pageRows, trace] : [
473
+ ...pageRows.slice(0, at),
474
+ trace,
475
+ ...pageRows.slice(at)
476
+ ]);
477
+ }
478
+ if (changed.size === 0) return data;
479
+ return {
480
+ ...data,
481
+ pages: data.pages.map((page, pageIndex) => changed.has(pageIndex) ? {
482
+ ...page,
483
+ traces: rows[pageIndex]
484
+ } : page)
485
+ };
486
+ }
487
+ /** Queries traces with cursor pagination and viewport-driven loading. */
488
+ function useTraceQuery({ query, limit = 25, enabled = true, withQueryTrace = true, legacyFilters, queryOptions }) {
489
+ const client = useMastraClient();
490
+ const { inView, setRef: setEndOfListElement } = useInView();
491
+ const queryResult = useInfiniteQuery({
492
+ queryKey: traceQueryKey(query, limit),
493
+ queryFn: query ? async ({ pageParam }) => {
494
+ const response = await new MastraClient({
495
+ ...client.options,
496
+ retries: 0
497
+ }).queryTraces({
498
+ ...query,
499
+ page: {
500
+ limit,
501
+ after: pageParam ?? null
502
+ }
503
+ });
504
+ if ("traces" in response && "page" in response) return response;
505
+ throw new Error("Expected a cursor-paginated trace query response");
506
+ } : skipToken,
507
+ initialPageParam: void 0,
508
+ getNextPageParam: getTraceQueryNextPageParam,
509
+ select: selectTraceQueryTraces,
510
+ retry: false,
511
+ placeholderData: keepPreviousData,
512
+ enabled: enabled && withQueryTrace,
513
+ ...queryOptions?.traceQuery
514
+ });
515
+ const orderBy = query?.orderBy;
516
+ const legacyDirection = orderBy?.[0]?.direction === "asc" ? "ASC" : "DESC";
517
+ const legacyResult = useInfiniteQuery({
518
+ queryKey: [
519
+ "trace-query-legacy",
520
+ legacyFilters,
521
+ limit,
522
+ orderBy
523
+ ],
524
+ queryFn: ({ pageParam }) => client.listTracesLight({
525
+ filters: legacyFilters,
526
+ pagination: {
527
+ page: pageParam,
528
+ perPage: limit
529
+ },
530
+ orderBy: {
531
+ field: "startedAt",
532
+ direction: legacyDirection
533
+ }
534
+ }),
535
+ initialPageParam: 0,
536
+ getNextPageParam: getLegacyTraceQueryNextPageParam,
537
+ select: selectLegacyTraceQueryTraces,
538
+ retry: false,
539
+ placeholderData: keepPreviousData,
540
+ enabled: enabled && !withQueryTrace,
541
+ ...queryOptions?.legacy
542
+ });
543
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isPlaceholderData, isFetching, isRefetching, fetchStatus, isError, error, refetch, isFetchNextPageError } = withQueryTrace ? queryResult : legacyResult;
544
+ useEffect(() => {
545
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
546
+ }, [
547
+ enabled,
548
+ inView,
549
+ hasNextPage,
550
+ isFetching,
551
+ isFetchNextPageError,
552
+ fetchNextPage
553
+ ]);
554
+ return {
555
+ data,
556
+ hasNextPage,
557
+ isFetchingNextPage,
558
+ fetchNextPage,
559
+ isLoading,
560
+ isPlaceholderData,
561
+ isFetching,
562
+ isRefetching,
563
+ fetchStatus,
564
+ isError,
565
+ error,
566
+ refetch,
567
+ setEndOfListElement
568
+ };
569
+ }
570
+ function omitOrderBy({ orderBy: _orderBy, ...rest }) {
571
+ return rest;
572
+ }
573
+ /** Request timeouts and rate limits clear up on their own, unlike the other 4xx refusals. */
574
+ const TRANSIENT_CLIENT_ERROR_STATUSES = /* @__PURE__ */ new Set([408, 429]);
575
+ /** The server refused the request or does not support delta polling; polling again cannot change that. */
576
+ function isRejectedDeltaRequest(error) {
577
+ if (!(error instanceof MastraClientError) || TRANSIENT_CLIENT_ERROR_STATUSES.has(error.status)) return false;
578
+ return error.status >= 400 && error.status < 500 || error.status === 501;
579
+ }
580
+ const isCursorConflict = (error) => error instanceof MastraClientError && error.status === 409;
581
+ /**
582
+ * Polls `queryTraces({ mode: 'delta' })` and merges new or updated traces into the list of a
583
+ * `useTraceQuery` rendered with the same `query` and `limit`. The first request only establishes
584
+ * the server cursor; each later poll drains every batch since that cursor. A cursor conflict (409)
585
+ * starts over with a new cursor. A poll that returns while the list is loading a page, or before
586
+ * the list has loaded at all, keeps its cursor and asks again on the next poll.
587
+ *
588
+ * The cursor is keyed on the query without `orderBy` (delta polls cannot sort) and on `limit`, so
589
+ * re-sorting the list keeps polling from the same cursor, and lists with different page sizes each
590
+ * get their own cursor.
591
+ *
592
+ * Requires the `deltaPolling` capability (see `useTraceQueryDeltaPollingAvailable`). The list's
593
+ * `timeRange.to` must not move between polls, so a live list needs a `to` in the future.
594
+ *
595
+ * Known limitation: the cursor is established in parallel with the list's first page, so a trace
596
+ * that completes between the first page's read and the cursor can be missed until the list is
597
+ * refetched. Traces returned by both are merged by `traceId`.
598
+ */
599
+ function useTraceQueryLatest({ query, limit = 25, enabled = true, refetchInterval = false, queryOptions }) {
600
+ const client = useMastraClient();
601
+ const queryClient = useQueryClient();
602
+ const deltaQuery = query && omitOrderBy(query);
603
+ const queryKey = [
604
+ "trace-query-latest",
605
+ deltaQuery,
606
+ limit
607
+ ];
608
+ return useQuery({
609
+ queryKey,
610
+ queryFn: query && deltaQuery ? async () => {
611
+ const mastra = new MastraClient({
612
+ ...client.options,
613
+ retries: 0
614
+ });
615
+ const bootstrap = async () => {
616
+ return { deltaCursor: (await mastra.queryTraces({
617
+ ...deltaQuery,
618
+ mode: "delta"
619
+ })).deltaCursor };
620
+ };
621
+ const previous = queryClient.getQueryData(queryKey);
622
+ if (!previous) return bootstrap();
623
+ const traces = [];
624
+ let deltaCursor = previous.deltaCursor;
625
+ try {
626
+ for (let hasMore = true; hasMore;) {
627
+ const response = await mastra.queryTraces({
628
+ ...deltaQuery,
629
+ mode: "delta",
630
+ after: deltaCursor,
631
+ limit: 100
632
+ });
633
+ traces.push(...response.traces);
634
+ deltaCursor = response.deltaCursor;
635
+ hasMore = response.delta.hasMore;
636
+ }
637
+ } catch (error) {
638
+ if (isCursorConflict(error)) return bootstrap();
639
+ throw error;
640
+ }
641
+ const listKey = traceQueryKey(query, limit);
642
+ const listState = queryClient.getQueryState(listKey);
643
+ if (!listState?.data || listState.fetchStatus === "fetching") return previous;
644
+ queryClient.setQueryData(listKey, (data) => data ? mergeTraceQueryDelta(data, traces, query.orderBy) : data);
645
+ return { deltaCursor };
646
+ } : skipToken,
647
+ retry: false,
648
+ refetchInterval: (q) => isRejectedDeltaRequest(q.state.error) ? false : refetchInterval,
649
+ refetchIntervalInBackground: false,
650
+ enabled: enabled && !!query,
651
+ ...queryOptions
652
+ });
653
+ }
654
+ // src/hooks/traces/use-query-spans.ts
655
+ const SPAN_QUERY_PER_PAGE = 25;
656
+ const selectSpans = (data) => data.pages.flatMap((page) => page.spans);
657
+ /** Queries completed spans with cursor pagination and viewport-driven loading. */
658
+ function useQuerySpans({ query, limit = 25, enabled = true, queryOptions }) {
659
+ const client = useMastraClient();
660
+ const { inView, setRef: setEndOfListElement } = useInView();
661
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = useInfiniteQuery({
662
+ queryKey: [
663
+ "span-query",
664
+ query,
665
+ limit
666
+ ],
667
+ queryFn: query ? ({ pageParam }) => client.querySpans({
668
+ ...query,
669
+ page: pageParam ? {
670
+ limit,
671
+ after: pageParam
672
+ } : { limit }
673
+ }) : skipToken,
674
+ initialPageParam: void 0,
675
+ getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
676
+ select: selectSpans,
677
+ retry: false,
678
+ placeholderData: keepPreviousData,
679
+ enabled,
680
+ ...queryOptions
681
+ });
682
+ useEffect(() => {
683
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
684
+ }, [
685
+ enabled,
686
+ inView,
687
+ hasNextPage,
688
+ isFetching,
689
+ isFetchNextPageError,
690
+ fetchNextPage
691
+ ]);
692
+ return {
693
+ spans: data,
694
+ hasNextPage,
695
+ isFetchingNextPage,
696
+ fetchNextPage: () => void fetchNextPage(),
697
+ setEndOfListElement,
698
+ isLoading,
699
+ isFetching,
700
+ isError,
701
+ error,
702
+ refetch: () => void refetch()
703
+ };
704
+ }
705
+ // src/hooks/traces/use-query-threads.ts
706
+ const THREAD_QUERY_PER_PAGE = 25;
707
+ const selectThreads = (data) => data.pages.flatMap((page) => page.threads);
708
+ /** Queries thread rows with cursor pagination and viewport-driven loading. */
709
+ function useQueryThreads({ query, limit = 25, enabled = true, queryOptions }) {
710
+ const client = useMastraClient();
711
+ const { inView, setRef: setEndOfListElement } = useInView();
712
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = useInfiniteQuery({
713
+ queryKey: [
714
+ "thread-query",
715
+ query,
716
+ limit
717
+ ],
718
+ queryFn: query ? ({ pageParam }) => client.queryTraceThreads({
719
+ ...query,
720
+ page: pageParam ? {
721
+ limit,
722
+ after: pageParam
723
+ } : { limit }
724
+ }) : skipToken,
725
+ initialPageParam: void 0,
726
+ getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
727
+ select: selectThreads,
728
+ retry: false,
729
+ placeholderData: keepPreviousData,
730
+ enabled,
731
+ ...queryOptions
732
+ });
733
+ useEffect(() => {
734
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
735
+ }, [
736
+ enabled,
737
+ inView,
738
+ hasNextPage,
739
+ isFetching,
740
+ isFetchNextPageError,
741
+ fetchNextPage
742
+ ]);
743
+ return {
744
+ threads: data,
745
+ hasNextPage,
746
+ isFetchingNextPage,
747
+ fetchNextPage: () => void fetchNextPage(),
748
+ setEndOfListElement,
749
+ isLoading,
750
+ isFetching,
751
+ isError,
752
+ error,
753
+ refetch: () => void refetch()
754
+ };
755
+ }
756
+ // src/hooks/traces/use-trace-usage.ts
757
+ const INPUT_TOKEN_METRIC = "mastra_model_total_input_tokens";
758
+ const OUTPUT_TOKEN_METRIC = "mastra_model_total_output_tokens";
759
+ const TRACE_IDS_PER_REQUEST = 500;
760
+ function chunkTraceIds(traceIds) {
761
+ const chunks = [];
762
+ for (let index = 0; index < traceIds.length; index += TRACE_IDS_PER_REQUEST) chunks.push(traceIds.slice(index, index + TRACE_IDS_PER_REQUEST));
763
+ return chunks;
764
+ }
765
+ function createTraceUsageAccumulator() {
766
+ return {
767
+ estimatedCost: 0,
768
+ hasEstimatedCost: false,
769
+ costUnits: /* @__PURE__ */ new Set(),
770
+ hasUnknownCostUnit: false
771
+ };
772
+ }
773
+ function addBreakdown(accumulators, response) {
774
+ for (const group of response.groups) {
775
+ const traceId = group.dimensions.traceId;
776
+ const metricName = group.dimensions.name;
777
+ if (!traceId || metricName !== INPUT_TOKEN_METRIC && metricName !== OUTPUT_TOKEN_METRIC) continue;
778
+ const accumulator = getOrCreate(accumulators, traceId, createTraceUsageAccumulator);
779
+ const tokenField = metricName === INPUT_TOKEN_METRIC ? "inputTokens" : "outputTokens";
780
+ accumulator[tokenField] = (accumulator[tokenField] ?? 0) + group.value;
781
+ if (group.estimatedCost == null) continue;
782
+ accumulator.estimatedCost += group.estimatedCost;
783
+ accumulator.hasEstimatedCost = true;
784
+ if (group.costUnit) accumulator.costUnits.add(group.costUnit.toLowerCase());
785
+ else accumulator.hasUnknownCostUnit = true;
786
+ }
787
+ }
788
+ function summarizeUsage(accumulators) {
789
+ const summaries = /* @__PURE__ */ new Map();
790
+ for (const [traceId, accumulator] of accumulators) {
791
+ const summary = {
792
+ inputTokens: accumulator.inputTokens,
793
+ outputTokens: accumulator.outputTokens
794
+ };
795
+ if (accumulator.hasEstimatedCost && !accumulator.hasUnknownCostUnit && accumulator.costUnits.size === 1) {
796
+ summary.estimatedCost = accumulator.estimatedCost;
797
+ summary.costUnit = [...accumulator.costUnits][0];
798
+ }
799
+ summaries.set(traceId, summary);
800
+ }
801
+ return summaries;
802
+ }
803
+ function useTraceUsage({ traceIds, enabled, autoRefetch, queryOptions }) {
804
+ const client = useMastraClient();
805
+ const uniqueTraceIds = [...new Set(traceIds)].toSorted();
806
+ const projectKey = `${client.options.baseUrl || (typeof window === "undefined" ? "local" : window.location.origin || "local")}:${client.options.apiPrefix ?? "/api"}`;
807
+ return useQuery({
808
+ queryKey: [
809
+ "trace-usage",
810
+ projectKey,
811
+ uniqueTraceIds
812
+ ],
813
+ enabled: enabled && uniqueTraceIds.length > 0,
814
+ queryFn: async () => {
815
+ const batches = chunkTraceIds(uniqueTraceIds);
816
+ const responses = await Promise.allSettled(batches.map((batch) => client.getMetricBreakdown({
817
+ name: [INPUT_TOKEN_METRIC, OUTPUT_TOKEN_METRIC],
818
+ aggregation: "sum",
819
+ groupBy: ["traceId", "name"],
820
+ filters: { traceIds: batch },
821
+ limit: batch.length * 2
822
+ })));
823
+ const accumulators = /* @__PURE__ */ new Map();
824
+ for (const response of responses) if (response.status === "fulfilled") addBreakdown(accumulators, response.value);
825
+ return summarizeUsage(accumulators);
826
+ },
827
+ placeholderData: (previousData, previousQuery) => previousQuery?.queryKey[1] === projectKey ? previousData : void 0,
828
+ refetchInterval: enabled && autoRefetch ? 1e4 : false,
829
+ ...queryOptions
830
+ });
831
+ }
832
+ // src/hooks/traces/use-traces.tsx
833
+ const deltaSupportByClient = /* @__PURE__ */ new WeakMap();
834
+ const lightListSupportByClient = /* @__PURE__ */ new WeakMap();
835
+ /** When the current run of light-endpoint 500s started, per client. Cleared by any light success. */
836
+ const lightListFirstServerErrorAtByClient = /* @__PURE__ */ new WeakMap();
837
+ /** A 500 is ambiguous — an old core's store throwing, or a transient fault (DB hiccup, timeout).
838
+ * Serve the request from the full endpoint either way, but only pin the session once the 500s
839
+ * have outlasted a blip; a hiccup would otherwise degrade the list until the tab is reloaded.
840
+ * Elapsed time, not a request count: the page refetch, the delta poll and the status refresh can
841
+ * fail in the same instant, and a fallback response still looks like a success to the delta query,
842
+ * so chase mode keeps re-polling every `deltaChaseIntervalMs` throughout the outage. */
843
+ const LIGHT_LIST_SERVER_ERROR_PIN_AFTER_MS = 1e4;
844
+ const DEFAULT_POLLING_CONFIG = {
845
+ deltaPollIntervalMs: 5e3,
846
+ deltaChaseIntervalMs: 100,
847
+ deltaLimit: 100,
848
+ pageModeRefetchIntervalMs: 1e4,
849
+ page0StatusRefreshIntervalMs: 6e4,
850
+ idleGuardThresholdMs: 9e5,
851
+ minRefetchSpinMs: 400,
852
+ deltaHighlightMs: 1e3
853
+ };
854
+ /** Returns true when the cursor should be considered stale and re-seeded.
855
+ * Exported for testing — pure function of timestamps. */
856
+ function shouldResetAfterIdle(lastSuccessAt, now, thresholdMs) {
857
+ if (lastSuccessAt === 0) return false;
858
+ return now - lastSuccessAt > thresholdMs;
859
+ }
860
+ function isHttp501(error) {
861
+ return error?.status === 501;
862
+ }
863
+ /** Only 404 and 500 can mean the light endpoint isn't served: 404 from servers without
864
+ * the route, 500 from cores whose store throws instead of serving the projection.
865
+ * Anything else (401, 403, 429, other 5xx, the 501 disabled-domain signal) is a
866
+ * condition the full endpoint would hit too, so it propagates instead of falling
867
+ * back — mirroring how the delta-support cache matches exactly 501. */
868
+ function lightListFallbackStatus(error) {
869
+ const status = error?.status;
870
+ return status === 404 || status === 500 ? status : void 0;
871
+ }
872
+ /** Whether a failed light-list request should pin the session to the full endpoint.
873
+ * `firstServerErrorAt` is undefined when this 500 opens a new run of them, so a single
874
+ * fault never pins. Exported for testing — pure function of the status and timestamps. */
875
+ function shouldPinLightList(status, firstServerErrorAt, now) {
876
+ if (status === 404) return true;
877
+ if (status !== 500) return false;
878
+ if (firstServerErrorAt === void 0) return false;
879
+ return now - firstServerErrorAt >= LIGHT_LIST_SERVER_ERROR_PIN_AFTER_MS;
880
+ }
881
+ const fetchTracesFn = async (args) => {
882
+ const { client, filters, listMode = "traces" } = args;
883
+ const params = args.mode === "delta" ? {
884
+ mode: "delta",
885
+ after: args.after,
886
+ limit: args.limit,
887
+ filters
888
+ } : {
889
+ pagination: {
890
+ page: args.page,
891
+ perPage: args.perPage
892
+ },
893
+ filters
894
+ };
895
+ if (listMode === "branches") return client.listBranches(params);
896
+ if (lightListSupportByClient.get(client) === "unsupported") return client.listTraces(params);
897
+ try {
898
+ const response = await client.listTracesLight(params);
899
+ if (args.mode !== "delta") {
900
+ const spans = response.spans ?? [];
901
+ if (spans.length > 0 && spans.every((span) => span.status === void 0)) {
902
+ lightListSupportByClient.set(client, "unsupported");
903
+ return client.listTraces(params);
904
+ }
905
+ }
906
+ lightListFirstServerErrorAtByClient.delete(client);
907
+ return response;
908
+ } catch (error) {
909
+ const status = lightListFallbackStatus(error);
910
+ if (status === void 0) throw error;
911
+ const now = Date.now();
912
+ const firstServerErrorAt = lightListFirstServerErrorAtByClient.get(client);
913
+ if (status === 500 && firstServerErrorAt === void 0) lightListFirstServerErrorAtByClient.set(client, now);
914
+ if (shouldPinLightList(status, firstServerErrorAt, now)) lightListSupportByClient.set(client, "unsupported");
915
+ return client.listTraces(params);
916
+ }
917
+ };
918
+ const TRACES_PER_PAGE = 25;
919
+ /** Returns the next page number if the server indicates more pages are available. */
920
+ function getTracesNextPageParam(lastPage, _allPages, lastPageParam) {
921
+ if (lastPage?.pagination?.hasMore) return lastPageParam + 1;
922
+ }
923
+ /** Branch rows are full spans and trace rows are lightweight; the list only reads the
924
+ * fields they share, so both are surfaced as `LightSpanRecord`. */
925
+ function getPageSpans(page) {
926
+ if ("branches" in page) return page.branches ?? [];
927
+ return page.spans ?? [];
928
+ }
929
+ /** Deduplicates trace/branch rows by traceId + spanId across all loaded pages.
930
+ * Also surfaces page 0's deltaCursor so the live-tail query can read it reactively. */
931
+ function selectUniqueTraces(data) {
932
+ const seen = /* @__PURE__ */ new Set();
933
+ return {
934
+ spans: data.pages.flatMap((page) => getPageSpans(page)).filter((span) => {
935
+ const key = `${span.traceId}:${span.spanId}`;
936
+ if (seen.has(key)) return false;
937
+ seen.add(key);
938
+ return true;
939
+ }),
940
+ deltaCursor: data.pages[0]?.deltaCursor
941
+ };
942
+ }
943
+ function rowKey(row) {
944
+ return `${row.traceId}:${row.spanId}`;
945
+ }
946
+ function indexRowsByKey(rows) {
947
+ return new Map(rows.map((row) => [rowKey(row), row]));
948
+ }
949
+ /** Replaces existing page-0 rows in place (keyed by traceId:spanId) with
950
+ * refreshed copies from the server. Rows the server doesn't return are kept
951
+ * as-is so delta-accumulated rows that have aged off the server's page 0
952
+ * aren't dropped from the UI. New rows aren't added here — delta polling
953
+ * delivers those. */
954
+ function refreshPage0Rows(old, refreshed, listMode) {
955
+ if (!old || old.pages.length === 0) return old;
956
+ const [firstPage, ...rest] = old.pages;
957
+ if (!firstPage) return old;
958
+ let updatedFirst;
959
+ if (listMode === "branches" && "branches" in firstPage && "branches" in refreshed) {
960
+ const refreshedByKey = indexRowsByKey(refreshed.branches ?? []);
961
+ if (refreshedByKey.size === 0) return old;
962
+ updatedFirst = {
963
+ ...firstPage,
964
+ branches: (firstPage.branches ?? []).map((existing) => refreshedByKey.get(rowKey(existing)) ?? existing)
965
+ };
966
+ } else if ("spans" in firstPage && "spans" in refreshed) {
967
+ const refreshedByKey = indexRowsByKey(refreshed.spans ?? []);
968
+ if (refreshedByKey.size === 0) return old;
969
+ updatedFirst = {
970
+ ...firstPage,
971
+ spans: (firstPage.spans ?? []).map((existing) => refreshedByKey.get(rowKey(existing)) ?? existing)
972
+ };
973
+ } else return old;
974
+ return {
975
+ ...old,
976
+ pages: [updatedFirst, ...rest]
977
+ };
978
+ }
979
+ /** Stable `startedAt DESC` sort matching the server's default page-mode
980
+ * ordering for both list endpoints. Rows missing `startedAt` sink to the
981
+ * bottom (compared as time 0). */
982
+ function sortRowsByStartedAtDesc(rows) {
983
+ return [...rows].sort((a, b) => {
984
+ const aTime = a.startedAt ? new Date(a.startedAt).getTime() : 0;
985
+ return (b.startedAt ? new Date(b.startedAt).getTime() : 0) - aTime;
986
+ });
987
+ }
988
+ /** Prepends delta-mode rows into page 0 and advances its deltaCursor.
989
+ * Delta responses come back in server cursor order (insertion order into
990
+ * the per-store delta index), not the `startedAt DESC` order page-mode
991
+ * uses — so we re-sort the merged page 0 to match what the user sees on
992
+ * a fresh page-mode load. Cross-page duplication is handled later by
993
+ * selectUniqueTraces. */
994
+ function mergeDeltaIntoPage0(old, delta, listMode) {
995
+ if (!old || old.pages.length === 0) return old;
996
+ const [firstPage, ...rest] = old.pages;
997
+ if (!firstPage) return old;
998
+ const nextCursor = delta.deltaCursor ?? firstPage.deltaCursor;
999
+ let updatedFirst;
1000
+ if (listMode === "branches" && "branches" in firstPage) {
1001
+ const newRows = delta.branches ?? [];
1002
+ updatedFirst = {
1003
+ ...firstPage,
1004
+ branches: sortRowsByStartedAtDesc([...newRows, ...firstPage.branches ?? []]),
1005
+ deltaCursor: nextCursor
1006
+ };
1007
+ } else if ("spans" in firstPage) {
1008
+ const newRows = delta.spans ?? [];
1009
+ updatedFirst = {
1010
+ ...firstPage,
1011
+ spans: sortRowsByStartedAtDesc([...newRows, ...firstPage.spans ?? []]),
1012
+ deltaCursor: nextCursor
1013
+ };
1014
+ } else return old;
1015
+ return {
1016
+ ...old,
1017
+ pages: [updatedFirst, ...rest]
1018
+ };
1019
+ }
1020
+ const useTraces = ({ filters, listMode = "traces", polling = {}, enabled = true, queryOptions }) => {
1021
+ 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;
1022
+ const client = useMastraClient();
1023
+ const queryClient = useQueryClient();
1024
+ const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();
1025
+ const [deltaSupport, setDeltaSupport] = useState(() => deltaSupportByClient.get(client) ?? "unknown");
1026
+ const deltaUnsupported = deltaSupport === "unsupported";
1027
+ const [autoRefetch, setAutoRefetch] = useState(true);
1028
+ const [recentlyAddedKeys, setRecentlyAddedKeys] = useState(() => /* @__PURE__ */ new Set());
1029
+ useEffect(() => {
1030
+ setRecentlyAddedKeys(/* @__PURE__ */ new Set());
1031
+ }, [listMode, filters]);
1032
+ const tracesQueryKey = [
1033
+ "traces",
1034
+ listMode,
1035
+ filters
1036
+ ];
1037
+ const query = useInfiniteQuery({
1038
+ queryKey: tracesQueryKey,
1039
+ enabled,
1040
+ queryFn: ({ pageParam }) => fetchTracesFn({
1041
+ client,
1042
+ page: pageParam,
1043
+ perPage: 25,
1044
+ filters,
1045
+ listMode
1046
+ }),
1047
+ initialPageParam: 0,
1048
+ getNextPageParam: getTracesNextPageParam,
1049
+ select: selectUniqueTraces,
1050
+ retry: false,
1051
+ refetchInterval: (q) => {
1052
+ if (is403ForbiddenError(q.state.error)) return false;
1053
+ if (!autoRefetch) return false;
1054
+ return deltaUnsupported ? pageModeRefetchIntervalMs : false;
1055
+ },
1056
+ ...queryOptions?.traces
1057
+ });
1058
+ const cursor = query.data?.deltaCursor;
1059
+ useEffect(() => {
1060
+ if (query.isSuccess && cursor === void 0 && deltaSupport === "unknown") {
1061
+ deltaSupportByClient.set(client, "unsupported");
1062
+ setDeltaSupport("unsupported");
1063
+ }
1064
+ }, [
1065
+ query.isSuccess,
1066
+ cursor,
1067
+ deltaSupport,
1068
+ client
1069
+ ]);
1070
+ const deltaQuery = useQuery({
1071
+ queryKey: [
1072
+ "traces-delta",
1073
+ listMode,
1074
+ filters
1075
+ ],
1076
+ queryFn: () => {
1077
+ const current = queryClient.getQueryData(tracesQueryKey)?.pages[0]?.deltaCursor;
1078
+ if (!current) return null;
1079
+ return fetchTracesFn({
1080
+ client,
1081
+ mode: "delta",
1082
+ after: current,
1083
+ limit: deltaLimit,
1084
+ filters,
1085
+ listMode
1086
+ });
1087
+ },
1088
+ enabled: enabled && !!cursor && !deltaUnsupported && autoRefetch,
1089
+ retry: false,
1090
+ refetchInterval: (q) => {
1091
+ if (q.state.error) return false;
1092
+ if (q.state.data?.delta?.hasMore) return deltaChaseIntervalMs;
1093
+ return deltaPollIntervalMs;
1094
+ },
1095
+ ...queryOptions?.delta
1096
+ });
1097
+ useEffect(() => {
1098
+ const result = deltaQuery.data;
1099
+ if (!result) return;
1100
+ queryClient.setQueryData(tracesQueryKey, (old) => mergeDeltaIntoPage0(old, result, listMode));
1101
+ const newRows = listMode === "branches" && "branches" in result ? result.branches ?? [] : "spans" in result ? result.spans ?? [] : [];
1102
+ if (newRows.length === 0) return;
1103
+ const keys = newRows.map((r) => `${r.traceId}:${r.spanId ?? ""}`);
1104
+ setRecentlyAddedKeys((prev) => {
1105
+ const next = new Set(prev);
1106
+ for (const k of keys) next.add(k);
1107
+ return next;
1108
+ });
1109
+ setTimeout(() => {
1110
+ setRecentlyAddedKeys((prev) => {
1111
+ const next = new Set(prev);
1112
+ for (const k of keys) next.delete(k);
1113
+ return next;
1114
+ });
1115
+ }, deltaHighlightMs);
1116
+ }, [
1117
+ deltaQuery.data,
1118
+ queryClient,
1119
+ listMode,
1120
+ filters,
1121
+ deltaHighlightMs
1122
+ ]);
1123
+ useEffect(() => {
1124
+ if (isHttp501(deltaQuery.error)) {
1125
+ deltaSupportByClient.set(client, "unsupported");
1126
+ setDeltaSupport("unsupported");
1127
+ }
1128
+ }, [deltaQuery.error, client]);
1129
+ const statusRefreshQuery = useQuery({
1130
+ queryKey: [
1131
+ "traces-status-refresh",
1132
+ listMode,
1133
+ filters
1134
+ ],
1135
+ queryFn: () => fetchTracesFn({
1136
+ client,
1137
+ page: 0,
1138
+ perPage: 25,
1139
+ filters,
1140
+ listMode
1141
+ }),
1142
+ enabled: enabled && !!cursor && !deltaUnsupported && autoRefetch,
1143
+ refetchInterval: page0StatusRefreshIntervalMs,
1144
+ refetchOnMount: false,
1145
+ retry: false,
1146
+ ...queryOptions?.statusRefresh
1147
+ });
1148
+ useEffect(() => {
1149
+ const result = statusRefreshQuery.data;
1150
+ if (!result) return;
1151
+ queryClient.setQueryData(tracesQueryKey, (old) => refreshPage0Rows(old, result, listMode));
1152
+ }, [
1153
+ statusRefreshQuery.data,
1154
+ queryClient,
1155
+ listMode,
1156
+ filters
1157
+ ]);
1158
+ const lastSuccessAtRef = useRef(0);
1159
+ useEffect(() => {
1160
+ const ts = Math.max(query.dataUpdatedAt, deltaQuery.dataUpdatedAt, statusRefreshQuery.dataUpdatedAt);
1161
+ if (ts > lastSuccessAtRef.current) lastSuccessAtRef.current = ts;
1162
+ }, [
1163
+ query.dataUpdatedAt,
1164
+ deltaQuery.dataUpdatedAt,
1165
+ statusRefreshQuery.dataUpdatedAt
1166
+ ]);
1167
+ const autoRefetchRef = useRef(autoRefetch);
1168
+ useEffect(() => {
1169
+ autoRefetchRef.current = enabled && autoRefetch;
1170
+ }, [enabled, autoRefetch]);
1171
+ useEffect(() => {
1172
+ const handler = () => {
1173
+ if (document.visibilityState !== "visible") return;
1174
+ if (!autoRefetchRef.current) return;
1175
+ if (!shouldResetAfterIdle(lastSuccessAtRef.current, Date.now(), idleGuardThresholdMs)) return;
1176
+ queryClient.resetQueries({ queryKey: [
1177
+ "traces",
1178
+ listMode,
1179
+ filters
1180
+ ] });
1181
+ };
1182
+ document.addEventListener("visibilitychange", handler);
1183
+ return () => document.removeEventListener("visibilitychange", handler);
1184
+ }, [
1185
+ queryClient,
1186
+ listMode,
1187
+ filters,
1188
+ idleGuardThresholdMs
1189
+ ]);
1190
+ const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;
1191
+ useEffect(() => {
1192
+ if (enabled && isEndOfListInView && hasNextPage && !isFetchingNextPage) fetchNextPage();
1193
+ }, [
1194
+ enabled,
1195
+ isEndOfListInView,
1196
+ hasNextPage,
1197
+ isFetchingNextPage,
1198
+ fetchNextPage
1199
+ ]);
1200
+ const isFetchingAny = query.isFetching || statusRefreshQuery.isFetching || deltaQuery.isFetching;
1201
+ const lastActivityAt = Math.max(query.dataUpdatedAt, query.errorUpdatedAt, deltaQuery.dataUpdatedAt, deltaQuery.errorUpdatedAt, statusRefreshQuery.dataUpdatedAt, statusRefreshQuery.errorUpdatedAt);
1202
+ const [pulse, setPulse] = useState(false);
1203
+ const prevActivityAtRef = useRef(lastActivityAt);
1204
+ useEffect(() => {
1205
+ if (lastActivityAt > prevActivityAtRef.current) {
1206
+ prevActivityAtRef.current = lastActivityAt;
1207
+ setPulse(true);
1208
+ const t = setTimeout(() => setPulse(false), minRefetchSpinMs);
1209
+ return () => clearTimeout(t);
1210
+ }
1211
+ }, [lastActivityAt, minRefetchSpinMs]);
1212
+ const isRefetching = isFetchingAny || pulse;
1213
+ return {
1214
+ ...query,
1215
+ setEndOfListElement,
1216
+ isRefetching,
1217
+ autoRefetch,
1218
+ setAutoRefetch,
1219
+ recentlyAddedKeys
1220
+ };
1221
+ };
1222
+ // src/hooks/traces/use-create-feedback.tsx
1223
+ /**
1224
+ * Submits a free-text comment as a feedback record, scoped to the trace or to a
1225
+ * single span, then invalidates the matching feedback list so it refreshes.
1226
+ */
1227
+ const useCreateFeedback = ({ traceId, spanId, queryOptions }) => {
1228
+ const client = useMastraClient();
1229
+ const queryClient = useQueryClient();
1230
+ return useMutation({
1231
+ mutationFn: ({ text }) => client.createFeedback({ feedback: {
1232
+ traceId,
1233
+ ...spanId ? { spanId } : {},
1234
+ feedbackType: "comment",
1235
+ feedbackSource: "user",
1236
+ value: text
1237
+ } }),
1238
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: spanId ? [
1239
+ "span-feedback",
1240
+ traceId,
1241
+ spanId
1242
+ ] : ["trace-feedback", traceId] }),
1243
+ ...queryOptions
1244
+ });
1245
+ };
1246
+ // src/hooks/traces/use-delete-feedback.tsx
1247
+ /**
1248
+ * Deletes a single feedback record by id, then invalidates the matching
1249
+ * feedback list (trace- or span-scoped) so it refreshes.
1250
+ */
1251
+ const useDeleteFeedback = ({ traceId, spanId, queryOptions }) => {
1252
+ const client = useMastraClient();
1253
+ const queryClient = useQueryClient();
1254
+ return useMutation({
1255
+ mutationFn: ({ feedbackId }) => client.deleteFeedback({ feedbackIds: [feedbackId] }),
1256
+ onSuccess: () => queryClient.invalidateQueries({ queryKey: spanId ? [
1257
+ "span-feedback",
1258
+ traceId,
1259
+ spanId
1260
+ ] : ["trace-feedback", traceId] }),
1261
+ ...queryOptions
1262
+ });
1263
+ };
1264
+ // src/hooks/traces/use-span-feedback.tsx
1265
+ /**
1266
+ * Feedback scoped to a single span. Both identifiers are required: without a `spanId`
1267
+ * the query stays disabled rather than falling back to trace-wide feedback.
1268
+ *
1269
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
1270
+ */
1271
+ const useSpanFeedback = ({ traceId = "", spanId = "", page, queryOptions }) => {
1272
+ const client = useMastraClient();
1273
+ const pageNumber = page ?? 0;
1274
+ return useQuery({
1275
+ queryKey: [
1276
+ "span-feedback",
1277
+ traceId,
1278
+ spanId,
1279
+ pageNumber
1280
+ ],
1281
+ queryFn: () => client.listFeedback({
1282
+ filters: {
1283
+ traceId,
1284
+ spanId
1285
+ },
1286
+ pagination: {
1287
+ page: pageNumber,
1288
+ perPage: 10
1289
+ }
1290
+ }),
1291
+ refetchInterval: getFeedbackRefetchInterval,
1292
+ gcTime: 0,
1293
+ staleTime: 0,
1294
+ ...queryOptions
1295
+ });
1296
+ };
1297
+ // src/hooks/traces/use-trace-feedback.tsx
1298
+ /** Loads a page of trace-level feedback and stops polling when storage cannot serve feedback. */
1299
+ /**
1300
+ * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
1301
+ */
1302
+ const useTraceFeedback = ({ traceId = "", page, queryOptions }) => {
1303
+ const client = useMastraClient();
1304
+ const pageNumber = page ?? 0;
1305
+ return useQuery({
1306
+ queryKey: [
1307
+ "trace-feedback",
1308
+ traceId,
1309
+ pageNumber
1310
+ ],
1311
+ queryFn: () => client.listFeedback({
1312
+ filters: { traceId },
1313
+ pagination: {
1314
+ page: pageNumber,
1315
+ perPage: 10
1316
+ }
1317
+ }),
1318
+ select: (data) => {
1319
+ const feedback = data.feedback.filter((item) => !item.spanId);
1320
+ if (!data.pagination) return {
1321
+ ...data,
1322
+ feedback
1323
+ };
1324
+ return {
1325
+ ...data,
1326
+ feedback,
1327
+ pagination: {
1328
+ ...data.pagination,
1329
+ total: feedback.length
1330
+ }
1331
+ };
1332
+ },
1333
+ refetchInterval: getFeedbackRefetchInterval,
1334
+ gcTime: 0,
1335
+ staleTime: 0,
1336
+ ...queryOptions
1337
+ });
1338
+ };
1339
+ // src/hooks/traces/use-trace-metadata-filter-fields.ts
1340
+ const DISCOVERY_LIMIT = 100;
1341
+ const EMPTY_FIELDS = {
1342
+ canonicalFields: [],
1343
+ observedFields: [],
1344
+ observedFieldsTruncated: false
1345
+ };
1346
+ const TRACE_QUERY_DISCOVERY_UNSUPPORTED = "TRACE_QUERY_DISCOVERY_UNSUPPORTED";
1347
+ const isDiscoveryUnsupportedError = (error) => error instanceof MastraClientError && typeof error.body === "object" && error.body !== null && error.body.code === TRACE_QUERY_DISCOVERY_UNSUPPORTED;
1348
+ const traceQueryFieldsQueryKey = (timeRange) => [
1349
+ "trace-query-fields",
1350
+ timeRange.from,
1351
+ timeRange.to
1352
+ ];
1353
+ /** Lazy FilterBar suggestions resolver backed by the value-discovery endpoint for one
1354
+ * `predicateScope` + `path`. the caller owns debounce/abort; this only fetches. */
1355
+ const createTraceQueryValuesResolver = (client, timeRange, predicateScope, path) => {
1356
+ return async ({ query: search, signal }) => {
1357
+ const { values } = await client.getTraceQueryValues({
1358
+ timeRange,
1359
+ predicateScope,
1360
+ path,
1361
+ search: search.trim() || void 0,
1362
+ limit: DISCOVERY_LIMIT
1363
+ }, { signal });
1364
+ return values.map(({ value }) => ({ value }));
1365
+ };
1366
+ };
1367
+ /**
1368
+ * Discovers the `metadata.*` fields observed on traces in the given time range and returns
1369
+ * them as filter bar fields, each with a lazy `suggestions` resolver that fetches the field's
1370
+ * values when the user opens the value step (the caller owns debounce/abort).
1371
+ *
1372
+ * Resolves to an empty field list when the server or store does not support discovery
1373
+ * (`TRACE_QUERY_DISCOVERY_UNSUPPORTED`) so callers never stay blocked.
1374
+ */
1375
+ const useTraceMetadataFilterFields = ({ timeRange, queryOptions }) => {
1376
+ const client = useMastraClient();
1377
+ const query = useQuery({
1378
+ queryKey: traceQueryFieldsQueryKey(timeRange),
1379
+ queryFn: async ({ signal }) => {
1380
+ try {
1381
+ return await client.getTraceQueryFields({
1382
+ timeRange,
1383
+ predicateScope: "trace",
1384
+ limit: DISCOVERY_LIMIT
1385
+ }, { signal });
1386
+ } catch (error) {
1387
+ if (isDiscoveryUnsupportedError(error)) return EMPTY_FIELDS;
1388
+ throw error;
1389
+ }
1390
+ },
1391
+ retry: false,
1392
+ staleTime: DISCOVERY_STALE_TIME,
1393
+ placeholderData: keepPreviousData,
1394
+ ...queryOptions
1395
+ });
1396
+ const observedFields = query.data?.observedFields;
1397
+ const canonicalFields = query.data?.canonicalFields ?? EMPTY_FIELDS.canonicalFields;
1398
+ return {
1399
+ fields: useMemo(() => (observedFields ?? []).map((field) => ({
1400
+ path: field.path,
1401
+ suggestions: createTraceQueryValuesResolver(client, timeRange, "trace", field.path)
1402
+ })), [
1403
+ observedFields,
1404
+ client,
1405
+ timeRange
1406
+ ]),
1407
+ canonicalFields,
1408
+ isLoading: query.isLoading,
1409
+ error: query.error
1410
+ };
1411
+ };
1412
+ // src/hooks/traces/use-trace-column-preferences-storage-key.ts
1413
+ /**
1414
+ * Storage key for the trace list column preferences, scoped to the Mastra server the client
1415
+ * talks to so each project keeps its own column layout, and to the list (traces, spans or threads)
1416
+ * so each list keeps its own selection.
1417
+ */
1418
+ function useTraceColumnPreferencesStorageKey(scope = "traces") {
1419
+ const client = useMastraClient();
1420
+ return `mastra:${scope}:columns:${client.options.baseUrl || (typeof window === "undefined" ? "local" : window.location.origin || "local")}:${client.options.apiPrefix ?? "/api"}`;
1421
+ }
1422
+ export { DISCOVERY_STALE_TIME, ROOT_ENTITY_TYPES, SPAN_QUERY_PER_PAGE, THREAD_QUERY_PER_PAGE, TRACES_PER_PAGE, TRACE_QUERY_DELTA_LIMIT, TRACE_QUERY_PER_PAGE, createTraceQueryValuesResolver, getLegacyTraceQueryNextPageParam, getTraceQueryNextPageParam, getTracesNextPageParam, lightSpanToTraceQueryTrace, mergeDeltaIntoPage0, mergeTraceQueryDelta, refreshPage0Rows, selectLegacyTraceQueryTraces, selectTraceQueryTraces, selectUniqueTraces, shouldPinLightList, shouldResetAfterIdle, traceQueryFieldsQueryKey, traceQueryKey, traceSpansQueryOptions, useBranch, useCreateFeedback, useDeleteFeedback, useEntityNames, useEnvironments, useFetchTraceSpans, useQuerySpans, useQueryThreads, useServiceNames, useSpanAggregate, useSpanDetail, useSpanFeedback, useTags, useThreadHasOtherTraces, useTraceAggregate, useTraceColumnPreferencesStorageKey, useTraceFeedback, useTraceLightSpans, useTraceMetadataFilterFields, useTraceOrBranchSpans, useTraceQuery, useTraceQueryLatest, useTraceSpans, useTraceSpansQueries, useTraceUsage, useTraces };
1423
+
1424
+ //# sourceMappingURL=index.js.map