@youdotcom-oss/ai-sdk-plugin 1.0.2 → 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 +1 -11
- package/dist/main.d.ts +6 -51
- package/dist/main.js +87 -421
- package/package.json +2 -2
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,
|
|
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" | "
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} | undefined;
|
|
105
|
+
favicon_url: string;
|
|
106
|
+
site_name?: string | null | undefined;
|
|
107
|
+
} | null | undefined;
|
|
153
108
|
}[]>;
|
package/dist/main.js
CHANGED
|
@@ -1818,10 +1818,6 @@ var $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, d
|
|
|
1818
1818
|
$ZodCheckNumberFormat.init(inst, def);
|
|
1819
1819
|
$ZodNumber.init(inst, def);
|
|
1820
1820
|
});
|
|
1821
|
-
var $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
1822
|
-
$ZodType.init(inst, def);
|
|
1823
|
-
inst._zod.parse = (payload) => payload;
|
|
1824
|
-
});
|
|
1825
1821
|
var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1826
1822
|
$ZodType.init(inst, def);
|
|
1827
1823
|
inst._zod.parse = (payload) => payload;
|
|
@@ -2268,114 +2264,6 @@ function handleIntersectionResults(result, left, right) {
|
|
|
2268
2264
|
result.value = merged.data;
|
|
2269
2265
|
return result;
|
|
2270
2266
|
}
|
|
2271
|
-
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
2272
|
-
$ZodType.init(inst, def);
|
|
2273
|
-
inst._zod.parse = (payload, ctx) => {
|
|
2274
|
-
const input = payload.value;
|
|
2275
|
-
if (!isPlainObject(input)) {
|
|
2276
|
-
payload.issues.push({
|
|
2277
|
-
expected: "record",
|
|
2278
|
-
code: "invalid_type",
|
|
2279
|
-
input,
|
|
2280
|
-
inst
|
|
2281
|
-
});
|
|
2282
|
-
return payload;
|
|
2283
|
-
}
|
|
2284
|
-
const proms = [];
|
|
2285
|
-
const values = def.keyType._zod.values;
|
|
2286
|
-
if (values) {
|
|
2287
|
-
payload.value = {};
|
|
2288
|
-
const recordKeys = new Set;
|
|
2289
|
-
for (const key of values) {
|
|
2290
|
-
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
2291
|
-
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
2292
|
-
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2293
|
-
if (result instanceof Promise) {
|
|
2294
|
-
proms.push(result.then((result2) => {
|
|
2295
|
-
if (result2.issues.length) {
|
|
2296
|
-
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
2297
|
-
}
|
|
2298
|
-
payload.value[key] = result2.value;
|
|
2299
|
-
}));
|
|
2300
|
-
} else {
|
|
2301
|
-
if (result.issues.length) {
|
|
2302
|
-
payload.issues.push(...prefixIssues(key, result.issues));
|
|
2303
|
-
}
|
|
2304
|
-
payload.value[key] = result.value;
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
let unrecognized;
|
|
2309
|
-
for (const key in input) {
|
|
2310
|
-
if (!recordKeys.has(key)) {
|
|
2311
|
-
unrecognized = unrecognized ?? [];
|
|
2312
|
-
unrecognized.push(key);
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
if (unrecognized && unrecognized.length > 0) {
|
|
2316
|
-
payload.issues.push({
|
|
2317
|
-
code: "unrecognized_keys",
|
|
2318
|
-
input,
|
|
2319
|
-
inst,
|
|
2320
|
-
keys: unrecognized
|
|
2321
|
-
});
|
|
2322
|
-
}
|
|
2323
|
-
} else {
|
|
2324
|
-
payload.value = {};
|
|
2325
|
-
for (const key of Reflect.ownKeys(input)) {
|
|
2326
|
-
if (key === "__proto__")
|
|
2327
|
-
continue;
|
|
2328
|
-
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
2329
|
-
if (keyResult instanceof Promise) {
|
|
2330
|
-
throw new Error("Async schemas not supported in object keys currently");
|
|
2331
|
-
}
|
|
2332
|
-
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
|
|
2333
|
-
if (checkNumericKey) {
|
|
2334
|
-
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
2335
|
-
if (retryResult instanceof Promise) {
|
|
2336
|
-
throw new Error("Async schemas not supported in object keys currently");
|
|
2337
|
-
}
|
|
2338
|
-
if (retryResult.issues.length === 0) {
|
|
2339
|
-
keyResult = retryResult;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
if (keyResult.issues.length) {
|
|
2343
|
-
if (def.mode === "loose") {
|
|
2344
|
-
payload.value[key] = input[key];
|
|
2345
|
-
} else {
|
|
2346
|
-
payload.issues.push({
|
|
2347
|
-
code: "invalid_key",
|
|
2348
|
-
origin: "record",
|
|
2349
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
2350
|
-
input: key,
|
|
2351
|
-
path: [key],
|
|
2352
|
-
inst
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
continue;
|
|
2356
|
-
}
|
|
2357
|
-
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
2358
|
-
if (result instanceof Promise) {
|
|
2359
|
-
proms.push(result.then((result2) => {
|
|
2360
|
-
if (result2.issues.length) {
|
|
2361
|
-
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
2362
|
-
}
|
|
2363
|
-
payload.value[keyResult.value] = result2.value;
|
|
2364
|
-
}));
|
|
2365
|
-
} else {
|
|
2366
|
-
if (result.issues.length) {
|
|
2367
|
-
payload.issues.push(...prefixIssues(key, result.issues));
|
|
2368
|
-
}
|
|
2369
|
-
payload.value[keyResult.value] = result.value;
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
if (proms.length) {
|
|
2374
|
-
return Promise.all(proms).then(() => payload);
|
|
2375
|
-
}
|
|
2376
|
-
return payload;
|
|
2377
|
-
};
|
|
2378
|
-
});
|
|
2379
2267
|
var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
2380
2268
|
$ZodType.init(inst, def);
|
|
2381
2269
|
const values = getEnumValues(def.entries);
|
|
@@ -2396,28 +2284,6 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
2396
2284
|
return payload;
|
|
2397
2285
|
};
|
|
2398
2286
|
});
|
|
2399
|
-
var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
2400
|
-
$ZodType.init(inst, def);
|
|
2401
|
-
if (def.values.length === 0) {
|
|
2402
|
-
throw new Error("Cannot create literal schema with no valid values");
|
|
2403
|
-
}
|
|
2404
|
-
const values = new Set(def.values);
|
|
2405
|
-
inst._zod.values = values;
|
|
2406
|
-
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
2407
|
-
inst._zod.parse = (payload, _ctx) => {
|
|
2408
|
-
const input = payload.value;
|
|
2409
|
-
if (values.has(input)) {
|
|
2410
|
-
return payload;
|
|
2411
|
-
}
|
|
2412
|
-
payload.issues.push({
|
|
2413
|
-
code: "invalid_value",
|
|
2414
|
-
values: def.values,
|
|
2415
|
-
input,
|
|
2416
|
-
inst
|
|
2417
|
-
});
|
|
2418
|
-
return payload;
|
|
2419
|
-
};
|
|
2420
|
-
});
|
|
2421
2287
|
var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2422
2288
|
$ZodType.init(inst, def);
|
|
2423
2289
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -2987,11 +2853,6 @@ function _int(Class2, params) {
|
|
|
2987
2853
|
...normalizeParams(params)
|
|
2988
2854
|
});
|
|
2989
2855
|
}
|
|
2990
|
-
function _any(Class2) {
|
|
2991
|
-
return new Class2({
|
|
2992
|
-
type: "any"
|
|
2993
|
-
});
|
|
2994
|
-
}
|
|
2995
2856
|
function _unknown(Class2) {
|
|
2996
2857
|
return new Class2({
|
|
2997
2858
|
type: "unknown"
|
|
@@ -3607,7 +3468,6 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
3607
3468
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
3608
3469
|
json.not = {};
|
|
3609
3470
|
};
|
|
3610
|
-
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
3611
3471
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
3612
3472
|
var enumProcessor = (schema, _ctx, json, _params) => {
|
|
3613
3473
|
const def = schema._zod.def;
|
|
@@ -3618,44 +3478,6 @@ var enumProcessor = (schema, _ctx, json, _params) => {
|
|
|
3618
3478
|
json.type = "string";
|
|
3619
3479
|
json.enum = values;
|
|
3620
3480
|
};
|
|
3621
|
-
var literalProcessor = (schema, ctx, json, _params) => {
|
|
3622
|
-
const def = schema._zod.def;
|
|
3623
|
-
const vals = [];
|
|
3624
|
-
for (const val of def.values) {
|
|
3625
|
-
if (val === undefined) {
|
|
3626
|
-
if (ctx.unrepresentable === "throw") {
|
|
3627
|
-
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
3628
|
-
} else {}
|
|
3629
|
-
} else if (typeof val === "bigint") {
|
|
3630
|
-
if (ctx.unrepresentable === "throw") {
|
|
3631
|
-
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
3632
|
-
} else {
|
|
3633
|
-
vals.push(Number(val));
|
|
3634
|
-
}
|
|
3635
|
-
} else {
|
|
3636
|
-
vals.push(val);
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
|
-
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3640
|
-
const val = vals[0];
|
|
3641
|
-
json.type = val === null ? "null" : typeof val;
|
|
3642
|
-
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
3643
|
-
json.enum = [val];
|
|
3644
|
-
} else {
|
|
3645
|
-
json.const = val;
|
|
3646
|
-
}
|
|
3647
|
-
} else {
|
|
3648
|
-
if (vals.every((v) => typeof v === "number"))
|
|
3649
|
-
json.type = "number";
|
|
3650
|
-
if (vals.every((v) => typeof v === "string"))
|
|
3651
|
-
json.type = "string";
|
|
3652
|
-
if (vals.every((v) => typeof v === "boolean"))
|
|
3653
|
-
json.type = "boolean";
|
|
3654
|
-
if (vals.every((v) => v === null))
|
|
3655
|
-
json.type = "null";
|
|
3656
|
-
json.enum = vals;
|
|
3657
|
-
}
|
|
3658
|
-
};
|
|
3659
3481
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
3660
3482
|
if (ctx.unrepresentable === "throw") {
|
|
3661
3483
|
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
@@ -3743,42 +3565,6 @@ var intersectionProcessor = (schema, ctx, json, params) => {
|
|
|
3743
3565
|
];
|
|
3744
3566
|
json.allOf = allOf;
|
|
3745
3567
|
};
|
|
3746
|
-
var recordProcessor = (schema, ctx, _json, params) => {
|
|
3747
|
-
const json = _json;
|
|
3748
|
-
const def = schema._zod.def;
|
|
3749
|
-
json.type = "object";
|
|
3750
|
-
const keyType = def.keyType;
|
|
3751
|
-
const keyBag = keyType._zod.bag;
|
|
3752
|
-
const patterns = keyBag?.patterns;
|
|
3753
|
-
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
3754
|
-
const valueSchema = process2(def.valueType, ctx, {
|
|
3755
|
-
...params,
|
|
3756
|
-
path: [...params.path, "patternProperties", "*"]
|
|
3757
|
-
});
|
|
3758
|
-
json.patternProperties = {};
|
|
3759
|
-
for (const pattern of patterns) {
|
|
3760
|
-
json.patternProperties[pattern.source] = valueSchema;
|
|
3761
|
-
}
|
|
3762
|
-
} else {
|
|
3763
|
-
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
3764
|
-
json.propertyNames = process2(def.keyType, ctx, {
|
|
3765
|
-
...params,
|
|
3766
|
-
path: [...params.path, "propertyNames"]
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
json.additionalProperties = process2(def.valueType, ctx, {
|
|
3770
|
-
...params,
|
|
3771
|
-
path: [...params.path, "additionalProperties"]
|
|
3772
|
-
});
|
|
3773
|
-
}
|
|
3774
|
-
const keyValues = keyType._zod.values;
|
|
3775
|
-
if (keyValues) {
|
|
3776
|
-
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
3777
|
-
if (validKeyValues.length > 0) {
|
|
3778
|
-
json.required = validKeyValues;
|
|
3779
|
-
}
|
|
3780
|
-
}
|
|
3781
|
-
};
|
|
3782
3568
|
var nullableProcessor = (schema, ctx, json, params) => {
|
|
3783
3569
|
const def = schema._zod.def;
|
|
3784
3570
|
const inner = process2(def.innerType, ctx, params);
|
|
@@ -4181,14 +3967,6 @@ var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def
|
|
|
4181
3967
|
function int(params) {
|
|
4182
3968
|
return _int(ZodNumberFormat, params);
|
|
4183
3969
|
}
|
|
4184
|
-
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
4185
|
-
$ZodAny.init(inst, def);
|
|
4186
|
-
ZodType.init(inst, def);
|
|
4187
|
-
inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor(inst, ctx, json, params);
|
|
4188
|
-
});
|
|
4189
|
-
function any() {
|
|
4190
|
-
return _any(ZodAny);
|
|
4191
|
-
}
|
|
4192
3970
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
4193
3971
|
$ZodUnknown.init(inst, def);
|
|
4194
3972
|
ZodType.init(inst, def);
|
|
@@ -4277,21 +4055,6 @@ function intersection(left, right) {
|
|
|
4277
4055
|
right
|
|
4278
4056
|
});
|
|
4279
4057
|
}
|
|
4280
|
-
var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
4281
|
-
$ZodRecord.init(inst, def);
|
|
4282
|
-
ZodType.init(inst, def);
|
|
4283
|
-
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
4284
|
-
inst.keyType = def.keyType;
|
|
4285
|
-
inst.valueType = def.valueType;
|
|
4286
|
-
});
|
|
4287
|
-
function record(keyType, valueType, params) {
|
|
4288
|
-
return new ZodRecord({
|
|
4289
|
-
type: "record",
|
|
4290
|
-
keyType,
|
|
4291
|
-
valueType,
|
|
4292
|
-
...exports_util.normalizeParams(params)
|
|
4293
|
-
});
|
|
4294
|
-
}
|
|
4295
4058
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
4296
4059
|
$ZodEnum.init(inst, def);
|
|
4297
4060
|
ZodType.init(inst, def);
|
|
@@ -4338,27 +4101,6 @@ function _enum(values, params) {
|
|
|
4338
4101
|
...exports_util.normalizeParams(params)
|
|
4339
4102
|
});
|
|
4340
4103
|
}
|
|
4341
|
-
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
4342
|
-
$ZodLiteral.init(inst, def);
|
|
4343
|
-
ZodType.init(inst, def);
|
|
4344
|
-
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
4345
|
-
inst.values = new Set(def.values);
|
|
4346
|
-
Object.defineProperty(inst, "value", {
|
|
4347
|
-
get() {
|
|
4348
|
-
if (def.values.length > 1) {
|
|
4349
|
-
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
4350
|
-
}
|
|
4351
|
-
return def.values[0];
|
|
4352
|
-
}
|
|
4353
|
-
});
|
|
4354
|
-
});
|
|
4355
|
-
function literal(value, params) {
|
|
4356
|
-
return new ZodLiteral({
|
|
4357
|
-
type: "literal",
|
|
4358
|
-
values: Array.isArray(value) ? value : [value],
|
|
4359
|
-
...exports_util.normalizeParams(params)
|
|
4360
|
-
});
|
|
4361
|
-
}
|
|
4362
4104
|
var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
4363
4105
|
$ZodTransform.init(inst, def);
|
|
4364
4106
|
ZodType.init(inst, def);
|
|
@@ -4529,7 +4271,7 @@ function superRefine(fn) {
|
|
|
4529
4271
|
return _superRefine(fn);
|
|
4530
4272
|
}
|
|
4531
4273
|
|
|
4532
|
-
//
|
|
4274
|
+
// ../api/src/contents/contents.schemas.ts
|
|
4533
4275
|
var ContentsQuerySchema = object({
|
|
4534
4276
|
urls: array(string2().url()).min(1).describe('Array of webpage URLs to extract content from (e.g., ["https://example.com"])'),
|
|
4535
4277
|
formats: array(_enum(["markdown", "html", "metadata"])).optional().describe('Output formats: array of "markdown" (text), "html" (layout), or "metadata" (structured data)'),
|
|
@@ -4538,22 +4280,20 @@ var ContentsQuerySchema = object({
|
|
|
4538
4280
|
});
|
|
4539
4281
|
var ContentsItemSchema = object({
|
|
4540
4282
|
url: string2().describe("URL"),
|
|
4541
|
-
title: string2().optional().describe("Title"),
|
|
4542
|
-
html: string2().optional().describe("HTML content"),
|
|
4543
|
-
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"),
|
|
4544
4286
|
metadata: object({
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
}).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)")
|
|
4549
4290
|
});
|
|
4550
4291
|
var ContentsApiResponseSchema = array(ContentsItemSchema);
|
|
4551
|
-
//
|
|
4292
|
+
// ../api/src/shared/api.constants.ts
|
|
4552
4293
|
var SEARCH_API_URL = "https://ydc-index.io/v1/search";
|
|
4553
|
-
var EXPRESS_API_URL = "https://api.you.com/v1/agents/runs";
|
|
4554
4294
|
var CONTENTS_API_URL = "https://ydc-index.io/v1/contents";
|
|
4555
4295
|
|
|
4556
|
-
//
|
|
4296
|
+
// ../api/src/shared/check-response-for-errors.ts
|
|
4557
4297
|
var checkResponseForErrors = (responseData) => {
|
|
4558
4298
|
if (typeof responseData === "object" && responseData !== null && "error" in responseData) {
|
|
4559
4299
|
const errorMessage = typeof responseData.error === "string" ? responseData.error : JSON.stringify(responseData.error);
|
|
@@ -4562,7 +4302,7 @@ var checkResponseForErrors = (responseData) => {
|
|
|
4562
4302
|
return responseData;
|
|
4563
4303
|
};
|
|
4564
4304
|
|
|
4565
|
-
//
|
|
4305
|
+
// ../api/src/contents/contents.utils.ts
|
|
4566
4306
|
var fetchContents = async ({
|
|
4567
4307
|
contentsQuery: { urls, formats, format, crawl_timeout },
|
|
4568
4308
|
YDC_API_KEY = process.env.YDC_API_KEY,
|
|
@@ -4617,119 +4357,77 @@ var fetchContents = async ({
|
|
|
4617
4357
|
const parsedResults = ContentsApiResponseSchema.parse(results);
|
|
4618
4358
|
return parsedResults;
|
|
4619
4359
|
};
|
|
4620
|
-
//
|
|
4621
|
-
var
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
var
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
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)")
|
|
4365
|
+
});
|
|
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")
|
|
4370
|
+
});
|
|
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")
|
|
4374
|
+
});
|
|
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"
|
|
4645
4428
|
]);
|
|
4646
|
-
var ExpressAgentApiResponseSchema = object({
|
|
4647
|
-
output: array(ExpressAgentApiOutputItemSchema),
|
|
4648
|
-
agent: string2().optional().describe("Agent identifier"),
|
|
4649
|
-
mode: string2().optional().describe("Agent mode"),
|
|
4650
|
-
input: array(any()).optional().describe("Input messages")
|
|
4651
|
-
}).passthrough();
|
|
4652
|
-
var McpSearchResultItemSchema = object({
|
|
4653
|
-
url: string2().describe("URL"),
|
|
4654
|
-
title: string2().describe("Title"),
|
|
4655
|
-
snippet: string2().describe("Snippet")
|
|
4656
|
-
});
|
|
4657
|
-
var ExpressAgentMcpResponseSchema = object({
|
|
4658
|
-
answer: string2().describe("AI answer"),
|
|
4659
|
-
results: object({
|
|
4660
|
-
web: array(McpSearchResultItemSchema).describe("Web results")
|
|
4661
|
-
}).optional().describe("Search results"),
|
|
4662
|
-
agent: string2().optional().describe("Agent ID")
|
|
4663
|
-
});
|
|
4664
|
-
// ../../node_modules/.bun/@youdotcom-oss+api@0.0.1/node_modules/@youdotcom-oss/api/src/express/express.utils.ts
|
|
4665
|
-
var agentThrowOnFailedStatus = async (response) => {
|
|
4666
|
-
const errorCode = response.status;
|
|
4667
|
-
const errorData = await response.json();
|
|
4668
|
-
if (errorCode === 400) {
|
|
4669
|
-
throw new Error(`Bad Request:
|
|
4670
|
-
${JSON.stringify(errorData)}`);
|
|
4671
|
-
} else if (errorCode === 401) {
|
|
4672
|
-
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.`);
|
|
4673
|
-
} else if (errorCode === 403) {
|
|
4674
|
-
throw new Error(`Forbidden: You are not allowed to use the requested tool for this agent or tenant`);
|
|
4675
|
-
} else if (errorCode === 429) {
|
|
4676
|
-
throw new Error("Rate limited by You.com API. Please try again later.");
|
|
4677
|
-
}
|
|
4678
|
-
throw new Error(`Failed to call agent. Error code: ${errorCode}`);
|
|
4679
|
-
};
|
|
4680
|
-
var callExpressAgent = async ({
|
|
4681
|
-
YDC_API_KEY = process.env.YDC_API_KEY,
|
|
4682
|
-
agentInput: { input, tools },
|
|
4683
|
-
getUserAgent
|
|
4684
|
-
}) => {
|
|
4685
|
-
const requestBody = {
|
|
4686
|
-
agent: "express",
|
|
4687
|
-
input,
|
|
4688
|
-
stream: false
|
|
4689
|
-
};
|
|
4690
|
-
if (tools) {
|
|
4691
|
-
requestBody.tools = tools;
|
|
4692
|
-
}
|
|
4693
|
-
const options = {
|
|
4694
|
-
method: "POST",
|
|
4695
|
-
headers: new Headers({
|
|
4696
|
-
Authorization: `Bearer ${YDC_API_KEY || ""}`,
|
|
4697
|
-
"Content-Type": "application/json",
|
|
4698
|
-
Accept: "application/json",
|
|
4699
|
-
"User-Agent": getUserAgent()
|
|
4700
|
-
}),
|
|
4701
|
-
body: JSON.stringify(requestBody)
|
|
4702
|
-
};
|
|
4703
|
-
const response = await fetch(EXPRESS_API_URL, options);
|
|
4704
|
-
if (!response.ok) {
|
|
4705
|
-
await agentThrowOnFailedStatus(response);
|
|
4706
|
-
}
|
|
4707
|
-
const jsonResponse = await response.json();
|
|
4708
|
-
checkResponseForErrors(jsonResponse);
|
|
4709
|
-
const apiResponse = ExpressAgentApiResponseSchema.parse(jsonResponse);
|
|
4710
|
-
const answerItem = apiResponse.output.find((item) => item.type === "message.answer");
|
|
4711
|
-
if (!answerItem) {
|
|
4712
|
-
throw new Error("Express API response missing required message.answer item");
|
|
4713
|
-
}
|
|
4714
|
-
const searchItem = apiResponse.output.find((item) => item.type === "web_search.results");
|
|
4715
|
-
const mcpResponse = {
|
|
4716
|
-
answer: answerItem.text,
|
|
4717
|
-
agent: apiResponse.agent
|
|
4718
|
-
};
|
|
4719
|
-
if (searchItem && "content" in searchItem && Array.isArray(searchItem.content)) {
|
|
4720
|
-
mcpResponse.results = {
|
|
4721
|
-
web: searchItem.content.map((item) => ({
|
|
4722
|
-
url: item.url || item.citation_uri || "",
|
|
4723
|
-
title: item.title || "",
|
|
4724
|
-
snippet: item.snippet || ""
|
|
4725
|
-
}))
|
|
4726
|
-
};
|
|
4727
|
-
}
|
|
4728
|
-
return mcpResponse;
|
|
4729
|
-
};
|
|
4730
|
-
// ../../node_modules/.bun/@youdotcom-oss+api@0.0.1/node_modules/@youdotcom-oss/api/src/search/search.schemas.ts
|
|
4731
4429
|
var SearchQuerySchema = object({
|
|
4732
|
-
query: string2().min(1, "Query is required").describe(
|
|
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"'),
|
|
4733
4431
|
count: number2().int().min(1).max(100).optional().describe("Max results per section"),
|
|
4734
4432
|
freshness: string2().optional().describe("day/week/month/year or YYYY-MM-DDtoYYYY-MM-DD"),
|
|
4735
4433
|
offset: number2().int().min(0).max(9).optional().describe("Pagination offset"),
|
|
@@ -4759,6 +4457,7 @@ var SearchQuerySchema = object({
|
|
|
4759
4457
|
"CN",
|
|
4760
4458
|
"PL",
|
|
4761
4459
|
"PT",
|
|
4460
|
+
"PT-BR",
|
|
4762
4461
|
"PH",
|
|
4763
4462
|
"RU",
|
|
4764
4463
|
"SA",
|
|
@@ -4772,11 +4471,6 @@ var SearchQuerySchema = object({
|
|
|
4772
4471
|
"US"
|
|
4773
4472
|
]).optional().describe("Country code"),
|
|
4774
4473
|
safesearch: _enum(["off", "moderate", "strict"]).optional().describe("Filter level"),
|
|
4775
|
-
site: string2().optional().describe("Specific domain"),
|
|
4776
|
-
fileType: string2().optional().describe("File type"),
|
|
4777
|
-
language: string2().optional().describe("ISO 639-1 language code"),
|
|
4778
|
-
excludeTerms: string2().optional().describe("Terms to exclude (pipe-separated)"),
|
|
4779
|
-
exactTerms: string2().optional().describe("Exact terms (pipe-separated)"),
|
|
4780
4474
|
livecrawl: _enum(["web", "news", "all"]).optional().describe("Live-crawl sections for full content"),
|
|
4781
4475
|
livecrawl_formats: _enum(["html", "markdown"]).optional().describe("Format for crawled content")
|
|
4782
4476
|
});
|
|
@@ -4817,27 +4511,18 @@ var SearchResponseSchema = object({
|
|
|
4817
4511
|
}),
|
|
4818
4512
|
metadata: MetadataSchema.partial()
|
|
4819
4513
|
});
|
|
4820
|
-
//
|
|
4514
|
+
// ../api/src/search/search.utils.ts
|
|
4821
4515
|
var fetchSearchResults = async ({
|
|
4822
4516
|
YDC_API_KEY = process.env.YDC_API_KEY,
|
|
4823
|
-
searchQuery
|
|
4517
|
+
searchQuery,
|
|
4824
4518
|
getUserAgent
|
|
4825
4519
|
}) => {
|
|
4826
4520
|
const url = new URL(SEARCH_API_URL);
|
|
4827
4521
|
const searchParams = new URLSearchParams;
|
|
4828
|
-
const searchQuery
|
|
4829
|
-
|
|
4830
|
-
fileType && searchQuery.push(`filetype:${fileType}`);
|
|
4831
|
-
language && searchQuery.push(`lang:${language}`);
|
|
4832
|
-
if (exactTerms && excludeTerms) {
|
|
4833
|
-
throw new Error("Cannot specify both exactTerms and excludeTerms - please use only one");
|
|
4834
|
-
}
|
|
4835
|
-
exactTerms && searchQuery.push(exactTerms.split("|").map((term) => `+${term}`).join(" AND "));
|
|
4836
|
-
excludeTerms && searchQuery.push(excludeTerms.split("|").map((term) => `-${term}`).join(" AND "));
|
|
4837
|
-
searchParams.append("query", searchQuery.join(" "));
|
|
4838
|
-
for (const [name, value] of Object.entries(rest)) {
|
|
4839
|
-
if (value)
|
|
4522
|
+
for (const [name, value] of Object.entries(searchQuery)) {
|
|
4523
|
+
if (value !== undefined && value !== null) {
|
|
4840
4524
|
searchParams.append(name, `${value}`);
|
|
4525
|
+
}
|
|
4841
4526
|
}
|
|
4842
4527
|
url.search = searchParams.toString();
|
|
4843
4528
|
const options = {
|
|
@@ -4867,7 +4552,7 @@ import { tool } from "ai";
|
|
|
4867
4552
|
// package.json
|
|
4868
4553
|
var package_default = {
|
|
4869
4554
|
name: "@youdotcom-oss/ai-sdk-plugin",
|
|
4870
|
-
version: "
|
|
4555
|
+
version: "2.0.0",
|
|
4871
4556
|
description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
|
|
4872
4557
|
license: "MIT",
|
|
4873
4558
|
engines: {
|
|
@@ -4929,7 +4614,7 @@ var package_default = {
|
|
|
4929
4614
|
},
|
|
4930
4615
|
types: "./dist/main.d.ts",
|
|
4931
4616
|
dependencies: {
|
|
4932
|
-
"@youdotcom-oss/api": "0.0
|
|
4617
|
+
"@youdotcom-oss/api": "0.2.0"
|
|
4933
4618
|
},
|
|
4934
4619
|
peerDependencies: {
|
|
4935
4620
|
ai: "^6.0.0"
|
|
@@ -4960,24 +4645,6 @@ var youSearch = (config2 = {}) => {
|
|
|
4960
4645
|
}
|
|
4961
4646
|
});
|
|
4962
4647
|
};
|
|
4963
|
-
var youExpress = (config2 = {}) => {
|
|
4964
|
-
const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
|
|
4965
|
-
return tool({
|
|
4966
|
-
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.",
|
|
4967
|
-
inputSchema: ExpressAgentInputSchema,
|
|
4968
|
-
execute: async (params) => {
|
|
4969
|
-
if (!apiKey) {
|
|
4970
|
-
throw new Error("YDC_API_KEY is required. Set it in environment variables or pass it in config.");
|
|
4971
|
-
}
|
|
4972
|
-
const response = await callExpressAgent({
|
|
4973
|
-
agentInput: params,
|
|
4974
|
-
YDC_API_KEY: apiKey,
|
|
4975
|
-
getUserAgent
|
|
4976
|
-
});
|
|
4977
|
-
return response;
|
|
4978
|
-
}
|
|
4979
|
-
});
|
|
4980
|
-
};
|
|
4981
4648
|
var youContents = (config2 = {}) => {
|
|
4982
4649
|
const apiKey = config2.apiKey ?? process.env.YDC_API_KEY;
|
|
4983
4650
|
return tool({
|
|
@@ -4998,6 +4665,5 @@ var youContents = (config2 = {}) => {
|
|
|
4998
4665
|
};
|
|
4999
4666
|
export {
|
|
5000
4667
|
youSearch,
|
|
5001
|
-
youExpress,
|
|
5002
4668
|
youContents
|
|
5003
4669
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youdotcom-oss/ai-sdk-plugin",
|
|
3
|
-
"version": "
|
|
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.0
|
|
65
|
+
"@youdotcom-oss/api": "0.2.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"ai": "^6.0.0"
|