@youdotcom-oss/ai-sdk-plugin 1.0.1 → 1.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.
- package/dist/main.js +21 -124
- package/package.json +5 -9
package/dist/main.js
CHANGED
|
@@ -954,7 +954,6 @@ var string = (params) => {
|
|
|
954
954
|
};
|
|
955
955
|
var integer = /^-?\d+$/;
|
|
956
956
|
var number = /^-?\d+(?:\.\d+)?$/;
|
|
957
|
-
var boolean = /^(?:true|false)$/i;
|
|
958
957
|
var lowercase = /^[^A-Z]*$/;
|
|
959
958
|
var uppercase = /^[^a-z]*$/;
|
|
960
959
|
|
|
@@ -1819,30 +1818,6 @@ var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, d
|
|
|
1819
1818
|
$ZodCheckNumberFormat.init(inst, def);
|
|
1820
1819
|
$ZodNumber.init(inst, def);
|
|
1821
1820
|
});
|
|
1822
|
-
var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
1823
|
-
$ZodType.init(inst, def);
|
|
1824
|
-
inst._zod.pattern = boolean;
|
|
1825
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
1826
|
-
if (def.coerce)
|
|
1827
|
-
try {
|
|
1828
|
-
payload.value = Boolean(payload.value);
|
|
1829
|
-
} catch (_) {}
|
|
1830
|
-
const input = payload.value;
|
|
1831
|
-
if (typeof input === "boolean")
|
|
1832
|
-
return payload;
|
|
1833
|
-
payload.issues.push({
|
|
1834
|
-
expected: "boolean",
|
|
1835
|
-
code: "invalid_type",
|
|
1836
|
-
input,
|
|
1837
|
-
inst
|
|
1838
|
-
});
|
|
1839
|
-
return payload;
|
|
1840
|
-
};
|
|
1841
|
-
});
|
|
1842
|
-
var $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
1843
|
-
$ZodType.init(inst, def);
|
|
1844
|
-
inst._zod.parse = (payload) => payload;
|
|
1845
|
-
});
|
|
1846
1821
|
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1847
1822
|
$ZodType.init(inst, def);
|
|
1848
1823
|
inst._zod.parse = (payload) => payload;
|
|
@@ -3008,17 +2983,6 @@ function _int(Class2, params) {
|
|
|
3008
2983
|
...normalizeParams(params)
|
|
3009
2984
|
});
|
|
3010
2985
|
}
|
|
3011
|
-
function _boolean(Class2, params) {
|
|
3012
|
-
return new Class2({
|
|
3013
|
-
type: "boolean",
|
|
3014
|
-
...normalizeParams(params)
|
|
3015
|
-
});
|
|
3016
|
-
}
|
|
3017
|
-
function _any(Class2) {
|
|
3018
|
-
return new Class2({
|
|
3019
|
-
type: "any"
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
3022
2986
|
function _unknown(Class2) {
|
|
3023
2987
|
return new Class2({
|
|
3024
2988
|
type: "unknown"
|
|
@@ -3631,13 +3595,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3631
3595
|
if (typeof multipleOf === "number")
|
|
3632
3596
|
json.multipleOf = multipleOf;
|
|
3633
3597
|
};
|
|
3634
|
-
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
3635
|
-
json.type = "boolean";
|
|
3636
|
-
};
|
|
3637
3598
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3638
3599
|
json.not = {};
|
|
3639
3600
|
};
|
|
3640
|
-
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
3641
3601
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
3642
3602
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3643
3603
|
const def = schema._zod.def;
|
|
@@ -4211,22 +4171,6 @@ var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def
|
|
|
4211
4171
|
function int(params) {
|
|
4212
4172
|
return _int(ZodNumberFormat, params);
|
|
4213
4173
|
}
|
|
4214
|
-
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
4215
|
-
$ZodBoolean.init(inst, def);
|
|
4216
|
-
ZodType.init(inst, def);
|
|
4217
|
-
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
4218
|
-
});
|
|
4219
|
-
function boolean2(params) {
|
|
4220
|
-
return _boolean(ZodBoolean, params);
|
|
4221
|
-
}
|
|
4222
|
-
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
4223
|
-
$ZodAny.init(inst, def);
|
|
4224
|
-
ZodType.init(inst, def);
|
|
4225
|
-
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor(inst, ctx, json, params);
|
|
4226
|
-
});
|
|
4227
|
-
function any() {
|
|
4228
|
-
return _any(ZodAny);
|
|
4229
|
-
}
|
|
4230
4174
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
4231
4175
|
$ZodUnknown.init(inst, def);
|
|
4232
4176
|
ZodType.init(inst, def);
|
|
@@ -4567,7 +4511,7 @@ function superRefine(fn) {
|
|
|
4567
4511
|
return _superRefine(fn);
|
|
4568
4512
|
}
|
|
4569
4513
|
|
|
4570
|
-
// ../
|
|
4514
|
+
// ../api/src/contents/contents.schemas.ts
|
|
4571
4515
|
var ContentsQuerySchema = object({
|
|
4572
4516
|
urls: array(string2().url()).min(1).describe('Array of webpage URLs to extract content from (e.g., ["https://example.com"])'),
|
|
4573
4517
|
formats: array(_enum(["markdown", "html", "metadata"])).optional().describe('Output formats: array of "markdown" (text), "html" (layout), or "metadata" (structured data)'),
|
|
@@ -4586,27 +4530,12 @@ var ContentsItemSchema = object({
|
|
|
4586
4530
|
}).optional().describe("Structured metadata when available")
|
|
4587
4531
|
});
|
|
4588
4532
|
var ContentsApiResponseSchema = array(ContentsItemSchema);
|
|
4589
|
-
|
|
4590
|
-
count: number2().describe("URLs processed"),
|
|
4591
|
-
formats: array(string2()).describe("Content formats requested"),
|
|
4592
|
-
items: array(object({
|
|
4593
|
-
url: string2().describe("URL"),
|
|
4594
|
-
title: string2().optional().describe("Title"),
|
|
4595
|
-
markdown: string2().optional().describe("Markdown content"),
|
|
4596
|
-
html: string2().optional().describe("HTML content"),
|
|
4597
|
-
metadata: object({
|
|
4598
|
-
jsonld: array(record(string2(), unknown())).optional(),
|
|
4599
|
-
opengraph: record(string2(), string2()).optional(),
|
|
4600
|
-
twitter: record(string2(), string2()).optional()
|
|
4601
|
-
}).optional().describe("Structured metadata")
|
|
4602
|
-
})).describe("Extracted items")
|
|
4603
|
-
});
|
|
4604
|
-
// ../mcp/src/shared/api-constants.ts
|
|
4533
|
+
// ../api/src/shared/api.constants.ts
|
|
4605
4534
|
var SEARCH_API_URL = "https://ydc-index.io/v1/search";
|
|
4606
4535
|
var EXPRESS_API_URL = "https://api.you.com/v1/agents/runs";
|
|
4607
4536
|
var CONTENTS_API_URL = "https://ydc-index.io/v1/contents";
|
|
4608
4537
|
|
|
4609
|
-
// ../
|
|
4538
|
+
// ../api/src/shared/check-response-for-errors.ts
|
|
4610
4539
|
var checkResponseForErrors = (responseData) => {
|
|
4611
4540
|
if (typeof responseData === "object" && responseData !== null && "error" in responseData) {
|
|
4612
4541
|
const errorMessage = typeof responseData.error === "string" ? responseData.error : JSON.stringify(responseData.error);
|
|
@@ -4615,7 +4544,7 @@ var checkResponseForErrors = (responseData) => {
|
|
|
4615
4544
|
return responseData;
|
|
4616
4545
|
};
|
|
4617
4546
|
|
|
4618
|
-
// ../
|
|
4547
|
+
// ../api/src/contents/contents.utils.ts
|
|
4619
4548
|
var fetchContents = async ({
|
|
4620
4549
|
contentsQuery: { urls, formats, format, crawl_timeout },
|
|
4621
4550
|
YDC_API_KEY = process.env.YDC_API_KEY,
|
|
@@ -4670,7 +4599,7 @@ var fetchContents = async ({
|
|
|
4670
4599
|
const parsedResults = ContentsApiResponseSchema.parse(results);
|
|
4671
4600
|
return parsedResults;
|
|
4672
4601
|
};
|
|
4673
|
-
// ../
|
|
4602
|
+
// ../api/src/express/express.schemas.ts
|
|
4674
4603
|
var ExpressAgentInputSchema = object({
|
|
4675
4604
|
input: string2().min(1, "Input is required").describe("Query or prompt"),
|
|
4676
4605
|
tools: array(object({
|
|
@@ -4678,13 +4607,13 @@ var ExpressAgentInputSchema = object({
|
|
|
4678
4607
|
})).optional().describe("Tools (web search only)")
|
|
4679
4608
|
});
|
|
4680
4609
|
var ApiSearchResultItemSchema = object({
|
|
4681
|
-
source_type: string2().optional(),
|
|
4610
|
+
source_type: string2().nullable().optional(),
|
|
4682
4611
|
citation_uri: string2().optional(),
|
|
4683
4612
|
url: string2(),
|
|
4684
4613
|
title: string2(),
|
|
4685
4614
|
snippet: string2(),
|
|
4686
|
-
thumbnail_url: string2().optional(),
|
|
4687
|
-
provider:
|
|
4615
|
+
thumbnail_url: string2().nullable().optional(),
|
|
4616
|
+
provider: string2().nullable().optional()
|
|
4688
4617
|
});
|
|
4689
4618
|
var ExpressAgentApiOutputItemSchema = union([
|
|
4690
4619
|
object({
|
|
@@ -4700,7 +4629,10 @@ var ExpressAgentApiResponseSchema = object({
|
|
|
4700
4629
|
output: array(ExpressAgentApiOutputItemSchema),
|
|
4701
4630
|
agent: string2().optional().describe("Agent identifier"),
|
|
4702
4631
|
mode: string2().optional().describe("Agent mode"),
|
|
4703
|
-
input: array(
|
|
4632
|
+
input: array(object({
|
|
4633
|
+
role: _enum(["user"]).describe("User role"),
|
|
4634
|
+
content: string2().describe("User question")
|
|
4635
|
+
})).optional().describe("Input messages")
|
|
4704
4636
|
}).passthrough();
|
|
4705
4637
|
var McpSearchResultItemSchema = object({
|
|
4706
4638
|
url: string2().describe("URL"),
|
|
@@ -4714,19 +4646,7 @@ var ExpressAgentMcpResponseSchema = object({
|
|
|
4714
4646
|
}).optional().describe("Search results"),
|
|
4715
4647
|
agent: string2().optional().describe("Agent ID")
|
|
4716
4648
|
});
|
|
4717
|
-
|
|
4718
|
-
answer: string2().describe("AI answer"),
|
|
4719
|
-
hasResults: boolean2().describe("Has web results"),
|
|
4720
|
-
resultCount: number2().describe("Result count"),
|
|
4721
|
-
agent: string2().optional().describe("Agent ID"),
|
|
4722
|
-
results: object({
|
|
4723
|
-
web: array(object({
|
|
4724
|
-
url: string2().describe("URL"),
|
|
4725
|
-
title: string2().describe("Title")
|
|
4726
|
-
})).optional().describe("Web results")
|
|
4727
|
-
}).optional().describe("Search results")
|
|
4728
|
-
});
|
|
4729
|
-
// ../mcp/src/express/express.utils.ts
|
|
4649
|
+
// ../api/src/express/express.utils.ts
|
|
4730
4650
|
var agentThrowOnFailedStatus = async (response) => {
|
|
4731
4651
|
const errorCode = response.status;
|
|
4732
4652
|
const errorData = await response.json();
|
|
@@ -4792,7 +4712,7 @@ var callExpressAgent = async ({
|
|
|
4792
4712
|
}
|
|
4793
4713
|
return mcpResponse;
|
|
4794
4714
|
};
|
|
4795
|
-
// ../
|
|
4715
|
+
// ../api/src/search/search.schemas.ts
|
|
4796
4716
|
var SearchQuerySchema = object({
|
|
4797
4717
|
query: string2().min(1, "Query is required").describe("Search query (supports +, -, site:, filetype:, lang:)"),
|
|
4798
4718
|
count: number2().int().min(1).max(100).optional().describe("Max results per section"),
|
|
@@ -4882,26 +4802,7 @@ var SearchResponseSchema = object({
|
|
|
4882
4802
|
}),
|
|
4883
4803
|
metadata: MetadataSchema.partial()
|
|
4884
4804
|
});
|
|
4885
|
-
|
|
4886
|
-
resultCounts: object({
|
|
4887
|
-
web: number2().describe("Web results"),
|
|
4888
|
-
news: number2().describe("News results"),
|
|
4889
|
-
total: number2().describe("Total results")
|
|
4890
|
-
}),
|
|
4891
|
-
results: object({
|
|
4892
|
-
web: array(object({
|
|
4893
|
-
url: string2().describe("URL"),
|
|
4894
|
-
title: string2().describe("Title"),
|
|
4895
|
-
page_age: string2().optional().describe("Publication timestamp")
|
|
4896
|
-
})).optional().describe("Web results"),
|
|
4897
|
-
news: array(object({
|
|
4898
|
-
url: string2().describe("URL"),
|
|
4899
|
-
title: string2().describe("Title"),
|
|
4900
|
-
page_age: string2().describe("Publication timestamp")
|
|
4901
|
-
})).optional().describe("News results")
|
|
4902
|
-
}).optional().describe("Search results")
|
|
4903
|
-
});
|
|
4904
|
-
// ../mcp/src/search/search.utils.ts
|
|
4805
|
+
// ../api/src/search/search.utils.ts
|
|
4905
4806
|
var fetchSearchResults = async ({
|
|
4906
4807
|
YDC_API_KEY = process.env.YDC_API_KEY,
|
|
4907
4808
|
searchQuery: { query, site, fileType, language, exactTerms, excludeTerms, ...rest },
|
|
@@ -4951,7 +4852,7 @@ import { tool } from "ai";
|
|
|
4951
4852
|
// package.json
|
|
4952
4853
|
var package_default = {
|
|
4953
4854
|
name: "@youdotcom-oss/ai-sdk-plugin",
|
|
4954
|
-
version: "1.0.
|
|
4855
|
+
version: "1.0.3",
|
|
4955
4856
|
description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
|
|
4956
4857
|
license: "MIT",
|
|
4957
4858
|
engines: {
|
|
@@ -5002,13 +4903,9 @@ var package_default = {
|
|
|
5002
4903
|
"check:biome": "biome check",
|
|
5003
4904
|
"check:package": "format-package --check",
|
|
5004
4905
|
"check:types": "tsc --noEmit",
|
|
5005
|
-
"check:write": "
|
|
4906
|
+
"check:write": "biome check --write && bun run format:package",
|
|
5006
4907
|
example: "bun scripts/run-example.ts",
|
|
5007
|
-
format: "biome format --write",
|
|
5008
|
-
"format:check": "biome format",
|
|
5009
4908
|
"format:package": "format-package --write",
|
|
5010
|
-
lint: "biome lint",
|
|
5011
|
-
"lint:fix": "biome lint --write",
|
|
5012
4909
|
prepublishOnly: "bun run build",
|
|
5013
4910
|
test: "bun test",
|
|
5014
4911
|
"test:coverage": "bun test --coverage",
|
|
@@ -5017,19 +4914,19 @@ var package_default = {
|
|
|
5017
4914
|
},
|
|
5018
4915
|
types: "./dist/main.d.ts",
|
|
5019
4916
|
dependencies: {
|
|
5020
|
-
"@youdotcom-oss/
|
|
4917
|
+
"@youdotcom-oss/api": "0.1.1"
|
|
5021
4918
|
},
|
|
5022
4919
|
peerDependencies: {
|
|
5023
4920
|
ai: "^6.0.0"
|
|
5024
4921
|
},
|
|
5025
4922
|
devDependencies: {
|
|
5026
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
5027
|
-
ai: "^6.0.
|
|
4923
|
+
"@ai-sdk/anthropic": "^3.0.35",
|
|
4924
|
+
ai: "^6.0.67"
|
|
5028
4925
|
}
|
|
5029
4926
|
};
|
|
5030
4927
|
|
|
5031
4928
|
// src/main.ts
|
|
5032
|
-
var getUserAgent = () => `AI-SDK-Plugin
|
|
4929
|
+
var getUserAgent = () => `AI-SDK-Plugin/${package_default.version} (You.com;${process.env.NEXT_PUBLIC_SITE_URL || ""})`;
|
|
5033
4930
|
var youSearch = (config2 = {}) => {
|
|
5034
4931
|
const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
|
|
5035
4932
|
return tool({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdotcom-oss/ai-sdk-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.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": {
|
|
@@ -51,13 +51,9 @@
|
|
|
51
51
|
"check:biome": "biome check",
|
|
52
52
|
"check:package": "format-package --check",
|
|
53
53
|
"check:types": "tsc --noEmit",
|
|
54
|
-
"check:write": "
|
|
54
|
+
"check:write": "biome check --write && bun run format:package",
|
|
55
55
|
"example": "bun scripts/run-example.ts",
|
|
56
|
-
"format": "biome format --write",
|
|
57
|
-
"format:check": "biome format",
|
|
58
56
|
"format:package": "format-package --write",
|
|
59
|
-
"lint": "biome lint",
|
|
60
|
-
"lint:fix": "biome lint --write",
|
|
61
57
|
"prepublishOnly": "bun run build",
|
|
62
58
|
"test": "bun test",
|
|
63
59
|
"test:coverage": "bun test --coverage",
|
|
@@ -66,13 +62,13 @@
|
|
|
66
62
|
},
|
|
67
63
|
"types": "./dist/main.d.ts",
|
|
68
64
|
"dependencies": {
|
|
69
|
-
"@youdotcom-oss/
|
|
65
|
+
"@youdotcom-oss/api": "0.1.1"
|
|
70
66
|
},
|
|
71
67
|
"peerDependencies": {
|
|
72
68
|
"ai": "^6.0.0"
|
|
73
69
|
},
|
|
74
70
|
"devDependencies": {
|
|
75
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
76
|
-
"ai": "^6.0.
|
|
71
|
+
"@ai-sdk/anthropic": "^3.0.35",
|
|
72
|
+
"ai": "^6.0.67"
|
|
77
73
|
}
|
|
78
74
|
}
|