@youdotcom-oss/ai-sdk-plugin 1.0.3 → 2.0.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
@@ -42,7 +42,7 @@ Import the tools and add them to your AI SDK configuration:
42
42
  ```typescript
43
43
  import { createAnthropic } from '@ai-sdk/anthropic';
44
44
  import { generateText } from 'ai';
45
- import { youSearch, youExpress, youContents } from '@youdotcom-oss/ai-sdk-plugin';
45
+ import { youSearch, youContents } from '@youdotcom-oss/ai-sdk-plugin';
46
46
 
47
47
  // Create your AI model provider
48
48
  const anthropic = createAnthropic({
@@ -53,7 +53,6 @@ const result = await generateText({
53
53
  model: anthropic('claude-sonnet-4-5-20250929'),
54
54
  tools: {
55
55
  search: youSearch(),
56
- agent: youExpress(),
57
56
  extract: youContents(),
58
57
  },
59
58
  maxSteps: 5,
@@ -209,15 +208,6 @@ Comprehensive web and news search with advanced filtering capabilities. Perfect
209
208
  - Finding specific content with filters (dates, sites, file types)
210
209
  - Research queries requiring multiple results
211
210
 
212
- ### youExpress()
213
-
214
- Fast AI-powered agent that provides synthesized answers with optional real-time web search. Ideal for straightforward questions that benefit from AI interpretation.
215
-
216
- **When your AI will use this:**
217
- - Direct questions needing quick answers
218
- - Queries benefiting from AI synthesis
219
- - Requests for explanations or summaries with web context
220
-
221
211
  ### youContents()
222
212
 
223
213
  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
@@ -30,13 +30,8 @@ export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
30
30
  count?: number | undefined;
31
31
  freshness?: string | undefined;
32
32
  offset?: number | undefined;
33
- country?: "AR" | "AU" | "AT" | "BE" | "BR" | "CA" | "CL" | "DK" | "FI" | "FR" | "DE" | "HK" | "IN" | "ID" | "IT" | "JP" | "KR" | "MY" | "MX" | "NL" | "NZ" | "NO" | "CN" | "PL" | "PT" | "PH" | "RU" | "SA" | "ZA" | "ES" | "SE" | "CH" | "TW" | "TR" | "GB" | "US" | 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;
34
34
  safesearch?: "off" | "moderate" | "strict" | undefined;
35
- site?: string | undefined;
36
- fileType?: string | undefined;
37
- language?: string | undefined;
38
- excludeTerms?: string | undefined;
39
- exactTerms?: string | undefined;
40
35
  livecrawl?: "web" | "news" | "all" | undefined;
41
36
  livecrawl_formats?: "markdown" | "html" | undefined;
42
37
  }, {
@@ -73,45 +68,6 @@ export declare const youSearch: (config?: YouToolsConfig) => import("ai").Tool<{
73
68
  latency?: number | undefined;
74
69
  };
75
70
  }>;
76
- /**
77
- * You.com AI agent tool for Vercel AI SDK
78
- *
79
- * Fast AI responses with optional web search integration.
80
- *
81
- * @param config - Configuration options
82
- * @returns A tool that can be used with AI SDK's generateText, streamText, etc.
83
- *
84
- * @example
85
- * ```ts
86
- * import { generateText, stepCountIs } from 'ai';
87
- * import { youExpress } from '@youdotcom-oss/ai-sdk-plugin';
88
- *
89
- * const { text } = await generateText({
90
- * model: 'anthropic/claude-sonnet-4.5',
91
- * prompt: 'What are the latest AI developments?',
92
- * tools: {
93
- * agent: youExpress(),
94
- * },
95
- * stopWhen: stepCountIs(3),
96
- * });
97
- * ```
98
- */
99
- export declare const youExpress: (config?: YouToolsConfig) => import("ai").Tool<{
100
- input: string;
101
- tools?: {
102
- type: "web_search";
103
- }[] | undefined;
104
- }, {
105
- answer: string;
106
- results?: {
107
- web: {
108
- url: string;
109
- title: string;
110
- snippet: string;
111
- }[];
112
- } | undefined;
113
- agent?: string | undefined;
114
- }>;
115
71
  /**
116
72
  * You.com content extraction tool for Vercel AI SDK
117
73
  *
@@ -143,11 +99,10 @@ export declare const youContents: (config?: YouToolsConfig) => import("ai").Tool
143
99
  }, {
144
100
  url: string;
145
101
  title?: string | undefined;
146
- html?: string | undefined;
147
- markdown?: string | undefined;
102
+ html?: string | null | undefined;
103
+ markdown?: string | null | undefined;
148
104
  metadata?: {
149
- jsonld?: Record<string, unknown>[] | undefined;
150
- opengraph?: Record<string, string> | undefined;
151
- twitter?: Record<string, string> | undefined;
152
- } | undefined;
105
+ favicon_url: string;
106
+ site_name?: string | null | undefined;
107
+ } | null | undefined;
153
108
  }[]>;
package/dist/main.js CHANGED
@@ -2264,114 +2264,6 @@ function handleIntersectionResults(result, left, right) {
2264
2264
  result.value = merged.data;
2265
2265
  return result;
2266
2266
  }
2267
- var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2268
- $ZodType.init(inst, def);
2269
- inst._zod.parse = (payload, ctx) => {
2270
- const input = payload.value;
2271
- if (!isPlainObject(input)) {
2272
- payload.issues.push({
2273
- expected: "record",
2274
- code: "invalid_type",
2275
- input,
2276
- inst
2277
- });
2278
- return payload;
2279
- }
2280
- const proms = [];
2281
- const values = def.keyType._zod.values;
2282
- if (values) {
2283
- payload.value = {};
2284
- const recordKeys = new Set;
2285
- for (const key of values) {
2286
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2287
- recordKeys.add(typeof key === "number" ? key.toString() : key);
2288
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2289
- if (result instanceof Promise) {
2290
- proms.push(result.then((result2) => {
2291
- if (result2.issues.length) {
2292
- payload.issues.push(...prefixIssues(key, result2.issues));
2293
- }
2294
- payload.value[key] = result2.value;
2295
- }));
2296
- } else {
2297
- if (result.issues.length) {
2298
- payload.issues.push(...prefixIssues(key, result.issues));
2299
- }
2300
- payload.value[key] = result.value;
2301
- }
2302
- }
2303
- }
2304
- let unrecognized;
2305
- for (const key in input) {
2306
- if (!recordKeys.has(key)) {
2307
- unrecognized = unrecognized ?? [];
2308
- unrecognized.push(key);
2309
- }
2310
- }
2311
- if (unrecognized && unrecognized.length > 0) {
2312
- payload.issues.push({
2313
- code: "unrecognized_keys",
2314
- input,
2315
- inst,
2316
- keys: unrecognized
2317
- });
2318
- }
2319
- } else {
2320
- payload.value = {};
2321
- for (const key of Reflect.ownKeys(input)) {
2322
- if (key === "__proto__")
2323
- continue;
2324
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2325
- if (keyResult instanceof Promise) {
2326
- throw new Error("Async schemas not supported in object keys currently");
2327
- }
2328
- const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
2329
- if (checkNumericKey) {
2330
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2331
- if (retryResult instanceof Promise) {
2332
- throw new Error("Async schemas not supported in object keys currently");
2333
- }
2334
- if (retryResult.issues.length === 0) {
2335
- keyResult = retryResult;
2336
- }
2337
- }
2338
- if (keyResult.issues.length) {
2339
- if (def.mode === "loose") {
2340
- payload.value[key] = input[key];
2341
- } else {
2342
- payload.issues.push({
2343
- code: "invalid_key",
2344
- origin: "record",
2345
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2346
- input: key,
2347
- path: [key],
2348
- inst
2349
- });
2350
- }
2351
- continue;
2352
- }
2353
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2354
- if (result instanceof Promise) {
2355
- proms.push(result.then((result2) => {
2356
- if (result2.issues.length) {
2357
- payload.issues.push(...prefixIssues(key, result2.issues));
2358
- }
2359
- payload.value[keyResult.value] = result2.value;
2360
- }));
2361
- } else {
2362
- if (result.issues.length) {
2363
- payload.issues.push(...prefixIssues(key, result.issues));
2364
- }
2365
- payload.value[keyResult.value] = result.value;
2366
- }
2367
- }
2368
- }
2369
- if (proms.length) {
2370
- return Promise.all(proms).then(() => payload);
2371
- }
2372
- return payload;
2373
- };
2374
- });
2375
2267
  var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2376
2268
  $ZodType.init(inst, def);
2377
2269
  const values = getEnumValues(def.entries);
@@ -2392,28 +2284,6 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2392
2284
  return payload;
2393
2285
  };
2394
2286
  });
2395
- var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2396
- $ZodType.init(inst, def);
2397
- if (def.values.length === 0) {
2398
- throw new Error("Cannot create literal schema with no valid values");
2399
- }
2400
- const values = new Set(def.values);
2401
- inst._zod.values = values;
2402
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2403
- inst._zod.parse = (payload, _ctx) => {
2404
- const input = payload.value;
2405
- if (values.has(input)) {
2406
- return payload;
2407
- }
2408
- payload.issues.push({
2409
- code: "invalid_value",
2410
- values: def.values,
2411
- input,
2412
- inst
2413
- });
2414
- return payload;
2415
- };
2416
- });
2417
2287
  var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2418
2288
  $ZodType.init(inst, def);
2419
2289
  inst._zod.parse = (payload, ctx) => {
@@ -3608,44 +3478,6 @@ var enumProcessor = (schema, _ctx, json, _params) => {
3608
3478
  json.type = "string";
3609
3479
  json.enum = values;
3610
3480
  };
3611
- var literalProcessor = (schema, ctx, json, _params) => {
3612
- const def = schema._zod.def;
3613
- const vals = [];
3614
- for (const val of def.values) {
3615
- if (val === undefined) {
3616
- if (ctx.unrepresentable === "throw") {
3617
- throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3618
- } else {}
3619
- } else if (typeof val === "bigint") {
3620
- if (ctx.unrepresentable === "throw") {
3621
- throw new Error("BigInt literals cannot be represented in JSON Schema");
3622
- } else {
3623
- vals.push(Number(val));
3624
- }
3625
- } else {
3626
- vals.push(val);
3627
- }
3628
- }
3629
- if (vals.length === 0) {} else if (vals.length === 1) {
3630
- const val = vals[0];
3631
- json.type = val === null ? "null" : typeof val;
3632
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3633
- json.enum = [val];
3634
- } else {
3635
- json.const = val;
3636
- }
3637
- } else {
3638
- if (vals.every((v) => typeof v === "number"))
3639
- json.type = "number";
3640
- if (vals.every((v) => typeof v === "string"))
3641
- json.type = "string";
3642
- if (vals.every((v) => typeof v === "boolean"))
3643
- json.type = "boolean";
3644
- if (vals.every((v) => v === null))
3645
- json.type = "null";
3646
- json.enum = vals;
3647
- }
3648
- };
3649
3481
  var customProcessor = (_schema, ctx, _json, _params) => {
3650
3482
  if (ctx.unrepresentable === "throw") {
3651
3483
  throw new Error("Custom types cannot be represented in JSON Schema");
@@ -3733,42 +3565,6 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3733
3565
  ];
3734
3566
  json.allOf = allOf;
3735
3567
  };
3736
- var recordProcessor = (schema, ctx, _json, params) => {
3737
- const json = _json;
3738
- const def = schema._zod.def;
3739
- json.type = "object";
3740
- const keyType = def.keyType;
3741
- const keyBag = keyType._zod.bag;
3742
- const patterns = keyBag?.patterns;
3743
- if (def.mode === "loose" && patterns && patterns.size > 0) {
3744
- const valueSchema = process2(def.valueType, ctx, {
3745
- ...params,
3746
- path: [...params.path, "patternProperties", "*"]
3747
- });
3748
- json.patternProperties = {};
3749
- for (const pattern of patterns) {
3750
- json.patternProperties[pattern.source] = valueSchema;
3751
- }
3752
- } else {
3753
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
3754
- json.propertyNames = process2(def.keyType, ctx, {
3755
- ...params,
3756
- path: [...params.path, "propertyNames"]
3757
- });
3758
- }
3759
- json.additionalProperties = process2(def.valueType, ctx, {
3760
- ...params,
3761
- path: [...params.path, "additionalProperties"]
3762
- });
3763
- }
3764
- const keyValues = keyType._zod.values;
3765
- if (keyValues) {
3766
- const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3767
- if (validKeyValues.length > 0) {
3768
- json.required = validKeyValues;
3769
- }
3770
- }
3771
- };
3772
3568
  var nullableProcessor = (schema, ctx, json, params) => {
3773
3569
  const def = schema._zod.def;
3774
3570
  const inner = process2(def.innerType, ctx, params);
@@ -4259,21 +4055,6 @@ function intersection(left, right) {
4259
4055
  right
4260
4056
  });
4261
4057
  }
4262
- var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4263
- $ZodRecord.init(inst, def);
4264
- ZodType.init(inst, def);
4265
- inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4266
- inst.keyType = def.keyType;
4267
- inst.valueType = def.valueType;
4268
- });
4269
- function record(keyType, valueType, params) {
4270
- return new ZodRecord({
4271
- type: "record",
4272
- keyType,
4273
- valueType,
4274
- ...exports_util.normalizeParams(params)
4275
- });
4276
- }
4277
4058
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4278
4059
  $ZodEnum.init(inst, def);
4279
4060
  ZodType.init(inst, def);
@@ -4320,27 +4101,6 @@ function _enum(values, params) {
4320
4101
  ...exports_util.normalizeParams(params)
4321
4102
  });
4322
4103
  }
4323
- var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4324
- $ZodLiteral.init(inst, def);
4325
- ZodType.init(inst, def);
4326
- inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4327
- inst.values = new Set(def.values);
4328
- Object.defineProperty(inst, "value", {
4329
- get() {
4330
- if (def.values.length > 1) {
4331
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4332
- }
4333
- return def.values[0];
4334
- }
4335
- });
4336
- });
4337
- function literal(value, params) {
4338
- return new ZodLiteral({
4339
- type: "literal",
4340
- values: Array.isArray(value) ? value : [value],
4341
- ...exports_util.normalizeParams(params)
4342
- });
4343
- }
4344
4104
  var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4345
4105
  $ZodTransform.init(inst, def);
4346
4106
  ZodType.init(inst, def);
@@ -4520,19 +4280,17 @@ var ContentsQuerySchema = object({
4520
4280
  });
4521
4281
  var ContentsItemSchema = object({
4522
4282
  url: string2().describe("URL"),
4523
- title: string2().optional().describe("Title"),
4524
- html: string2().optional().describe("HTML content"),
4525
- markdown: string2().optional().describe("Markdown content"),
4283
+ title: string2().optional().describe("Title (optional in actual API responses)"),
4284
+ html: string2().nullable().optional().describe("HTML content"),
4285
+ markdown: string2().nullable().optional().describe("Markdown content"),
4526
4286
  metadata: object({
4527
- jsonld: array(record(string2(), unknown())).optional().describe("JSON-LD structured data (Schema.org)"),
4528
- opengraph: record(string2(), string2()).optional().describe("OpenGraph meta tags"),
4529
- twitter: record(string2(), string2()).optional().describe("Twitter Card metadata")
4530
- }).optional().describe("Structured metadata when available")
4287
+ site_name: string2().nullable().optional().describe("OpenGraph site name"),
4288
+ favicon_url: string2().describe("Favicon URL")
4289
+ }).nullable().optional().describe("Page metadata (only when metadata format requested)")
4531
4290
  });
4532
4291
  var ContentsApiResponseSchema = array(ContentsItemSchema);
4533
4292
  // ../api/src/shared/api.constants.ts
4534
4293
  var SEARCH_API_URL = "https://ydc-index.io/v1/search";
4535
- var EXPRESS_API_URL = "https://api.you.com/v1/agents/runs";
4536
4294
  var CONTENTS_API_URL = "https://ydc-index.io/v1/contents";
4537
4295
 
4538
4296
  // ../api/src/shared/check-response-for-errors.ts
@@ -4599,122 +4357,77 @@ var fetchContents = async ({
4599
4357
  const parsedResults = ContentsApiResponseSchema.parse(results);
4600
4358
  return parsedResults;
4601
4359
  };
4602
- // ../api/src/express/express.schemas.ts
4603
- var ExpressAgentInputSchema = object({
4604
- input: string2().min(1, "Input is required").describe("Query or prompt"),
4605
- tools: array(object({
4606
- type: _enum(["web_search"]).describe("Tool type")
4607
- })).optional().describe("Tools (web search only)")
4360
+ // ../api/src/deep-search/deep-search.schemas.ts
4361
+ var SearchEffortSchema = _enum(["low", "medium", "high"]).describe("Search effort level");
4362
+ var DeepSearchQuerySchema = object({
4363
+ query: string2().min(1, "Query is required").describe("The research question or complex query requiring in-depth investigation and multi-step reasoning"),
4364
+ search_effort: SearchEffortSchema.optional().default("medium").describe("Computation budget: low (<30s), medium (<60s, default), high (<300s)")
4608
4365
  });
4609
- var ApiSearchResultItemSchema = object({
4610
- source_type: string2().nullable().optional(),
4611
- citation_uri: string2().optional(),
4612
- url: string2(),
4613
- title: string2(),
4614
- snippet: string2(),
4615
- thumbnail_url: string2().nullable().optional(),
4616
- provider: string2().nullable().optional()
4366
+ var DeepSearchSourceSchema = object({
4367
+ url: string2().describe("Source webpage URL"),
4368
+ title: string2().describe("Source webpage title"),
4369
+ snippets: array(string2()).describe("Relevant excerpts from the source page used in generating the answer")
4617
4370
  });
4618
- var ExpressAgentApiOutputItemSchema = union([
4619
- object({
4620
- type: literal("web_search.results"),
4621
- content: array(ApiSearchResultItemSchema)
4622
- }),
4623
- object({
4624
- type: literal("message.answer"),
4625
- text: string2()
4626
- })
4627
- ]);
4628
- var ExpressAgentApiResponseSchema = object({
4629
- output: array(ExpressAgentApiOutputItemSchema),
4630
- agent: string2().optional().describe("Agent identifier"),
4631
- mode: string2().optional().describe("Agent mode"),
4632
- input: array(object({
4633
- role: _enum(["user"]).describe("User role"),
4634
- content: string2().describe("User question")
4635
- })).optional().describe("Input messages")
4636
- }).passthrough();
4637
- var McpSearchResultItemSchema = object({
4638
- url: string2().describe("URL"),
4639
- title: string2().describe("Title"),
4640
- snippet: string2().describe("Snippet")
4371
+ var DeepSearchResponseSchema = object({
4372
+ answer: string2().describe("Comprehensive response with inline citations, formatted in Markdown"),
4373
+ results: array(DeepSearchSourceSchema).describe("List of web sources used to generate the answer")
4641
4374
  });
4642
- var ExpressAgentMcpResponseSchema = object({
4643
- answer: string2().describe("AI answer"),
4644
- results: object({
4645
- web: array(McpSearchResultItemSchema).describe("Web results")
4646
- }).optional().describe("Search results"),
4647
- agent: string2().optional().describe("Agent ID")
4648
- });
4649
- // ../api/src/express/express.utils.ts
4650
- var agentThrowOnFailedStatus = async (response) => {
4651
- const errorCode = response.status;
4652
- const errorData = await response.json();
4653
- if (errorCode === 400) {
4654
- throw new Error(`Bad Request:
4655
- ${JSON.stringify(errorData)}`);
4656
- } else if (errorCode === 401) {
4657
- throw new Error(`Unauthorized: The Agent APIs require a valid You.com API key with agent access. Ensure your YDC_API_KEY has permissions for agent endpoints.`);
4658
- } else if (errorCode === 403) {
4659
- throw new Error(`Forbidden: You are not allowed to use the requested tool for this agent or tenant`);
4660
- } else if (errorCode === 429) {
4661
- throw new Error("Rate limited by You.com API. Please try again later.");
4662
- }
4663
- throw new Error(`Failed to call agent. Error code: ${errorCode}`);
4664
- };
4665
- var callExpressAgent = async ({
4666
- YDC_API_KEY = process.env.YDC_API_KEY,
4667
- agentInput: { input, tools },
4668
- getUserAgent
4669
- }) => {
4670
- const requestBody = {
4671
- agent: "express",
4672
- input,
4673
- stream: false
4674
- };
4675
- if (tools) {
4676
- requestBody.tools = tools;
4677
- }
4678
- const options = {
4679
- method: "POST",
4680
- headers: new Headers({
4681
- Authorization: `Bearer ${YDC_API_KEY || ""}`,
4682
- "Content-Type": "application/json",
4683
- Accept: "application/json",
4684
- "User-Agent": getUserAgent()
4685
- }),
4686
- body: JSON.stringify(requestBody)
4687
- };
4688
- const response = await fetch(EXPRESS_API_URL, options);
4689
- if (!response.ok) {
4690
- await agentThrowOnFailedStatus(response);
4691
- }
4692
- const jsonResponse = await response.json();
4693
- checkResponseForErrors(jsonResponse);
4694
- const apiResponse = ExpressAgentApiResponseSchema.parse(jsonResponse);
4695
- const answerItem = apiResponse.output.find((item) => item.type === "message.answer");
4696
- if (!answerItem) {
4697
- throw new Error("Express API response missing required message.answer item");
4698
- }
4699
- const searchItem = apiResponse.output.find((item) => item.type === "web_search.results");
4700
- const mcpResponse = {
4701
- answer: answerItem.text,
4702
- agent: apiResponse.agent
4703
- };
4704
- if (searchItem && "content" in searchItem && Array.isArray(searchItem.content)) {
4705
- mcpResponse.results = {
4706
- web: searchItem.content.map((item) => ({
4707
- url: item.url || item.citation_uri || "",
4708
- title: item.title || "",
4709
- snippet: item.snippet || ""
4710
- }))
4711
- };
4712
- }
4713
- return mcpResponse;
4714
- };
4715
4375
  // ../api/src/search/search.schemas.ts
4376
+ var LanguageSchema = _enum([
4377
+ "AR",
4378
+ "EU",
4379
+ "BN",
4380
+ "BG",
4381
+ "CA",
4382
+ "ZH-HANS",
4383
+ "ZH-HANT",
4384
+ "HR",
4385
+ "CS",
4386
+ "DA",
4387
+ "NL",
4388
+ "EN",
4389
+ "EN-GB",
4390
+ "ET",
4391
+ "FI",
4392
+ "FR",
4393
+ "GL",
4394
+ "DE",
4395
+ "EL",
4396
+ "GU",
4397
+ "HE",
4398
+ "HI",
4399
+ "HU",
4400
+ "IS",
4401
+ "IT",
4402
+ "JP",
4403
+ "KN",
4404
+ "KO",
4405
+ "LV",
4406
+ "LT",
4407
+ "MS",
4408
+ "ML",
4409
+ "MR",
4410
+ "NB",
4411
+ "PL",
4412
+ "PT-BR",
4413
+ "PT-PT",
4414
+ "PA",
4415
+ "RO",
4416
+ "RU",
4417
+ "SR",
4418
+ "SK",
4419
+ "SL",
4420
+ "ES",
4421
+ "SV",
4422
+ "TA",
4423
+ "TE",
4424
+ "TH",
4425
+ "TR",
4426
+ "UK",
4427
+ "VI"
4428
+ ]);
4716
4429
  var SearchQuerySchema = object({
4717
- query: string2().min(1, "Query is required").describe("Search query (supports +, -, site:, filetype:, lang:)"),
4430
+ query: string2().min(1, "Query is required").describe('Search query. Supports operators: site:domain.com (domain filter), filetype:pdf (file type), +term (include), -term (exclude), AND/OR/NOT (boolean logic), lang:en (language). Example: "machine learning (Python OR PyTorch) -TensorFlow filetype:pdf"'),
4718
4431
  count: number2().int().min(1).max(100).optional().describe("Max results per section"),
4719
4432
  freshness: string2().optional().describe("day/week/month/year or YYYY-MM-DDtoYYYY-MM-DD"),
4720
4433
  offset: number2().int().min(0).max(9).optional().describe("Pagination offset"),
@@ -4744,6 +4457,7 @@ var SearchQuerySchema = object({
4744
4457
  "CN",
4745
4458
  "PL",
4746
4459
  "PT",
4460
+ "PT-BR",
4747
4461
  "PH",
4748
4462
  "RU",
4749
4463
  "SA",
@@ -4757,11 +4471,6 @@ var SearchQuerySchema = object({
4757
4471
  "US"
4758
4472
  ]).optional().describe("Country code"),
4759
4473
  safesearch: _enum(["off", "moderate", "strict"]).optional().describe("Filter level"),
4760
- site: string2().optional().describe("Specific domain"),
4761
- fileType: string2().optional().describe("File type"),
4762
- language: string2().optional().describe("ISO 639-1 language code"),
4763
- excludeTerms: string2().optional().describe("Terms to exclude (pipe-separated)"),
4764
- exactTerms: string2().optional().describe("Exact terms (pipe-separated)"),
4765
4474
  livecrawl: _enum(["web", "news", "all"]).optional().describe("Live-crawl sections for full content"),
4766
4475
  livecrawl_formats: _enum(["html", "markdown"]).optional().describe("Format for crawled content")
4767
4476
  });
@@ -4805,24 +4514,15 @@ var SearchResponseSchema = object({
4805
4514
  // ../api/src/search/search.utils.ts
4806
4515
  var fetchSearchResults = async ({
4807
4516
  YDC_API_KEY = process.env.YDC_API_KEY,
4808
- searchQuery: { query, site, fileType, language, exactTerms, excludeTerms, ...rest },
4517
+ searchQuery,
4809
4518
  getUserAgent
4810
4519
  }) => {
4811
4520
  const url = new URL(SEARCH_API_URL);
4812
4521
  const searchParams = new URLSearchParams;
4813
- const searchQuery = [query];
4814
- site && searchQuery.push(`site:${site}`);
4815
- fileType && searchQuery.push(`filetype:${fileType}`);
4816
- language && searchQuery.push(`lang:${language}`);
4817
- if (exactTerms && excludeTerms) {
4818
- throw new Error("Cannot specify both exactTerms and excludeTerms - please use only one");
4819
- }
4820
- exactTerms && searchQuery.push(exactTerms.split("|").map((term) => `+${term}`).join(" AND "));
4821
- excludeTerms && searchQuery.push(excludeTerms.split("|").map((term) => `-${term}`).join(" AND "));
4822
- searchParams.append("query", searchQuery.join(" "));
4823
- for (const [name, value] of Object.entries(rest)) {
4824
- if (value)
4522
+ for (const [name, value] of Object.entries(searchQuery)) {
4523
+ if (value !== undefined && value !== null) {
4825
4524
  searchParams.append(name, `${value}`);
4525
+ }
4826
4526
  }
4827
4527
  url.search = searchParams.toString();
4828
4528
  const options = {
@@ -4852,7 +4552,7 @@ import { tool } from "ai";
4852
4552
  // package.json
4853
4553
  var package_default = {
4854
4554
  name: "@youdotcom-oss/ai-sdk-plugin",
4855
- version: "1.0.3",
4555
+ version: "2.0.0",
4856
4556
  description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
4857
4557
  license: "MIT",
4858
4558
  engines: {
@@ -4914,7 +4614,7 @@ var package_default = {
4914
4614
  },
4915
4615
  types: "./dist/main.d.ts",
4916
4616
  dependencies: {
4917
- "@youdotcom-oss/api": "0.1.1"
4617
+ "@youdotcom-oss/api": "0.2.0"
4918
4618
  },
4919
4619
  peerDependencies: {
4920
4620
  ai: "^6.0.0"
@@ -4945,24 +4645,6 @@ var youSearch = (config2 = {}) => {
4945
4645
  }
4946
4646
  });
4947
4647
  };
4948
- var youExpress = (config2 = {}) => {
4949
- const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
4950
- return tool({
4951
- description: "Fast AI agent powered by You.com that provides quick answers with optional web search. Use this for straightforward queries that benefit from real-time web information.",
4952
- inputSchema: ExpressAgentInputSchema,
4953
- execute: async (params) => {
4954
- if (!apiKey) {
4955
- throw new Error("YDC_API_KEY is required. Set it in environment variables or pass it in config.");
4956
- }
4957
- const response = await callExpressAgent({
4958
- agentInput: params,
4959
- YDC_API_KEY: apiKey,
4960
- getUserAgent
4961
- });
4962
- return response;
4963
- }
4964
- });
4965
- };
4966
4648
  var youContents = (config2 = {}) => {
4967
4649
  const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
4968
4650
  return tool({
@@ -4983,6 +4665,5 @@ var youContents = (config2 = {}) => {
4983
4665
  };
4984
4666
  export {
4985
4667
  youSearch,
4986
- youExpress,
4987
4668
  youContents
4988
4669
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdotcom-oss/ai-sdk-plugin",
3
- "version": "1.0.3",
3
+ "version": "2.0.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.1.1"
65
+ "@youdotcom-oss/api": "0.2.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "ai": "^6.0.0"