@mastra/react 1.13.0-alpha.3 → 1.13.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/{accumulator-BmD8-x9I.cjs → accumulator-Bjfckb5t.cjs} +5 -9
  2. package/dist/{accumulator-BmD8-x9I.cjs.map → accumulator-Bjfckb5t.cjs.map} +1 -1
  3. package/dist/{accumulator-D9jAph99.js → accumulator-DysrPe6U.js} +5 -9
  4. package/dist/{accumulator-D9jAph99.js.map → accumulator-DysrPe6U.js.map} +1 -1
  5. package/dist/chat/index.cjs +1 -1
  6. package/dist/chat/index.js +1 -1
  7. package/dist/{combine-by-ids-CcaZKGT9.js → combine-by-ids-C-0oe4eH.js} +2 -3
  8. package/dist/{combine-by-ids-CcaZKGT9.js.map → combine-by-ids-C-0oe4eH.js.map} +1 -1
  9. package/dist/{combine-by-ids-D_lp6Dvq.cjs → combine-by-ids-ERVPXXBi.cjs} +2 -3
  10. package/dist/{combine-by-ids-D_lp6Dvq.cjs.map → combine-by-ids-ERVPXXBi.cjs.map} +1 -1
  11. package/dist/{experiments-CJw1N3FB.cjs → experiments-Duv0RgkM.cjs} +12 -19
  12. package/dist/{experiments-CJw1N3FB.cjs.map → experiments-Duv0RgkM.cjs.map} +1 -1
  13. package/dist/{experiments-B7vRMK5T.js → experiments-DyecjEut.js} +12 -19
  14. package/dist/{experiments-B7vRMK5T.js.map → experiments-DyecjEut.js.map} +1 -1
  15. package/dist/{feedback-refetch-interval-XD5FVc2k.cjs → feedback-refetch-interval-BBcT9r8s.cjs} +3 -4
  16. package/dist/{feedback-refetch-interval-XD5FVc2k.cjs.map → feedback-refetch-interval-BBcT9r8s.cjs.map} +1 -1
  17. package/dist/{feedback-refetch-interval-DLHzQoVV.js → feedback-refetch-interval-C12Nzb2r.js} +3 -4
  18. package/dist/{feedback-refetch-interval-DLHzQoVV.js.map → feedback-refetch-interval-C12Nzb2r.js.map} +1 -1
  19. package/dist/hooks/agents/index.cjs +19 -37
  20. package/dist/hooks/agents/index.cjs.map +1 -1
  21. package/dist/hooks/agents/index.js +19 -37
  22. package/dist/hooks/agents/index.js.map +1 -1
  23. package/dist/hooks/auth/index.cjs +11 -21
  24. package/dist/hooks/auth/index.cjs.map +1 -1
  25. package/dist/hooks/auth/index.js +11 -21
  26. package/dist/hooks/auth/index.js.map +1 -1
  27. package/dist/hooks/capabilities/index.cjs +11 -21
  28. package/dist/hooks/capabilities/index.cjs.map +1 -1
  29. package/dist/hooks/capabilities/index.js +11 -21
  30. package/dist/hooks/capabilities/index.js.map +1 -1
  31. package/dist/hooks/configuration/index.cjs +2 -3
  32. package/dist/hooks/configuration/index.js +2 -3
  33. package/dist/hooks/datasets/index.cjs +12 -21
  34. package/dist/hooks/datasets/index.cjs.map +1 -1
  35. package/dist/hooks/datasets/index.js +12 -21
  36. package/dist/hooks/datasets/index.js.map +1 -1
  37. package/dist/hooks/embedders/index.cjs +2 -3
  38. package/dist/hooks/embedders/index.js +2 -3
  39. package/dist/hooks/experiments/index.cjs +1 -1
  40. package/dist/hooks/experiments/index.js +1 -1
  41. package/dist/hooks/feedback/index.cjs +3 -4
  42. package/dist/hooks/feedback/index.js +3 -4
  43. package/dist/hooks/llm/index.cjs +2 -3
  44. package/dist/hooks/llm/index.js +2 -3
  45. package/dist/hooks/logs/index.cjs +4 -5
  46. package/dist/hooks/logs/index.js +4 -5
  47. package/dist/hooks/mcps/index.cjs +8 -15
  48. package/dist/hooks/mcps/index.cjs.map +1 -1
  49. package/dist/hooks/mcps/index.js +8 -15
  50. package/dist/hooks/mcps/index.js.map +1 -1
  51. package/dist/hooks/memory/index.cjs +5 -9
  52. package/dist/hooks/memory/index.cjs.map +1 -1
  53. package/dist/hooks/memory/index.js +5 -9
  54. package/dist/hooks/memory/index.js.map +1 -1
  55. package/dist/hooks/metrics/index.cjs +19 -36
  56. package/dist/hooks/metrics/index.cjs.map +1 -1
  57. package/dist/hooks/metrics/index.js +19 -36
  58. package/dist/hooks/metrics/index.js.map +1 -1
  59. package/dist/hooks/processors/index.cjs +2 -3
  60. package/dist/hooks/processors/index.js +2 -3
  61. package/dist/hooks/prompt-blocks/index.cjs +3 -5
  62. package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
  63. package/dist/hooks/prompt-blocks/index.js +3 -5
  64. package/dist/hooks/prompt-blocks/index.js.map +1 -1
  65. package/dist/hooks/query/index.cjs +2 -3
  66. package/dist/hooks/query/index.js +2 -3
  67. package/dist/hooks/review/index.cjs +4 -6
  68. package/dist/hooks/review/index.cjs.map +1 -1
  69. package/dist/hooks/review/index.js +4 -6
  70. package/dist/hooks/review/index.js.map +1 -1
  71. package/dist/hooks/schedules/index.cjs +6 -10
  72. package/dist/hooks/schedules/index.cjs.map +1 -1
  73. package/dist/hooks/schedules/index.js +6 -10
  74. package/dist/hooks/schedules/index.js.map +1 -1
  75. package/dist/hooks/scores/index.cjs +8 -13
  76. package/dist/hooks/scores/index.cjs.map +1 -1
  77. package/dist/hooks/scores/index.js +8 -13
  78. package/dist/hooks/scores/index.js.map +1 -1
  79. package/dist/hooks/templates/index.cjs +2 -3
  80. package/dist/hooks/templates/index.js +2 -3
  81. package/dist/hooks/tool-providers/index.cjs +10 -19
  82. package/dist/hooks/tool-providers/index.cjs.map +1 -1
  83. package/dist/hooks/tool-providers/index.js +10 -19
  84. package/dist/hooks/tool-providers/index.js.map +1 -1
  85. package/dist/hooks/tools/index.cjs +3 -5
  86. package/dist/hooks/tools/index.cjs.map +1 -1
  87. package/dist/hooks/tools/index.js +3 -5
  88. package/dist/hooks/tools/index.js.map +1 -1
  89. package/dist/hooks/traces/index.cjs +28 -51
  90. package/dist/hooks/traces/index.cjs.map +1 -1
  91. package/dist/hooks/traces/index.js +28 -51
  92. package/dist/hooks/traces/index.js.map +1 -1
  93. package/dist/hooks/vectors/index.cjs +2 -3
  94. package/dist/hooks/vectors/index.js +2 -3
  95. package/dist/hooks/voice/index.cjs +3 -4
  96. package/dist/hooks/voice/index.js +3 -4
  97. package/dist/hooks/workflows/index.cjs +7 -11
  98. package/dist/hooks/workflows/index.cjs.map +1 -1
  99. package/dist/hooks/workflows/index.js +7 -11
  100. package/dist/hooks/workflows/index.js.map +1 -1
  101. package/dist/hooks/workspace/index.cjs +12 -22
  102. package/dist/hooks/workspace/index.cjs.map +1 -1
  103. package/dist/hooks/workspace/index.js +12 -22
  104. package/dist/hooks/workspace/index.js.map +1 -1
  105. package/dist/{hooks-XYsmqFCz.cjs → hooks-Bt15IwzP.cjs} +6 -9
  106. package/dist/{hooks-XYsmqFCz.cjs.map → hooks-Bt15IwzP.cjs.map} +1 -1
  107. package/dist/{hooks-DG-Y1KFe.js → hooks-Btt7PyI-.js} +6 -9
  108. package/dist/{hooks-DG-Y1KFe.js.map → hooks-Btt7PyI-.js.map} +1 -1
  109. package/dist/{hooks-BfysjY_K.js → hooks-CEikbhrN.js} +9 -15
  110. package/dist/{hooks-BfysjY_K.js.map → hooks-CEikbhrN.js.map} +1 -1
  111. package/dist/{hooks-BbUMSab8.cjs → hooks-D6LDSEcm.cjs} +9 -15
  112. package/dist/{hooks-BbUMSab8.cjs.map → hooks-D6LDSEcm.cjs.map} +1 -1
  113. package/dist/index.cjs +7 -9
  114. package/dist/index.cjs.map +1 -1
  115. package/dist/index.js +7 -9
  116. package/dist/index.js.map +1 -1
  117. package/dist/{map-CDv4fbu4.js → map-5-4U5rwA.js} +2 -3
  118. package/dist/{map-CDv4fbu4.js.map → map-5-4U5rwA.js.map} +1 -1
  119. package/dist/{map-wjmL1y5O.cjs → map-BGoWBTGy.cjs} +2 -3
  120. package/dist/{map-wjmL1y5O.cjs.map → map-BGoWBTGy.cjs.map} +1 -1
  121. package/dist/{mastra-client-context-Bx_g84YB.js → mastra-client-context-DQ5z_ze9.js} +2 -3
  122. package/dist/{mastra-client-context-Bx_g84YB.js.map → mastra-client-context-DQ5z_ze9.js.map} +1 -1
  123. package/dist/{mastra-client-context-DzX3f0RF.cjs → mastra-client-context-DX8wJM9p.cjs} +2 -3
  124. package/dist/{mastra-client-context-DzX3f0RF.cjs.map → mastra-client-context-DX8wJM9p.cjs.map} +1 -1
  125. package/dist/{query-utils-CcrChYgz.cjs → query-utils-BVgE_xxj.cjs} +2 -3
  126. package/dist/{query-utils-CcrChYgz.cjs.map → query-utils-BVgE_xxj.cjs.map} +1 -1
  127. package/dist/{query-utils-D1NgFnWU.js → query-utils-DvMERIwf.js} +2 -3
  128. package/dist/{query-utils-D1NgFnWU.js.map → query-utils-DvMERIwf.js.map} +1 -1
  129. package/dist/ui/index.cjs +15 -30
  130. package/dist/ui/index.cjs.map +1 -1
  131. package/dist/ui/index.js +14 -28
  132. package/dist/ui/index.js.map +1 -1
  133. package/dist/{use-in-view-B6eJO9Zi.cjs → use-in-view-BxdrrnCw.cjs} +2 -3
  134. package/dist/{use-in-view-B6eJO9Zi.cjs.map → use-in-view-BxdrrnCw.cjs.map} +1 -1
  135. package/dist/{use-in-view-C9sYPGRm.js → use-in-view-CyjKdplM.js} +2 -3
  136. package/dist/{use-in-view-C9sYPGRm.js.map → use-in-view-CyjKdplM.js.map} +1 -1
  137. package/dist/{voice-BOtUdMi8.cjs → voice-Didej2E1.cjs} +5 -8
  138. package/dist/{voice-BOtUdMi8.cjs.map → voice-Didej2E1.cjs.map} +1 -1
  139. package/dist/{voice-DgirjEyH.js → voice-ugGu7VyA.js} +5 -8
  140. package/dist/{voice-DgirjEyH.js.map → voice-ugGu7VyA.js.map} +1 -1
  141. package/package.json +18 -18
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
3
- const require_voice = require("../../voice-BOtUdMi8.cjs");
2
+ const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
3
+ const require_voice = require("../../voice-Didej2E1.cjs");
4
4
  let react = require("react");
5
- //#region src/hooks/voice/use-read-aloud.ts
5
+ // src/hooks/voice/use-read-aloud.ts
6
6
  /**
7
7
  * Read-aloud (text-to-speech) for assistant messages, replacing the assistant-ui
8
8
  * speech adapters (`VoiceAttachmentAdapter` / `WebSpeechSynthesisAdapter`).
@@ -81,7 +81,6 @@ const useReadAloud = (agentId, requestContext, options) => {
81
81
  stop
82
82
  };
83
83
  };
84
- //#endregion
85
84
  exports.useReadAloud = useReadAloud;
86
85
 
87
86
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
- import { n as useMastraClient } from "../../mastra-client-context-Bx_g84YB.js";
2
- import { n as playStreamWithWebAudio } from "../../voice-DgirjEyH.js";
1
+ import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
2
+ import { n as playStreamWithWebAudio } from "../../voice-ugGu7VyA.js";
3
3
  import { useCallback, useEffect, useRef, useState } from "react";
4
- //#region src/hooks/voice/use-read-aloud.ts
4
+ // src/hooks/voice/use-read-aloud.ts
5
5
  /**
6
6
  * Read-aloud (text-to-speech) for assistant messages, replacing the assistant-ui
7
7
  * speech adapters (`VoiceAttachmentAdapter` / `WebSpeechSynthesisAdapter`).
@@ -80,7 +80,6 @@ const useReadAloud = (agentId, requestContext, options) => {
80
80
  stop
81
81
  };
82
82
  };
83
- //#endregion
84
83
  export { useReadAloud };
85
84
 
86
85
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
3
- const require_hooks = require("../../hooks-XYsmqFCz.cjs");
4
- const require_use_in_view = require("../../use-in-view-B6eJO9Zi.cjs");
2
+ const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
3
+ const require_hooks = require("../../hooks-Bt15IwzP.cjs");
4
+ const require_use_in_view = require("../../use-in-view-BxdrrnCw.cjs");
5
5
  let _mastra_client_js = require("@mastra/client-js");
6
6
  let react = require("react");
7
7
  let _tanstack_react_query = require("@tanstack/react-query");
8
- //#region src/hooks/workflows/use-workflows.ts
8
+ // src/hooks/workflows/use-workflows.ts
9
9
  const useWorkflows = ({ requestContext, queryOptions } = {}) => {
10
10
  const client = require_mastra_client_context.useMastraClient();
11
11
  return (0, _tanstack_react_query.useQuery)({
@@ -17,8 +17,7 @@ const useWorkflows = ({ requestContext, queryOptions } = {}) => {
17
17
  ...queryOptions
18
18
  });
19
19
  };
20
- //#endregion
21
- //#region src/hooks/workflows/use-workflow.ts
20
+ // src/hooks/workflows/use-workflow.ts
22
21
  /**
23
22
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
24
23
  */
@@ -33,8 +32,7 @@ const useWorkflow = ({ workflowId, requestContext, queryOptions } = {}) => {
33
32
  ...queryOptions
34
33
  });
35
34
  };
36
- //#endregion
37
- //#region src/hooks/workflows/use-workflow-runs.ts
35
+ // src/hooks/workflows/use-workflow-runs.ts
38
36
  const PER_PAGE = 20;
39
37
  function getWorkflowRunsNextPageParam(lastPage, _allPages, lastPageParam) {
40
38
  if (lastPage.runs.length < 20) return;
@@ -116,8 +114,7 @@ const useDeleteWorkflowRun = ({ workflowId, queryOptions }) => {
116
114
  ...queryOptions
117
115
  });
118
116
  };
119
- //#endregion
120
- //#region src/hooks/workflows/use-workflows-run-counts.ts
117
+ // src/hooks/workflows/use-workflows-run-counts.ts
121
118
  const RUN_COUNTS_REFETCH_INTERVAL_MS = 5e3;
122
119
  const NO_COUNTS = {};
123
120
  /** Older servers don't ship the endpoint — that (and only that) ends polling. */
@@ -152,7 +149,6 @@ const useWorkflowsRunCounts = ({ requestContext, queryOptions } = {}) => {
152
149
  });
153
150
  return data ?? NO_COUNTS;
154
151
  };
155
- //#endregion
156
152
  exports.PER_PAGE = PER_PAGE;
157
153
  exports.RUN_COUNTS_REFETCH_INTERVAL_MS = RUN_COUNTS_REFETCH_INTERVAL_MS;
158
154
  exports.getWorkflowRunsNextPageParam = getWorkflowRunsNextPageParam;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useInView","useInfiniteQuery","useQuery","useQueryClient","useMutation","MastraClientError","useMastraClient","useQuery"],"sources":["../../../src/hooks/workflows/use-workflows.ts","../../../src/hooks/workflows/use-workflow.ts","../../../src/hooks/workflows/use-workflow-runs.ts","../../../src/hooks/workflows/use-workflows-run-counts.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowsResponse = Awaited<ReturnType<MastraClient['listWorkflows']>>;\n\nexport const useWorkflows = <TData = WorkflowsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflows', requestContext],\n queryFn: async (): Promise<WorkflowsResponse> => {\n const workflows = await client.listWorkflows(requestContext);\n // Filter out processor workflows - they're shown on the Processors tab instead\n return Object.fromEntries(Object.entries(workflows).filter(([_, workflow]) => !workflow.isProcessorWorkflow));\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['details']>> | null;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflow = <TData = WorkflowResponse>({\n workflowId,\n requestContext,\n queryOptions,\n}: {\n workflowId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['workflow', workflowId],\n queryFn: () => (workflowId ? client.getWorkflow(workflowId).details(requestContext) : null),\n retry: false,\n refetchOnWindowFocus: false,\n throwOnError: false,\n ...queryOptions,\n });\n};\n","import type { GetWorkflowRunByIdResponse, MastraClient } from '@mastra/client-js';\nimport type { QueryKey, UseInfiniteQueryResult, UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype WorkflowRuns = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['runs']>>;\n\nexport const PER_PAGE = 20;\n\nexport function getWorkflowRunsNextPageParam(lastPage: WorkflowRuns, _allPages: unknown, lastPageParam: number) {\n if (lastPage.runs.length < PER_PAGE) {\n return undefined;\n }\n return lastPageParam + 1;\n}\n\nexport function selectUniqueRuns(data: { pages: WorkflowRuns[] }) {\n const seen = new Set<string>();\n return data.pages\n .flatMap(page => page.runs)\n .filter(run => {\n if (seen.has(run.runId)) return false;\n seen.add(run.runId);\n return true;\n });\n}\n\n/**\n * `summary: true` asks the server to reduce each run snapshot to `{ status, timestamp }`,\n * avoiding transfer of full snapshots when only list metadata is displayed.\n */\nexport const useWorkflowRuns = <TData = ReturnType<typeof selectUniqueRuns>>({\n workflowId,\n summary = false,\n queryOptions,\n}: {\n workflowId: string;\n summary?: boolean;\n queryOptions?: MastraInfiniteQueryOptions<WorkflowRuns, TData, QueryKey, number>;\n}): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const query = useInfiniteQuery({\n queryKey: ['workflow-runs', workflowId, { summary }],\n queryFn: ({ pageParam }) =>\n client\n .getWorkflow(workflowId)\n .runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE, ...(summary ? { summary: true } : {}) }),\n initialPageParam: 0,\n getNextPageParam: getWorkflowRunsNextPageParam,\n select: data => selectUniqueRuns(data) as TData,\n retry: false,\n refetchInterval: 5000,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const workflowRunQueryKey = (workflowId: string, runId: string) => ['workflow-run', workflowId, runId] as const;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflowRun = <TData = GetWorkflowRunByIdResponse>({\n workflowId,\n runId,\n queryOptions,\n}: {\n workflowId: string;\n runId: string;\n queryOptions?: MastraQueryOptions<GetWorkflowRunByIdResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<GetWorkflowRunByIdResponse, Error, TData>({\n queryKey: workflowRunQueryKey(workflowId, runId),\n queryFn: () => client.getWorkflow(workflowId).runById(runId),\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkflowRun = ({\n workflowId,\n queryOptions,\n}: {\n workflowId: string;\n queryOptions?: MastraMutationOptions<unknown, { runId: string }>;\n}): UseMutationResult<unknown, Error, { runId: string }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ runId }: { runId: string }) => client.getWorkflow(workflowId).deleteRunById(runId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['workflow-runs', workflowId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListWorkflowRunCountsResponse } from '@mastra/client-js';\nimport { MastraClientError } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const RUN_COUNTS_REFETCH_INTERVAL_MS = 5000;\n\nconst NO_COUNTS: ListWorkflowRunCountsResponse = {};\n\n/** Older servers don't ship the endpoint — that (and only that) ends polling. */\nexport function isRunCountsUnsupported(error: unknown): boolean {\n return error instanceof MastraClientError && error.status === 404;\n}\n\n/**\n * Poll cadence: keep polling through transient failures (a blip must not\n * silence the counts forever), but stop entirely once the server has said the\n * endpoint does not exist.\n */\nexport function runCountsRefetchInterval(error: unknown): number | false {\n return isRunCountsUnsupported(error) ? false : RUN_COUNTS_REFETCH_INTERVAL_MS;\n}\n\n/**\n * Per-workflow counts of `running` (in-flight) and `suspended` (stopped at a\n * suspend() point awaiting resume — the human-in-the-loop state) runs, keyed\n * by the workflow registry key.\n *\n * One lightweight server request per poll — the server aggregates counts\n * across workflows (GET /workflows/run-counts). Older servers 404 the first\n * request; polling then stops and the list renders without count columns.\n */\nexport const useWorkflowsRunCounts = ({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListWorkflowRunCountsResponse>;\n} = {}): ListWorkflowRunCountsResponse => {\n const client = useMastraClient();\n\n const { data } = useQuery({\n queryKey: ['workflow-run-counts', requestContext],\n queryFn: () => client.listWorkflowRunCounts(requestContext),\n retry: false,\n refetchInterval: query => runCountsRefetchInterval(query.state.error),\n ...queryOptions,\n });\n\n return data ?? NO_COUNTS;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,gBAA2C,EACtD,gBACA,iBAIE,CAAC,MAAoC;CACvC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,aAAa,cAAc;EACtC,SAAS,YAAwC;GAC/C,MAAM,YAAY,MAAM,OAAO,cAAc,cAAc;GAE3D,OAAO,OAAO,YAAY,OAAO,QAAQ,SAA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AqC;CACxC,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,MAAM,EAAE,UAAA,GAASC,sBAAAA,SAAAA,CAAS;EACxB,UAAU,CAAC,uBAAuB,cAAc;EAChD,eAAe,OAAO,sBAAsB,cAAc;EAC1D,OAAO;EACP,kBAAiB,UAAS,yBAAyB,MAAM,MAAM,KAAK;EACpE,GAAG;CACL,CAAC;CAED,OAAO,QAAQ;AACjB"}
1
+ {"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useInView","useInfiniteQuery","useQuery","useQueryClient","useMutation","MastraClientError","useMastraClient","useQuery"],"sources":["../../../src/hooks/workflows/use-workflows.ts","../../../src/hooks/workflows/use-workflow.ts","../../../src/hooks/workflows/use-workflow-runs.ts","../../../src/hooks/workflows/use-workflows-run-counts.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowsResponse = Awaited<ReturnType<MastraClient['listWorkflows']>>;\n\nexport const useWorkflows = <TData = WorkflowsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflows', requestContext],\n queryFn: async (): Promise<WorkflowsResponse> => {\n const workflows = await client.listWorkflows(requestContext);\n // Filter out processor workflows - they're shown on the Processors tab instead\n return Object.fromEntries(Object.entries(workflows).filter(([_, workflow]) => !workflow.isProcessorWorkflow));\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['details']>> | null;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflow = <TData = WorkflowResponse>({\n workflowId,\n requestContext,\n queryOptions,\n}: {\n workflowId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['workflow', workflowId],\n queryFn: () => (workflowId ? client.getWorkflow(workflowId).details(requestContext) : null),\n retry: false,\n refetchOnWindowFocus: false,\n throwOnError: false,\n ...queryOptions,\n });\n};\n","import type { GetWorkflowRunByIdResponse, MastraClient } from '@mastra/client-js';\nimport type { QueryKey, UseInfiniteQueryResult, UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype WorkflowRuns = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['runs']>>;\n\nexport const PER_PAGE = 20;\n\nexport function getWorkflowRunsNextPageParam(lastPage: WorkflowRuns, _allPages: unknown, lastPageParam: number) {\n if (lastPage.runs.length < PER_PAGE) {\n return undefined;\n }\n return lastPageParam + 1;\n}\n\nexport function selectUniqueRuns(data: { pages: WorkflowRuns[] }) {\n const seen = new Set<string>();\n return data.pages\n .flatMap(page => page.runs)\n .filter(run => {\n if (seen.has(run.runId)) return false;\n seen.add(run.runId);\n return true;\n });\n}\n\n/**\n * `summary: true` asks the server to reduce each run snapshot to `{ status, timestamp }`,\n * avoiding transfer of full snapshots when only list metadata is displayed.\n */\nexport const useWorkflowRuns = <TData = ReturnType<typeof selectUniqueRuns>>({\n workflowId,\n summary = false,\n queryOptions,\n}: {\n workflowId: string;\n summary?: boolean;\n queryOptions?: MastraInfiniteQueryOptions<WorkflowRuns, TData, QueryKey, number>;\n}): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const query = useInfiniteQuery({\n queryKey: ['workflow-runs', workflowId, { summary }],\n queryFn: ({ pageParam }) =>\n client\n .getWorkflow(workflowId)\n .runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE, ...(summary ? { summary: true } : {}) }),\n initialPageParam: 0,\n getNextPageParam: getWorkflowRunsNextPageParam,\n select: data => selectUniqueRuns(data) as TData,\n retry: false,\n refetchInterval: 5000,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const workflowRunQueryKey = (workflowId: string, runId: string) => ['workflow-run', workflowId, runId] as const;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflowRun = <TData = GetWorkflowRunByIdResponse>({\n workflowId,\n runId,\n queryOptions,\n}: {\n workflowId: string;\n runId: string;\n queryOptions?: MastraQueryOptions<GetWorkflowRunByIdResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<GetWorkflowRunByIdResponse, Error, TData>({\n queryKey: workflowRunQueryKey(workflowId, runId),\n queryFn: () => client.getWorkflow(workflowId).runById(runId),\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkflowRun = ({\n workflowId,\n queryOptions,\n}: {\n workflowId: string;\n queryOptions?: MastraMutationOptions<unknown, { runId: string }>;\n}): UseMutationResult<unknown, Error, { runId: string }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ runId }: { runId: string }) => client.getWorkflow(workflowId).deleteRunById(runId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['workflow-runs', workflowId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListWorkflowRunCountsResponse } from '@mastra/client-js';\nimport { MastraClientError } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const RUN_COUNTS_REFETCH_INTERVAL_MS = 5000;\n\nconst NO_COUNTS: ListWorkflowRunCountsResponse = {};\n\n/** Older servers don't ship the endpoint — that (and only that) ends polling. */\nexport function isRunCountsUnsupported(error: unknown): boolean {\n return error instanceof MastraClientError && error.status === 404;\n}\n\n/**\n * Poll cadence: keep polling through transient failures (a blip must not\n * silence the counts forever), but stop entirely once the server has said the\n * endpoint does not exist.\n */\nexport function runCountsRefetchInterval(error: unknown): number | false {\n return isRunCountsUnsupported(error) ? false : RUN_COUNTS_REFETCH_INTERVAL_MS;\n}\n\n/**\n * Per-workflow counts of `running` (in-flight) and `suspended` (stopped at a\n * suspend() point awaiting resume — the human-in-the-loop state) runs, keyed\n * by the workflow registry key.\n *\n * One lightweight server request per poll — the server aggregates counts\n * across workflows (GET /workflows/run-counts). Older servers 404 the first\n * request; polling then stops and the list renders without count columns.\n */\nexport const useWorkflowsRunCounts = ({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListWorkflowRunCountsResponse>;\n} = {}): ListWorkflowRunCountsResponse => {\n const client = useMastraClient();\n\n const { data } = useQuery({\n queryKey: ['workflow-run-counts', requestContext],\n queryFn: () => client.listWorkflowRunCounts(requestContext),\n retry: false,\n refetchInterval: query => runCountsRefetchInterval(query.state.error),\n ...queryOptions,\n });\n\n return data ?? NO_COUNTS;\n};\n"],"m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GA,MAAa,iCAAiC;AAE9C,MAAM,YAA2C,CAAC;;AAGlD,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,iBAAiBC,kBAAAA,qBAAqB,MAAM,WAAW;AAChE;;;;;;AAOA,SAAgB,yBAAyB,OAAgC;CACvE,OAAO,uBAAuB,KAAK,IAAI,QAAQ;AACjD;;;;;;;;;;AAWA,MAAa,yBAAyB,EACpC,gBACA,iBAIE,CAAC,MAAqC;CACxC,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,MAAM,EAAE,UAAA,GAASC,sBAAAA,SAAAA,CAAS;EACxB,UAAU,CAAC,uBAAuB,cAAc;EAChD,eAAe,OAAO,sBAAsB,cAAc;EAC1D,OAAO;EACP,kBAAiB,UAAS,yBAAyB,MAAM,MAAM,KAAK;EACpE,GAAG;CACL,CAAC;CAED,OAAO,QAAQ;AACjB"}
@@ -1,10 +1,10 @@
1
- import { n as useMastraClient } from "../../mastra-client-context-Bx_g84YB.js";
2
- import { n as useCreateWorkflowRun, r as useStreamWorkflow, t as useCancelWorkflowRun } from "../../hooks-DG-Y1KFe.js";
3
- import { t as useInView } from "../../use-in-view-C9sYPGRm.js";
1
+ import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
2
+ import { n as useCreateWorkflowRun, r as useStreamWorkflow, t as useCancelWorkflowRun } from "../../hooks-Btt7PyI-.js";
3
+ import { t as useInView } from "../../use-in-view-CyjKdplM.js";
4
4
  import { MastraClientError } from "@mastra/client-js";
5
5
  import { useEffect } from "react";
6
6
  import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
7
- //#region src/hooks/workflows/use-workflows.ts
7
+ // src/hooks/workflows/use-workflows.ts
8
8
  const useWorkflows = ({ requestContext, queryOptions } = {}) => {
9
9
  const client = useMastraClient();
10
10
  return useQuery({
@@ -16,8 +16,7 @@ const useWorkflows = ({ requestContext, queryOptions } = {}) => {
16
16
  ...queryOptions
17
17
  });
18
18
  };
19
- //#endregion
20
- //#region src/hooks/workflows/use-workflow.ts
19
+ // src/hooks/workflows/use-workflow.ts
21
20
  /**
22
21
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
23
22
  */
@@ -32,8 +31,7 @@ const useWorkflow = ({ workflowId, requestContext, queryOptions } = {}) => {
32
31
  ...queryOptions
33
32
  });
34
33
  };
35
- //#endregion
36
- //#region src/hooks/workflows/use-workflow-runs.ts
34
+ // src/hooks/workflows/use-workflow-runs.ts
37
35
  const PER_PAGE = 20;
38
36
  function getWorkflowRunsNextPageParam(lastPage, _allPages, lastPageParam) {
39
37
  if (lastPage.runs.length < 20) return;
@@ -115,8 +113,7 @@ const useDeleteWorkflowRun = ({ workflowId, queryOptions }) => {
115
113
  ...queryOptions
116
114
  });
117
115
  };
118
- //#endregion
119
- //#region src/hooks/workflows/use-workflows-run-counts.ts
116
+ // src/hooks/workflows/use-workflows-run-counts.ts
120
117
  const RUN_COUNTS_REFETCH_INTERVAL_MS = 5e3;
121
118
  const NO_COUNTS = {};
122
119
  /** Older servers don't ship the endpoint — that (and only that) ends polling. */
@@ -151,7 +148,6 @@ const useWorkflowsRunCounts = ({ requestContext, queryOptions } = {}) => {
151
148
  });
152
149
  return data ?? NO_COUNTS;
153
150
  };
154
- //#endregion
155
151
  export { PER_PAGE, RUN_COUNTS_REFETCH_INTERVAL_MS, getWorkflowRunsNextPageParam, isRunCountsUnsupported, runCountsRefetchInterval, selectUniqueRuns, useCancelWorkflowRun, useCreateWorkflowRun, useDeleteWorkflowRun, useStreamWorkflow, useWorkflow, useWorkflowRun, useWorkflowRuns, useWorkflows, useWorkflowsRunCounts, workflowRunQueryKey };
156
152
 
157
153
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/workflows/use-workflows.ts","../../../src/hooks/workflows/use-workflow.ts","../../../src/hooks/workflows/use-workflow-runs.ts","../../../src/hooks/workflows/use-workflows-run-counts.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowsResponse = Awaited<ReturnType<MastraClient['listWorkflows']>>;\n\nexport const useWorkflows = <TData = WorkflowsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflows', requestContext],\n queryFn: async (): Promise<WorkflowsResponse> => {\n const workflows = await client.listWorkflows(requestContext);\n // Filter out processor workflows - they're shown on the Processors tab instead\n return Object.fromEntries(Object.entries(workflows).filter(([_, workflow]) => !workflow.isProcessorWorkflow));\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['details']>> | null;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflow = <TData = WorkflowResponse>({\n workflowId,\n requestContext,\n queryOptions,\n}: {\n workflowId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['workflow', workflowId],\n queryFn: () => (workflowId ? client.getWorkflow(workflowId).details(requestContext) : null),\n retry: false,\n refetchOnWindowFocus: false,\n throwOnError: false,\n ...queryOptions,\n });\n};\n","import type { GetWorkflowRunByIdResponse, MastraClient } from '@mastra/client-js';\nimport type { QueryKey, UseInfiniteQueryResult, UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype WorkflowRuns = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['runs']>>;\n\nexport const PER_PAGE = 20;\n\nexport function getWorkflowRunsNextPageParam(lastPage: WorkflowRuns, _allPages: unknown, lastPageParam: number) {\n if (lastPage.runs.length < PER_PAGE) {\n return undefined;\n }\n return lastPageParam + 1;\n}\n\nexport function selectUniqueRuns(data: { pages: WorkflowRuns[] }) {\n const seen = new Set<string>();\n return data.pages\n .flatMap(page => page.runs)\n .filter(run => {\n if (seen.has(run.runId)) return false;\n seen.add(run.runId);\n return true;\n });\n}\n\n/**\n * `summary: true` asks the server to reduce each run snapshot to `{ status, timestamp }`,\n * avoiding transfer of full snapshots when only list metadata is displayed.\n */\nexport const useWorkflowRuns = <TData = ReturnType<typeof selectUniqueRuns>>({\n workflowId,\n summary = false,\n queryOptions,\n}: {\n workflowId: string;\n summary?: boolean;\n queryOptions?: MastraInfiniteQueryOptions<WorkflowRuns, TData, QueryKey, number>;\n}): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const query = useInfiniteQuery({\n queryKey: ['workflow-runs', workflowId, { summary }],\n queryFn: ({ pageParam }) =>\n client\n .getWorkflow(workflowId)\n .runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE, ...(summary ? { summary: true } : {}) }),\n initialPageParam: 0,\n getNextPageParam: getWorkflowRunsNextPageParam,\n select: data => selectUniqueRuns(data) as TData,\n retry: false,\n refetchInterval: 5000,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const workflowRunQueryKey = (workflowId: string, runId: string) => ['workflow-run', workflowId, runId] as const;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflowRun = <TData = GetWorkflowRunByIdResponse>({\n workflowId,\n runId,\n queryOptions,\n}: {\n workflowId: string;\n runId: string;\n queryOptions?: MastraQueryOptions<GetWorkflowRunByIdResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<GetWorkflowRunByIdResponse, Error, TData>({\n queryKey: workflowRunQueryKey(workflowId, runId),\n queryFn: () => client.getWorkflow(workflowId).runById(runId),\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkflowRun = ({\n workflowId,\n queryOptions,\n}: {\n workflowId: string;\n queryOptions?: MastraMutationOptions<unknown, { runId: string }>;\n}): UseMutationResult<unknown, Error, { runId: string }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ runId }: { runId: string }) => client.getWorkflow(workflowId).deleteRunById(runId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['workflow-runs', workflowId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListWorkflowRunCountsResponse } from '@mastra/client-js';\nimport { MastraClientError } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const RUN_COUNTS_REFETCH_INTERVAL_MS = 5000;\n\nconst NO_COUNTS: ListWorkflowRunCountsResponse = {};\n\n/** Older servers don't ship the endpoint — that (and only that) ends polling. */\nexport function isRunCountsUnsupported(error: unknown): boolean {\n return error instanceof MastraClientError && error.status === 404;\n}\n\n/**\n * Poll cadence: keep polling through transient failures (a blip must not\n * silence the counts forever), but stop entirely once the server has said the\n * endpoint does not exist.\n */\nexport function runCountsRefetchInterval(error: unknown): number | false {\n return isRunCountsUnsupported(error) ? false : RUN_COUNTS_REFETCH_INTERVAL_MS;\n}\n\n/**\n * Per-workflow counts of `running` (in-flight) and `suspended` (stopped at a\n * suspend() point awaiting resume — the human-in-the-loop state) runs, keyed\n * by the workflow registry key.\n *\n * One lightweight server request per poll — the server aggregates counts\n * across workflows (GET /workflows/run-counts). Older servers 404 the first\n * request; polling then stops and the list renders without count columns.\n */\nexport const useWorkflowsRunCounts = ({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListWorkflowRunCountsResponse>;\n} = {}): ListWorkflowRunCountsResponse => {\n const client = useMastraClient();\n\n const { data } = useQuery({\n queryKey: ['workflow-run-counts', requestContext],\n queryFn: () => client.listWorkflowRunCounts(requestContext),\n retry: false,\n refetchInterval: query => runCountsRefetchInterval(query.state.error),\n ...queryOptions,\n });\n\n return data ?? NO_COUNTS;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,gBAA2C,EACtD,gBACA,iBAIE,CAAC,MAAoC;CACvC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAS;EACd,UAAU,CAAC,aAAa,cAAc;EACtC,SAAS,YAAwC;GAC/C,MAAM,YAAY,MAAM,OAAO,cAAc,cAAc;GAE3D,OAAO,OAAO,YAAY,OAAO,QAAQ,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,SAAS,mBAAmB,CAAC;EAC9G;EACA,GAAG;CACL,CAAC;AACH;;;;;;ACfA,MAAa,eAAyC,EACpD,YACA,gBACA,iBAKE,CAAC,MAAoC;CACvC,MAAM,SAAS,gBAAgB;CAC/B,OAAO,SAAS;EACd,UAAU,CAAC,YAAY,UAAU;EACjC,eAAgB,aAAa,OAAO,YAAY,UAAU,CAAC,CAAC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A,mBAKkC;CAClC,MAAM,SAAS,gBAAgB;CAC/B,OAAO,SAAmD;EACxD,UAAU,oBAAoB,YAAY,KAAK;EAC/C,eAAe,OAAO,YAAY,UAAU,CAAC,CAAC,QAAQ,KAAK;EAC3D,QAAQ;EACR,WAAW;EACX,GAAG;CACL,CAAC;AACH;AAEA,MAAa,wBAAwB,EACnC,YACA,mBAI0D;CAC1D,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CACnC,OAAO,YAAY;EACjB,aAAa,EAAE,YAA+B,OAAO,YAAY,UAAU,CAAC,CAAC,cAAc,KAAK;EAChG,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,UAAU,EAAE,CAAC;EAChF;EACA,GAAG;CACL,CAAC;AACH;;;AC1GA,MAAa,iCAAiC;AAE9C,MAAM,YAA2C,CAAC;;AAGlD,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,iBAAiB,qBAAqB,MAAM,WAAW;AAChE;;;;;;AAOA,SAAgB,yBAAyB,OAAgC;CACvE,OAAO,uBAAuB,KAAK,IAAI,QAAQ;AACjD;;;;;;;;;;AAWA,MAAa,yBAAyB,EACpC,gBACA,iBAIE,CAAC,MAAqC;CACxC,MAAM,SAAS,gBAAgB;CAE/B,MAAM,EAAE,SAAS,SAAS;EACxB,UAAU,CAAC,uBAAuB,cAAc;EAChD,eAAe,OAAO,sBAAsB,cAAc;EAC1D,OAAO;EACP,kBAAiB,UAAS,yBAAyB,MAAM,MAAM,KAAK;EACpE,GAAG;CACL,CAAC;CAED,OAAO,QAAQ;AACjB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/workflows/use-workflows.ts","../../../src/hooks/workflows/use-workflow.ts","../../../src/hooks/workflows/use-workflow-runs.ts","../../../src/hooks/workflows/use-workflows-run-counts.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowsResponse = Awaited<ReturnType<MastraClient['listWorkflows']>>;\n\nexport const useWorkflows = <TData = WorkflowsResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['workflows', requestContext],\n queryFn: async (): Promise<WorkflowsResponse> => {\n const workflows = await client.listWorkflows(requestContext);\n // Filter out processor workflows - they're shown on the Processors tab instead\n return Object.fromEntries(Object.entries(workflows).filter(([_, workflow]) => !workflow.isProcessorWorkflow));\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype WorkflowResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['details']>> | null;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflow = <TData = WorkflowResponse>({\n workflowId,\n requestContext,\n queryOptions,\n}: {\n workflowId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<WorkflowResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery({\n queryKey: ['workflow', workflowId],\n queryFn: () => (workflowId ? client.getWorkflow(workflowId).details(requestContext) : null),\n retry: false,\n refetchOnWindowFocus: false,\n throwOnError: false,\n ...queryOptions,\n });\n};\n","import type { GetWorkflowRunByIdResponse, MastraClient } from '@mastra/client-js';\nimport type { QueryKey, UseInfiniteQueryResult, UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions, MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\ntype WorkflowRuns = Awaited<ReturnType<ReturnType<MastraClient['getWorkflow']>['runs']>>;\n\nexport const PER_PAGE = 20;\n\nexport function getWorkflowRunsNextPageParam(lastPage: WorkflowRuns, _allPages: unknown, lastPageParam: number) {\n if (lastPage.runs.length < PER_PAGE) {\n return undefined;\n }\n return lastPageParam + 1;\n}\n\nexport function selectUniqueRuns(data: { pages: WorkflowRuns[] }) {\n const seen = new Set<string>();\n return data.pages\n .flatMap(page => page.runs)\n .filter(run => {\n if (seen.has(run.runId)) return false;\n seen.add(run.runId);\n return true;\n });\n}\n\n/**\n * `summary: true` asks the server to reduce each run snapshot to `{ status, timestamp }`,\n * avoiding transfer of full snapshots when only list metadata is displayed.\n */\nexport const useWorkflowRuns = <TData = ReturnType<typeof selectUniqueRuns>>({\n workflowId,\n summary = false,\n queryOptions,\n}: {\n workflowId: string;\n summary?: boolean;\n queryOptions?: MastraInfiniteQueryOptions<WorkflowRuns, TData, QueryKey, number>;\n}): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n const query = useInfiniteQuery({\n queryKey: ['workflow-runs', workflowId, { summary }],\n queryFn: ({ pageParam }) =>\n client\n .getWorkflow(workflowId)\n .runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE, ...(summary ? { summary: true } : {}) }),\n initialPageParam: 0,\n getNextPageParam: getWorkflowRunsNextPageParam,\n select: data => selectUniqueRuns(data) as TData,\n retry: false,\n refetchInterval: 5000,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const workflowRunQueryKey = (workflowId: string, runId: string) => ['workflow-run', workflowId, runId] as const;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkflowRun = <TData = GetWorkflowRunByIdResponse>({\n workflowId,\n runId,\n queryOptions,\n}: {\n workflowId: string;\n runId: string;\n queryOptions?: MastraQueryOptions<GetWorkflowRunByIdResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<GetWorkflowRunByIdResponse, Error, TData>({\n queryKey: workflowRunQueryKey(workflowId, runId),\n queryFn: () => client.getWorkflow(workflowId).runById(runId),\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkflowRun = ({\n workflowId,\n queryOptions,\n}: {\n workflowId: string;\n queryOptions?: MastraMutationOptions<unknown, { runId: string }>;\n}): UseMutationResult<unknown, Error, { runId: string }> => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ runId }: { runId: string }) => client.getWorkflow(workflowId).deleteRunById(runId),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['workflow-runs', workflowId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListWorkflowRunCountsResponse } from '@mastra/client-js';\nimport { MastraClientError } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const RUN_COUNTS_REFETCH_INTERVAL_MS = 5000;\n\nconst NO_COUNTS: ListWorkflowRunCountsResponse = {};\n\n/** Older servers don't ship the endpoint — that (and only that) ends polling. */\nexport function isRunCountsUnsupported(error: unknown): boolean {\n return error instanceof MastraClientError && error.status === 404;\n}\n\n/**\n * Poll cadence: keep polling through transient failures (a blip must not\n * silence the counts forever), but stop entirely once the server has said the\n * endpoint does not exist.\n */\nexport function runCountsRefetchInterval(error: unknown): number | false {\n return isRunCountsUnsupported(error) ? false : RUN_COUNTS_REFETCH_INTERVAL_MS;\n}\n\n/**\n * Per-workflow counts of `running` (in-flight) and `suspended` (stopped at a\n * suspend() point awaiting resume — the human-in-the-loop state) runs, keyed\n * by the workflow registry key.\n *\n * One lightweight server request per poll — the server aggregates counts\n * across workflows (GET /workflows/run-counts). Older servers 404 the first\n * request; polling then stops and the list renders without count columns.\n */\nexport const useWorkflowsRunCounts = ({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListWorkflowRunCountsResponse>;\n} = {}): ListWorkflowRunCountsResponse => {\n const client = useMastraClient();\n\n const { data } = useQuery({\n queryKey: ['workflow-run-counts', requestContext],\n queryFn: () => client.listWorkflowRunCounts(requestContext),\n retry: false,\n refetchInterval: query => runCountsRefetchInterval(query.state.error),\n ...queryOptions,\n });\n\n return data ?? NO_COUNTS;\n};\n"],"mappings":";;;;;;;AAQA,MAAa,gBAA2C,EACtD,gBACA,iBAIE,CAAC,MAAoC;CACvC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAS;EACd,UAAU,CAAC,aAAa,cAAc;EACtC,SAAS,YAAwC;GAC/C,MAAM,YAAY,MAAM,OAAO,cAAc,cAAc;GAE3D,OAAO,OAAO,YAAY,OAAO,QAAQ,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,cAAc,CAAC,SAAS,mBAAmB,CAAC;EAC9G;EACA,GAAG;CACL,CAAC;AACH;;;;;ACfA,MAAa,eAAyC,EACpD,YACA,gBACA,iBAKE,CAAC,MAAoC;CACvC,MAAM,SAAS,gBAAgB;CAC/B,OAAO,SAAS;EACd,UAAU,CAAC,YAAY,UAAU;EACjC,eAAgB,aAAa,OAAO,YAAY,UAAU,CAAC,CAAC,QAAQ,cAAc,IAAI;EACtF,OAAO;EACP,sBAAsB;EACtB,cAAc;EACd,GAAG;CACL,CA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,YAAY,KAAK;EAC/C,eAAe,OAAO,YAAY,UAAU,CAAC,CAAC,QAAQ,KAAK;EAC3D,QAAQ;EACR,WAAW;EACX,GAAG;CACL,CAAC;AACH;AAEA,MAAa,wBAAwB,EACnC,YACA,mBAI0D;CAC1D,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CACnC,OAAO,YAAY;EACjB,aAAa,EAAE,YAA+B,OAAO,YAAY,UAAU,CAAC,CAAC,cAAc,KAAK;EAChG,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,UAAU,EAAE,CAAC;EAChF;EACA,GAAG;CACL,CAAC;AACH;;AC1GA,MAAa,iCAAiC;AAE9C,MAAM,YAA2C,CAAC;;AAGlD,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,iBAAiB,qBAAqB,MAAM,WAAW;AAChE;;;;;;AAOA,SAAgB,yBAAyB,OAAgC;CACvE,OAAO,uBAAuB,KAAK,IAAI,QAAQ;AACjD;;;;;;;;;;AAWA,MAAa,yBAAyB,EACpC,gBACA,iBAIE,CAAC,MAAqC;CACxC,MAAM,SAAS,gBAAgB;CAE/B,MAAM,EAAE,SAAS,SAAS;EACxB,UAAU,CAAC,uBAAuB,cAAc;EAChD,eAAe,OAAO,sBAAsB,cAAc;EAC1D,OAAO;EACP,kBAAiB,UAAS,yBAAyB,MAAM,MAAM,KAAK;EACpE,GAAG;CACL,CAAC;CAED,OAAO,QAAQ;AACjB"}
@@ -1,17 +1,16 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mastra_client_context = require("../../mastra-client-context-DzX3f0RF.cjs");
3
- const require_query_utils = require("../../query-utils-CcrChYgz.cjs");
2
+ const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
3
+ const require_query_utils = require("../../query-utils-BVgE_xxj.cjs");
4
4
  let _tanstack_react_query = require("@tanstack/react-query");
5
5
  let _mastra_core_features = require("@mastra/core/features");
6
- //#region src/hooks/workspace/client-utils.ts
6
+ // src/hooks/workspace/client-utils.ts
7
7
  /**
8
8
  * Checks if a method exists on an object and is callable.
9
9
  */
10
10
  function hasMethod(obj, method) {
11
11
  return method in obj && typeof obj[method] === "function";
12
12
  }
13
- //#endregion
14
- //#region src/hooks/workspace/compatibility.ts
13
+ // src/hooks/workspace/compatibility.ts
15
14
  /**
16
15
  * Checks if workspace v1 features are supported by both core and client.
17
16
  * This guards against version mismatches between playground-ui, core, and client-js.
@@ -68,8 +67,7 @@ const shouldRetryWorkspaceQuery = (failureCount, error) => {
68
67
  if (require_query_utils.isNonRetryableError(error)) return false;
69
68
  return failureCount < 3;
70
69
  };
71
- //#endregion
72
- //#region src/hooks/workspace/file-type.ts
70
+ // src/hooks/workspace/file-type.ts
73
71
  const IMAGE_EXTENSIONS = [
74
72
  "png",
75
73
  "jpg",
@@ -96,8 +94,7 @@ const isVideoFile = (path, mimeType) => mimeType?.startsWith("video/") || extens
96
94
  const isMediaFile = (path) => isImageFile(path) || isVideoFile(path);
97
95
  const videoMimeType = (path, mimeType) => mimeType?.startsWith("video/") ? mimeType : VIDEO_MIME_TYPES[extension(path)] ?? "video/mp4";
98
96
  const isMarkdownFile = (path) => /\.mdx?$/i.test(path);
99
- //#endregion
100
- //#region src/hooks/workspace/use-skills-sh.ts
97
+ // src/hooks/workspace/use-skills-sh.ts
101
98
  /**
102
99
  * Search skills on skills.sh (via server proxy)
103
100
  */
@@ -257,8 +254,7 @@ const useRemoveSkill = ({ queryOptions } = {}) => {
257
254
  ...queryOptions
258
255
  });
259
256
  };
260
- //#endregion
261
- //#region src/hooks/workspace/use-stored-workspaces.ts
257
+ // src/hooks/workspace/use-stored-workspaces.ts
262
258
  /**
263
259
  * Hook to list stored workspaces from the database.
264
260
  * These are workspaces that have been persisted via the stored workspaces API,
@@ -274,8 +270,7 @@ const useStoredWorkspaces = ({ queryOptions, ...params } = {}) => {
274
270
  ...queryOptions
275
271
  });
276
272
  };
277
- //#endregion
278
- //#region src/hooks/workspace/use-workspace.ts
273
+ // src/hooks/workspace/use-workspace.ts
279
274
  function getParentPath(path) {
280
275
  return path.split("/").slice(0, -1).join("/") || (path.startsWith("/") ? "/" : ".");
281
276
  }
@@ -450,8 +445,7 @@ const useIndexWorkspaceContent = ({ queryOptions } = {}) => {
450
445
  ...queryOptions
451
446
  });
452
447
  };
453
- //#endregion
454
- //#region src/hooks/workspace/use-workspace-directory.ts
448
+ // src/hooks/workspace/use-workspace-directory.ts
455
449
  const WORKSPACE_REFETCH_INTERVAL = 1e4;
456
450
  function useWorkspaceDirectory({ workspaceId, path, queryOptions }) {
457
451
  const client = require_mastra_client_context.useMastraClient();
@@ -468,8 +462,7 @@ function useWorkspaceDirectory({ workspaceId, path, queryOptions }) {
468
462
  ...queryOptions
469
463
  });
470
464
  }
471
- //#endregion
472
- //#region src/hooks/workspace/use-workspace-file-content.ts
465
+ // src/hooks/workspace/use-workspace-file-content.ts
473
466
  /**
474
467
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
475
468
  */
@@ -490,8 +483,7 @@ function useWorkspaceFileContent({ workspaceId, path, queryOptions }) {
490
483
  ...queryOptions
491
484
  });
492
485
  }
493
- //#endregion
494
- //#region src/hooks/workspace/use-workspace-search.ts
486
+ // src/hooks/workspace/use-workspace-search.ts
495
487
  const filePathFromId = (id) => id.replace(/#chunk-\d+$/, "");
496
488
  const basename = (path) => path.split("/").filter(Boolean).pop() ?? path;
497
489
  const skillFilePath = (result) => result.skillPath ? `${result.skillPath.replace(/\/$/, "")}/SKILL.md` : result.source;
@@ -540,8 +532,7 @@ function useWorkspaceSearch({ workspaceId, query, files: searchFiles = true, ski
540
532
  ...queryOptions
541
533
  });
542
534
  }
543
- //#endregion
544
- //#region src/hooks/workspace/use-workspace-skills.ts
535
+ // src/hooks/workspace/use-workspace-skills.ts
545
536
  /**
546
537
  * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
547
538
  */
@@ -589,7 +580,6 @@ const useAgentSkill = ({ agentId, skillName, workspaceId, path, queryOptions })
589
580
  enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true)
590
581
  });
591
582
  };
592
- //#endregion
593
583
  exports.WORKSPACE_REFETCH_INTERVAL = WORKSPACE_REFETCH_INTERVAL;
594
584
  exports.isImageFile = isImageFile;
595
585
  exports.isMarkdownFile = isMarkdownFile;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["coreFeatures","isNonRetryableError","useMastraClient","useMutation","useQuery","useQueryClient","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery"],"sources":["../../../src/hooks/workspace/client-utils.ts","../../../src/hooks/workspace/compatibility.ts","../../../src/hooks/workspace/file-type.ts","../../../src/hooks/workspace/use-skills-sh.ts","../../../src/hooks/workspace/use-stored-workspaces.ts","../../../src/hooks/workspace/use-workspace.ts","../../../src/hooks/workspace/use-workspace-directory.ts","../../../src/hooks/workspace/use-workspace-file-content.ts","../../../src/hooks/workspace/use-workspace-search.ts","../../../src/hooks/workspace/use-workspace-skills.ts"],"sourcesContent":["/**\n * Checks if a method exists on an object and is callable.\n */\nexport function hasMethod<T>(obj: T, method: string): boolean {\n return method in (obj as object) && typeof (obj as Record<string, unknown>)[method] === 'function';\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { coreFeatures } from '@mastra/core/features';\nimport { isNonRetryableError } from '../query/query-utils';\nimport { hasMethod } from './client-utils';\n\n/**\n * Checks if workspace v1 features are supported by both core and client.\n * This guards against version mismatches between playground-ui, core, and client-js.\n */\nexport const isWorkspaceV1Supported = (client: MastraClient) => {\n const workspaceClientMethods = ['listWorkspaces', 'getWorkspace'];\n\n const coreSupported = coreFeatures.has('workspaces-v1');\n const clientSupported = workspaceClientMethods.every(method => hasMethod(client, method));\n\n return coreSupported && clientSupported;\n};\n\n/**\n * Gets the HTTP status code from an error if present.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst getStatusCode = (error: unknown): number | undefined => {\n if (!error || typeof error !== 'object') return undefined;\n\n // Check for status property (MastraClientError, fetch Response, etc.)\n if ('status' in error && typeof (error as { status: unknown }).status === 'number') {\n return (error as { status: number }).status;\n }\n\n // Check for statusCode property (from some HTTP clients)\n if ('statusCode' in error && typeof (error as { statusCode: unknown }).statusCode === 'number') {\n return (error as { statusCode: number }).statusCode;\n }\n\n return undefined;\n};\n\n/**\n * Checks if an error has a specific HTTP status code.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst hasStatusCode = (error: unknown, statusCode: number): boolean => {\n return getStatusCode(error) === statusCode;\n};\n\n/**\n * Checks if an error is a 4xx client error (e.g., 400, 401, 403, 404).\n * Client errors won't resolve with retries.\n */\nconst isClientError = (error: unknown): boolean => {\n const status = getStatusCode(error);\n return status !== undefined && status >= 400 && status < 500;\n};\n\n/**\n * Checks if an error is a \"Not Implemented\" (501) error from the server.\n * This indicates the server's @mastra/core version doesn't support workspaces.\n */\nexport const isWorkspaceNotSupportedError = (error: unknown): boolean => {\n if (hasStatusCode(error, 501)) {\n return true;\n }\n\n // Check error message for our specific error\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('Workspace v1 not supported') || message.includes('501');\n }\n\n return false;\n};\n\n/**\n * Checks if an error is a \"Not Found\" (404) error from the server.\n * This indicates the requested resource doesn't exist (e.g., file not found).\n */\nexport const isNotFoundError = (error: unknown): boolean => {\n if (hasStatusCode(error, 404)) {\n return true;\n }\n\n // Check error message for status code (client-js throws Error with message like \"HTTP error! status: 404 - ...\")\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('status: 404');\n }\n\n return false;\n};\n\n/**\n * React Query retry function that doesn't retry on client errors (4xx) or 501 errors.\n * Use this to prevent infinite retries when resources don't exist, access is denied, or workspaces aren't supported.\n */\nexport const shouldRetryWorkspaceQuery = (failureCount: number, error: Error): boolean => {\n // Don't retry 4xx client errors (400, 401, 403, 404, etc.) - these won't resolve with retries\n if (isClientError(error)) {\n return false;\n }\n // Don't retry 501 \"Not Implemented\" errors - they won't resolve with retries\n if (isWorkspaceNotSupportedError(error)) {\n return false;\n }\n // Don't retry 4xx client errors (400, 401, 403, 404)\n if (isNonRetryableError(error)) {\n return false;\n }\n // Default retry behavior: retry up to 3 times\n return failureCount < 3;\n};\n","const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'bmp', 'avif', 'tiff', 'tif'];\nconst VIDEO_MIME_TYPES: Record<string, string> = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n mov: 'video/quicktime',\n m4v: 'video/mp4',\n ogv: 'video/ogg',\n};\n\nconst extension = (path: string) => path.split('/').pop()?.split('.').pop()?.toLowerCase() ?? '';\n\nexport const isImageFile = (path: string, mimeType?: string) =>\n mimeType?.startsWith('image/') || IMAGE_EXTENSIONS.includes(extension(path));\n\nexport const isVideoFile = (path: string, mimeType?: string) =>\n mimeType?.startsWith('video/') || extension(path) in VIDEO_MIME_TYPES;\n\n/** Media must be read as base64: reading it as utf-8 corrupts the bytes. */\nexport const isMediaFile = (path: string) => isImageFile(path) || isVideoFile(path);\n\nexport const videoMimeType = (path: string, mimeType?: string) =>\n mimeType?.startsWith('video/') ? mimeType : (VIDEO_MIME_TYPES[extension(path)] ?? 'video/mp4');\n\nexport const isMarkdownFile = (path: string) => /\\.mdx?$/i.test(path);\n","import type { MastraClient, SkillsShSkill } from '@mastra/client-js';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { SkillsShSkill };\n\ntype SearchSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['searchSkillsSh']>>;\ntype PopularSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['listPopularSkillsSh']>>;\ntype InstallSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['installSkillsSh']>>;\ntype UpdateSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['updateSkillsSh']>>;\ntype RemoveSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['removeSkillsSh']>>;\n\n/**\n * Search skills on skills.sh (via server proxy)\n */\nexport const useSearchSkillsSh = ({\n workspaceId,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n queryOptions?: MastraMutationOptions<SearchSkillsShResponse, string>;\n}): UseMutationResult<SearchSkillsShResponse, Error, string> => {\n const client = useMastraClient();\n\n return useMutation<SearchSkillsShResponse, Error, string>({\n mutationFn: (query: string) => {\n if (!workspaceId) throw new Error('Workspace ID is required');\n return client.getWorkspace(workspaceId).searchSkillsSh({ q: query, limit: 10 });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Get popular skills from skills.sh (via server proxy, cached for 5 minutes)\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePopularSkillsSh = <TData = PopularSkillsShResponse>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n queryOptions?: MastraQueryOptions<PopularSkillsShResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PopularSkillsShResponse, Error, TData>({\n queryKey: ['skills-sh', 'popular', workspaceId],\n queryFn: () => {\n if (!workspaceId) throw new Error('Workspace ID is required');\n return client.getWorkspace(workspaceId).listPopularSkillsSh({ limit: 10, offset: 0 });\n },\n staleTime: 5 * 60 * 1000,\n ...queryOptions,\n });\n};\n\n/**\n * Preview a skill by fetching its SKILL.md (via server proxy to avoid CORS)\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSkillPreview = <TData = string>({\n workspaceId,\n owner,\n repo,\n skillPath,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n owner: string | undefined;\n repo: string | undefined;\n skillPath: string | undefined;\n queryOptions?: MastraQueryOptions<string, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<string, Error, TData>({\n queryKey: ['skills-sh', 'preview', workspaceId, owner, repo, skillPath],\n queryFn: async () => {\n if (!workspaceId || !owner || !repo || !skillPath) {\n throw new Error('workspaceId, owner, repo, and skillPath are required');\n }\n const { content } = await client.getWorkspace(workspaceId).previewSkillsSh({ owner, repo, path: skillPath });\n return content;\n },\n retry: false,\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Helper: Parse skills.sh skill ID to repository info\n// =============================================================================\n\n/**\n * Parse a skill's topSource field to extract GitHub repository info\n *\n * skills.sh topSource formats:\n * - \"owner/repo\" (e.g., \"vercel-labs/agent-skills\")\n * - \"owner/repo/path\" (e.g., \"anthropics/skills/frontend-design\")\n * - \"github.com/owner/repo/path\" (full URL format)\n *\n * The skill name is used as the path within the repo when not specified\n */\nexport function parseSkillSource(\n topSource: string,\n skillName?: string,\n): {\n owner: string;\n repo: string;\n skillPath: string;\n} | null {\n // Remove protocol and github.com prefix if present\n let cleanSource = topSource.replace(/^https?:\\/\\//, '');\n cleanSource = cleanSource.replace(/^github\\.com\\//, '');\n // Remove trailing slash if present\n cleanSource = cleanSource.replace(/\\/$/, '');\n\n const parts = cleanSource.split('/').filter(Boolean);\n const [owner, repo] = parts;\n\n if (!owner || !repo) {\n return null;\n }\n\n // If there's a path in topSource, use it; otherwise use skill name\n let skillPath: string;\n if (parts.length > 2) {\n // Path is specified in topSource (e.g., \"anthropics/skills/frontend-design\")\n skillPath = parts.slice(2).join('/');\n } else if (skillName) {\n // No path in topSource, use skill name (e.g., for \"vercel-labs/agent-skills\" + skill \"web-design-guidelines\")\n skillPath = skillName;\n } else {\n return null;\n }\n\n return {\n owner,\n repo,\n skillPath,\n };\n}\n\n// =============================================================================\n// Skill Management Hooks (via server proxy)\n// =============================================================================\n\nexport interface InstallSkillParams {\n workspaceId: string;\n /** Repository in format owner/repo */\n repository: string;\n /** Skill name within the repo */\n skillName: string;\n /** Mount path to install into (for CompositeFilesystem) */\n mount?: string;\n}\n\n/**\n * Install a skill by fetching from GitHub and writing to workspace filesystem.\n */\nexport const useInstallSkill = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<InstallSkillsShResponse, InstallSkillParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: InstallSkillParams) => {\n const [owner, repo] = params.repository.split('/');\n if (!owner || !repo) {\n throw new Error('Invalid repository format. Expected owner/repo');\n }\n return client\n .getWorkspace(params.workspaceId)\n .installSkillsSh({ owner, repo, skillName: params.skillName, mount: params.mount });\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n\nexport interface UpdateSkillsParams {\n workspaceId: string;\n skillName?: string;\n}\n\n/**\n * Update installed skills by re-fetching from GitHub.\n */\nexport const useUpdateSkills = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<UpdateSkillsShResponse, UpdateSkillsParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: UpdateSkillsParams) =>\n client.getWorkspace(params.workspaceId).updateSkillsSh({ skillName: params.skillName }),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n\nexport interface RemoveSkillParams {\n workspaceId: string;\n skillName: string;\n}\n\n/**\n * Remove an installed skill by deleting its directory.\n */\nexport const useRemoveSkill = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<RemoveSkillsShResponse, RemoveSkillParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: RemoveSkillParams) =>\n client.getWorkspace(params.workspaceId).removeSkillsSh({ skillName: params.skillName }),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListStoredWorkspacesParams, ListStoredWorkspacesResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Hook to list stored workspaces from the database.\n * These are workspaces that have been persisted via the stored workspaces API,\n * as opposed to runtime-registered workspaces from code-defined agents.\n */\nexport const useStoredWorkspaces = <TData = ListStoredWorkspacesResponse>({\n queryOptions,\n ...params\n}: ListStoredWorkspacesParams & {\n queryOptions?: MastraQueryOptions<ListStoredWorkspacesResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredWorkspacesResponse, Error, TData>({\n queryKey: ['stored-workspaces', params],\n queryFn: async (): Promise<ListStoredWorkspacesResponse> => {\n return client.listStoredWorkspaces(params);\n },\n ...queryOptions,\n });\n};\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { isWorkspaceV1Supported, shouldRetryWorkspaceQuery, isWorkspaceNotSupportedError } from './compatibility';\nimport type {\n WorkspaceInfo,\n WorkspacesListResponse,\n FileStatResponse,\n WriteFileParams,\n WriteFileFromFileParams,\n} from './types';\n\nexport type DeleteWorkspaceFileParams = { path: string; recursive?: boolean; force?: boolean; workspaceId?: string };\nexport type CreateWorkspaceDirectoryParams = { path: string; recursive?: boolean; workspaceId?: string };\nexport type IndexWorkspaceContentParams = {\n workspaceId: string;\n path: string;\n content: string;\n metadata?: Record<string, unknown>;\n};\n\nfunction getParentPath(path: string): string {\n return path.split('/').slice(0, -1).join('/') || (path.startsWith('/') ? '/' : '.');\n}\n\n// Re-export for other hooks to use\nexport { isWorkspaceV1Supported, isWorkspaceNotSupportedError };\n\n// =============================================================================\n// Workspace Info Hook\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceInfo = <TData = WorkspaceInfo>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<WorkspaceInfo, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<WorkspaceInfo, Error, TData>({\n queryKey: ['workspace', 'info', workspaceId],\n queryFn: async (): Promise<WorkspaceInfo> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.info();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\n// =============================================================================\n// List All Workspaces Hook\n// =============================================================================\n\nexport const useWorkspaces = <TData = WorkspacesListResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<WorkspacesListResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<WorkspacesListResponse, Error, TData>({\n queryKey: ['workspaces'],\n queryFn: async (): Promise<WorkspacesListResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n return (client as any).listWorkspaces();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Filesystem Hooks\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceFileStat = <TData = FileStatResponse>({\n path,\n workspaceId,\n queryOptions,\n}: {\n path: string;\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<FileStatResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<FileStatResponse, Error, TData>({\n queryKey: ['workspace', 'stat', path, workspaceId],\n queryFn: async (): Promise<FileStatResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.stat(path);\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\nexport const useWriteWorkspaceFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, WriteFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, WriteFileParams>({\n mutationFn: async (params: WriteFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.writeFile(params.path, params.content, {\n encoding: params.encoding,\n recursive: params.recursive ?? true,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useWriteWorkspaceFileFromFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, WriteFileFromFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, WriteFileFromFileParams>({\n mutationFn: async (params: WriteFileFromFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n // Convert file to base64\n const arrayBuffer = await params.file.arrayBuffer();\n const base64 = btoa(new Uint8Array(arrayBuffer).reduce((data, byte) => data + String.fromCharCode(byte), ''));\n\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.writeFile(params.path, base64, {\n encoding: 'base64',\n recursive: params.recursive ?? true,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkspaceFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, DeleteWorkspaceFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, DeleteWorkspaceFileParams>({\n mutationFn: async (params: DeleteWorkspaceFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.delete(params.path, {\n recursive: params.recursive,\n force: params.force,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useCreateWorkspaceDirectory = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, CreateWorkspaceDirectoryParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, CreateWorkspaceDirectoryParams>({\n mutationFn: async (params: CreateWorkspaceDirectoryParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.mkdir(params.path, params.recursive);\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n },\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Search Hooks\n// =============================================================================\n\nexport const useIndexWorkspaceContent = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, IndexWorkspaceContentParams> } = {}) => {\n const client = useMastraClient();\n\n return useMutation<unknown, Error, IndexWorkspaceContentParams>({\n mutationFn: async (params: IndexWorkspaceContentParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.index({\n path: params.path,\n content: params.content,\n metadata: params.metadata,\n });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const WORKSPACE_REFETCH_INTERVAL = 10_000;\n\n/** Lists a single directory level and polls it. Callers enable it only once the folder is expanded. */\ntype WorkspaceDirectoryEntries = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['listFiles']>>['entries'];\n\nexport function useWorkspaceDirectory<TData = WorkspaceDirectoryEntries>({\n workspaceId,\n path,\n queryOptions,\n}: {\n workspaceId: string;\n path: string;\n queryOptions?: MastraQueryOptions<WorkspaceDirectoryEntries, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<WorkspaceDirectoryEntries, Error, TData>({\n queryKey: ['workspace', workspaceId, 'fs', 'list', path],\n queryFn: async () => (await client.getWorkspace(workspaceId).listFiles(path, false)).entries,\n refetchInterval: WORKSPACE_REFETCH_INTERVAL,\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport { isMediaFile } from './file-type';\nimport { WORKSPACE_REFETCH_INTERVAL } from './use-workspace-directory';\n\n/** Reads a file (base64 for images/videos) and polls it so the viewer follows external edits. */\ntype WorkspaceFileContent = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['readFile']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkspaceFileContent<TData = WorkspaceFileContent>({\n workspaceId,\n path,\n queryOptions,\n}: {\n workspaceId: string;\n path?: string;\n queryOptions?: MastraQueryOptions<WorkspaceFileContent, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const encoding = path && isMediaFile(path) ? 'base64' : undefined;\n\n return useQuery<WorkspaceFileContent, Error, TData>({\n queryKey: ['workspace', workspaceId, 'fs', 'read', path, encoding],\n queryFn: () => client.getWorkspace(workspaceId).readFile(path ?? '', encoding),\n refetchInterval: WORKSPACE_REFETCH_INTERVAL,\n ...queryOptions,\n });\n}\n","import type { SkillSearchResult } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface WorkspaceSearchHit {\n kind: 'file' | 'skill';\n path: string;\n label: string;\n score: number;\n}\n\n// Chunked files are indexed as `<path>#chunk-<n>`.\nconst filePathFromId = (id: string) => id.replace(/#chunk-\\d+$/, '');\n\nconst basename = (path: string) => path.split('/').filter(Boolean).pop() ?? path;\n\n// The server returns `skillPath`, which the client type does not declare yet.\nconst skillFilePath = (result: SkillSearchResult & { skillPath?: string }) =>\n result.skillPath ? `${result.skillPath.replace(/\\/$/, '')}/SKILL.md` : result.source;\n\n/** Searches files and skills in parallel; one failing source (e.g. 501 not configured) keeps the other's hits. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkspaceSearch<TData = WorkspaceSearchHit[]>({\n workspaceId,\n query,\n files: searchFiles = true,\n skills: searchSkills = true,\n queryOptions,\n}: {\n workspaceId: string;\n query: string;\n files?: boolean;\n skills?: boolean;\n queryOptions?: MastraQueryOptions<WorkspaceSearchHit[], TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const trimmed = query.trim();\n\n return useQuery<WorkspaceSearchHit[], Error, TData>({\n queryKey: ['workspace', workspaceId, 'search', trimmed, searchFiles, searchSkills],\n queryFn: async () => {\n const workspace = client.getWorkspace(workspaceId);\n const [files, skills] = await Promise.allSettled([\n searchFiles ? workspace.search({ query: trimmed }) : Promise.reject(new Error('File search disabled')),\n searchSkills ? workspace.searchSkills({ query: trimmed }) : Promise.reject(new Error('Skill search disabled')),\n ]);\n\n if (files.status === 'rejected' && skills.status === 'rejected') {\n throw (searchFiles ? files : skills).reason;\n }\n\n const hits = new Map<string, WorkspaceSearchHit>();\n const add = (hit: WorkspaceSearchHit) => {\n const existing = hits.get(hit.path);\n if (!existing || existing.score < hit.score) hits.set(hit.path, hit);\n };\n\n if (files.status === 'fulfilled') {\n for (const result of files.value.results) {\n const path = filePathFromId(result.id);\n add({ kind: 'file', path, label: basename(path), score: result.score });\n }\n }\n if (skills.status === 'fulfilled') {\n for (const result of skills.value.results) {\n add({\n kind: 'skill',\n path: skillFilePath(result),\n label: result.skillName,\n score: result.score,\n });\n }\n }\n\n return [...hits.values()].sort((a, b) => b.score - a.score);\n },\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport { isWorkspaceV1Supported, shouldRetryWorkspaceQuery } from './compatibility';\nimport type { Skill, ListSkillsResponse } from './types';\n\n// =============================================================================\n// Skills Hooks (via Workspace API)\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceSkills = <TData = ListSkillsResponse>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<ListSkillsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListSkillsResponse, Error, TData>({\n queryKey: ['workspace', 'skills', workspaceId],\n queryFn: async (): Promise<ListSkillsResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.listSkills();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\n// =============================================================================\n// Agent-Specific Skill Hook\n// =============================================================================\n\n/**\n * Hook to get a specific skill from an agent's workspace\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentSkill = <TData = Skill>({\n agentId,\n skillName,\n workspaceId,\n path,\n queryOptions,\n}: {\n agentId: string;\n skillName: string;\n workspaceId?: string;\n path?: string;\n queryOptions?: MastraQueryOptions<Skill, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<Skill, Error, TData>({\n queryKey: ['agents', agentId, 'skills', skillName, path, workspaceId],\n queryFn: async (): Promise<Skill> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n const skill = workspace.getSkill(skillName, path);\n return skill.details();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n"],"mappings":";;;;;;;;;AAGA,SAAgB,UAAa,KAAQ,QAAyB;CAC5D,OAAO,UAAW,OAAkB,OAAQ,IAAgC,YAAY;AAC1F;;;;;;;ACIA,MAAa,0BAA0B,WAAyB;CAC9D,MAAM,yBAAyB,CAAC,kBAAkB,cAAc;CAEhE,MAAM,g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cAAc,WAAW;CACvE,CAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["coreFeatures","isNonRetryableError","useMastraClient","useMutation","useQuery","useQueryClient","useMastraClient","useQuery","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQuery"],"sources":["../../../src/hooks/workspace/client-utils.ts","../../../src/hooks/workspace/compatibility.ts","../../../src/hooks/workspace/file-type.ts","../../../src/hooks/workspace/use-skills-sh.ts","../../../src/hooks/workspace/use-stored-workspaces.ts","../../../src/hooks/workspace/use-workspace.ts","../../../src/hooks/workspace/use-workspace-directory.ts","../../../src/hooks/workspace/use-workspace-file-content.ts","../../../src/hooks/workspace/use-workspace-search.ts","../../../src/hooks/workspace/use-workspace-skills.ts"],"sourcesContent":["/**\n * Checks if a method exists on an object and is callable.\n */\nexport function hasMethod<T>(obj: T, method: string): boolean {\n return method in (obj as object) && typeof (obj as Record<string, unknown>)[method] === 'function';\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport { coreFeatures } from '@mastra/core/features';\nimport { isNonRetryableError } from '../query/query-utils';\nimport { hasMethod } from './client-utils';\n\n/**\n * Checks if workspace v1 features are supported by both core and client.\n * This guards against version mismatches between playground-ui, core, and client-js.\n */\nexport const isWorkspaceV1Supported = (client: MastraClient) => {\n const workspaceClientMethods = ['listWorkspaces', 'getWorkspace'];\n\n const coreSupported = coreFeatures.has('workspaces-v1');\n const clientSupported = workspaceClientMethods.every(method => hasMethod(client, method));\n\n return coreSupported && clientSupported;\n};\n\n/**\n * Gets the HTTP status code from an error if present.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst getStatusCode = (error: unknown): number | undefined => {\n if (!error || typeof error !== 'object') return undefined;\n\n // Check for status property (MastraClientError, fetch Response, etc.)\n if ('status' in error && typeof (error as { status: unknown }).status === 'number') {\n return (error as { status: number }).status;\n }\n\n // Check for statusCode property (from some HTTP clients)\n if ('statusCode' in error && typeof (error as { statusCode: unknown }).statusCode === 'number') {\n return (error as { statusCode: number }).statusCode;\n }\n\n return undefined;\n};\n\n/**\n * Checks if an error has a specific HTTP status code.\n * Supports MastraClientError, fetch Response, and other HTTP client error formats.\n */\nconst hasStatusCode = (error: unknown, statusCode: number): boolean => {\n return getStatusCode(error) === statusCode;\n};\n\n/**\n * Checks if an error is a 4xx client error (e.g., 400, 401, 403, 404).\n * Client errors won't resolve with retries.\n */\nconst isClientError = (error: unknown): boolean => {\n const status = getStatusCode(error);\n return status !== undefined && status >= 400 && status < 500;\n};\n\n/**\n * Checks if an error is a \"Not Implemented\" (501) error from the server.\n * This indicates the server's @mastra/core version doesn't support workspaces.\n */\nexport const isWorkspaceNotSupportedError = (error: unknown): boolean => {\n if (hasStatusCode(error, 501)) {\n return true;\n }\n\n // Check error message for our specific error\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('Workspace v1 not supported') || message.includes('501');\n }\n\n return false;\n};\n\n/**\n * Checks if an error is a \"Not Found\" (404) error from the server.\n * This indicates the requested resource doesn't exist (e.g., file not found).\n */\nexport const isNotFoundError = (error: unknown): boolean => {\n if (hasStatusCode(error, 404)) {\n return true;\n }\n\n // Check error message for status code (client-js throws Error with message like \"HTTP error! status: 404 - ...\")\n if (error && typeof error === 'object' && 'message' in error) {\n const message = (error as { message: string }).message;\n return message.includes('status: 404');\n }\n\n return false;\n};\n\n/**\n * React Query retry function that doesn't retry on client errors (4xx) or 501 errors.\n * Use this to prevent infinite retries when resources don't exist, access is denied, or workspaces aren't supported.\n */\nexport const shouldRetryWorkspaceQuery = (failureCount: number, error: Error): boolean => {\n // Don't retry 4xx client errors (400, 401, 403, 404, etc.) - these won't resolve with retries\n if (isClientError(error)) {\n return false;\n }\n // Don't retry 501 \"Not Implemented\" errors - they won't resolve with retries\n if (isWorkspaceNotSupportedError(error)) {\n return false;\n }\n // Don't retry 4xx client errors (400, 401, 403, 404)\n if (isNonRetryableError(error)) {\n return false;\n }\n // Default retry behavior: retry up to 3 times\n return failureCount < 3;\n};\n","const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'bmp', 'avif', 'tiff', 'tif'];\nconst VIDEO_MIME_TYPES: Record<string, string> = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n mov: 'video/quicktime',\n m4v: 'video/mp4',\n ogv: 'video/ogg',\n};\n\nconst extension = (path: string) => path.split('/').pop()?.split('.').pop()?.toLowerCase() ?? '';\n\nexport const isImageFile = (path: string, mimeType?: string) =>\n mimeType?.startsWith('image/') || IMAGE_EXTENSIONS.includes(extension(path));\n\nexport const isVideoFile = (path: string, mimeType?: string) =>\n mimeType?.startsWith('video/') || extension(path) in VIDEO_MIME_TYPES;\n\n/** Media must be read as base64: reading it as utf-8 corrupts the bytes. */\nexport const isMediaFile = (path: string) => isImageFile(path) || isVideoFile(path);\n\nexport const videoMimeType = (path: string, mimeType?: string) =>\n mimeType?.startsWith('video/') ? mimeType : (VIDEO_MIME_TYPES[extension(path)] ?? 'video/mp4');\n\nexport const isMarkdownFile = (path: string) => /\\.mdx?$/i.test(path);\n","import type { MastraClient, SkillsShSkill } from '@mastra/client-js';\nimport type { UseMutationResult, UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { SkillsShSkill };\n\ntype SearchSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['searchSkillsSh']>>;\ntype PopularSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['listPopularSkillsSh']>>;\ntype InstallSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['installSkillsSh']>>;\ntype UpdateSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['updateSkillsSh']>>;\ntype RemoveSkillsShResponse = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['removeSkillsSh']>>;\n\n/**\n * Search skills on skills.sh (via server proxy)\n */\nexport const useSearchSkillsSh = ({\n workspaceId,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n queryOptions?: MastraMutationOptions<SearchSkillsShResponse, string>;\n}): UseMutationResult<SearchSkillsShResponse, Error, string> => {\n const client = useMastraClient();\n\n return useMutation<SearchSkillsShResponse, Error, string>({\n mutationFn: (query: string) => {\n if (!workspaceId) throw new Error('Workspace ID is required');\n return client.getWorkspace(workspaceId).searchSkillsSh({ q: query, limit: 10 });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Get popular skills from skills.sh (via server proxy, cached for 5 minutes)\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePopularSkillsSh = <TData = PopularSkillsShResponse>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n queryOptions?: MastraQueryOptions<PopularSkillsShResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PopularSkillsShResponse, Error, TData>({\n queryKey: ['skills-sh', 'popular', workspaceId],\n queryFn: () => {\n if (!workspaceId) throw new Error('Workspace ID is required');\n return client.getWorkspace(workspaceId).listPopularSkillsSh({ limit: 10, offset: 0 });\n },\n staleTime: 5 * 60 * 1000,\n ...queryOptions,\n });\n};\n\n/**\n * Preview a skill by fetching its SKILL.md (via server proxy to avoid CORS)\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSkillPreview = <TData = string>({\n workspaceId,\n owner,\n repo,\n skillPath,\n queryOptions,\n}: {\n workspaceId: string | undefined;\n owner: string | undefined;\n repo: string | undefined;\n skillPath: string | undefined;\n queryOptions?: MastraQueryOptions<string, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<string, Error, TData>({\n queryKey: ['skills-sh', 'preview', workspaceId, owner, repo, skillPath],\n queryFn: async () => {\n if (!workspaceId || !owner || !repo || !skillPath) {\n throw new Error('workspaceId, owner, repo, and skillPath are required');\n }\n const { content } = await client.getWorkspace(workspaceId).previewSkillsSh({ owner, repo, path: skillPath });\n return content;\n },\n retry: false,\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Helper: Parse skills.sh skill ID to repository info\n// =============================================================================\n\n/**\n * Parse a skill's topSource field to extract GitHub repository info\n *\n * skills.sh topSource formats:\n * - \"owner/repo\" (e.g., \"vercel-labs/agent-skills\")\n * - \"owner/repo/path\" (e.g., \"anthropics/skills/frontend-design\")\n * - \"github.com/owner/repo/path\" (full URL format)\n *\n * The skill name is used as the path within the repo when not specified\n */\nexport function parseSkillSource(\n topSource: string,\n skillName?: string,\n): {\n owner: string;\n repo: string;\n skillPath: string;\n} | null {\n // Remove protocol and github.com prefix if present\n let cleanSource = topSource.replace(/^https?:\\/\\//, '');\n cleanSource = cleanSource.replace(/^github\\.com\\//, '');\n // Remove trailing slash if present\n cleanSource = cleanSource.replace(/\\/$/, '');\n\n const parts = cleanSource.split('/').filter(Boolean);\n const [owner, repo] = parts;\n\n if (!owner || !repo) {\n return null;\n }\n\n // If there's a path in topSource, use it; otherwise use skill name\n let skillPath: string;\n if (parts.length > 2) {\n // Path is specified in topSource (e.g., \"anthropics/skills/frontend-design\")\n skillPath = parts.slice(2).join('/');\n } else if (skillName) {\n // No path in topSource, use skill name (e.g., for \"vercel-labs/agent-skills\" + skill \"web-design-guidelines\")\n skillPath = skillName;\n } else {\n return null;\n }\n\n return {\n owner,\n repo,\n skillPath,\n };\n}\n\n// =============================================================================\n// Skill Management Hooks (via server proxy)\n// =============================================================================\n\nexport interface InstallSkillParams {\n workspaceId: string;\n /** Repository in format owner/repo */\n repository: string;\n /** Skill name within the repo */\n skillName: string;\n /** Mount path to install into (for CompositeFilesystem) */\n mount?: string;\n}\n\n/**\n * Install a skill by fetching from GitHub and writing to workspace filesystem.\n */\nexport const useInstallSkill = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<InstallSkillsShResponse, InstallSkillParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: InstallSkillParams) => {\n const [owner, repo] = params.repository.split('/');\n if (!owner || !repo) {\n throw new Error('Invalid repository format. Expected owner/repo');\n }\n return client\n .getWorkspace(params.workspaceId)\n .installSkillsSh({ owner, repo, skillName: params.skillName, mount: params.mount });\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n\nexport interface UpdateSkillsParams {\n workspaceId: string;\n skillName?: string;\n}\n\n/**\n * Update installed skills by re-fetching from GitHub.\n */\nexport const useUpdateSkills = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<UpdateSkillsShResponse, UpdateSkillsParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: UpdateSkillsParams) =>\n client.getWorkspace(params.workspaceId).updateSkillsSh({ skillName: params.skillName }),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n\nexport interface RemoveSkillParams {\n workspaceId: string;\n skillName: string;\n}\n\n/**\n * Remove an installed skill by deleting its directory.\n */\nexport const useRemoveSkill = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<RemoveSkillsShResponse, RemoveSkillParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: (params: RemoveSkillParams) =>\n client.getWorkspace(params.workspaceId).removeSkillsSh({ skillName: params.skillName }),\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'skills', variables.workspaceId] });\n },\n ...queryOptions,\n });\n};\n","import type { ListStoredWorkspacesParams, ListStoredWorkspacesResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\n/**\n * Hook to list stored workspaces from the database.\n * These are workspaces that have been persisted via the stored workspaces API,\n * as opposed to runtime-registered workspaces from code-defined agents.\n */\nexport const useStoredWorkspaces = <TData = ListStoredWorkspacesResponse>({\n queryOptions,\n ...params\n}: ListStoredWorkspacesParams & {\n queryOptions?: MastraQueryOptions<ListStoredWorkspacesResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredWorkspacesResponse, Error, TData>({\n queryKey: ['stored-workspaces', params],\n queryFn: async (): Promise<ListStoredWorkspacesResponse> => {\n return client.listStoredWorkspaces(params);\n },\n ...queryOptions,\n });\n};\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\nimport { isWorkspaceV1Supported, shouldRetryWorkspaceQuery, isWorkspaceNotSupportedError } from './compatibility';\nimport type {\n WorkspaceInfo,\n WorkspacesListResponse,\n FileStatResponse,\n WriteFileParams,\n WriteFileFromFileParams,\n} from './types';\n\nexport type DeleteWorkspaceFileParams = { path: string; recursive?: boolean; force?: boolean; workspaceId?: string };\nexport type CreateWorkspaceDirectoryParams = { path: string; recursive?: boolean; workspaceId?: string };\nexport type IndexWorkspaceContentParams = {\n workspaceId: string;\n path: string;\n content: string;\n metadata?: Record<string, unknown>;\n};\n\nfunction getParentPath(path: string): string {\n return path.split('/').slice(0, -1).join('/') || (path.startsWith('/') ? '/' : '.');\n}\n\n// Re-export for other hooks to use\nexport { isWorkspaceV1Supported, isWorkspaceNotSupportedError };\n\n// =============================================================================\n// Workspace Info Hook\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceInfo = <TData = WorkspaceInfo>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<WorkspaceInfo, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<WorkspaceInfo, Error, TData>({\n queryKey: ['workspace', 'info', workspaceId],\n queryFn: async (): Promise<WorkspaceInfo> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.info();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\n// =============================================================================\n// List All Workspaces Hook\n// =============================================================================\n\nexport const useWorkspaces = <TData = WorkspacesListResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<WorkspacesListResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<WorkspacesListResponse, Error, TData>({\n queryKey: ['workspaces'],\n queryFn: async (): Promise<WorkspacesListResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n return (client as any).listWorkspaces();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Filesystem Hooks\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceFileStat = <TData = FileStatResponse>({\n path,\n workspaceId,\n queryOptions,\n}: {\n path: string;\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<FileStatResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<FileStatResponse, Error, TData>({\n queryKey: ['workspace', 'stat', path, workspaceId],\n queryFn: async (): Promise<FileStatResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.stat(path);\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\nexport const useWriteWorkspaceFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, WriteFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, WriteFileParams>({\n mutationFn: async (params: WriteFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.writeFile(params.path, params.content, {\n encoding: params.encoding,\n recursive: params.recursive ?? true,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useWriteWorkspaceFileFromFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, WriteFileFromFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, WriteFileFromFileParams>({\n mutationFn: async (params: WriteFileFromFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n // Convert file to base64\n const arrayBuffer = await params.file.arrayBuffer();\n const base64 = btoa(new Uint8Array(arrayBuffer).reduce((data, byte) => data + String.fromCharCode(byte), ''));\n\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.writeFile(params.path, base64, {\n encoding: 'base64',\n recursive: params.recursive ?? true,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useDeleteWorkspaceFile = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, DeleteWorkspaceFileParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, DeleteWorkspaceFileParams>({\n mutationFn: async (params: DeleteWorkspaceFileParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.delete(params.path, {\n recursive: params.recursive,\n force: params.force,\n });\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'file', variables.path] });\n },\n ...queryOptions,\n });\n};\n\nexport const useCreateWorkspaceDirectory = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, CreateWorkspaceDirectoryParams> } = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<unknown, Error, CreateWorkspaceDirectoryParams>({\n mutationFn: async (params: CreateWorkspaceDirectoryParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.mkdir(params.path, params.recursive);\n },\n onSuccess: (_, variables) => {\n const parentPath = getParentPath(variables.path);\n void queryClient.invalidateQueries({ queryKey: ['workspace', 'files', parentPath] });\n },\n ...queryOptions,\n });\n};\n\n// =============================================================================\n// Search Hooks\n// =============================================================================\n\nexport const useIndexWorkspaceContent = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<unknown, IndexWorkspaceContentParams> } = {}) => {\n const client = useMastraClient();\n\n return useMutation<unknown, Error, IndexWorkspaceContentParams>({\n mutationFn: async (params: IndexWorkspaceContentParams) => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n const workspace = (client as any).getWorkspace(params.workspaceId);\n return workspace.index({\n path: params.path,\n content: params.content,\n metadata: params.metadata,\n });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport const WORKSPACE_REFETCH_INTERVAL = 10_000;\n\n/** Lists a single directory level and polls it. Callers enable it only once the folder is expanded. */\ntype WorkspaceDirectoryEntries = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['listFiles']>>['entries'];\n\nexport function useWorkspaceDirectory<TData = WorkspaceDirectoryEntries>({\n workspaceId,\n path,\n queryOptions,\n}: {\n workspaceId: string;\n path: string;\n queryOptions?: MastraQueryOptions<WorkspaceDirectoryEntries, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery<WorkspaceDirectoryEntries, Error, TData>({\n queryKey: ['workspace', workspaceId, 'fs', 'list', path],\n queryFn: async () => (await client.getWorkspace(workspaceId).listFiles(path, false)).entries,\n refetchInterval: WORKSPACE_REFETCH_INTERVAL,\n ...queryOptions,\n });\n}\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport { isMediaFile } from './file-type';\nimport { WORKSPACE_REFETCH_INTERVAL } from './use-workspace-directory';\n\n/** Reads a file (base64 for images/videos) and polls it so the viewer follows external edits. */\ntype WorkspaceFileContent = Awaited<ReturnType<ReturnType<MastraClient['getWorkspace']>['readFile']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkspaceFileContent<TData = WorkspaceFileContent>({\n workspaceId,\n path,\n queryOptions,\n}: {\n workspaceId: string;\n path?: string;\n queryOptions?: MastraQueryOptions<WorkspaceFileContent, TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const encoding = path && isMediaFile(path) ? 'base64' : undefined;\n\n return useQuery<WorkspaceFileContent, Error, TData>({\n queryKey: ['workspace', workspaceId, 'fs', 'read', path, encoding],\n queryFn: () => client.getWorkspace(workspaceId).readFile(path ?? '', encoding),\n refetchInterval: WORKSPACE_REFETCH_INTERVAL,\n ...queryOptions,\n });\n}\n","import type { SkillSearchResult } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface WorkspaceSearchHit {\n kind: 'file' | 'skill';\n path: string;\n label: string;\n score: number;\n}\n\n// Chunked files are indexed as `<path>#chunk-<n>`.\nconst filePathFromId = (id: string) => id.replace(/#chunk-\\d+$/, '');\n\nconst basename = (path: string) => path.split('/').filter(Boolean).pop() ?? path;\n\n// The server returns `skillPath`, which the client type does not declare yet.\nconst skillFilePath = (result: SkillSearchResult & { skillPath?: string }) =>\n result.skillPath ? `${result.skillPath.replace(/\\/$/, '')}/SKILL.md` : result.source;\n\n/** Searches files and skills in parallel; one failing source (e.g. 501 not configured) keeps the other's hits. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport function useWorkspaceSearch<TData = WorkspaceSearchHit[]>({\n workspaceId,\n query,\n files: searchFiles = true,\n skills: searchSkills = true,\n queryOptions,\n}: {\n workspaceId: string;\n query: string;\n files?: boolean;\n skills?: boolean;\n queryOptions?: MastraQueryOptions<WorkspaceSearchHit[], TData>;\n}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n const trimmed = query.trim();\n\n return useQuery<WorkspaceSearchHit[], Error, TData>({\n queryKey: ['workspace', workspaceId, 'search', trimmed, searchFiles, searchSkills],\n queryFn: async () => {\n const workspace = client.getWorkspace(workspaceId);\n const [files, skills] = await Promise.allSettled([\n searchFiles ? workspace.search({ query: trimmed }) : Promise.reject(new Error('File search disabled')),\n searchSkills ? workspace.searchSkills({ query: trimmed }) : Promise.reject(new Error('Skill search disabled')),\n ]);\n\n if (files.status === 'rejected' && skills.status === 'rejected') {\n throw (searchFiles ? files : skills).reason;\n }\n\n const hits = new Map<string, WorkspaceSearchHit>();\n const add = (hit: WorkspaceSearchHit) => {\n const existing = hits.get(hit.path);\n if (!existing || existing.score < hit.score) hits.set(hit.path, hit);\n };\n\n if (files.status === 'fulfilled') {\n for (const result of files.value.results) {\n const path = filePathFromId(result.id);\n add({ kind: 'file', path, label: basename(path), score: result.score });\n }\n }\n if (skills.status === 'fulfilled') {\n for (const result of skills.value.results) {\n add({\n kind: 'skill',\n path: skillFilePath(result),\n label: result.skillName,\n score: result.score,\n });\n }\n }\n\n return [...hits.values()].sort((a, b) => b.score - a.score);\n },\n ...queryOptions,\n });\n}\n","import type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport { isWorkspaceV1Supported, shouldRetryWorkspaceQuery } from './compatibility';\nimport type { Skill, ListSkillsResponse } from './types';\n\n// =============================================================================\n// Skills Hooks (via Workspace API)\n// =============================================================================\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useWorkspaceSkills = <TData = ListSkillsResponse>({\n workspaceId,\n queryOptions,\n}: {\n workspaceId?: string;\n queryOptions?: MastraQueryOptions<ListSkillsResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListSkillsResponse, Error, TData>({\n queryKey: ['workspace', 'skills', workspaceId],\n queryFn: async (): Promise<ListSkillsResponse> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n return workspace.listSkills();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n\n// =============================================================================\n// Agent-Specific Skill Hook\n// =============================================================================\n\n/**\n * Hook to get a specific skill from an agent's workspace\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useAgentSkill = <TData = Skill>({\n agentId,\n skillName,\n workspaceId,\n path,\n queryOptions,\n}: {\n agentId: string;\n skillName: string;\n workspaceId?: string;\n path?: string;\n queryOptions?: MastraQueryOptions<Skill, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<Skill, Error, TData>({\n queryKey: ['agents', agentId, 'skills', skillName, path, workspaceId],\n queryFn: async (): Promise<Skill> => {\n if (!isWorkspaceV1Supported(client)) {\n throw new Error('Workspace v1 not supported by core or client');\n }\n if (!workspaceId) {\n throw new Error('workspaceId is required');\n }\n const workspace = (client as any).getWorkspace(workspaceId);\n const skill = workspace.getSkill(skillName, path);\n return skill.details();\n },\n retry: shouldRetryWorkspaceQuery,\n ...queryOptions,\n enabled: isWorkspaceV1Supported(client) && (queryOptions?.enabled ?? true),\n });\n};\n"],"mappings":";;;;;;;;;AAGA,SAAgB,UAAa,KAAQ,QAAyB;CAC5D,OAAO,UAAW,OAAkB,OAAQ,IAAgC,YAAY;AAC1F;;;;;;ACIA,MAAa,0BAA0B,WAAyB;CAC9D,MAAM,yBAAyB,CAAC,kBAAkB,cAAc;CAEhE,MAAM,gBAAgBA,sBAAAA,aAAa,IAAI,eAAe;CACtD,MAAM,kBAAkB,uBAAuB,OAAM,WAAU,UAAU,QAAQ,MAAM,CAAC;CAExF,OAAO,iBAAiB;AAC1B;;;;;AAMA,MAAM,iBAAiB,UAAuC;CAC5D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO,KAAA;CAGh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