@specstream/ai-sdk 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # @specstream/ai-sdk
2
2
 
3
- Search tools hand your agent pages to read. SpecStream hands it the finished list: ask in plain words – "dental clinics in Lisbon with online booking", "US startups that filed a $5M+ Form D this week" – and the agent gets back every matching row, each with the page it was read from. The price is set before anything runs, in your code, and the model can't raise it.
3
+ [SpecStream](https://specstream.ai) is the live web data engine for teams and agents. One platform to build, search, extract, enrich, map, and monitor data across the entire web. Ask for any dataset in plain words, and SpecStream builds it from the entire live web: every match found, extracted and enriched into structured records, then monitored for change. Source URL and read time on every value.
4
4
 
5
5
  ```bash
6
6
  npm install @specstream/ai-sdk ai zod
7
7
  export SPECSTREAM_API_KEY=ss_live_... # Agents & API in your SpecStream workspace
8
8
  ```
9
9
 
10
- A free account comes with $10 of work to use within 30 days and needs no card: [specstream.ai](https://specstream.ai/signup).
10
+ A free account comes with $10 of credit to use within 30 days and needs no card: [specstream.ai](https://specstream.ai/signup).
11
11
 
12
12
  ## An agent that can find lists
13
13
 
@@ -50,11 +50,13 @@ Columns follow the request. Ask for "breweries in Portland, Oregon that host eve
50
50
 
51
51
  The tool's result wraps the rows with `status`, `list_id`, `list_link`, `row_count` and `maximum_price_usd`, so the agent can cite the list and hand your user a link to it.
52
52
 
53
- ## The two tools
53
+ ## The four tools
54
54
 
55
55
  | Tool | The model gives | What happens | Cost |
56
56
  | --- | --- | --- | --- |
57
- | `specstream_find_list` | `request`, `maxResults` (1 to 1000, default 25) | Reads the request, prices it, starts it only within `maxPriceUsd`, waits up to `waitSeconds` (7 minutes by default) and returns every row | Only the rows that match |
57
+ | `specstream_web_search` | `q`, `passages` | Calls `GET /v1/web-search` and returns the answer, matching rows, ranked sources and optional page passages | $5 per 1,000 searches |
58
+ | `specstream_extract_pages` | `urls`, `format` | Calls `POST /v1/extract` and returns the clean main text, title and published date of 1 to 20 web pages, PDFs, Word or Excel files | $0.80 per 1,000 pages (empty pages free) |
59
+ | `specstream_find_list` | `request`, `maxResults` (1 to 1000, default 25) | Reads the request, prices it, starts it only within `maxPriceUsd`, waits up to `waitSeconds` (7 minutes by default) and returns every row | Only delivered rows |
58
60
  | `specstream_get_list_results` | `listId` | Every row found so far, for a list that was still running | Free |
59
61
 
60
62
  When the price is above your maximum, nothing runs: the tool returns `status: "over_maximum"` and the price, so the agent can ask for fewer rows or tell the user. When a request is too vague to price ("clinics"), it returns `status: "needs_edit"` and how SpecStream read it, so the agent can add the place or the conditions.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** The SpecStream REST calls the tools share: read a request, price it, start it within a maximum, read its rows. */
2
2
  export declare const DEFAULT_BASE_URL = "https://api.specstream.ai";
3
- export declare const USER_AGENT = "@specstream/ai-sdk/0.1.3";
3
+ export declare const USER_AGENT = "@specstream/ai-sdk/0.2.0";
4
4
  /** A list runs for up to about five minutes, so the tools wait a little longer than that by default. */
5
5
  export declare const DEFAULT_WAIT_SECONDS = 420;
6
6
  export declare const DEFAULT_POLL_INTERVAL_SECONDS = 3;
@@ -106,6 +106,16 @@ export declare class SpecStreamClient {
106
106
  constructor(options?: SpecStreamClientOptions);
107
107
  get hasKey(): boolean;
108
108
  private request;
109
+ /** Search the live web with GET /v1/web-search ($5 per 1,000 searches, no quote needed). */
110
+ webSearch(query: string, options?: {
111
+ passages?: boolean;
112
+ abortSignal?: AbortSignal;
113
+ }): Promise<Record<string, unknown>>;
114
+ /** Extract the main text of 1 to 20 URLs live with POST /v1/extract ($0.80 per 1,000 pages, empty pages free). */
115
+ extractPages(urls: string[], options?: {
116
+ format?: "markdown" | "text";
117
+ abortSignal?: AbortSignal;
118
+ }): Promise<Record<string, unknown>>;
109
119
  /** Every row found so far for a list, following the pages. Reading is free. */
110
120
  results(findId: string, abortSignal?: AbortSignal): Promise<ListResults>;
111
121
  /** Reads the request, prices it, and runs it only if the most it can cost is within `maxPriceUsd`. */
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** The SpecStream REST calls the tools share: read a request, price it, start it within a maximum, read its rows. */
2
2
  export const DEFAULT_BASE_URL = "https://api.specstream.ai";
3
- export const USER_AGENT = "@specstream/ai-sdk/0.1.3";
3
+ export const USER_AGENT = "@specstream/ai-sdk/0.2.0";
4
4
  /** A list runs for up to about five minutes, so the tools wait a little longer than that by default. */
5
5
  export const DEFAULT_WAIT_SECONDS = 420;
6
6
  export const DEFAULT_POLL_INTERVAL_SECONDS = 3;
@@ -150,6 +150,24 @@ export class SpecStreamClient {
150
150
  throw new SpecStreamError("SpecStream returned a response this package couldn't read.");
151
151
  return data;
152
152
  }
153
+ /** Search the live web with GET /v1/web-search ($5 per 1,000 searches, no quote needed). */
154
+ async webSearch(query, options = {}) {
155
+ const q = (query ?? "").trim();
156
+ if (!q || q.length > 2000)
157
+ throw new Error("q must be between 1 and 2,000 characters.");
158
+ const params = new URLSearchParams({ q });
159
+ if (options.passages)
160
+ params.set("passages", "true");
161
+ return (await this.request("GET", `/v1/web-search?${params}`, undefined, { abortSignal: options.abortSignal })) ?? {};
162
+ }
163
+ /** Extract the main text of 1 to 20 URLs live with POST /v1/extract ($0.80 per 1,000 pages, empty pages free). */
164
+ async extractPages(urls, options = {}) {
165
+ const cleaned = (Array.isArray(urls) ? urls : []).map((u) => String(u ?? "").trim()).filter(Boolean);
166
+ if (cleaned.length < 1 || cleaned.length > 20)
167
+ throw new Error("Provide 1 to 20 http or https URLs in urls.");
168
+ const format = options.format === "text" ? "text" : "markdown";
169
+ return (await this.request("POST", "/v1/extract", { urls: cleaned, format }, { abortSignal: options.abortSignal })) ?? {};
170
+ }
153
171
  /** Every row found so far for a list, following the pages. Reading is free. */
154
172
  async results(findId, abortSignal) {
155
173
  const rows = [];
package/dist/tools.d.ts CHANGED
@@ -29,6 +29,464 @@ export type SpecStreamToolsOptions = {
29
29
  * });
30
30
  */
31
31
  export declare function specstreamTools(options: SpecStreamToolsOptions): {
32
+ specstream_web_search: ({
33
+ deferLoading?: boolean;
34
+ title?: string;
35
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
36
+ metadata?: import("@ai-sdk/provider").JSONObject;
37
+ inputSchema: import("ai").FlexibleSchema<{
38
+ q: string;
39
+ passages?: boolean | undefined;
40
+ }>;
41
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
42
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
43
+ q: string;
44
+ passages?: boolean | undefined;
45
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
46
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
47
+ onInputDelta?: ((options: {
48
+ inputTextDelta: string;
49
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
50
+ onInputAvailable?: ((options: {
51
+ input: {
52
+ q: string;
53
+ passages?: boolean | undefined;
54
+ };
55
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
56
+ toModelOutput?: ((options: {
57
+ toolCallId: string;
58
+ input: {
59
+ q: string;
60
+ passages?: boolean | undefined;
61
+ };
62
+ output: NoInfer<Record<string, unknown>>;
63
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
64
+ } & {
65
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
66
+ execute: import("ai").ToolExecuteFunction<{
67
+ q: string;
68
+ passages?: boolean | undefined;
69
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
70
+ } & {
71
+ description?: string | ((options: {
72
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
73
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
74
+ }) => string) | undefined;
75
+ strict?: boolean;
76
+ inputExamples?: {
77
+ input: NoInfer<{
78
+ q: string;
79
+ passages?: boolean | undefined;
80
+ }>;
81
+ }[] | undefined;
82
+ id?: never;
83
+ isProviderExecuted?: never;
84
+ args?: never;
85
+ supportsDeferredResults?: never;
86
+ } & {
87
+ type?: undefined | "function";
88
+ } & {
89
+ execute: import("ai").ToolExecuteFunction<{
90
+ q: string;
91
+ passages?: boolean | undefined;
92
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
93
+ }) | ({
94
+ deferLoading?: boolean;
95
+ title?: string;
96
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
97
+ metadata?: import("@ai-sdk/provider").JSONObject;
98
+ inputSchema: import("ai").FlexibleSchema<{
99
+ q: string;
100
+ passages?: boolean | undefined;
101
+ }>;
102
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
103
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
104
+ q: string;
105
+ passages?: boolean | undefined;
106
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
107
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
108
+ onInputDelta?: ((options: {
109
+ inputTextDelta: string;
110
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
111
+ onInputAvailable?: ((options: {
112
+ input: {
113
+ q: string;
114
+ passages?: boolean | undefined;
115
+ };
116
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
117
+ toModelOutput?: ((options: {
118
+ toolCallId: string;
119
+ input: {
120
+ q: string;
121
+ passages?: boolean | undefined;
122
+ };
123
+ output: NoInfer<Record<string, unknown>>;
124
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
125
+ } & {
126
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
127
+ execute: import("ai").ToolExecuteFunction<{
128
+ q: string;
129
+ passages?: boolean | undefined;
130
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
131
+ } & {
132
+ description?: string | ((options: {
133
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
134
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
135
+ }) => string) | undefined;
136
+ strict?: boolean;
137
+ inputExamples?: {
138
+ input: NoInfer<{
139
+ q: string;
140
+ passages?: boolean | undefined;
141
+ }>;
142
+ }[] | undefined;
143
+ id?: never;
144
+ isProviderExecuted?: never;
145
+ args?: never;
146
+ supportsDeferredResults?: never;
147
+ } & {
148
+ type: "dynamic";
149
+ } & {
150
+ execute: import("ai").ToolExecuteFunction<{
151
+ q: string;
152
+ passages?: boolean | undefined;
153
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
154
+ }) | ({
155
+ deferLoading?: boolean;
156
+ title?: string;
157
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
158
+ metadata?: import("@ai-sdk/provider").JSONObject;
159
+ inputSchema: import("ai").FlexibleSchema<{
160
+ q: string;
161
+ passages?: boolean | undefined;
162
+ }>;
163
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
164
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
165
+ q: string;
166
+ passages?: boolean | undefined;
167
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
168
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
169
+ onInputDelta?: ((options: {
170
+ inputTextDelta: string;
171
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
172
+ onInputAvailable?: ((options: {
173
+ input: {
174
+ q: string;
175
+ passages?: boolean | undefined;
176
+ };
177
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
178
+ toModelOutput?: ((options: {
179
+ toolCallId: string;
180
+ input: {
181
+ q: string;
182
+ passages?: boolean | undefined;
183
+ };
184
+ output: NoInfer<Record<string, unknown>>;
185
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
186
+ } & {
187
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
188
+ execute: import("ai").ToolExecuteFunction<{
189
+ q: string;
190
+ passages?: boolean | undefined;
191
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
192
+ } & {
193
+ type: "provider";
194
+ id: `${string}.${string}`;
195
+ args: Record<string, unknown>;
196
+ description?: never;
197
+ strict?: never;
198
+ inputExamples?: never;
199
+ } & {
200
+ isProviderExecuted: false;
201
+ supportsDeferredResults?: never;
202
+ } & {
203
+ execute: import("ai").ToolExecuteFunction<{
204
+ q: string;
205
+ passages?: boolean | undefined;
206
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
207
+ }) | ({
208
+ deferLoading?: boolean;
209
+ title?: string;
210
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
211
+ metadata?: import("@ai-sdk/provider").JSONObject;
212
+ inputSchema: import("ai").FlexibleSchema<{
213
+ q: string;
214
+ passages?: boolean | undefined;
215
+ }>;
216
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
217
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
218
+ q: string;
219
+ passages?: boolean | undefined;
220
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
221
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
222
+ onInputDelta?: ((options: {
223
+ inputTextDelta: string;
224
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
225
+ onInputAvailable?: ((options: {
226
+ input: {
227
+ q: string;
228
+ passages?: boolean | undefined;
229
+ };
230
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
231
+ toModelOutput?: ((options: {
232
+ toolCallId: string;
233
+ input: {
234
+ q: string;
235
+ passages?: boolean | undefined;
236
+ };
237
+ output: NoInfer<Record<string, unknown>>;
238
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
239
+ } & {
240
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
241
+ execute: import("ai").ToolExecuteFunction<{
242
+ q: string;
243
+ passages?: boolean | undefined;
244
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
245
+ } & {
246
+ type: "provider";
247
+ id: `${string}.${string}`;
248
+ args: Record<string, unknown>;
249
+ description?: never;
250
+ strict?: never;
251
+ inputExamples?: never;
252
+ } & {
253
+ isProviderExecuted: true;
254
+ supportsDeferredResults?: boolean;
255
+ } & {
256
+ execute: import("ai").ToolExecuteFunction<{
257
+ q: string;
258
+ passages?: boolean | undefined;
259
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
260
+ });
261
+ specstream_extract_pages: ({
262
+ deferLoading?: boolean;
263
+ title?: string;
264
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
265
+ metadata?: import("@ai-sdk/provider").JSONObject;
266
+ inputSchema: import("ai").FlexibleSchema<{
267
+ urls: string[];
268
+ format?: "markdown" | "text" | undefined;
269
+ }>;
270
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
271
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
272
+ urls: string[];
273
+ format?: "markdown" | "text" | undefined;
274
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
275
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
276
+ onInputDelta?: ((options: {
277
+ inputTextDelta: string;
278
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
279
+ onInputAvailable?: ((options: {
280
+ input: {
281
+ urls: string[];
282
+ format?: "markdown" | "text" | undefined;
283
+ };
284
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
285
+ toModelOutput?: ((options: {
286
+ toolCallId: string;
287
+ input: {
288
+ urls: string[];
289
+ format?: "markdown" | "text" | undefined;
290
+ };
291
+ output: NoInfer<Record<string, unknown>>;
292
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
293
+ } & {
294
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
295
+ execute: import("ai").ToolExecuteFunction<{
296
+ urls: string[];
297
+ format?: "markdown" | "text" | undefined;
298
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
299
+ } & {
300
+ description?: string | ((options: {
301
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
302
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
303
+ }) => string) | undefined;
304
+ strict?: boolean;
305
+ inputExamples?: {
306
+ input: NoInfer<{
307
+ urls: string[];
308
+ format?: "markdown" | "text" | undefined;
309
+ }>;
310
+ }[] | undefined;
311
+ id?: never;
312
+ isProviderExecuted?: never;
313
+ args?: never;
314
+ supportsDeferredResults?: never;
315
+ } & {
316
+ type?: undefined | "function";
317
+ } & {
318
+ execute: import("ai").ToolExecuteFunction<{
319
+ urls: string[];
320
+ format?: "markdown" | "text" | undefined;
321
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
322
+ }) | ({
323
+ deferLoading?: boolean;
324
+ title?: string;
325
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
326
+ metadata?: import("@ai-sdk/provider").JSONObject;
327
+ inputSchema: import("ai").FlexibleSchema<{
328
+ urls: string[];
329
+ format?: "markdown" | "text" | undefined;
330
+ }>;
331
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
332
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
333
+ urls: string[];
334
+ format?: "markdown" | "text" | undefined;
335
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
336
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
337
+ onInputDelta?: ((options: {
338
+ inputTextDelta: string;
339
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
340
+ onInputAvailable?: ((options: {
341
+ input: {
342
+ urls: string[];
343
+ format?: "markdown" | "text" | undefined;
344
+ };
345
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
346
+ toModelOutput?: ((options: {
347
+ toolCallId: string;
348
+ input: {
349
+ urls: string[];
350
+ format?: "markdown" | "text" | undefined;
351
+ };
352
+ output: NoInfer<Record<string, unknown>>;
353
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
354
+ } & {
355
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
356
+ execute: import("ai").ToolExecuteFunction<{
357
+ urls: string[];
358
+ format?: "markdown" | "text" | undefined;
359
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
360
+ } & {
361
+ description?: string | ((options: {
362
+ context: NoInfer<import("@ai-sdk/provider-utils").Context>;
363
+ experimental_sandbox?: import("ai").Experimental_SandboxSession;
364
+ }) => string) | undefined;
365
+ strict?: boolean;
366
+ inputExamples?: {
367
+ input: NoInfer<{
368
+ urls: string[];
369
+ format?: "markdown" | "text" | undefined;
370
+ }>;
371
+ }[] | undefined;
372
+ id?: never;
373
+ isProviderExecuted?: never;
374
+ args?: never;
375
+ supportsDeferredResults?: never;
376
+ } & {
377
+ type: "dynamic";
378
+ } & {
379
+ execute: import("ai").ToolExecuteFunction<{
380
+ urls: string[];
381
+ format?: "markdown" | "text" | undefined;
382
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
383
+ }) | ({
384
+ deferLoading?: boolean;
385
+ title?: string;
386
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
387
+ metadata?: import("@ai-sdk/provider").JSONObject;
388
+ inputSchema: import("ai").FlexibleSchema<{
389
+ urls: string[];
390
+ format?: "markdown" | "text" | undefined;
391
+ }>;
392
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
393
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
394
+ urls: string[];
395
+ format?: "markdown" | "text" | undefined;
396
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
397
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
398
+ onInputDelta?: ((options: {
399
+ inputTextDelta: string;
400
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
401
+ onInputAvailable?: ((options: {
402
+ input: {
403
+ urls: string[];
404
+ format?: "markdown" | "text" | undefined;
405
+ };
406
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
407
+ toModelOutput?: ((options: {
408
+ toolCallId: string;
409
+ input: {
410
+ urls: string[];
411
+ format?: "markdown" | "text" | undefined;
412
+ };
413
+ output: NoInfer<Record<string, unknown>>;
414
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
415
+ } & {
416
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
417
+ execute: import("ai").ToolExecuteFunction<{
418
+ urls: string[];
419
+ format?: "markdown" | "text" | undefined;
420
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
421
+ } & {
422
+ type: "provider";
423
+ id: `${string}.${string}`;
424
+ args: Record<string, unknown>;
425
+ description?: never;
426
+ strict?: never;
427
+ inputExamples?: never;
428
+ } & {
429
+ isProviderExecuted: false;
430
+ supportsDeferredResults?: never;
431
+ } & {
432
+ execute: import("ai").ToolExecuteFunction<{
433
+ urls: string[];
434
+ format?: "markdown" | "text" | undefined;
435
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
436
+ }) | ({
437
+ deferLoading?: boolean;
438
+ title?: string;
439
+ providerOptions?: import("@ai-sdk/provider-utils").ProviderOptions;
440
+ metadata?: import("@ai-sdk/provider").JSONObject;
441
+ inputSchema: import("ai").FlexibleSchema<{
442
+ urls: string[];
443
+ format?: "markdown" | "text" | undefined;
444
+ }>;
445
+ contextSchema?: import("ai").FlexibleSchema<import("@ai-sdk/provider-utils").Context> | undefined;
446
+ needsApproval?: boolean | import("@ai-sdk/provider-utils").ToolNeedsApprovalFunction<{
447
+ urls: string[];
448
+ format?: "markdown" | "text" | undefined;
449
+ }, NoInfer<import("@ai-sdk/provider-utils").Context>> | undefined;
450
+ onInputStart?: ((options: import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
451
+ onInputDelta?: ((options: {
452
+ inputTextDelta: string;
453
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
454
+ onInputAvailable?: ((options: {
455
+ input: {
456
+ urls: string[];
457
+ format?: "markdown" | "text" | undefined;
458
+ };
459
+ } & import("ai").ToolExecutionOptions<NoInfer<import("@ai-sdk/provider-utils").Context>>) => void | PromiseLike<void>) | undefined;
460
+ toModelOutput?: ((options: {
461
+ toolCallId: string;
462
+ input: {
463
+ urls: string[];
464
+ format?: "markdown" | "text" | undefined;
465
+ };
466
+ output: NoInfer<Record<string, unknown>>;
467
+ }) => import("@ai-sdk/provider-utils").ToolResultOutput | PromiseLike<import("@ai-sdk/provider-utils").ToolResultOutput>) | undefined;
468
+ } & {
469
+ outputSchema?: import("ai").FlexibleSchema<Record<string, unknown>> | undefined;
470
+ execute: import("ai").ToolExecuteFunction<{
471
+ urls: string[];
472
+ format?: "markdown" | "text" | undefined;
473
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
474
+ } & {
475
+ type: "provider";
476
+ id: `${string}.${string}`;
477
+ args: Record<string, unknown>;
478
+ description?: never;
479
+ strict?: never;
480
+ inputExamples?: never;
481
+ } & {
482
+ isProviderExecuted: true;
483
+ supportsDeferredResults?: boolean;
484
+ } & {
485
+ execute: import("ai").ToolExecuteFunction<{
486
+ urls: string[];
487
+ format?: "markdown" | "text" | undefined;
488
+ }, Record<string, unknown>, NoInfer<import("@ai-sdk/provider-utils").Context>>;
489
+ });
32
490
  specstream_find_list: ({
33
491
  deferLoading?: boolean;
34
492
  title?: string;
package/dist/tools.js CHANGED
@@ -18,6 +18,14 @@ const findListInput = z.object({
18
18
  const getListResultsInput = z.object({
19
19
  listId: z.string().min(1).describe('The list_id that specstream_find_list returned, like "fnd_gk5y3d0r97bvyz0t08zzh75kr6".'),
20
20
  });
21
+ const webSearchInput = z.object({
22
+ q: z.string().min(1).max(2000).describe("The search question or request in everyday words (1 to 2,000 characters). Quoted phrases are searched as phrases."),
23
+ passages: z.boolean().optional().describe("Set true to include the main text passages of the top matching pages in the response."),
24
+ });
25
+ const extractPagesInput = z.object({
26
+ urls: z.array(z.string().min(1)).min(1).max(20).describe("1 to 20 http or https URLs (web pages, PDF, Word, Excel) to read live."),
27
+ format: z.enum(["markdown", "text"]).optional().describe('Output format: "markdown" (default) or "text".'),
28
+ });
21
29
  const FIND_LIST_DESCRIPTION = [
22
30
  "Find a list of real things on the live web and return every matching row, each with the page it was read from.",
23
31
  "Use it when the answer is many things that meet conditions: companies in a city, local businesses with a service, funding filings, open grants, tenders, clinical trials, repositories, people in a role.",
@@ -54,6 +62,18 @@ export function specstreamTools(options) {
54
62
  if (!client.hasKey)
55
63
  throw new Error(MISSING_KEY_MESSAGE);
56
64
  return {
65
+ specstream_web_search: tool({
66
+ description: "Search the live web in seconds with the SpecStream Search API (GET /v1/web-search, $5 per 1,000 searches, no quote needed). " +
67
+ "Returns JSON with kind ('fact' or 'list'), answer (value, page and seen_at), matching rows, ranked sources and optional passages.",
68
+ inputSchema: webSearchInput,
69
+ execute: async ({ q, passages }, { abortSignal }) => client.webSearch(q, { passages, abortSignal }),
70
+ }),
71
+ specstream_extract_pages: tool({
72
+ description: "Read the main text, title and published date of 1 to 20 web pages, PDFs, Word or Excel files live with the SpecStream Extract API " +
73
+ "(POST /v1/extract, $0.80 per 1,000 pages, empty pages free, no quote needed).",
74
+ inputSchema: extractPagesInput,
75
+ execute: async ({ urls, format }, { abortSignal }) => client.extractPages(urls, { format, abortSignal }),
76
+ }),
57
77
  specstream_find_list: tool({
58
78
  description: FIND_LIST_DESCRIPTION,
59
79
  inputSchema: findListInput,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@specstream/ai-sdk",
3
- "version": "0.1.3",
4
- "description": "Give a Vercel AI SDK agent lead lists, company lists and grants from the live web. Every row comes with its source, priced per match.",
3
+ "version": "0.2.0",
4
+ "description": "The live web data engine for the Vercel AI SDK: Search API ($5 per 1,000 searches), Extract API ($0.80 per 1,000 pages) and Deep Search.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",