webfox 4.11.0 → 4.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.
Files changed (95) hide show
  1. package/README.md +5 -2
  2. package/dist/adapter-2HWVV4H7.js +144 -0
  3. package/dist/{adapter-QQZFHUOP.js → adapter-2V73476L.js} +69 -131
  4. package/dist/{adapter-SZMVKAMC.js → adapter-3V4OZDZZ.js} +10 -14
  5. package/dist/adapter-64462GL3.js +247 -0
  6. package/dist/{adapter-WXEVTCM3.js → adapter-BCZ4UE7S.js} +38 -81
  7. package/dist/{adapter-YVZ4YBK5.js → adapter-BHDA6JOK.js} +40 -56
  8. package/dist/adapter-EQ3LZTZ4.js +152 -0
  9. package/dist/adapter-EQSFB26L.js +58 -0
  10. package/dist/{adapter-ODDFBGJG.js → adapter-EXDS6465.js} +36 -57
  11. package/dist/adapter-IWGMWJ5A.js +121 -0
  12. package/dist/{adapter-XSQX3GAI.js → adapter-JQNYUBYZ.js} +33 -23
  13. package/dist/{adapter-VXT4C6RZ.js → adapter-OTMS6OEU.js} +81 -102
  14. package/dist/{adapter-MZ7USB6Q.js → adapter-PW4UL2DR.js} +12 -32
  15. package/dist/adapter-RBSOVQCV.js +84 -0
  16. package/dist/{adapter-GFXYSHKP.js → adapter-RJ334ZU5.js} +28 -76
  17. package/dist/{adapter-XU2APKPC.js → adapter-T6UEERC7.js} +19 -24
  18. package/dist/{adapter-BZO5UEI6.js → adapter-VVWNAGWI.js} +118 -142
  19. package/dist/{adapter-GJOUFE2U.js → adapter-XMEXVEMQ.js} +7 -10
  20. package/dist/adapter-ZLS55DG2.js +341 -0
  21. package/dist/{chunk-NENL6L6N.js → chunk-46OIVYHW.js} +1 -0
  22. package/dist/{chunk-WCTOYZVB.js → chunk-6UC3ZBNK.js} +15 -5
  23. package/dist/{chunk-YILOS4E7.js → chunk-7NTO6AQX.js} +110 -72
  24. package/dist/{chunk-PVNWACMT.js → chunk-EBKQHHCO.js} +199 -20
  25. package/dist/chunk-HZVTFUBC.js +139 -0
  26. package/dist/{chunk-LDVDVA4Z.js → chunk-I4HLGP7F.js} +3 -7
  27. package/dist/chunk-U4I3X7IN.js +267 -0
  28. package/dist/chunk-V4SQCDI3.js +336 -0
  29. package/dist/chunk-VMIDLDYP.js +111 -0
  30. package/dist/cli.js +9 -9
  31. package/dist/config.schema.json +222 -1
  32. package/dist/document-schema.d.ts +4 -4
  33. package/dist/domain.d.ts +1 -1
  34. package/dist/durable.js +73 -65
  35. package/dist/index.js +8 -7
  36. package/dist/pi-render.d.ts +3 -2
  37. package/dist/pi-shared.d.ts +39 -0
  38. package/dist/pi.js +87 -191
  39. package/dist/providers/brave/adapter.d.ts +4 -5
  40. package/dist/providers/cloudflare/adapter.d.ts +3 -2
  41. package/dist/providers/contract.d.ts +20 -19
  42. package/dist/providers/custom/adapter.d.ts +2 -2
  43. package/dist/providers/exa/adapter.d.ts +6 -6
  44. package/dist/providers/firecrawl/adapter.d.ts +5 -5
  45. package/dist/providers/gemini/adapter.d.ts +5 -10
  46. package/dist/providers/keenable/adapter.d.ts +2 -3
  47. package/dist/providers/linkup/adapter.d.ts +5 -5
  48. package/dist/providers/ollama/adapter.d.ts +4 -4
  49. package/dist/providers/openai/adapter.d.ts +4 -4
  50. package/dist/providers/openai/types.d.ts +2 -4
  51. package/dist/providers/parallel/adapter.d.ts +4 -4
  52. package/dist/providers/perplexity/adapter.d.ts +4 -5
  53. package/dist/providers/registry.d.ts +1 -0
  54. package/dist/providers/serpbase/types.d.ts +2 -4
  55. package/dist/providers/serper/adapter.d.ts +2 -2
  56. package/dist/providers/serper/types.d.ts +2 -4
  57. package/dist/providers/shared.d.ts +50 -0
  58. package/dist/providers/sofya/adapter.d.ts +6 -6
  59. package/dist/providers/tapline/adapter.d.ts +4 -0
  60. package/dist/providers/tapline/definition.d.ts +1 -0
  61. package/dist/providers/tavily/adapter.d.ts +4 -4
  62. package/dist/providers/valyu/adapter.d.ts +6 -6
  63. package/dist/providers/youcom/adapter.d.ts +2 -3
  64. package/dist/runtime/duration.d.ts +2 -0
  65. package/dist/runtime/execute.d.ts +3 -1
  66. package/dist/runtime/lifecycle.d.ts +0 -1
  67. package/dist/runtime/outward.d.ts +6 -1
  68. package/dist/runtime/polling.d.ts +2 -3
  69. package/docs/provider.md +29 -0
  70. package/package.json +14 -20
  71. package/dist/adapter-44ZBIK47.js +0 -121
  72. package/dist/adapter-57MELLYI.js +0 -160
  73. package/dist/adapter-D4EXZEDL.js +0 -213
  74. package/dist/adapter-DJCTEEOA.js +0 -159
  75. package/dist/adapter-DLNMW34W.js +0 -214
  76. package/dist/adapter-RR55EZAW.js +0 -73
  77. package/dist/chunk-FSTCLBSF.js +0 -76
  78. package/dist/chunk-I2UIACY3.js +0 -12
  79. package/dist/chunk-KMUCUJVN.js +0 -251
  80. package/dist/chunk-TYJ6RHKB.js +0 -31
  81. package/dist/chunk-VVOQKYOP.js +0 -112
  82. package/dist/contents.d.ts +0 -24
  83. package/dist/providers/brave/types.d.ts +0 -4
  84. package/dist/providers/exa/types.d.ts +0 -4
  85. package/dist/providers/firecrawl/types.d.ts +0 -4
  86. package/dist/providers/gemini/types.d.ts +0 -3
  87. package/dist/providers/keenable/types.d.ts +0 -4
  88. package/dist/providers/linkup/types.d.ts +0 -4
  89. package/dist/providers/ollama/types.d.ts +0 -4
  90. package/dist/providers/parallel/types.d.ts +0 -4
  91. package/dist/providers/perplexity/types.d.ts +0 -4
  92. package/dist/providers/sofya/types.d.ts +0 -4
  93. package/dist/providers/tavily/types.d.ts +0 -4
  94. package/dist/providers/valyu/types.d.ts +0 -4
  95. package/dist/providers/youcom/types.d.ts +0 -4
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  executeAsyncResearch
3
- } from "./chunk-LDVDVA4Z.js";
4
- import "./chunk-I2UIACY3.js";
5
- import "./chunk-WCTOYZVB.js";
3
+ } from "./chunk-I4HLGP7F.js";
4
+ import "./chunk-6UC3ZBNK.js";
5
+ import {
6
+ readNonEmptyString,
7
+ requireApiKey
8
+ } from "./chunk-U4I3X7IN.js";
6
9
  import {
7
10
  httpError
8
11
  } from "./chunk-U4BLULLV.js";
@@ -10,19 +13,19 @@ import {
10
13
  // src/providers/gemini/adapter.ts
11
14
  var DEFAULT_ANSWER_MODEL = "gemini-3.8-flash";
12
15
  var DEFAULT_RESEARCH_AGENT = "deep-research-preview-04-2026";
13
- var geminiImplementation = {
14
- async answer(query, config, context, options) {
15
- const request = buildGeminiGenerateContentRequest({
16
+ var adapter = {
17
+ async answer(request, config, context) {
18
+ const built = buildGeminiGenerateContentRequest({
16
19
  defaultModel: DEFAULT_ANSWER_MODEL,
17
- prompt: query,
18
- options,
20
+ prompt: request.query,
21
+ options: request.options,
19
22
  toolConfig: { googleSearch: {} }
20
23
  });
21
24
  const response = await requestGemini(
22
- `models/${encodeURIComponent(request.model.replace(/^models\//, ""))}:generateContent`,
25
+ `models/${encodeURIComponent(built.model.replace(/^models\//, ""))}:generateContent`,
23
26
  config,
24
27
  context,
25
- request.body
28
+ built.body
26
29
  );
27
30
  const candidate = Array.isArray(response.candidates) ? asRecord(response.candidates[0]) : {};
28
31
  const parts = asRecord(candidate.content).parts;
@@ -30,89 +33,85 @@ var geminiImplementation = {
30
33
  (part) => isPlainObject(part) && !part.thought && typeof part.text === "string"
31
34
  ).map((part) => part.text).join("").trim() : "";
32
35
  return {
33
- provider: "gemini",
34
36
  text,
35
37
  sources: extractGroundingSources(
36
38
  asRecord(candidate.groundingMetadata).groundingChunks
37
39
  )
38
40
  };
39
41
  },
40
- async research(input, config, context, options) {
42
+ async research(request, config, context) {
41
43
  return await executeAsyncResearch({
42
44
  providerLabel: "Gemini",
43
- providerId: "gemini",
44
45
  context,
45
- start: (researchContext) => this.startResearch(input, config, researchContext, options),
46
- poll: (id, researchContext) => this.pollResearch(id, config, researchContext, options)
46
+ start: (researchContext) => startResearch(request.input, config, researchContext, request.options),
47
+ poll: (id, researchContext) => pollResearch(id, config, researchContext)
47
48
  });
48
- },
49
- async startResearch(input, config, context, options) {
50
- const requestOptions = getGeminiResearchRequestOptions(options);
51
- const interaction = await requestGemini(
52
- "interactions",
53
- config,
54
- context,
55
- {
56
- ...requestOptions,
57
- input,
58
- agent: DEFAULT_RESEARCH_AGENT,
59
- background: true
60
- },
61
- context.idempotencyKey
62
- );
63
- const id = readNonEmptyString(interaction.id);
64
- if (!id) {
65
- throw new Error("Gemini research response is missing an interaction ID.");
66
- }
67
- return { id };
68
- },
69
- async pollResearch(id, config, context, _options) {
70
- const interaction = await requestGemini(
71
- `interactions/${encodeURIComponent(id)}`,
72
- config,
73
- context
74
- );
75
- const status = readNonEmptyString(interaction.status) ?? "unknown";
76
- if (status === "completed") {
77
- const text = formatInteractionSteps(readInteractionSteps(interaction));
78
- return {
79
- status: "completed",
80
- output: {
81
- provider: "gemini",
82
- text
83
- }
84
- };
85
- }
86
- if (status === "failed") {
87
- return {
88
- status: "failed",
89
- error: "research failed"
90
- };
91
- }
92
- if (status === "cancelled") {
93
- return {
94
- status: "cancelled",
95
- error: "research was canceled"
96
- };
97
- }
98
- if (status === "incomplete") {
99
- return {
100
- status: "failed",
101
- error: "research ended incomplete"
102
- };
103
- }
104
- if (status === "requires_action") {
105
- return {
106
- status: "failed",
107
- error: describeGeminiRequiredAction(readInteractionSteps(interaction))
108
- };
109
- }
110
- return status === "in_progress" ? { status: "in_progress" } : { status: "in_progress", statusText: status };
111
49
  }
112
50
  };
51
+ async function startResearch(input, config, context, options) {
52
+ const requestOptions = getGeminiResearchRequestOptions(options);
53
+ const interaction = await requestGemini(
54
+ "interactions",
55
+ config,
56
+ context,
57
+ {
58
+ ...requestOptions,
59
+ input,
60
+ agent: DEFAULT_RESEARCH_AGENT,
61
+ background: true
62
+ },
63
+ context.idempotencyKey
64
+ );
65
+ const id = readNonEmptyString(interaction.id);
66
+ if (!id) {
67
+ throw new Error("Gemini research response is missing an interaction ID.");
68
+ }
69
+ return { id };
70
+ }
71
+ async function pollResearch(id, config, context) {
72
+ const interaction = await requestGemini(
73
+ `interactions/${encodeURIComponent(id)}`,
74
+ config,
75
+ context
76
+ );
77
+ const status = readNonEmptyString(interaction.status) ?? "unknown";
78
+ if (status === "completed") {
79
+ const text = formatInteractionSteps(readInteractionSteps(interaction));
80
+ return {
81
+ status: "completed",
82
+ output: {
83
+ text
84
+ }
85
+ };
86
+ }
87
+ if (status === "failed") {
88
+ return {
89
+ status: "failed",
90
+ error: "research failed"
91
+ };
92
+ }
93
+ if (status === "cancelled") {
94
+ return {
95
+ status: "cancelled",
96
+ error: "research was canceled"
97
+ };
98
+ }
99
+ if (status === "incomplete") {
100
+ return {
101
+ status: "failed",
102
+ error: "research ended incomplete"
103
+ };
104
+ }
105
+ if (status === "requires_action") {
106
+ return {
107
+ status: "failed",
108
+ error: describeGeminiRequiredAction(readInteractionSteps(interaction))
109
+ };
110
+ }
111
+ return status === "in_progress" ? { status: "in_progress" } : { status: "in_progress", statusText: status };
112
+ }
113
113
  async function requestGemini(path, config, context, body, idempotencyKey) {
114
- const apiKey = config.credentials?.api;
115
- if (!apiKey) throw new Error("is missing an API key");
114
+ const apiKey = requireApiKey(config);
116
115
  const response = await fetch(
117
116
  `https://generativelanguage.googleapis.com/v1beta/${path}`,
118
117
  {
@@ -285,28 +284,8 @@ function getGeminiDeepResearchAgentConfig(value) {
285
284
  function isPlainObject(value) {
286
285
  return typeof value === "object" && value !== null && !Array.isArray(value);
287
286
  }
288
- function readNonEmptyString(value) {
289
- return typeof value === "string" && value.trim().length > 0 ? value : void 0;
290
- }
291
- var adapter = {
292
- async answer(input, config, context) {
293
- return await geminiImplementation.answer(
294
- input.query,
295
- config,
296
- context,
297
- input.options
298
- );
299
- },
300
- async research(input, config, context) {
301
- return await geminiImplementation.research(
302
- input.input,
303
- config,
304
- context,
305
- input.options
306
- );
307
- }
308
- };
309
287
  export {
310
288
  adapter,
311
- geminiImplementation
289
+ pollResearch,
290
+ startResearch
312
291
  };
@@ -1,7 +1,11 @@
1
1
  import {
2
2
  asJsonObject,
3
+ asRecord,
4
+ readInteger,
5
+ readString,
6
+ requireApiKey,
3
7
  trimSnippet
4
- } from "./chunk-FSTCLBSF.js";
8
+ } from "./chunk-U4I3X7IN.js";
5
9
  import {
6
10
  httpError
7
11
  } from "./chunk-U4BLULLV.js";
@@ -84,19 +88,16 @@ var CONTEXT_ARRAY_FIELDS = [
84
88
  "visualMatches",
85
89
  "suggestions"
86
90
  ];
87
- var serperImplementation = {
88
- async search(query, maxResults, config, context, options) {
89
- const apiKey = config.credentials?.api;
90
- if (!apiKey) {
91
- throw new Error("is missing an API key");
92
- }
93
- const callOptions = asJsonObject(options);
91
+ var adapter = {
92
+ async search(request, config, context) {
93
+ const apiKey = requireApiKey(config);
94
+ const callOptions = asJsonObject(request.options);
94
95
  const requestOptions = readRequestOptions({
95
96
  ...callOptions
96
97
  });
97
98
  const requestBody = buildRequestBody(
98
- query,
99
- clampMaxResults(maxResults),
99
+ request.query,
100
+ clampMaxResults(request.maxResults),
100
101
  requestOptions
101
102
  );
102
103
  const response = await fetch(joinUrl(config.baseUrl, requestOptions.mode), {
@@ -123,12 +124,11 @@ var serperImplementation = {
123
124
  requestOptions.mode
124
125
  );
125
126
  return {
126
- provider: "serper",
127
127
  results: results.map(
128
128
  (entry) => toSearchResult(entry, searchContext, requestOptions.mode)
129
129
  ).filter(
130
130
  (result) => result !== null
131
- ).slice(0, clampMaxResults(maxResults))
131
+ ).slice(0, clampMaxResults(request.maxResults))
132
132
  };
133
133
  }
134
134
  };
@@ -457,35 +457,15 @@ function omitUndefined(value) {
457
457
  Object.entries(value).filter(([, entry]) => entry !== void 0)
458
458
  );
459
459
  }
460
- function asRecord(value) {
461
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
462
- }
463
460
  function asArray(value) {
464
461
  return Array.isArray(value) ? value : void 0;
465
462
  }
466
- function readString(value) {
467
- return typeof value === "string" ? value : void 0;
468
- }
469
463
  function readNumber(value) {
470
464
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
471
465
  }
472
- function readInteger(value) {
473
- return typeof value === "number" && Number.isInteger(value) ? value : void 0;
474
- }
475
466
  function readBoolean(value) {
476
467
  return typeof value === "boolean" ? value : void 0;
477
468
  }
478
- var adapter = {
479
- async search(input, config, context) {
480
- return await serperImplementation.search(
481
- input.query,
482
- input.maxResults,
483
- config,
484
- context,
485
- input.options
486
- );
487
- }
488
- };
489
469
  export {
490
470
  adapter
491
471
  };
@@ -0,0 +1,84 @@
1
+ import {
2
+ PACKAGE_VERSION
3
+ } from "./chunk-HZVTFUBC.js";
4
+ import {
5
+ asRecord,
6
+ describeHttpError,
7
+ joinUrl,
8
+ readNonEmptyString,
9
+ requestJson,
10
+ requireApiKey,
11
+ trimSnippet
12
+ } from "./chunk-U4I3X7IN.js";
13
+ import {
14
+ WebfoxError
15
+ } from "./chunk-U4BLULLV.js";
16
+
17
+ // src/providers/tapline/adapter.ts
18
+ var DEFAULT_BASE_URL = "https://api.tapline.sh";
19
+ var adapter = {
20
+ async search(request, config, context) {
21
+ const options = request.options ?? {};
22
+ if (options.date_from === void 0 !== (options.date_to === void 0)) {
23
+ throw new WebfoxError(
24
+ "INVALID_INPUT",
25
+ "Tapline search needs both date_from and date_to for a published-date range."
26
+ );
27
+ }
28
+ const apiKey = requireApiKey(config, "api", "Tapline search");
29
+ const url = new URL(
30
+ joinUrl(config.baseUrl ?? DEFAULT_BASE_URL, "v1/brave-search/search")
31
+ );
32
+ url.searchParams.set("query", request.query);
33
+ for (const [key, value] of Object.entries(options)) {
34
+ if (value !== void 0) url.searchParams.set(key, String(value));
35
+ }
36
+ const payload = asRecord(
37
+ await requestJson(
38
+ url.toString(),
39
+ {
40
+ headers: {
41
+ "X-API-Key": apiKey,
42
+ "User-Agent": `webfox/${PACKAGE_VERSION}`
43
+ },
44
+ signal: context.signal
45
+ },
46
+ (body, response) => describeHttpError("Tapline search", body, response)
47
+ )
48
+ );
49
+ const entries = payload?.results;
50
+ if (!payload || !Array.isArray(entries)) {
51
+ throw new WebfoxError(
52
+ "PROVIDER_FAILURE",
53
+ "Tapline returned an invalid search response.",
54
+ { retryable: false }
55
+ );
56
+ }
57
+ const results = entries.map(toSearchResult).filter((result) => result !== void 0);
58
+ return { results: results.slice(0, request.maxResults) };
59
+ }
60
+ };
61
+ function toSearchResult(entry) {
62
+ const record = asRecord(entry);
63
+ const url = readNonEmptyString(record?.url);
64
+ if (!record || !url) return void 0;
65
+ const {
66
+ title,
67
+ url: _url,
68
+ description,
69
+ description_html: _descriptionHtml,
70
+ ...rest
71
+ } = record;
72
+ const metadata = Object.fromEntries(
73
+ Object.entries(rest).filter(([, value]) => value !== null)
74
+ );
75
+ return {
76
+ title: readNonEmptyString(title),
77
+ url,
78
+ snippet: trimSnippet(readNonEmptyString(description)),
79
+ ...Object.keys(metadata).length > 0 ? { metadata } : {}
80
+ };
81
+ }
82
+ export {
83
+ adapter
84
+ };
@@ -1,32 +1,31 @@
1
1
  import {
2
+ ambiguousContentsError,
2
3
  formatJson,
3
4
  joinUrl,
5
+ omittedContentsError,
6
+ pickSingleUrlOutcome,
4
7
  requestJson,
8
+ requireApiKey,
5
9
  trimSnippet
6
- } from "./chunk-FSTCLBSF.js";
7
- import {
8
- omittedContents,
9
- orderedContents
10
- } from "./chunk-TYJ6RHKB.js";
10
+ } from "./chunk-U4I3X7IN.js";
11
11
  import "./chunk-U4BLULLV.js";
12
12
 
13
13
  // src/providers/exa/adapter.ts
14
14
  var DEFAULT_BASE_URL = "https://api.exa.ai";
15
15
  var DEFAULT_MAX_CHARACTERS = 1e4;
16
- var exaImplementation = {
17
- async search(query, maxResults, config, context, searchOptions) {
16
+ var adapter = {
17
+ async search(request, config, context) {
18
18
  const response = await exaRequest(
19
19
  config,
20
20
  "/search",
21
- buildSearchBody(query, {
22
- ...searchOptions ?? {},
23
- numResults: maxResults
21
+ buildSearchBody(request.query, {
22
+ ...request.options ?? {},
23
+ numResults: request.maxResults
24
24
  }),
25
25
  context
26
26
  );
27
27
  return {
28
- provider: "exa",
29
- results: (response.results ?? []).slice(0, maxResults).map((result) => ({
28
+ results: (response.results ?? []).slice(0, request.maxResults).map((result) => ({
30
29
  title: typeof result.title === "string" ? result.title : void 0,
31
30
  url: String(result.url ?? ""),
32
31
  snippet: trimSnippet(
@@ -36,36 +35,31 @@ var exaImplementation = {
36
35
  }))
37
36
  };
38
37
  },
39
- async contents(urls, config, context, options) {
38
+ async contents(request, config, context) {
40
39
  const response = await exaRequest(
41
40
  config,
42
41
  "/contents",
43
- { urls, ...options ?? {} },
42
+ { urls: [request.url], ...request.options ?? {} },
44
43
  context
45
44
  );
46
- const results = response.results ?? [];
45
+ const outcome = pickSingleUrlOutcome(request.url, response.results ?? []);
46
+ if (outcome.kind === "omitted") throw omittedContentsError();
47
+ if (outcome.kind === "ambiguous") throw ambiguousContentsError();
48
+ const result = outcome.value;
47
49
  return {
48
- provider: "exa",
49
- answers: urls.map((url, index) => {
50
- const result = results[index];
51
- if (!result) {
52
- return omittedContents(url);
53
- }
54
- return {
55
- url: typeof result.url === "string" ? result.url : url,
56
- ...typeof result.text === "string" ? { content: result.text } : {},
57
- ...result.summary !== void 0 ? { summary: result.summary } : {},
58
- metadata: result
59
- };
60
- })
50
+ url: typeof result.url === "string" ? result.url : request.url,
51
+ ...typeof result.text === "string" ? { content: result.text } : {},
52
+ ...result.summary !== void 0 ? { summary: result.summary } : {},
53
+ metadata: result
61
54
  };
62
55
  },
63
- async answer(query, config, context, options) {
56
+ async answer(request, config, context) {
57
+ const options = request.options;
64
58
  const response = await exaRequest(
65
59
  config,
66
60
  "/answer",
67
61
  {
68
- query,
62
+ query: request.query,
69
63
  stream: false,
70
64
  text: options?.text ?? false,
71
65
  model: options?.model ?? "exa",
@@ -76,19 +70,18 @@ var exaImplementation = {
76
70
  context
77
71
  );
78
72
  return {
79
- provider: "exa",
80
73
  text: typeof response.answer === "string" ? response.answer : response.answer == null ? "" : formatJson(response.answer),
81
74
  sources: response.citations ?? []
82
75
  };
83
76
  },
84
- async research(input, config, context, options) {
77
+ async research(request, config, context) {
85
78
  context.signal?.throwIfAborted();
86
79
  context.onProgress?.("Exa is researching and synthesizing the report.");
87
80
  const result = await exaRequest(
88
81
  config,
89
82
  "/search",
90
- buildSearchBody(input, {
91
- ...options ?? {},
83
+ buildSearchBody(request.input, {
84
+ ...request.options ?? {},
92
85
  type: "deep-reasoning",
93
86
  outputSchema: {
94
87
  type: "text",
@@ -99,7 +92,6 @@ var exaImplementation = {
99
92
  );
100
93
  const content = result.output?.content;
101
94
  return {
102
- provider: "exa",
103
95
  text: typeof content === "string" ? content : "",
104
96
  sources: result.results ?? []
105
97
  };
@@ -121,10 +113,7 @@ function buildSearchBody(query, options) {
121
113
  return { query, ...rest };
122
114
  }
123
115
  async function exaRequest(config, path, body, context) {
124
- const apiKey = config.credentials?.api;
125
- if (!apiKey) {
126
- throw new Error("is missing an API key");
127
- }
116
+ const apiKey = requireApiKey(config);
128
117
  return await requestJson(
129
118
  joinUrl(config.baseUrl ?? DEFAULT_BASE_URL, path),
130
119
  { headers: { "x-api-key": apiKey }, body, signal: context.signal },
@@ -142,43 +131,6 @@ function readExaError(payload, response) {
142
131
  const message = parts.filter((part) => typeof part === "string" && part !== "").join(". ");
143
132
  return message || `Request failed with status ${response.status}.`;
144
133
  }
145
- var adapter = {
146
- async search(input, config, context) {
147
- return await exaImplementation.search(
148
- input.query,
149
- input.maxResults,
150
- config,
151
- context,
152
- input.options
153
- );
154
- },
155
- async contents(input, config, context) {
156
- return orderedContents(
157
- await exaImplementation.contents(
158
- input.urls,
159
- config,
160
- context,
161
- input.options
162
- )
163
- );
164
- },
165
- async answer(input, config, context) {
166
- return await exaImplementation.answer(
167
- input.query,
168
- config,
169
- context,
170
- input.options
171
- );
172
- },
173
- async research(input, config, context) {
174
- return await exaImplementation.research(
175
- input.input,
176
- config,
177
- context,
178
- input.options
179
- );
180
- }
181
- };
182
134
  export {
183
135
  adapter
184
136
  };