{"version":3,"sources":["../src/server/schemas/builder-registry.ts","../src/server/handlers/builder-registry.ts"],"names":["z","HTTPException","assertSafeFilePath","createRoute","handleError","skillsShSearchResponseSchema","searchSkillsSh","skillsShListResponseSchema","getPopularSkillsSh","skillsShPreviewResponseSchema","previewSkillsSh","fetchSkillFiles","assertSafeSkillName","toSlug","getCallerAuthorId"],"mappings":";;;;;;;;;;;AAuBO,IAAM,0BAAA,GAA6BA,KAAE,MAAA,CAAO;AAAA,EACjD,IAAIA,IAAA,CAAE,OAAA,CAAQ,WAAW,CAAA,CAAE,SAAS,4BAA4B,CAAA;AAAA,EAChE,OAAA,EAASA,IAAA,CAAE,OAAA,EAAQ,CAAE,SAAS,4DAA4D,CAAA;AAAA,EAC1F,KAAA,EAAOA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,8BAA8B;AAC3D,CAAC,CAAA;AAGM,IAAM,+BAAA,GAAkCA,KAAE,MAAA,CAAO;AAAA,EACtD,UAAA,EAAYA,IAAA,CAAE,KAAA,CAAM,0BAA0B;AAChD,CAAC,CAAA;AAOM,IAAM,yBAAA,GAA4BA,KAAE,MAAA,CAAO;AAAA,EAChD,UAAA,EAAYA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,wCAAwC;AAC1E,CAAC,CAAA;AAEM,IAAM,gCAAA,GAAmCA,KAAE,MAAA,CAAO;AAAA,EACvD,CAAA,EAAGA,IAAA,CAAE,MAAA,EAAO,CAAE,SAAS,cAAc,CAAA;AAAA,EACrC,OAAOA,IAAA,CAAE,MAAA,CAAO,QAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CAAC,EAAE,GAAA,CAAI,GAAG,EAAE,QAAA,EAAS,CAAE,QAAQ,EAAE,CAAA,CAAE,SAAS,mCAAmC;AACpH,CAAC,CAAA;AAEM,IAAM,iCAAA,GAAoCA,KAC9C,MAAA,CAAO;AAAA,EACN,OAAOA,IAAA,CAAE,MAAA,CAAO,QAAO,CAAE,GAAA,GAAM,GAAA,CAAI,CA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A,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-7FIDKZUG.cjs","sourcesContent":["/**\n * Builder Registry Schemas\n *\n * Schemas for the Agent Builder skill registry routes. These are distinct from\n * the workspace skills.sh proxy schemas because:\n * - Builder routes are not scoped to a workspace.\n * - Builder install does not accept a `mount` field.\n * - Builder install body carries visibility + the resolved registry id.\n * - Builder install response returns the created stored skill id.\n *\n * The upstream skills.sh proxy response shapes are reused via the shared\n * `skillsShSearchResponseSchema`, `skillsShListResponseSchema`, and\n * `skillsShPreviewResponseSchema` since the wire shape from skills.sh is\n * registry-independent.\n */\n\nimport { z } from 'zod/v4';\n\n// =============================================================================\n// Registry list\n// =============================================================================\n\n/** Single entry in the registries list. */\nexport const builderRegistryEntrySchema = z.object({\n id: z.literal('skills-sh').describe('Stable registry identifier'),\n enabled: z.boolean().describe('Whether this registry is enabled in the running deployment'),\n label: z.string().describe('Human-readable registry name'),\n});\n\n/** Response for `GET /editor/builder/registries`. */\nexport const builderRegistriesResponseSchema = z.object({\n registries: z.array(builderRegistryEntrySchema),\n});\n\n// =============================================================================\n// Search / popular / preview\n// =============================================================================\n\n/** Path params used by every per-registry route. */\nexport const builderRegistryPathParams = z.object({\n registryId: z.string().describe('Registry identifier (e.g. \"skills-sh\")'),\n});\n\nexport const builderRegistrySearchQuerySchema = z.object({\n q: z.string().describe('Search query'),\n limit: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Maximum number of results (1-100)'),\n});\n\nexport const builderRegistryPopularQuerySchema = z\n .object({\n limit: z.coerce.number().int().min(1).max(100).optional().default(10).describe('Maximum number of results (1-100)'),\n offset: z.coerce\n .number()\n .int()\n .min(0)\n .optional()\n .default(0)\n .describe('Offset for pagination (must be a multiple of `limit`)'),\n })\n .refine(args => args.offset % args.limit === 0, {\n message: 'offset must be a multiple of limit (the upstream registry pages by `limit`)',\n path: ['offset'],\n });\n\nexport const builderRegistryPreviewQuerySchema = z.object({\n owner: z.string().describe('GitHub repository owner'),\n repo: z.string().describe('GitHub repository name'),\n path: z.string().describe('Skill name within repo'),\n});\n\n// =============================================================================\n// Install\n// =============================================================================\n\n/**\n * Body for `POST /editor/builder/registries/:registryId/install`.\n *\n * Visibility behaves like the standard stored-skill create flow: optional,\n * defaults to private when the caller is authenticated.\n */\nexport const builderRegistryInstallBodySchema = z.object({\n owner: z.string().describe('GitHub repository owner'),\n repo: z.string().describe('GitHub repository name'),\n skillName: z.string().describe('Skill name from the registry'),\n visibility: z.enum(['private', 'public']).optional().describe('Visibility for the new stored skill'),\n});\n\n/** Response for the install route. Mirrors stored-skill identity fields. */\nexport const builderRegistryInstallResponseSchema = z.object({\n storedSkillId: z.string().describe('Id of the newly created stored skill'),\n name: z.string().describe('Resolved skill name'),\n filesWritten: z.number().describe('Number of files materialized into the skill version snapshot'),\n});\n\nexport type BuilderRegistryEntry = z.infer;\nexport type BuilderRegistriesResponse = z.infer;\nexport type BuilderRegistryInstallBody = z.infer;\nexport type BuilderRegistryInstallResponse = z.infer;\n","/**\n * Builder Registry Handlers\n *\n * Routes that let admins browse and install skills from configured external\n * registries (currently just skills.sh) directly into the Builder's stored\n * skills DB. Distinct from the workspace skills.sh routes, which write to a\n * workspace filesystem and never touch storage.\n *\n * Registry availability is driven by `AgentBuilderOptions.registries`. When\n * the requested registry is disabled (or the builder is missing entirely),\n * the routes 404 instead of leaking the surface.\n */\n\nimport type { Mastra } from '@mastra/core';\nimport type { StorageSkillFileNode } from '@mastra/core/storage';\n\nimport { HTTPException } from '../http-exception';\nimport {\n builderRegistriesResponseSchema,\n builderRegistryInstallBodySchema,\n builderRegistryInstallResponseSchema,\n builderRegistryPathParams,\n builderRegistryPopularQuerySchema,\n builderRegistryPreviewQuerySchema,\n builderRegistrySearchQuerySchema,\n} from '../schemas/builder-registry';\nimport {\n skillsShListResponseSchema,\n skillsShPreviewResponseSchema,\n skillsShSearchResponseSchema,\n} from '../schemas/workspace';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\nimport { getCallerAuthorId } from './authorship';\nimport { handleError } from './error';\nimport {\n assertSafeFilePath,\n assertSafeSkillName,\n fetchSkillFiles,\n getPopularSkillsSh,\n previewSkillsSh,\n searchSkillsSh,\n} from './skills-sh-shared';\n\n// =============================================================================\n// Registry resolution\n// =============================================================================\n\n/** Stable identifiers + display labels for every supported registry. */\nconst REGISTRY_LABELS: Record = {\n 'skills-sh': 'skills.sh',\n};\n\ninterface RegistryStatus {\n id: 'skills-sh';\n enabled: boolean;\n label: string;\n}\n\n/**\n * Resolve which registries are enabled for the running deployment by reading\n * the builder's `registries` config. Returns a list with all known registries\n * (so the frontend can render an empty/disabled state) plus their enabled\n * flag.\n */\nasync function resolveRegistries(mastra: Mastra): Promise {\n const editor = mastra.getEditor();\n if (!editor || typeof editor.resolveBuilder !== 'function') {\n return [{ id: 'skills-sh', enabled: false, label: REGISTRY_LABELS['skills-sh']! }];\n }\n const builder = await editor.resolveBuilder();\n const registries = builder?.getRegistries?.();\n return [\n {\n id: 'skills-sh',\n enabled: registries?.skillsSh?.enabled === true,\n label: REGISTRY_LABELS['skills-sh']!,\n },\n ];\n}\n\n/**\n * Hard-gate: throws 404 when the requested registry is unknown or disabled.\n * Mirrors `requireBuilderFeature` semantics — no surface leak for OFF registries.\n */\nasync function requireEnabledRegistry(mastra: Mastra, registryId: string): Promise {\n const list = await resolveRegistries(mastra);\n const match = list.find(r => r.id === registryId);\n if (!match || !match.enabled) {\n throw new HTTPException(404, { message: 'Registry not found' });\n }\n}\n\n// =============================================================================\n// File-tree helpers\n// =============================================================================\n\n/**\n * Convert a flat list of `{ path, content, encoding }` entries into the\n * `StorageSkillFileNode` tree shape expected by the stored-skills create path.\n *\n * Each path is validated via `assertSafeFilePath` to prevent traversal from\n * upstream-controlled responses. Folder nodes are created on demand.\n */\nfunction buildFileTree(\n files: Array<{ path: string; content: string; encoding: 'utf-8' | 'base64' }>,\n): StorageSkillFileNode[] {\n const root: StorageSkillFileNode[] = [];\n\n for (const file of files) {\n const safePath = assertSafeFilePath(file.path);\n const segments = safePath.split('/').filter(Boolean);\n if (segments.length === 0) continue;\n\n let cursor = root;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i]!;\n let folder = cursor.find(node => node.type === 'folder' && node.name === segment);\n if (!folder) {\n folder = { name: segment, type: 'folder', children: [] };\n cursor.push(folder);\n }\n if (!folder.children) folder.children = [];\n cursor = folder.children;\n }\n\n const fileName = segments[segments.length - 1]!;\n const content = file.encoding === 'base64' ? Buffer.from(file.content, 'base64').toString('utf-8') : file.content;\n cursor.push({ name: fileName, type: 'file', content });\n }\n\n return root;\n}\n\n/**\n * Locally-bound SKILL.md frontmatter parser.\n *\n * Mirrors `parseSkillSnapshotFromFiles` from `@mastra/core/workspace`, but\n * inlined here because the server package's `@mastra/core` peer floor\n * (>=1.32.0) predates that helper. Once the floor is bumped to a release\n * containing the helper, this can be replaced by the shared core import.\n *\n * Only SKILL.md is consulted — frontmatter is split from the body using a\n * minimal YAML key:value reader sufficient for the fields registries\n * actually use (name, description). The body is everything after the\n * second `---` line, trimmed.\n */\ntype ParsedSkillSnapshot = {\n name?: string;\n description?: string;\n instructions: string;\n};\n\nfunction parseSkillSnapshot(\n files: Array<{ path: string; content: string; encoding: 'utf-8' | 'base64' }>,\n): ParsedSkillSnapshot | null {\n const skillMd = files.find(f => f.path === 'SKILL.md');\n if (!skillMd) return null;\n\n const raw =\n skillMd.encoding === 'base64' ? Buffer.from(skillMd.content, 'base64').toString('utf-8') : skillMd.content;\n\n const fmMatch = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n if (!fmMatch) {\n return { instructions: raw.trim() };\n }\n\n const fmBlock = fmMatch[1] ?? '';\n const body = fmMatch[2] ?? '';\n const frontmatter: Record = {};\n for (const line of fmBlock.split(/\\r?\\n/)) {\n const m = line.match(/^([A-Za-z0-9_-]+)\\s*:\\s*(.*)$/);\n if (!m) continue;\n const key = m[1];\n const value = m[2] ?? '';\n if (!key) continue;\n // Strip surrounding quotes, leave the rest as-is. Registry SKILL.md\n // frontmatter is consistently flat string fields in practice.\n frontmatter[key] = value.trim().replace(/^[\"'](.*)[\"']$/, '$1');\n }\n\n return {\n name: frontmatter.name,\n description: frontmatter.description,\n instructions: body.trim(),\n };\n}\n\n// =============================================================================\n// Routes\n// =============================================================================\n\n/**\n * GET /editor/builder/registries\n *\n * Lists every known registry and whether it's enabled in this deployment.\n * Used by the Builder UI to decide whether to show the \"Browse registry\"\n * entry point at all.\n */\nexport const LIST_BUILDER_REGISTRIES_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/registries',\n responseType: 'json',\n responseSchema: builderRegistriesResponseSchema,\n summary: 'List available skill registries',\n description: 'Returns the configured external skill registries and their enabled state.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra }) => {\n try {\n const registries = await resolveRegistries(mastra);\n return { registries };\n } catch (error) {\n return handleError(error, 'Error listing builder registries');\n }\n },\n});\n\n/**\n * GET /editor/builder/registries/:registryId/search\n *\n * Proxies a search query to the underlying registry. Currently only\n * registryId=\"skills-sh\" is supported.\n */\nexport const BUILDER_REGISTRY_SEARCH_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/registries/:registryId/search',\n responseType: 'json',\n pathParamSchema: builderRegistryPathParams,\n queryParamSchema: builderRegistrySearchQuerySchema,\n responseSchema: skillsShSearchResponseSchema,\n summary: 'Search skills in a registry',\n description: 'Proxies a search request to the configured registry to avoid CORS issues.',\n tags: ['Editor', 'Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, registryId, q, limit }) => {\n try {\n await requireEnabledRegistry(mastra, registryId);\n return await searchSkillsSh({ q, limit });\n } catch (error) {\n if (error instanceof HTTPException) throw error;\n return handleError(error, 'Error searching registry');\n }\n },\n});\n\n/**\n * GET /editor/builder/registries/:registryId/popular\n *\n * Returns the most popular skills in a registry.\n */\nexport const BUILDER_REGISTRY_POPULAR_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/registries/:registryId/popular',\n responseType: 'json',\n pathParamSchema: builderRegistryPathParams,\n queryParamSchema: builderRegistryPopularQuerySchema,\n responseSchema: skillsShListResponseSchema,\n summary: 'Get popular skills from a registry',\n description: 'Proxies a popular-skills request to the configured registry to avoid CORS issues.',\n tags: ['Editor', 'Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, registryId, limit, offset }) => {\n try {\n await requireEnabledRegistry(mastra, registryId);\n return await getPopularSkillsSh({ limit, offset });\n } catch (error) {\n if (error instanceof HTTPException) throw error;\n return handleError(error, 'Error fetching popular skills');\n }\n },\n});\n\n/**\n * GET /editor/builder/registries/:registryId/preview\n *\n * Returns the rendered SKILL.md content for a single skill in the registry.\n */\nexport const BUILDER_REGISTRY_PREVIEW_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/registries/:registryId/preview',\n responseType: 'json',\n pathParamSchema: builderRegistryPathParams,\n queryParamSchema: builderRegistryPreviewQuerySchema,\n responseSchema: skillsShPreviewResponseSchema,\n summary: 'Preview a skill from a registry',\n description: 'Fetches the SKILL.md content for a single skill in the configured registry.',\n tags: ['Editor', 'Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:read',\n handler: async ({ mastra, registryId, owner, repo, path: skillName }) => {\n try {\n await requireEnabledRegistry(mastra, registryId);\n return await previewSkillsSh({ owner, repo, skillName });\n } catch (error) {\n if (error instanceof HTTPException) throw error;\n return handleError(error, 'Error fetching skill preview');\n }\n },\n});\n\n/**\n * POST /editor/builder/registries/:registryId/install\n *\n * Fetches the full file tree for a skill from the registry, parses the\n * SKILL.md frontmatter for name/description, and persists everything as a\n * new stored skill. The registry origin is recorded under `metadata.origin`\n * so the UI can surface \"imported from skills.sh\" badges and re-resolve the\n * source later.\n *\n * Collisions (a stored skill with the derived id already exists) return 409\n * so the UI can offer an \"Open existing\" link instead of silently\n * overwriting.\n */\nexport const BUILDER_REGISTRY_INSTALL_ROUTE = createRoute({\n method: 'POST',\n path: '/editor/builder/registries/:registryId/install',\n responseType: 'json',\n pathParamSchema: builderRegistryPathParams,\n bodySchema: builderRegistryInstallBodySchema,\n responseSchema: builderRegistryInstallResponseSchema,\n summary: 'Install a registry skill into stored skills',\n description: 'Fetches a skill from the configured registry and persists it as a new stored skill.',\n tags: ['Editor', 'Skills'],\n requiresAuth: true,\n requiresPermission: 'stored-skills:write',\n handler: async ({ mastra, requestContext, registryId, owner, repo, skillName, visibility: bodyVisibility }) => {\n try {\n await requireEnabledRegistry(mastra, registryId);\n\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n const skillStore = await storage.getStore('skills');\n if (!skillStore) {\n throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n }\n\n // Pull files from the registry\n const result = await fetchSkillFiles(owner, repo, skillName);\n if (!result || result.files.length === 0) {\n throw new HTTPException(404, {\n message: `Could not find skill \"${skillName}\" in ${owner}/${repo}.`,\n });\n }\n\n const safeSkillId = assertSafeSkillName(result.skillId);\n const files = buildFileTree(result.files);\n\n // Parse SKILL.md frontmatter into structured fields. Splitting\n // frontmatter (name/description) from the markdown body keeps the\n // body as the agent-facing `instructions` instead of polluting it\n // with raw YAML metadata. SKILL.md missing or unparseable simply\n // yields a null snapshot — registry-provided values then fill in.\n const snapshot = parseSkillSnapshot(result.files);\n\n const resolvedName = snapshot?.name ?? safeSkillId;\n const description = snapshot?.description ?? `Imported from ${owner}/${repo}`;\n const id = toSlug(resolvedName) || safeSkillId;\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive skill ID from registry skill metadata.',\n });\n }\n\n // Reject collisions instead of silently overwriting; UI offers \"Open existing\".\n const existing = await skillStore.getById(id);\n if (existing) {\n throw new HTTPException(409, {\n message: `Skill with id \"${id}\" already exists.`,\n // Surface the existing id so the client can deep-link.\n cause: { storedSkillId: id },\n });\n }\n\n // Match the standard create flow: no caller = always public, otherwise default private.\n const authorId = getCallerAuthorId(requestContext) ?? undefined;\n const visibility: 'private' | 'public' = authorId ? (bodyVisibility ?? 'private') : 'public';\n\n // Use the SKILL.md body (post-frontmatter) as instructions. Frontmatter\n // values are already lifted into structured columns above, so re-storing\n // them in `instructions` would both duplicate metadata and feed YAML\n // into the agent's prompt. Fall back to description when no usable body\n // exists so `resolved.snapshot.instructions` stays non-empty.\n const instructions = snapshot?.instructions?.trim() ? snapshot.instructions : description;\n\n await skillStore.create({\n skill: {\n id,\n authorId,\n visibility,\n name: resolvedName,\n description,\n instructions,\n files,\n metadata: {\n origin: {\n type: 'skills-sh',\n owner,\n repo,\n skillName,\n },\n },\n },\n });\n\n return {\n storedSkillId: id,\n name: resolvedName,\n filesWritten: result.files.length,\n };\n } catch (error) {\n if (error instanceof HTTPException) throw error;\n return handleError(error, 'Error installing registry skill');\n }\n },\n});\n"]}