pi-web-providers 0.1.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.
Files changed (3) hide show
  1. package/README.md +118 -41
  2. package/dist/index.js +1669 -324
  3. package/package.json +9 -4
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 🌍 pi-web-providers
2
2
 
3
- A *meta* web extension for [pi](https://pi.dev).
3
+ A _meta_ web extension for [pi](https://pi.dev).
4
4
 
5
5
  ## Why?
6
6
 
@@ -18,16 +18,23 @@ only the tools that make sense. If your active provider offers search and
18
18
  content extraction but not deep research, the agent never sees a research tool.
19
19
  Switch to a provider that supports it and the tool appears automatically.
20
20
 
21
+ The extension also separates **available tools** from the **active tool set**.
22
+ When a session starts, it can add every available managed tool. Before each
23
+ agent run, it removes tools that are no longer available but keeps any managed
24
+ tools that you explicitly removed from the active set disabled. That keeps the
25
+ tool prompt aligned with the tools that the agent can actually call.
26
+
21
27
  ## ✨ Features
22
28
 
23
29
  - **Provider-driven tool surface** — tools are injected based on what the active
24
30
  provider actually supports, not a fixed list
25
- - **Five providers**: Codex, Exa, Gemini, Parallel, Valyu — each with its own
26
- SDK, strengths, and capability set
31
+ - **Multiple providers**: Claude, Codex, Exa, Gemini, Perplexity, Parallel,
32
+ Valyu each with
33
+ its own SDK, strengths, and capability set
27
34
  - **One config command** (`/web-providers`) with a TUI that adapts to the
28
35
  selected provider
29
- - **Transparent fallback** — if no provider is explicitly enabled, the extension
30
- walks the list alphabetically and picks the first one that is available
36
+ - **Transparent fallback** — search falls back to Codex when no provider is
37
+ explicitly enabled and the local CLI is installed and authenticated
31
38
  - **Per-provider tool toggles** — disable individual capabilities you don't need
32
39
  without switching providers
33
40
  - **Truncated output with temp-file spillover** for large results
@@ -51,8 +58,9 @@ This command edits a single global config file:
51
58
 
52
59
  The flow is provider-first: pick the active provider, then configure only that
53
60
  provider's tool toggles and settings. Each provider view surfaces the knobs that
54
- actually apply—Codex shows reasoning-effort and web-search-mode toggles; Exa
55
- shows search type and text-content flags; and so on.
61
+ actually apply—Claude shows model/effort/turns settings; Codex shows
62
+ reasoning-effort and web-search-mode toggles; Exa shows search type and
63
+ text-content flags; and so on.
56
64
 
57
65
  ## 🔧 Tools
58
66
 
@@ -62,61 +70,80 @@ corresponding tool is never exposed to the agent.
62
70
 
63
71
  ### `web_search`
64
72
 
65
- Search the web and return titles, URLs, and snippets.
73
+ Find likely sources on the public web and return titles, URLs, and snippets.
66
74
 
67
- | Parameter | Type | Default | Description |
68
- |-----------|------|---------|-------------|
69
- | `query` | string | required | What to search for |
70
- | `maxResults` | integer | `5` | Result count, clamped to `1–20` |
71
- | `provider` | string | auto | Optional override: `codex`, `exa`, `gemini`, `parallel`, or `valyu` |
75
+ | Parameter | Type | Default | Description |
76
+ | ------------ | ------- | -------- | ----------------------------------------------------------------------------- |
77
+ | `query` | string | required | What to search for |
78
+ | `maxResults` | integer | `5` | Result count, clamped to `1–20` |
79
+ | `options` | object | | Provider-specific search options |
80
+ | `provider` | string | auto | Optional override: `claude`, `codex`, `exa`, `gemini`, `perplexity`, `parallel`, or `valyu` |
72
81
 
73
82
  ### `web_contents`
74
83
 
75
- Extract contents for one or more URLs.
84
+ Read and extract the main contents of one or more web pages.
76
85
 
77
- | Parameter | Type | Default | Description |
78
- |-----------|------|---------|-------------|
79
- | `urls` | string[] | required | One or more URLs to extract |
80
- | `options` | object | — | Provider-specific extraction options |
81
- | `provider` | string | auto | Optional override among providers that support contents |
86
+ | Parameter | Type | Default | Description |
87
+ | ---------- | -------- | -------- | ------------------------------------------------------- |
88
+ | `urls` | string[] | required | One or more URLs to extract |
89
+ | `options` | object | — | Provider-specific extraction options |
90
+ | `provider` | string | auto | Optional override among providers that support contents |
82
91
 
83
92
  ### `web_answer`
84
93
 
85
- Get a provider-generated answer grounded in search results.
94
+ Answer a question using web-grounded evidence.
86
95
 
87
- | Parameter | Type | Default | Description |
88
- |-----------|------|---------|-------------|
89
- | `query` | string | required | Question to answer |
90
- | `options` | object | — | Provider-specific answer options |
91
- | `provider` | string | auto | Optional override among providers that support answers |
96
+ | Parameter | Type | Default | Description |
97
+ | ---------- | ------ | -------- | ------------------------------------------------------ |
98
+ | `query` | string | required | Question to answer |
99
+ | `options` | object | — | Provider-specific answer options |
100
+ | `provider` | string | auto | Optional override among providers that support answers |
92
101
 
93
102
  ### `web_research`
94
103
 
95
- Run a longer-form research task.
104
+ Investigate a topic across web sources and produce a longer report.
105
+
106
+ | Parameter | Type | Default | Description |
107
+ | ---------- | ------ | -------- | ------------------------------------------------------- |
108
+ | `input` | string | required | Research brief or question |
109
+ | `options` | object | — | Provider-specific research options |
110
+ | `provider` | string | auto | Optional override among providers that support research |
96
111
 
97
- | Parameter | Type | Default | Description |
98
- |-----------|------|---------|-------------|
99
- | `input` | string | required | Research brief or question |
100
- | `options` | object | | Provider-specific research options |
101
- | `provider` | string | auto | Optional override among providers that support research |
112
+ `options` are provider-native and provider-specific. Equivalent concepts can
113
+ use different field names across SDKs, for example Perplexity uses `country`,
114
+ Exa uses `userLocation`, and Valyu uses `countryCode`. Runtime `options`
115
+ override provider defaults, but managed tool inputs and tool wiring stay fixed.
102
116
 
103
117
  ## 🔌 Providers
104
118
 
105
119
  Every provider is a thin adapter around an official SDK. The table below
106
120
  summarises which capabilities each provider exposes:
107
121
 
108
- | Provider | search | contents | answer | research | Auth |
109
- |----------|:------:|:--------:|:------:|:--------:|------|
110
- | **Codex** | | | | | Local Codex CLI auth |
111
- | **Exa** | ||| | `EXA_API_KEY` |
112
- | **Gemini** | | | | | `GOOGLE_API_KEY` |
113
- | **Parallel** | | | | | `PARALLEL_API_KEY` |
114
- | **Valyu** | ✓ || | | `VALYU_API_KEY` |
122
+ | Provider | search | contents | answer | research | Auth |
123
+ | ------------ | :----: | :------: | :----: | :------: | ---------------------- |
124
+ | **Claude** | | || | Local Claude Code auth |
125
+ | **Codex** | | | | | Local Codex CLI auth |
126
+ | **Exa** | || | | `EXA_API_KEY` |
127
+ | **Gemini** | | ||| `GOOGLE_API_KEY` |
128
+ | **Perplexity** | ✓ | | | | `PERPLEXITY_API_KEY` |
129
+ | **Parallel** | ✓ | ✓ | | | `PARALLEL_API_KEY` |
130
+ | **Valyu** | ✓ | ✓ | ✓ | ✓ | `VALYU_API_KEY` |
131
+
132
+ ### Claude
133
+
134
+ - SDK: `@anthropic-ai/claude-agent-sdk`
135
+ - Uses Claude Code's built-in `WebSearch` and `WebFetch` tools behind a
136
+ structured JSON adapter
137
+ - Supports request-shaping `options` such as `model`, `thinking`, `effort`, and
138
+ `maxTurns`
139
+ - Great for search plus grounded answers if you already use Claude Code locally
115
140
 
116
141
  ### Codex
117
142
 
118
143
  - SDK: `@openai/codex-sdk`
119
144
  - Runs in read-only mode with web search enabled
145
+ - Supports request-shaping `web_search.options` such as `model`,
146
+ `modelReasoningEffort`, and `webSearchMode`
120
147
  - Best if you already use the local Codex CLI and auth flow
121
148
 
122
149
  ### Exa
@@ -128,18 +155,32 @@ summarises which capabilities each provider exposes:
128
155
  ### Gemini
129
156
 
130
157
  - SDK: `@google/genai`
131
- - Grounded answers and deep-research agents via Google's Gemini API
158
+ - Google Search grounding for answers and URL Context extraction for page contents
159
+ - Deep-research agents via Google's Gemini API
160
+ - Supports provider-native request options such as `model`, `config`,
161
+ `generation_config`, and `agent_config` depending on the tool
162
+
163
+ ### Perplexity
164
+
165
+ - SDK: `@perplexity-ai/perplexity_ai`
166
+ - Uses Perplexity Search for `web_search`
167
+ - Uses Sonar for `web_answer` and `sonar-deep-research` for `web_research`
168
+ - Supports provider-specific `web_search.options` such as `country`,
169
+ `search_mode`, `search_domain_filter`, and `search_recency_filter`
132
170
 
133
171
  ### Parallel
134
172
 
135
173
  - SDK: `parallel-web`
136
174
  - Agentic and one-shot search modes
137
175
  - Page content extraction with excerpt and full-content toggles
176
+ - Supports provider-native search and extraction options from the Parallel SDK
138
177
 
139
178
  ### Valyu
140
179
 
141
180
  - SDK: `valyu-js`
142
181
  - Web, proprietary, and news search types
182
+ - Supports provider-native options such as `countryCode`, `responseLength`, and
183
+ search/source filters
143
184
  - Configurable response length for answers and research
144
185
 
145
186
  ## 📝 Config Notes
@@ -148,8 +189,15 @@ summarises which capabilities each provider exposes:
148
189
  for the selected provider and `enabled: false` for the others
149
190
  - Each provider can also enable or disable its individual tools through a `tools`
150
191
  block
151
- - If a config has no explicitly enabled provider, the extension falls back to the
152
- first available provider alphabetically
192
+ - Managed tools are registered from available provider capabilities, but the
193
+ active tool set can still be narrower if you removed a tool from the session
194
+ - If no provider is explicitly enabled for search, the extension falls back to
195
+ Codex when the local CLI is installed and authenticated, unless Codex was
196
+ explicitly configured as disabled
197
+ - Tools stay inactive when no provider is available for their capability, so
198
+ they are not injected into the LLM prompt
199
+ - Before each agent run, the extension removes newly unavailable managed tools
200
+ and keeps manually pruned managed tools inactive instead of re-adding them
153
201
  - Secret-like values can be:
154
202
  - literal strings
155
203
  - environment variable names such as `EXA_API_KEY`
@@ -161,6 +209,13 @@ Example:
161
209
  {
162
210
  "version": 1,
163
211
  "providers": {
212
+ "claude": {
213
+ "enabled": false,
214
+ "tools": {
215
+ "search": true,
216
+ "answer": true
217
+ }
218
+ },
164
219
  "codex": {
165
220
  "enabled": true,
166
221
  "tools": {
@@ -191,16 +246,38 @@ Example:
191
246
  "enabled": false,
192
247
  "tools": {
193
248
  "search": true,
249
+ "contents": true,
194
250
  "answer": true,
195
251
  "research": true
196
252
  },
197
253
  "apiKey": "GOOGLE_API_KEY",
198
254
  "defaults": {
199
255
  "searchModel": "gemini-2.5-flash",
256
+ "contentsModel": "gemini-2.5-flash",
200
257
  "answerModel": "gemini-2.5-flash",
201
258
  "researchAgent": "deep-research-pro-preview-12-2025"
202
259
  }
203
260
  },
261
+ "perplexity": {
262
+ "enabled": false,
263
+ "tools": {
264
+ "search": true,
265
+ "answer": true,
266
+ "research": true
267
+ },
268
+ "apiKey": "PERPLEXITY_API_KEY",
269
+ "defaults": {
270
+ "search": {
271
+ "country": "US"
272
+ },
273
+ "answer": {
274
+ "model": "sonar"
275
+ },
276
+ "research": {
277
+ "model": "sonar-deep-research"
278
+ }
279
+ }
280
+ },
204
281
  "parallel": {
205
282
  "enabled": false,
206
283
  "tools": {