@howells/fieldwork-sdk 0.12.0 → 0.13.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 +2 -1
- package/dist/{best-CO9liYDa.js → best-DiKYwLdC.js} +2 -2
- package/dist/brave.js +12 -12
- package/dist/browserbase.js +11 -11
- package/dist/{document-BSCwJgBM.js → document-x9fWsQ1W.js} +3 -3
- package/dist/exa.js +26 -23
- package/dist/firecrawl.js +42 -42
- package/dist/{http-CJcvTPnE.js → http-Bg0h3D-t.js} +44 -44
- package/dist/image.js +1 -1
- package/dist/{job-JLEpszjr.js → job-BsrOrrO1.js} +4 -4
- package/dist/kernel.js +13 -13
- package/dist/llamaparse.js +12 -12
- package/dist/parallel.d.ts +2 -2
- package/dist/parallel.js +48 -41
- package/dist/{path-DO2llIdp.js → path-tDCyAKK9.js} +1 -1
- package/dist/perplexity.js +9 -9
- package/dist/reducto.js +10 -10
- package/dist/{schema-CJXFAZ-x.js → schema-Bfd2E8u2.js} +2 -2
- package/dist/serpapi.js +11 -11
- package/dist/tavily.js +18 -18
- package/dist/tools.d.ts +37 -34
- package/dist/tools.js +156 -120
- package/dist/{util-LvME_uOj.js → util-BOqd71Om.js} +13 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -74,7 +74,8 @@ Options are typed per provider. An option means the same thing under the same na
|
|
|
74
74
|
| `match` | On `reverseImage`: `"exact"` for pages showing the same image, `"visual"` for similar ones. |
|
|
75
75
|
| `content` | On `search`: include each result's page text. |
|
|
76
76
|
| `maxTokens`, `maxTokensPerResult` | On `search`: total and per-result token caps for returned passages (Brave with `content: true`, Perplexity). |
|
|
77
|
-
| `maxCharsPerResult
|
|
77
|
+
| `maxCharsPerResult` | On `search`, `read` and `readMany`: per-result character cap for returned excerpts or highlights (Exa, Parallel). |
|
|
78
|
+
| `maxCharsTotal` | On `search`, `read` and `readMany`: total character cap across returned excerpts (Parallel). |
|
|
78
79
|
| `maxContentChars` | On `read` and `readMany`: per-page character cap for full page `markdown` (Exa, Parallel). |
|
|
79
80
|
| `continueFrom` | On `answer` and `research`: the `continuationId` of an earlier result, to ask a follow-up. |
|
|
80
81
|
| `maxBytes` | On `download`: the largest file accepted, in bytes. Defaults to, and may not exceed, the provider's ceiling. |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createDocument } from "@mixmark-io/domino";
|
|
1
2
|
import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
|
|
2
|
-
import { n as checkCallSettings } from "./util-
|
|
3
|
+
import { n as checkCallSettings } from "./util-BOqd71Om.js";
|
|
3
4
|
import { z } from "zod/mini";
|
|
4
|
-
import { createDocument } from "@mixmark-io/domino";
|
|
5
5
|
// src/image/blocked.ts
|
|
6
6
|
/**
|
|
7
7
|
* What the page is instead of the page, such as "a Cloudflare challenge", or
|
package/dist/brave.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
1
2
|
import { t as defineAdapter } from "./adapter-CBSAfErv.js";
|
|
2
3
|
import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
|
|
3
|
-
import { d as looseObject, f as nonEmptyString, h as optionalBoolean, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, w as recordOf, x as optionalString } from "./http-
|
|
4
|
-
import { a as compact, c as parseJson,
|
|
5
|
-
import * as z$1 from "zod/mini";
|
|
4
|
+
import { d as looseObject, f as nonEmptyString, h as optionalBoolean, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, w as recordOf, x as optionalString } from "./http-Bg0h3D-t.js";
|
|
5
|
+
import { a as compact, c as parseJson, f as refuseTogether, s as meta, t as callSettings } from "./util-BOqd71Om.js";
|
|
6
6
|
// src/adapters/brave/response.ts
|
|
7
7
|
/** The `query` block every search response carries. */
|
|
8
8
|
const Query = looseObject({
|
|
@@ -328,7 +328,7 @@ const streamText = (stream) => {
|
|
|
328
328
|
const payload = line.slice(5).trim();
|
|
329
329
|
if (payload === "" || payload === "[DONE]") continue;
|
|
330
330
|
try {
|
|
331
|
-
const chunk = z
|
|
331
|
+
const chunk = z.parse(Completion, JSON.parse(payload));
|
|
332
332
|
for (const choice of chunk.choices) content += choice.delta.content ?? "";
|
|
333
333
|
} catch {}
|
|
334
334
|
}
|
|
@@ -347,8 +347,8 @@ const USAGE_TAG = /<usage>(?<body>[\s\S]*?)<\/usage>/gu;
|
|
|
347
347
|
const parseTag = (body, schema) => {
|
|
348
348
|
try {
|
|
349
349
|
const value = JSON.parse(body);
|
|
350
|
-
const twice = z
|
|
351
|
-
return [z
|
|
350
|
+
const twice = z.safeParse(z.string(), value);
|
|
351
|
+
return [z.parse(schema, twice.success ? JSON.parse(twice.data) : value)];
|
|
352
352
|
} catch {
|
|
353
353
|
return [];
|
|
354
354
|
}
|
|
@@ -384,7 +384,7 @@ const replyContent = (reply) => {
|
|
|
384
384
|
};
|
|
385
385
|
const completion = parseJson(provider, reply);
|
|
386
386
|
return {
|
|
387
|
-
content: completionText(z
|
|
387
|
+
content: completionText(z.parse(Completion, completion)),
|
|
388
388
|
response: completion
|
|
389
389
|
};
|
|
390
390
|
};
|
|
@@ -423,7 +423,7 @@ const answering = (raw) => ({ async answer(question, options = {}) {
|
|
|
423
423
|
}),
|
|
424
424
|
text: true
|
|
425
425
|
});
|
|
426
|
-
const { content, response } = replyContent(z
|
|
426
|
+
const { content, response } = replyContent(z.parse(z.string(), reply));
|
|
427
427
|
const answer = content.replace(CITATION_TAG, "").replace(USAGE_TAG, "").trim();
|
|
428
428
|
if (answer === "") throw new FieldworkError("ProviderError", "brave returned no answer text", {
|
|
429
429
|
cause: response,
|
|
@@ -456,7 +456,7 @@ const imaging = (raw) => ({ async images(query, options = {}) {
|
|
|
456
456
|
search_lang: lower(o.language),
|
|
457
457
|
spellcheck: o.spellcheck
|
|
458
458
|
}), call);
|
|
459
|
-
const body = z
|
|
459
|
+
const body = z.parse(ImageSearchResponse, response);
|
|
460
460
|
const results = [];
|
|
461
461
|
let withoutImage = 0;
|
|
462
462
|
for (const item of body.results) {
|
|
@@ -510,7 +510,7 @@ const searching = (raw) => ({ async search(query, options = {}) {
|
|
|
510
510
|
}), call);
|
|
511
511
|
return compact({
|
|
512
512
|
raw: response,
|
|
513
|
-
results: parseContext(z
|
|
513
|
+
results: parseContext(z.parse(ContextResponse, response))
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
if (mode === "news" || mode === "videos") {
|
|
@@ -521,7 +521,7 @@ const searching = (raw) => ({ async search(query, options = {}) {
|
|
|
521
521
|
spellcheck: o.spellcheck,
|
|
522
522
|
ui_lang: o.uiLanguage
|
|
523
523
|
}), call);
|
|
524
|
-
const body = z
|
|
524
|
+
const body = z.parse(VerticalSearchResponse, response);
|
|
525
525
|
const kind = mode === "news" ? "news" : "video";
|
|
526
526
|
return compact({
|
|
527
527
|
meta: meta({ warnings: warningsOf(body.query) }),
|
|
@@ -539,7 +539,7 @@ const searching = (raw) => ({ async search(query, options = {}) {
|
|
|
539
539
|
ui_lang: o.uiLanguage,
|
|
540
540
|
units: o.units
|
|
541
541
|
}), call);
|
|
542
|
-
const body = z
|
|
542
|
+
const body = z.parse(WebSearchResponse, response);
|
|
543
543
|
return compact({
|
|
544
544
|
meta: meta({ warnings: warningsOf(body.query) }),
|
|
545
545
|
raw: response,
|
package/dist/browserbase.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
1
2
|
import { t as defineAdapter } from "./adapter-CBSAfErv.js";
|
|
2
3
|
import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
|
|
3
|
-
import { O as withOriginal, _ as optionalId, b as optionalScalar, d as looseObject, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, w as recordOf, x as optionalString } from "./http-
|
|
4
|
-
import { a as compact,
|
|
4
|
+
import { O as withOriginal, _ as optionalId, b as optionalScalar, d as looseObject, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, w as recordOf, x as optionalString } from "./http-Bg0h3D-t.js";
|
|
5
|
+
import { a as compact, f as refuseTogether, p as requireJobId, s as meta, t as callSettings, u as presentPage } from "./util-BOqd71Om.js";
|
|
5
6
|
import { a as presentFile, i as header, n as byteLimit, o as tooLarge, r as checkFileUrl, t as MIB } from "./download-kuTqNnuZ.js";
|
|
6
|
-
import * as z$1 from "zod/mini";
|
|
7
7
|
// src/adapters/browserbase/response.ts
|
|
8
8
|
/** `POST /v1/sessions`. The id keeps the value as it arrived, for the error raised when there is none. */
|
|
9
9
|
const SessionResponse = looseObject({
|
|
@@ -52,7 +52,7 @@ const MAX_HOPS = 10;
|
|
|
52
52
|
/** The part of Browserbase's error body that says why. */
|
|
53
53
|
const ErrorBody = looseObject({ message: optionalString });
|
|
54
54
|
/** Whether Browserbase refused the response for exceeding its size limit. */
|
|
55
|
-
const overCeiling = (error) => error.status === 502 && (z
|
|
55
|
+
const overCeiling = (error) => error.status === 502 && (z.parse(ErrorBody, error.cause).message ?? "").includes("maximum allowed size");
|
|
56
56
|
/**
|
|
57
57
|
* The body as Fetch returned it: Base64 for a binary file, or text Fetch
|
|
58
58
|
* decoded as UTF-8. Throws `ProviderError` for text in any other encoding,
|
|
@@ -93,7 +93,7 @@ const hop = async (download, current, hops) => {
|
|
|
93
93
|
throw error instanceof FieldworkError && overCeiling(error) ? tooLarge(provider, url, void 0, limit) : error;
|
|
94
94
|
}
|
|
95
95
|
const seen = [...hops, response];
|
|
96
|
-
const body = z
|
|
96
|
+
const body = z.parse(FetchResponse, response);
|
|
97
97
|
const status = body.statusCode;
|
|
98
98
|
if (status !== void 0 && status >= 300 && status < 400) {
|
|
99
99
|
const location = header(body.headers, "location");
|
|
@@ -151,7 +151,7 @@ const fetchProxies = (o) => {
|
|
|
151
151
|
/** The session's live view URL, or a warning when Browserbase would not give one. */
|
|
152
152
|
const liveView = async (raw, id, call) => {
|
|
153
153
|
try {
|
|
154
|
-
const urls = z
|
|
154
|
+
const urls = z.parse(DebugResponse, await raw.request("GET", `/v1/sessions/${segment(id)}/debug`, call));
|
|
155
155
|
return { url: urls.debuggerFullscreenUrl ?? urls.debuggerUrl };
|
|
156
156
|
} catch (error) {
|
|
157
157
|
return { warning: `could not get the live view URL: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -159,7 +159,7 @@ const liveView = async (raw, id, call) => {
|
|
|
159
159
|
};
|
|
160
160
|
/** The key's project when it has exactly one; otherwise refuses rather than guess. */
|
|
161
161
|
const onlyProject = async (raw, call) => {
|
|
162
|
-
const projects = z
|
|
162
|
+
const projects = z.parse(ProjectsResponse, await raw.request("GET", "/v1/projects", call));
|
|
163
163
|
if (projects.length !== 1) throw invalidRequest(provider, `usage needs a project: pass projectId (this key has ${projects.length} projects)`);
|
|
164
164
|
return requireJobId(provider, projects[0]?.id ?? {
|
|
165
165
|
original: void 0,
|
|
@@ -209,7 +209,7 @@ const browsing = (raw, projectId) => ({ browser: {
|
|
|
209
209
|
userMetadata: o.userMetadata
|
|
210
210
|
})
|
|
211
211
|
});
|
|
212
|
-
const session = z
|
|
212
|
+
const session = z.parse(SessionResponse, response);
|
|
213
213
|
const id = requireJobId(provider, session.id);
|
|
214
214
|
const view = await liveView(raw, id, call);
|
|
215
215
|
return compact({
|
|
@@ -247,7 +247,7 @@ const fetching = (raw) => ({
|
|
|
247
247
|
url
|
|
248
248
|
})
|
|
249
249
|
});
|
|
250
|
-
const body = z
|
|
250
|
+
const body = z.parse(FetchResponse, response);
|
|
251
251
|
const { content } = body;
|
|
252
252
|
const binary = body.encoding === "base64";
|
|
253
253
|
const contentType = body.contentType ?? "";
|
|
@@ -282,7 +282,7 @@ const searching = (raw) => ({ async search(query, options = {}) {
|
|
|
282
282
|
query
|
|
283
283
|
})
|
|
284
284
|
});
|
|
285
|
-
const body = z
|
|
285
|
+
const body = z.parse(SearchResponse, response);
|
|
286
286
|
return compact({
|
|
287
287
|
meta: meta({ requestId: body.requestId }),
|
|
288
288
|
raw: response,
|
|
@@ -301,7 +301,7 @@ const accounting = (raw, projectId) => ({ async usage(options = {}) {
|
|
|
301
301
|
const { call } = callSettings(options);
|
|
302
302
|
const id = projectId ?? await onlyProject(raw, call);
|
|
303
303
|
const response = await raw.request("GET", `/v1/projects/${segment(id)}/usage`, call);
|
|
304
|
-
const body = z
|
|
304
|
+
const body = z.parse(UsageResponse, response);
|
|
305
305
|
return compact({
|
|
306
306
|
breakdown: Object.fromEntries(Object.entries({
|
|
307
307
|
browserMinutes: body.browserMinutes,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
1
2
|
import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
|
|
2
|
-
import {
|
|
3
|
-
import * as z$1 from "zod/mini";
|
|
3
|
+
import { f as refuseTogether } from "./util-BOqd71Om.js";
|
|
4
4
|
// src/document.ts
|
|
5
5
|
/** Content types of the document files parsers commonly take, by extension. */
|
|
6
6
|
const MEDIA_TYPES = new Map(Object.entries({
|
|
@@ -57,7 +57,7 @@ const enclosing = (boxes) => {
|
|
|
57
57
|
const documentUrl = (provider, document) => {
|
|
58
58
|
refuseTogether(provider, document, "url", "data");
|
|
59
59
|
refuseTogether(provider, document, "url", "name");
|
|
60
|
-
const parsed = z
|
|
60
|
+
const parsed = z.safeParse(z.url({ protocol: /^https?$/u }), document.url);
|
|
61
61
|
if (!parsed.success) throw invalidRequest(provider, "document url must be a public HTTP or HTTPS URL");
|
|
62
62
|
return parsed.data;
|
|
63
63
|
};
|
package/dist/exa.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
1
2
|
import { t as defineAdapter } from "./adapter-CBSAfErv.js";
|
|
2
3
|
import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
|
|
3
|
-
import { C as optionalStructure, E as warningEntry, O as withOriginal, S as optionalStringOrNumber, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, h as optionalBoolean, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, x as optionalString } from "./http-
|
|
4
|
-
import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-
|
|
5
|
-
import { n as jsonSchemaOf, t as checkOutput } from "./schema-
|
|
6
|
-
import { a as compact, c as parseJson,
|
|
7
|
-
import * as z$1 from "zod/mini";
|
|
4
|
+
import { C as optionalStructure, E as warningEntry, O as withOriginal, S as optionalStringOrNumber, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, h as optionalBoolean, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, x as optionalString } from "./http-Bg0h3D-t.js";
|
|
5
|
+
import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
|
|
6
|
+
import { n as jsonSchemaOf, t as checkOutput } from "./schema-Bfd2E8u2.js";
|
|
7
|
+
import { a as compact, c as parseJson, i as citationsOf, l as positiveWhole, m as uniqueCitations, o as hours, p as requireJobId, s as meta, t as callSettings } from "./util-BOqd71Om.js";
|
|
8
8
|
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/u;
|
|
9
9
|
/** The search types that take `additionalQueries`. */
|
|
10
10
|
const DEEP_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -37,6 +37,7 @@ const summaryOption = (summary, schema) => {
|
|
|
37
37
|
};
|
|
38
38
|
/** Refuses option combinations Exa does not accept, before the request is sent. */
|
|
39
39
|
const checkSearch = (o) => {
|
|
40
|
+
positiveWhole("exa", "maxCharsPerResult", o.maxCharsPerResult);
|
|
40
41
|
if (o.type === "lite") {
|
|
41
42
|
const unsupported = [
|
|
42
43
|
"additionalQueries",
|
|
@@ -107,6 +108,8 @@ const generatedAnswer = (output) => {
|
|
|
107
108
|
* out.
|
|
108
109
|
*/
|
|
109
110
|
const readBody = (o) => {
|
|
111
|
+
const maxCharsPerResult = positiveWhole("exa", "maxCharsPerResult", o.maxCharsPerResult);
|
|
112
|
+
const maxContentChars = positiveWhole("exa", "maxContentChars", o.maxContentChars);
|
|
110
113
|
const links = o.linkLimit ?? 100;
|
|
111
114
|
const images = o.imageLimit ?? 100;
|
|
112
115
|
const extras = compact({
|
|
@@ -114,7 +117,7 @@ const readBody = (o) => {
|
|
|
114
117
|
links: links > 0 ? links : void 0
|
|
115
118
|
});
|
|
116
119
|
const highlights = compact({
|
|
117
|
-
maxCharacters:
|
|
120
|
+
maxCharacters: maxCharsPerResult,
|
|
118
121
|
query: o.query === void 0 || o.query === "" ? void 0 : o.query
|
|
119
122
|
});
|
|
120
123
|
return compact({
|
|
@@ -123,7 +126,7 @@ const readBody = (o) => {
|
|
|
123
126
|
maxAgeHours: hours(o.maxAge),
|
|
124
127
|
snapshotAsOf: o.snapshotAsOf,
|
|
125
128
|
summary: summaryOption(o.summary),
|
|
126
|
-
text:
|
|
129
|
+
text: maxContentChars === void 0 ? true : { maxCharacters: maxContentChars }
|
|
127
130
|
});
|
|
128
131
|
};
|
|
129
132
|
/** The `/contents` options for `extract`: a structured summary of the page, and its cache age. */
|
|
@@ -262,7 +265,7 @@ const researchResult = (id, entry, structured) => {
|
|
|
262
265
|
};
|
|
263
266
|
/** Exa's trigger period for an interval schedule: `hour`, `day` and `week` become `1h`, `1d` and `7d`. Exa has no cron. */
|
|
264
267
|
const intervalPeriod = (schedule) => {
|
|
265
|
-
const parsed = z
|
|
268
|
+
const parsed = z.safeParse(z.string(), schedule.every);
|
|
266
269
|
if (!parsed.success) throw invalidRequest("exa", "monitors run on an interval of whole hours or days; Exa has no cron");
|
|
267
270
|
const every = parsed.data;
|
|
268
271
|
let value = every;
|
|
@@ -322,15 +325,15 @@ looseObject(metered);
|
|
|
322
325
|
const Result = looseObject({
|
|
323
326
|
author: optionalString,
|
|
324
327
|
extras: looseObject({
|
|
325
|
-
imageLinks: arrayOf(z
|
|
326
|
-
links: arrayOf(z
|
|
328
|
+
imageLinks: arrayOf(z.string()),
|
|
329
|
+
links: arrayOf(z.string())
|
|
327
330
|
}),
|
|
328
331
|
favicon: optionalString,
|
|
329
|
-
highlights: arrayOf(z
|
|
332
|
+
highlights: arrayOf(z.string()),
|
|
330
333
|
image: optionalString,
|
|
331
334
|
publishedDate: optionalString,
|
|
332
335
|
score: optionalNumber,
|
|
333
|
-
summary: z
|
|
336
|
+
summary: z.pipe(both(optionalString, anything), z.transform(({ first, second }) => ({
|
|
334
337
|
text: first,
|
|
335
338
|
value: second
|
|
336
339
|
}))),
|
|
@@ -345,7 +348,7 @@ const UrlStatus = looseObject({
|
|
|
345
348
|
tag: optionalString
|
|
346
349
|
}),
|
|
347
350
|
id: optionalString,
|
|
348
|
-
status: z
|
|
351
|
+
status: z.pipe(both(anything, optionalString), z.transform(({ first, second }) => ({
|
|
349
352
|
text: second,
|
|
350
353
|
value: first
|
|
351
354
|
})))
|
|
@@ -359,14 +362,14 @@ const ContentsResponse = looseObject({
|
|
|
359
362
|
/** A generated answer: text, or the structured value the output schema asked for. */
|
|
360
363
|
const AnswerResponse = looseObject({
|
|
361
364
|
...metered,
|
|
362
|
-
answer: z
|
|
365
|
+
answer: z.pipe(both(optionalString, optionalStructure), z.transform(({ first, second }) => ({
|
|
363
366
|
structure: second,
|
|
364
367
|
text: first
|
|
365
368
|
}))),
|
|
366
369
|
citations: arrayOf(Source)
|
|
367
370
|
});
|
|
368
371
|
/** A string, or any other value kept as it arrived. */
|
|
369
|
-
const Content = z
|
|
372
|
+
const Content = z.pipe(both(optionalAnyString, anything), z.transform(({ first, second }) => ({
|
|
370
373
|
text: first,
|
|
371
374
|
value: second
|
|
372
375
|
})));
|
|
@@ -452,7 +455,7 @@ const RunsPage = looseObject({
|
|
|
452
455
|
* one before it names its cursor. A cursor seen before ends the listing.
|
|
453
456
|
*/
|
|
454
457
|
const listMonitors = async (raw, call, cursor, seen) => {
|
|
455
|
-
const page = z
|
|
458
|
+
const page = z.parse(MonitorsPage, await raw.request("GET", "/monitors", {
|
|
456
459
|
...call,
|
|
457
460
|
query: {
|
|
458
461
|
cursor,
|
|
@@ -489,7 +492,7 @@ const exaMonitor = (raw) => ({
|
|
|
489
492
|
url: o.webhookUrl
|
|
490
493
|
})
|
|
491
494
|
});
|
|
492
|
-
return monitorInfo(z
|
|
495
|
+
return monitorInfo(z.parse(MonitorEntry, await raw.request("POST", "/monitors", {
|
|
493
496
|
creates: true,
|
|
494
497
|
...call,
|
|
495
498
|
body
|
|
@@ -508,7 +511,7 @@ const exaMonitor = (raw) => ({
|
|
|
508
511
|
limit: o.limit
|
|
509
512
|
}
|
|
510
513
|
});
|
|
511
|
-
const page = z
|
|
514
|
+
const page = z.parse(RunsPage, response);
|
|
512
515
|
return compact({
|
|
513
516
|
events: page.data.map((entry) => monitorEvent(entry)),
|
|
514
517
|
next: page.hasMore === true ? page.nextCursor : void 0,
|
|
@@ -517,7 +520,7 @@ const exaMonitor = (raw) => ({
|
|
|
517
520
|
},
|
|
518
521
|
async get(id, options = {}) {
|
|
519
522
|
const { call } = callSettings(options);
|
|
520
|
-
return monitorInfo(z
|
|
523
|
+
return monitorInfo(z.parse(MonitorEntry, await raw.request("GET", `/monitors/${segment(id)}`, call)));
|
|
521
524
|
},
|
|
522
525
|
async list(options = {}) {
|
|
523
526
|
const { call } = callSettings(options);
|
|
@@ -535,7 +538,7 @@ const fetchContents = async (raw, urls, body, call) => {
|
|
|
535
538
|
}
|
|
536
539
|
});
|
|
537
540
|
return {
|
|
538
|
-
body: z
|
|
541
|
+
body: z.parse(ContentsResponse, response),
|
|
539
542
|
response
|
|
540
543
|
};
|
|
541
544
|
};
|
|
@@ -576,7 +579,7 @@ const searching = (raw) => ({
|
|
|
576
579
|
userLocation: o.country === void 0 || o.country === "" ? void 0 : { country: o.country }
|
|
577
580
|
})
|
|
578
581
|
});
|
|
579
|
-
const body = z
|
|
582
|
+
const body = z.parse(AnswerResponse, response);
|
|
580
583
|
const { structure, text } = body.answer;
|
|
581
584
|
const answer = structure === void 0 ? text : JSON.stringify(structure);
|
|
582
585
|
if (answer === void 0 || answer === "") throw new FieldworkError("ProviderError", "exa returned no answer text", {
|
|
@@ -613,7 +616,7 @@ const searching = (raw) => ({
|
|
|
613
616
|
userLocation: o.country === void 0 || o.country === "" ? void 0 : { country: o.country }
|
|
614
617
|
})
|
|
615
618
|
});
|
|
616
|
-
const body = z
|
|
619
|
+
const body = z.parse(SearchResponse, response);
|
|
617
620
|
return compact({
|
|
618
621
|
answer: generatedAnswer(body.output),
|
|
619
622
|
meta: responseMeta(body, [...body.warnings, ...body.notices].filter((note) => note !== void 0)),
|
|
@@ -671,7 +674,7 @@ const researching = (raw) => ({ async research(question, options = {}) {
|
|
|
671
674
|
const { call, rest: o } = callSettings(options);
|
|
672
675
|
checkResearch(o);
|
|
673
676
|
return await runJob("exa", {
|
|
674
|
-
check: async (id, request) => runState(id, z
|
|
677
|
+
check: async (id, request) => runState(id, z.parse(RunEntry, await raw.request("GET", `/agent/runs/${segment(id)}`, request))),
|
|
675
678
|
finish: async (run, id) => {
|
|
676
679
|
const { outputSchema } = run.value.request;
|
|
677
680
|
const structured = o.schema !== void 0 || outputSchema !== void 0 && outputSchema !== null;
|