@scavio/ai-sdk 0.2.2 → 0.3.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 +34 -10
- package/dist/index.cjs +118 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -13
- package/dist/index.d.ts +82 -13
- package/dist/index.js +112 -26
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,6 +4,14 @@ Scavio search tools for the [Vercel AI SDK](https://sdk.vercel.ai). Give any AI
|
|
|
4
4
|
search across Google, YouTube, Reddit, Amazon, Walmart, TikTok, and Instagram via the
|
|
5
5
|
[Scavio](https://scavio.dev) API.
|
|
6
6
|
|
|
7
|
+
> **Amazon changed (breaking).** The upstream provider moved in 2026-07:
|
|
8
|
+
> `domain` is replaced by `country`, a two-letter marketplace code (`us`, `gb`
|
|
9
|
+
> -- the UK is `gb`, not `uk` -- `de`, `jp`, ...), and `sort_by`, `pages`,
|
|
10
|
+
> `category_id`, `merchant_id`, `language`, `currency`, `device`, `zip_code`
|
|
11
|
+
> and `autoselect_variant` are gone. The marketplace ignores all of them
|
|
12
|
+
> (`sort_by` returns the identical unordered set for every value), so they are
|
|
13
|
+
> removed rather than kept as silent no-ops. Rank and filter results yourself.
|
|
14
|
+
|
|
7
15
|
## Install
|
|
8
16
|
|
|
9
17
|
```bash
|
|
@@ -22,7 +30,7 @@ import { scavioSearch, scavioTools } from "@scavio/ai-sdk";
|
|
|
22
30
|
|
|
23
31
|
// A single tool:
|
|
24
32
|
const res = await generateText({
|
|
25
|
-
model: openai("gpt-
|
|
33
|
+
model: openai("gpt-5.5"),
|
|
26
34
|
tools: { scavio_search: scavioSearch({ maxResults: 5 }) },
|
|
27
35
|
stopWhen: stepCountIs(3),
|
|
28
36
|
prompt: "Find the official GitHub repo of the Agno framework",
|
|
@@ -30,7 +38,7 @@ const res = await generateText({
|
|
|
30
38
|
|
|
31
39
|
// Or all tools at once:
|
|
32
40
|
const res2 = await generateText({
|
|
33
|
-
model: openai("gpt-
|
|
41
|
+
model: openai("gpt-5.5"),
|
|
34
42
|
tools: scavioTools(),
|
|
35
43
|
stopWhen: stepCountIs(3),
|
|
36
44
|
prompt: "Compare prices for a mechanical keyboard on Amazon and Walmart",
|
|
@@ -41,17 +49,33 @@ const res2 = await generateText({
|
|
|
41
49
|
|
|
42
50
|
| Factory | Tool name | Provider |
|
|
43
51
|
| --- | --- | --- |
|
|
44
|
-
| `scavioSearch` | `scavio_search` | Google web search |
|
|
45
|
-
| `scavioYoutubeSearch` | `scavio_youtube_search` | YouTube video search |
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
52
|
+
| `scavioSearch` | `scavio_search` | Google web search, `/api/v2/google` (1 credit) |
|
|
53
|
+
| `scavioYoutubeSearch` | `scavio_youtube_search` | YouTube video search (2 credits) |
|
|
54
|
+
| `scavioYoutubeVideo` | `scavio_youtube_video` | YouTube video details (1 credit) |
|
|
55
|
+
| `scavioYoutubeTranscript` | `scavio_youtube_transcript` | YouTube transcript / subtitles (8 credits) |
|
|
56
|
+
| `scavioYoutubeComments` | `scavio_youtube_comments` | YouTube video comments (1 credit) |
|
|
57
|
+
| `scavioYoutubeChannel` | `scavio_youtube_channel` | YouTube channel details (1 credit) |
|
|
58
|
+
| `scavioRedditSearch` | `scavio_reddit_search` | Reddit posts (1 credit) |
|
|
59
|
+
| `scavioAmazonSearch` | `scavio_amazon_search` | Amazon products (1 credit) |
|
|
60
|
+
| `scavioAmazonOffers` | `scavio_amazon_offers` | Amazon seller offers for one ASIN (1 credit) |
|
|
61
|
+
| `scavioWalmartSearch` | `scavio_walmart_search` | Walmart products (1 credit) |
|
|
62
|
+
| `scavioTiktokSearch` | `scavio_tiktok_search` | TikTok videos (1 credit) |
|
|
63
|
+
| `scavioInstagramSearch` | `scavio_instagram_search` | Instagram users (10 credits) |
|
|
51
64
|
| `scavioTools` | all of the above | bundle for `tools:` |
|
|
52
65
|
|
|
53
66
|
Each factory accepts `{ apiKey?, maxResults?, ...ScavioConfig }`. The key falls back to `SCAVIO_API_KEY`.
|
|
54
|
-
Get a key at [dashboard.scavio.dev](https://dashboard.scavio.dev)
|
|
67
|
+
Get a key at [dashboard.scavio.dev](https://dashboard.scavio.dev) - new accounts get 50 free credits, no
|
|
68
|
+
credit card.
|
|
69
|
+
|
|
70
|
+
`maxResults` trims the result list in place. Google returns a flat body, so it trims
|
|
71
|
+
`organic_results`; every other endpoint nests its payload under `data`, so those trim inside `data`
|
|
72
|
+
(`data.results`, `data.products`, `data.aweme_list`, `data.users`, ...) and the
|
|
73
|
+
`{ data, response_time, credits_used, credits_remaining }` envelope is preserved.
|
|
74
|
+
|
|
75
|
+
These tools cover the most common surfaces. The full Scavio API - 98 endpoints across Google,
|
|
76
|
+
YouTube, Amazon, Walmart, Reddit, TikTok, TikTok Shop, Instagram, X and LinkedIn - is available
|
|
77
|
+
directly through the [`scavio`](https://www.npmjs.com/package/scavio) SDK or the
|
|
78
|
+
[MCP server](https://scavio.dev/docs).
|
|
55
79
|
|
|
56
80
|
## License
|
|
57
81
|
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
scavioAmazonOffers: () => scavioAmazonOffers,
|
|
23
24
|
scavioAmazonSearch: () => scavioAmazonSearch,
|
|
24
25
|
scavioInstagramSearch: () => scavioInstagramSearch,
|
|
25
26
|
scavioRedditSearch: () => scavioRedditSearch,
|
|
@@ -27,7 +28,11 @@ __export(index_exports, {
|
|
|
27
28
|
scavioTiktokSearch: () => scavioTiktokSearch,
|
|
28
29
|
scavioTools: () => scavioTools,
|
|
29
30
|
scavioWalmartSearch: () => scavioWalmartSearch,
|
|
30
|
-
|
|
31
|
+
scavioYoutubeChannel: () => scavioYoutubeChannel,
|
|
32
|
+
scavioYoutubeComments: () => scavioYoutubeComments,
|
|
33
|
+
scavioYoutubeSearch: () => scavioYoutubeSearch,
|
|
34
|
+
scavioYoutubeTranscript: () => scavioYoutubeTranscript,
|
|
35
|
+
scavioYoutubeVideo: () => scavioYoutubeVideo
|
|
31
36
|
});
|
|
32
37
|
module.exports = __toCommonJS(index_exports);
|
|
33
38
|
var import_ai = require("ai");
|
|
@@ -36,17 +41,19 @@ var import_scavio = require("scavio");
|
|
|
36
41
|
function client(config) {
|
|
37
42
|
return new import_scavio.Scavio({ apiKey: config?.apiKey });
|
|
38
43
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
if (Array.isArray(
|
|
42
|
-
return { ...res,
|
|
44
|
+
function trimFlat(res, key, max) {
|
|
45
|
+
const list = res[key];
|
|
46
|
+
if (Array.isArray(list) && list.length > max) {
|
|
47
|
+
return { ...res, [key]: list.slice(0, max) };
|
|
43
48
|
}
|
|
44
49
|
return res;
|
|
45
50
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
51
|
+
function trimData(res, key, max) {
|
|
52
|
+
const data = res.data;
|
|
53
|
+
if (!data || typeof data !== "object") return res;
|
|
54
|
+
const list = data[key];
|
|
48
55
|
if (Array.isArray(list) && list.length > max) {
|
|
49
|
-
return { ...res, [key]: list.slice(0, max) };
|
|
56
|
+
return { ...res, data: { ...data, [key]: list.slice(0, max) } };
|
|
50
57
|
}
|
|
51
58
|
return res;
|
|
52
59
|
}
|
|
@@ -70,7 +77,7 @@ function scavioSearch(config) {
|
|
|
70
77
|
if (page && page > 1) params.start = (page - 1) * 10;
|
|
71
78
|
if (device) params.device = device;
|
|
72
79
|
if (nfpr !== void 0) params.nfpr = nfpr;
|
|
73
|
-
return
|
|
80
|
+
return trimFlat(await c.google.search(params), "organic_results", max);
|
|
74
81
|
}
|
|
75
82
|
});
|
|
76
83
|
}
|
|
@@ -78,64 +85,138 @@ function scavioYoutubeSearch(config) {
|
|
|
78
85
|
const c = client(config);
|
|
79
86
|
const max = config?.maxResults ?? 10;
|
|
80
87
|
return (0, import_ai.tool)({
|
|
81
|
-
description: "Search YouTube for videos via the Scavio API.",
|
|
88
|
+
description: "Search YouTube for videos, channels, or playlists via the Scavio API (2 credits). Videos come back under `data.results`, with `data.channels` and `data.playlists` alongside.",
|
|
89
|
+
inputSchema: import_zod.z.object({
|
|
90
|
+
query: import_zod.z.string().describe("The search query."),
|
|
91
|
+
upload_date: import_zod.z.string().optional().describe("Upload date filter, e.g. 'today', 'this_week', 'this_month'."),
|
|
92
|
+
type: import_zod.z.string().optional().describe("Result type: 'video', 'channel', 'playlist', 'movie'."),
|
|
93
|
+
duration: import_zod.z.string().optional().describe("Duration filter: 'short', 'medium', 'long'."),
|
|
94
|
+
sort_by: import_zod.z.string().optional().describe("Sort order: 'relevance', 'date', 'view_count', 'rating'."),
|
|
95
|
+
cursor: import_zod.z.string().optional().describe("Pagination cursor (`next_cursor`) from a prior response.")
|
|
96
|
+
}),
|
|
97
|
+
execute: async ({ query, upload_date, type, duration, sort_by, cursor }) => trimData(
|
|
98
|
+
await c.youtube.search({ query, upload_date, type, duration, sort_by, cursor }),
|
|
99
|
+
"results",
|
|
100
|
+
max
|
|
101
|
+
)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function scavioYoutubeVideo(config) {
|
|
105
|
+
const c = client(config);
|
|
106
|
+
return (0, import_ai.tool)({
|
|
107
|
+
description: "Fetch full details for a YouTube video (title, author, view count, description, captions, chapters) via the Scavio API.",
|
|
108
|
+
inputSchema: import_zod.z.object({
|
|
109
|
+
video_id: import_zod.z.string().describe("YouTube video id or a full watch URL.")
|
|
110
|
+
}),
|
|
111
|
+
execute: async ({ video_id }) => c.youtube.video({ video_id })
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function scavioYoutubeTranscript(config) {
|
|
115
|
+
const c = client(config);
|
|
116
|
+
return (0, import_ai.tool)({
|
|
117
|
+
description: "Fetch a YouTube video's transcript or timed subtitles via the Scavio API (8 credits).",
|
|
118
|
+
inputSchema: import_zod.z.object({
|
|
119
|
+
video_id: import_zod.z.string().describe("YouTube video id or a full watch URL."),
|
|
120
|
+
language: import_zod.z.string().optional().describe("Transcript language code (default 'en')."),
|
|
121
|
+
format: import_zod.z.enum(["text", "srt"]).optional().describe("'text' for a plain transcript, 'srt' for timed subtitles.")
|
|
122
|
+
}),
|
|
123
|
+
execute: async ({ video_id, language, format }) => c.youtube.transcript({ video_id, language, format })
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function scavioYoutubeComments(config) {
|
|
127
|
+
const c = client(config);
|
|
128
|
+
const max = config?.maxResults ?? 10;
|
|
129
|
+
return (0, import_ai.tool)({
|
|
130
|
+
description: "List comments on a YouTube video via the Scavio API.",
|
|
82
131
|
inputSchema: import_zod.z.object({
|
|
83
|
-
|
|
132
|
+
video_id: import_zod.z.string().describe("YouTube video id or a full watch URL."),
|
|
133
|
+
cursor: import_zod.z.string().optional().describe("Pagination cursor.")
|
|
84
134
|
}),
|
|
85
|
-
execute: async ({
|
|
135
|
+
execute: async ({ video_id, cursor }) => trimData(
|
|
136
|
+
await c.youtube.comments({ video_id, cursor }),
|
|
137
|
+
"comments",
|
|
138
|
+
max
|
|
139
|
+
)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function scavioYoutubeChannel(config) {
|
|
143
|
+
const c = client(config);
|
|
144
|
+
return (0, import_ai.tool)({
|
|
145
|
+
description: "Fetch a YouTube channel's details (subscribers, video count, views, links) via the Scavio API.",
|
|
146
|
+
inputSchema: import_zod.z.object({
|
|
147
|
+
channel_id: import_zod.z.string().describe("YouTube channel id, @handle, or channel URL.")
|
|
148
|
+
}),
|
|
149
|
+
execute: async ({ channel_id }) => c.youtube.channel({ channel_id })
|
|
86
150
|
});
|
|
87
151
|
}
|
|
88
152
|
function scavioRedditSearch(config) {
|
|
89
153
|
const c = client(config);
|
|
90
154
|
const max = config?.maxResults ?? 10;
|
|
91
155
|
return (0, import_ai.tool)({
|
|
92
|
-
description: "Search Reddit posts
|
|
156
|
+
description: "Search Reddit posts via the Scavio API (1 credit). Returns matching posts under `data.results` with `data.next_cursor` for the next page. Results cannot be sorted or filtered by type.",
|
|
93
157
|
inputSchema: import_zod.z.object({
|
|
94
158
|
query: import_zod.z.string().describe("The search query."),
|
|
95
|
-
|
|
159
|
+
cursor: import_zod.z.string().optional().describe("Pagination cursor (`next_cursor`) from a prior response.")
|
|
96
160
|
}),
|
|
97
|
-
execute: async ({ query,
|
|
161
|
+
execute: async ({ query, cursor }) => trimData(await c.reddit.search({ query, cursor }), "results", max)
|
|
98
162
|
});
|
|
99
163
|
}
|
|
100
164
|
function scavioAmazonSearch(config) {
|
|
101
165
|
const c = client(config);
|
|
102
166
|
const max = config?.maxResults ?? 10;
|
|
103
167
|
return (0, import_ai.tool)({
|
|
104
|
-
description: "Search Amazon for products via the Scavio API.",
|
|
168
|
+
description: "Search Amazon for products via the Scavio API. Results are unsorted and cannot be filtered by category, merchant or price.",
|
|
105
169
|
inputSchema: import_zod.z.object({
|
|
106
170
|
query: import_zod.z.string().describe("The product search query."),
|
|
107
|
-
|
|
171
|
+
country: import_zod.z.string().optional().describe(
|
|
172
|
+
"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us."
|
|
173
|
+
)
|
|
174
|
+
}),
|
|
175
|
+
execute: async ({ query, country }) => trimData(await c.amazon.search({ query, country }), "products", max)
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function scavioAmazonOffers(config) {
|
|
179
|
+
const c = client(config);
|
|
180
|
+
const max = config?.maxResults ?? 10;
|
|
181
|
+
return (0, import_ai.tool)({
|
|
182
|
+
description: "List every seller offer for one Amazon ASIN via the Scavio API: price, seller, condition, shipping, and which offer holds the buy box. Page 1 only.",
|
|
183
|
+
inputSchema: import_zod.z.object({
|
|
184
|
+
asin: import_zod.z.string().describe("Amazon Standard Identification Number (ASIN) of the product."),
|
|
185
|
+
country: import_zod.z.string().optional().describe(
|
|
186
|
+
"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us."
|
|
187
|
+
)
|
|
108
188
|
}),
|
|
109
|
-
execute: async ({
|
|
189
|
+
execute: async ({ asin, country }) => trimData(await c.amazon.offers({ asin, country }), "offers", max)
|
|
110
190
|
});
|
|
111
191
|
}
|
|
112
192
|
function scavioWalmartSearch(config) {
|
|
113
193
|
const c = client(config);
|
|
114
194
|
const max = config?.maxResults ?? 10;
|
|
115
195
|
return (0, import_ai.tool)({
|
|
116
|
-
description: "Search Walmart for products via the Scavio API.",
|
|
196
|
+
description: "Search Walmart for products via the Scavio API. Products come back under `data.products`.",
|
|
117
197
|
inputSchema: import_zod.z.object({
|
|
118
198
|
query: import_zod.z.string().describe("The product search query.")
|
|
119
199
|
}),
|
|
120
|
-
execute: async ({ query }) =>
|
|
200
|
+
execute: async ({ query }) => trimData(await c.walmart.search({ query }), "products", max)
|
|
121
201
|
});
|
|
122
202
|
}
|
|
123
203
|
function scavioTiktokSearch(config) {
|
|
124
204
|
const c = client(config);
|
|
125
205
|
const max = config?.maxResults ?? 10;
|
|
126
206
|
return (0, import_ai.tool)({
|
|
127
|
-
description: "Search TikTok for videos by keyword via the Scavio API.",
|
|
207
|
+
description: "Search TikTok for videos by keyword via the Scavio API. Videos come back under `data.aweme_list`.",
|
|
128
208
|
inputSchema: import_zod.z.object({
|
|
129
209
|
keyword: import_zod.z.string().describe("The search keyword."),
|
|
130
|
-
sort_type: import_zod.z.
|
|
131
|
-
publish_time: import_zod.z.
|
|
210
|
+
sort_type: import_zod.z.enum(["0", "1"]).optional().describe("Sort order: '0' relevance, '1' most likes."),
|
|
211
|
+
publish_time: import_zod.z.enum(["0", "1", "7", "30", "90", "180"]).optional().describe("Publish window in days: '0' all time, '1', '7', '30', '90', '180'.")
|
|
132
212
|
}),
|
|
133
|
-
execute: async ({ keyword, sort_type, publish_time }) =>
|
|
213
|
+
execute: async ({ keyword, sort_type, publish_time }) => trimData(
|
|
134
214
|
await c.tiktok.searchVideos({
|
|
135
215
|
keyword,
|
|
136
216
|
sort_type,
|
|
137
217
|
publish_time
|
|
138
218
|
}),
|
|
219
|
+
"aweme_list",
|
|
139
220
|
max
|
|
140
221
|
)
|
|
141
222
|
});
|
|
@@ -144,19 +225,24 @@ function scavioInstagramSearch(config) {
|
|
|
144
225
|
const c = client(config);
|
|
145
226
|
const max = config?.maxResults ?? 10;
|
|
146
227
|
return (0, import_ai.tool)({
|
|
147
|
-
description: "Search Instagram for users by keyword via the Scavio API.",
|
|
228
|
+
description: "Search Instagram for users by keyword via the Scavio API (10 credits). Users come back under `data.users`.",
|
|
148
229
|
inputSchema: import_zod.z.object({
|
|
149
230
|
keyword: import_zod.z.string().describe("The search keyword.")
|
|
150
231
|
}),
|
|
151
|
-
execute: async ({ keyword }) =>
|
|
232
|
+
execute: async ({ keyword }) => trimData(await c.instagram.searchUsers({ keyword }), "users", max)
|
|
152
233
|
});
|
|
153
234
|
}
|
|
154
235
|
function scavioTools(config) {
|
|
155
236
|
return {
|
|
156
237
|
scavio_search: scavioSearch(config),
|
|
157
238
|
scavio_youtube_search: scavioYoutubeSearch(config),
|
|
239
|
+
scavio_youtube_video: scavioYoutubeVideo(config),
|
|
240
|
+
scavio_youtube_transcript: scavioYoutubeTranscript(config),
|
|
241
|
+
scavio_youtube_comments: scavioYoutubeComments(config),
|
|
242
|
+
scavio_youtube_channel: scavioYoutubeChannel(config),
|
|
158
243
|
scavio_reddit_search: scavioRedditSearch(config),
|
|
159
244
|
scavio_amazon_search: scavioAmazonSearch(config),
|
|
245
|
+
scavio_amazon_offers: scavioAmazonOffers(config),
|
|
160
246
|
scavio_walmart_search: scavioWalmartSearch(config),
|
|
161
247
|
scavio_tiktok_search: scavioTiktokSearch(config),
|
|
162
248
|
scavio_instagram_search: scavioInstagramSearch(config)
|
|
@@ -164,6 +250,7 @@ function scavioTools(config) {
|
|
|
164
250
|
}
|
|
165
251
|
// Annotate the CommonJS export names for ESM import in node:
|
|
166
252
|
0 && (module.exports = {
|
|
253
|
+
scavioAmazonOffers,
|
|
167
254
|
scavioAmazonSearch,
|
|
168
255
|
scavioInstagramSearch,
|
|
169
256
|
scavioRedditSearch,
|
|
@@ -171,6 +258,10 @@ function scavioTools(config) {
|
|
|
171
258
|
scavioTiktokSearch,
|
|
172
259
|
scavioTools,
|
|
173
260
|
scavioWalmartSearch,
|
|
174
|
-
|
|
261
|
+
scavioYoutubeChannel,
|
|
262
|
+
scavioYoutubeComments,
|
|
263
|
+
scavioYoutubeSearch,
|
|
264
|
+
scavioYoutubeTranscript,
|
|
265
|
+
scavioYoutubeVideo
|
|
175
266
|
});
|
|
176
267
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { Scavio, type ScavioConfig, type GoogleSearchOptions } from \"scavio\";\n\nexport interface ScavioToolConfig extends ScavioConfig {\n /** Max number of results to keep in `results`-style lists. Defaults to 10. */\n maxResults?: number;\n}\n\nfunction client(config?: ScavioToolConfig): Scavio {\n return new Scavio({ apiKey: config?.apiKey });\n}\n\nfunction trim(res: Record<string, unknown>, max: number): Record<string, unknown> {\n const results = res.results;\n if (Array.isArray(results) && results.length > max) {\n return { ...res, results: results.slice(0, max) };\n }\n return res;\n}\n\nfunction trimList(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const list = res[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, [key]: list.slice(0, max) };\n }\n return res;\n}\n\n/** Google web search (/api/v2/google, 1 credit). */\nexport function scavioSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search the web with Google via the Scavio API (1 credit). Returns real-time organic search results, each with a title, link, and snippet, under `organic_results`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n countryCode: z.string().optional().describe('Two-letter country code to localize results, e.g. \"us\".'),\n language: z.string().optional().describe('Two-letter UI language code, e.g. \"en\".'),\n page: z.number().int().optional().describe(\"1-based result page; page 2 starts at result 10.\"),\n device: z.enum([\"desktop\", \"mobile\"]).optional().describe(\"Device to emulate.\"),\n nfpr: z.boolean().optional().describe(\"Disable spelling auto-correction / similar-result substitution when true.\"),\n }),\n execute: async ({ query, countryCode, language, page, device, nfpr }) => {\n const params: GoogleSearchOptions = { query };\n if (countryCode) params.gl = countryCode;\n if (language) params.hl = language;\n if (page && page > 1) params.start = (page - 1) * 10;\n if (device) params.device = device;\n if (nfpr !== undefined) params.nfpr = nfpr;\n return trimList(await c.google.search(params), \"organic_results\", max);\n },\n });\n}\n\n/** YouTube video search. */\nexport function scavioYoutubeSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search YouTube for videos via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n }),\n execute: async ({ query }) => trim(await c.youtube.search({ query }), max),\n });\n}\n\n/** Reddit post/community search (costs 2 credits). */\nexport function scavioRedditSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Reddit posts and communities via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n sort: z.string().optional().describe(\"Sort order for results.\"),\n }),\n execute: async ({ query, sort }) =>\n trim(await c.reddit.search({ query, sort } as Parameters<typeof c.reddit.search>[0]), max),\n });\n}\n\n/** Amazon product search. */\nexport function scavioAmazonSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Amazon for products via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n domain: z.string().optional().describe('Amazon domain, e.g. \"amazon.com\".'),\n }),\n execute: async ({ query, domain }) => trim(await c.amazon.search({ query, domain }), max),\n });\n}\n\n/** Walmart product search. */\nexport function scavioWalmartSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Walmart for products via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n }),\n execute: async ({ query }) => trim(await c.walmart.search({ query }), max),\n });\n}\n\n/** TikTok video search. */\nexport function scavioTiktokSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search TikTok for videos by keyword via the Scavio API.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n sort_type: z.string().optional().describe(\"Sort order for results.\"),\n publish_time: z.string().optional().describe(\"Filter by publish time window.\"),\n }),\n execute: async ({ keyword, sort_type, publish_time }) =>\n trim(\n await c.tiktok.searchVideos({\n keyword,\n sort_type,\n publish_time,\n } as Parameters<typeof c.tiktok.searchVideos>[0]),\n max,\n ),\n });\n}\n\n/** Instagram user search. */\nexport function scavioInstagramSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Instagram for users by keyword via the Scavio API.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n }),\n execute: async ({ keyword }) => trim(await c.instagram.searchUsers({ keyword }), max),\n });\n}\n\n/**\n * All Scavio tools as an object keyed by tool name, ready to spread into the\n * `tools` option of `generateText` / `streamText`.\n */\nexport function scavioTools(config?: ScavioToolConfig) {\n return {\n scavio_search: scavioSearch(config),\n scavio_youtube_search: scavioYoutubeSearch(config),\n scavio_reddit_search: scavioRedditSearch(config),\n scavio_amazon_search: scavioAmazonSearch(config),\n scavio_walmart_search: scavioWalmartSearch(config),\n scavio_tiktok_search: scavioTiktokSearch(config),\n scavio_instagram_search: scavioInstagramSearch(config),\n };\n}\n"],"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AChD;AAAA,IACF;AAAA,EACJ,CAAC;AACH;AAGO,SAAS,sBAAsB,QAA2B;AAC/D,QAAM,IAAI,OAAO,MAAM;AACvB,QAAM,MAAM,QAAQ,cAAc;AAClC,aAAO,gBAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,aAAE,OAAO;AAAA,MACpB,SAAS,aAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,IACpD,CAAC;AAAA,IACD,SAAS,OAAO,EAAE,QAAQ,MAAM,KAAK,MAAM,EAAE,UAAU,YAAY,EAAE,QAAQ,CAAC,GAAG,GAAG;AAAA,EACtF,CAAC;AACH;AAMO,SAAS,YAAY,QAA2B;AACrD,SAAO;AAAA,IACL,eAAe,aAAa,MAAM;AAAA,IAClC,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,yBAAyB,sBAAsB,MAAM;AAAA,EACvD;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { Scavio, type ScavioConfig, type GoogleSearchOptions } from \"scavio\";\n\nexport interface ScavioToolConfig extends ScavioConfig {\n /**\n * Max number of items to keep in the tool's result list. Defaults to 10.\n * Trimmed inside `data` on every platform except Google, whose body is flat.\n */\n maxResults?: number;\n}\n\nfunction client(config?: ScavioToolConfig): Scavio {\n return new Scavio({ apiKey: config?.apiKey });\n}\n\n/**\n * Google is the ONLY family with a flat body: `organic_results` and friends sit\n * at the top level, next to `response_time` / `credits_used` / `credits_remaining`.\n */\nfunction trimFlat(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const list = res[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, [key]: list.slice(0, max) };\n }\n return res;\n}\n\n/**\n * Every non-Google endpoint nests its payload under `data` - the response is\n * `{ data: { products: [...] }, response_time, credits_used, credits_remaining }`.\n * Trimming the top level is therefore a silent no-op, so those tools trim\n * inside `data`.\n */\nfunction trimData(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const data = res.data;\n if (!data || typeof data !== \"object\") return res;\n const list = (data as Record<string, unknown>)[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, data: { ...(data as Record<string, unknown>), [key]: list.slice(0, max) } };\n }\n return res;\n}\n\n/** Google web search (/api/v2/google, 1 credit). */\nexport function scavioSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search the web with Google via the Scavio API (1 credit). Returns real-time organic search results, each with a title, link, and snippet, under `organic_results`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n countryCode: z.string().optional().describe('Two-letter country code to localize results, e.g. \"us\".'),\n language: z.string().optional().describe('Two-letter UI language code, e.g. \"en\".'),\n page: z.number().int().optional().describe(\"1-based result page; page 2 starts at result 10.\"),\n device: z.enum([\"desktop\", \"mobile\"]).optional().describe(\"Device to emulate.\"),\n nfpr: z.boolean().optional().describe(\"Disable spelling auto-correction / similar-result substitution when true.\"),\n }),\n execute: async ({ query, countryCode, language, page, device, nfpr }) => {\n const params: GoogleSearchOptions = { query };\n if (countryCode) params.gl = countryCode;\n if (language) params.hl = language;\n if (page && page > 1) params.start = (page - 1) * 10;\n if (device) params.device = device;\n if (nfpr !== undefined) params.nfpr = nfpr;\n return trimFlat(await c.google.search(params), \"organic_results\", max);\n },\n });\n}\n\n/** YouTube video search (2 credits). */\nexport function scavioYoutubeSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search YouTube for videos, channels, or playlists via the Scavio API (2 credits). Videos come back under `data.results`, with `data.channels` and `data.playlists` alongside.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n upload_date: z.string().optional().describe(\"Upload date filter, e.g. 'today', 'this_week', 'this_month'.\"),\n type: z.string().optional().describe(\"Result type: 'video', 'channel', 'playlist', 'movie'.\"),\n duration: z.string().optional().describe(\"Duration filter: 'short', 'medium', 'long'.\"),\n sort_by: z.string().optional().describe(\"Sort order: 'relevance', 'date', 'view_count', 'rating'.\"),\n cursor: z.string().optional().describe(\"Pagination cursor (`next_cursor`) from a prior response.\"),\n }),\n execute: async ({ query, upload_date, type, duration, sort_by, cursor }) =>\n trimData(\n await c.youtube.search({ query, upload_date, type, duration, sort_by, cursor } as Parameters<\n typeof c.youtube.search\n >[0]),\n \"results\",\n max,\n ),\n });\n}\n\n/** YouTube video details (1 credit). */\nexport function scavioYoutubeVideo(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch full details for a YouTube video (title, author, view count, description, captions, chapters) via the Scavio API.\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n }),\n execute: async ({ video_id }) => c.youtube.video({ video_id }),\n });\n}\n\n/** YouTube video transcript / subtitles (8 credits). */\nexport function scavioYoutubeTranscript(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch a YouTube video's transcript or timed subtitles via the Scavio API (8 credits).\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n language: z.string().optional().describe(\"Transcript language code (default 'en').\"),\n format: z.enum([\"text\", \"srt\"]).optional().describe(\"'text' for a plain transcript, 'srt' for timed subtitles.\"),\n }),\n execute: async ({ video_id, language, format }) =>\n c.youtube.transcript({ video_id, language, format } as Parameters<typeof c.youtube.transcript>[0]),\n });\n}\n\n/** YouTube video comments (1 credit). */\nexport function scavioYoutubeComments(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"List comments on a YouTube video via the Scavio API.\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n cursor: z.string().optional().describe(\"Pagination cursor.\"),\n }),\n execute: async ({ video_id, cursor }) =>\n trimData(\n await c.youtube.comments({ video_id, cursor } as Parameters<typeof c.youtube.comments>[0]),\n \"comments\",\n max,\n ),\n });\n}\n\n/** YouTube channel details (1 credit). */\nexport function scavioYoutubeChannel(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch a YouTube channel's details (subscribers, video count, views, links) via the Scavio API.\",\n inputSchema: z.object({\n channel_id: z.string().describe(\"YouTube channel id, @handle, or channel URL.\"),\n }),\n execute: async ({ channel_id }) => c.youtube.channel({ channel_id }),\n });\n}\n\n/**\n * Reddit post search (1 credit).\n *\n * The endpoint takes `query` and `cursor` and nothing else - it cannot sort or\n * filter by type, so no such input is offered. The API silently ignores those\n * params, which would leave a model believing it had filtered when it had not.\n */\nexport function scavioRedditSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Reddit posts via the Scavio API (1 credit). Returns matching posts under `data.results` with `data.next_cursor` for the next page. Results cannot be sorted or filtered by type.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n cursor: z.string().optional().describe(\"Pagination cursor (`next_cursor`) from a prior response.\"),\n }),\n execute: async ({ query, cursor }) => trimData(await c.reddit.search({ query, cursor }), \"results\", max),\n });\n}\n\n/**\n * Amazon product search.\n *\n * `domain` was dropped in favour of `country`, a two-letter marketplace code -\n * the upstream provider changed in 2026-07 and no longer takes a domain\n * suffix. It still works on the wire as a deprecated alias, but a model should\n * only ever see one spelling of a param.\n */\nexport function scavioAmazonSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Amazon for products via the Scavio API. Results are unsorted and cannot be filtered by category, merchant or price.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n country: z\n .string()\n .optional()\n .describe(\n \"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us.\"\n ),\n }),\n execute: async ({ query, country }) =>\n trimData(await c.amazon.search({ query, country }), \"products\", max),\n });\n}\n\n/** Every seller offer for one Amazon ASIN. */\nexport function scavioAmazonOffers(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"List every seller offer for one Amazon ASIN via the Scavio API: price, seller, condition, shipping, and which offer holds the buy box. Page 1 only.\",\n inputSchema: z.object({\n asin: z.string().describe(\"Amazon Standard Identification Number (ASIN) of the product.\"),\n country: z\n .string()\n .optional()\n .describe(\n \"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us.\"\n ),\n }),\n execute: async ({ asin, country }) =>\n trimData(await c.amazon.offers({ asin, country }), \"offers\", max),\n });\n}\n\n/** Walmart product search. */\nexport function scavioWalmartSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Walmart for products via the Scavio API. Products come back under `data.products`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n }),\n execute: async ({ query }) => trimData(await c.walmart.search({ query }), \"products\", max),\n });\n}\n\n/** TikTok video search. */\nexport function scavioTiktokSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search TikTok for videos by keyword via the Scavio API. Videos come back under `data.aweme_list`.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n sort_type: z.enum([\"0\", \"1\"]).optional().describe(\"Sort order: '0' relevance, '1' most likes.\"),\n publish_time: z\n .enum([\"0\", \"1\", \"7\", \"30\", \"90\", \"180\"])\n .optional()\n .describe(\"Publish window in days: '0' all time, '1', '7', '30', '90', '180'.\"),\n }),\n execute: async ({ keyword, sort_type, publish_time }) =>\n trimData(\n await c.tiktok.searchVideos({\n keyword,\n sort_type,\n publish_time,\n } as Parameters<typeof c.tiktok.searchVideos>[0]),\n \"aweme_list\",\n max,\n ),\n });\n}\n\n/** Instagram user search. */\nexport function scavioInstagramSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Instagram for users by keyword via the Scavio API (10 credits). Users come back under `data.users`.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n }),\n execute: async ({ keyword }) => trimData(await c.instagram.searchUsers({ keyword }), \"users\", max),\n });\n}\n\n/**\n * All Scavio tools as an object keyed by tool name, ready to spread into the\n * `tools` option of `generateText` / `streamText`.\n */\nexport function scavioTools(config?: ScavioToolConfig) {\n return {\n scavio_search: scavioSearch(config),\n scavio_youtube_search: scavioYoutubeSearch(config),\n scavio_youtube_video: scavioYoutubeVideo(config),\n scavio_youtube_transcript: scavioYoutubeTranscript(config),\n scavio_youtube_comments: scavioYoutubeComments(config),\n scavio_youtube_channel: scavioYoutubeChannel(config),\n scavio_reddit_search: scavioRedditSearch(config),\n scavio_amazon_search: scavioAmazonSearch(config),\n scavio_amazon_offers: scavioAmazonOffers(config),\n scavio_walmart_search: scavioWalmartSearch(config),\n scavio_tiktok_search: scavioTiktokSearch(config),\n scavio_instagram_search: scavioInstagramSearch(config),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqB;AACrB,iBAAkB;AAClB,oBAAoE;AAUpE,SAAS,OAAO,QAAmC;AACjD,SAAO,IAAI,qBAAO,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAC9C;AAMA,SAAS,SAAS,KAA8B,KAAa,KAAsC;AACjG,QAAM,OAAO,IAAI,GAAG;AACpB,MAAI,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,KAAK;AAC5C,WAAO,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,MAAM,GAAG,GA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E,UAAU,YAAY,EAAE,QAAQ,CAAC,GAAG,SAAS,GAAG;AAAA,EACnG,CAAC;AACH;AAMO,SAAS,YAAY,QAA2B;AACrD,SAAO;AAAA,IACL,eAAe,aAAa,MAAM;AAAA,IAClC,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,2BAA2B,wBAAwB,MAAM;AAAA,IACzD,yBAAyB,sBAAsB,MAAM;AAAA,IACrD,wBAAwB,qBAAqB,MAAM;AAAA,IACnD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,yBAAyB,sBAAsB,MAAM;AAAA,EACvD;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,10 @@ import * as ai from 'ai';
|
|
|
2
2
|
import { ScavioConfig } from 'scavio';
|
|
3
3
|
|
|
4
4
|
interface ScavioToolConfig extends ScavioConfig {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Max number of items to keep in the tool's result list. Defaults to 10.
|
|
7
|
+
* Trimmed inside `data` on every platform except Google, whose body is flat.
|
|
8
|
+
*/
|
|
6
9
|
maxResults?: number;
|
|
7
10
|
}
|
|
8
11
|
/** Google web search (/api/v2/google, 1 credit). */
|
|
@@ -14,19 +17,61 @@ declare function scavioSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
|
14
17
|
device?: "desktop" | "mobile" | undefined;
|
|
15
18
|
nfpr?: boolean | undefined;
|
|
16
19
|
}, Record<string, unknown>>;
|
|
17
|
-
/** YouTube video search. */
|
|
20
|
+
/** YouTube video search (2 credits). */
|
|
18
21
|
declare function scavioYoutubeSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
19
22
|
query: string;
|
|
23
|
+
type?: string | undefined;
|
|
24
|
+
upload_date?: string | undefined;
|
|
25
|
+
duration?: string | undefined;
|
|
26
|
+
sort_by?: string | undefined;
|
|
27
|
+
cursor?: string | undefined;
|
|
20
28
|
}, Record<string, unknown>>;
|
|
21
|
-
/**
|
|
29
|
+
/** YouTube video details (1 credit). */
|
|
30
|
+
declare function scavioYoutubeVideo(config?: ScavioToolConfig): ai.Tool<{
|
|
31
|
+
video_id: string;
|
|
32
|
+
}, Record<string, unknown>>;
|
|
33
|
+
/** YouTube video transcript / subtitles (8 credits). */
|
|
34
|
+
declare function scavioYoutubeTranscript(config?: ScavioToolConfig): ai.Tool<{
|
|
35
|
+
video_id: string;
|
|
36
|
+
language?: string | undefined;
|
|
37
|
+
format?: "text" | "srt" | undefined;
|
|
38
|
+
}, Record<string, unknown>>;
|
|
39
|
+
/** YouTube video comments (1 credit). */
|
|
40
|
+
declare function scavioYoutubeComments(config?: ScavioToolConfig): ai.Tool<{
|
|
41
|
+
video_id: string;
|
|
42
|
+
cursor?: string | undefined;
|
|
43
|
+
}, Record<string, unknown>>;
|
|
44
|
+
/** YouTube channel details (1 credit). */
|
|
45
|
+
declare function scavioYoutubeChannel(config?: ScavioToolConfig): ai.Tool<{
|
|
46
|
+
channel_id: string;
|
|
47
|
+
}, Record<string, unknown>>;
|
|
48
|
+
/**
|
|
49
|
+
* Reddit post search (1 credit).
|
|
50
|
+
*
|
|
51
|
+
* The endpoint takes `query` and `cursor` and nothing else - it cannot sort or
|
|
52
|
+
* filter by type, so no such input is offered. The API silently ignores those
|
|
53
|
+
* params, which would leave a model believing it had filtered when it had not.
|
|
54
|
+
*/
|
|
22
55
|
declare function scavioRedditSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
23
56
|
query: string;
|
|
24
|
-
|
|
57
|
+
cursor?: string | undefined;
|
|
25
58
|
}, Record<string, unknown>>;
|
|
26
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Amazon product search.
|
|
61
|
+
*
|
|
62
|
+
* `domain` was dropped in favour of `country`, a two-letter marketplace code -
|
|
63
|
+
* the upstream provider changed in 2026-07 and no longer takes a domain
|
|
64
|
+
* suffix. It still works on the wire as a deprecated alias, but a model should
|
|
65
|
+
* only ever see one spelling of a param.
|
|
66
|
+
*/
|
|
27
67
|
declare function scavioAmazonSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
28
68
|
query: string;
|
|
29
|
-
|
|
69
|
+
country?: string | undefined;
|
|
70
|
+
}, Record<string, unknown>>;
|
|
71
|
+
/** Every seller offer for one Amazon ASIN. */
|
|
72
|
+
declare function scavioAmazonOffers(config?: ScavioToolConfig): ai.Tool<{
|
|
73
|
+
asin: string;
|
|
74
|
+
country?: string | undefined;
|
|
30
75
|
}, Record<string, unknown>>;
|
|
31
76
|
/** Walmart product search. */
|
|
32
77
|
declare function scavioWalmartSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
@@ -35,8 +80,8 @@ declare function scavioWalmartSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
|
35
80
|
/** TikTok video search. */
|
|
36
81
|
declare function scavioTiktokSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
37
82
|
keyword: string;
|
|
38
|
-
sort_type?:
|
|
39
|
-
publish_time?:
|
|
83
|
+
sort_type?: "0" | "1" | undefined;
|
|
84
|
+
publish_time?: "0" | "1" | "7" | "30" | "90" | "180" | undefined;
|
|
40
85
|
}, Record<string, unknown>>;
|
|
41
86
|
/** Instagram user search. */
|
|
42
87
|
declare function scavioInstagramSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
@@ -57,26 +102,50 @@ declare function scavioTools(config?: ScavioToolConfig): {
|
|
|
57
102
|
}, Record<string, unknown>>;
|
|
58
103
|
scavio_youtube_search: ai.Tool<{
|
|
59
104
|
query: string;
|
|
105
|
+
type?: string | undefined;
|
|
106
|
+
upload_date?: string | undefined;
|
|
107
|
+
duration?: string | undefined;
|
|
108
|
+
sort_by?: string | undefined;
|
|
109
|
+
cursor?: string | undefined;
|
|
110
|
+
}, Record<string, unknown>>;
|
|
111
|
+
scavio_youtube_video: ai.Tool<{
|
|
112
|
+
video_id: string;
|
|
113
|
+
}, Record<string, unknown>>;
|
|
114
|
+
scavio_youtube_transcript: ai.Tool<{
|
|
115
|
+
video_id: string;
|
|
116
|
+
language?: string | undefined;
|
|
117
|
+
format?: "text" | "srt" | undefined;
|
|
118
|
+
}, Record<string, unknown>>;
|
|
119
|
+
scavio_youtube_comments: ai.Tool<{
|
|
120
|
+
video_id: string;
|
|
121
|
+
cursor?: string | undefined;
|
|
122
|
+
}, Record<string, unknown>>;
|
|
123
|
+
scavio_youtube_channel: ai.Tool<{
|
|
124
|
+
channel_id: string;
|
|
60
125
|
}, Record<string, unknown>>;
|
|
61
126
|
scavio_reddit_search: ai.Tool<{
|
|
62
127
|
query: string;
|
|
63
|
-
|
|
128
|
+
cursor?: string | undefined;
|
|
64
129
|
}, Record<string, unknown>>;
|
|
65
130
|
scavio_amazon_search: ai.Tool<{
|
|
66
131
|
query: string;
|
|
67
|
-
|
|
132
|
+
country?: string | undefined;
|
|
133
|
+
}, Record<string, unknown>>;
|
|
134
|
+
scavio_amazon_offers: ai.Tool<{
|
|
135
|
+
asin: string;
|
|
136
|
+
country?: string | undefined;
|
|
68
137
|
}, Record<string, unknown>>;
|
|
69
138
|
scavio_walmart_search: ai.Tool<{
|
|
70
139
|
query: string;
|
|
71
140
|
}, Record<string, unknown>>;
|
|
72
141
|
scavio_tiktok_search: ai.Tool<{
|
|
73
142
|
keyword: string;
|
|
74
|
-
sort_type?:
|
|
75
|
-
publish_time?:
|
|
143
|
+
sort_type?: "0" | "1" | undefined;
|
|
144
|
+
publish_time?: "0" | "1" | "7" | "30" | "90" | "180" | undefined;
|
|
76
145
|
}, Record<string, unknown>>;
|
|
77
146
|
scavio_instagram_search: ai.Tool<{
|
|
78
147
|
keyword: string;
|
|
79
148
|
}, Record<string, unknown>>;
|
|
80
149
|
};
|
|
81
150
|
|
|
82
|
-
export { type ScavioToolConfig, scavioAmazonSearch, scavioInstagramSearch, scavioRedditSearch, scavioSearch, scavioTiktokSearch, scavioTools, scavioWalmartSearch, scavioYoutubeSearch };
|
|
151
|
+
export { type ScavioToolConfig, scavioAmazonOffers, scavioAmazonSearch, scavioInstagramSearch, scavioRedditSearch, scavioSearch, scavioTiktokSearch, scavioTools, scavioWalmartSearch, scavioYoutubeChannel, scavioYoutubeComments, scavioYoutubeSearch, scavioYoutubeTranscript, scavioYoutubeVideo };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import * as ai from 'ai';
|
|
|
2
2
|
import { ScavioConfig } from 'scavio';
|
|
3
3
|
|
|
4
4
|
interface ScavioToolConfig extends ScavioConfig {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Max number of items to keep in the tool's result list. Defaults to 10.
|
|
7
|
+
* Trimmed inside `data` on every platform except Google, whose body is flat.
|
|
8
|
+
*/
|
|
6
9
|
maxResults?: number;
|
|
7
10
|
}
|
|
8
11
|
/** Google web search (/api/v2/google, 1 credit). */
|
|
@@ -14,19 +17,61 @@ declare function scavioSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
|
14
17
|
device?: "desktop" | "mobile" | undefined;
|
|
15
18
|
nfpr?: boolean | undefined;
|
|
16
19
|
}, Record<string, unknown>>;
|
|
17
|
-
/** YouTube video search. */
|
|
20
|
+
/** YouTube video search (2 credits). */
|
|
18
21
|
declare function scavioYoutubeSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
19
22
|
query: string;
|
|
23
|
+
type?: string | undefined;
|
|
24
|
+
upload_date?: string | undefined;
|
|
25
|
+
duration?: string | undefined;
|
|
26
|
+
sort_by?: string | undefined;
|
|
27
|
+
cursor?: string | undefined;
|
|
20
28
|
}, Record<string, unknown>>;
|
|
21
|
-
/**
|
|
29
|
+
/** YouTube video details (1 credit). */
|
|
30
|
+
declare function scavioYoutubeVideo(config?: ScavioToolConfig): ai.Tool<{
|
|
31
|
+
video_id: string;
|
|
32
|
+
}, Record<string, unknown>>;
|
|
33
|
+
/** YouTube video transcript / subtitles (8 credits). */
|
|
34
|
+
declare function scavioYoutubeTranscript(config?: ScavioToolConfig): ai.Tool<{
|
|
35
|
+
video_id: string;
|
|
36
|
+
language?: string | undefined;
|
|
37
|
+
format?: "text" | "srt" | undefined;
|
|
38
|
+
}, Record<string, unknown>>;
|
|
39
|
+
/** YouTube video comments (1 credit). */
|
|
40
|
+
declare function scavioYoutubeComments(config?: ScavioToolConfig): ai.Tool<{
|
|
41
|
+
video_id: string;
|
|
42
|
+
cursor?: string | undefined;
|
|
43
|
+
}, Record<string, unknown>>;
|
|
44
|
+
/** YouTube channel details (1 credit). */
|
|
45
|
+
declare function scavioYoutubeChannel(config?: ScavioToolConfig): ai.Tool<{
|
|
46
|
+
channel_id: string;
|
|
47
|
+
}, Record<string, unknown>>;
|
|
48
|
+
/**
|
|
49
|
+
* Reddit post search (1 credit).
|
|
50
|
+
*
|
|
51
|
+
* The endpoint takes `query` and `cursor` and nothing else - it cannot sort or
|
|
52
|
+
* filter by type, so no such input is offered. The API silently ignores those
|
|
53
|
+
* params, which would leave a model believing it had filtered when it had not.
|
|
54
|
+
*/
|
|
22
55
|
declare function scavioRedditSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
23
56
|
query: string;
|
|
24
|
-
|
|
57
|
+
cursor?: string | undefined;
|
|
25
58
|
}, Record<string, unknown>>;
|
|
26
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Amazon product search.
|
|
61
|
+
*
|
|
62
|
+
* `domain` was dropped in favour of `country`, a two-letter marketplace code -
|
|
63
|
+
* the upstream provider changed in 2026-07 and no longer takes a domain
|
|
64
|
+
* suffix. It still works on the wire as a deprecated alias, but a model should
|
|
65
|
+
* only ever see one spelling of a param.
|
|
66
|
+
*/
|
|
27
67
|
declare function scavioAmazonSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
28
68
|
query: string;
|
|
29
|
-
|
|
69
|
+
country?: string | undefined;
|
|
70
|
+
}, Record<string, unknown>>;
|
|
71
|
+
/** Every seller offer for one Amazon ASIN. */
|
|
72
|
+
declare function scavioAmazonOffers(config?: ScavioToolConfig): ai.Tool<{
|
|
73
|
+
asin: string;
|
|
74
|
+
country?: string | undefined;
|
|
30
75
|
}, Record<string, unknown>>;
|
|
31
76
|
/** Walmart product search. */
|
|
32
77
|
declare function scavioWalmartSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
@@ -35,8 +80,8 @@ declare function scavioWalmartSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
|
35
80
|
/** TikTok video search. */
|
|
36
81
|
declare function scavioTiktokSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
37
82
|
keyword: string;
|
|
38
|
-
sort_type?:
|
|
39
|
-
publish_time?:
|
|
83
|
+
sort_type?: "0" | "1" | undefined;
|
|
84
|
+
publish_time?: "0" | "1" | "7" | "30" | "90" | "180" | undefined;
|
|
40
85
|
}, Record<string, unknown>>;
|
|
41
86
|
/** Instagram user search. */
|
|
42
87
|
declare function scavioInstagramSearch(config?: ScavioToolConfig): ai.Tool<{
|
|
@@ -57,26 +102,50 @@ declare function scavioTools(config?: ScavioToolConfig): {
|
|
|
57
102
|
}, Record<string, unknown>>;
|
|
58
103
|
scavio_youtube_search: ai.Tool<{
|
|
59
104
|
query: string;
|
|
105
|
+
type?: string | undefined;
|
|
106
|
+
upload_date?: string | undefined;
|
|
107
|
+
duration?: string | undefined;
|
|
108
|
+
sort_by?: string | undefined;
|
|
109
|
+
cursor?: string | undefined;
|
|
110
|
+
}, Record<string, unknown>>;
|
|
111
|
+
scavio_youtube_video: ai.Tool<{
|
|
112
|
+
video_id: string;
|
|
113
|
+
}, Record<string, unknown>>;
|
|
114
|
+
scavio_youtube_transcript: ai.Tool<{
|
|
115
|
+
video_id: string;
|
|
116
|
+
language?: string | undefined;
|
|
117
|
+
format?: "text" | "srt" | undefined;
|
|
118
|
+
}, Record<string, unknown>>;
|
|
119
|
+
scavio_youtube_comments: ai.Tool<{
|
|
120
|
+
video_id: string;
|
|
121
|
+
cursor?: string | undefined;
|
|
122
|
+
}, Record<string, unknown>>;
|
|
123
|
+
scavio_youtube_channel: ai.Tool<{
|
|
124
|
+
channel_id: string;
|
|
60
125
|
}, Record<string, unknown>>;
|
|
61
126
|
scavio_reddit_search: ai.Tool<{
|
|
62
127
|
query: string;
|
|
63
|
-
|
|
128
|
+
cursor?: string | undefined;
|
|
64
129
|
}, Record<string, unknown>>;
|
|
65
130
|
scavio_amazon_search: ai.Tool<{
|
|
66
131
|
query: string;
|
|
67
|
-
|
|
132
|
+
country?: string | undefined;
|
|
133
|
+
}, Record<string, unknown>>;
|
|
134
|
+
scavio_amazon_offers: ai.Tool<{
|
|
135
|
+
asin: string;
|
|
136
|
+
country?: string | undefined;
|
|
68
137
|
}, Record<string, unknown>>;
|
|
69
138
|
scavio_walmart_search: ai.Tool<{
|
|
70
139
|
query: string;
|
|
71
140
|
}, Record<string, unknown>>;
|
|
72
141
|
scavio_tiktok_search: ai.Tool<{
|
|
73
142
|
keyword: string;
|
|
74
|
-
sort_type?:
|
|
75
|
-
publish_time?:
|
|
143
|
+
sort_type?: "0" | "1" | undefined;
|
|
144
|
+
publish_time?: "0" | "1" | "7" | "30" | "90" | "180" | undefined;
|
|
76
145
|
}, Record<string, unknown>>;
|
|
77
146
|
scavio_instagram_search: ai.Tool<{
|
|
78
147
|
keyword: string;
|
|
79
148
|
}, Record<string, unknown>>;
|
|
80
149
|
};
|
|
81
150
|
|
|
82
|
-
export { type ScavioToolConfig, scavioAmazonSearch, scavioInstagramSearch, scavioRedditSearch, scavioSearch, scavioTiktokSearch, scavioTools, scavioWalmartSearch, scavioYoutubeSearch };
|
|
151
|
+
export { type ScavioToolConfig, scavioAmazonOffers, scavioAmazonSearch, scavioInstagramSearch, scavioRedditSearch, scavioSearch, scavioTiktokSearch, scavioTools, scavioWalmartSearch, scavioYoutubeChannel, scavioYoutubeComments, scavioYoutubeSearch, scavioYoutubeTranscript, scavioYoutubeVideo };
|
package/dist/index.js
CHANGED
|
@@ -5,17 +5,19 @@ import { Scavio } from "scavio";
|
|
|
5
5
|
function client(config) {
|
|
6
6
|
return new Scavio({ apiKey: config?.apiKey });
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
if (Array.isArray(
|
|
11
|
-
return { ...res,
|
|
8
|
+
function trimFlat(res, key, max) {
|
|
9
|
+
const list = res[key];
|
|
10
|
+
if (Array.isArray(list) && list.length > max) {
|
|
11
|
+
return { ...res, [key]: list.slice(0, max) };
|
|
12
12
|
}
|
|
13
13
|
return res;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
15
|
+
function trimData(res, key, max) {
|
|
16
|
+
const data = res.data;
|
|
17
|
+
if (!data || typeof data !== "object") return res;
|
|
18
|
+
const list = data[key];
|
|
17
19
|
if (Array.isArray(list) && list.length > max) {
|
|
18
|
-
return { ...res, [key]: list.slice(0, max) };
|
|
20
|
+
return { ...res, data: { ...data, [key]: list.slice(0, max) } };
|
|
19
21
|
}
|
|
20
22
|
return res;
|
|
21
23
|
}
|
|
@@ -39,7 +41,7 @@ function scavioSearch(config) {
|
|
|
39
41
|
if (page && page > 1) params.start = (page - 1) * 10;
|
|
40
42
|
if (device) params.device = device;
|
|
41
43
|
if (nfpr !== void 0) params.nfpr = nfpr;
|
|
42
|
-
return
|
|
44
|
+
return trimFlat(await c.google.search(params), "organic_results", max);
|
|
43
45
|
}
|
|
44
46
|
});
|
|
45
47
|
}
|
|
@@ -47,64 +49,138 @@ function scavioYoutubeSearch(config) {
|
|
|
47
49
|
const c = client(config);
|
|
48
50
|
const max = config?.maxResults ?? 10;
|
|
49
51
|
return tool({
|
|
50
|
-
description: "Search YouTube for videos via the Scavio API.",
|
|
52
|
+
description: "Search YouTube for videos, channels, or playlists via the Scavio API (2 credits). Videos come back under `data.results`, with `data.channels` and `data.playlists` alongside.",
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
query: z.string().describe("The search query."),
|
|
55
|
+
upload_date: z.string().optional().describe("Upload date filter, e.g. 'today', 'this_week', 'this_month'."),
|
|
56
|
+
type: z.string().optional().describe("Result type: 'video', 'channel', 'playlist', 'movie'."),
|
|
57
|
+
duration: z.string().optional().describe("Duration filter: 'short', 'medium', 'long'."),
|
|
58
|
+
sort_by: z.string().optional().describe("Sort order: 'relevance', 'date', 'view_count', 'rating'."),
|
|
59
|
+
cursor: z.string().optional().describe("Pagination cursor (`next_cursor`) from a prior response.")
|
|
60
|
+
}),
|
|
61
|
+
execute: async ({ query, upload_date, type, duration, sort_by, cursor }) => trimData(
|
|
62
|
+
await c.youtube.search({ query, upload_date, type, duration, sort_by, cursor }),
|
|
63
|
+
"results",
|
|
64
|
+
max
|
|
65
|
+
)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function scavioYoutubeVideo(config) {
|
|
69
|
+
const c = client(config);
|
|
70
|
+
return tool({
|
|
71
|
+
description: "Fetch full details for a YouTube video (title, author, view count, description, captions, chapters) via the Scavio API.",
|
|
72
|
+
inputSchema: z.object({
|
|
73
|
+
video_id: z.string().describe("YouTube video id or a full watch URL.")
|
|
74
|
+
}),
|
|
75
|
+
execute: async ({ video_id }) => c.youtube.video({ video_id })
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function scavioYoutubeTranscript(config) {
|
|
79
|
+
const c = client(config);
|
|
80
|
+
return tool({
|
|
81
|
+
description: "Fetch a YouTube video's transcript or timed subtitles via the Scavio API (8 credits).",
|
|
82
|
+
inputSchema: z.object({
|
|
83
|
+
video_id: z.string().describe("YouTube video id or a full watch URL."),
|
|
84
|
+
language: z.string().optional().describe("Transcript language code (default 'en')."),
|
|
85
|
+
format: z.enum(["text", "srt"]).optional().describe("'text' for a plain transcript, 'srt' for timed subtitles.")
|
|
86
|
+
}),
|
|
87
|
+
execute: async ({ video_id, language, format }) => c.youtube.transcript({ video_id, language, format })
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function scavioYoutubeComments(config) {
|
|
91
|
+
const c = client(config);
|
|
92
|
+
const max = config?.maxResults ?? 10;
|
|
93
|
+
return tool({
|
|
94
|
+
description: "List comments on a YouTube video via the Scavio API.",
|
|
51
95
|
inputSchema: z.object({
|
|
52
|
-
|
|
96
|
+
video_id: z.string().describe("YouTube video id or a full watch URL."),
|
|
97
|
+
cursor: z.string().optional().describe("Pagination cursor.")
|
|
53
98
|
}),
|
|
54
|
-
execute: async ({
|
|
99
|
+
execute: async ({ video_id, cursor }) => trimData(
|
|
100
|
+
await c.youtube.comments({ video_id, cursor }),
|
|
101
|
+
"comments",
|
|
102
|
+
max
|
|
103
|
+
)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function scavioYoutubeChannel(config) {
|
|
107
|
+
const c = client(config);
|
|
108
|
+
return tool({
|
|
109
|
+
description: "Fetch a YouTube channel's details (subscribers, video count, views, links) via the Scavio API.",
|
|
110
|
+
inputSchema: z.object({
|
|
111
|
+
channel_id: z.string().describe("YouTube channel id, @handle, or channel URL.")
|
|
112
|
+
}),
|
|
113
|
+
execute: async ({ channel_id }) => c.youtube.channel({ channel_id })
|
|
55
114
|
});
|
|
56
115
|
}
|
|
57
116
|
function scavioRedditSearch(config) {
|
|
58
117
|
const c = client(config);
|
|
59
118
|
const max = config?.maxResults ?? 10;
|
|
60
119
|
return tool({
|
|
61
|
-
description: "Search Reddit posts
|
|
120
|
+
description: "Search Reddit posts via the Scavio API (1 credit). Returns matching posts under `data.results` with `data.next_cursor` for the next page. Results cannot be sorted or filtered by type.",
|
|
62
121
|
inputSchema: z.object({
|
|
63
122
|
query: z.string().describe("The search query."),
|
|
64
|
-
|
|
123
|
+
cursor: z.string().optional().describe("Pagination cursor (`next_cursor`) from a prior response.")
|
|
65
124
|
}),
|
|
66
|
-
execute: async ({ query,
|
|
125
|
+
execute: async ({ query, cursor }) => trimData(await c.reddit.search({ query, cursor }), "results", max)
|
|
67
126
|
});
|
|
68
127
|
}
|
|
69
128
|
function scavioAmazonSearch(config) {
|
|
70
129
|
const c = client(config);
|
|
71
130
|
const max = config?.maxResults ?? 10;
|
|
72
131
|
return tool({
|
|
73
|
-
description: "Search Amazon for products via the Scavio API.",
|
|
132
|
+
description: "Search Amazon for products via the Scavio API. Results are unsorted and cannot be filtered by category, merchant or price.",
|
|
74
133
|
inputSchema: z.object({
|
|
75
134
|
query: z.string().describe("The product search query."),
|
|
76
|
-
|
|
135
|
+
country: z.string().optional().describe(
|
|
136
|
+
"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us."
|
|
137
|
+
)
|
|
138
|
+
}),
|
|
139
|
+
execute: async ({ query, country }) => trimData(await c.amazon.search({ query, country }), "products", max)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function scavioAmazonOffers(config) {
|
|
143
|
+
const c = client(config);
|
|
144
|
+
const max = config?.maxResults ?? 10;
|
|
145
|
+
return tool({
|
|
146
|
+
description: "List every seller offer for one Amazon ASIN via the Scavio API: price, seller, condition, shipping, and which offer holds the buy box. Page 1 only.",
|
|
147
|
+
inputSchema: z.object({
|
|
148
|
+
asin: z.string().describe("Amazon Standard Identification Number (ASIN) of the product."),
|
|
149
|
+
country: z.string().optional().describe(
|
|
150
|
+
"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us."
|
|
151
|
+
)
|
|
77
152
|
}),
|
|
78
|
-
execute: async ({
|
|
153
|
+
execute: async ({ asin, country }) => trimData(await c.amazon.offers({ asin, country }), "offers", max)
|
|
79
154
|
});
|
|
80
155
|
}
|
|
81
156
|
function scavioWalmartSearch(config) {
|
|
82
157
|
const c = client(config);
|
|
83
158
|
const max = config?.maxResults ?? 10;
|
|
84
159
|
return tool({
|
|
85
|
-
description: "Search Walmart for products via the Scavio API.",
|
|
160
|
+
description: "Search Walmart for products via the Scavio API. Products come back under `data.products`.",
|
|
86
161
|
inputSchema: z.object({
|
|
87
162
|
query: z.string().describe("The product search query.")
|
|
88
163
|
}),
|
|
89
|
-
execute: async ({ query }) =>
|
|
164
|
+
execute: async ({ query }) => trimData(await c.walmart.search({ query }), "products", max)
|
|
90
165
|
});
|
|
91
166
|
}
|
|
92
167
|
function scavioTiktokSearch(config) {
|
|
93
168
|
const c = client(config);
|
|
94
169
|
const max = config?.maxResults ?? 10;
|
|
95
170
|
return tool({
|
|
96
|
-
description: "Search TikTok for videos by keyword via the Scavio API.",
|
|
171
|
+
description: "Search TikTok for videos by keyword via the Scavio API. Videos come back under `data.aweme_list`.",
|
|
97
172
|
inputSchema: z.object({
|
|
98
173
|
keyword: z.string().describe("The search keyword."),
|
|
99
|
-
sort_type: z.
|
|
100
|
-
publish_time: z.
|
|
174
|
+
sort_type: z.enum(["0", "1"]).optional().describe("Sort order: '0' relevance, '1' most likes."),
|
|
175
|
+
publish_time: z.enum(["0", "1", "7", "30", "90", "180"]).optional().describe("Publish window in days: '0' all time, '1', '7', '30', '90', '180'.")
|
|
101
176
|
}),
|
|
102
|
-
execute: async ({ keyword, sort_type, publish_time }) =>
|
|
177
|
+
execute: async ({ keyword, sort_type, publish_time }) => trimData(
|
|
103
178
|
await c.tiktok.searchVideos({
|
|
104
179
|
keyword,
|
|
105
180
|
sort_type,
|
|
106
181
|
publish_time
|
|
107
182
|
}),
|
|
183
|
+
"aweme_list",
|
|
108
184
|
max
|
|
109
185
|
)
|
|
110
186
|
});
|
|
@@ -113,25 +189,31 @@ function scavioInstagramSearch(config) {
|
|
|
113
189
|
const c = client(config);
|
|
114
190
|
const max = config?.maxResults ?? 10;
|
|
115
191
|
return tool({
|
|
116
|
-
description: "Search Instagram for users by keyword via the Scavio API.",
|
|
192
|
+
description: "Search Instagram for users by keyword via the Scavio API (10 credits). Users come back under `data.users`.",
|
|
117
193
|
inputSchema: z.object({
|
|
118
194
|
keyword: z.string().describe("The search keyword.")
|
|
119
195
|
}),
|
|
120
|
-
execute: async ({ keyword }) =>
|
|
196
|
+
execute: async ({ keyword }) => trimData(await c.instagram.searchUsers({ keyword }), "users", max)
|
|
121
197
|
});
|
|
122
198
|
}
|
|
123
199
|
function scavioTools(config) {
|
|
124
200
|
return {
|
|
125
201
|
scavio_search: scavioSearch(config),
|
|
126
202
|
scavio_youtube_search: scavioYoutubeSearch(config),
|
|
203
|
+
scavio_youtube_video: scavioYoutubeVideo(config),
|
|
204
|
+
scavio_youtube_transcript: scavioYoutubeTranscript(config),
|
|
205
|
+
scavio_youtube_comments: scavioYoutubeComments(config),
|
|
206
|
+
scavio_youtube_channel: scavioYoutubeChannel(config),
|
|
127
207
|
scavio_reddit_search: scavioRedditSearch(config),
|
|
128
208
|
scavio_amazon_search: scavioAmazonSearch(config),
|
|
209
|
+
scavio_amazon_offers: scavioAmazonOffers(config),
|
|
129
210
|
scavio_walmart_search: scavioWalmartSearch(config),
|
|
130
211
|
scavio_tiktok_search: scavioTiktokSearch(config),
|
|
131
212
|
scavio_instagram_search: scavioInstagramSearch(config)
|
|
132
213
|
};
|
|
133
214
|
}
|
|
134
215
|
export {
|
|
216
|
+
scavioAmazonOffers,
|
|
135
217
|
scavioAmazonSearch,
|
|
136
218
|
scavioInstagramSearch,
|
|
137
219
|
scavioRedditSearch,
|
|
@@ -139,6 +221,10 @@ export {
|
|
|
139
221
|
scavioTiktokSearch,
|
|
140
222
|
scavioTools,
|
|
141
223
|
scavioWalmartSearch,
|
|
142
|
-
|
|
224
|
+
scavioYoutubeChannel,
|
|
225
|
+
scavioYoutubeComments,
|
|
226
|
+
scavioYoutubeSearch,
|
|
227
|
+
scavioYoutubeTranscript,
|
|
228
|
+
scavioYoutubeVideo
|
|
143
229
|
};
|
|
144
230
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { Scavio, type ScavioConfig, type GoogleSearchOptions } from \"scavio\";\n\nexport interface ScavioToolConfig extends ScavioConfig {\n /** Max number of results to keep in `results`-style lists. Defaults to 10. */\n maxResults?: number;\n}\n\nfunction client(config?: ScavioToolConfig): Scavio {\n return new Scavio({ apiKey: config?.apiKey });\n}\n\nfunction trim(res: Record<string, unknown>, max: number): Record<string, unknown> {\n const results = res.results;\n if (Array.isArray(results) && results.length > max) {\n return { ...res, results: results.slice(0, max) };\n }\n return res;\n}\n\nfunction trimList(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const list = res[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, [key]: list.slice(0, max) };\n }\n return res;\n}\n\n/** Google web search (/api/v2/google, 1 credit). */\nexport function scavioSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search the web with Google via the Scavio API (1 credit). Returns real-time organic search results, each with a title, link, and snippet, under `organic_results`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n countryCode: z.string().optional().describe('Two-letter country code to localize results, e.g. \"us\".'),\n language: z.string().optional().describe('Two-letter UI language code, e.g. \"en\".'),\n page: z.number().int().optional().describe(\"1-based result page; page 2 starts at result 10.\"),\n device: z.enum([\"desktop\", \"mobile\"]).optional().describe(\"Device to emulate.\"),\n nfpr: z.boolean().optional().describe(\"Disable spelling auto-correction / similar-result substitution when true.\"),\n }),\n execute: async ({ query, countryCode, language, page, device, nfpr }) => {\n const params: GoogleSearchOptions = { query };\n if (countryCode) params.gl = countryCode;\n if (language) params.hl = language;\n if (page && page > 1) params.start = (page - 1) * 10;\n if (device) params.device = device;\n if (nfpr !== undefined) params.nfpr = nfpr;\n return trimList(await c.google.search(params), \"organic_results\", max);\n },\n });\n}\n\n/** YouTube video search. */\nexport function scavioYoutubeSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search YouTube for videos via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n }),\n execute: async ({ query }) => trim(await c.youtube.search({ query }), max),\n });\n}\n\n/** Reddit post/community search (costs 2 credits). */\nexport function scavioRedditSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Reddit posts and communities via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n sort: z.string().optional().describe(\"Sort order for results.\"),\n }),\n execute: async ({ query, sort }) =>\n trim(await c.reddit.search({ query, sort } as Parameters<typeof c.reddit.search>[0]), max),\n });\n}\n\n/** Amazon product search. */\nexport function scavioAmazonSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Amazon for products via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n domain: z.string().optional().describe('Amazon domain, e.g. \"amazon.com\".'),\n }),\n execute: async ({ query, domain }) => trim(await c.amazon.search({ query, domain }), max),\n });\n}\n\n/** Walmart product search. */\nexport function scavioWalmartSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Walmart for products via the Scavio API.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n }),\n execute: async ({ query }) => trim(await c.walmart.search({ query }), max),\n });\n}\n\n/** TikTok video search. */\nexport function scavioTiktokSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search TikTok for videos by keyword via the Scavio API.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n sort_type: z.string().optional().describe(\"Sort order for results.\"),\n publish_time: z.string().optional().describe(\"Filter by publish time window.\"),\n }),\n execute: async ({ keyword, sort_type, publish_time }) =>\n trim(\n await c.tiktok.searchVideos({\n keyword,\n sort_type,\n publish_time,\n } as Parameters<typeof c.tiktok.searchVideos>[0]),\n max,\n ),\n });\n}\n\n/** Instagram user search. */\nexport function scavioInstagramSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Instagram for users by keyword via the Scavio API.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n }),\n execute: async ({ keyword }) => trim(await c.instagram.searchUsers({ keyword }), max),\n });\n}\n\n/**\n * All Scavio tools as an object keyed by tool name, ready to spread into the\n * `tools` option of `generateText` / `streamText`.\n */\nexport function scavioTools(config?: ScavioToolConfig) {\n return {\n scavio_search: scavioSearch(config),\n scavio_youtube_search: scavioYoutubeSearch(config),\n scavio_reddit_search: scavioRedditSearch(config),\n scavio_amazon_search: scavioAmazonSearch(config),\n scavio_walmart_search: scavioWalmartSearch(config),\n scavio_tiktok_search: scavioTiktokSearch(config),\n scavio_instagram_search: scavioInstagramSearch(config),\n };\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,SAAS;AAClB,SAAS,cAA2D;AAOpE,SAAS,OAAO,QAAmC;AACjD,SAAO,IAAI,OAAO,EAAE,QAAQ,QAAQ,OAAO,CAAC;AAC9C;AAEA,SAAS,KAAK,KAA8B,KAAsC;AAChF,QAAM,UAAU,IAAI;AACpB,MAAI,MAAM,QAAQ,OAAO,KAAK,QAAQ,SAAS,KAAK;AAClD,WAAO,EAAE,GAAG,KAAK,SAAS,QAAQ,MAAM,GAAG,GAAG,EAAE;AAAA,EAClD;AACA,SAAO;AACT;AAEA,SAAS,SAAS,KAA8B,KAAa,KAAsC;AACjG,QAAM,OAAO,IAAI,GAAG;AACpB,MAAI,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,KAAK;AAC5C,WAAO,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,MAAM,GAAG,GAAG,EAAE;AAAA,EAC7C;AACA,SAAO;AACT;AAGO,SAAS,aAAa,QAA2B;AACtD,QAAM,IAAI,OAAO,MAAM;AACvB,QAAM,MAAM,QAAQ,cAAc;AAClC,SAAO,KAAK;AAAA,IACV,aACE;AAAA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AM,QAAQ,cAAc;AAClC,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,EAAE,OAAO;AAAA,MACpB,SAAS,EAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,MAClD,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,yBAAyB;AAAA,MACnE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,gCAAgC;AAAA,IAC/E,CAAC;AAAA,IACD,SAAS,OAAO,EAAE,SAAS,WAAW,aAAa,MACjD;AAAA,MACE,MAAM,EAAE,OAAO,aAAa;AAAA,QAC1B;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAgD;AAAA,MAChD;AAAA,IACF;AAAA,EACJ,CAAC;AACH;AAGO,SAAS,sBAAsB,QAA2B;AAC/D,QAAM,IAAI,OAAO,MAAM;AACvB,QAAM,MAAM,QAAQ,cAAc;AAClC,SAAO,KAAK;AAAA,IACV,aAAa;AAAA,IACb,aAAa,EAAE,OAAO;AAAA,MACpB,SAAS,EAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,IACpD,CAAC;AAAA,IACD,SAAS,OAAO,EAAE,QAAQ,MAAM,KAAK,MAAM,EAAE,UAAU,YAAY,EAAE,QAAQ,CAAC,GAAG,GAAG;AAAA,EACtF,CAAC;AACH;AAMO,SAAS,YAAY,QAA2B;AACrD,SAAO;AAAA,IACL,eAAe,aAAa,MAAM;AAAA,IAClC,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,yBAAyB,sBAAsB,MAAM;AAAA,EACvD;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport { Scavio, type ScavioConfig, type GoogleSearchOptions } from \"scavio\";\n\nexport interface ScavioToolConfig extends ScavioConfig {\n /**\n * Max number of items to keep in the tool's result list. Defaults to 10.\n * Trimmed inside `data` on every platform except Google, whose body is flat.\n */\n maxResults?: number;\n}\n\nfunction client(config?: ScavioToolConfig): Scavio {\n return new Scavio({ apiKey: config?.apiKey });\n}\n\n/**\n * Google is the ONLY family with a flat body: `organic_results` and friends sit\n * at the top level, next to `response_time` / `credits_used` / `credits_remaining`.\n */\nfunction trimFlat(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const list = res[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, [key]: list.slice(0, max) };\n }\n return res;\n}\n\n/**\n * Every non-Google endpoint nests its payload under `data` - the response is\n * `{ data: { products: [...] }, response_time, credits_used, credits_remaining }`.\n * Trimming the top level is therefore a silent no-op, so those tools trim\n * inside `data`.\n */\nfunction trimData(res: Record<string, unknown>, key: string, max: number): Record<string, unknown> {\n const data = res.data;\n if (!data || typeof data !== \"object\") return res;\n const list = (data as Record<string, unknown>)[key];\n if (Array.isArray(list) && list.length > max) {\n return { ...res, data: { ...(data as Record<string, unknown>), [key]: list.slice(0, max) } };\n }\n return res;\n}\n\n/** Google web search (/api/v2/google, 1 credit). */\nexport function scavioSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search the web with Google via the Scavio API (1 credit). Returns real-time organic search results, each with a title, link, and snippet, under `organic_results`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n countryCode: z.string().optional().describe('Two-letter country code to localize results, e.g. \"us\".'),\n language: z.string().optional().describe('Two-letter UI language code, e.g. \"en\".'),\n page: z.number().int().optional().describe(\"1-based result page; page 2 starts at result 10.\"),\n device: z.enum([\"desktop\", \"mobile\"]).optional().describe(\"Device to emulate.\"),\n nfpr: z.boolean().optional().describe(\"Disable spelling auto-correction / similar-result substitution when true.\"),\n }),\n execute: async ({ query, countryCode, language, page, device, nfpr }) => {\n const params: GoogleSearchOptions = { query };\n if (countryCode) params.gl = countryCode;\n if (language) params.hl = language;\n if (page && page > 1) params.start = (page - 1) * 10;\n if (device) params.device = device;\n if (nfpr !== undefined) params.nfpr = nfpr;\n return trimFlat(await c.google.search(params), \"organic_results\", max);\n },\n });\n}\n\n/** YouTube video search (2 credits). */\nexport function scavioYoutubeSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search YouTube for videos, channels, or playlists via the Scavio API (2 credits). Videos come back under `data.results`, with `data.channels` and `data.playlists` alongside.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n upload_date: z.string().optional().describe(\"Upload date filter, e.g. 'today', 'this_week', 'this_month'.\"),\n type: z.string().optional().describe(\"Result type: 'video', 'channel', 'playlist', 'movie'.\"),\n duration: z.string().optional().describe(\"Duration filter: 'short', 'medium', 'long'.\"),\n sort_by: z.string().optional().describe(\"Sort order: 'relevance', 'date', 'view_count', 'rating'.\"),\n cursor: z.string().optional().describe(\"Pagination cursor (`next_cursor`) from a prior response.\"),\n }),\n execute: async ({ query, upload_date, type, duration, sort_by, cursor }) =>\n trimData(\n await c.youtube.search({ query, upload_date, type, duration, sort_by, cursor } as Parameters<\n typeof c.youtube.search\n >[0]),\n \"results\",\n max,\n ),\n });\n}\n\n/** YouTube video details (1 credit). */\nexport function scavioYoutubeVideo(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch full details for a YouTube video (title, author, view count, description, captions, chapters) via the Scavio API.\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n }),\n execute: async ({ video_id }) => c.youtube.video({ video_id }),\n });\n}\n\n/** YouTube video transcript / subtitles (8 credits). */\nexport function scavioYoutubeTranscript(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch a YouTube video's transcript or timed subtitles via the Scavio API (8 credits).\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n language: z.string().optional().describe(\"Transcript language code (default 'en').\"),\n format: z.enum([\"text\", \"srt\"]).optional().describe(\"'text' for a plain transcript, 'srt' for timed subtitles.\"),\n }),\n execute: async ({ video_id, language, format }) =>\n c.youtube.transcript({ video_id, language, format } as Parameters<typeof c.youtube.transcript>[0]),\n });\n}\n\n/** YouTube video comments (1 credit). */\nexport function scavioYoutubeComments(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"List comments on a YouTube video via the Scavio API.\",\n inputSchema: z.object({\n video_id: z.string().describe(\"YouTube video id or a full watch URL.\"),\n cursor: z.string().optional().describe(\"Pagination cursor.\"),\n }),\n execute: async ({ video_id, cursor }) =>\n trimData(\n await c.youtube.comments({ video_id, cursor } as Parameters<typeof c.youtube.comments>[0]),\n \"comments\",\n max,\n ),\n });\n}\n\n/** YouTube channel details (1 credit). */\nexport function scavioYoutubeChannel(config?: ScavioToolConfig) {\n const c = client(config);\n return tool({\n description:\n \"Fetch a YouTube channel's details (subscribers, video count, views, links) via the Scavio API.\",\n inputSchema: z.object({\n channel_id: z.string().describe(\"YouTube channel id, @handle, or channel URL.\"),\n }),\n execute: async ({ channel_id }) => c.youtube.channel({ channel_id }),\n });\n}\n\n/**\n * Reddit post search (1 credit).\n *\n * The endpoint takes `query` and `cursor` and nothing else - it cannot sort or\n * filter by type, so no such input is offered. The API silently ignores those\n * params, which would leave a model believing it had filtered when it had not.\n */\nexport function scavioRedditSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Reddit posts via the Scavio API (1 credit). Returns matching posts under `data.results` with `data.next_cursor` for the next page. Results cannot be sorted or filtered by type.\",\n inputSchema: z.object({\n query: z.string().describe(\"The search query.\"),\n cursor: z.string().optional().describe(\"Pagination cursor (`next_cursor`) from a prior response.\"),\n }),\n execute: async ({ query, cursor }) => trimData(await c.reddit.search({ query, cursor }), \"results\", max),\n });\n}\n\n/**\n * Amazon product search.\n *\n * `domain` was dropped in favour of `country`, a two-letter marketplace code -\n * the upstream provider changed in 2026-07 and no longer takes a domain\n * suffix. It still works on the wire as a deprecated alias, but a model should\n * only ever see one spelling of a param.\n */\nexport function scavioAmazonSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Amazon for products via the Scavio API. Results are unsorted and cannot be filtered by category, merchant or price.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n country: z\n .string()\n .optional()\n .describe(\n \"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us.\"\n ),\n }),\n execute: async ({ query, country }) =>\n trimData(await c.amazon.search({ query, country }), \"products\", max),\n });\n}\n\n/** Every seller offer for one Amazon ASIN. */\nexport function scavioAmazonOffers(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"List every seller offer for one Amazon ASIN via the Scavio API: price, seller, condition, shipping, and which offer holds the buy box. Page 1 only.\",\n inputSchema: z.object({\n asin: z.string().describe(\"Amazon Standard Identification Number (ASIN) of the product.\"),\n country: z\n .string()\n .optional()\n .describe(\n \"Marketplace country code (ISO 3166-1 alpha-2), not a domain: us (default), gb (the UK is gb, not uk), de, fr, jp, ... An unknown code falls back to us.\"\n ),\n }),\n execute: async ({ asin, country }) =>\n trimData(await c.amazon.offers({ asin, country }), \"offers\", max),\n });\n}\n\n/** Walmart product search. */\nexport function scavioWalmartSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description: \"Search Walmart for products via the Scavio API. Products come back under `data.products`.\",\n inputSchema: z.object({\n query: z.string().describe(\"The product search query.\"),\n }),\n execute: async ({ query }) => trimData(await c.walmart.search({ query }), \"products\", max),\n });\n}\n\n/** TikTok video search. */\nexport function scavioTiktokSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search TikTok for videos by keyword via the Scavio API. Videos come back under `data.aweme_list`.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n sort_type: z.enum([\"0\", \"1\"]).optional().describe(\"Sort order: '0' relevance, '1' most likes.\"),\n publish_time: z\n .enum([\"0\", \"1\", \"7\", \"30\", \"90\", \"180\"])\n .optional()\n .describe(\"Publish window in days: '0' all time, '1', '7', '30', '90', '180'.\"),\n }),\n execute: async ({ keyword, sort_type, publish_time }) =>\n trimData(\n await c.tiktok.searchVideos({\n keyword,\n sort_type,\n publish_time,\n } as Parameters<typeof c.tiktok.searchVideos>[0]),\n \"aweme_list\",\n max,\n ),\n });\n}\n\n/** Instagram user search. */\nexport function scavioInstagramSearch(config?: ScavioToolConfig) {\n const c = client(config);\n const max = config?.maxResults ?? 10;\n return tool({\n description:\n \"Search Instagram for users by keyword via the Scavio API (10 credits). Users come back under `data.users`.\",\n inputSchema: z.object({\n keyword: z.string().describe(\"The search keyword.\"),\n }),\n execute: async ({ keyword }) => trimData(await c.instagram.searchUsers({ keyword }), \"users\", max),\n });\n}\n\n/**\n * All Scavio tools as an object keyed by tool name, ready to spread into the\n * `tools` option of `generateText` / `streamText`.\n */\nexport function scavioTools(config?: ScavioToolConfig) {\n return {\n scavio_search: scavioSearch(config),\n scavio_youtube_search: scavioYoutubeSearch(config),\n scavio_youtube_video: scavioYoutubeVideo(config),\n scavio_youtube_transcript: scavioYoutubeTranscript(config),\n scavio_youtube_comments: scavioYoutubeComments(config),\n scavio_youtube_channel: scavioYoutubeChannel(config),\n scavio_reddit_search: scavioRedditSearch(config),\n scavio_amazon_search: scavioAmazonSearch(config),\n scavio_amazon_offers: scavioAmazonOffers(config),\n scavio_walmart_search: scavioWalmartSearch(config),\n scavio_tiktok_search: scavioTiktokSearch(config),\n scavio_instagram_search: scavioInstagramSearch(config),\n };\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,S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J,CAAC;AACH;AAGO,SAAS,sBAAsB,QAA2B;AAC/D,QAAM,IAAI,OAAO,MAAM;AACvB,QAAM,MAAM,QAAQ,cAAc;AAClC,SAAO,KAAK;AAAA,IACV,aACE;AAAA,IACF,aAAa,EAAE,OAAO;AAAA,MACpB,SAAS,EAAE,OAAO,EAAE,SAAS,qBAAqB;AAAA,IACpD,CAAC;AAAA,IACD,SAAS,OAAO,EAAE,QAAQ,MAAM,SAAS,MAAM,EAAE,UAAU,YAAY,EAAE,QAAQ,CAAC,GAAG,SAAS,GAAG;AAAA,EACnG,CAAC;AACH;AAMO,SAAS,YAAY,QAA2B;AACrD,SAAO;AAAA,IACL,eAAe,aAAa,MAAM;AAAA,IAClC,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,2BAA2B,wBAAwB,MAAM;AAAA,IACzD,yBAAyB,sBAAsB,MAAM;AAAA,IACrD,wBAAwB,qBAAqB,MAAM;AAAA,IACnD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,uBAAuB,oBAAoB,MAAM;AAAA,IACjD,sBAAsB,mBAAmB,MAAM;AAAA,IAC/C,yBAAyB,sBAAsB,MAAM;AAAA,EACvD;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scavio/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Scavio search tools for the Vercel AI SDK (Google, YouTube, Reddit, Amazon, Walmart, TikTok, Instagram).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"zod": ">=3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"scavio": "^0.
|
|
51
|
+
"scavio": "^0.13.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@ai-sdk/openai": "^3.0.74",
|
|
55
55
|
"ai": "^6.0.208",
|
|
56
|
-
"scavio": "^0.
|
|
56
|
+
"scavio": "^0.13.0",
|
|
57
57
|
"tsup": "^8.0.0",
|
|
58
58
|
"typescript": "^5.4.0",
|
|
59
59
|
"vitest": "^2.0.0",
|