pi-web-providers 2.4.2 β†’ 3.0.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 (3) hide show
  1. package/README.md +129 -50
  2. package/dist/index.js +4156 -2354
  3. package/package.json +23 -21
package/README.md CHANGED
@@ -1,20 +1,21 @@
1
1
  # 🌍 pi-web-providers
2
2
 
3
3
  A _meta_ web extension for [pi](https://pi.dev) that routes search, content
4
- extraction, answers, and research through configurable per-tool providers, with
5
- explicit provider-specific option schemas for each managed tool.
4
+ extraction, quick grounded answers, and research through configurable per-tool
5
+ providers, with explicit provider-specific option schemas for each managed tool.
6
6
 
7
7
  ## Why?
8
8
 
9
9
  Most web extensions hard-wire a single backend. **pi-web-providers** lets you
10
10
  mix and match providers per tool instead, so `web_search`, `web_contents`,
11
11
  `web_answer`, and `web_research` can each use a different backend or be turned
12
- off entirely.
12
+ off entirely. Treat `web_answer` as a fast path for simple grounded questions,
13
+ not as a replacement for source inspection or deeper research.
13
14
 
14
15
  ## ✨ Features
15
16
 
16
- - **Multiple providers**: Claude, Cloudflare, Codex, Exa, Firecrawl,
17
- Gemini, Linkup, OpenAI, Perplexity, Parallel, Serper,
17
+ - **Multiple providers**: Brave, Claude, Cloudflare, Codex, Exa, Firecrawl,
18
+ Gemini, Linkup, Ollama, OpenAI, Perplexity, Parallel, Serper,
18
19
  [Tavily](https://tavily.com), Valyu
19
20
  - **Provider-aware tool options**: pi only exposes the provider settings that
20
21
  actually apply to the backend you selected, so tool calls are easier to
@@ -56,11 +57,13 @@ Each tool can be routed to any compatible provider:
56
57
 
57
58
  | Provider | search | contents | answer | research | Auth |
58
59
  | -------------- | :----: | :------: | :----: | :------: | ------------------------------------------------ |
60
+ | **Brave** | βœ” | | βœ” | βœ” | `BRAVE_SEARCH_API_KEY` / `BRAVE_ANSWERS_API_KEY` |
59
61
  | **Cloudflare** | | βœ” | | | `CLOUDFLARE_API_TOKEN` + `CLOUDFLARE_ACCOUNT_ID` |
60
62
  | **Exa** | βœ” | βœ” | βœ” | βœ” | `EXA_API_KEY` |
61
63
  | **Firecrawl** | βœ” | βœ” | | | `FIRECRAWL_API_KEY` |
62
64
  | **Gemini** | βœ” | | βœ” | βœ” | `GOOGLE_API_KEY` |
63
65
  | **Linkup** | βœ” | βœ” | | | `LINKUP_API_KEY` |
66
+ | **Ollama** | βœ” | βœ” | | | `OLLAMA_API_KEY` |
64
67
  | **OpenAI** | βœ” | | βœ” | βœ” | `OPENAI_API_KEY` |
65
68
  | **Parallel** | βœ” | βœ” | | | `PARALLEL_API_KEY` |
66
69
  | **Perplexity** | βœ” | | βœ” | βœ” | `PERPLEXITY_API_KEY` |
@@ -68,9 +71,8 @@ Each tool can be routed to any compatible provider:
68
71
  | **Tavily** | βœ” | βœ” | | | `TAVILY_API_KEY` |
69
72
  | **Valyu** | βœ” | βœ” | βœ” | βœ” | `VALYU_API_KEY` |
70
73
 
71
- Advanced option: `custom` is a configurable adapter provider that can route
72
- any managed tool through a local wrapper command using a JSON stdin/stdout
73
- contract.
74
+ Advanced option: `custom` can route any managed tool through a local wrapper
75
+ command using a JSON stdin/stdout contract.
74
76
 
75
77
  See [`example-config.json`](example-config.json) for the minimal default
76
78
  configuration.
@@ -82,7 +84,8 @@ Removing a tool mapping turns that tool off. A tool is only exposed when it is
82
84
  mapped to a compatible provider and that provider is currently available.
83
85
  Shared defaults and tool-specific settings live under `settings`; search-specific
84
86
  settings live under `settings.search`, and async research uses
85
- `settings.researchTimeoutMs`.
87
+ `settings.researchTimeoutMs`. Provider option schemas are strict: only the keys
88
+ shown for the active provider are accepted.
86
89
 
87
90
  #### `web_search`
88
91
 
@@ -94,18 +97,16 @@ results should arrive as soon as they are ready.
94
97
  <details>
95
98
  <summary><strong>Parameters and behavior</strong></summary>
96
99
 
97
- | Parameter | Type | Default | Description |
98
- | ------------ | -------- | -------- | ------------------------------------------------------------------------------------------ |
99
- | `queries` | string[] | required | One or more search queries to run (max 10) |
100
- | `maxResults` | integer | `5` | Result count per query, clamped to `1–20` |
101
- | `options` | object | β€” | `provider` settings exposed by the selected provider schema, plus local `runtime` settings |
100
+ | Parameter | Type | Default | Description |
101
+ | ------------ | -------- | -------- | ------------------------------------------------------------------ |
102
+ | `queries` | string[] | required | One or more search queries to run (max 10) |
103
+ | `maxResults` | integer | `5` | Result count per query, clamped to `1–20` |
104
+ | `options` | object | β€” | Provider-specific settings exposed by the selected provider schema |
102
105
 
103
- `web_search.options.runtime.prefetch` is local-only and is not forwarded to the
104
- provider SDK. It accepts `provider`, `maxUrls`, and `ttlMs`, and starts a
105
- background page-extraction workflow only when `prefetch.provider` is set.
106
- `/web-providers` can also persist default search prefetch settings under
107
- `settings.search`. Per-call retry and timeout overrides also live under
108
- `web_search.options.runtime`.
106
+ `options` is omitted when the configured search provider has no per-call
107
+ provider options. Runtime controls are not accepted in tool calls. Configure
108
+ retry, timeout, and background contents prefetch under `settings` and
109
+ `settings.search`; prefetch starts only when `settings.search.provider` is set.
109
110
 
110
111
  </details>
111
112
 
@@ -119,10 +120,10 @@ each page can be acted on independently.
119
120
  <details>
120
121
  <summary><strong>Parameters and behavior</strong></summary>
121
122
 
122
- | Parameter | Type | Default | Description |
123
- | --------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------- |
124
- | `urls` | string[] | required | One or more URLs to extract |
125
- | `options` | object | β€” | `provider` extraction settings exposed by the selected provider schema, plus optional local `runtime` overrides |
123
+ | Parameter | Type | Default | Description |
124
+ | --------- | -------- | -------- | ------------------------------------------------------------------ |
125
+ | `urls` | string[] | required | One or more URLs to extract |
126
+ | `options` | object | β€” | Provider-specific settings exposed by the selected provider schema |
126
127
 
127
128
  `web_contents` reuses any matching cached pages already present in the local
128
129
  in-memory cacheβ€”whether they came from prefetch or an earlier readβ€”and only
@@ -132,18 +133,24 @@ fetches missing or stale URLs.
132
133
 
133
134
  #### `web_answer`
134
135
 
135
- Answer one or more questions using web-grounded evidence. When you ask more
136
- than one question, the response is grouped into per-question sections. Batch
137
- related questions when the answers belong together; split them into sibling
138
- calls when earlier independent answers can unblock the next step.
136
+ Answer one or more simple factual questions using web-grounded evidence. Use it
137
+ as a lightweight shortcut when you want a concise grounded answer without
138
+ manually selecting and reading sources. Prefer `web_search` plus `web_contents`
139
+ when source selection matters or you need to inspect primary sources directly;
140
+ prefer `web_research` for open-ended, controversial, or multi-step
141
+ investigations.
142
+
143
+ When you ask more than one question, the response is grouped into per-question
144
+ sections. Batch related questions when the answers belong together; split them
145
+ into sibling calls when earlier independent answers can unblock the next step.
139
146
 
140
147
  <details>
141
148
  <summary><strong>Parameters and behavior</strong></summary>
142
149
 
143
- | Parameter | Type | Default | Description |
144
- | --------- | -------- | -------- | ---------------------------------------------------------------------------------------------------- |
145
- | `queries` | string[] | required | One or more questions to answer in one call (max 10) |
146
- | `options` | object | β€” | `provider` settings exposed by the selected provider schema, plus optional local `runtime` overrides |
150
+ | Parameter | Type | Default | Description |
151
+ | --------- | -------- | -------- | ------------------------------------------------------------------ |
152
+ | `queries` | string[] | required | One or more questions to answer in one call (max 10) |
153
+ | `options` | object | β€” | Provider-specific settings exposed by the selected provider schema |
147
154
 
148
155
  Responses are grouped into per-question sections when more than one question is
149
156
  provided.
@@ -160,15 +167,15 @@ saved report path.
160
167
  <details>
161
168
  <summary><strong>Parameters and behavior</strong></summary>
162
169
 
163
- | Parameter | Type | Default | Description |
164
- | --------- | ------ | -------- | ----------------------------------------------------------------------------- |
165
- | `input` | string | required | Research brief or question |
166
- | `options` | object | β€” | Provider-specific `provider` settings exposed by the selected provider schema |
170
+ | Parameter | Type | Default | Description |
171
+ | --------- | ------ | -------- | ------------------------------------------------------------------ |
172
+ | `input` | string | required | Research brief or question |
173
+ | `options` | object | β€” | Provider-specific settings exposed by the selected provider schema |
167
174
 
168
- `options.provider` is provider-specific. Equivalent concepts can use different
169
- field names across SDKsβ€”for example Perplexity uses `country`, Exa uses
170
- `userLocation`, and Valyu uses `countryCode`. Unlike the other managed tools,
171
- `web_research` does not support per-call `options.runtime` overrides.
175
+ `options` is provider-specific. Equivalent concepts can use different field
176
+ names across SDKsβ€”for example Perplexity uses `country`, Exa uses
177
+ `userLocation`, and Valyu uses `countryCode`. Runtime controls are not accepted
178
+ in tool calls.
172
179
 
173
180
  Unlike the other managed tools, `web_research` does not accept local timeout,
174
181
  retry, polling, or resume controls. Research has one opinionated execution
@@ -179,14 +186,49 @@ report under `.pi/artifacts/research/`.
179
186
 
180
187
  ### Providers
181
188
 
182
- The built-in providers below are thin adapters around official SDKs.
189
+ The built-in providers below integrate with official SDKs or documented APIs.
190
+
191
+ <details>
192
+ <summary><strong>Brave</strong></summary>
193
+
194
+ - API: Brave Search API and Brave Answers API
195
+ - Supports `web_search` via Web Search, plus optional `llm_context`, `news`, `videos`, `images`, and `places` search modes
196
+ - Supports `web_answer` and `web_research` via Brave Answers streaming chat completions
197
+ - `web_contents` stays routed to URL-fetch providers; Brave LLM Context is query-based retrieval and is exposed as a search mode instead
198
+ - Brave Answers may require a different key or plan than Brave Search
199
+
200
+ **Setup**
201
+
202
+ ```json
203
+ {
204
+ "tools": {
205
+ "search": "brave",
206
+ "answer": "brave",
207
+ "research": "brave"
208
+ },
209
+ "providers": {
210
+ "brave": {
211
+ "credentials": {
212
+ "search": "BRAVE_SEARCH_API_KEY",
213
+ "answers": "BRAVE_ANSWERS_API_KEY"
214
+ }
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ Use `providers.brave.options.search.mode` or per-call search options to select
221
+ `llm_context`, `news`, `videos`, `images`, or `places`. Places details and
222
+ descriptions are opt-in because they can add calls, latency, and place-specific
223
+ semantics.
224
+
225
+ </details>
183
226
 
184
227
  <details>
185
228
  <summary><strong>Claude</strong></summary>
186
229
 
187
230
  - SDK: `@anthropic-ai/claude-agent-sdk`
188
- - Uses Claude Code's built-in `WebSearch` and `WebFetch` tools behind a
189
- structured JSON adapter
231
+ - Uses Claude Code's built-in `WebSearch` and `WebFetch` tools with structured JSON output
190
232
  - Exposes `model`, `thinking`, `effort`, `maxThinkingTokens`, `maxTurns`, and
191
233
  `maxBudgetUsd` as provider options for search and answer calls
192
234
  - Great for search plus grounded answers if you already use Claude Code locally
@@ -219,7 +261,9 @@ The built-in providers below are thin adapters around official SDKs.
219
261
  },
220
262
  "providers": {
221
263
  "cloudflare": {
222
- "apiToken": "CLOUDFLARE_API_TOKEN",
264
+ "credentials": {
265
+ "api": "CLOUDFLARE_API_TOKEN"
266
+ },
223
267
  "accountId": "CLOUDFLARE_ACCOUNT_ID"
224
268
  }
225
269
  }
@@ -253,8 +297,7 @@ scope, or account ID is usually wrong.
253
297
  - Exposes search options such as `category`, `type`, date filters,
254
298
  `includeDomains`, `excludeDomains`, `userLocation`, and `contents`
255
299
  - Persisted Exa defaults are scoped under `providers.exa.options.search`
256
- - `web_contents`, `web_answer`, and `web_research` currently use fixed adapter
257
- behavior with no extra per-call provider options
300
+ - `web_contents`, `web_answer`, and `web_research` currently use fixed provider behavior with no extra per-call provider options
258
301
 
259
302
  </details>
260
303
 
@@ -302,6 +345,38 @@ scope, or account ID is usually wrong.
302
345
 
303
346
  </details>
304
347
 
348
+ <details>
349
+ <summary><strong>Ollama</strong></summary>
350
+
351
+ - API: [Ollama Web Search and Fetch API](https://docs.ollama.com/capabilities/web-search)
352
+ - Supports `web_search` via Ollama's `POST /api/web_search` endpoint
353
+ - Supports `web_contents` via Ollama's `POST /api/web_fetch` endpoint
354
+ - Authenticates with an Ollama API key using `OLLAMA_API_KEY` by default
355
+ - Optional `baseUrl` overrides the default `https://ollama.com` API host for
356
+ proxies or compatible endpoints
357
+ - Ollama caps search requests at 10 results, so `web_search.maxResults` is
358
+ clamped to `1–10` for this provider
359
+
360
+ Minimal config:
361
+
362
+ ```json
363
+ {
364
+ "tools": {
365
+ "search": "ollama",
366
+ "contents": "ollama"
367
+ },
368
+ "providers": {
369
+ "ollama": {
370
+ "credentials": {
371
+ "api": "OLLAMA_API_KEY"
372
+ }
373
+ }
374
+ }
375
+ }
376
+ ```
377
+
378
+ </details>
379
+
305
380
  <details>
306
381
  <summary><strong>OpenAI</strong></summary>
307
382
 
@@ -334,7 +409,9 @@ scope, or account ID is usually wrong.
334
409
  },
335
410
  "providers": {
336
411
  "openai": {
337
- "apiKey": "OPENAI_API_KEY",
412
+ "credentials": {
413
+ "api": "OPENAI_API_KEY"
414
+ },
338
415
  "options": {
339
416
  "search": {
340
417
  "model": "gpt-4.1"
@@ -405,7 +482,9 @@ Minimal config:
405
482
  },
406
483
  "providers": {
407
484
  "serper": {
408
- "apiKey": "SERPER_API_KEY"
485
+ "credentials": {
486
+ "api": "SERPER_API_KEY"
487
+ }
409
488
  }
410
489
  }
411
490
  }
@@ -439,7 +518,7 @@ Minimal config:
439
518
  - Exposes answer and research options `responseLength` and `countryCode`
440
519
  - Persisted Valyu defaults are scoped under `providers.valyu.options.search`,
441
520
  `providers.valyu.options.answer`, and `providers.valyu.options.research`
442
- - `web_contents` currently uses fixed adapter behavior with no extra per-call
521
+ - `web_contents` currently uses fixed provider behavior with no extra per-call
443
522
  provider options
444
523
 
445
524
  </details>
@@ -450,7 +529,7 @@ The `custom` provider lets you bring your own wrapper command for any
450
529
  managed tool. Each capability can point at a different local command under
451
530
  `providers["custom"].options`.
452
531
 
453
- `custom` does not expose standard per-call `options.provider` fields. Put
532
+ `custom` does not expose standard per-call `options` fields. Put
454
533
  provider-specific behavior in the wrapper configuration or in the wrapper
455
534
  implementation.
456
535