@howells/fieldwork-sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/exa.js CHANGED
@@ -1,163 +1,471 @@
1
- import { t as defineAdapter } from "./adapter-D-6-GFhJ.js";
2
- import { t as FieldworkError } from "./errors-pzPMh82H.js";
3
- import { a as list, c as record, d as strings, f as text, g as requireKey, h as poll, i as compact, l as requireId, m as createRawClient, o as num, p as uniqueCitations, r as citations, s as parseJson, t as callSettings } from "./util-DgcIZI2K.js";
1
+ import { t as defineAdapter } from "./adapter-CEAQuT7F.js";
2
+ import { t as FieldworkError } from "./errors-BiIBG9zN.js";
3
+ import { _ as uniqueCitations, a as hours, b as requireKey, c as num, d as record, g as text, h as strings, i as compact, l as parseJson, o as list, p as requireId, r as citations, s as meta, t as callSettings, v as createRawClient, y as poll } from "./util-CYenIQQT.js";
4
+ const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/u;
5
+ const DEEP_TYPES = /* @__PURE__ */ new Set([
6
+ "deep-lite",
7
+ "deep",
8
+ "deep-reasoning"
9
+ ]);
10
+ const invalid = (message) => {
11
+ throw new FieldworkError("InvalidRequest", `exa ${message}`, { provider: "exa" });
12
+ };
13
+ const dateTime = (value, endOfDay) => {
14
+ if (value === void 0 || !DATE_ONLY.test(value)) return value;
15
+ return endOfDay ? `${value}T23:59:59.999Z` : `${value}T00:00:00.000Z`;
16
+ };
17
+ const costOf = (response) => num(record(response.costDollars).total);
18
+ const responseMeta = (response, warnings) => meta({
19
+ costUsd: costOf(response),
20
+ requestId: response.requestId,
21
+ warnings
22
+ });
23
+ const summaryOption = (summary, schema) => {
24
+ if (summary === void 0 || summary === false) return schema ? compact({ schema }) : void 0;
25
+ return compact({
26
+ query: typeof summary === "object" ? summary.query : void 0,
27
+ schema
28
+ });
29
+ };
30
+ const checkSearch = (o) => {
31
+ if (o.type === "lite") {
32
+ const unsupported = [
33
+ "additionalQueries",
34
+ "outputSchema",
35
+ "systemPrompt",
36
+ "summary",
37
+ "maxAge"
38
+ ].filter((name) => o[name] !== void 0);
39
+ if (unsupported.length > 0) invalid(`search type "lite" does not accept ${unsupported.join(", ")}`);
40
+ }
41
+ if (o.additionalQueries !== void 0 && !DEEP_TYPES.has(o.type ?? "")) invalid("additionalQueries needs search type \"deep-lite\", \"deep\" or \"deep-reasoning\"");
42
+ const dated = o.publishedAfter !== void 0 || o.publishedBefore !== void 0;
43
+ if ((o.category === "company" || o.category === "people") && dated) invalid(`category "${o.category}" does not accept publishedAfter or publishedBefore`);
44
+ if (o.category === "people" && o.excludeDomains !== void 0) invalid("category \"people\" does not accept excludeDomains");
45
+ };
46
+ const highlightsOption = (highlights) => typeof highlights === "object" ? compact({
47
+ maxCharacters: highlights.maxCharacters,
48
+ query: highlights.query
49
+ }) : true;
50
+ const searchContents = (o) => {
51
+ const contents = compact({
52
+ highlights: o.highlights === false ? void 0 : highlightsOption(o.highlights),
53
+ maxAgeHours: hours(o.maxAge),
54
+ summary: summaryOption(o.summary),
55
+ text: o.content ? true : void 0
56
+ });
57
+ return Object.keys(contents).length > 0 ? contents : void 0;
58
+ };
59
+ const searchResult = (item) => {
60
+ const result = record(item);
61
+ return compact({
62
+ author: text(result.author),
63
+ content: text(result.text),
64
+ favicon: text(result.favicon),
65
+ image: text(result.image),
66
+ publishedAt: text(result.publishedDate),
67
+ score: num(result.score),
68
+ snippet: strings(result.highlights)?.join(" … "),
69
+ title: text(result.title),
70
+ url: text(result.url) ?? ""
71
+ });
72
+ };
73
+ const generatedAnswer = (output) => {
74
+ const { content } = output;
75
+ if (typeof content === "string") return text(content);
76
+ return content === void 0 || content === null ? void 0 : JSON.stringify(content);
77
+ };
78
+ const readBody = (o) => {
79
+ const links = o.linkLimit ?? 100;
80
+ const images = o.imageLimit ?? 100;
81
+ const extras = compact({
82
+ imageLinks: images > 0 ? images : void 0,
83
+ links: links > 0 ? links : void 0
84
+ });
85
+ return compact({
86
+ extras: Object.keys(extras).length > 0 ? extras : void 0,
87
+ highlights: o.query ? { query: o.query } : void 0,
88
+ maxAgeHours: hours(o.maxAge),
89
+ snapshotAsOf: o.snapshotAsOf,
90
+ summary: summaryOption(o.summary),
91
+ text: o.maxCharacters === void 0 ? true : { maxCharacters: o.maxCharacters }
92
+ });
93
+ };
94
+ const failureCode = (tag, httpStatus) => {
95
+ if (tag === "CRAWL_NOT_FOUND" || tag === "CONTENT_NOT_CACHED") return "NotFound";
96
+ if (tag === "CRAWL_TIMEOUT") return "Timeout";
97
+ if (httpStatus === 404 || httpStatus === 410) return "NotFound";
98
+ return httpStatus === 408 || httpStatus === 504 ? "Timeout" : "ProviderError";
99
+ };
100
+ const statusReason = (status) => {
101
+ const error = record(status.error);
102
+ const httpStatus = num(error.httpStatusCode);
103
+ return text(error.tag) ?? (httpStatus === void 0 ? void 0 : `HTTP ${httpStatus}`) ?? text(status.status) ?? "unknown";
104
+ };
105
+ const failedStatuses = (response) => list(response.statuses).map((item) => record(item)).filter((status) => status.status !== void 0 && status.status !== "success");
106
+ const pageFrom = (url, item, rawValue) => {
107
+ const result = record(item);
108
+ const extras = record(result.extras);
109
+ return compact({
110
+ author: text(result.author),
111
+ excerpts: strings(result.highlights),
112
+ favicon: text(result.favicon),
113
+ image: text(result.image),
114
+ images: strings(extras.imageLinks),
115
+ links: strings(extras.links),
116
+ markdown: text(result.text),
117
+ publishedAt: text(result.publishedDate),
118
+ raw: rawValue,
119
+ summary: text(result.summary),
120
+ title: text(result.title),
121
+ url: text(result.url) ?? url
122
+ });
123
+ };
124
+ const hasOutput = (run, structured) => {
125
+ const output = record(run.output);
126
+ return structured ? output.structured !== void 0 && output.structured !== null : text(output.text) !== void 0;
127
+ };
128
+ const runMeta = (run) => {
129
+ const usage = record(run.usage);
130
+ return meta({
131
+ costUsd: costOf(run),
132
+ units: {
133
+ agentComputeUnits: usage.agentComputeUnits,
134
+ emails: usage.emails,
135
+ phoneNumbers: usage.phoneNumbers,
136
+ searches: usage.searches
137
+ }
138
+ });
139
+ };
140
+ const checkResearch = (o) => {
141
+ const effort = o.effort ?? "auto";
142
+ if (o.maxCostDollars !== void 0 && effort !== "auto" && effort !== "ultra") invalid(`maxCostDollars needs effort "auto" or "ultra", not "${effort}"`);
143
+ if (o.maxDurationSeconds !== void 0 && effort !== "ultra") invalid(`maxDurationSeconds needs effort "ultra", not "${effort}"`);
144
+ };
145
+ const researchBody = (question, o) => {
146
+ const budget = compact({
147
+ maxCostDollars: o.maxCostDollars,
148
+ maxDurationSeconds: o.maxDurationSeconds
149
+ });
150
+ const input = compact({
151
+ data: o.input?.data,
152
+ exclusion: o.input?.exclusion
153
+ });
154
+ return compact({
155
+ budget: Object.keys(budget).length > 0 ? budget : void 0,
156
+ effort: o.effort,
157
+ input: Object.keys(input).length > 0 ? input : void 0,
158
+ outputSchema: o.schema,
159
+ previousRunId: o.continueFrom,
160
+ query: question,
161
+ systemPrompt: o.systemPrompt
162
+ });
163
+ };
164
+ const researchResult = (id, run, structured) => {
165
+ const stopReason = text(run.stopReason);
166
+ const status = text(run.status) ?? "unknown";
167
+ if (status !== "completed" && !hasOutput(run, structured)) {
168
+ const error = record(run.error);
169
+ const message = text(error.message);
170
+ const detail = message ? `${text(error.code) ?? text(error.type) ?? "error"}: ${message}` : stopReason;
171
+ throw new FieldworkError("JobFailed", `exa research run ${id} ended ${status}${detail ? ` (${detail})` : ""}`, {
172
+ cause: run,
173
+ jobId: id,
174
+ provider: "exa"
175
+ });
176
+ }
177
+ const output = record(run.output);
178
+ const fields = list(output.grounding).map((item) => {
179
+ const grounding = record(item);
180
+ return compact({
181
+ citations: citations(grounding.citations),
182
+ confidence: text(grounding.confidence) ?? num(grounding.confidence),
183
+ field: text(grounding.field) ?? ""
184
+ });
185
+ });
186
+ const finished = status === "completed" && (stopReason === void 0 || stopReason === "schema_satisfied");
187
+ return compact({
188
+ continuationId: status === "completed" ? id : void 0,
189
+ fields: fields.length > 0 ? fields : void 0,
190
+ id,
191
+ meta: runMeta(run),
192
+ output: structured ? output.structured : output.text,
193
+ raw: run,
194
+ sources: uniqueCitations(fields.flatMap((field) => field.citations)),
195
+ status: finished ? "completed" : "partial",
196
+ stopReason: finished ? void 0 : stopReason ?? status
197
+ });
198
+ };
199
+ const intervalPeriod = (schedule) => {
200
+ const { every } = schedule;
201
+ if (typeof every !== "string") return invalid("monitors run on an interval of whole hours or days; Exa has no cron");
202
+ let value = every;
203
+ if (every === "hour") value = "1h";
204
+ else if (every === "day") value = "1d";
205
+ else if (every === "week") value = "7d";
206
+ if (!/^[1-9]\d*[hd]$/u.test(value)) return invalid(`monitor schedule "${every}" is not whole hours or days, at least 1h`);
207
+ return value;
208
+ };
209
+ const period = (schedule) => schedule === void 0 ? void 0 : intervalPeriod(schedule);
210
+ const monitorInfo = (value) => {
211
+ const found = record(value);
212
+ return compact({
213
+ createdAt: text(found.createdAt),
214
+ id: requireId("exa", found.id),
215
+ raw: value,
216
+ schedule: text(record(found.trigger).period),
217
+ status: text(found.status),
218
+ watch: text(record(found.search).query),
219
+ webhookUrl: text(record(found.webhook).url)
220
+ });
221
+ };
222
+ const eventSummary = (run, content) => {
223
+ if (typeof content === "string") return text(content);
224
+ if (run.status === "failed") {
225
+ const reason = text(run.failReason);
226
+ return `Run failed${reason ? `: ${reason}` : ""}`;
227
+ }
228
+ };
229
+ const monitorEvent = (item) => {
230
+ const run = record(item);
231
+ const output = record(run.output);
232
+ const { content } = output;
233
+ const grounded = uniqueCitations(list(output.grounding).flatMap((entry) => citations(record(entry).citations)));
234
+ const structured = content !== void 0 && content !== null && typeof content !== "string";
235
+ return compact({
236
+ at: text(run.completedAt) ?? text(run.createdAt),
237
+ citations: grounded.length > 0 ? grounded : void 0,
238
+ id: text(run.id),
239
+ output: structured ? content : void 0,
240
+ raw: item,
241
+ summary: eventSummary(run, content)
242
+ });
243
+ };
4
244
  // src/adapters/exa.ts
5
- function exa(config = {}) {
6
- const provider = "exa";
245
+ const exa = (config = {}) => {
7
246
  const raw = createRawClient({
8
- provider,
9
247
  baseUrl: config.baseUrl ?? "https://api.exa.ai",
10
- headers: { "x-api-key": requireKey(provider, config.apiKey, "EXA_API_KEY") },
11
- fetch: config.fetch
12
- });
13
- async function contents(url, body, call) {
14
- const response = await raw.request("POST", "/contents", {
15
- ...call,
16
- body: {
17
- urls: [url],
18
- ...body
19
- }
20
- });
21
- const status = record(list(record(response).statuses)[0]);
22
- if (status.status && status.status !== "success") {
23
- const reason = text(record(status.error).tag) ?? text(status.status) ?? "unknown";
24
- throw new FieldworkError(reason === "CRAWL_NOT_FOUND" ? "NotFound" : "ProviderError", `exa could not read ${url}: ${reason}`, {
25
- provider,
26
- cause: response
248
+ fetch: config.fetch,
249
+ headers: { "x-api-key": requireKey("exa", config.apiKey, "EXA_API_KEY") },
250
+ provider: "exa"
251
+ });
252
+ const fetchContents = async (urls, body, call) => record(await raw.request("POST", "/contents", {
253
+ ...call,
254
+ body: {
255
+ urls,
256
+ ...body
257
+ }
258
+ }));
259
+ const readOne = async (url, body, call) => {
260
+ const response = await fetchContents([url], body, call);
261
+ const [failed] = failedStatuses(response);
262
+ if (failed) {
263
+ const error = record(failed.error);
264
+ throw new FieldworkError(failureCode(text(error.tag), num(error.httpStatusCode)), `exa could not read ${url}: ${statusReason(failed)}`, {
265
+ cause: response,
266
+ provider: "exa",
267
+ status: num(error.httpStatusCode)
27
268
  });
28
269
  }
270
+ const [result] = list(response.results);
271
+ if (result === void 0) throw new FieldworkError("ProviderError", `exa returned no content for ${url}`, {
272
+ cause: response,
273
+ provider: "exa"
274
+ });
29
275
  return {
30
276
  response,
31
- result: record(list(record(response).results)[0])
277
+ result
32
278
  };
33
- }
279
+ };
34
280
  return defineAdapter({
35
- name: provider,
281
+ name: "exa",
36
282
  operations: {
37
- async search(query, options) {
283
+ async answer(question, options) {
38
284
  const { call, rest: o } = callSettings(options);
39
- const response = record(await raw.request("POST", "/search", {
285
+ const response = record(await raw.request("POST", "/answer", {
40
286
  ...call,
41
287
  body: compact({
42
- query,
43
- numResults: o.limit,
44
- type: o.type,
45
- category: o.category,
46
- includeDomains: o.includeDomains,
47
- excludeDomains: o.excludeDomains,
48
- startPublishedDate: o.publishedAfter,
49
- endPublishedDate: o.publishedBefore,
50
- startCrawlDate: o.crawledAfter,
51
- endCrawlDate: o.crawledBefore,
52
- includeText: o.includeText,
53
- excludeText: o.excludeText,
54
- userLocation: o.country ? { country: o.country } : void 0,
55
- additionalQueries: o.additionalQueries,
56
- contents: o.content ? { text: true } : void 0
288
+ model: o.model,
289
+ outputSchema: o.schema,
290
+ query: question,
291
+ systemPrompt: o.systemPrompt,
292
+ userLocation: o.country ? { country: o.country } : void 0
57
293
  })
58
294
  }));
59
- return {
60
- results: list(response.results).map((item) => {
61
- const result = record(item);
62
- return compact({
63
- url: text(result.url) ?? "",
64
- title: text(result.title),
65
- snippet: strings(result.highlights)?.join(" … "),
66
- content: text(result.text),
67
- publishedAt: text(result.publishedDate),
68
- score: num(result.score)
69
- });
70
- }),
71
- raw: response
72
- };
73
- },
74
- async read(url, options) {
75
- const { call, rest: o } = callSettings(options);
76
- const { response, result } = await contents(url, compact({
77
- text: compact({ maxCharacters: o.maxCharacters }),
78
- highlights: o.query ? { query: o.query } : void 0,
79
- maxAgeHours: o.maxAgeHours,
80
- snapshotAsOf: o.snapshotAsOf,
81
- extras: {
82
- links: 100,
83
- imageLinks: 100
84
- }
85
- }), call);
86
- const extras = record(result.extras);
295
+ const { answer: value } = response;
296
+ const structured = typeof value === "object" && value !== null;
87
297
  return compact({
88
- url: text(result.url) ?? url,
89
- title: text(result.title),
90
- markdown: text(result.text),
91
- excerpts: strings(result.highlights),
92
- links: strings(extras.links),
93
- images: strings(extras.imageLinks),
298
+ answer: structured ? JSON.stringify(value) : text(value) ?? "",
299
+ citations: uniqueCitations(citations(response.citations)),
300
+ meta: responseMeta(response),
301
+ output: structured ? value : void 0,
94
302
  raw: response
95
303
  });
96
304
  },
97
305
  async extract(url, options) {
98
306
  const { call, rest: o } = callSettings(options);
99
- const { response, result } = await contents(url, compact({
100
- text: true,
307
+ const { response, result } = await readOne(url, compact({
308
+ maxAgeHours: hours(o.maxAge),
101
309
  summary: compact({
102
310
  query: o.prompt,
103
311
  schema: o.schema
104
- }),
105
- maxAgeHours: o.maxAgeHours
312
+ })
106
313
  }), call);
107
- if (result.summary === void 0) throw new FieldworkError("ProviderError", `exa returned no structured summary for ${url}`, {
108
- provider,
109
- cause: response
314
+ const { summary } = record(result);
315
+ if (summary === void 0) throw new FieldworkError("ProviderError", `exa returned no structured summary for ${url}`, {
316
+ cause: response,
317
+ provider: "exa"
318
+ });
319
+ return compact({
320
+ data: parseJson("exa", summary),
321
+ meta: responseMeta(response),
322
+ raw: response
323
+ });
324
+ },
325
+ monitor: {
326
+ async create(options) {
327
+ const { call, rest: o } = callSettings(options);
328
+ const every = period(o.schedule);
329
+ const body = compact({
330
+ metadata: o.metadata,
331
+ name: o.name,
332
+ outputSchema: o.outputSchema,
333
+ search: compact({
334
+ contents: o.content ? { text: true } : void 0,
335
+ excludeDomains: o.excludeDomains,
336
+ includeDomains: o.includeDomains,
337
+ numResults: o.limit,
338
+ query: o.query
339
+ }),
340
+ trigger: every ? {
341
+ period: every,
342
+ type: "interval"
343
+ } : void 0,
344
+ webhook: compact({
345
+ events: o.webhookEvents,
346
+ url: o.webhookUrl
347
+ })
348
+ });
349
+ return monitorInfo(await raw.request("POST", "/monitors", {
350
+ ...call,
351
+ body
352
+ }));
353
+ },
354
+ async delete(id, options) {
355
+ const { call } = callSettings(options);
356
+ await raw.request("DELETE", `/monitors/${encodeURIComponent(id)}`, call);
357
+ },
358
+ async events(id, options) {
359
+ const { call, rest: o } = callSettings(options);
360
+ const response = record(await raw.request("GET", `/monitors/${encodeURIComponent(id)}/runs`, {
361
+ ...call,
362
+ query: {
363
+ cursor: o.cursor,
364
+ limit: o.limit
365
+ }
366
+ }));
367
+ return compact({
368
+ events: list(response.data).map((item) => monitorEvent(item)),
369
+ next: response.hasMore === true ? text(response.nextCursor) : void 0,
370
+ raw: response
371
+ });
372
+ },
373
+ async get(id, options) {
374
+ const { call } = callSettings(options);
375
+ return monitorInfo(await raw.request("GET", `/monitors/${encodeURIComponent(id)}`, call));
376
+ },
377
+ async list(options) {
378
+ const { call } = callSettings(options);
379
+ const monitors = [];
380
+ const seen = /* @__PURE__ */ new Set();
381
+ let cursor;
382
+ for (;;) {
383
+ const page = record(await raw.request("GET", "/monitors", {
384
+ ...call,
385
+ query: {
386
+ cursor,
387
+ limit: 100
388
+ }
389
+ }));
390
+ monitors.push(...list(page.data).map((item) => monitorInfo(item)));
391
+ cursor = text(page.nextCursor);
392
+ if (page.hasMore !== true || cursor === void 0 || seen.has(cursor)) return monitors;
393
+ seen.add(cursor);
394
+ }
395
+ }
396
+ },
397
+ async read(url, options) {
398
+ const { call, rest: o } = callSettings(options);
399
+ const { response, result } = await readOne(url, readBody(o), call);
400
+ return compact({
401
+ ...pageFrom(url, result, response),
402
+ meta: responseMeta(response)
110
403
  });
404
+ },
405
+ async readMany(urls, options) {
406
+ const { call, rest: o } = callSettings(options);
407
+ if (urls.length === 0) invalid("readMany needs at least one URL");
408
+ if (urls.length > 100) invalid(`readMany reads at most 100 URLs per call`);
409
+ const response = await fetchContents(urls, readBody(o), call);
111
410
  return {
112
- data: parseJson(provider, result.summary),
411
+ failed: failedStatuses(response).map((status) => ({
412
+ error: statusReason(status),
413
+ url: text(status.id) ?? ""
414
+ })),
415
+ meta: responseMeta(response),
416
+ pages: list(response.results).map((item) => pageFrom("", item, item)),
113
417
  raw: response
114
418
  };
115
419
  },
116
420
  async research(question, options) {
117
421
  const { call, rest: o } = callSettings(options);
118
- const budget = compact({
119
- maxCostDollars: o.maxCostDollars,
120
- maxDurationSeconds: o.maxDurationSeconds
121
- });
122
- const id = o.resume ?? requireId(provider, record(await raw.request("POST", "/agent/runs", {
422
+ checkResearch(o);
423
+ const id = o.resume ?? requireId("exa", record(await raw.request("POST", "/agent/runs", {
123
424
  ...call,
124
- body: compact({
125
- query: question,
126
- outputSchema: o.schema,
127
- effort: o.effort,
128
- budget: Object.keys(budget).length > 0 ? budget : void 0
129
- })
425
+ body: researchBody(question, o)
130
426
  })).id);
131
- const run = await poll(provider, id, async () => {
132
- const current = record(await raw.request("GET", `/agent/runs/${id}`, { signal: call.signal }));
133
- if (current.status === "failed" || current.status === "cancelled") throw new FieldworkError("JobFailed", `exa research run ${id} ended ${text(current.status) ?? "unknown"}`, {
134
- provider,
135
- cause: current
136
- });
137
- return current.status === "completed" ? current : void 0;
427
+ const run = await poll("exa", id, async () => {
428
+ const current = record(await raw.request("GET", `/agent/runs/${encodeURIComponent(id)}`, { signal: call.signal }));
429
+ return current.status === "completed" || current.status === "failed" || current.status === "cancelled" ? current : void 0;
138
430
  }, {
139
431
  ...call,
140
432
  interval: o.interval
141
433
  });
142
- const output = record(run.output);
143
- const fields = list(output.grounding).map((item) => {
144
- const grounding = record(item);
145
- return compact({
146
- field: text(grounding.field) ?? "",
147
- citations: citations(grounding.citations),
148
- confidence: text(grounding.confidence) ?? num(grounding.confidence)
149
- });
434
+ const { outputSchema } = record(run.request);
435
+ const structured = o.schema !== void 0 || outputSchema !== void 0 && outputSchema !== null;
436
+ return researchResult(id, run, structured);
437
+ },
438
+ async search(query, options) {
439
+ const { call, rest: o } = callSettings(options);
440
+ checkSearch(o);
441
+ const response = record(await raw.request("POST", "/search", {
442
+ ...call,
443
+ body: compact({
444
+ additionalQueries: o.additionalQueries,
445
+ category: o.category,
446
+ contents: searchContents(o),
447
+ endPublishedDate: dateTime(o.publishedBefore, true),
448
+ excludeDomains: o.excludeDomains,
449
+ includeDomains: o.includeDomains,
450
+ moderation: o.moderation,
451
+ numResults: o.limit,
452
+ outputSchema: o.outputSchema,
453
+ query,
454
+ startPublishedDate: dateTime(o.publishedAfter, false),
455
+ systemPrompt: o.systemPrompt,
456
+ type: o.type,
457
+ userLocation: o.country ? { country: o.country } : void 0
458
+ })
459
+ }));
460
+ return compact({
461
+ answer: generatedAnswer(record(response.output)),
462
+ meta: responseMeta(response, [...list(response.warnings), ...list(response.notices)]),
463
+ raw: response,
464
+ results: list(response.results).map((item) => searchResult(item))
150
465
  });
151
- return {
152
- id,
153
- output: o.schema ? output.structured : output.text,
154
- sources: uniqueCitations(fields.flatMap((field) => field.citations)),
155
- fields,
156
- raw: run
157
- };
158
466
  }
159
467
  },
160
468
  raw
161
469
  });
162
- }
470
+ };
163
471
  export { exa };
@@ -1,4 +1,4 @@
1
- import { n as AnyAdapter, u as Capability } from "./adapter-C_kRm6TT.js";
1
+ import { n as AnyAdapter, p as Capability } from "./adapter-DGehHCMo.js";
2
2
  type FieldworkErrorCode =
3
3
  /** The adapter's provider does not offer this capability. */
4
4
  "Unsupported" |
@@ -44,14 +44,14 @@ declare class FieldworkError extends Error {
44
44
  constructor(code: FieldworkErrorCode, message: string, options?: FieldworkErrorOptions);
45
45
  /** The fields an agent or a log needs, without the provider's response. */
46
46
  toJSON(): {
47
- name: string;
48
47
  code: FieldworkErrorCode;
48
+ jobId: string | undefined;
49
49
  message: string;
50
+ name: string;
50
51
  provider: string | undefined;
51
- status: number | undefined;
52
- retryable: boolean;
53
52
  retryAfter: number | undefined;
54
- jobId: string | undefined;
53
+ retryable: boolean;
54
+ status: number | undefined;
55
55
  };
56
56
  }
57
57
  interface FieldworkOptions<A extends AnyAdapter> {