parallel-web 0.3.1 → 0.3.2
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/CHANGELOG.md +32 -0
- package/README.md +2 -2
- package/client.d.mts +6 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -1
- package/client.d.ts.map +1 -1
- package/client.js +27 -19
- package/client.js.map +1 -1
- package/client.mjs +27 -19
- package/client.mjs.map +1 -1
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/utils/query.d.mts +5 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +5 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +23 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +20 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +1 -1
- package/resources/beta/beta.d.mts +14 -13
- package/resources/beta/beta.d.mts.map +1 -1
- package/resources/beta/beta.d.ts +14 -13
- package/resources/beta/beta.d.ts.map +1 -1
- package/resources/beta/beta.js +0 -3
- package/resources/beta/beta.js.map +1 -1
- package/resources/beta/beta.mjs +0 -3
- package/resources/beta/beta.mjs.map +1 -1
- package/resources/beta/findall.d.mts +4 -1
- package/resources/beta/findall.d.mts.map +1 -1
- package/resources/beta/findall.d.ts +4 -1
- package/resources/beta/findall.d.ts.map +1 -1
- package/resources/beta/findall.js +3 -0
- package/resources/beta/findall.js.map +1 -1
- package/resources/beta/findall.mjs +3 -0
- package/resources/beta/findall.mjs.map +1 -1
- package/resources/beta/task-group.d.mts +12 -1
- package/resources/beta/task-group.d.mts.map +1 -1
- package/resources/beta/task-group.d.ts +12 -1
- package/resources/beta/task-group.d.ts.map +1 -1
- package/resources/beta/task-group.js +9 -0
- package/resources/beta/task-group.js.map +1 -1
- package/resources/beta/task-group.mjs +9 -0
- package/resources/beta/task-group.mjs.map +1 -1
- package/resources/beta/task-run.d.mts +12 -0
- package/resources/beta/task-run.d.mts.map +1 -1
- package/resources/beta/task-run.d.ts +12 -0
- package/resources/beta/task-run.d.ts.map +1 -1
- package/resources/beta/task-run.js +4 -0
- package/resources/beta/task-run.js.map +1 -1
- package/resources/beta/task-run.mjs +4 -0
- package/resources/beta/task-run.mjs.map +1 -1
- package/resources/task-run.d.mts +17 -0
- package/resources/task-run.d.mts.map +1 -1
- package/resources/task-run.d.ts +17 -0
- package/resources/task-run.d.ts.map +1 -1
- package/resources/task-run.js +4 -0
- package/resources/task-run.js.map +1 -1
- package/resources/task-run.mjs +4 -0
- package/resources/task-run.mjs.map +1 -1
- package/src/client.ts +32 -24
- package/src/core/streaming.ts +2 -2
- package/src/internal/parse.ts +6 -0
- package/src/internal/utils/query.ts +23 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/beta/api.md +84 -0
- package/src/resources/beta/beta.ts +14 -13
- package/src/resources/beta/findall.ts +4 -0
- package/src/resources/beta/task-group.ts +12 -1
- package/src/resources/beta/task-run.ts +14 -0
- package/src/resources/task-run.ts +20 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
14
15
|
import { VERSION } from './version';
|
|
15
16
|
import * as Errors from './core/error';
|
|
16
17
|
import * as Uploads from './core/uploads';
|
|
@@ -228,21 +229,8 @@ export class Parallel {
|
|
|
228
229
|
/**
|
|
229
230
|
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
230
231
|
*/
|
|
231
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
232
|
-
return
|
|
233
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
234
|
-
.map(([key, value]) => {
|
|
235
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
236
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
237
|
-
}
|
|
238
|
-
if (value === null) {
|
|
239
|
-
return `${encodeURIComponent(key)}=`;
|
|
240
|
-
}
|
|
241
|
-
throw new Errors.ParallelError(
|
|
242
|
-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
243
|
-
);
|
|
244
|
-
})
|
|
245
|
-
.join('&');
|
|
232
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
233
|
+
return stringifyQuery(query);
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
private getUserAgent(): string {
|
|
@@ -274,12 +262,13 @@ export class Parallel {
|
|
|
274
262
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
275
263
|
|
|
276
264
|
const defaultQuery = this.defaultQuery();
|
|
277
|
-
|
|
278
|
-
|
|
265
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
266
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
267
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
279
268
|
}
|
|
280
269
|
|
|
281
270
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
282
|
-
url.search = this.stringifyQuery(query
|
|
271
|
+
url.search = this.stringifyQuery(query);
|
|
283
272
|
}
|
|
284
273
|
|
|
285
274
|
return url.toString();
|
|
@@ -463,7 +452,7 @@ export class Parallel {
|
|
|
463
452
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
464
453
|
|
|
465
454
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
466
|
-
const errJSON = safeJSON(errText);
|
|
455
|
+
const errJSON = safeJSON(errText) as any;
|
|
467
456
|
const errMessage = errJSON ? undefined : errText;
|
|
468
457
|
|
|
469
458
|
loggerFor(this).debug(
|
|
@@ -504,9 +493,10 @@ export class Parallel {
|
|
|
504
493
|
controller: AbortController,
|
|
505
494
|
): Promise<Response> {
|
|
506
495
|
const { signal, method, ...options } = init || {};
|
|
507
|
-
|
|
496
|
+
const abort = this._makeAbort(controller);
|
|
497
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
508
498
|
|
|
509
|
-
const timeout = setTimeout(
|
|
499
|
+
const timeout = setTimeout(abort, ms);
|
|
510
500
|
|
|
511
501
|
const isReadableBody =
|
|
512
502
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -583,9 +573,9 @@ export class Parallel {
|
|
|
583
573
|
}
|
|
584
574
|
}
|
|
585
575
|
|
|
586
|
-
// If the API asks us to wait a certain amount of time
|
|
587
|
-
//
|
|
588
|
-
if (
|
|
576
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
577
|
+
// says, but otherwise calculate a default
|
|
578
|
+
if (timeoutMillis === undefined) {
|
|
589
579
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
590
580
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
591
581
|
}
|
|
@@ -673,6 +663,12 @@ export class Parallel {
|
|
|
673
663
|
return headers.values;
|
|
674
664
|
}
|
|
675
665
|
|
|
666
|
+
private _makeAbort(controller: AbortController) {
|
|
667
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
668
|
+
// would capture all request options, and cause a memory leak.
|
|
669
|
+
return () => controller.abort();
|
|
670
|
+
}
|
|
671
|
+
|
|
676
672
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
677
673
|
bodyHeaders: HeadersLike;
|
|
678
674
|
body: BodyInit | undefined;
|
|
@@ -705,6 +701,14 @@ export class Parallel {
|
|
|
705
701
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
706
702
|
) {
|
|
707
703
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
704
|
+
} else if (
|
|
705
|
+
typeof body === 'object' &&
|
|
706
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
707
|
+
) {
|
|
708
|
+
return {
|
|
709
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
710
|
+
body: this.stringifyQuery(body),
|
|
711
|
+
};
|
|
708
712
|
} else {
|
|
709
713
|
return this.#encoder({ body, headers });
|
|
710
714
|
}
|
|
@@ -729,6 +733,10 @@ export class Parallel {
|
|
|
729
733
|
|
|
730
734
|
static toFile = Uploads.toFile;
|
|
731
735
|
|
|
736
|
+
/**
|
|
737
|
+
* The Task API executes web research and extraction tasks. Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
|
|
738
|
+
* - Output metadata: citations, excerpts, reasoning, and confidence per field
|
|
739
|
+
*/
|
|
732
740
|
taskRun: API.TaskRun = new API.TaskRun(this);
|
|
733
741
|
beta: API.Beta = new API.Beta(this);
|
|
734
742
|
}
|
package/src/core/streaming.ts
CHANGED
|
@@ -46,7 +46,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
46
46
|
try {
|
|
47
47
|
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
48
48
|
try {
|
|
49
|
-
yield JSON.parse(sse.data);
|
|
49
|
+
yield JSON.parse(sse.data) as Item;
|
|
50
50
|
} catch (e) {
|
|
51
51
|
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
52
52
|
logger.error(`From chunk:`, sse.raw);
|
|
@@ -102,7 +102,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
|
|
|
102
102
|
try {
|
|
103
103
|
for await (const line of iterLines()) {
|
|
104
104
|
if (done) continue;
|
|
105
|
-
if (line) yield JSON.parse(line);
|
|
105
|
+
if (line) yield JSON.parse(line) as Item;
|
|
106
106
|
}
|
|
107
107
|
done = true;
|
|
108
108
|
} catch (e) {
|
package/src/internal/parse.ts
CHANGED
|
@@ -43,6 +43,12 @@ export async function defaultParseResponse<T>(client: Parallel, props: APIRespon
|
|
|
43
43
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
44
44
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
45
45
|
if (isJSON) {
|
|
46
|
+
const contentLength = response.headers.get('content-length');
|
|
47
|
+
if (contentLength === '0') {
|
|
48
|
+
// if there is no content we can't do anything
|
|
49
|
+
return undefined as T;
|
|
50
|
+
}
|
|
51
|
+
|
|
46
52
|
const json = await response.json();
|
|
47
53
|
return json as T;
|
|
48
54
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { ParallelError } from '../../core/error';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
7
|
+
*/
|
|
8
|
+
export function stringifyQuery(query: object | Record<string, unknown>) {
|
|
9
|
+
return Object.entries(query)
|
|
10
|
+
.filter(([_, value]) => typeof value !== 'undefined')
|
|
11
|
+
.map(([key, value]) => {
|
|
12
|
+
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
13
|
+
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
14
|
+
}
|
|
15
|
+
if (value === null) {
|
|
16
|
+
return `${encodeURIComponent(key)}=`;
|
|
17
|
+
}
|
|
18
|
+
throw new ParallelError(
|
|
19
|
+
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
20
|
+
);
|
|
21
|
+
})
|
|
22
|
+
.join('&');
|
|
23
|
+
}
|
package/src/internal/utils.ts
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Beta
|
|
2
|
+
|
|
3
|
+
Types:
|
|
4
|
+
|
|
5
|
+
- <code><a href="./src/resources/beta/beta.ts">ExcerptSettings</a></code>
|
|
6
|
+
- <code><a href="./src/resources/beta/beta.ts">ExtractError</a></code>
|
|
7
|
+
- <code><a href="./src/resources/beta/beta.ts">ExtractResponse</a></code>
|
|
8
|
+
- <code><a href="./src/resources/beta/beta.ts">ExtractResult</a></code>
|
|
9
|
+
- <code><a href="./src/resources/beta/beta.ts">FetchPolicy</a></code>
|
|
10
|
+
- <code><a href="./src/resources/beta/beta.ts">SearchResult</a></code>
|
|
11
|
+
- <code><a href="./src/resources/beta/beta.ts">UsageItem</a></code>
|
|
12
|
+
- <code><a href="./src/resources/beta/beta.ts">WebSearchResult</a></code>
|
|
13
|
+
|
|
14
|
+
Methods:
|
|
15
|
+
|
|
16
|
+
- <code title="post /v1beta/extract">client.beta.<a href="./src/resources/beta/beta.ts">extract</a>({ ...params }) -> ExtractResponse</code>
|
|
17
|
+
- <code title="post /v1beta/search">client.beta.<a href="./src/resources/beta/beta.ts">search</a>({ ...params }) -> SearchResult</code>
|
|
18
|
+
|
|
19
|
+
## TaskRun
|
|
20
|
+
|
|
21
|
+
Types:
|
|
22
|
+
|
|
23
|
+
- <code><a href="./src/resources/beta/task-run.ts">BetaRunInput</a></code>
|
|
24
|
+
- <code><a href="./src/resources/beta/task-run.ts">BetaTaskRunResult</a></code>
|
|
25
|
+
- <code><a href="./src/resources/beta/task-run.ts">ErrorEvent</a></code>
|
|
26
|
+
- <code><a href="./src/resources/beta/task-run.ts">McpServer</a></code>
|
|
27
|
+
- <code><a href="./src/resources/beta/task-run.ts">McpToolCall</a></code>
|
|
28
|
+
- <code><a href="./src/resources/beta/task-run.ts">ParallelBeta</a></code>
|
|
29
|
+
- <code><a href="./src/resources/beta/task-run.ts">TaskRunEvent</a></code>
|
|
30
|
+
- <code><a href="./src/resources/beta/task-run.ts">Webhook</a></code>
|
|
31
|
+
- <code><a href="./src/resources/beta/task-run.ts">TaskRunEventsResponse</a></code>
|
|
32
|
+
|
|
33
|
+
Methods:
|
|
34
|
+
|
|
35
|
+
- <code title="post /v1/tasks/runs?beta=true">client.beta.taskRun.<a href="./src/resources/beta/task-run.ts">create</a>({ ...params }) -> TaskRun</code>
|
|
36
|
+
- <code title="get /v1beta/tasks/runs/{run_id}/events">client.beta.taskRun.<a href="./src/resources/beta/task-run.ts">events</a>(runID) -> TaskRunEventsResponse</code>
|
|
37
|
+
- <code title="get /v1/tasks/runs/{run_id}/result?beta=true">client.beta.taskRun.<a href="./src/resources/beta/task-run.ts">result</a>(runID, { ...params }) -> BetaTaskRunResult</code>
|
|
38
|
+
|
|
39
|
+
## TaskGroup
|
|
40
|
+
|
|
41
|
+
Types:
|
|
42
|
+
|
|
43
|
+
- <code><a href="./src/resources/beta/task-group.ts">TaskGroup</a></code>
|
|
44
|
+
- <code><a href="./src/resources/beta/task-group.ts">TaskGroupRunResponse</a></code>
|
|
45
|
+
- <code><a href="./src/resources/beta/task-group.ts">TaskGroupStatus</a></code>
|
|
46
|
+
- <code><a href="./src/resources/beta/task-group.ts">TaskGroupEventsResponse</a></code>
|
|
47
|
+
- <code><a href="./src/resources/beta/task-group.ts">TaskGroupGetRunsResponse</a></code>
|
|
48
|
+
|
|
49
|
+
Methods:
|
|
50
|
+
|
|
51
|
+
- <code title="post /v1beta/tasks/groups">client.beta.taskGroup.<a href="./src/resources/beta/task-group.ts">create</a>({ ...params }) -> TaskGroup</code>
|
|
52
|
+
- <code title="get /v1beta/tasks/groups/{taskgroup_id}">client.beta.taskGroup.<a href="./src/resources/beta/task-group.ts">retrieve</a>(taskGroupID) -> TaskGroup</code>
|
|
53
|
+
- <code title="post /v1beta/tasks/groups/{taskgroup_id}/runs">client.beta.taskGroup.<a href="./src/resources/beta/task-group.ts">addRuns</a>(taskGroupID, { ...params }) -> TaskGroupRunResponse</code>
|
|
54
|
+
- <code title="get /v1beta/tasks/groups/{taskgroup_id}/events">client.beta.taskGroup.<a href="./src/resources/beta/task-group.ts">events</a>(taskGroupID, { ...params }) -> TaskGroupEventsResponse</code>
|
|
55
|
+
- <code title="get /v1beta/tasks/groups/{taskgroup_id}/runs">client.beta.taskGroup.<a href="./src/resources/beta/task-group.ts">getRuns</a>(taskGroupID, { ...params }) -> TaskGroupGetRunsResponse</code>
|
|
56
|
+
|
|
57
|
+
## FindAll
|
|
58
|
+
|
|
59
|
+
Types:
|
|
60
|
+
|
|
61
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllCandidateMatchStatusEvent</a></code>
|
|
62
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllEnrichInput</a></code>
|
|
63
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllExtendInput</a></code>
|
|
64
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllRun</a></code>
|
|
65
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllRunInput</a></code>
|
|
66
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllRunResult</a></code>
|
|
67
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllRunStatusEvent</a></code>
|
|
68
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllSchema</a></code>
|
|
69
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllSchemaUpdatedEvent</a></code>
|
|
70
|
+
- <code><a href="./src/resources/beta/findall.ts">IngestInput</a></code>
|
|
71
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllCancelResponse</a></code>
|
|
72
|
+
- <code><a href="./src/resources/beta/findall.ts">FindAllEventsResponse</a></code>
|
|
73
|
+
|
|
74
|
+
Methods:
|
|
75
|
+
|
|
76
|
+
- <code title="post /v1beta/findall/runs">client.beta.findall.<a href="./src/resources/beta/findall.ts">create</a>({ ...params }) -> FindAllRun</code>
|
|
77
|
+
- <code title="get /v1beta/findall/runs/{findall_id}">client.beta.findall.<a href="./src/resources/beta/findall.ts">retrieve</a>(findallID, { ...params }) -> FindAllRun</code>
|
|
78
|
+
- <code title="post /v1beta/findall/runs/{findall_id}/cancel">client.beta.findall.<a href="./src/resources/beta/findall.ts">cancel</a>(findallID, { ...params }) -> unknown</code>
|
|
79
|
+
- <code title="post /v1beta/findall/runs/{findall_id}/enrich">client.beta.findall.<a href="./src/resources/beta/findall.ts">enrich</a>(findallID, { ...params }) -> FindAllSchema</code>
|
|
80
|
+
- <code title="get /v1beta/findall/runs/{findall_id}/events">client.beta.findall.<a href="./src/resources/beta/findall.ts">events</a>(findallID, { ...params }) -> FindAllEventsResponse</code>
|
|
81
|
+
- <code title="post /v1beta/findall/runs/{findall_id}/extend">client.beta.findall.<a href="./src/resources/beta/findall.ts">extend</a>(findallID, { ...params }) -> FindAllSchema</code>
|
|
82
|
+
- <code title="post /v1beta/findall/ingest">client.beta.findall.<a href="./src/resources/beta/findall.ts">ingest</a>({ ...params }) -> FindAllSchema</code>
|
|
83
|
+
- <code title="get /v1beta/findall/runs/{findall_id}/result">client.beta.findall.<a href="./src/resources/beta/findall.ts">result</a>(findallID, { ...params }) -> FindAllRunResult</code>
|
|
84
|
+
- <code title="get /v1beta/findall/runs/{findall_id}/schema">client.beta.findall.<a href="./src/resources/beta/findall.ts">schema</a>(findallID, { ...params }) -> FindAllSchema</code>
|
|
@@ -83,9 +83,6 @@ export class Beta extends APIResource {
|
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Searches the web.
|
|
86
|
-
*
|
|
87
|
-
* To access this endpoint, pass the `parallel-beta` header with the value
|
|
88
|
-
* `search-extract-2025-10-10`.
|
|
89
86
|
*/
|
|
90
87
|
search(params: BetaSearchParams, options?: RequestOptions): APIPromise<SearchResult> {
|
|
91
88
|
const { betas, ...body } = params;
|
|
@@ -107,15 +104,15 @@ export interface ExcerptSettings {
|
|
|
107
104
|
/**
|
|
108
105
|
* Optional upper bound on the total number of characters to include per url.
|
|
109
106
|
* Excerpts may contain fewer characters than this limit to maximize relevance and
|
|
110
|
-
* token efficiency
|
|
107
|
+
* token efficiency. Values below 1000 will be automatically set to 1000.
|
|
111
108
|
*/
|
|
112
109
|
max_chars_per_result?: number | null;
|
|
113
110
|
|
|
114
111
|
/**
|
|
115
112
|
* Optional upper bound on the total number of characters to include across all
|
|
116
113
|
* urls. Results may contain fewer characters than this limit to maximize relevance
|
|
117
|
-
* and token efficiency
|
|
118
|
-
*
|
|
114
|
+
* and token efficiency. Values below 1000 will be automatically set to 1000. This
|
|
115
|
+
* overall limit applies in addition to max_chars_per_result.
|
|
119
116
|
*/
|
|
120
117
|
max_chars_total?: number | null;
|
|
121
118
|
}
|
|
@@ -362,18 +359,22 @@ export interface BetaSearchParams {
|
|
|
362
359
|
max_chars_per_result?: number | null;
|
|
363
360
|
|
|
364
361
|
/**
|
|
365
|
-
* Body param: Upper bound on the number of results to return.
|
|
366
|
-
*
|
|
362
|
+
* Body param: Upper bound on the number of results to return. Defaults to 10 if
|
|
363
|
+
* not provided.
|
|
367
364
|
*/
|
|
368
365
|
max_results?: number | null;
|
|
369
366
|
|
|
370
367
|
/**
|
|
371
368
|
* Body param: Presets default values for parameters for different use cases.
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
*
|
|
370
|
+
* - `one-shot` returns more comprehensive results and longer excerpts to answer
|
|
371
|
+
* questions from a single response
|
|
372
|
+
* - `agentic` returns more concise, token-efficient results for use in an agentic
|
|
373
|
+
* loop
|
|
374
|
+
* - `fast` trades some quality for lower latency, with best results when used with
|
|
375
|
+
* concise and high-quality objective and keyword queries
|
|
376
|
+
*/
|
|
377
|
+
mode?: 'one-shot' | 'agentic' | 'fast' | null;
|
|
377
378
|
|
|
378
379
|
/**
|
|
379
380
|
* Body param: Natural-language description of what the web search is trying to
|
|
@@ -9,6 +9,9 @@ import { buildHeaders } from '../../internal/headers';
|
|
|
9
9
|
import { RequestOptions } from '../../internal/request-options';
|
|
10
10
|
import { path } from '../../internal/utils/path';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The FindAll API discovers and evaluates entities that match complex criteria from natural language objectives. Submit a high-level goal and the service automatically generates structured match conditions, discovers relevant candidates, and evaluates each against the criteria. Returns comprehensive results with detailed reasoning, citations, and confidence scores for each match decision. Streaming events and webhooks are supported.
|
|
14
|
+
*/
|
|
12
15
|
export class FindAll extends APIResource {
|
|
13
16
|
/**
|
|
14
17
|
* Starts a FindAll run.
|
|
@@ -367,6 +370,7 @@ export namespace FindAllRun {
|
|
|
367
370
|
| 'user_cancelled'
|
|
368
371
|
| 'error_occurred'
|
|
369
372
|
| 'timeout'
|
|
373
|
+
| 'insufficient_funds'
|
|
370
374
|
| null;
|
|
371
375
|
}
|
|
372
376
|
|
|
@@ -10,6 +10,15 @@ import { buildHeaders } from '../../internal/headers';
|
|
|
10
10
|
import { RequestOptions } from '../../internal/request-options';
|
|
11
11
|
import { path } from '../../internal/utils/path';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The Task Group API is currently in beta and enables batch execution of many independent Task runs with group-level monitoring and failure handling.
|
|
15
|
+
* - Submit hundreds or thousands of Tasks as a single group
|
|
16
|
+
* - Observe group progress and receive results as they complete
|
|
17
|
+
* - Real-time updates via Server-Sent Events (SSE)
|
|
18
|
+
* - Add tasks to an existing group while it is running
|
|
19
|
+
* - Group-level retry and error aggregation
|
|
20
|
+
* Status: beta and subject to change.
|
|
21
|
+
*/
|
|
13
22
|
export class TaskGroup extends APIResource {
|
|
14
23
|
/**
|
|
15
24
|
* Initiates a TaskGroup to group and track multiple runs.
|
|
@@ -233,7 +242,9 @@ export interface TaskGroupCreateParams {
|
|
|
233
242
|
|
|
234
243
|
export interface TaskGroupAddRunsParams {
|
|
235
244
|
/**
|
|
236
|
-
* Body param: List of task runs to execute.
|
|
245
|
+
* Body param: List of task runs to execute. Up to 1,000 runs can be specified per
|
|
246
|
+
* request. If you'd like to add more runs, split them across multiple TaskGroup
|
|
247
|
+
* POST requests.
|
|
237
248
|
*/
|
|
238
249
|
inputs: Array<BetaTaskRunAPI.BetaRunInput>;
|
|
239
250
|
|
|
@@ -10,6 +10,10 @@ import { buildHeaders } from '../../internal/headers';
|
|
|
10
10
|
import { RequestOptions } from '../../internal/request-options';
|
|
11
11
|
import { path } from '../../internal/utils/path';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The Task API executes web research and extraction tasks. Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
|
|
15
|
+
* - Output metadata: citations, excerpts, reasoning, and confidence per field
|
|
16
|
+
*/
|
|
13
17
|
export class TaskRun extends APIResource {
|
|
14
18
|
/**
|
|
15
19
|
* Initiates a task run.
|
|
@@ -109,6 +113,11 @@ export interface BetaRunInput {
|
|
|
109
113
|
*/
|
|
110
114
|
metadata?: { [key: string]: string | number | boolean } | null;
|
|
111
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Interaction ID to use as context for this request.
|
|
118
|
+
*/
|
|
119
|
+
previous_interaction_id?: string | null;
|
|
120
|
+
|
|
112
121
|
/**
|
|
113
122
|
* Source policy for web search results.
|
|
114
123
|
*
|
|
@@ -476,6 +485,11 @@ export interface TaskRunCreateParams {
|
|
|
476
485
|
*/
|
|
477
486
|
metadata?: { [key: string]: string | number | boolean } | null;
|
|
478
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Body param: Interaction ID to use as context for this request.
|
|
490
|
+
*/
|
|
491
|
+
previous_interaction_id?: string | null;
|
|
492
|
+
|
|
479
493
|
/**
|
|
480
494
|
* Body param: Source policy for web search results.
|
|
481
495
|
*
|
|
@@ -6,6 +6,10 @@ import { APIPromise } from '../core/api-promise';
|
|
|
6
6
|
import { RequestOptions } from '../internal/request-options';
|
|
7
7
|
import { path } from '../internal/utils/path';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* The Task API executes web research and extraction tasks. Clients submit a natural-language objective with an optional input schema; the service plans retrieval, fetches relevant URLs, and returns outputs that conform to a provided or inferred JSON schema. Supports deep research style queries and can return rich structured JSON outputs. Processors trade-off between cost, latency, and quality. Each processor supports calibrated confidences.
|
|
11
|
+
* - Output metadata: citations, excerpts, reasoning, and confidence per field
|
|
12
|
+
*/
|
|
9
13
|
export class TaskRun extends APIResource {
|
|
10
14
|
/**
|
|
11
15
|
* Initiates a task run.
|
|
@@ -131,6 +135,11 @@ export interface RunInput {
|
|
|
131
135
|
*/
|
|
132
136
|
metadata?: { [key: string]: string | number | boolean } | null;
|
|
133
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Interaction ID to use as context for this request.
|
|
140
|
+
*/
|
|
141
|
+
previous_interaction_id?: string | null;
|
|
142
|
+
|
|
134
143
|
/**
|
|
135
144
|
* Source policy for web search results.
|
|
136
145
|
*
|
|
@@ -158,6 +167,12 @@ export interface TaskRun {
|
|
|
158
167
|
*/
|
|
159
168
|
created_at: string | null;
|
|
160
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Identifier for this interaction. Pass this value as `previous_interaction_id` to
|
|
172
|
+
* reuse context for a future request.
|
|
173
|
+
*/
|
|
174
|
+
interaction_id: string;
|
|
175
|
+
|
|
161
176
|
/**
|
|
162
177
|
* Whether the run is currently active, i.e. status is one of {'cancelling',
|
|
163
178
|
* 'queued', 'running'}.
|
|
@@ -355,6 +370,11 @@ export interface TaskRunCreateParams {
|
|
|
355
370
|
*/
|
|
356
371
|
metadata?: { [key: string]: string | number | boolean } | null;
|
|
357
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Interaction ID to use as context for this request.
|
|
375
|
+
*/
|
|
376
|
+
previous_interaction_id?: string | null;
|
|
377
|
+
|
|
358
378
|
/**
|
|
359
379
|
* Source policy for web search results.
|
|
360
380
|
*
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.3.
|
|
1
|
+
export const VERSION = '0.3.2'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.3.
|
|
1
|
+
export declare const VERSION = "0.3.2";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.3.
|
|
1
|
+
export declare const VERSION = "0.3.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.3.
|
|
1
|
+
export const VERSION = '0.3.2'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|