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