@mastra/react 1.7.3-alpha.3 → 1.8.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accumulator-B1MuNX3j.js +1668 -0
- package/dist/accumulator-B1MuNX3j.js.map +1 -0
- package/dist/accumulator-CsUGDUHk.cjs +1709 -0
- package/dist/accumulator-CsUGDUHk.cjs.map +1 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/agent/user-message.d.ts +4 -0
- package/dist/agent/user-message.d.ts.map +1 -0
- package/dist/chat/index.cjs +3 -0
- package/dist/chat/index.d.ts +3 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +2 -0
- package/dist/feedback-refetch-interval-DLHzQoVV.js +12 -0
- package/dist/feedback-refetch-interval-DLHzQoVV.js.map +1 -0
- package/dist/feedback-refetch-interval-XD5FVc2k.cjs +17 -0
- package/dist/feedback-refetch-interval-XD5FVc2k.cjs.map +1 -0
- package/dist/hooks/agents/index.cjs +988 -0
- package/dist/hooks/agents/index.cjs.map +1 -0
- package/dist/hooks/agents/index.d.ts +19 -0
- package/dist/hooks/agents/index.d.ts.map +1 -0
- package/dist/hooks/agents/index.js +952 -0
- package/dist/hooks/agents/index.js.map +1 -0
- package/dist/hooks/agents/is-model-not-allowed.d.ts +15 -0
- package/dist/hooks/agents/is-model-not-allowed.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-messages.d.ts +18 -0
- package/dist/hooks/agents/use-agent-messages.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-plan.d.ts +14 -0
- package/dist/hooks/agents/use-agent-plan.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-skills.d.ts +2021 -0
- package/dist/hooks/agents/use-agent-skills.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-versions.d.ts +72 -0
- package/dist/hooks/agents/use-agent-versions.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-working-memory.d.ts +11 -0
- package/dist/hooks/agents/use-agent-working-memory.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-workspace.d.ts +2022 -0
- package/dist/hooks/agents/use-agent-workspace.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent.d.ts +12 -0
- package/dist/hooks/agents/use-agent.d.ts.map +1 -0
- package/dist/hooks/agents/use-agents-model-providers.d.ts +9 -0
- package/dist/hooks/agents/use-agents-model-providers.d.ts.map +1 -0
- package/dist/hooks/agents/use-agents.d.ts +28 -0
- package/dist/hooks/agents/use-agents.d.ts.map +1 -0
- package/dist/hooks/agents/use-background-tasks.d.ts +51 -0
- package/dist/hooks/agents/use-background-tasks.d.ts.map +1 -0
- package/dist/hooks/agents/use-browser-session-probe.d.ts +34 -0
- package/dist/hooks/agents/use-browser-session-probe.d.ts.map +1 -0
- package/dist/hooks/agents/use-channels.d.ts +34 -0
- package/dist/hooks/agents/use-channels.d.ts.map +1 -0
- package/dist/hooks/agents/use-close-browser.d.ts +17 -0
- package/dist/hooks/agents/use-close-browser.d.ts.map +1 -0
- package/dist/hooks/agents/use-execute-agent-tool.d.ts +14 -0
- package/dist/hooks/agents/use-execute-agent-tool.d.ts.map +1 -0
- package/dist/hooks/agents/use-preview-instructions.d.ts +20 -0
- package/dist/hooks/agents/use-preview-instructions.d.ts.map +1 -0
- package/dist/hooks/agents/use-stored-agents.d.ts +8023 -0
- package/dist/hooks/agents/use-stored-agents.d.ts.map +1 -0
- package/dist/hooks/agents/use-stored-skills.d.ts +8 -0
- package/dist/hooks/agents/use-stored-skills.d.ts.map +1 -0
- package/dist/hooks/auth/fetch-with-refresh.d.ts +28 -0
- package/dist/hooks/auth/fetch-with-refresh.d.ts.map +1 -0
- package/dist/hooks/auth/get-client-query-key.d.ts +7 -0
- package/dist/hooks/auth/get-client-query-key.d.ts.map +1 -0
- package/dist/hooks/auth/index.cjs +492 -0
- package/dist/hooks/auth/index.cjs.map +1 -0
- package/dist/hooks/auth/index.d.ts +11 -0
- package/dist/hooks/auth/index.d.ts.map +1 -0
- package/dist/hooks/auth/index.js +474 -0
- package/dist/hooks/auth/index.js.map +1 -0
- package/dist/hooks/auth/sso-login.d.ts +8 -0
- package/dist/hooks/auth/sso-login.d.ts.map +1 -0
- package/dist/hooks/auth/types.d.ts +107 -0
- package/dist/hooks/auth/types.d.ts.map +1 -0
- package/dist/hooks/auth/use-auth-actions.d.ts +99 -0
- package/dist/hooks/auth/use-auth-actions.d.ts.map +1 -0
- package/dist/hooks/auth/use-auth-capabilities.d.ts +43 -0
- package/dist/hooks/auth/use-auth-capabilities.d.ts.map +1 -0
- package/dist/hooks/auth/use-credentials-login.d.ts +63 -0
- package/dist/hooks/auth/use-credentials-login.d.ts.map +1 -0
- package/dist/hooks/auth/use-credentials-signup.d.ts +66 -0
- package/dist/hooks/auth/use-credentials-signup.d.ts.map +1 -0
- package/dist/hooks/auth/use-current-user.d.ts +40 -0
- package/dist/hooks/auth/use-current-user.d.ts.map +1 -0
- package/dist/hooks/auth/use-permission-patterns.d.ts +24 -0
- package/dist/hooks/auth/use-permission-patterns.d.ts.map +1 -0
- package/dist/hooks/capabilities/index.cjs +47 -0
- package/dist/hooks/capabilities/index.cjs.map +1 -0
- package/dist/hooks/capabilities/index.d.ts +4 -0
- package/dist/hooks/capabilities/index.d.ts.map +1 -0
- package/dist/hooks/capabilities/index.js +44 -0
- package/dist/hooks/capabilities/index.js.map +1 -0
- package/dist/hooks/capabilities/use-feedback-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-feedback-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-observability-capabilities.d.ts +9 -0
- package/dist/hooks/capabilities/use-observability-capabilities.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-trace-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-trace-query-available.d.ts.map +1 -0
- package/dist/hooks/configuration/index.cjs +18 -0
- package/dist/hooks/configuration/index.cjs.map +1 -0
- package/dist/hooks/configuration/index.d.ts +2 -0
- package/dist/hooks/configuration/index.d.ts.map +1 -0
- package/dist/hooks/configuration/index.js +17 -0
- package/dist/hooks/configuration/index.js.map +1 -0
- package/dist/hooks/configuration/use-mastra-packages.d.ts +9 -0
- package/dist/hooks/configuration/use-mastra-packages.d.ts.map +1 -0
- package/dist/hooks/datasets/index.cjs +615 -0
- package/dist/hooks/datasets/index.cjs.map +1 -0
- package/dist/hooks/datasets/index.d.ts +10 -0
- package/dist/hooks/datasets/index.d.ts.map +1 -0
- package/dist/hooks/datasets/index.js +600 -0
- package/dist/hooks/datasets/index.js.map +1 -0
- package/dist/hooks/datasets/use-compare-experiments.d.ts +23 -0
- package/dist/hooks/datasets/use-compare-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-experiments.d.ts +49 -0
- package/dist/hooks/datasets/use-dataset-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-item-versions.d.ts +31 -0
- package/dist/hooks/datasets/use-dataset-item-versions.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-items.d.ts +38 -0
- package/dist/hooks/datasets/use-dataset-items.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-mutations.d.ts +362 -0
- package/dist/hooks/datasets/use-dataset-mutations.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-versions.d.ts +23 -0
- package/dist/hooks/datasets/use-dataset-versions.d.ts.map +1 -0
- package/dist/hooks/datasets/use-datasets.d.ts +44 -0
- package/dist/hooks/datasets/use-datasets.d.ts.map +1 -0
- package/dist/hooks/datasets/use-experiments.d.ts +16 -0
- package/dist/hooks/datasets/use-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-workflow-schema.d.ts +16 -0
- package/dist/hooks/datasets/use-workflow-schema.d.ts.map +1 -0
- package/dist/hooks/embedders/index.cjs +19 -0
- package/dist/hooks/embedders/index.cjs.map +1 -0
- package/dist/hooks/embedders/index.d.ts +2 -0
- package/dist/hooks/embedders/index.d.ts.map +1 -0
- package/dist/hooks/embedders/index.js +18 -0
- package/dist/hooks/embedders/index.js.map +1 -0
- package/dist/hooks/embedders/use-embedders.d.ts +17 -0
- package/dist/hooks/embedders/use-embedders.d.ts.map +1 -0
- package/dist/hooks/experiments/index.cjs +152 -0
- package/dist/hooks/experiments/index.cjs.map +1 -0
- package/dist/hooks/experiments/index.d.ts +5 -0
- package/dist/hooks/experiments/index.d.ts.map +1 -0
- package/dist/hooks/experiments/index.js +146 -0
- package/dist/hooks/experiments/index.js.map +1 -0
- package/dist/hooks/experiments/use-experiment-metrics.d.ts +30 -0
- package/dist/hooks/experiments/use-experiment-metrics.d.ts.map +1 -0
- package/dist/hooks/experiments/use-experiment-trace.d.ts +13 -0
- package/dist/hooks/experiments/use-experiment-trace.d.ts.map +1 -0
- package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts +22 -0
- package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts.map +1 -0
- package/dist/hooks/experiments/use-infinite-experiments.d.ts +22 -0
- package/dist/hooks/experiments/use-infinite-experiments.d.ts.map +1 -0
- package/dist/hooks/feedback/feedback-refetch-interval.d.ts +7 -0
- package/dist/hooks/feedback/feedback-refetch-interval.d.ts.map +1 -0
- package/dist/hooks/feedback/index.cjs +22 -0
- package/dist/hooks/feedback/index.cjs.map +1 -0
- package/dist/hooks/feedback/index.d.ts +3 -0
- package/dist/hooks/feedback/index.d.ts.map +1 -0
- package/dist/hooks/feedback/index.js +20 -0
- package/dist/hooks/feedback/index.js.map +1 -0
- package/dist/hooks/feedback/use-feedback.d.ts +56 -0
- package/dist/hooks/feedback/use-feedback.d.ts.map +1 -0
- package/dist/hooks/llm/index.cjs +17 -0
- package/dist/hooks/llm/index.cjs.map +1 -0
- package/dist/hooks/llm/index.d.ts +2 -0
- package/dist/hooks/llm/index.d.ts.map +1 -0
- package/dist/hooks/llm/index.js +16 -0
- package/dist/hooks/llm/index.js.map +1 -0
- package/dist/hooks/llm/use-llm-providers.d.ts +7 -0
- package/dist/hooks/llm/use-llm-providers.d.ts.map +1 -0
- package/dist/hooks/logs/index.cjs +84 -0
- package/dist/hooks/logs/index.cjs.map +1 -0
- package/dist/hooks/logs/index.d.ts +4 -0
- package/dist/hooks/logs/index.d.ts.map +1 -0
- package/dist/hooks/logs/index.js +82 -0
- package/dist/hooks/logs/index.js.map +1 -0
- package/dist/hooks/logs/types.d.ts +36 -0
- package/dist/hooks/logs/types.d.ts.map +1 -0
- package/dist/hooks/logs/use-logs.d.ts +79 -0
- package/dist/hooks/logs/use-logs.d.ts.map +1 -0
- package/dist/hooks/mcps/index.cjs +215 -0
- package/dist/hooks/mcps/index.cjs.map +1 -0
- package/dist/hooks/mcps/index.d.ts +7 -0
- package/dist/hooks/mcps/index.d.ts.map +1 -0
- package/dist/hooks/mcps/index.js +208 -0
- package/dist/hooks/mcps/index.js.map +1 -0
- package/dist/hooks/mcps/use-mcp-app-tools.d.ts +21 -0
- package/dist/hooks/mcps/use-mcp-app-tools.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tool.d.ts +25 -0
- package/dist/hooks/mcps/use-mcp-server-tool.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts +13 -0
- package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tools.d.ts +9 -0
- package/dist/hooks/mcps/use-mcp-server-tools.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-servers.d.ts +8 -0
- package/dist/hooks/mcps/use-mcp-servers.d.ts.map +1 -0
- package/dist/hooks/mcps/use-try-connect-mcp.d.ts +15 -0
- package/dist/hooks/mcps/use-try-connect-mcp.d.ts.map +1 -0
- package/dist/hooks/memory/index.cjs +328 -0
- package/dist/hooks/memory/index.cjs.map +1 -0
- package/dist/hooks/memory/index.d.ts +5 -0
- package/dist/hooks/memory/index.d.ts.map +1 -0
- package/dist/hooks/memory/index.js +312 -0
- package/dist/hooks/memory/index.js.map +1 -0
- package/dist/hooks/memory/use-memory-status.d.ts +12 -0
- package/dist/hooks/memory/use-memory-status.d.ts.map +1 -0
- package/dist/hooks/memory/use-memory-thread-messages.d.ts +13 -0
- package/dist/hooks/memory/use-memory-thread-messages.d.ts.map +1 -0
- package/dist/hooks/memory/use-memory.d.ts +159 -0
- package/dist/hooks/memory/use-memory.d.ts.map +1 -0
- package/dist/hooks/memory/use-observational-memory.d.ts +13 -0
- package/dist/hooks/memory/use-observational-memory.d.ts.map +1 -0
- package/dist/hooks/metrics/index.cjs +997 -0
- package/dist/hooks/metrics/index.cjs.map +1 -0
- package/dist/hooks/metrics/index.d.ts +16 -0
- package/dist/hooks/metrics/index.d.ts.map +1 -0
- package/dist/hooks/metrics/index.js +981 -0
- package/dist/hooks/metrics/index.js.map +1 -0
- package/dist/hooks/metrics/metrics-interval.d.ts +8 -0
- package/dist/hooks/metrics/metrics-interval.d.ts.map +1 -0
- package/dist/hooks/metrics/metrics-query-filters.d.ts +62 -0
- package/dist/hooks/metrics/metrics-query-filters.d.ts.map +1 -0
- package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts +12 -0
- package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts +12 -0
- package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts +9 -0
- package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-latency-metrics.d.ts +23 -0
- package/dist/hooks/metrics/use-latency-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts +14 -0
- package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts +16 -0
- package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-scores-metrics.d.ts +24 -0
- package/dist/hooks/metrics/use-scores-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts +15 -0
- package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-token-usage-timeseries.d.ts +22 -0
- package/dist/hooks/metrics/use-token-usage-timeseries.d.ts.map +1 -0
- package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts +21 -0
- package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts +20 -0
- package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts +13 -0
- package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-trace-volume-metrics.d.ts +17 -0
- package/dist/hooks/metrics/use-trace-volume-metrics.d.ts.map +1 -0
- package/dist/hooks/processors/index.cjs +43 -0
- package/dist/hooks/processors/index.cjs.map +1 -0
- package/dist/hooks/processors/index.d.ts +2 -0
- package/dist/hooks/processors/index.d.ts.map +1 -0
- package/dist/hooks/processors/index.js +40 -0
- package/dist/hooks/processors/index.js.map +1 -0
- package/dist/hooks/processors/use-processors.d.ts +64 -0
- package/dist/hooks/processors/use-processors.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/index.cjs +181 -0
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -0
- package/dist/hooks/prompt-blocks/index.d.ts +3 -0
- package/dist/hooks/prompt-blocks/index.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/index.js +172 -0
- package/dist/hooks/prompt-blocks/index.js.map +1 -0
- package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts +59 -0
- package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts +180 -0
- package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts.map +1 -0
- package/dist/hooks/query/index.cjs +34 -0
- package/dist/hooks/query/index.cjs.map +1 -0
- package/dist/hooks/query/index.d.ts +4 -0
- package/dist/hooks/query/index.d.ts.map +1 -0
- package/dist/hooks/query/index.js +25 -0
- package/dist/hooks/query/index.js.map +1 -0
- package/dist/hooks/query/query-client-provider.d.ts +8 -0
- package/dist/hooks/query/query-client-provider.d.ts.map +1 -0
- package/dist/hooks/query/query-utils.d.ts +48 -0
- package/dist/hooks/query/query-utils.d.ts.map +1 -0
- package/dist/hooks/review/index.cjs +89 -0
- package/dist/hooks/review/index.cjs.map +1 -0
- package/dist/hooks/review/index.d.ts +4 -0
- package/dist/hooks/review/index.d.ts.map +1 -0
- package/dist/hooks/review/index.js +86 -0
- package/dist/hooks/review/index.js.map +1 -0
- package/dist/hooks/review/types.d.ts +21 -0
- package/dist/hooks/review/types.d.ts.map +1 -0
- package/dist/hooks/review/use-dataset-review-items.d.ts +19 -0
- package/dist/hooks/review/use-dataset-review-items.d.ts.map +1 -0
- package/dist/hooks/review/use-review-summary.d.ts +9 -0
- package/dist/hooks/review/use-review-summary.d.ts.map +1 -0
- package/dist/hooks/schedules/index.cjs +110 -0
- package/dist/hooks/schedules/index.cjs.map +1 -0
- package/dist/hooks/schedules/index.d.ts +5 -0
- package/dist/hooks/schedules/index.d.ts.map +1 -0
- package/dist/hooks/schedules/index.js +106 -0
- package/dist/hooks/schedules/index.js.map +1 -0
- package/dist/hooks/schedules/use-schedule-triggers.d.ts +18 -0
- package/dist/hooks/schedules/use-schedule-triggers.d.ts.map +1 -0
- package/dist/hooks/schedules/use-schedule.d.ts +11 -0
- package/dist/hooks/schedules/use-schedule.d.ts.map +1 -0
- package/dist/hooks/schedules/use-schedules.d.ts +7 -0
- package/dist/hooks/schedules/use-schedules.d.ts.map +1 -0
- package/dist/hooks/schedules/use-toggle-schedule.d.ts +13 -0
- package/dist/hooks/schedules/use-toggle-schedule.d.ts.map +1 -0
- package/dist/hooks/scores/index.cjs +339 -0
- package/dist/hooks/scores/index.cjs.map +1 -0
- package/dist/hooks/scores/index.d.ts +6 -0
- package/dist/hooks/scores/index.d.ts.map +1 -0
- package/dist/hooks/scores/index.js +323 -0
- package/dist/hooks/scores/index.js.map +1 -0
- package/dist/hooks/scores/use-scorer-versions.d.ts +71 -0
- package/dist/hooks/scores/use-scorer-versions.d.ts.map +1 -0
- package/dist/hooks/scores/use-scorers.d.ts +34 -0
- package/dist/hooks/scores/use-scorers.d.ts.map +1 -0
- package/dist/hooks/scores/use-stored-scorers.d.ts +151 -0
- package/dist/hooks/scores/use-stored-scorers.d.ts.map +1 -0
- package/dist/hooks/scores/use-trace-span-scores.d.ts +20 -0
- package/dist/hooks/scores/use-trace-span-scores.d.ts.map +1 -0
- package/dist/hooks/scores/use-trigger-scorer.d.ts +17 -0
- package/dist/hooks/scores/use-trigger-scorer.d.ts.map +1 -0
- package/dist/hooks/shared/cost.d.ts +7 -0
- package/dist/hooks/shared/cost.d.ts.map +1 -0
- package/dist/hooks/shared/date-format.d.ts +30 -0
- package/dist/hooks/shared/date-format.d.ts.map +1 -0
- package/dist/hooks/shared/map.d.ts +2 -0
- package/dist/hooks/shared/map.d.ts.map +1 -0
- package/dist/hooks/shared/query-options.d.ts +19 -0
- package/dist/hooks/shared/query-options.d.ts.map +1 -0
- package/dist/hooks/shared/use-in-view.d.ts +23 -0
- package/dist/hooks/shared/use-in-view.d.ts.map +1 -0
- package/dist/hooks/templates/index.cjs +464 -0
- package/dist/hooks/templates/index.cjs.map +1 -0
- package/dist/hooks/templates/index.d.ts +2 -0
- package/dist/hooks/templates/index.d.ts.map +1 -0
- package/dist/hooks/templates/index.js +456 -0
- package/dist/hooks/templates/index.js.map +1 -0
- package/dist/hooks/templates/use-templates.d.ts +139 -0
- package/dist/hooks/templates/use-templates.d.ts.map +1 -0
- package/dist/hooks/tool-providers/index.cjs +342 -0
- package/dist/hooks/tool-providers/index.cjs.map +1 -0
- package/dist/hooks/tool-providers/index.d.ts +10 -0
- package/dist/hooks/tool-providers/index.d.ts.map +1 -0
- package/dist/hooks/tool-providers/index.js +332 -0
- package/dist/hooks/tool-providers/index.js.map +1 -0
- package/dist/hooks/tool-providers/use-all-connections.d.ts +41 -0
- package/dist/hooks/tool-providers/use-all-connections.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-all-provider-tools.d.ts +25 -0
- package/dist/hooks/tool-providers/use-all-provider-tools.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-authorize.d.ts +45 -0
- package/dist/hooks/tool-providers/use-authorize.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-disconnect-connection.d.ts +24 -0
- package/dist/hooks/tool-providers/use-disconnect-connection.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-existing-connections.d.ts +33 -0
- package/dist/hooks/tool-providers/use-existing-connections.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-provider-tools.d.ts +17 -0
- package/dist/hooks/tool-providers/use-provider-tools.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-tool-providers.d.ts +23 -0
- package/dist/hooks/tool-providers/use-tool-providers.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-toolkits.d.ts +13 -0
- package/dist/hooks/tool-providers/use-toolkits.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-update-connection.d.ts +24 -0
- package/dist/hooks/tool-providers/use-update-connection.d.ts.map +1 -0
- package/dist/hooks/tools/index.cjs +49 -0
- package/dist/hooks/tools/index.cjs.map +1 -0
- package/dist/hooks/tools/index.d.ts +3 -0
- package/dist/hooks/tools/index.d.ts.map +1 -0
- package/dist/hooks/tools/index.js +46 -0
- package/dist/hooks/tools/index.js.map +1 -0
- package/dist/hooks/tools/use-all-tools.d.ts +16 -0
- package/dist/hooks/tools/use-all-tools.d.ts.map +1 -0
- package/dist/hooks/tools/use-execute-tool.d.ts +13 -0
- package/dist/hooks/tools/use-execute-tool.d.ts.map +1 -0
- package/dist/hooks/traces/discovery-cache.d.ts +12 -0
- package/dist/hooks/traces/discovery-cache.d.ts.map +1 -0
- package/dist/hooks/traces/index.cjs +1168 -0
- package/dist/hooks/traces/index.cjs.map +1 -0
- package/dist/hooks/traces/index.d.ts +22 -0
- package/dist/hooks/traces/index.d.ts.map +1 -0
- package/dist/hooks/traces/index.js +1129 -0
- package/dist/hooks/traces/index.js.map +1 -0
- package/dist/hooks/traces/types.d.ts +20 -0
- package/dist/hooks/traces/types.d.ts.map +1 -0
- package/dist/hooks/traces/use-branch.d.ts +18 -0
- package/dist/hooks/traces/use-branch.d.ts.map +1 -0
- package/dist/hooks/traces/use-create-feedback.d.ts +21 -0
- package/dist/hooks/traces/use-create-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-delete-feedback.d.ts +21 -0
- package/dist/hooks/traces/use-delete-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-entity-names.d.ts +14 -0
- package/dist/hooks/traces/use-entity-names.d.ts.map +1 -0
- package/dist/hooks/traces/use-environments.d.ts +10 -0
- package/dist/hooks/traces/use-environments.d.ts.map +1 -0
- package/dist/hooks/traces/use-service-names.d.ts +10 -0
- package/dist/hooks/traces/use-service-names.d.ts.map +1 -0
- package/dist/hooks/traces/use-span-detail.d.ts +14 -0
- package/dist/hooks/traces/use-span-detail.d.ts.map +1 -0
- package/dist/hooks/traces/use-span-feedback.d.ts +19 -0
- package/dist/hooks/traces/use-span-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-tags.d.ts +10 -0
- package/dist/hooks/traces/use-tags.d.ts.map +1 -0
- package/dist/hooks/traces/use-thread-has-other-traces.d.ts +17 -0
- package/dist/hooks/traces/use-thread-has-other-traces.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts +6 -0
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-feedback.d.ts +16 -0
- package/dist/hooks/traces/use-trace-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-light-spans.d.ts +16 -0
- package/dist/hooks/traces/use-trace-light-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts +36 -0
- package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-or-branch-spans.d.ts +39 -0
- package/dist/hooks/traces/use-trace-or-branch-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-query.d.ts +57 -0
- package/dist/hooks/traces/use-trace-query.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-spans.d.ts +46 -0
- package/dist/hooks/traces/use-trace-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-usage.d.ts +10 -0
- package/dist/hooks/traces/use-trace-usage.d.ts.map +1 -0
- package/dist/hooks/traces/use-traces.d.ts +292 -0
- package/dist/hooks/traces/use-traces.d.ts.map +1 -0
- package/dist/hooks/vectors/index.cjs +19 -0
- package/dist/hooks/vectors/index.cjs.map +1 -0
- package/dist/hooks/vectors/index.d.ts +2 -0
- package/dist/hooks/vectors/index.d.ts.map +1 -0
- package/dist/hooks/vectors/index.js +18 -0
- package/dist/hooks/vectors/index.js.map +1 -0
- package/dist/hooks/vectors/use-vectors.d.ts +14 -0
- package/dist/hooks/vectors/use-vectors.d.ts.map +1 -0
- package/dist/hooks/voice/index.cjs +87 -0
- package/dist/hooks/voice/index.cjs.map +1 -0
- package/dist/hooks/voice/index.d.ts +2 -0
- package/dist/hooks/voice/index.d.ts.map +1 -0
- package/dist/hooks/voice/index.js +86 -0
- package/dist/hooks/voice/index.js.map +1 -0
- package/dist/hooks/voice/use-read-aloud.d.ts +20 -0
- package/dist/hooks/voice/use-read-aloud.d.ts.map +1 -0
- package/dist/hooks/workflows/index.cjs +173 -0
- package/dist/hooks/workflows/index.cjs.map +1 -0
- package/dist/hooks/workflows/index.d.ts +7 -0
- package/dist/hooks/workflows/index.d.ts.map +1 -0
- package/dist/hooks/workflows/index.js +157 -0
- package/dist/hooks/workflows/index.js.map +1 -0
- package/dist/hooks/workflows/use-workflow-runs.d.ts +51 -0
- package/dist/hooks/workflows/use-workflow-runs.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflow.d.ts +14 -0
- package/dist/hooks/workflows/use-workflow.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflows-run-counts.d.ts +25 -0
- package/dist/hooks/workflows/use-workflows-run-counts.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflows.d.ts +10 -0
- package/dist/hooks/workflows/use-workflows.d.ts.map +1 -0
- package/dist/hooks/workspace/client-utils.d.ts +5 -0
- package/dist/hooks/workspace/client-utils.d.ts.map +1 -0
- package/dist/hooks/workspace/compatibility.d.ts +22 -0
- package/dist/hooks/workspace/compatibility.d.ts.map +1 -0
- package/dist/hooks/workspace/file-type.d.ts +7 -0
- package/dist/hooks/workspace/file-type.d.ts.map +1 -0
- package/dist/hooks/workspace/index.cjs +624 -0
- package/dist/hooks/workspace/index.cjs.map +1 -0
- package/dist/hooks/workspace/index.d.ts +11 -0
- package/dist/hooks/workspace/index.d.ts.map +1 -0
- package/dist/hooks/workspace/index.js +594 -0
- package/dist/hooks/workspace/index.js.map +1 -0
- package/dist/hooks/workspace/types.d.ts +199 -0
- package/dist/hooks/workspace/types.d.ts.map +1 -0
- package/dist/hooks/workspace/use-skills-sh.d.ts +104 -0
- package/dist/hooks/workspace/use-skills-sh.d.ts.map +1 -0
- package/dist/hooks/workspace/use-stored-workspaces.d.ts +12 -0
- package/dist/hooks/workspace/use-stored-workspaces.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-directory.d.ts +13 -0
- package/dist/hooks/workspace/use-workspace-directory.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-file-content.d.ts +15 -0
- package/dist/hooks/workspace/use-workspace-file-content.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-search.d.ts +20 -0
- package/dist/hooks/workspace/use-workspace-search.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-skills.d.ts +23 -0
- package/dist/hooks/workspace/use-workspace-skills.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace.d.ts +56 -0
- package/dist/hooks/workspace/use-workspace.d.ts.map +1 -0
- package/dist/hooks-BFQK_s4g.js +1231 -0
- package/dist/hooks-BFQK_s4g.js.map +1 -0
- package/dist/hooks-CMjizg6y.cjs +1248 -0
- package/dist/hooks-CMjizg6y.cjs.map +1 -0
- package/dist/hooks-CjULNHpJ.js +252 -0
- package/dist/hooks-CjULNHpJ.js.map +1 -0
- package/dist/hooks-DsDYaJ3T.cjs +269 -0
- package/dist/hooks-DsDYaJ3T.cjs.map +1 -0
- package/dist/index.cjs +21 -3434
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3419
- package/dist/index.js.map +1 -1
- package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +3 -4
- package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -1
- package/dist/map-CDv4fbu4.js +12 -0
- package/dist/map-CDv4fbu4.js.map +1 -0
- package/dist/map-wjmL1y5O.cjs +17 -0
- package/dist/map-wjmL1y5O.cjs.map +1 -0
- package/dist/mastra-client-context-Bx_g84YB.js +50 -0
- package/dist/mastra-client-context-Bx_g84YB.js.map +1 -0
- package/dist/mastra-client-context-DzX3f0RF.cjs +61 -0
- package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -0
- package/dist/query-utils-CcrChYgz.cjs +174 -0
- package/dist/query-utils-CcrChYgz.cjs.map +1 -0
- package/dist/query-utils-D1NgFnWU.js +127 -0
- package/dist/query-utils-D1NgFnWU.js.map +1 -0
- package/dist/use-in-view-B6eJO9Zi.cjs +37 -0
- package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -0
- package/dist/use-in-view-C9sYPGRm.js +32 -0
- package/dist/use-in-view-C9sYPGRm.js.map +1 -0
- package/dist/voice-BOtUdMi8.cjs +281 -0
- package/dist/voice-BOtUdMi8.cjs.map +1 -0
- package/dist/voice-DgirjEyH.js +264 -0
- package/dist/voice-DgirjEyH.js.map +1 -0
- package/package.json +32 -3
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
|
|
3
|
+
const require_map = require("../../map-wjmL1y5O.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
|
+
//#region src/hooks/metrics/metrics-query-filters.ts
|
|
7
|
+
const DEFAULT_WINDOW_MS = 1440 * 60 * 1e3;
|
|
8
|
+
const PRESET_MS = {
|
|
9
|
+
"24h": DEFAULT_WINDOW_MS,
|
|
10
|
+
"3d": 4320 * 60 * 1e3,
|
|
11
|
+
"7d": 10080 * 60 * 1e3,
|
|
12
|
+
"14d": 336 * 60 * 60 * 1e3,
|
|
13
|
+
"30d": 720 * 60 * 60 * 1e3
|
|
14
|
+
};
|
|
15
|
+
function buildTimestamp(preset, customRange, anchor) {
|
|
16
|
+
if (preset !== "custom") {
|
|
17
|
+
const ms = PRESET_MS[preset] ?? DEFAULT_WINDOW_MS;
|
|
18
|
+
return {
|
|
19
|
+
start: new Date(anchor - ms),
|
|
20
|
+
end: new Date(anchor)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
start: customRange?.from ?? /* @__PURE__ */ new Date(anchor - DEFAULT_WINDOW_MS),
|
|
25
|
+
end: customRange?.to ?? new Date(anchor)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compose a ready-to-use metrics filter object from a date window and a
|
|
30
|
+
* dimensional filter. Pass the result to the metrics hooks.
|
|
31
|
+
*
|
|
32
|
+
* Stability guarantees (important for react-query):
|
|
33
|
+
* - `timestamp` is frozen at the moment the inputs change and does NOT update
|
|
34
|
+
* on every render. Otherwise each render would mint a new `new Date()` and
|
|
35
|
+
* every metrics query would re-fetch on every keystroke.
|
|
36
|
+
* - `filters` and `filterKey` are referentially stable while inputs are
|
|
37
|
+
* unchanged, so `queryKey` hashing is cheap and caches hit.
|
|
38
|
+
*/
|
|
39
|
+
function useMetricsQueryFilters({ datePreset, customRange, dimensionalFilter, dimensionalFilterKey }) {
|
|
40
|
+
const anchorRef = (0, react.useRef)(null);
|
|
41
|
+
const windowKey = datePreset === "custom" ? `custom:${customRange?.from?.getTime() ?? ""}:${customRange?.to?.getTime() ?? ""}` : `preset:${datePreset}`;
|
|
42
|
+
if (!anchorRef.current || anchorRef.current.key !== windowKey) anchorRef.current = {
|
|
43
|
+
key: windowKey,
|
|
44
|
+
anchor: Date.now()
|
|
45
|
+
};
|
|
46
|
+
const anchor = anchorRef.current.anchor;
|
|
47
|
+
const timestamp = (0, react.useMemo)(() => buildTimestamp(datePreset, customRange, anchor), [
|
|
48
|
+
datePreset,
|
|
49
|
+
customRange,
|
|
50
|
+
anchor
|
|
51
|
+
]);
|
|
52
|
+
return {
|
|
53
|
+
datePreset,
|
|
54
|
+
customRange,
|
|
55
|
+
timestamp,
|
|
56
|
+
filters: (0, react.useMemo)(() => ({
|
|
57
|
+
timestamp,
|
|
58
|
+
...dimensionalFilter
|
|
59
|
+
}), [timestamp, dimensionalFilterKey]),
|
|
60
|
+
dimensionalFilter,
|
|
61
|
+
filterKey: (0, react.useMemo)(() => `${windowKey}|${dimensionalFilterKey}`, [windowKey, dimensionalFilterKey])
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/hooks/shared/date-format.ts
|
|
66
|
+
function toDate(value) {
|
|
67
|
+
if (value == null) return void 0;
|
|
68
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
69
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
70
|
+
}
|
|
71
|
+
const PRESET_OPTIONS = {
|
|
72
|
+
time: {
|
|
73
|
+
hour: "numeric",
|
|
74
|
+
minute: "2-digit"
|
|
75
|
+
},
|
|
76
|
+
"time-seconds": {
|
|
77
|
+
hour: "numeric",
|
|
78
|
+
minute: "2-digit",
|
|
79
|
+
second: "2-digit"
|
|
80
|
+
},
|
|
81
|
+
"date-time": {
|
|
82
|
+
month: "short",
|
|
83
|
+
day: "numeric",
|
|
84
|
+
year: "numeric",
|
|
85
|
+
hour: "numeric",
|
|
86
|
+
minute: "2-digit"
|
|
87
|
+
},
|
|
88
|
+
"date-time-seconds": {
|
|
89
|
+
month: "short",
|
|
90
|
+
day: "numeric",
|
|
91
|
+
year: "numeric",
|
|
92
|
+
hour: "numeric",
|
|
93
|
+
minute: "2-digit",
|
|
94
|
+
second: "2-digit"
|
|
95
|
+
},
|
|
96
|
+
"day-time-seconds": {
|
|
97
|
+
month: "short",
|
|
98
|
+
day: "numeric",
|
|
99
|
+
hour: "numeric",
|
|
100
|
+
minute: "2-digit",
|
|
101
|
+
second: "2-digit"
|
|
102
|
+
},
|
|
103
|
+
calendar: {
|
|
104
|
+
year: "numeric",
|
|
105
|
+
month: "numeric",
|
|
106
|
+
day: "numeric",
|
|
107
|
+
calendar: "gregory",
|
|
108
|
+
numberingSystem: "latn"
|
|
109
|
+
},
|
|
110
|
+
dayMonth: {
|
|
111
|
+
month: "short",
|
|
112
|
+
day: "numeric"
|
|
113
|
+
},
|
|
114
|
+
dayMonthYear: {
|
|
115
|
+
month: "short",
|
|
116
|
+
day: "numeric",
|
|
117
|
+
year: "numeric"
|
|
118
|
+
},
|
|
119
|
+
precise: {
|
|
120
|
+
month: "short",
|
|
121
|
+
day: "numeric",
|
|
122
|
+
year: "numeric",
|
|
123
|
+
hour: "numeric",
|
|
124
|
+
minute: "2-digit",
|
|
125
|
+
second: "2-digit",
|
|
126
|
+
fractionalSecondDigits: 3
|
|
127
|
+
},
|
|
128
|
+
timePrecise: {
|
|
129
|
+
hour: "numeric",
|
|
130
|
+
minute: "2-digit",
|
|
131
|
+
second: "2-digit",
|
|
132
|
+
fractionalSecondDigits: 3
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const formatters = /* @__PURE__ */ new Map();
|
|
136
|
+
function getFormatter(key, locale, timeZone) {
|
|
137
|
+
const cacheKey = `${locale ?? ""}|${timeZone ?? ""}|${key}`;
|
|
138
|
+
let formatter = formatters.get(cacheKey);
|
|
139
|
+
if (!formatter) {
|
|
140
|
+
formatter = new Intl.DateTimeFormat(locale, {
|
|
141
|
+
...PRESET_OPTIONS[key],
|
|
142
|
+
timeZone
|
|
143
|
+
});
|
|
144
|
+
formatters.set(cacheKey, formatter);
|
|
145
|
+
}
|
|
146
|
+
return formatter;
|
|
147
|
+
}
|
|
148
|
+
function calendarDate(date, timeZone) {
|
|
149
|
+
const parts = getFormatter("calendar", "en-US", timeZone).formatToParts(date);
|
|
150
|
+
return {
|
|
151
|
+
year: parts.find((part) => part.type === "year")?.value,
|
|
152
|
+
month: parts.find((part) => part.type === "month")?.value,
|
|
153
|
+
day: parts.find((part) => part.type === "day")?.value
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Short absolute date without time: `Sep 24` this year, `Sep 24, 2025` otherwise. */
|
|
157
|
+
function formatShortDate(value, { locale, now, timeZone } = {}) {
|
|
158
|
+
const date = toDate(value);
|
|
159
|
+
if (!date) return void 0;
|
|
160
|
+
const reference = new Date(now ?? Date.now());
|
|
161
|
+
return getFormatter(calendarDate(date, timeZone).year === calendarDate(reference, timeZone).year ? "dayMonth" : "dayMonthYear", locale, timeZone).format(date);
|
|
162
|
+
}
|
|
163
|
+
const LONG_RELATIVE_UNITS = [
|
|
164
|
+
["year", 365 * 86400],
|
|
165
|
+
["month", 30 * 86400],
|
|
166
|
+
["week", 7 * 86400],
|
|
167
|
+
["day", 86400],
|
|
168
|
+
["hour", 3600],
|
|
169
|
+
["minute", 60]
|
|
170
|
+
];
|
|
171
|
+
const relativeFormatters = /* @__PURE__ */ new Map();
|
|
172
|
+
function getRelativeFormatter(locale) {
|
|
173
|
+
const key = locale ?? "";
|
|
174
|
+
let formatter = relativeFormatters.get(key);
|
|
175
|
+
if (!formatter) {
|
|
176
|
+
formatter = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
177
|
+
relativeFormatters.set(key, formatter);
|
|
178
|
+
}
|
|
179
|
+
return formatter;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Uses the browser locale unless `locale` is given.
|
|
183
|
+
* - `date`: date only; omits the year when it matches `now` in the requested timezone
|
|
184
|
+
* - `date-time`: date, year and time to minutes, including historical dates
|
|
185
|
+
* - `date-time-seconds`: date, year and time to seconds
|
|
186
|
+
* - `day-time-seconds`: month, day and time to seconds, without the year
|
|
187
|
+
* - `time`: time to minutes, without a date
|
|
188
|
+
* - `time-seconds`: time to seconds, without a date
|
|
189
|
+
* - `relative-time`: short relative label; delegates to `date` at seven days
|
|
190
|
+
*/
|
|
191
|
+
function formatDate(value, preset, options = {}) {
|
|
192
|
+
const date = toDate(value);
|
|
193
|
+
if (!date) return void 0;
|
|
194
|
+
const { locale, now, timeZone } = options;
|
|
195
|
+
if (preset === "relative-time") {
|
|
196
|
+
const diff = date.getTime() - new Date(now ?? Date.now()).getTime();
|
|
197
|
+
const abs = Math.abs(diff);
|
|
198
|
+
if (abs < 5e3) return "just now";
|
|
199
|
+
const match = [
|
|
200
|
+
{
|
|
201
|
+
limit: 6e4,
|
|
202
|
+
size: 1e3,
|
|
203
|
+
unit: "s"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
limit: 36e5,
|
|
207
|
+
size: 6e4,
|
|
208
|
+
unit: "m"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
limit: 864e5,
|
|
212
|
+
size: 36e5,
|
|
213
|
+
unit: "h"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
limit: 7 * 864e5,
|
|
217
|
+
size: 864e5,
|
|
218
|
+
unit: "d"
|
|
219
|
+
}
|
|
220
|
+
].find(({ limit }) => abs < limit);
|
|
221
|
+
if (!match) return formatDate(date, "date", options);
|
|
222
|
+
const label = `${Math.floor(abs / match.size)}${match.unit}`;
|
|
223
|
+
return diff < 0 ? `${label} ago` : `in ${label}`;
|
|
224
|
+
}
|
|
225
|
+
if (preset === "relative-long") {
|
|
226
|
+
const seconds = (date.getTime() - new Date(now ?? Date.now()).getTime()) / 1e3;
|
|
227
|
+
const [unit, size] = LONG_RELATIVE_UNITS.find(([, size]) => Math.abs(seconds) >= size) ?? ["second", 1];
|
|
228
|
+
return getRelativeFormatter(locale).format(Math.round(seconds / size), unit);
|
|
229
|
+
}
|
|
230
|
+
if (preset === "date") return formatShortDate(date, options);
|
|
231
|
+
return getFormatter(preset, locale, timeZone).format(date);
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/hooks/metrics/metrics-interval.ts
|
|
235
|
+
const HOURLY_MAX_RANGE_MS = 2880 * 60 * 1e3;
|
|
236
|
+
/** Hourly buckets up to 48h, daily buckets beyond, so long ranges stay readable. */
|
|
237
|
+
function chooseMetricsInterval({ start, end }) {
|
|
238
|
+
return end.getTime() - start.getTime() <= HOURLY_MAX_RANGE_MS ? "1h" : "1d";
|
|
239
|
+
}
|
|
240
|
+
function formatMetricsBucketLabel(ts, interval) {
|
|
241
|
+
if (interval === "1h") return formatDate(ts, "time") ?? "";
|
|
242
|
+
return formatShortDate(ts) ?? "";
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/hooks/metrics/use-active-resources-kpi-metrics.tsx
|
|
246
|
+
/** Active Resources — number of distinct resource IDs observed in agent runs.
|
|
247
|
+
* Uses approximate `count_distinct` (HyperLogLog on ClickHouse,
|
|
248
|
+
* `approx_count_distinct` on DuckDB) so the query stays fast even on
|
|
249
|
+
* tens of millions of rows. */
|
|
250
|
+
function useActiveResourcesKpiMetrics(params) {
|
|
251
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
252
|
+
const { filters, filterKey, queryOptions } = params;
|
|
253
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
254
|
+
queryKey: [
|
|
255
|
+
"metrics",
|
|
256
|
+
"active-resources-kpi",
|
|
257
|
+
filterKey
|
|
258
|
+
],
|
|
259
|
+
queryFn: () => client.getMetricAggregate({
|
|
260
|
+
name: ["mastra_agent_duration_ms"],
|
|
261
|
+
aggregation: "count_distinct",
|
|
262
|
+
distinctColumn: "resourceId",
|
|
263
|
+
filters,
|
|
264
|
+
comparePeriod: "previous_period"
|
|
265
|
+
}),
|
|
266
|
+
...queryOptions
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/hooks/metrics/use-active-threads-kpi-metrics.tsx
|
|
271
|
+
/** Active Threads — number of distinct thread IDs observed in agent runs.
|
|
272
|
+
* Uses approximate `count_distinct` (HyperLogLog on ClickHouse,
|
|
273
|
+
* `approx_count_distinct` on DuckDB) so the query stays fast even on
|
|
274
|
+
* tens of millions of rows. */
|
|
275
|
+
function useActiveThreadsKpiMetrics(params) {
|
|
276
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
277
|
+
const { filters, filterKey, queryOptions } = params;
|
|
278
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
279
|
+
queryKey: [
|
|
280
|
+
"metrics",
|
|
281
|
+
"active-threads-kpi",
|
|
282
|
+
filterKey
|
|
283
|
+
],
|
|
284
|
+
queryFn: () => client.getMetricAggregate({
|
|
285
|
+
name: ["mastra_agent_duration_ms"],
|
|
286
|
+
aggregation: "count_distinct",
|
|
287
|
+
distinctColumn: "threadId",
|
|
288
|
+
filters,
|
|
289
|
+
comparePeriod: "previous_period"
|
|
290
|
+
}),
|
|
291
|
+
...queryOptions
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/hooks/metrics/use-agent-runs-kpi-metrics.tsx
|
|
296
|
+
/** Total Agent Runs — count of agent duration metric observations */
|
|
297
|
+
function useAgentRunsKpiMetrics(params) {
|
|
298
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
299
|
+
const { filters, filterKey, queryOptions } = params;
|
|
300
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
301
|
+
queryKey: [
|
|
302
|
+
"metrics",
|
|
303
|
+
"agent-runs-kpi",
|
|
304
|
+
filterKey
|
|
305
|
+
],
|
|
306
|
+
queryFn: () => client.getMetricAggregate({
|
|
307
|
+
name: ["mastra_agent_duration_ms"],
|
|
308
|
+
aggregation: "count",
|
|
309
|
+
filters,
|
|
310
|
+
comparePeriod: "previous_period"
|
|
311
|
+
}),
|
|
312
|
+
...queryOptions
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/hooks/metrics/use-latency-metrics.tsx
|
|
317
|
+
async function fetchPercentiles(client, metricName, filters, interval) {
|
|
318
|
+
const res = await client.getMetricPercentiles({
|
|
319
|
+
name: metricName,
|
|
320
|
+
percentiles: [.5, .95],
|
|
321
|
+
interval,
|
|
322
|
+
filters
|
|
323
|
+
});
|
|
324
|
+
const p50Series = res.series.find((s) => s.percentile === .5);
|
|
325
|
+
const p95Series = res.series.find((s) => s.percentile === .95);
|
|
326
|
+
if (!p50Series || !p95Series) return [];
|
|
327
|
+
const p95Map = new Map(p95Series.points.map((p) => [new Date(p.timestamp).getTime(), p.value]));
|
|
328
|
+
return p50Series.points.map((p) => {
|
|
329
|
+
const ts = new Date(p.timestamp);
|
|
330
|
+
const tsMs = ts.getTime();
|
|
331
|
+
return {
|
|
332
|
+
time: formatMetricsBucketLabel(ts, interval),
|
|
333
|
+
tsMs,
|
|
334
|
+
p50: Math.round(p.value),
|
|
335
|
+
p95: Math.round(p95Map.get(tsMs) ?? 0)
|
|
336
|
+
};
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function useLatencyMetrics(params) {
|
|
340
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
341
|
+
const { timestamp, filters, filterKey, queryOptions } = params;
|
|
342
|
+
const interval = chooseMetricsInterval(timestamp);
|
|
343
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
344
|
+
queryKey: [
|
|
345
|
+
"metrics",
|
|
346
|
+
"latency",
|
|
347
|
+
filterKey,
|
|
348
|
+
interval
|
|
349
|
+
],
|
|
350
|
+
queryFn: async () => {
|
|
351
|
+
const [agentData, workflowData, toolData] = await Promise.all([
|
|
352
|
+
fetchPercentiles(client, "mastra_agent_duration_ms", filters, interval),
|
|
353
|
+
fetchPercentiles(client, "mastra_workflow_duration_ms", filters, interval),
|
|
354
|
+
fetchPercentiles(client, "mastra_tool_duration_ms", filters, interval)
|
|
355
|
+
]);
|
|
356
|
+
return {
|
|
357
|
+
agentData,
|
|
358
|
+
workflowData,
|
|
359
|
+
toolData,
|
|
360
|
+
interval
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
...queryOptions
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/hooks/metrics/use-model-cost-kpi-metrics.tsx
|
|
368
|
+
function useModelCostKpiMetrics(params) {
|
|
369
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
370
|
+
const { filters, filterKey, queryOptions } = params;
|
|
371
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
372
|
+
queryKey: [
|
|
373
|
+
"metrics",
|
|
374
|
+
"model-cost-kpi",
|
|
375
|
+
filterKey
|
|
376
|
+
],
|
|
377
|
+
queryFn: async () => {
|
|
378
|
+
const res = await client.getMetricAggregate({
|
|
379
|
+
name: ["mastra_model_total_input_tokens", "mastra_model_total_output_tokens"],
|
|
380
|
+
aggregation: "sum",
|
|
381
|
+
filters,
|
|
382
|
+
comparePeriod: "previous_period"
|
|
383
|
+
});
|
|
384
|
+
return {
|
|
385
|
+
cost: res.estimatedCost ?? null,
|
|
386
|
+
costUnit: res.costUnit ?? null,
|
|
387
|
+
previousCost: res.previousEstimatedCost ?? null,
|
|
388
|
+
costChangePercent: res.costChangePercent ?? null
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
...queryOptions
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/hooks/shared/cost.ts
|
|
396
|
+
const compactNumber = new Intl.NumberFormat("en-US", {
|
|
397
|
+
notation: "compact",
|
|
398
|
+
maximumSignificantDigits: 3
|
|
399
|
+
});
|
|
400
|
+
const fullNumber = new Intl.NumberFormat("en-US");
|
|
401
|
+
const currencyCodes = new Set(Intl.supportedValuesOf("currency"));
|
|
402
|
+
function isCurrency(code) {
|
|
403
|
+
return code !== void 0 && currencyCodes.has(code.toUpperCase());
|
|
404
|
+
}
|
|
405
|
+
function money(currency, options) {
|
|
406
|
+
return new Intl.NumberFormat("en-US", {
|
|
407
|
+
style: "currency",
|
|
408
|
+
currency,
|
|
409
|
+
...options
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function formatCompactNumber(value, { currency } = {}) {
|
|
413
|
+
if (!isCurrency(currency)) return compactNumber.format(value);
|
|
414
|
+
const size = Math.abs(value);
|
|
415
|
+
if (size < 100) return formatFullNumber(value, { currency });
|
|
416
|
+
if (size < 1e3) return money(currency, { maximumFractionDigits: 0 }).format(value);
|
|
417
|
+
return money(currency, {
|
|
418
|
+
notation: "compact",
|
|
419
|
+
maximumSignificantDigits: 3
|
|
420
|
+
}).format(value);
|
|
421
|
+
}
|
|
422
|
+
function formatFullNumber(value, { currency } = {}) {
|
|
423
|
+
if (!isCurrency(currency)) return fullNumber.format(value);
|
|
424
|
+
const formatter = money(currency, {});
|
|
425
|
+
const smallestUnit = 10 ** -(formatter.resolvedOptions().maximumFractionDigits ?? 2);
|
|
426
|
+
if (value !== 0 && Math.abs(value) < smallestUnit) return `${value < 0 ? "-" : ""}<${formatter.format(smallestUnit)}`;
|
|
427
|
+
return formatter.format(value);
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/hooks/metrics/use-model-usage-cost-metrics.tsx
|
|
431
|
+
function useModelUsageCostMetrics(params) {
|
|
432
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
433
|
+
const { filters, filterKey, queryOptions } = params;
|
|
434
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
435
|
+
queryKey: [
|
|
436
|
+
"metrics",
|
|
437
|
+
"model-usage-cost",
|
|
438
|
+
filterKey
|
|
439
|
+
],
|
|
440
|
+
queryFn: async () => {
|
|
441
|
+
const [inputRes, outputRes, cacheReadRes, cacheWriteRes] = await Promise.all([
|
|
442
|
+
"mastra_model_total_input_tokens",
|
|
443
|
+
"mastra_model_total_output_tokens",
|
|
444
|
+
"mastra_model_input_cache_read_tokens",
|
|
445
|
+
"mastra_model_input_cache_write_tokens"
|
|
446
|
+
].map((name) => client.getMetricBreakdown({
|
|
447
|
+
name: [name],
|
|
448
|
+
groupBy: ["model"],
|
|
449
|
+
aggregation: "sum",
|
|
450
|
+
orderDirection: "DESC",
|
|
451
|
+
filters
|
|
452
|
+
})));
|
|
453
|
+
if (!inputRes || !outputRes || !cacheReadRes || !cacheWriteRes) return [];
|
|
454
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
455
|
+
const ensureModel = (model) => require_map.getOrCreate(modelMap, model, () => ({
|
|
456
|
+
input: 0,
|
|
457
|
+
output: 0,
|
|
458
|
+
cacheRead: 0,
|
|
459
|
+
cacheWrite: 0,
|
|
460
|
+
cost: null,
|
|
461
|
+
costUnit: null
|
|
462
|
+
}));
|
|
463
|
+
const addCost = (entry, group) => {
|
|
464
|
+
if (group.estimatedCost != null) {
|
|
465
|
+
entry.cost = (entry.cost ?? 0) + group.estimatedCost;
|
|
466
|
+
if (group.costUnit) entry.costUnit = group.costUnit;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
for (const group of inputRes.groups) {
|
|
470
|
+
const entry = ensureModel(group.dimensions.model ?? "unknown");
|
|
471
|
+
entry.input = group.value;
|
|
472
|
+
addCost(entry, group);
|
|
473
|
+
}
|
|
474
|
+
for (const group of outputRes.groups) {
|
|
475
|
+
const entry = ensureModel(group.dimensions.model ?? "unknown");
|
|
476
|
+
entry.output = group.value;
|
|
477
|
+
addCost(entry, group);
|
|
478
|
+
}
|
|
479
|
+
for (const group of cacheReadRes.groups) {
|
|
480
|
+
const entry = ensureModel(group.dimensions.model ?? "unknown");
|
|
481
|
+
entry.cacheRead = group.value;
|
|
482
|
+
}
|
|
483
|
+
for (const group of cacheWriteRes.groups) {
|
|
484
|
+
const entry = ensureModel(group.dimensions.model ?? "unknown");
|
|
485
|
+
entry.cacheWrite = group.value;
|
|
486
|
+
}
|
|
487
|
+
return Array.from(modelMap.entries()).map(([model, vals]) => ({
|
|
488
|
+
model,
|
|
489
|
+
input: formatCompactNumber(vals.input),
|
|
490
|
+
output: formatCompactNumber(vals.output),
|
|
491
|
+
cacheRead: formatCompactNumber(vals.cacheRead),
|
|
492
|
+
cacheWrite: formatCompactNumber(vals.cacheWrite),
|
|
493
|
+
cost: vals.cost,
|
|
494
|
+
costUnit: vals.costUnit
|
|
495
|
+
})).sort((a, b) => a.model.localeCompare(b.model));
|
|
496
|
+
},
|
|
497
|
+
...queryOptions
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/hooks/metrics/use-scores-metrics.tsx
|
|
502
|
+
function useScoresMetrics(params) {
|
|
503
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
504
|
+
const { datePreset, customRange, timestamp, queryOptions } = params;
|
|
505
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
506
|
+
queryKey: [
|
|
507
|
+
"metrics",
|
|
508
|
+
"scores-card",
|
|
509
|
+
datePreset,
|
|
510
|
+
customRange
|
|
511
|
+
],
|
|
512
|
+
queryFn: async () => {
|
|
513
|
+
const filters = { timestamp: {
|
|
514
|
+
start: timestamp.start,
|
|
515
|
+
end: timestamp.end
|
|
516
|
+
} };
|
|
517
|
+
const scorersMap = await client.listScorers();
|
|
518
|
+
const scorerIds = Object.keys(scorersMap ?? {});
|
|
519
|
+
if (scorerIds.length === 0) return {
|
|
520
|
+
summaryData: [],
|
|
521
|
+
overTimeData: [],
|
|
522
|
+
scorerNames: [],
|
|
523
|
+
avgScore: null
|
|
524
|
+
};
|
|
525
|
+
const summaryData = (await Promise.all(scorerIds.map(async (scorerId) => {
|
|
526
|
+
const [avg, min, max, count] = await Promise.all([
|
|
527
|
+
client.getScoreAggregate({
|
|
528
|
+
scorerId,
|
|
529
|
+
aggregation: "avg",
|
|
530
|
+
filters
|
|
531
|
+
}),
|
|
532
|
+
client.getScoreAggregate({
|
|
533
|
+
scorerId,
|
|
534
|
+
aggregation: "min",
|
|
535
|
+
filters
|
|
536
|
+
}),
|
|
537
|
+
client.getScoreAggregate({
|
|
538
|
+
scorerId,
|
|
539
|
+
aggregation: "max",
|
|
540
|
+
filters
|
|
541
|
+
}),
|
|
542
|
+
client.getScoreAggregate({
|
|
543
|
+
scorerId,
|
|
544
|
+
aggregation: "count",
|
|
545
|
+
filters
|
|
546
|
+
})
|
|
547
|
+
]);
|
|
548
|
+
return {
|
|
549
|
+
scorer: scorerId,
|
|
550
|
+
avg: avg.value ?? 0,
|
|
551
|
+
min: min.value ?? 0,
|
|
552
|
+
max: max.value ?? 0,
|
|
553
|
+
count: count.value ?? 0
|
|
554
|
+
};
|
|
555
|
+
}))).filter((s) => s.count > 0);
|
|
556
|
+
const scorerNames = summaryData.map((s) => s.scorer);
|
|
557
|
+
if (summaryData.length === 0) return {
|
|
558
|
+
summaryData: [],
|
|
559
|
+
overTimeData: [],
|
|
560
|
+
scorerNames: [],
|
|
561
|
+
avgScore: null
|
|
562
|
+
};
|
|
563
|
+
const totalWeighted = summaryData.reduce((s, d) => s + d.avg * d.count, 0);
|
|
564
|
+
const totalCount = summaryData.reduce((s, d) => s + d.count, 0);
|
|
565
|
+
const avgScore = totalCount ? Math.round(totalWeighted / totalCount * 100) / 100 : 0;
|
|
566
|
+
const interval = "1h";
|
|
567
|
+
const timeSeriesResults = await Promise.all(scorerNames.map((scorerId) => client.getScoreTimeSeries({
|
|
568
|
+
scorerId,
|
|
569
|
+
interval,
|
|
570
|
+
aggregation: "avg",
|
|
571
|
+
filters
|
|
572
|
+
})));
|
|
573
|
+
const hourBuckets = /* @__PURE__ */ new Map();
|
|
574
|
+
for (let i = 0; i < scorerNames.length; i++) {
|
|
575
|
+
const scorerId = scorerNames[i];
|
|
576
|
+
const series = timeSeriesResults[i]?.series ?? [];
|
|
577
|
+
for (const s of series) for (const point of s.points) {
|
|
578
|
+
const ts = new Date(point.timestamp);
|
|
579
|
+
const acc = require_map.getOrCreate(require_map.getOrCreate(hourBuckets, ts.getHours() * 60 + ts.getMinutes(), () => /* @__PURE__ */ new Map()), scorerId, () => ({
|
|
580
|
+
sum: 0,
|
|
581
|
+
count: 0
|
|
582
|
+
}));
|
|
583
|
+
acc.sum += point.value;
|
|
584
|
+
acc.count += 1;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
summaryData,
|
|
589
|
+
overTimeData: Array.from(hourBuckets.entries()).sort(([a], [b]) => a - b).map(([hourKey, scorerMap]) => {
|
|
590
|
+
const point = { time: formatDate(new Date(2e3, 0, 1, Math.floor(hourKey / 60), hourKey % 60), "time") ?? "" };
|
|
591
|
+
for (const [scorerId, acc] of scorerMap) point[scorerId] = +(acc.sum / acc.count).toFixed(2);
|
|
592
|
+
return point;
|
|
593
|
+
}),
|
|
594
|
+
scorerNames,
|
|
595
|
+
avgScore
|
|
596
|
+
};
|
|
597
|
+
},
|
|
598
|
+
...queryOptions
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
//#endregion
|
|
602
|
+
//#region src/hooks/metrics/use-token-usage-by-agent-metrics.tsx
|
|
603
|
+
function useTokenUsageByAgentMetrics(params) {
|
|
604
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
605
|
+
const { filters, filterKey, queryOptions } = params;
|
|
606
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
607
|
+
queryKey: [
|
|
608
|
+
"metrics",
|
|
609
|
+
"token-usage-by-agent",
|
|
610
|
+
filterKey
|
|
611
|
+
],
|
|
612
|
+
queryFn: async () => {
|
|
613
|
+
const breakdownBase = {
|
|
614
|
+
groupBy: ["entityName"],
|
|
615
|
+
aggregation: "sum",
|
|
616
|
+
orderDirection: "DESC",
|
|
617
|
+
filters
|
|
618
|
+
};
|
|
619
|
+
const [inputRes, outputRes] = await Promise.all([client.getMetricBreakdown({
|
|
620
|
+
...breakdownBase,
|
|
621
|
+
name: ["mastra_model_total_input_tokens"]
|
|
622
|
+
}), client.getMetricBreakdown({
|
|
623
|
+
...breakdownBase,
|
|
624
|
+
name: ["mastra_model_total_output_tokens"]
|
|
625
|
+
})]);
|
|
626
|
+
const agentMap = /* @__PURE__ */ new Map();
|
|
627
|
+
const ensure = (name) => require_map.getOrCreate(agentMap, name, () => ({
|
|
628
|
+
input: 0,
|
|
629
|
+
output: 0,
|
|
630
|
+
cost: null,
|
|
631
|
+
costUnit: null
|
|
632
|
+
}));
|
|
633
|
+
const addCost = (entry, group) => {
|
|
634
|
+
if (group.estimatedCost != null) {
|
|
635
|
+
entry.cost = (entry.cost ?? 0) + group.estimatedCost;
|
|
636
|
+
if (group.costUnit) entry.costUnit = group.costUnit;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
for (const group of inputRes.groups) {
|
|
640
|
+
const entry = ensure(group.dimensions.entityName ?? "unknown");
|
|
641
|
+
entry.input = group.value;
|
|
642
|
+
addCost(entry, group);
|
|
643
|
+
}
|
|
644
|
+
for (const group of outputRes.groups) {
|
|
645
|
+
const entry = ensure(group.dimensions.entityName ?? "unknown");
|
|
646
|
+
entry.output = group.value;
|
|
647
|
+
addCost(entry, group);
|
|
648
|
+
}
|
|
649
|
+
return Array.from(agentMap.entries()).map(([name, vals]) => ({
|
|
650
|
+
name,
|
|
651
|
+
input: vals.input,
|
|
652
|
+
output: vals.output,
|
|
653
|
+
total: vals.input + vals.output,
|
|
654
|
+
cost: vals.cost,
|
|
655
|
+
costUnit: vals.costUnit
|
|
656
|
+
})).sort((a, b) => b.total - a.total);
|
|
657
|
+
},
|
|
658
|
+
...queryOptions
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/hooks/metrics/use-token-usage-timeseries.tsx
|
|
663
|
+
function addSeriesPoints(pointMap, series, key) {
|
|
664
|
+
for (const point of series?.points ?? []) {
|
|
665
|
+
const tsMs = new Date(point.timestamp).getTime();
|
|
666
|
+
if (!Number.isFinite(tsMs)) continue;
|
|
667
|
+
const existing = pointMap.get(tsMs) ?? {
|
|
668
|
+
tsMs,
|
|
669
|
+
input: 0,
|
|
670
|
+
output: 0,
|
|
671
|
+
cost: null,
|
|
672
|
+
costUnits: /* @__PURE__ */ new Set(),
|
|
673
|
+
hasUnknownCostUnit: false
|
|
674
|
+
};
|
|
675
|
+
existing[key] += point.value;
|
|
676
|
+
if (point.estimatedCost != null) {
|
|
677
|
+
existing.cost = (existing.cost ?? 0) + point.estimatedCost;
|
|
678
|
+
if (series?.costUnit) existing.costUnits.add(series.costUnit);
|
|
679
|
+
else existing.hasUnknownCostUnit = true;
|
|
680
|
+
}
|
|
681
|
+
pointMap.set(tsMs, existing);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function toCostUnit(entry) {
|
|
685
|
+
if (entry.cost == null || entry.hasUnknownCostUnit || entry.costUnits.size !== 1) return null;
|
|
686
|
+
return [...entry.costUnits][0] ?? null;
|
|
687
|
+
}
|
|
688
|
+
function useTokenUsageTimeSeries(params) {
|
|
689
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
690
|
+
const { timestamp, filters, filterKey, queryOptions } = params;
|
|
691
|
+
const interval = chooseMetricsInterval(timestamp);
|
|
692
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
693
|
+
queryKey: [
|
|
694
|
+
"metrics",
|
|
695
|
+
"token-usage-timeseries",
|
|
696
|
+
filterKey,
|
|
697
|
+
interval
|
|
698
|
+
],
|
|
699
|
+
queryFn: async () => {
|
|
700
|
+
const [inputRes, outputRes] = await Promise.all([client.getMetricTimeSeries({
|
|
701
|
+
name: ["mastra_model_total_input_tokens"],
|
|
702
|
+
interval,
|
|
703
|
+
aggregation: "sum",
|
|
704
|
+
filters
|
|
705
|
+
}), client.getMetricTimeSeries({
|
|
706
|
+
name: ["mastra_model_total_output_tokens"],
|
|
707
|
+
interval,
|
|
708
|
+
aggregation: "sum",
|
|
709
|
+
filters
|
|
710
|
+
})]);
|
|
711
|
+
const pointMap = /* @__PURE__ */ new Map();
|
|
712
|
+
addSeriesPoints(pointMap, inputRes.series[0], "input");
|
|
713
|
+
addSeriesPoints(pointMap, outputRes.series[0], "output");
|
|
714
|
+
return {
|
|
715
|
+
data: Array.from(pointMap.values()).sort((a, b) => a.tsMs - b.tsMs).map((point) => {
|
|
716
|
+
return {
|
|
717
|
+
time: formatMetricsBucketLabel(new Date(point.tsMs), interval),
|
|
718
|
+
tsMs: point.tsMs,
|
|
719
|
+
input: point.input,
|
|
720
|
+
output: point.output,
|
|
721
|
+
total: point.input + point.output,
|
|
722
|
+
cost: point.cost,
|
|
723
|
+
costUnit: toCostUnit(point)
|
|
724
|
+
};
|
|
725
|
+
}),
|
|
726
|
+
interval
|
|
727
|
+
};
|
|
728
|
+
},
|
|
729
|
+
...queryOptions
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
//#endregion
|
|
733
|
+
//#region src/hooks/metrics/use-top-active-threads-metrics.tsx
|
|
734
|
+
const TOP_N$1 = 20;
|
|
735
|
+
/** Top Active Threads — the threads with the most agent runs in the selected
|
|
736
|
+
* range. Server-side TopK (`ORDER BY value DESC LIMIT 20`) is required so the
|
|
737
|
+
* query never returns the full thread set when cardinality is in the millions.
|
|
738
|
+
*
|
|
739
|
+
* Tokens + cost are joined in from parallel breakdowns on the same `threadId`
|
|
740
|
+
* grouping so we don't need any new backend aggregation support. */
|
|
741
|
+
function useTopActiveThreadsMetrics(params) {
|
|
742
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
743
|
+
const { filters, filterKey, queryOptions } = params;
|
|
744
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
745
|
+
queryKey: [
|
|
746
|
+
"metrics",
|
|
747
|
+
"top-active-threads",
|
|
748
|
+
filterKey
|
|
749
|
+
],
|
|
750
|
+
queryFn: async () => {
|
|
751
|
+
const breakdownBase = {
|
|
752
|
+
groupBy: ["threadId", "resourceId"],
|
|
753
|
+
orderDirection: "DESC",
|
|
754
|
+
filters
|
|
755
|
+
};
|
|
756
|
+
const [runsRes, inputRes, outputRes] = await Promise.all([
|
|
757
|
+
client.getMetricBreakdown({
|
|
758
|
+
...breakdownBase,
|
|
759
|
+
name: ["mastra_agent_duration_ms"],
|
|
760
|
+
aggregation: "count",
|
|
761
|
+
limit: TOP_N$1
|
|
762
|
+
}),
|
|
763
|
+
client.getMetricBreakdown({
|
|
764
|
+
...breakdownBase,
|
|
765
|
+
name: ["mastra_model_total_input_tokens"],
|
|
766
|
+
aggregation: "sum",
|
|
767
|
+
limit: TOP_N$1
|
|
768
|
+
}),
|
|
769
|
+
client.getMetricBreakdown({
|
|
770
|
+
...breakdownBase,
|
|
771
|
+
name: ["mastra_model_total_output_tokens"],
|
|
772
|
+
aggregation: "sum",
|
|
773
|
+
limit: TOP_N$1
|
|
774
|
+
})
|
|
775
|
+
]);
|
|
776
|
+
const byThread = /* @__PURE__ */ new Map();
|
|
777
|
+
const ensure = (threadId) => require_map.getOrCreate(byThread, threadId, () => ({
|
|
778
|
+
tokens: 0,
|
|
779
|
+
cost: null,
|
|
780
|
+
costUnit: null
|
|
781
|
+
}));
|
|
782
|
+
const foldTokens = (groups) => {
|
|
783
|
+
for (const group of groups) {
|
|
784
|
+
const threadId = group.dimensions.threadId;
|
|
785
|
+
if (!threadId) continue;
|
|
786
|
+
const entry = ensure(threadId);
|
|
787
|
+
entry.tokens += group.value;
|
|
788
|
+
if (group.estimatedCost != null) {
|
|
789
|
+
entry.cost = (entry.cost ?? 0) + group.estimatedCost;
|
|
790
|
+
if (group.costUnit) entry.costUnit = group.costUnit;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
foldTokens(inputRes.groups);
|
|
795
|
+
foldTokens(outputRes.groups);
|
|
796
|
+
return runsRes.groups.filter((group) => !!group.dimensions.threadId).map((group) => {
|
|
797
|
+
const threadId = group.dimensions.threadId;
|
|
798
|
+
const extra = byThread.get(threadId);
|
|
799
|
+
return {
|
|
800
|
+
threadId,
|
|
801
|
+
resourceId: group.dimensions.resourceId ?? null,
|
|
802
|
+
runs: group.value,
|
|
803
|
+
tokens: extra?.tokens ?? 0,
|
|
804
|
+
cost: extra?.cost ?? null,
|
|
805
|
+
costUnit: extra?.costUnit ?? null
|
|
806
|
+
};
|
|
807
|
+
});
|
|
808
|
+
},
|
|
809
|
+
...queryOptions
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region src/hooks/metrics/use-top-resources-by-threads-metrics.tsx
|
|
814
|
+
const TOP_N = 20;
|
|
815
|
+
/** Top Resources by Thread Count — the resources with the most distinct threads
|
|
816
|
+
* in the selected range. Uses `count_distinct(threadId)` per `resourceId`,
|
|
817
|
+
* with server-side TopK (`ORDER BY value DESC LIMIT 20`).
|
|
818
|
+
*
|
|
819
|
+
* Tokens + cost are joined in from parallel breakdowns on `resourceId` so the
|
|
820
|
+
* table can show cost/usage without a separate backend aggregation. */
|
|
821
|
+
function useTopResourcesByThreadsMetrics(params) {
|
|
822
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
823
|
+
const { filters, filterKey, queryOptions } = params;
|
|
824
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
825
|
+
queryKey: [
|
|
826
|
+
"metrics",
|
|
827
|
+
"top-resources-by-threads",
|
|
828
|
+
filterKey
|
|
829
|
+
],
|
|
830
|
+
queryFn: async () => {
|
|
831
|
+
const breakdownBase = {
|
|
832
|
+
groupBy: ["resourceId"],
|
|
833
|
+
orderDirection: "DESC",
|
|
834
|
+
filters
|
|
835
|
+
};
|
|
836
|
+
const [threadsRes, inputRes, outputRes] = await Promise.all([
|
|
837
|
+
client.getMetricBreakdown({
|
|
838
|
+
...breakdownBase,
|
|
839
|
+
name: ["mastra_agent_duration_ms"],
|
|
840
|
+
aggregation: "count_distinct",
|
|
841
|
+
distinctColumn: "threadId",
|
|
842
|
+
limit: TOP_N
|
|
843
|
+
}),
|
|
844
|
+
client.getMetricBreakdown({
|
|
845
|
+
...breakdownBase,
|
|
846
|
+
name: ["mastra_model_total_input_tokens"],
|
|
847
|
+
aggregation: "sum",
|
|
848
|
+
limit: TOP_N
|
|
849
|
+
}),
|
|
850
|
+
client.getMetricBreakdown({
|
|
851
|
+
...breakdownBase,
|
|
852
|
+
name: ["mastra_model_total_output_tokens"],
|
|
853
|
+
aggregation: "sum",
|
|
854
|
+
limit: TOP_N
|
|
855
|
+
})
|
|
856
|
+
]);
|
|
857
|
+
const byResource = /* @__PURE__ */ new Map();
|
|
858
|
+
const ensure = (resourceId) => require_map.getOrCreate(byResource, resourceId, () => ({
|
|
859
|
+
tokens: 0,
|
|
860
|
+
cost: null,
|
|
861
|
+
costUnit: null
|
|
862
|
+
}));
|
|
863
|
+
const foldTokens = (groups) => {
|
|
864
|
+
for (const group of groups) {
|
|
865
|
+
const resourceId = group.dimensions.resourceId;
|
|
866
|
+
if (!resourceId) continue;
|
|
867
|
+
const entry = ensure(resourceId);
|
|
868
|
+
entry.tokens += group.value;
|
|
869
|
+
if (group.estimatedCost != null) {
|
|
870
|
+
entry.cost = (entry.cost ?? 0) + group.estimatedCost;
|
|
871
|
+
if (group.costUnit) entry.costUnit = group.costUnit;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
foldTokens(inputRes.groups);
|
|
876
|
+
foldTokens(outputRes.groups);
|
|
877
|
+
return threadsRes.groups.filter((group) => !!group.dimensions.resourceId).map((group) => {
|
|
878
|
+
const resourceId = group.dimensions.resourceId;
|
|
879
|
+
const extra = byResource.get(resourceId);
|
|
880
|
+
return {
|
|
881
|
+
resourceId,
|
|
882
|
+
threadCount: group.value,
|
|
883
|
+
tokens: extra?.tokens ?? 0,
|
|
884
|
+
cost: extra?.cost ?? null,
|
|
885
|
+
costUnit: extra?.costUnit ?? null
|
|
886
|
+
};
|
|
887
|
+
});
|
|
888
|
+
},
|
|
889
|
+
...queryOptions
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region src/hooks/metrics/use-total-tokens-kpi-metrics.tsx
|
|
894
|
+
function useTotalTokensKpiMetrics(params) {
|
|
895
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
896
|
+
const { filters, filterKey, queryOptions } = params;
|
|
897
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
898
|
+
queryKey: [
|
|
899
|
+
"metrics",
|
|
900
|
+
"total-tokens-kpi",
|
|
901
|
+
filterKey
|
|
902
|
+
],
|
|
903
|
+
queryFn: async () => {
|
|
904
|
+
const [input, output] = await Promise.all([client.getMetricAggregate({
|
|
905
|
+
name: ["mastra_model_total_input_tokens"],
|
|
906
|
+
aggregation: "sum",
|
|
907
|
+
filters,
|
|
908
|
+
comparePeriod: "previous_period"
|
|
909
|
+
}), client.getMetricAggregate({
|
|
910
|
+
name: ["mastra_model_total_output_tokens"],
|
|
911
|
+
aggregation: "sum",
|
|
912
|
+
filters,
|
|
913
|
+
comparePeriod: "previous_period"
|
|
914
|
+
})]);
|
|
915
|
+
const hasCurrent = input.value != null || output.value != null;
|
|
916
|
+
const hasPrevious = input.previousValue != null || output.previousValue != null;
|
|
917
|
+
const value = (input.value ?? 0) + (output.value ?? 0);
|
|
918
|
+
const previousValue = (input.previousValue ?? 0) + (output.previousValue ?? 0);
|
|
919
|
+
const changePercent = hasPrevious && previousValue > 0 ? (value - previousValue) / previousValue * 100 : null;
|
|
920
|
+
return {
|
|
921
|
+
value: hasCurrent ? value : null,
|
|
922
|
+
previousValue: hasPrevious ? previousValue : null,
|
|
923
|
+
changePercent
|
|
924
|
+
};
|
|
925
|
+
},
|
|
926
|
+
...queryOptions
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region src/hooks/metrics/use-trace-volume-metrics.tsx
|
|
931
|
+
async function fetchVolume(client, metricName, filters) {
|
|
932
|
+
const res = await client.getMetricBreakdown({
|
|
933
|
+
name: [metricName],
|
|
934
|
+
groupBy: ["entityName", "status"],
|
|
935
|
+
aggregation: "count",
|
|
936
|
+
orderDirection: "DESC",
|
|
937
|
+
filters
|
|
938
|
+
});
|
|
939
|
+
const map = /* @__PURE__ */ new Map();
|
|
940
|
+
for (const group of res.groups) {
|
|
941
|
+
const name = group.dimensions.entityName ?? "unknown";
|
|
942
|
+
const status = group.dimensions.status ?? "ok";
|
|
943
|
+
const entry = require_map.getOrCreate(map, name, () => ({
|
|
944
|
+
completed: 0,
|
|
945
|
+
errors: 0
|
|
946
|
+
}));
|
|
947
|
+
if (status === "error") entry.errors += group.value;
|
|
948
|
+
else entry.completed += group.value;
|
|
949
|
+
}
|
|
950
|
+
return Array.from(map.entries()).map(([name, vals]) => ({
|
|
951
|
+
name,
|
|
952
|
+
...vals
|
|
953
|
+
})).sort((a, b) => b.completed + b.errors - (a.completed + a.errors));
|
|
954
|
+
}
|
|
955
|
+
function useTraceVolumeMetrics(params) {
|
|
956
|
+
const client = require_mastra_client_context.useMastraClient();
|
|
957
|
+
const { filters, filterKey, queryOptions } = params;
|
|
958
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
959
|
+
queryKey: [
|
|
960
|
+
"metrics",
|
|
961
|
+
"trace-volume",
|
|
962
|
+
filterKey
|
|
963
|
+
],
|
|
964
|
+
queryFn: async () => {
|
|
965
|
+
const [agentData, workflowData, toolData] = await Promise.all([
|
|
966
|
+
fetchVolume(client, "mastra_agent_duration_ms", filters),
|
|
967
|
+
fetchVolume(client, "mastra_workflow_duration_ms", filters),
|
|
968
|
+
fetchVolume(client, "mastra_tool_duration_ms", filters)
|
|
969
|
+
]);
|
|
970
|
+
return {
|
|
971
|
+
agentData,
|
|
972
|
+
workflowData,
|
|
973
|
+
toolData
|
|
974
|
+
};
|
|
975
|
+
},
|
|
976
|
+
...queryOptions
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
980
|
+
exports.chooseMetricsInterval = chooseMetricsInterval;
|
|
981
|
+
exports.formatMetricsBucketLabel = formatMetricsBucketLabel;
|
|
982
|
+
exports.useActiveResourcesKpiMetrics = useActiveResourcesKpiMetrics;
|
|
983
|
+
exports.useActiveThreadsKpiMetrics = useActiveThreadsKpiMetrics;
|
|
984
|
+
exports.useAgentRunsKpiMetrics = useAgentRunsKpiMetrics;
|
|
985
|
+
exports.useLatencyMetrics = useLatencyMetrics;
|
|
986
|
+
exports.useMetricsQueryFilters = useMetricsQueryFilters;
|
|
987
|
+
exports.useModelCostKpiMetrics = useModelCostKpiMetrics;
|
|
988
|
+
exports.useModelUsageCostMetrics = useModelUsageCostMetrics;
|
|
989
|
+
exports.useScoresMetrics = useScoresMetrics;
|
|
990
|
+
exports.useTokenUsageByAgentMetrics = useTokenUsageByAgentMetrics;
|
|
991
|
+
exports.useTokenUsageTimeSeries = useTokenUsageTimeSeries;
|
|
992
|
+
exports.useTopActiveThreadsMetrics = useTopActiveThreadsMetrics;
|
|
993
|
+
exports.useTopResourcesByThreadsMetrics = useTopResourcesByThreadsMetrics;
|
|
994
|
+
exports.useTotalTokensKpiMetrics = useTotalTokensKpiMetrics;
|
|
995
|
+
exports.useTraceVolumeMetrics = useTraceVolumeMetrics;
|
|
996
|
+
|
|
997
|
+
//# sourceMappingURL=index.cjs.map
|