@youdotcom-oss/ai-sdk-plugin 2.0.2 → 2.0.3

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.
Files changed (2) hide show
  1. package/dist/main.js +22 -4
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -4290,8 +4290,9 @@ var ContentsItemSchema = object({
4290
4290
  });
4291
4291
  var ContentsApiResponseSchema = array(ContentsItemSchema);
4292
4292
  // ../api/src/shared/api.constants.ts
4293
- var SEARCH_API_URL = "https://ydc-index.io/v1/search";
4294
- var CONTENTS_API_URL = "https://ydc-index.io/v1/contents";
4293
+ var SEARCH_API_URL = process.env.YDC_SEARCH_API_URL || "https://ydc-index.io/v1/search";
4294
+ var DEEP_SEARCH_API_URL = process.env.YDC_DEEP_SEARCH_API_URL || "https://api.you.com/v1/deep_search";
4295
+ var CONTENTS_API_URL = process.env.YDC_CONTENTS_API_URL || "https://ydc-index.io/v1/contents";
4295
4296
 
4296
4297
  // ../api/src/shared/check-response-for-errors.ts
4297
4298
  var checkResponseForErrors = (responseData) => {
@@ -4539,6 +4540,23 @@ var fetchSearchResults = async ({
4539
4540
  throw new Error("Rate limited by You.com API. Please try again later.");
4540
4541
  } else if (errorCode === 403) {
4541
4542
  throw new Error("Forbidden. Please check your You.com API key.");
4543
+ } else if (errorCode === 402) {
4544
+ let errorMessage = "Free tier limit exceeded. Please upgrade to continue.";
4545
+ let upgradeUrl = "https://you.com/platform";
4546
+ try {
4547
+ const errorBody = await response.json();
4548
+ if (errorBody?.message) {
4549
+ errorMessage = errorBody.message;
4550
+ }
4551
+ if (errorBody?.upgrade_url) {
4552
+ upgradeUrl = errorBody.upgrade_url;
4553
+ }
4554
+ if (errorBody?.reset_at) {
4555
+ const resetDate = new Date(errorBody.reset_at).toLocaleDateString();
4556
+ errorMessage += ` Limit resets on ${resetDate}.`;
4557
+ }
4558
+ } catch {}
4559
+ throw new Error(`${errorMessage} Upgrade at: ${upgradeUrl}`);
4542
4560
  }
4543
4561
  throw new Error(`Failed to perform search. Error code: ${errorCode}`);
4544
4562
  }
@@ -4552,7 +4570,7 @@ import { tool } from "ai";
4552
4570
  // package.json
4553
4571
  var package_default = {
4554
4572
  name: "@youdotcom-oss/ai-sdk-plugin",
4555
- version: "2.0.2",
4573
+ version: "2.0.3",
4556
4574
  description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
4557
4575
  license: "MIT",
4558
4576
  engines: {
@@ -4614,7 +4632,7 @@ var package_default = {
4614
4632
  },
4615
4633
  types: "./dist/main.d.ts",
4616
4634
  dependencies: {
4617
- "@youdotcom-oss/api": "0.2.2"
4635
+ "@youdotcom-oss/api": "0.3.0"
4618
4636
  },
4619
4637
  peerDependencies: {
4620
4638
  ai: "^6.0.72"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdotcom-oss/ai-sdk-plugin",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
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.2.2"
65
+ "@youdotcom-oss/api": "0.3.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "ai": "^6.0.72"