parallel-web 0.1.1 → 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.
@@ -30,20 +30,128 @@ import {
30
30
  Webhook,
31
31
  } from './task-run';
32
32
  import { APIPromise } from '../../core/api-promise';
33
+ import { buildHeaders } from '../../internal/headers';
33
34
  import { RequestOptions } from '../../internal/request-options';
34
35
 
35
36
  export class Beta extends APIResource {
36
37
  taskRun: TaskRunAPI.TaskRun = new TaskRunAPI.TaskRun(this._client);
37
38
  taskGroup: TaskGroupAPI.TaskGroup = new TaskGroupAPI.TaskGroup(this._client);
38
39
 
40
+ /**
41
+ * Extracts relevant content from specific web URLs.
42
+ *
43
+ * To access this endpoint, pass the `parallel-beta` header with the value
44
+ * `search-extract-2025-10-10`.
45
+ */
46
+ extract(params: BetaExtractParams, options?: RequestOptions): APIPromise<ExtractResponse> {
47
+ const { betas, ...body } = params;
48
+ return this._client.post('/v1beta/extract', {
49
+ body,
50
+ ...options,
51
+ headers: buildHeaders([
52
+ { ...(betas?.toString() != null ? { 'parallel-beta': betas?.toString() } : undefined) },
53
+ options?.headers,
54
+ ]),
55
+ });
56
+ }
57
+
39
58
  /**
40
59
  * Searches the web.
41
60
  */
42
- search(body: BetaSearchParams, options?: RequestOptions): APIPromise<SearchResult> {
43
- return this._client.post('/v1beta/search', { body, ...options });
61
+ search(params: BetaSearchParams, options?: RequestOptions): APIPromise<SearchResult> {
62
+ const { betas, ...body } = params;
63
+ return this._client.post('/v1beta/search', {
64
+ body,
65
+ ...options,
66
+ headers: buildHeaders([
67
+ { ...(betas?.toString() != null ? { 'parallel-beta': betas?.toString() } : undefined) },
68
+ options?.headers,
69
+ ]),
70
+ });
44
71
  }
45
72
  }
46
73
 
74
+ /**
75
+ * Optional settings for returning relevant excerpts.
76
+ */
77
+ export interface ExcerptSettings {
78
+ /**
79
+ * Optional upper bound on the total number of characters to include across all
80
+ * excerpts for each url. Excerpts may contain fewer characters than this limit to
81
+ * maximize relevance and token efficiency.
82
+ */
83
+ max_chars_per_result?: number | null;
84
+ }
85
+
86
+ /**
87
+ * Extract error details.
88
+ */
89
+ export interface ExtractError {
90
+ /**
91
+ * Content returned for http client or server errors, if any.
92
+ */
93
+ content: string | null;
94
+
95
+ /**
96
+ * Error type.
97
+ */
98
+ error_type: string;
99
+
100
+ /**
101
+ * HTTP status code, if available.
102
+ */
103
+ http_status_code: number | null;
104
+
105
+ url: string;
106
+ }
107
+
108
+ /**
109
+ * Fetch result.
110
+ */
111
+ export interface ExtractResponse {
112
+ /**
113
+ * Extract errors: requested URLs not in the results.
114
+ */
115
+ errors: Array<ExtractError>;
116
+
117
+ /**
118
+ * Extract request ID, e.g. `extract_cad0a6d2dec046bd95ae900527d880e7`
119
+ */
120
+ extract_id: string;
121
+
122
+ /**
123
+ * Successful extract results.
124
+ */
125
+ results: Array<ExtractResult>;
126
+ }
127
+
128
+ /**
129
+ * Extract result for a single URL.
130
+ */
131
+ export interface ExtractResult {
132
+ /**
133
+ * Relevant excerpted content from the URL, formatted as markdown.
134
+ */
135
+ excerpts: Array<string> | null;
136
+
137
+ /**
138
+ * Full content from the URL formatted as markdown, if requested.
139
+ */
140
+ full_content: string | null;
141
+
142
+ /**
143
+ * Publish date of the webpage, if available.
144
+ */
145
+ publish_date: string | null;
146
+
147
+ /**
148
+ * Title of the webpage, if available.
149
+ */
150
+ title: string | null;
151
+
152
+ url: string;
153
+ }
154
+
47
155
  /**
48
156
  * Output for the Search API.
49
157
  */
@@ -54,7 +162,7 @@ export interface SearchResult {
54
162
  results: Array<WebSearchResult>;
55
163
 
56
164
  /**
57
- * Search ID. Example: `search_cad0a6d2-dec0-46bd-95ae-900527d880e7`
165
+ * Search ID. Example: `search_cad0a6d2dec046bd95ae900527d880e7`
58
166
  */
59
167
  search_id: string;
60
168
  }
@@ -79,52 +187,150 @@ export interface WebSearchResult {
79
187
  url: string;
80
188
  }
81
189
 
190
+ export interface BetaExtractParams {
191
+ /**
192
+ * Body param:
193
+ */
194
+ urls: Array<string>;
195
+
196
+ /**
197
+ * Body param: Include excerpts from each URL relevant to the search objective and
198
+ * queries. Note that if neither objective nor search_queries is provided, excerpts
199
+ * are redundant with full content.
200
+ */
201
+ excerpts?: boolean | ExcerptSettings;
202
+
203
+ /**
204
+ * Body param: Fetch policy.
205
+ *
206
+ * Determines when to return content from the cache (faster) vs fetching live
207
+ * content (fresher).
208
+ */
209
+ fetch_policy?: BetaExtractParams.FetchPolicy | null;
210
+
211
+ /**
212
+ * Body param: Include full content from each URL. Note that if neither objective
213
+ * nor search_queries is provided, excerpts are redundant with full content.
214
+ */
215
+ full_content?: boolean | BetaExtractParams.FullContentSettings;
216
+
217
+ /**
218
+ * Body param: If provided, focuses extracted content on the specified search
219
+ * objective.
220
+ */
221
+ objective?: string | null;
222
+
223
+ /**
224
+ * Body param: If provided, focuses extracted content on the specified keyword
225
+ * search queries.
226
+ */
227
+ search_queries?: Array<string> | null;
228
+
229
+ /**
230
+ * Header param: Optional header to specify the beta version(s) to enable.
231
+ */
232
+ betas?: Array<TaskRunAPI.ParallelBeta>;
233
+ }
234
+
235
+ export namespace BetaExtractParams {
236
+ /**
237
+ * Fetch policy.
238
+ *
239
+ * Determines when to return content from the cache (faster) vs fetching live
240
+ * content (fresher).
241
+ */
242
+ export interface FetchPolicy {
243
+ /**
244
+ * If false, fallback to cached content older than max-age if live fetch fails or
245
+ * times out. If true, returns an error instead.
246
+ */
247
+ disable_cache_fallback?: boolean;
248
+
249
+ /**
250
+ * Maximum age of cached content in seconds to trigger a live fetch. Minimum value
251
+ * 600 seconds (10 minutes). If not provided, a dynamic age policy will be used
252
+ * based on the search objective and url.
253
+ */
254
+ max_age_seconds?: number | null;
255
+
256
+ /**
257
+ * Timeout in seconds for fetching live content if unavailable in cache. If
258
+ * unspecified a dynamic timeout will be used based on the url, generally 15
259
+ * seconds for simple pages and up to 60 seconds for complex pages requiring
260
+ * javascript or PDF rendering.
261
+ */
262
+ timeout_seconds?: number | null;
263
+ }
264
+
265
+ /**
266
+ * Optional settings for returning full content.
267
+ */
268
+ export interface FullContentSettings {
269
+ /**
270
+ * Optional limit on the number of characters to include in the full content for
271
+ * each url. Full content always starts at the beginning of the page and is
272
+ * truncated at the limit if necessary.
273
+ */
274
+ max_chars_per_result?: number | null;
275
+ }
276
+ }
277
+
82
278
  export interface BetaSearchParams {
83
279
  /**
84
- * Upper bound on the number of characters to include in excerpts for each search
85
- * result.
280
+ * Body param: Upper bound on the number of characters to include in excerpts for
281
+ * each search result.
86
282
  */
87
283
  max_chars_per_result?: number | null;
88
284
 
89
285
  /**
90
- * Upper bound on the number of results to return. May be limited by the processor.
91
- * Defaults to 10 if not provided.
286
+ * Body param: Upper bound on the number of results to return. May be limited by
287
+ * the processor. Defaults to 10 if not provided.
92
288
  */
93
289
  max_results?: number | null;
94
290
 
95
291
  /**
96
- * Natural-language description of what the web search is trying to find. May
97
- * include guidance about preferred sources or freshness. At least one of objective
98
- * or search_queries must be provided.
292
+ * Body param: Natural-language description of what the web search is trying to
293
+ * find. May include guidance about preferred sources or freshness. At least one of
294
+ * objective or search_queries must be provided.
99
295
  */
100
296
  objective?: string | null;
101
297
 
102
298
  /**
103
- * Search processor.
299
+ * Body param: Search processor.
104
300
  */
105
- processor?: 'base' | 'pro';
301
+ processor?: 'base' | 'pro' | null;
106
302
 
107
303
  /**
108
- * Optional list of traditional keyword search queries to guide the search. May
109
- * contain search operators. At least one of objective or search_queries must be
110
- * provided.
304
+ * Body param: Optional list of traditional keyword search queries to guide the
305
+ * search. May contain search operators. At least one of objective or
306
+ * search_queries must be provided.
111
307
  */
112
308
  search_queries?: Array<string> | null;
113
309
 
114
310
  /**
115
- * Source policy for web search results.
311
+ * Body param: Source policy for web search results.
116
312
  *
117
313
  * This policy governs which sources are allowed/disallowed in results.
118
314
  */
119
315
  source_policy?: Shared.SourcePolicy | null;
316
+
317
+ /**
318
+ * Header param: Optional header to specify the beta version(s) to enable.
319
+ */
320
+ betas?: Array<TaskRunAPI.ParallelBeta>;
120
321
  }
121
322
 
122
323
  Beta.TaskRun = TaskRun;
123
324
 
124
325
  export declare namespace Beta {
125
326
  export {
327
+ type ExcerptSettings as ExcerptSettings,
328
+ type ExtractError as ExtractError,
329
+ type ExtractResponse as ExtractResponse,
330
+ type ExtractResult as ExtractResult,
126
331
  type SearchResult as SearchResult,
127
332
  type WebSearchResult as WebSearchResult,
333
+ type BetaExtractParams as BetaExtractParams,
128
334
  type BetaSearchParams as BetaSearchParams,
129
335
  };
130
336
 
@@ -47,8 +47,8 @@ export class TaskGroup extends APIResource {
47
47
  /**
48
48
  * Streams events from a TaskGroup: status updates and run completions.
49
49
  *
50
- * The connection will remain open for up to 10 minutes as long as at least one run
51
- * in the TaskGroup is active.
50
+ * The connection will remain open for up to an hour as long as at least one run in
51
+ * the group is still active.
52
52
  */
53
53
  events(
54
54
  taskGroupID: string,
@@ -65,6 +65,15 @@ export class TaskGroup extends APIResource {
65
65
 
66
66
  /**
67
67
  * Retrieves task runs in a TaskGroup and optionally their inputs and outputs.
68
+ *
69
+ * All runs within a TaskGroup are returned as a stream. To get the inputs and/or
70
+ * outputs back in the stream, set the corresponding `include_input` and
71
+ * `include_output` parameters to `true`.
72
+ *
73
+ * The stream is resumable using the `event_id` as the cursor. To resume a stream,
74
+ * specify the `last_event_id` parameter with the `event_id` of the last event in
75
+ * the stream. The stream will resume from the next event after the
76
+ * `last_event_id`.
68
77
  */
69
78
  getRuns(
70
79
  taskGroupID: string,
@@ -87,16 +87,16 @@ export interface BetaRunInput {
87
87
  * [Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
88
88
  * false, no progress events are tracked. Note that progress tracking cannot be
89
89
  * enabled after a run has been created. The flag is set to true by default for
90
- * premium processors (pro and above). This feature is not available via the Python
91
- * SDK. To enable this feature in your API requests, specify the `parallel-beta`
92
- * header with `events-sse-2025-07-24` value.
90
+ * premium processors (pro and above). To enable this feature in your requests,
91
+ * specify `events-sse-2025-07-24` as one of the values in `parallel-beta` header
92
+ * (for API calls) or `betas` param (for the SDKs).
93
93
  */
94
94
  enable_events?: boolean | null;
95
95
 
96
96
  /**
97
- * Optional list of MCP servers to use for the run. This feature is not available
98
- * via the Python SDK. To enable this feature in your API requests, specify the
99
- * `parallel-beta` header with `mcp-server-2025-07-17` value.
97
+ * Optional list of MCP servers to use for the run. To enable this feature in your
98
+ * requests, specify `mcp-server-2025-07-17` as one of the values in
99
+ * `parallel-beta` header (for API calls) or `betas` param (for the SDKs).
100
100
  */
101
101
  mcp_servers?: Array<McpServer> | null;
102
102
 
@@ -365,6 +365,12 @@ export namespace TaskRunEventsResponse {
365
365
  * A progress update for a task run.
366
366
  */
367
367
  export interface TaskRunProgressStatsEvent {
368
+ /**
369
+ * Completion percentage of the task run. Ranges from 0 to 100 where 0 indicates no
370
+ * progress and 100 indicates completion.
371
+ */
372
+ progress_meter: number;
373
+
368
374
  /**
369
375
  * Source stats for a task run.
370
376
  */
@@ -441,16 +447,16 @@ export interface TaskRunCreateParams {
441
447
  * [Task Run events](https://platform.parallel.ai/api-reference) endpoint. When
442
448
  * false, no progress events are tracked. Note that progress tracking cannot be
443
449
  * enabled after a run has been created. The flag is set to true by default for
444
- * premium processors (pro and above). This feature is not available via the Python
445
- * SDK. To enable this feature in your API requests, specify the `parallel-beta`
446
- * header with `events-sse-2025-07-24` value.
450
+ * premium processors (pro and above). To enable this feature in your requests,
451
+ * specify `events-sse-2025-07-24` as one of the values in `parallel-beta` header
452
+ * (for API calls) or `betas` param (for the SDKs).
447
453
  */
448
454
  enable_events?: boolean | null;
449
455
 
450
456
  /**
451
- * Body param: Optional list of MCP servers to use for the run. This feature is not
452
- * available via the Python SDK. To enable this feature in your API requests,
453
- * specify the `parallel-beta` header with `mcp-server-2025-07-17` value.
457
+ * Body param: Optional list of MCP servers to use for the run. To enable this
458
+ * feature in your requests, specify `mcp-server-2025-07-17` as one of the values
459
+ * in `parallel-beta` header (for API calls) or `betas` param (for the SDKs).
454
460
  */
455
461
  mcp_servers?: Array<McpServer> | null;
456
462
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.1.1'; // x-release-please-version
1
+ export const VERSION = '0.2.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.1";
1
+ export declare const VERSION = "0.2.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.1";
1
+ export declare const VERSION = "0.2.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.1.1'; // x-release-please-version
4
+ exports.VERSION = '0.2.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.1.1'; // x-release-please-version
1
+ export const VERSION = '0.2.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map