@youdotcom-oss/ai-sdk-plugin 2.0.7 → 2.1.0

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/README.md CHANGED
@@ -6,7 +6,7 @@ Give your AI applications **real-time access to the web** with native AI SDK too
6
6
 
7
7
  Build AI applications that can:
8
8
  - **Search the web in real-time** - Access current information with advanced filtering (dates, sites, file types)
9
- - **Generate answers with web context** - Fast AI responses enhanced with live web data
9
+ - **Research** - Comprehensive answers with cited sources, configurable effort (lite to exhaustive)
10
10
  - **Extract any webpage** - Pull full content in markdown or HTML format
11
11
  - **Zero configuration** - Works with any AI SDK model provider (Anthropic, OpenAI, Google, and more)
12
12
  - **Type-safe** - Full TypeScript support with Zod schema validation
@@ -57,7 +57,7 @@ Import the tools and add them to your AI SDK configuration:
57
57
  ```typescript
58
58
  import { createAnthropic } from '@ai-sdk/anthropic';
59
59
  import { generateText, stepCountIs } from 'ai';
60
- import { youSearch, youContents } from '@youdotcom-oss/ai-sdk-plugin';
60
+ import { youSearch, youResearch, youContents } from '@youdotcom-oss/ai-sdk-plugin';
61
61
 
62
62
  // Create your AI model provider
63
63
  const anthropic = createAnthropic({
@@ -68,6 +68,7 @@ const result = await generateText({
68
68
  model: anthropic('claude-sonnet-4-5-20250929'),
69
69
  tools: {
70
70
  search: youSearch(),
71
+ research: youResearch(),
71
72
  extract: youContents(),
72
73
  },
73
74
  stopWhen: stepCountIs(5), // Required for tool result processing
@@ -228,6 +229,15 @@ Comprehensive web and news search with advanced filtering capabilities. Perfect
228
229
  - Finding specific content with filters (dates, sites, file types)
229
230
  - Research queries requiring multiple results
230
231
 
232
+ ### youResearch()
233
+
234
+ Research with comprehensive answers and cited sources. Configurable effort levels (lite, standard, deep, exhaustive) let you trade speed for thoroughness.
235
+
236
+ **When your AI will use this:**
237
+ - Complex questions requiring in-depth analysis
238
+ - Research reports needing cited sources
239
+ - Thorough comparisons or detailed explanations
240
+
231
241
  ### youContents()
232
242
 
233
243
  Extract full page content from URLs in markdown or HTML format. Useful for documentation analysis, content processing, and batch URL extraction.
package/dist/main.d.ts CHANGED
@@ -10,27 +10,14 @@ export type YouToolsConfig = {
10
10
  * @param config - Configuration options
11
11
  * @returns A tool that can be used with AI SDK's generateText, streamText, etc.
12
12
  *
13
- * @example
14
- * ```ts
15
- * import { generateText, stepCountIs } from 'ai';
16
- * import { youSearch } from '@youdotcom-oss/ai-sdk-plugin';
17
- *
18
- * const { text } = await generateText({
19
- * model: 'anthropic/claude-sonnet-4.5',
20
- * prompt: 'What happened in San Francisco last week?',
21
- * tools: {
22
- * search: youSearch(),
23
- * },
24
- * stopWhen: stepCountIs(3),
25
- * });
26
- * ```
13
+ * @public
27
14
  */
28
15
  export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
29
16
  query: string;
30
17
  count?: number | undefined;
31
18
  freshness?: string | undefined;
32
19
  offset?: number | undefined;
33
- country?: "AR" | "CA" | "NL" | "FI" | "FR" | "DE" | "IT" | "JP" | "PL" | "PT-BR" | "RU" | "ES" | "TR" | "AU" | "AT" | "BE" | "BR" | "CL" | "DK" | "HK" | "IN" | "ID" | "KR" | "MY" | "MX" | "NZ" | "NO" | "CN" | "PT" | "PH" | "SA" | "ZA" | "SE" | "CH" | "TW" | "GB" | "US" | undefined;
20
+ country?: "AR" | "CA" | "NL" | "FI" | "FR" | "DE" | "IT" | "JP" | "PL" | "RU" | "ES" | "TR" | "AU" | "AT" | "BE" | "BR" | "CL" | "DK" | "HK" | "IN" | "ID" | "KR" | "MY" | "MX" | "NZ" | "NO" | "CN" | "PT" | "PH" | "SA" | "ZA" | "SE" | "CH" | "TW" | "GB" | "US" | undefined;
34
21
  safesearch?: "off" | "moderate" | "strict" | undefined;
35
22
  livecrawl?: "web" | "news" | "all" | undefined;
36
23
  livecrawl_formats?: "markdown" | "html" | undefined;
@@ -68,6 +55,30 @@ export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
68
55
  latency?: number | undefined;
69
56
  };
70
57
  }>;
58
+ /**
59
+ * You.com research tool for Vercel AI SDK
60
+ *
61
+ * Perform research with cited sources and configurable effort (lite, standard, deep, exhaustive).
62
+ *
63
+ * @param config - Configuration options
64
+ * @returns A tool that can be used with AI SDK's generateText, streamText, etc.
65
+ *
66
+ * @public
67
+ */
68
+ export declare const youResearch: (config?: YouToolsConfig) => import("ai").Tool<{
69
+ input: string;
70
+ research_effort: "lite" | "standard" | "deep" | "exhaustive";
71
+ }, {
72
+ output: {
73
+ content: string;
74
+ content_type: "text";
75
+ sources: {
76
+ url: string;
77
+ snippets: string[];
78
+ title?: string | undefined;
79
+ }[];
80
+ };
81
+ }>;
71
82
  /**
72
83
  * You.com content extraction tool for Vercel AI SDK
73
84
  *
@@ -76,20 +87,7 @@ export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
76
87
  * @param config - Configuration options
77
88
  * @returns A tool that can be used with AI SDK's generateText, streamText, etc.
78
89
  *
79
- * @example
80
- * ```ts
81
- * import { generateText, stepCountIs } from 'ai';
82
- * import { youContents } from '@youdotcom-oss/ai-sdk-plugin';
83
- *
84
- * const { text } = await generateText({
85
- * model: 'anthropic/claude-sonnet-4.5',
86
- * prompt: 'Summarize the content from vercel.com/blog',
87
- * tools: {
88
- * extract: youContents(),
89
- * },
90
- * stopWhen: stepCountIs(3),
91
- * });
92
- * ```
90
+ * @public
93
91
  */
94
92
  export declare const youContents: (config?: YouToolsConfig) => import("ai").Tool<{
95
93
  urls: string[];
package/dist/main.js CHANGED
@@ -1,11 +1,15 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
2
6
  var __export = (target, all) => {
3
7
  for (var name in all)
4
8
  __defProp(target, name, {
5
9
  get: all[name],
6
10
  enumerable: true,
7
11
  configurable: true,
8
- set: (newValue) => all[name] = () => newValue
12
+ set: __exportSetter.bind(all, name)
9
13
  });
10
14
  };
11
15
 
@@ -13568,7 +13572,7 @@ var ContentsItemSchema = object({
13568
13572
  var ContentsApiResponseSchema = array(ContentsItemSchema);
13569
13573
  // ../api/src/shared/api.constants.ts
13570
13574
  var SEARCH_API_URL = process.env.YDC_SEARCH_API_URL || "https://api.you.com/v1/agents/search";
13571
- var DEEP_SEARCH_API_URL = process.env.YDC_DEEP_SEARCH_API_URL || "https://api.you.com/v1/deep_search";
13575
+ var RESEARCH_API_URL = process.env.YDC_RESEARCH_API_URL || "https://api.you.com/v1/research";
13572
13576
  var CONTENTS_API_URL = process.env.YDC_CONTENTS_API_URL || "https://ydc-index.io/v1/contents";
13573
13577
 
13574
13578
  // ../api/src/shared/check-response-for-errors.ts
@@ -13635,21 +13639,58 @@ var fetchContents = async ({
13635
13639
  const parsedResults = ContentsApiResponseSchema.parse(results);
13636
13640
  return parsedResults;
13637
13641
  };
13638
- // ../api/src/deep-search/deep-search.schemas.ts
13639
- var SearchEffortSchema = _enum2(["low", "medium", "high"]).describe("Search effort level");
13640
- var DeepSearchQuerySchema = object({
13641
- query: string2().min(1, "Query is required").describe("The research question or complex query requiring in-depth investigation and multi-step reasoning"),
13642
- search_effort: SearchEffortSchema.optional().default("medium").describe("Computation budget: low (<30s), medium (<60s, default), high (<300s)")
13642
+ // ../api/src/research/research.schemas.ts
13643
+ var ResearchEffortSchema = _enum2(["lite", "standard", "deep", "exhaustive"]).describe("Controls how much time and effort the Research API spends on your question. Higher effort levels run more searches and dig deeper into sources, at the cost of a longer response time.");
13644
+ var ResearchQuerySchema = object({
13645
+ input: string2().min(1, "Input is required").describe("The research question or complex query requiring in-depth investigation and multi-step reasoning. Maximum length: 40,000 characters."),
13646
+ research_effort: ResearchEffortSchema.optional().default("standard").describe("Controls how much time and effort the Research API spends on your question. lite: fast answers, standard: balanced (default), deep: thorough, exhaustive: most comprehensive.")
13643
13647
  });
13644
- var DeepSearchSourceSchema = object({
13648
+ var ResearchSourceSchema = object({
13645
13649
  url: string2().describe("Source webpage URL"),
13646
- title: string2().describe("Source webpage title"),
13650
+ title: string2().optional().describe("Source webpage title"),
13647
13651
  snippets: array(string2()).describe("Relevant excerpts from the source page used in generating the answer")
13648
13652
  });
13649
- var DeepSearchResponseSchema = object({
13650
- answer: string2().describe("Comprehensive response with inline citations, formatted in Markdown"),
13651
- results: array(DeepSearchSourceSchema).describe("List of web sources used to generate the answer")
13653
+ var ResearchOutputSchema = object({
13654
+ content: string2().describe("Comprehensive response with inline citations, formatted in Markdown"),
13655
+ content_type: _enum2(["text"]).describe("The format of the content field"),
13656
+ sources: array(ResearchSourceSchema).describe("List of web sources used to generate the answer")
13657
+ });
13658
+ var ResearchResponseSchema = object({
13659
+ output: ResearchOutputSchema.describe("The research output containing the answer and sources")
13652
13660
  });
13661
+ // ../api/src/research/research.utils.ts
13662
+ var callResearch = async ({
13663
+ researchQuery,
13664
+ YDC_API_KEY = process.env.YDC_API_KEY,
13665
+ getUserAgent
13666
+ }) => {
13667
+ if (!YDC_API_KEY) {
13668
+ throw new Error("YDC_API_KEY is required for Research API");
13669
+ }
13670
+ const response = await fetch(RESEARCH_API_URL, {
13671
+ method: "POST",
13672
+ headers: new Headers({
13673
+ "X-API-Key": YDC_API_KEY,
13674
+ "Content-Type": "application/json",
13675
+ "User-Agent": getUserAgent()
13676
+ }),
13677
+ body: JSON.stringify(researchQuery)
13678
+ });
13679
+ if (!response.ok) {
13680
+ const errorCode = response.status;
13681
+ if (errorCode === 429) {
13682
+ throw new Error("Rate limited by You.com API. Please try again later.");
13683
+ } else if (errorCode === 403) {
13684
+ throw new Error("Forbidden. Please check your You.com API key.");
13685
+ } else if (errorCode === 402) {
13686
+ throw new Error("Free tier limit exceeded. Please upgrade at: https://you.com/platform");
13687
+ }
13688
+ throw new Error(`Research API request failed. Error code: ${errorCode}`);
13689
+ }
13690
+ const data = await response.json();
13691
+ checkResponseForErrors(data);
13692
+ return ResearchResponseSchema.parse(data);
13693
+ };
13653
13694
  // ../api/src/search/search.schemas.ts
13654
13695
  var LanguageSchema = _enum2([
13655
13696
  "AR",
@@ -13735,7 +13776,6 @@ var SearchQuerySchema = object({
13735
13776
  "CN",
13736
13777
  "PL",
13737
13778
  "PT",
13738
- "PT-BR",
13739
13779
  "PH",
13740
13780
  "RU",
13741
13781
  "SA",
@@ -13860,7 +13900,7 @@ import { tool } from "ai";
13860
13900
  // package.json
13861
13901
  var package_default = {
13862
13902
  name: "@youdotcom-oss/ai-sdk-plugin",
13863
- version: "2.0.7",
13903
+ version: "2.1.0",
13864
13904
  description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
13865
13905
  license: "MIT",
13866
13906
  engines: {
@@ -13922,7 +13962,7 @@ var package_default = {
13922
13962
  },
13923
13963
  types: "./dist/main.d.ts",
13924
13964
  dependencies: {
13925
- "@youdotcom-oss/api": "0.3.4"
13965
+ "@youdotcom-oss/api": "0.4.0"
13926
13966
  },
13927
13967
  peerDependencies: {
13928
13968
  ai: "^6.0.83"
@@ -13953,6 +13993,24 @@ var youSearch = (config2 = {}) => {
13953
13993
  }
13954
13994
  });
13955
13995
  };
13996
+ var youResearch = (config2 = {}) => {
13997
+ const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
13998
+ return tool({
13999
+ description: "Research a topic with comprehensive answers and cited sources using You.com. Supports configurable effort levels (lite, standard, deep, exhaustive). Returns a detailed answer with inline citations and a list of sources. Use this when you need thorough, well-researched answers to complex questions.",
14000
+ inputSchema: ResearchQuerySchema,
14001
+ execute: async (params) => {
14002
+ if (!apiKey) {
14003
+ throw new Error("YDC_API_KEY is required. Set it in environment variables or pass it in config.");
14004
+ }
14005
+ const response = await callResearch({
14006
+ researchQuery: params,
14007
+ YDC_API_KEY: apiKey,
14008
+ getUserAgent
14009
+ });
14010
+ return response;
14011
+ }
14012
+ });
14013
+ };
13956
14014
  var youContents = (config2 = {}) => {
13957
14015
  const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
13958
14016
  return tool({
@@ -13973,5 +14031,6 @@ var youContents = (config2 = {}) => {
13973
14031
  };
13974
14032
  export {
13975
14033
  youSearch,
14034
+ youResearch,
13976
14035
  youContents
13977
14036
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdotcom-oss/ai-sdk-plugin",
3
- "version": "2.0.7",
3
+ "version": "2.1.0",
4
4
  "description": "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "types": "./dist/main.d.ts",
64
64
  "dependencies": {
65
- "@youdotcom-oss/api": "0.3.4"
65
+ "@youdotcom-oss/api": "0.4.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "ai": "^6.0.83"