Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. π₯
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
Add skills search source (#5560)
Developers Digest7d8e92dc5d27
diff --git a/apps/api/openapi.json b/apps/api/openapi.jsonindex f70a26de1..238d10c99 100644--- a/apps/api/openapi.json+++ b/apps/api/openapi.json@@ -4377,10 +4377,22 @@},"required": ["type"],"additionalProperties": false+ },+ {+ "type": "object",+ "title": "Skills",+ "properties": {+ "type": {+ "type": "string",+ "enum": ["skills"]+ }+ },+ "required": ["type"],+ "additionalProperties": false}]},- "description": "Sources to search. Will determine the arrays available in the response. Defaults to ['web']. The plain string form (e.g. `[\"web\", \"alexandria\"]`) is also accepted. The `alexandria` source returns tool contracts discovered from the Alexandria catalogue in `data.tools` instead of search results; it is free and is never counted in `creditsUsed`. Requires the team's Alexandria access to be enabled (403 otherwise). When `sources` is omitted, an authenticated search may also return compact tools in `data.tools` for queries that ask for structured data; pass `sources` explicitly to turn this off.",+ "description": "Sources to search. Will determine the arrays available in the response. Defaults to ['web']. The plain string form (e.g. `[\"web\", \"alexandria\", \"skills\"]`) is also accepted. The `alexandria` source returns tool contracts discovered from the Alexandria catalogue in `data.tools` instead of search results; it is free and is never counted in `creditsUsed`. The `skills` source returns up to 3 short skill cards in `data.skills` (`id`, `name`, `description`, `source` of `official` or `provider`, plus `provider` when the skill belongs to a provider and `similarity` when the match was semantic). It is free, is never counted in `creditsUsed`, and uses the same access rules as `alexandria`. A timeout or upstream error returns an empty `data.skills` array and does not fail the search. The card is not the full skill; load that separately with the card `id`. Requires the team's Alexandria access to be enabled (403 otherwise). When `sources` is omitted, an authenticated search may also return compact tools in `data.tools` for queries that ask for structured data; pass `sources` explicitly to turn this off.","default": [{"type": "web"@@ -4769,6 +4781,38 @@"items": {"$ref": "#/components/schemas/DiscoveredTool"}+ },+ "skills": {+ "type": "array",+ "description": "Short skill cards from the Alexandria catalogue. Present when `skills` is among the sources, including when nothing matched or the lookup failed. At most 3 cards. Free, and never counted in `creditsUsed`.",+ "items": {+ "type": "object",+ "required": ["id", "name", "description", "source"],+ "properties": {+ "id": {+ "type": "string",+ "description": "Skill id. The full skill is loaded separately with this id."+ },+ "name": {+ "type": "string"+ },+ "description": {+ "type": "string"+ },+ "source": {+ "type": "string",+ "enum": ["official", "provider"]+ },+ "provider": {+ "type": "string",+ "description": "Publisher slug. Present when `source` is `provider`."+ },+ "similarity": {+ "type": "number",+ "description": "Semantic match score. Omitted when the card came from a word match."+ }+ }+ }}},"description": "The search results. The arrays available will depend on the sources you specified in the request. By default, the `web` array will be returned."diff --git a/apps/api/requests/v2/search.requests.http b/apps/api/requests/v2/search.requests.httpindex 401aa28eb..c4a5e6ea0 100644--- a/apps/api/requests/v2/search.requests.http+++ b/apps/api/requests/v2/search.requests.http@@ -11,7 +11,7 @@ content-type: application/json{"query": "firecrawl",- "sources": ["web", "images", "news"],+ "sources": ["web", "images", "news", "skills"],"limit": 5}diff --git a/apps/api/src/controllers/v2/__tests__/search-developer-ledger.test.ts b/apps/api/src/controllers/v2/__tests__/search-developer-ledger.test.tsindex 3b6741e65..1d2e3fc01 100644--- a/apps/api/src/controllers/v2/__tests__/search-developer-ledger.test.ts+++ b/apps/api/src/controllers/v2/__tests__/search-developer-ledger.test.ts@@ -66,6 +66,7 @@ vi.mock("../../../lib/logger", () => ({}));import { searchController } from "../search";+import { markAlexandriaActivity } from "../../../lib/alexandria-activity";const TEAM_ID = "11111111-1111-1111-1111-111111111111";@@ -419,3 +420,130 @@ describe("tool discovery availability", () => {);});});++describe("skill discovery source", () => {+ const card = {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official",+ };++ it("returns skill cards without billing or reserving keyless credits", async () => {+ mockProjectSearchTotalCredits.mockReturnValue(2);+ mockExecuteSearch.mockResolvedValue(+ executeResult({+ response: { skills: [card] },+ skillsDiscovered: true,+ totalResultsCount: 0,+ indexResultsCount: 0,+ searchCredits: 0,+ totalCredits: 0,+ }),+ );+ const res = makeRes();++ await searchController(+ makeReq({ query: "records", sources: ["skills"] }),+ res,+ );++ expect(mockReserveKeylessCredits).not.toHaveBeenCalled();+ expect(mockExecuteSearch).toHaveBeenCalledWith(+ expect.objectContaining({+ sources: [{ type: "skills" }],+ }),+ expect.anything(),+ expect.anything(),+ );+ expect(res.status).toHaveBeenCalledWith(200);+ expect(res.json).toHaveBeenCalledWith(+ expect.objectContaining({+ success: true,+ creditsUsed: 0,+ data: { skills: [card] },+ }),+ );+ expect(markAlexandriaActivity).toHaveBeenCalledWith(TEAM_ID);+ });++ it("answers 200 with empty cards when discovery produced nothing", async () => {+ mockExecuteSearch.mockResolvedValue(+ executeResult({+ response: { skills: [] },+ skillsDiscovered: false,+ totalResultsCount: 0,+ indexResultsCount: 0,+ searchCredits: 0,+ totalCredits: 0,+ toolsUnavailable: true,+ }),+ );+ const res = makeRes();++ await searchController(+ makeReq({ query: "records", sources: [{ type: "skills" }] }),+ res,+ );++ expect(res.status).toHaveBeenCalledWith(200);+ expect(res.json).toHaveBeenCalledWith(+ expect.objectContaining({ success: true, data: { skills: [] } }),+ );+ expect(markAlexandriaActivity).not.toHaveBeenCalled();+ });++ it("opens the feedback window for a successful lookup that matched nothing", async () => {+ mockExecuteSearch.mockResolvedValue(+ executeResult({+ response: { skills: [] },+ skillsDiscovered: true,+ totalResultsCount: 0,+ indexResultsCount: 0,+ searchCredits: 0,+ totalCredits: 0,+ }),+ );+ const res = makeRes();++ await searchController(+ makeReq({ query: "records", sources: ["skills"] }),+ res,+ );++ expect(markAlexandriaActivity).toHaveBeenCalledWith(TEAM_ID);+ });++ it("requires a query", async () => {+ const res = makeRes();++ await searchController(makeReq({ query: " ", sources: ["skills"] }), res);++ expect(res.status).toHaveBeenCalledWith(400);+ expect(mockExecuteSearch).not.toHaveBeenCalled();+ });++ it("refuses keyless and zero data retention the same way tool search does", async () => {+ const keyless = makeRes();+ await searchController(+ {+ ...makeReq({ query: "records", sources: ["skills"] }),+ auth: { team_id: "preview_keyless_203.0.113.8" },+ },+ keyless,+ );+ expect(keyless.status).toHaveBeenCalledWith(403);++ const zdr = makeRes();+ await searchController(+ makeReq({+ query: "records",+ sources: ["skills"],+ enterprise: ["zdr"],+ }),+ zdr,+ );+ expect(zdr.status).toHaveBeenCalledWith(403);+ expect(mockExecuteSearch).not.toHaveBeenCalled();+ });+});diff --git a/apps/api/src/controllers/v2/search-schema.test.ts b/apps/api/src/controllers/v2/search-schema.test.tsindex d31ae0189..0ee303edc 100644--- a/apps/api/src/controllers/v2/search-schema.test.ts+++ b/apps/api/src/controllers/v2/search-schema.test.ts@@ -1,6 +1,38 @@import { describe, expect, it } from "vitest";import { searchRequestSchema, scrapeRequestSchema } from "./types";+describe("searchRequestSchema sources", () => {+ it("accepts skills as a string or an object", () => {+ expect(+ searchRequestSchema.parse({+ query: "records",+ sources: ["skills"],+ }).sources,+ ).toEqual([{ type: "skills" }]);+ expect(+ searchRequestSchema.parse({+ query: "records",+ sources: [{ type: "skills" }],+ }).sources,+ ).toEqual([{ type: "skills" }]);+ });++ it("rejects extra fields and unknown sources", () => {+ expect(+ searchRequestSchema.safeParse({+ query: "records",+ sources: [{ type: "skills", limit: 3 }],+ }).success,+ ).toBe(false);+ expect(+ searchRequestSchema.safeParse({+ query: "records",+ sources: ["not-a-source"],+ }).success,+ ).toBe(false);+ });+});+describe("searchRequestSchema highlights", () => {it.each(["compact", "summary", "full"])("accepts %s tool detail",diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.tsindex 6f7e924eb..9d0669c06 100644--- a/apps/api/src/controllers/v2/search.ts+++ b/apps/api/src/controllers/v2/search.ts@@ -38,7 +38,10 @@ import {import { projectSearchTotalCredits } from "../../lib/keyless-credit-projection";import { applyAgentAuthDiscoveryHeader } from "../../lib/agent-auth-discovery";import { resolveThreatProtection } from "../../lib/threat-protection/request";-import { isToolsOnlySearch } from "../../search/alexandria";+import {+ isFreeCatalogueSearch,+ isToolsOnlySearch,+} from "../../search/alexandria";import {resolveSafeMode,isLockdownZeroDataRetention,@@ -189,8 +192,11 @@ async function searchControllerInner(const wantsTools = req.body.sources.some(source => source.type === "alexandria",);+ const wantsSkills = req.body.sources.some(+ source => source.type === "skills",+ );if (- (wantsTools || req.body.domainTools) &&+ (wantsTools || wantsSkills || req.body.domainTools) &&req.auth.team_id.startsWith("preview_keyless_")) {return res.status(403).json({@@ -198,13 +204,15 @@ async function searchControllerInner(error: "An API key is required for provider tools.",});}- if (wantsTools && !req.body.query.trim())+ if ((wantsTools || wantsSkills) && !req.body.query.trim())return res.status(400).json({success: false,- error: "A query is required for tool search.",+ error: wantsTools+ ? "A query is required for tool search."+ : "A query is required for skill search.",});if (- (wantsTools || req.body.domainTools) &&+ (wantsTools || wantsSkills || req.body.domainTools) &&(teamForcedKind ||req.body.enterprise?.some(mode => mode === "zdr" || mode === "anon")))@@ -427,11 +435,15 @@ async function searchControllerInner(}const toolsOnly = isToolsOnlySearch(req.body.sources, req.body.categories);+ const freeCatalogue = isFreeCatalogueSearch(+ req.body.sources,+ req.body.categories,+ );const govSearch = wantsGovCategory(categories);const projectedKeylessCredits =!isSearchPreview &&shouldBill &&- !toolsOnly &&+ !freeCatalogue &&(!govSearch || requestedFormats.length > 0)? projectSearchTotalCredits({@@ -664,8 +676,10 @@ async function searchControllerInner(scrapeful: result.shouldScrape,});- if (result.response.tools) {+ if (result.response.tools || result.skillsDiscovered) {markAlexandriaActivity(req.auth.team_id);+ }+ if (result.response.tools) {recordDiscoveredTools(req.auth.team_id,result.toolsAuto ? "auto_search" : "search",diff --git a/apps/api/src/controllers/v2/types.ts b/apps/api/src/controllers/v2/types.tsindex 72787e4c5..8790128d7 100644--- a/apps/api/src/controllers/v2/types.ts+++ b/apps/api/src/controllers/v2/types.ts@@ -11,6 +11,7 @@ import { hasReachableHost } from "../../lib/url-utils";import { countries } from "../../lib/validate-country";import { includesFormat } from "../../lib/format-utils";import { addPathRegexIssues, pathPatternsSchema } from "../../lib/crawl-regex";+import { isDeveloperCategoryAlias } from "../../lib/developer-category";import { addStrictSchemaIssue } from "../../lib/openai-strict-schema";import {ExtractorOptions,@@ -2537,20 +2538,6 @@ const govCategoryOptions = z.strictObject({type: z.literal("gov"),});-const developerCategoryAliases = new Set([- "repo",- "code",- "developer",- "docs",- "devdex",- "repo_search",- "developer_index",-]);--function isDeveloperCategoryAlias(value: unknown): value is string {- return typeof value === "string" && developerCategoryAliases.has(value);-}-function normalizeDeveloperCategoryAliases(value: unknown): unknown {if (!Array.isArray(value)) return value;let seenString = false;@@ -2601,7 +2588,7 @@ export const searchRequestSchema = zsources: z.union([// Array of strings (simple format)- z.array(z.enum(["web", "images", "news", "alexandria"])),+ z.array(z.enum(["web", "images", "news", "alexandria", "skills"])),// Array of objects (advanced format)z.array(z.union([@@ -2611,6 +2598,9 @@ export const searchRequestSchema = zz.strictObject({type: z.literal("alexandria"),}),+ z.strictObject({+ type: z.literal("skills"),+ }),]),),])diff --git a/apps/api/src/lib/__tests__/search-result-categories.test.ts b/apps/api/src/lib/__tests__/search-result-categories.test.tsindex 04bd98d45..3374f2c15 100644--- a/apps/api/src/lib/__tests__/search-result-categories.test.ts+++ b/apps/api/src/lib/__tests__/search-result-categories.test.ts@@ -111,6 +111,24 @@ describe("collectSearchResultCategories", () => {],}),).toEqual({ web: 0, images: 0, news: 0, tools: 1 });+ expect(+ countSearchResultsBySource({+ skills: [+ {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official",+ },+ ],+ }),+ ).toEqual({ web: 0, images: 0, news: 0, skills: 1 });+ expect(countSearchResultsBySource({ skills: [] })).toEqual({+ web: 0,+ images: 0,+ news: 0,+ skills: 0,+ });});it("positions line up with the counts feedback bounds against", () => {diff --git a/apps/api/src/lib/developer-category.ts b/apps/api/src/lib/developer-category.tsnew file mode 100644index 000000000..b098388f7--- /dev/null+++ b/apps/api/src/lib/developer-category.ts@@ -0,0 +1,14 @@+/** Strings the search schema accepts and rewrites to the developer category. */+export const developerCategoryAliases = new Set([+ "repo",+ "code",+ "developer",+ "docs",+ "devdex",+ "repo_search",+ "developer_index",+]);++export function isDeveloperCategoryAlias(value: unknown): value is string {+ return typeof value === "string" && developerCategoryAliases.has(value);+}diff --git a/apps/api/src/lib/entities.ts b/apps/api/src/lib/entities.tsindex d0165a87f..a0a41a941 100644--- a/apps/api/src/lib/entities.ts+++ b/apps/api/src/lib/entities.ts@@ -1,4 +1,5 @@import type { Action } from "../controllers/v1/types";+import type { SkillCard } from "../search/skill-cards";import type { BrandingProfile } from "../types/branding";export type PageOptions = {@@ -165,6 +166,7 @@ export type SearchResultType = "web" | "images" | "news";export interface SearchV2Response {tools?: import("../services/alexandria/contracts").DiscoveredTool[];+ skills?: SkillCard[];web?: WebSearchResult[];images?: ImageSearchResult[];news?: NewsSearchResult[];@@ -175,10 +177,12 @@ export interface SearchV2Response {* group is present and non-negative β a source that was not requested, or that* returned nothing, counts 0. Persisted per search so position-based feedback* can be bounded exactly per source rather than against a combined total.- * `tools` is present only when provider discovery ran.+ * `tools` is present only when provider discovery ran. `skills` is present+ * only when skill discovery ran.*/export type SearchResultCountsBySource = Record<SearchResultType, number> & {tools?: number;+ skills?: number;};export function countSearchResultsBySource(@@ -189,6 +193,7 @@ export function countSearchResultsBySource(images: response.images?.length ?? 0,news: response.news?.length ?? 0,...(response.tools ? { tools: response.tools.length } : {}),+ ...(response.skills ? { skills: response.skills.length } : {}),};}diff --git a/apps/api/src/routes/shared.ts b/apps/api/src/routes/shared.tsindex 5f33b7295..a6d9f76aa 100644--- a/apps/api/src/routes/shared.ts+++ b/apps/api/src/routes/shared.ts@@ -37,7 +37,7 @@ import {ThirdPartyDataUnsupportedOptionError,} from "../lib/exchange";import { getExchangeAccessForRequestBody } from "../lib/exchange-request";-import { isToolsOnlySearch } from "../search/alexandria";+import { isFreeCatalogueSearch } from "../search/alexandria";import { getScrapeZDR } from "../lib/zdr-helpers";import { isLockdownZeroDataRetention } from "../lib/safe-mode";import {@@ -131,15 +131,15 @@ export function checkCreditsMiddleware(// If verified, fall through to normal credit check (key is now on real account)}- // Tool discovery is free; provider execution reserves its own credits.+ // Catalogue discovery is free; provider execution reserves its own credits.const sources = (req.body as any)?.sources;const categories = (req.body as any)?.categories;- const toolsOnly =- req.path === "/search" && isToolsOnlySearch(sources, categories);+ const freeCatalogue =+ req.path === "/search" && isFreeCatalogueSearch(sources, categories);if ((req.path === "/scrape" &&(req.body as any)?.alexandria !== undefined) ||- toolsOnly+ freeCatalogue) {req.account = { remainingCredits: Infinity };return next();diff --git a/apps/api/src/search/alexandria.ts b/apps/api/src/search/alexandria.tsindex 960cba262..a7630c9f9 100644--- a/apps/api/src/search/alexandria.ts+++ b/apps/api/src/search/alexandria.ts@@ -1,5 +1,6 @@import { z } from "zod";import type { Logger } from "winston";+import { developerCategoryAliases } from "../lib/developer-category";import { exchangeRequest } from "../services/alexandria/client";import {toolSchema,@@ -25,20 +26,44 @@ type CategoryLike = string | { type: string };const typeOf = (value: SourceLike | CategoryLike) =>typeof value === "string" ? value : value?.type;+const CATALOGUE_SOURCES = new Set(["alexandria", "skills"]);++function excludesIndexCategory(categories: unknown): boolean {+ return (+ Array.isArray(categories) &&+ categories.some(category => {+ const type = typeOf(category);+ return (+ type === "gov" ||+ (type !== undefined && developerCategoryAliases.has(type))+ );+ })+ );+}+export function isToolsOnlySearch(sources: unknown,categories: unknown,): boolean {if (!Array.isArray(sources) || sources.length === 0) return false;if (!sources.every(source => typeOf(source) === "alexandria")) return false;- if (- Array.isArray(categories) &&- categories.some(category => {- const type = typeOf(category);- return type === "developer" || type === "gov";- })- )+ if (excludesIndexCategory(categories)) return false;+ return true;+}++/**+ * Search that only asks the Alexandria catalogue for tools and/or skill cards.+ * Both are free, so the credit check is skipped the same way as a tools-only+ * search. An index category still has its own billable path.+ */+export function isFreeCatalogueSearch(+ sources: unknown,+ categories: unknown,+): boolean {+ if (!Array.isArray(sources) || sources.length === 0) return false;+ if (!sources.every(source => CATALOGUE_SOURCES.has(typeOf(source) ?? "")))return false;+ if (excludesIndexCategory(categories)) return false;return true;}diff --git a/apps/api/src/search/execute.test.ts b/apps/api/src/search/execute.test.tsindex 26aaead72..1947a39e4 100644--- a/apps/api/src/search/execute.test.ts+++ b/apps/api/src/search/execute.test.ts@@ -4,6 +4,7 @@ const mocks = vi.hoisted(() => ({searchGovCategory: vi.fn(),checkUrlsAgainstThreatPolicy: vi.fn(),discoverTools: vi.fn(),+ discoverSkills: vi.fn(),removeExplicitResults: vi.fn(),inferToolIntent: vi.fn(),verifyTools: vi.fn(),@@ -22,6 +23,12 @@ vi.mock("./alexandria", () => ({source.type === "alexandria",}));+vi.mock("./skill-cards", () => ({+ discoverSkills: mocks.discoverSkills,+ isSkillsSource: (source: { type: string }) => source.type === "skills",+ SKILLS_DISCOVERY_TIMEOUT_MS: 3000,+}));+vi.mock("./v2", () => ({ search: mocks.search }));vi.mock("./developer", () => ({wantsDeveloperCategory: (categories?: Array<string | { type: string }>) =>@@ -112,6 +119,7 @@ beforeEach(() => {status: "available",items: [{ id: "fred/series/observations" }],});+ mocks.discoverSkills.mockResolvedValue({ skills: [], succeeded: false });mocks.verifyTools.mockImplementation(async (_query, items) => items);});@@ -854,3 +862,165 @@ describe("executeSearch query operators", () => {);});});++describe("executeSearch skill cards", () => {+ const card = {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official" as const,+ similarity: 0.5,+ };++ it("leaves skills off when the source was not requested", async () => {+ mocks.search.mockResolvedValue({ web: [developerResult] });++ const result = await executeSearch(options([]), context, logger);++ expect(mocks.discoverSkills).not.toHaveBeenCalled();+ expect(result.response).not.toHaveProperty("skills");+ expect(result.searchCredits).toBe(2);+ });++ it("starts skill discovery before the web search and maps the cards", async () => {+ const order: string[] = [];+ let releaseSkills: (found: {+ skills: unknown[];+ succeeded: boolean;+ }) => void = () => {};+ mocks.discoverSkills.mockImplementation(+ () =>+ new Promise(resolve => {+ order.push("skills");+ releaseSkills = resolve;+ }),+ );+ mocks.search.mockImplementation(async () => {+ order.push("web");+ releaseSkills({ skills: [card], succeeded: true });+ return { web: [developerResult] };+ });++ const result = await executeSearch(+ {+ ...options([]),+ sources: [{ type: "web" }, { type: "skills" }],+ },+ context,+ logger,+ );++ expect(order).toEqual(["skills", "web"]);+ expect(mocks.discoverSkills).toHaveBeenCalledWith(+ expect.objectContaining({+ teamId: "team-1",+ query: "retries",+ timeoutMs: 1000,+ usOnly: false,+ }),+ logger,+ );+ expect(mocks.search).toHaveBeenCalledWith(+ expect.objectContaining({ type: ["web"] }),+ );+ expect(result.response.skills).toEqual([card]);+ expect(result.skillsDiscovered).toBe(true);+ expect(result.response.web).toHaveLength(1);+ expect(result.searchCredits).toBe(2);+ });++ it("keeps web results and returns no cards when skill discovery fails", async () => {+ mocks.search.mockResolvedValue({ web: [developerResult] });+ mocks.discoverSkills.mockRejectedValue(new Error("timed out"));++ const result = await executeSearch(+ {+ ...options([]),+ sources: [{ type: "web" }, { type: "skills" }],+ },+ context,+ logger,+ );++ expect(result.response.web).toHaveLength(1);+ expect(result.response.skills).toEqual([]);+ expect(result.skillsDiscovered).toBe(false);+ expect(result.searchCredits).toBe(2);+ });++ it("does not run or bill web search for a skills-only request", async () => {+ mocks.discoverSkills.mockResolvedValue({+ skills: [card],+ succeeded: true,+ });++ const result = await executeSearch(+ { ...options([]), sources: [{ type: "skills" }] },+ context,+ logger,+ );++ expect(mocks.search).not.toHaveBeenCalled();+ expect(result.response.skills).toEqual([card]);+ expect(result.skillsDiscovered).toBe(true);+ expect(result.searchCredits).toBe(0);+ expect(result.totalCredits).toBe(0);+ });++ it.each([+ ["zero data retention", { zeroDataRetention: true }, {}],+ ["zdr enterprise mode", {}, { enterprise: ["zdr"] }],+ ["anon enterprise mode", {}, { enterprise: ["anon"] }],+ ])(+ "skips skill discovery under %s",+ async (_label, contextOverrides, optionOverrides) => {+ mocks.search.mockResolvedValue({ web: [developerResult] });++ const result = await executeSearch(+ {+ ...options([]),+ sources: [{ type: "web" }, { type: "skills" }],+ ...optionOverrides,+ },+ { ...context, ...contextOverrides },+ logger,+ );++ expect(mocks.discoverSkills).not.toHaveBeenCalled();+ expect(result.response).not.toHaveProperty("skills");+ expect(result.skillsDiscovered).toBe(false);+ },+ );++ it("skips skill discovery when the query is empty", async () => {+ const result = await executeSearch(+ {+ ...options([]),+ query: " ",+ sources: [{ type: "skills" }],+ },+ context,+ logger,+ );++ expect(mocks.discoverSkills).not.toHaveBeenCalled();+ expect(mocks.search).not.toHaveBeenCalled();+ expect(result.response).not.toHaveProperty("skills");+ expect(result.skillsDiscovered).toBe(false);+ });++ it("forwards a US-only team to skill discovery", async () => {+ mocks.discoverSkills.mockResolvedValue({ skills: [], succeeded: true });++ await executeSearch(+ { ...options([]), sources: [{ type: "skills" }] },+ { ...context, flags: { usOnly: true } },+ logger,+ );++ expect(mocks.discoverSkills).toHaveBeenCalledWith(+ expect.objectContaining({ usOnly: true }),+ logger,+ );+ });+});diff --git a/apps/api/src/search/execute.ts b/apps/api/src/search/execute.tsindex e9fb7fe9c..4bad67142 100644--- a/apps/api/src/search/execute.ts+++ b/apps/api/src/search/execute.ts@@ -4,6 +4,12 @@ import {isAlexandriaSource,usOnlyToolsWarning,} from "./alexandria";+import {+ discoverSkills,+ isSkillsSource,+ SKILLS_DISCOVERY_TIMEOUT_MS,+ type SkillDiscovery,+} from "./skill-cards";import {AUTO_TOOLS_WAIT_MS,inferToolIntent,@@ -105,6 +111,8 @@ interface SearchExecuteResult {/** The tools were added automatically, not requested. */toolsAuto?: boolean;toolsUnavailable?: boolean;+ /** Skill-card lookup returned the Exchange envelope, including an empty one. */+ skillsDiscovered?: boolean;response: SearchV2Response;totalResultsCount: number;resultCountsBySource: SearchResultCountsBySource;@@ -141,9 +149,26 @@ export async function executeSearch(logger.info("Searching for results");const wantsTools = sources.some(isAlexandriaSource);+ const wantsSkills = sources.some(isSkillsSource);const toolsAllowed =!zeroDataRetention &&!options.enterprise?.some(mode => mode === "zdr" || mode === "anon");+ const missedSkills: SkillDiscovery = { skills: [], succeeded: false };+ const skillsPromise =+ toolsAllowed && wantsSkills && query.trim()+ ? discoverSkills(+ {+ teamId,+ query,+ timeoutMs: Math.min(options.timeout, SKILLS_DISCOVERY_TIMEOUT_MS),+ usOnly,+ },+ logger,+ ).catch(error => {+ logger.warn("Skill discovery failed", { error });+ return missedSkills;+ })+ : null;const toolIntent =toolsAllowed &&(wantsTools ? options.inferToolQuery : options.autoTools) &&@@ -205,7 +230,9 @@ export async function executeSearch(const searchTypes = [...new Set(sources- .filter(source => !isAlexandriaSource(source))+ .filter(+ source => !isAlexandriaSource(source) && !isSkillsSource(source),+ ).map(source => source.type as SearchResultType),),];@@ -247,7 +274,8 @@ export async function executeSearch(: null;const searchResponse =- (wantsTools && !searchTypes.length) || indexResultsPromise !== null+ ((wantsTools || wantsSkills) && !searchTypes.length) ||+ indexResultsPromise !== null? ({} as SearchV2Response): ((await search({query: searchQuery,@@ -601,6 +629,13 @@ export async function executeSearch(}));}+ let skillsDiscovered = false;+ if (skillsPromise) {+ const found = await skillsPromise;+ searchResponse.skills = found.skills;+ skillsDiscovered = found.succeeded;+ }+const scrapeFormats = scrapeOptions?.formats? scrapeOptions.formats.map((f: any) =>typeof f === "string" ? f : f.type,@@ -647,6 +682,7 @@ export async function executeSearch(toolsWarning,toolsUnavailable,toolsAuto,+ skillsDiscovered,totalResultsCount,// Counted from the final response β after scraping and highlights β so it// matches exactly what the client can address by position.diff --git a/apps/api/src/search/skill-cards.test.ts b/apps/api/src/search/skill-cards.test.tsnew file mode 100644index 000000000..0833b9dfd--- /dev/null+++ b/apps/api/src/search/skill-cards.test.ts@@ -0,0 +1,257 @@+import { describe, it, expect, vi, beforeEach } from "vitest";+import { discoverSkills } from "./skill-cards";+import { isFreeCatalogueSearch, isToolsOnlySearch } from "./alexandria";+import { exchangeRequest } from "../services/alexandria/client";++vi.mock("../services/alexandria/client", () => ({ exchangeRequest: vi.fn() }));+const request = vi.mocked(exchangeRequest);+const logger = { warn: vi.fn() } as any;++const official = {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official" as const,+ similarity: 0.82,+ body: "full skill text",+};+const provider = {+ id: "acme/brief",+ name: "Brief",+ description: "A provider skill",+ source: "provider" as const,+ provider: "acme",+};++beforeEach(() => {+ vi.clearAllMocks();+});++it("maps a successful discover response onto short cards", async () => {+ request.mockResolvedValue({+ status: 200,+ body: { query: "records", skills: [official, provider] },+ });++ const cards = await discoverSkills(+ { teamId: "team", query: " records ", timeoutMs: 9000 },+ logger,+ );++ expect(request).toHaveBeenCalledTimes(1);+ expect(request.mock.calls[0][0]).toEqual({+ teamId: "team",+ path: "/v1/discover/skill-cards?q=records&limit=3",+ timeoutMs: 3000,+ usOnly: false,+ });+ expect(request.mock.calls[0][0]).not.toHaveProperty("body");+ expect(cards.succeeded).toBe(true);+ expect(cards.skills).toEqual([+ {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official",+ similarity: 0.82,+ },+ {+ id: "acme/brief",+ name: "Brief",+ description: "A provider skill",+ source: "provider",+ provider: "acme",+ },+ ]);+});++it("omits similarity and provider when the match did not include them", async () => {+ request.mockResolvedValue({+ status: 200,+ body: {+ query: "records",+ skills: [+ {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official",+ provider: null,+ similarity: null,+ },+ ],+ },+ });++ const cards = await discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000 },+ logger,+ );++ expect(cards.succeeded).toBe(true);+ expect(cards.skills).toEqual([+ {+ id: "official/search",+ name: "Search",+ description: "Find records",+ source: "official",+ },+ ]);+ expect(cards.skills[0]).not.toHaveProperty("similarity");+ expect(cards.skills[0]).not.toHaveProperty("provider");+});++it("returns no cards when the body is not the skill-card envelope", async () => {+ request.mockResolvedValue({+ status: 200,+ body: { skills: [{ name: "cohort" }] },+ });++ await expect(+ discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000 },+ logger,+ ),+ ).resolves.toEqual({ skills: [], succeeded: false });+ expect(logger.warn).toHaveBeenCalled();+});++it("forwards usOnly so Exchange can hide non-US providers", async () => {+ request.mockResolvedValue({+ status: 200,+ body: { query: "records", skills: [] },+ });++ const found = await discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000, usOnly: true },+ logger,+ );++ expect(request.mock.calls[0][0]).toMatchObject({ usOnly: true });+ expect(found).toEqual({ skills: [], succeeded: true });+});++it("returns only the first three when Exchange sends more", async () => {+ const skills = [1, 2, 3, 4].map(n => ({+ id: `official/skill-${n}`,+ name: `Skill ${n}`,+ description: "A skill",+ source: "official" as const,+ }));+ request.mockResolvedValue({+ status: 200,+ body: { query: "records", skills },+ });++ const found = await discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000 },+ logger,+ );++ expect(found.succeeded).toBe(true);+ expect(found.skills.map(skill => skill.id)).toEqual([+ "official/skill-1",+ "official/skill-2",+ "official/skill-3",+ ]);+});++it("drops invalid cards and keeps the valid ones", async () => {+ request.mockResolvedValue({+ status: 200,+ body: {+ query: "records",+ skills: [+ { id: "", name: "Missing", description: "no", source: "official" },+ official,+ ],+ },+ });++ const cards = await discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000 },+ logger,+ );++ expect(cards.succeeded).toBe(true);+ expect(cards.skills).toHaveLength(1);+ expect(cards.skills[0].id).toBe("official/search");+ expect(logger.warn).toHaveBeenCalled();+});++it.each([400, 500])(+ "returns no cards when discover answers %s",+ async status => {+ request.mockResolvedValue({ status, body: { error: "nope" } });++ await expect(+ discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 1000 },+ logger,+ ),+ ).resolves.toEqual({ skills: [], succeeded: false });+ expect(logger.warn).toHaveBeenCalled();+ },+);++it("returns no cards when the exchange call times out", async () => {+ request.mockRejectedValue(+ Object.assign(new Error("The operation was aborted due to timeout"), {+ name: "TimeoutError",+ }),+ );++ await expect(+ discoverSkills(+ { teamId: "team", query: "records", timeoutMs: 3000 },+ logger,+ ),+ ).resolves.toEqual({ skills: [], succeeded: false });+ expect(logger.warn).toHaveBeenCalled();+});++it("returns no cards for an empty or over-long query without calling exchange", async () => {+ await expect(+ discoverSkills({ teamId: "team", query: " ", timeoutMs: 1000 }, logger),+ ).resolves.toEqual({ skills: [], succeeded: false });+ await expect(+ discoverSkills(+ { teamId: "team", query: "x".repeat(2001), timeoutMs: 1000 },+ logger,+ ),+ ).resolves.toEqual({ skills: [], succeeded: false });+ expect(request).not.toHaveBeenCalled();+});++describe("catalogue search billing gate", () => {+ it("treats skill cards as free catalogue search without making them tools-only", () => {+ expect(isFreeCatalogueSearch([{ type: "skills" }], undefined)).toBe(true);+ expect(isToolsOnlySearch([{ type: "skills" }], undefined)).toBe(false);+ expect(+ isFreeCatalogueSearch(["alexandria", { type: "skills" }], undefined),+ ).toBe(true);+ expect(+ isFreeCatalogueSearch([{ type: "web" }, { type: "skills" }], undefined),+ ).toBe(false);+ expect(isFreeCatalogueSearch(["skills"], [{ type: "developer" }])).toBe(+ false,+ );+ for (const alias of [+ "docs",+ "repo",+ "code",+ "devdex",+ "repo_search",+ "developer_index",+ ]) {+ expect(isFreeCatalogueSearch(["alexandria"], [alias])).toBe(false);+ expect(isFreeCatalogueSearch(["alexandria"], [{ type: alias }])).toBe(+ false,+ );+ }+ expect(isFreeCatalogueSearch(["alexandria"], [{ type: "gov" }])).toBe(+ false,+ );+ expect(isToolsOnlySearch(["alexandria"], undefined)).toBe(true);+ });+});diff --git a/apps/api/src/search/skill-cards.ts b/apps/api/src/search/skill-cards.tsnew file mode 100644index 000000000..d11d33cef--- /dev/null+++ b/apps/api/src/search/skill-cards.ts@@ -0,0 +1,124 @@+import { z } from "zod";+import type { Logger } from "winston";+import { exchangeRequest } from "../services/alexandria/client";++const SKILLS_SOURCE = "skills";+/** Exchange default and maximum this search asks for. The search `limit` is not forwarded. */+const SKILLS_DISCOVERY_LIMIT = 3;+/** Kept short so a slow catalogue lookup cannot hold the rest of the search. */+export const SKILLS_DISCOVERY_TIMEOUT_MS = 3000;+const MAX_QUERY_CHARS = 2000;++export const isSkillsSource = (source: { type: string }) =>+ source.type === SKILLS_SOURCE;++const skillCardSchema = z.object({+ id: z.string().min(1),+ name: z.string(),+ description: z.string(),+ source: z.enum(["official", "provider"]),+ provider: z+ .string()+ .nullish()+ .transform(value => (value ? value : undefined)),+ similarity: z.number().finite().nullish(),+});++export type SkillCard = {+ id: string;+ name: string;+ description: string;+ source: "official" | "provider";+ provider?: string;+ similarity?: number;+};++export type SkillDiscovery = {+ skills: SkillCard[];+ /** True only when Exchange returned the skill-card envelope. */+ succeeded: boolean;+};++function missed(): SkillDiscovery {+ return { skills: [], succeeded: false };+}++function toCard(value: z.infer<typeof skillCardSchema>): SkillCard {+ return {+ id: value.id,+ name: value.name,+ description: value.description,+ source: value.source,+ ...(value.provider ? { provider: value.provider } : {}),+ ...(typeof value.similarity === "number"+ ? { similarity: value.similarity }+ : {}),+ };+}++/**+ * Short skill cards for a search query. Failures, including timeouts and a+ * missing Exchange, resolve to an empty list so the rest of the search can+ * still succeed. `succeeded` is false for those paths and for a query that+ * is empty or longer than Exchange accepts. Only the query is sent.+ */+export async function discoverSkills(+ input: {+ teamId: string;+ query: string;+ timeoutMs: number;+ /** The team may only be served by US-based providers. */+ usOnly?: boolean;+ },+ logger: Logger,+): Promise<SkillDiscovery> {+ const query = input.query.trim();+ if (!query || query.length > MAX_QUERY_CHARS) return missed();+ const params = new URLSearchParams({+ q: query,+ limit: String(SKILLS_DISCOVERY_LIMIT),+ });+ try {+ const result = await exchangeRequest({+ teamId: input.teamId,+ // Skill cards. /v1/discover/skills is a different, older route.+ path: `/v1/discover/skill-cards?${params.toString()}`,+ timeoutMs: Math.max(+ 1,+ Math.min(input.timeoutMs, SKILLS_DISCOVERY_TIMEOUT_MS),+ ),+ usOnly: input.usOnly === true,+ });+ if (result.status !== 200) {+ logger.warn("Skill discovery unavailable", { status: result.status });+ return missed();+ }+ const parsed = z+ .object({+ query: z.string(),+ skills: z.array(z.unknown()),+ })+ .safeParse(result.body);+ if (!parsed.success) {+ logger.warn("Skill discovery returned an unexpected body");+ return missed();+ }+ const cards: SkillCard[] = [];+ let dropped = 0;+ for (const item of parsed.data.skills) {+ const card = skillCardSchema.safeParse(item);+ if (!card.success) {+ dropped++;+ continue;+ }+ cards.push(toCard(card.data));+ if (cards.length >= SKILLS_DISCOVERY_LIMIT) break;+ }+ if (dropped)+ logger.warn("Skill discovery dropped invalid cards", { dropped });+ return { skills: cards, succeeded: true };+ } catch (error) {+ logger.warn("Skill discovery failed", { error });+ return missed();+ }+}diff --git a/apps/api/src/services/alexandria/README.md b/apps/api/src/services/alexandria/README.mdindex 7bfcc4170..b18dce130 100644--- a/apps/api/src/services/alexandria/README.md+++ b/apps/api/src/services/alexandria/README.md@@ -17,6 +17,17 @@ Search returns contracts in `data.tools`, up to `limit` per discovery source`creditsUsed`; web results are billed as before. `domainTools: false` disablesURL matching only.+`sources` may also include `skills`. That asks Exchange+`GET /v1/discover/skill-cards` with the search query and returns up to 3 short cards+on `data.skills` (`id`, `name`, `description`, `source`, and when present+`provider` and `similarity`). It is free and uses the same access rules as+`alexandria`. A timeout, a non-200, an unexpected body, or a card that fails+validation yields `data.skills: []` without failing the search. Invalid cards+are dropped, and a response whose cards are all invalid is an empty list. A+query longer than 2000 characters skips the lookup and yields the same empty+list. The card is not the full skill; the `id` is how that skill is+loaded later. Tool discovery does not read skills from find-tools.+```json{"alexandria": {diff --git a/apps/go-sdk/models.go b/apps/go-sdk/models.goindex f459de117..b3471b9d7 100644--- a/apps/go-sdk/models.go+++ b/apps/go-sdk/models.go@@ -728,6 +728,17 @@ type SearchData struct {News []map[string]interface{} `json:"news,omitempty"`Images []map[string]interface{} `json:"images,omitempty"`Tools []DiscoveredTool `json:"tools,omitempty"`+ Skills []SkillCard `json:"skills,omitempty"`+}++// SkillCard is a short skill card from the skills search source.+type SkillCard struct {+ ID string `json:"id"`+ Name string `json:"name"`+ Description string `json:"description"`+ Source string `json:"source"`+ Provider string `json:"provider,omitempty"`+ Similarity *float64 `json:"similarity,omitempty"`}type AlexandriaCall struct {diff --git a/apps/js-sdk/firecrawl/src/v2/methods/search.ts b/apps/js-sdk/firecrawl/src/v2/methods/search.tsindex b29f8cd83..c95240ed3 100644--- a/apps/js-sdk/firecrawl/src/v2/methods/search.ts+++ b/apps/js-sdk/firecrawl/src/v2/methods/search.ts@@ -110,6 +110,7 @@ export async function search(if (data.images)out.images = transformArray<SearchResultImages>(data.images);if (data.tools) out.tools = data.tools;+ if (data.skills) out.skills = data.skills;Object.defineProperty(out, "data", {get() {const parts: string[] = [];@@ -119,9 +120,11 @@ export async function search(parts.push(`.images (${out.images.length} results)`);if (out.tools?.length)parts.push(`.tools (${out.tools.length} results)`);+ if (out.skills?.length)+ parts.push(`.skills (${out.skills.length} results)`);const available = parts.length? parts.join(", ")- : ".web, .news, .images, or .tools";+ : ".web, .news, .images, .tools, or .skills";throw new Error(`SearchData has no '.data'. Results are grouped by source: ${available}`,);diff --git a/apps/js-sdk/firecrawl/src/v2/types.ts b/apps/js-sdk/firecrawl/src/v2/types.tsindex b9ccee9d5..9dfaf597d 100644--- a/apps/js-sdk/firecrawl/src/v2/types.ts+++ b/apps/js-sdk/firecrawl/src/v2/types.ts@@ -894,6 +894,15 @@ export interface SearchResultImages {position?: number;}+export interface SkillCard {+ id: string;+ name: string;+ description: string;+ source: "official" | "provider";+ provider?: string;+ similarity?: number;+}+export interface SearchData {agent_hints?: string[];warning?: string;@@ -901,6 +910,7 @@ export interface SearchData {news?: Array<SearchResultNews | Document>;images?: Array<SearchResultImages | Document>;tools?: DiscoveredTool[];+ skills?: SkillCard[];}/** A complete tool contract returned by semantic or contextual discovery. */@@ -1062,7 +1072,8 @@ export interface SearchRequest {| "news"| "images"| "alexandria"- | { type: "web" | "news" | "images" | "alexandria" }+ | "skills"+ | { type: "web" | "news" | "images" | "alexandria" | "skills" }>;/*** Narrow web search by category. See {@link CategoryOption}.diff --git a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.pyindex 7c293128a..4565139c0 100644--- a/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py+++ b/apps/python-sdk/firecrawl/__tests__/unit/v2/methods/test_search_validation.py@@ -67,6 +67,11 @@ class TestSearchValidation:with pytest.raises(ValueError, match="Invalid source type"):_validate_search_request(request)+ request = SearchRequest(+ query="test", sources=["web", "skills"]+ )+ assert _validate_search_request(request) == request+def test_validate_categories(self):"""Test validation of search categories."""for category in ["github", "research", "pdf", "developer"]:diff --git a/apps/python-sdk/firecrawl/v2/methods/aio/search.py b/apps/python-sdk/firecrawl/v2/methods/aio/search.pyindex 28c41735d..7517ce206 100644--- a/apps/python-sdk/firecrawl/v2/methods/aio/search.py+++ b/apps/python-sdk/firecrawl/v2/methods/aio/search.py@@ -1,6 +1,7 @@from typing import Dict, Any, Union, List, TypeVar, Typefrom ...types import (DiscoveredTool,+ SkillCard,SearchRequest,SearchData,Document,@@ -51,6 +52,8 @@ async def search(out.images = _transform_array(data["images"], SearchResultImages)if "tools" in data:out.tools = [DiscoveredTool(**item) for item in data["tools"]]+ if "skills" in data:+ out.skills = [SkillCard(**item) for item in data["skills"]]return outexcept Exception as err:response = getattr(err, "response", None)@@ -114,7 +117,13 @@ def _validate_search_request(request: SearchRequest) -> SearchRequest:raise ValueError("Timeout cannot exceed 300000ms (5 minutes)")if request.sources is not None:- valid_sources = {"web", "news", "images", "alexandria"}+ valid_sources = {+ "web",+ "news",+ "images",+ "alexandria",+ "skills",+ }for source in request.sources:if isinstance(source, str):if source not in valid_sources:diff --git a/apps/python-sdk/firecrawl/v2/methods/search.py b/apps/python-sdk/firecrawl/v2/methods/search.pyindex 10fe30c7f..21c2deec4 100644--- a/apps/python-sdk/firecrawl/v2/methods/search.py+++ b/apps/python-sdk/firecrawl/v2/methods/search.py@@ -3,7 +3,7 @@ Search functionality for Firecrawl v2 API."""from typing import Dict, Any, Union, List, TypeVar, Type-from ..types import SearchRequest, SearchData, Document, SearchResultWeb, SearchResultNews, SearchResultImages, DiscoveredTool+from ..types import SearchRequest, SearchData, Document, SearchResultWeb, SearchResultNews, SearchResultImages, DiscoveredTool, SkillCardfrom ..utils.agent_hints import agent_hint_metadatafrom ..utils.normalize import normalize_document_input, _map_search_result_keysfrom ..utils import HttpClient, handle_response_error, validate_scrape_options, prepare_scrape_options@@ -45,6 +45,8 @@ def search(out.images = _transform_array(data["images"], SearchResultImages)if "tools" in data:out.tools = [DiscoveredTool(**item) for item in data["tools"]]+ if "skills" in data:+ out.skills = [SkillCard(**item) for item in data["skills"]]return outexcept Exception as err:response = getattr(err, "response", None)@@ -124,7 +126,13 @@ def _validate_search_request(request: SearchRequest) -> SearchRequest:# Validate sources (if provided)if request.sources is not None:- valid_sources = {"web", "news", "images", "alexandria"}+ valid_sources = {+ "web",+ "news",+ "images",+ "alexandria",+ "skills",+ }for source in request.sources:if isinstance(source, str):if source not in valid_sources:diff --git a/apps/python-sdk/firecrawl/v2/types.py b/apps/python-sdk/firecrawl/v2/types.pyindex 1c912b8bf..1a08084fd 100644--- a/apps/python-sdk/firecrawl/v2/types.py+++ b/apps/python-sdk/firecrawl/v2/types.py@@ -2562,6 +2562,19 @@ class LinkResult(BaseModel):SearchResult = LinkResult+class SkillCard(BaseModel):+ """Short skill card returned by the skills search source."""++ model_config = {"extra": "ignore"}++ id: str+ name: str+ description: str+ source: Literal["official", "provider"]+ provider: Optional[str] = None+ similarity: Optional[float] = None++class SearchData(BaseModel):"""Search results grouped by source type."""@@ -2571,6 +2584,7 @@ class SearchData(BaseModel):news: Optional[List[Union[SearchResultNews, Document]]] = Noneimages: Optional[List[Union[SearchResultImages, Document]]] = Nonetools: Optional[List[DiscoveredTool]] = None+ skills: Optional[List[SkillCard]] = None@propertydef data(self):@@ -2583,7 +2597,9 @@ class SearchData(BaseModel):parts.append(f".images ({len(self.images)} results)")if self.tools:parts.append(f".tools ({len(self.tools)} results)")- available = ", ".join(parts) if parts else ".web, .news, .images, or .tools"+ if self.skills:+ parts.append(f".skills ({len(self.skills)} results)")+ available = ", ".join(parts) if parts else ".web, .news, .images, .tools, or .skills"raise AttributeError(f"SearchData has no '.data'. Results are grouped by source: {available}")diff --git a/apps/rust-sdk/src/search.rs b/apps/rust-sdk/src/search.rsindex 8cad0396f..3c3a11d95 100644--- a/apps/rust-sdk/src/search.rs+++ b/apps/rust-sdk/src/search.rs@@ -18,7 +18,7 @@ pub struct SearchOptions {/// Maximum number of results to return. Default: 5, Max: 20.pub limit: Option<u32>,- /// Search sources to query (web, news, images, alexandria).+ /// Search sources to query (web, news, images, alexandria, skills).pub sources: Option<Vec<SearchSource>>,/// Enable Alexandria domain-tool discovery (send alongside `sources: ["alexandria"]`).@@ -87,6 +87,22 @@ pub struct SearchData {/// Image search results.pub images: Option<Vec<SearchResultImage>>,pub tools: Option<Vec<DiscoveredTool>>,+ /// Short skill cards. Present when `skills` was requested.+ pub skills: Option<Vec<SkillCard>>,+}++/// Short skill card returned by the `skills` search source.+#[serde_with::skip_serializing_none]+#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]+#[serde(rename_all = "camelCase")]+pub struct SkillCard {+ pub id: String,+ pub name: String,+ pub description: String,+ /// `official` or `provider`.+ pub source: String,+ pub provider: Option<String>,+ pub similarity: Option<f64>,}/// A search result that may be a simple result or a full document.diff --git a/apps/rust-sdk/src/types.rs b/apps/rust-sdk/src/types.rsindex 8595b71a3..f37d32d3d 100644--- a/apps/rust-sdk/src/types.rs+++ b/apps/rust-sdk/src/types.rs@@ -1218,6 +1218,7 @@ pub enum SearchSource {News,Images,Alexandria,+ Skills,}/// Search category types.