@mastra/react 1.12.0-alpha.9 → 1.13.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/{accumulator-BQGsraqS.cjs → accumulator-BmD8-x9I.cjs} +52 -4
  2. package/dist/accumulator-BmD8-x9I.cjs.map +1 -0
  3. package/dist/{accumulator-C8kIc450.js → accumulator-D9jAph99.js} +52 -4
  4. package/dist/accumulator-D9jAph99.js.map +1 -0
  5. package/dist/chat/index.cjs +1 -1
  6. package/dist/chat/index.js +1 -2
  7. package/dist/combine-by-ids-D_lp6Dvq.cjs.map +1 -1
  8. package/dist/experiments-B7vRMK5T.js +306 -0
  9. package/dist/experiments-B7vRMK5T.js.map +1 -0
  10. package/dist/experiments-CJw1N3FB.cjs +353 -0
  11. package/dist/experiments-CJw1N3FB.cjs.map +1 -0
  12. package/dist/hooks/agents/index.cjs +2 -2
  13. package/dist/hooks/agents/index.cjs.map +1 -1
  14. package/dist/hooks/agents/index.js +2 -2
  15. package/dist/hooks/agents/index.js.map +1 -1
  16. package/dist/hooks/auth/index.cjs +2 -2
  17. package/dist/hooks/auth/index.cjs.map +1 -1
  18. package/dist/hooks/auth/index.js +2 -2
  19. package/dist/hooks/auth/index.js.map +1 -1
  20. package/dist/hooks/capabilities/index.cjs +58 -1
  21. package/dist/hooks/capabilities/index.cjs.map +1 -1
  22. package/dist/hooks/capabilities/index.d.ts +4 -0
  23. package/dist/hooks/capabilities/index.d.ts.map +1 -1
  24. package/dist/hooks/capabilities/index.js +55 -2
  25. package/dist/hooks/capabilities/index.js.map +1 -1
  26. package/dist/hooks/capabilities/use-span-aggregate-available.d.ts +9 -0
  27. package/dist/hooks/capabilities/use-span-aggregate-available.d.ts.map +1 -0
  28. package/dist/hooks/capabilities/use-span-query-available.d.ts +9 -0
  29. package/dist/hooks/capabilities/use-span-query-available.d.ts.map +1 -0
  30. package/dist/hooks/capabilities/use-thread-query-available.d.ts +9 -0
  31. package/dist/hooks/capabilities/use-thread-query-available.d.ts.map +1 -0
  32. package/dist/hooks/capabilities/use-trace-query-delta-polling-available.d.ts +10 -0
  33. package/dist/hooks/capabilities/use-trace-query-delta-polling-available.d.ts.map +1 -0
  34. package/dist/hooks/configuration/index.cjs.map +1 -1
  35. package/dist/hooks/datasets/index.cjs +25 -1
  36. package/dist/hooks/datasets/index.cjs.map +1 -1
  37. package/dist/hooks/datasets/index.js +25 -2
  38. package/dist/hooks/datasets/index.js.map +1 -1
  39. package/dist/hooks/datasets/use-datasets.d.ts +7 -0
  40. package/dist/hooks/datasets/use-datasets.d.ts.map +1 -1
  41. package/dist/hooks/embedders/index.cjs.map +1 -1
  42. package/dist/hooks/experiments/index.cjs +9 -235
  43. package/dist/hooks/experiments/index.d.ts +1 -0
  44. package/dist/hooks/experiments/index.d.ts.map +1 -1
  45. package/dist/hooks/experiments/index.js +1 -229
  46. package/dist/hooks/experiments/usage-accumulator.d.ts +25 -0
  47. package/dist/hooks/experiments/usage-accumulator.d.ts.map +1 -0
  48. package/dist/hooks/experiments/use-experiment-item-usage.d.ts +2 -7
  49. package/dist/hooks/experiments/use-experiment-item-usage.d.ts.map +1 -1
  50. package/dist/hooks/experiments/use-experiments-list-metrics.d.ts +19 -0
  51. package/dist/hooks/experiments/use-experiments-list-metrics.d.ts.map +1 -0
  52. package/dist/hooks/feedback/index.cjs.map +1 -1
  53. package/dist/hooks/llm/index.cjs.map +1 -1
  54. package/dist/hooks/logs/index.cjs.map +1 -1
  55. package/dist/hooks/mcps/index.cjs.map +1 -1
  56. package/dist/hooks/memory/index.cjs +10 -10
  57. package/dist/hooks/memory/index.cjs.map +1 -1
  58. package/dist/hooks/memory/index.js +10 -10
  59. package/dist/hooks/memory/index.js.map +1 -1
  60. package/dist/hooks/metrics/index.cjs +13 -11
  61. package/dist/hooks/metrics/index.cjs.map +1 -1
  62. package/dist/hooks/metrics/index.js +13 -11
  63. package/dist/hooks/metrics/index.js.map +1 -1
  64. package/dist/hooks/processors/index.cjs.map +1 -1
  65. package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
  66. package/dist/hooks/query/index.cjs.map +1 -1
  67. package/dist/hooks/review/index.cjs +2 -2
  68. package/dist/hooks/review/index.cjs.map +1 -1
  69. package/dist/hooks/review/index.js +1 -1
  70. package/dist/hooks/schedules/index.cjs.map +1 -1
  71. package/dist/hooks/scores/index.cjs.map +1 -1
  72. package/dist/hooks/templates/index.cjs +20 -18
  73. package/dist/hooks/templates/index.cjs.map +1 -1
  74. package/dist/hooks/templates/index.js +20 -18
  75. package/dist/hooks/templates/index.js.map +1 -1
  76. package/dist/hooks/templates/use-templates.d.ts.map +1 -1
  77. package/dist/hooks/tool-providers/index.cjs +1 -1
  78. package/dist/hooks/tool-providers/index.cjs.map +1 -1
  79. package/dist/hooks/tool-providers/index.js +1 -1
  80. package/dist/hooks/tool-providers/index.js.map +1 -1
  81. package/dist/hooks/tools/index.cjs.map +1 -1
  82. package/dist/hooks/traces/index.cjs +292 -9
  83. package/dist/hooks/traces/index.cjs.map +1 -1
  84. package/dist/hooks/traces/index.d.ts +2 -0
  85. package/dist/hooks/traces/index.d.ts.map +1 -1
  86. package/dist/hooks/traces/index.js +285 -10
  87. package/dist/hooks/traces/index.js.map +1 -1
  88. package/dist/hooks/traces/use-query-spans.d.ts +27 -0
  89. package/dist/hooks/traces/use-query-spans.d.ts.map +1 -0
  90. package/dist/hooks/traces/use-query-threads.d.ts +30 -0
  91. package/dist/hooks/traces/use-query-threads.d.ts.map +1 -0
  92. package/dist/hooks/traces/use-trace-query.d.ts +50 -1
  93. package/dist/hooks/traces/use-trace-query.d.ts.map +1 -1
  94. package/dist/hooks/traces/use-traces.d.ts +37 -37
  95. package/dist/hooks/vectors/index.cjs.map +1 -1
  96. package/dist/hooks/voice/index.cjs.map +1 -1
  97. package/dist/hooks/workflows/index.cjs +1 -1
  98. package/dist/hooks/workflows/index.cjs.map +1 -1
  99. package/dist/hooks/workflows/index.js +1 -1
  100. package/dist/hooks/workspace/index.cjs +1 -1
  101. package/dist/hooks/workspace/index.cjs.map +1 -1
  102. package/dist/hooks/workspace/index.js +1 -1
  103. package/dist/hooks/workspace/index.js.map +1 -1
  104. package/dist/{hooks-CIutb3DO.cjs → hooks-C6CJtoOR.cjs} +6 -4
  105. package/dist/hooks-C6CJtoOR.cjs.map +1 -0
  106. package/dist/{hooks-0L0RNfau.js → hooks-DG-Y1KFe.js} +2 -2
  107. package/dist/{hooks-0L0RNfau.js.map → hooks-DG-Y1KFe.js.map} +1 -1
  108. package/dist/{hooks-FVbeHlov.js → hooks-DvLSZtUd.js} +6 -4
  109. package/dist/{hooks-FVbeHlov.js.map → hooks-DvLSZtUd.js.map} +1 -1
  110. package/dist/{hooks-_YevKidX.cjs → hooks-XYsmqFCz.cjs} +2 -2
  111. package/dist/hooks-XYsmqFCz.cjs.map +1 -0
  112. package/dist/index.cjs +3 -3
  113. package/dist/index.cjs.map +1 -1
  114. package/dist/index.js +3 -3
  115. package/dist/lib/mastra-db/accumulator.d.ts +0 -6
  116. package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
  117. package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -1
  118. package/dist/ui/index.cjs +4 -4
  119. package/dist/ui/index.cjs.map +1 -1
  120. package/dist/ui/index.js +3 -3
  121. package/dist/ui/index.js.map +1 -1
  122. package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -1
  123. package/dist/voice-BOtUdMi8.cjs.map +1 -1
  124. package/package.json +7 -7
  125. package/dist/accumulator-BQGsraqS.cjs.map +0 -1
  126. package/dist/accumulator-C8kIc450.js.map +0 -1
  127. package/dist/hooks/experiments/index.cjs.map +0 -1
  128. package/dist/hooks/experiments/index.js.map +0 -1
  129. package/dist/hooks-CIutb3DO.cjs.map +0 -1
  130. package/dist/hooks-_YevKidX.cjs.map +0 -1
@@ -19,7 +19,7 @@ let _mastra_core_observability = require("@mastra/core/observability");
19
19
  * through to the store's discovery refresh. Matching the server TTL keeps the
20
20
  * client from asking more often than the answer can change.
21
21
  */
22
- const DISCOVERY_STALE_TIME = 300 * 1e3;
22
+ const DISCOVERY_STALE_TIME = 3e5;
23
23
  //#endregion
24
24
  //#region src/hooks/traces/use-branch.ts
25
25
  /**
@@ -136,7 +136,7 @@ const useServiceNames = ({ queryOptions } = {}) => {
136
136
  };
137
137
  //#endregion
138
138
  //#region src/hooks/traces/use-span-detail.ts
139
- const IMMUTABLE_CACHE_TIME$1 = 1e3 * 60 * 60 * 24 * 30;
139
+ const IMMUTABLE_CACHE_TIME$1 = 2592e6;
140
140
  /**
141
141
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
142
142
  */
@@ -201,7 +201,7 @@ function useThreadHasOtherTraces({ threadId, queryOptions }) {
201
201
  }
202
202
  //#endregion
203
203
  //#region src/hooks/traces/use-trace-light-spans.ts
204
- const IMMUTABLE_CACHE_TIME = 1e3 * 60 * 60 * 24 * 30;
204
+ const IMMUTABLE_CACHE_TIME = 2592e6;
205
205
  /**
206
206
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
207
207
  */
@@ -320,6 +320,8 @@ function useTraceOrBranchSpans({ traceId, anchorSpanId, listMode, depth, queryOp
320
320
  //#endregion
321
321
  //#region src/hooks/traces/use-trace-query.ts
322
322
  const TRACE_QUERY_PER_PAGE = 25;
323
+ /** Max traces per delta request; the server caps `limit` at 100. */
324
+ const TRACE_QUERY_DELTA_LIMIT = 100;
323
325
  function getTraceQueryNextPageParam(lastPage) {
324
326
  return lastPage?.page.next ?? void 0;
325
327
  }
@@ -369,16 +371,101 @@ function selectLegacyTraceQueryTraces(data) {
369
371
  function getLegacyTraceQueryNextPageParam(lastPage) {
370
372
  return lastPage.pagination?.hasMore ? lastPage.pagination.page + 1 : void 0;
371
373
  }
374
+ /** Cache key of `useTraceQuery`'s trace-query list. Pass the same `query` and `limit` to share it. */
375
+ const traceQueryKey = (query, limit = 25) => [
376
+ "trace-query",
377
+ query,
378
+ limit
379
+ ];
380
+ function traceSortValue(trace, field) {
381
+ if (field === "timeToFirstChunkMs") return trace.timeToFirstChunkMs ?? null;
382
+ const value = trace[field];
383
+ return value == null ? null : Date.parse(value);
384
+ }
385
+ /** Mirrors the server's keyset order: empty values last in both directions, ties by ascending `traceId`. */
386
+ function compareTraces(orderBy) {
387
+ return (a, b) => {
388
+ const va = traceSortValue(a, orderBy.field);
389
+ const vb = traceSortValue(b, orderBy.field);
390
+ if (va !== vb) {
391
+ if (va === null) return 1;
392
+ if (vb === null) return -1;
393
+ return orderBy.direction === "asc" ? va - vb : vb - va;
394
+ }
395
+ return a.traceId < b.traceId ? -1 : a.traceId > b.traceId ? 1 : 0;
396
+ };
397
+ }
398
+ /**
399
+ * Merges delta-polled traces into the pages of a `useTraceQuery` list, without mutating `data`.
400
+ * A trace already on a page is replaced in place when its sort value is unchanged; otherwise it is
401
+ * removed and placed again like a new trace (sorting by `endedAt`, a running trace moves once it
402
+ * ends). A new trace goes into the first page whose last row sorts after it; when no loaded page does, it is
403
+ * appended to the last page if that is the end of the list, and skipped otherwise, since keyset
404
+ * pagination returns it once the user scrolls there. Page cursors are kept as they are, and `data`
405
+ * itself is returned when nothing changed.
406
+ */
407
+ function mergeTraceQueryDelta(data, traces, orderBy) {
408
+ if (traces.length === 0 || data.pages.length === 0) return data;
409
+ const incoming = new Map(traces.map((trace) => [trace.traceId, trace]));
410
+ const rows = data.pages.map((page) => page.traces);
411
+ const changed = /* @__PURE__ */ new Set();
412
+ const write = (pageIndex, next) => {
413
+ rows[pageIndex] = next;
414
+ changed.add(pageIndex);
415
+ };
416
+ const sortBy = orderBy?.[0] ?? {
417
+ field: "startedAt",
418
+ direction: "desc"
419
+ };
420
+ const compare = compareTraces(sortBy);
421
+ const replacedInPlace = /* @__PURE__ */ new Set();
422
+ rows.forEach((pageRows, pageIndex) => {
423
+ if (!pageRows.some((row) => incoming.has(row.traceId))) return;
424
+ const next = [];
425
+ for (const row of pageRows) {
426
+ const update = incoming.get(row.traceId);
427
+ if (!update) next.push(row);
428
+ else if (traceSortValue(update, sortBy.field) === traceSortValue(row, sortBy.field)) {
429
+ next.push(update);
430
+ replacedInPlace.add(row.traceId);
431
+ }
432
+ }
433
+ write(pageIndex, next);
434
+ });
435
+ for (const traceId of replacedInPlace) incoming.delete(traceId);
436
+ const lastIndex = rows.length - 1;
437
+ for (const trace of incoming.values()) {
438
+ let pageIndex = rows.findIndex((pageRows) => {
439
+ const last = pageRows[pageRows.length - 1];
440
+ return last !== void 0 && compare(trace, last) < 0;
441
+ });
442
+ if (pageIndex === -1) {
443
+ if (data.pages[lastIndex].page.next !== null) continue;
444
+ pageIndex = lastIndex;
445
+ }
446
+ const pageRows = rows[pageIndex];
447
+ const at = pageRows.findIndex((row) => compare(trace, row) < 0);
448
+ write(pageIndex, at === -1 ? [...pageRows, trace] : [
449
+ ...pageRows.slice(0, at),
450
+ trace,
451
+ ...pageRows.slice(at)
452
+ ]);
453
+ }
454
+ if (changed.size === 0) return data;
455
+ return {
456
+ ...data,
457
+ pages: data.pages.map((page, pageIndex) => changed.has(pageIndex) ? {
458
+ ...page,
459
+ traces: rows[pageIndex]
460
+ } : page)
461
+ };
462
+ }
372
463
  /** Queries traces with cursor pagination and viewport-driven loading. */
373
464
  function useTraceQuery({ query, limit = 25, enabled = true, withQueryTrace = true, legacyFilters, queryOptions }) {
374
465
  const client = require_mastra_client_context.useMastraClient();
375
466
  const { inView, setRef: setEndOfListElement } = require_use_in_view.useInView();
376
467
  const queryResult = (0, _tanstack_react_query.useInfiniteQuery)({
377
- queryKey: [
378
- "trace-query",
379
- query,
380
- limit
381
- ],
468
+ queryKey: traceQueryKey(query, limit),
382
469
  queryFn: query ? async ({ pageParam }) => {
383
470
  const response = await new _mastra_client_js.MastraClient({
384
471
  ...client.options,
@@ -456,6 +543,194 @@ function useTraceQuery({ query, limit = 25, enabled = true, withQueryTrace = tru
456
543
  setEndOfListElement
457
544
  };
458
545
  }
546
+ function omitOrderBy({ orderBy: _orderBy, ...rest }) {
547
+ return rest;
548
+ }
549
+ /** Request timeouts and rate limits clear up on their own, unlike the other 4xx refusals. */
550
+ const TRANSIENT_CLIENT_ERROR_STATUSES = /* @__PURE__ */ new Set([408, 429]);
551
+ /** The server refused the request or does not support delta polling; polling again cannot change that. */
552
+ function isRejectedDeltaRequest(error) {
553
+ if (!(error instanceof _mastra_client_js.MastraClientError) || TRANSIENT_CLIENT_ERROR_STATUSES.has(error.status)) return false;
554
+ return error.status >= 400 && error.status < 500 || error.status === 501;
555
+ }
556
+ const isCursorConflict = (error) => error instanceof _mastra_client_js.MastraClientError && error.status === 409;
557
+ /**
558
+ * Polls `queryTraces({ mode: 'delta' })` and merges new or updated traces into the list of a
559
+ * `useTraceQuery` rendered with the same `query` and `limit`. The first request only establishes
560
+ * the server cursor; each later poll drains every batch since that cursor. A cursor conflict (409)
561
+ * starts over with a new cursor. A poll that returns while the list is loading a page, or before
562
+ * the list has loaded at all, keeps its cursor and asks again on the next poll.
563
+ *
564
+ * The cursor is keyed on the query without `orderBy` (delta polls cannot sort) and on `limit`, so
565
+ * re-sorting the list keeps polling from the same cursor, and lists with different page sizes each
566
+ * get their own cursor.
567
+ *
568
+ * Requires the `deltaPolling` capability (see `useTraceQueryDeltaPollingAvailable`). The list's
569
+ * `timeRange.to` must not move between polls, so a live list needs a `to` in the future.
570
+ *
571
+ * Known limitation: the cursor is established in parallel with the list's first page, so a trace
572
+ * that completes between the first page's read and the cursor can be missed until the list is
573
+ * refetched. Traces returned by both are merged by `traceId`.
574
+ */
575
+ function useTraceQueryLatest({ query, limit = 25, enabled = true, refetchInterval = false, queryOptions }) {
576
+ const client = require_mastra_client_context.useMastraClient();
577
+ const queryClient = (0, _tanstack_react_query.useQueryClient)();
578
+ const deltaQuery = query && omitOrderBy(query);
579
+ const queryKey = [
580
+ "trace-query-latest",
581
+ deltaQuery,
582
+ limit
583
+ ];
584
+ return (0, _tanstack_react_query.useQuery)({
585
+ queryKey,
586
+ queryFn: query && deltaQuery ? async () => {
587
+ const mastra = new _mastra_client_js.MastraClient({
588
+ ...client.options,
589
+ retries: 0
590
+ });
591
+ const bootstrap = async () => {
592
+ return { deltaCursor: (await mastra.queryTraces({
593
+ ...deltaQuery,
594
+ mode: "delta"
595
+ })).deltaCursor };
596
+ };
597
+ const previous = queryClient.getQueryData(queryKey);
598
+ if (!previous) return bootstrap();
599
+ const traces = [];
600
+ let deltaCursor = previous.deltaCursor;
601
+ try {
602
+ for (let hasMore = true; hasMore;) {
603
+ const response = await mastra.queryTraces({
604
+ ...deltaQuery,
605
+ mode: "delta",
606
+ after: deltaCursor,
607
+ limit: 100
608
+ });
609
+ traces.push(...response.traces);
610
+ deltaCursor = response.deltaCursor;
611
+ hasMore = response.delta.hasMore;
612
+ }
613
+ } catch (error) {
614
+ if (isCursorConflict(error)) return bootstrap();
615
+ throw error;
616
+ }
617
+ const listKey = traceQueryKey(query, limit);
618
+ const listState = queryClient.getQueryState(listKey);
619
+ if (!listState?.data || listState.fetchStatus === "fetching") return previous;
620
+ queryClient.setQueryData(listKey, (data) => data ? mergeTraceQueryDelta(data, traces, query.orderBy) : data);
621
+ return { deltaCursor };
622
+ } : _tanstack_react_query.skipToken,
623
+ retry: false,
624
+ refetchInterval: (q) => isRejectedDeltaRequest(q.state.error) ? false : refetchInterval,
625
+ refetchIntervalInBackground: false,
626
+ enabled: enabled && !!query,
627
+ ...queryOptions
628
+ });
629
+ }
630
+ //#endregion
631
+ //#region src/hooks/traces/use-query-spans.ts
632
+ const SPAN_QUERY_PER_PAGE = 25;
633
+ const selectSpans = (data) => data.pages.flatMap((page) => page.spans);
634
+ /** Queries completed spans with cursor pagination and viewport-driven loading. */
635
+ function useQuerySpans({ query, limit = 25, enabled = true, queryOptions }) {
636
+ const client = require_mastra_client_context.useMastraClient();
637
+ const { inView, setRef: setEndOfListElement } = require_use_in_view.useInView();
638
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = (0, _tanstack_react_query.useInfiniteQuery)({
639
+ queryKey: [
640
+ "span-query",
641
+ query,
642
+ limit
643
+ ],
644
+ queryFn: query ? ({ pageParam }) => client.querySpans({
645
+ ...query,
646
+ page: pageParam ? {
647
+ limit,
648
+ after: pageParam
649
+ } : { limit }
650
+ }) : _tanstack_react_query.skipToken,
651
+ initialPageParam: void 0,
652
+ getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
653
+ select: selectSpans,
654
+ retry: false,
655
+ placeholderData: _tanstack_react_query.keepPreviousData,
656
+ enabled,
657
+ ...queryOptions
658
+ });
659
+ (0, react.useEffect)(() => {
660
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
661
+ }, [
662
+ enabled,
663
+ inView,
664
+ hasNextPage,
665
+ isFetching,
666
+ isFetchNextPageError,
667
+ fetchNextPage
668
+ ]);
669
+ return {
670
+ spans: data,
671
+ hasNextPage,
672
+ isFetchingNextPage,
673
+ fetchNextPage: () => void fetchNextPage(),
674
+ setEndOfListElement,
675
+ isLoading,
676
+ isFetching,
677
+ isError,
678
+ error,
679
+ refetch: () => void refetch()
680
+ };
681
+ }
682
+ //#endregion
683
+ //#region src/hooks/traces/use-query-threads.ts
684
+ const THREAD_QUERY_PER_PAGE = 25;
685
+ const selectThreads = (data) => data.pages.flatMap((page) => page.threads);
686
+ /** Queries thread rows with cursor pagination and viewport-driven loading. */
687
+ function useQueryThreads({ query, limit = 25, enabled = true, queryOptions }) {
688
+ const client = require_mastra_client_context.useMastraClient();
689
+ const { inView, setRef: setEndOfListElement } = require_use_in_view.useInView();
690
+ const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = (0, _tanstack_react_query.useInfiniteQuery)({
691
+ queryKey: [
692
+ "thread-query",
693
+ query,
694
+ limit
695
+ ],
696
+ queryFn: query ? ({ pageParam }) => client.queryTraceThreads({
697
+ ...query,
698
+ page: pageParam ? {
699
+ limit,
700
+ after: pageParam
701
+ } : { limit }
702
+ }) : _tanstack_react_query.skipToken,
703
+ initialPageParam: void 0,
704
+ getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
705
+ select: selectThreads,
706
+ retry: false,
707
+ placeholderData: _tanstack_react_query.keepPreviousData,
708
+ enabled,
709
+ ...queryOptions
710
+ });
711
+ (0, react.useEffect)(() => {
712
+ if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
713
+ }, [
714
+ enabled,
715
+ inView,
716
+ hasNextPage,
717
+ isFetching,
718
+ isFetchNextPageError,
719
+ fetchNextPage
720
+ ]);
721
+ return {
722
+ threads: data,
723
+ hasNextPage,
724
+ isFetchingNextPage,
725
+ fetchNextPage: () => void fetchNextPage(),
726
+ setEndOfListElement,
727
+ isLoading,
728
+ isFetching,
729
+ isError,
730
+ error,
731
+ refetch: () => void refetch()
732
+ };
733
+ }
459
734
  //#endregion
460
735
  //#region src/hooks/traces/use-trace-usage.ts
461
736
  const INPUT_TOKEN_METRIC = "mastra_model_total_input_tokens";
@@ -552,7 +827,7 @@ const DEFAULT_POLLING_CONFIG = {
552
827
  deltaLimit: 100,
553
828
  pageModeRefetchIntervalMs: 1e4,
554
829
  page0StatusRefreshIntervalMs: 6e4,
555
- idleGuardThresholdMs: 15 * 6e4,
830
+ idleGuardThresholdMs: 9e5,
556
831
  minRefetchSpinMs: 400,
557
832
  deltaHighlightMs: 1e3
558
833
  };
@@ -1132,7 +1407,10 @@ function useTraceColumnPreferencesStorageKey() {
1132
1407
  //#endregion
1133
1408
  exports.DISCOVERY_STALE_TIME = DISCOVERY_STALE_TIME;
1134
1409
  exports.ROOT_ENTITY_TYPES = ROOT_ENTITY_TYPES;
1410
+ exports.SPAN_QUERY_PER_PAGE = SPAN_QUERY_PER_PAGE;
1411
+ exports.THREAD_QUERY_PER_PAGE = THREAD_QUERY_PER_PAGE;
1135
1412
  exports.TRACES_PER_PAGE = TRACES_PER_PAGE;
1413
+ exports.TRACE_QUERY_DELTA_LIMIT = TRACE_QUERY_DELTA_LIMIT;
1136
1414
  exports.TRACE_QUERY_PER_PAGE = TRACE_QUERY_PER_PAGE;
1137
1415
  exports.createTraceQueryValuesResolver = createTraceQueryValuesResolver;
1138
1416
  exports.getLegacyTraceQueryNextPageParam = getLegacyTraceQueryNextPageParam;
@@ -1140,6 +1418,7 @@ exports.getTraceQueryNextPageParam = getTraceQueryNextPageParam;
1140
1418
  exports.getTracesNextPageParam = getTracesNextPageParam;
1141
1419
  exports.lightSpanToTraceQueryTrace = lightSpanToTraceQueryTrace;
1142
1420
  exports.mergeDeltaIntoPage0 = mergeDeltaIntoPage0;
1421
+ exports.mergeTraceQueryDelta = mergeTraceQueryDelta;
1143
1422
  exports.refreshPage0Rows = refreshPage0Rows;
1144
1423
  exports.selectLegacyTraceQueryTraces = selectLegacyTraceQueryTraces;
1145
1424
  exports.selectTraceQueryTraces = selectTraceQueryTraces;
@@ -1147,6 +1426,7 @@ exports.selectUniqueTraces = selectUniqueTraces;
1147
1426
  exports.shouldPinLightList = shouldPinLightList;
1148
1427
  exports.shouldResetAfterIdle = shouldResetAfterIdle;
1149
1428
  exports.traceQueryFieldsQueryKey = traceQueryFieldsQueryKey;
1429
+ exports.traceQueryKey = traceQueryKey;
1150
1430
  exports.traceSpansQueryOptions = traceSpansQueryOptions;
1151
1431
  exports.useBranch = useBranch;
1152
1432
  exports.useCreateFeedback = useCreateFeedback;
@@ -1154,6 +1434,8 @@ exports.useDeleteFeedback = useDeleteFeedback;
1154
1434
  exports.useEntityNames = useEntityNames;
1155
1435
  exports.useEnvironments = useEnvironments;
1156
1436
  exports.useFetchTraceSpans = useFetchTraceSpans;
1437
+ exports.useQuerySpans = useQuerySpans;
1438
+ exports.useQueryThreads = useQueryThreads;
1157
1439
  exports.useServiceNames = useServiceNames;
1158
1440
  exports.useSpanDetail = useSpanDetail;
1159
1441
  exports.useSpanFeedback = useSpanFeedback;
@@ -1165,6 +1447,7 @@ exports.useTraceLightSpans = useTraceLightSpans;
1165
1447
  exports.useTraceMetadataFilterFields = useTraceMetadataFilterFields;
1166
1448
  exports.useTraceOrBranchSpans = useTraceOrBranchSpans;
1167
1449
  exports.useTraceQuery = useTraceQuery;
1450
+ exports.useTraceQueryLatest = useTraceQueryLatest;
1168
1451
  exports.useTraceSpans = useTraceSpans;
1169
1452
  exports.useTraceSpansQueries = useTraceSpansQueries;
1170
1453
  exports.useTraceUsage = useTraceUsage;