@mastra/react 1.12.0-alpha.10 → 1.12.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accumulator-C8kIc450.js → accumulator-BfvVnXJr.js} +1 -2
- package/dist/{accumulator-C8kIc450.js.map → accumulator-BfvVnXJr.js.map} +1 -1
- package/dist/{accumulator-BQGsraqS.cjs → accumulator-CgLQ_3q3.cjs} +1 -2
- package/dist/{accumulator-BQGsraqS.cjs.map → accumulator-CgLQ_3q3.cjs.map} +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -2
- package/dist/combine-by-ids-D_lp6Dvq.cjs.map +1 -1
- package/dist/hooks/agents/index.cjs +2 -2
- package/dist/hooks/agents/index.cjs.map +1 -1
- package/dist/hooks/agents/index.js +2 -2
- package/dist/hooks/agents/index.js.map +1 -1
- package/dist/hooks/auth/index.cjs +2 -2
- package/dist/hooks/auth/index.cjs.map +1 -1
- package/dist/hooks/auth/index.js +2 -2
- package/dist/hooks/auth/index.js.map +1 -1
- package/dist/hooks/capabilities/index.cjs +1 -1
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.js +1 -1
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/configuration/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.cjs +1 -1
- package/dist/hooks/datasets/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.js +1 -1
- package/dist/hooks/datasets/index.js.map +1 -1
- package/dist/hooks/embedders/index.cjs.map +1 -1
- package/dist/hooks/experiments/index.cjs.map +1 -1
- package/dist/hooks/feedback/index.cjs.map +1 -1
- package/dist/hooks/llm/index.cjs.map +1 -1
- package/dist/hooks/logs/index.cjs.map +1 -1
- package/dist/hooks/mcps/index.cjs.map +1 -1
- package/dist/hooks/memory/index.cjs +10 -10
- package/dist/hooks/memory/index.cjs.map +1 -1
- package/dist/hooks/memory/index.js +10 -10
- package/dist/hooks/memory/index.js.map +1 -1
- package/dist/hooks/metrics/index.cjs +13 -11
- package/dist/hooks/metrics/index.cjs.map +1 -1
- package/dist/hooks/metrics/index.js +13 -11
- package/dist/hooks/metrics/index.js.map +1 -1
- package/dist/hooks/processors/index.cjs.map +1 -1
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
- package/dist/hooks/query/index.cjs.map +1 -1
- package/dist/hooks/review/index.cjs.map +1 -1
- package/dist/hooks/schedules/index.cjs.map +1 -1
- package/dist/hooks/scores/index.cjs.map +1 -1
- package/dist/hooks/templates/index.cjs +20 -18
- package/dist/hooks/templates/index.cjs.map +1 -1
- package/dist/hooks/templates/index.js +20 -18
- package/dist/hooks/templates/index.js.map +1 -1
- package/dist/hooks/tool-providers/index.cjs +1 -1
- package/dist/hooks/tool-providers/index.cjs.map +1 -1
- package/dist/hooks/tool-providers/index.js +1 -1
- package/dist/hooks/tool-providers/index.js.map +1 -1
- package/dist/hooks/tools/index.cjs.map +1 -1
- package/dist/hooks/traces/index.cjs +4 -4
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.js +4 -4
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/vectors/index.cjs.map +1 -1
- package/dist/hooks/voice/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.cjs +1 -1
- package/dist/hooks/workflows/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.js +1 -1
- package/dist/hooks/workspace/index.cjs +1 -1
- package/dist/hooks/workspace/index.cjs.map +1 -1
- package/dist/hooks/workspace/index.js +1 -1
- package/dist/hooks/workspace/index.js.map +1 -1
- package/dist/{hooks-CIutb3DO.cjs → hooks-B1i-oHae.cjs} +6 -4
- package/dist/hooks-B1i-oHae.cjs.map +1 -0
- package/dist/{hooks-FVbeHlov.js → hooks-CLfMO5cH.js} +6 -4
- package/dist/{hooks-FVbeHlov.js.map → hooks-CLfMO5cH.js.map} +1 -1
- package/dist/{hooks-_YevKidX.cjs → hooks-D8nOYPUd.cjs} +2 -2
- package/dist/hooks-D8nOYPUd.cjs.map +1 -0
- package/dist/{hooks-0L0RNfau.js → hooks-NaZLZreZ.js} +2 -2
- package/dist/{hooks-0L0RNfau.js.map → hooks-NaZLZreZ.js.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -1
- package/dist/ui/index.cjs +4 -4
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -1
- package/dist/voice-BOtUdMi8.cjs.map +1 -1
- package/package.json +4 -4
- package/dist/hooks-CIutb3DO.cjs.map +0 -1
- package/dist/hooks-_YevKidX.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["coreFeatures","isNonRetryableError","useMastraClient","useMastraClient","useMastraClient","useMastraClient","useMastraClient","useMastraClient","useMastraClient"],"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) && (que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AAyB;GAI3C,OAFmB,OAAe,aAAa,WACzB,CAAC,CAAC,SAAS,WAAW,IACjC,CAAC,CAAC,QAAQ;EACvB;EACA,OAAO;EACP,GAAG;EACH,SAAS,uBAAuB,MAAM,MAAM,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,OA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"version":3,"file":"index.js","names":[],"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,gBAAgB,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;CAGhD,IAAI,YAAY,SAAS,OAAQ,MAA8B,WAAW,UACxE,OAAQ,MAA6B;CAIvC,IAAI,gBAAgB,SAAS,OAAQ,MAAkC,eAAe,UACpF,OAAQ,MAAiC;AAI7C;;;;;AAMA,MAAM,iBAAiB,OAAgB,eAAgC;CACrE,OAAO,cAAc,KAA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AS,uBAAuB,MAAM,MAAM,cAAc,WAAW;CACvE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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,gBAAgB,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;CAGhD,IAAI,YAAY,SAAS,OAAQ,MAA8B,WAAW,UACxE,OAAQ,MAA6B;CAIvC,IAAI,gBAAgB,SAAS,OAAQ,MAAkC,eAAe,UACpF,OAAQ,MAAiC;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,IACjC,CAAC,CAAC,QAAQ;EACvB;EACA,OAAO;EACP,GAAG;EACH,SAAS,uBAAuB,MAAM,MAAM,cAAc,WAAW;CACvE,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_mastra_client_context = require("./mastra-client-context-DzX3f0RF.cjs");
|
|
2
|
-
const require_accumulator = require("./accumulator-
|
|
2
|
+
const require_accumulator = require("./accumulator-CgLQ_3q3.cjs");
|
|
3
3
|
let _mastra_client_js = require("@mastra/client-js");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _lukeed_uuid = require("@lukeed/uuid");
|
|
@@ -779,8 +779,10 @@ const useChat = ({ agentId, resourceId, threadId, initialMessages, requestContex
|
|
|
779
779
|
_streamAbortRef.current?.abort();
|
|
780
780
|
const internalAbort = new AbortController();
|
|
781
781
|
_streamAbortRef.current = internalAbort;
|
|
782
|
-
if (signal)
|
|
783
|
-
|
|
782
|
+
if (signal) {
|
|
783
|
+
if (signal.aborted) internalAbort.abort();
|
|
784
|
+
else signal.addEventListener("abort", () => internalAbort.abort(), { once: true });
|
|
785
|
+
}
|
|
784
786
|
const agent = new _mastra_client_js.MastraClient({
|
|
785
787
|
...baseClient.options,
|
|
786
788
|
abortSignal: internalAbort.signal
|
|
@@ -1281,4 +1283,4 @@ Object.defineProperty(exports, "useChat", {
|
|
|
1281
1283
|
}
|
|
1282
1284
|
});
|
|
1283
1285
|
|
|
1284
|
-
//# sourceMappingURL=hooks-
|
|
1286
|
+
//# sourceMappingURL=hooks-B1i-oHae.cjs.map
|