pi-web-providers 1.0.0 → 1.1.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 CHANGED
@@ -12,8 +12,8 @@ off entirely.
12
12
 
13
13
  ## ✨ Features
14
14
 
15
- - **Multiple providers** — Claude, Codex, Exa, Gemini, Perplexity, Parallel,
16
- Valyu
15
+ - **Multiple providers** — Claude, Codex, Custom CLI, Exa, Gemini,
16
+ Perplexity, Parallel, Valyu
17
17
  - **Batched search and answers** — run several related queries in a single
18
18
  `web_search` or `web_answer` call and get grouped results back in one response
19
19
  - **Async contents prefetch** — optionally start background `web_contents`
@@ -49,6 +49,10 @@ Each tool can be routed to any compatible provider:
49
49
  | **Parallel** | ✔ | ✔ | | | `PARALLEL_API_KEY` |
50
50
  | **Valyu** | ✔ | ✔ | ✔ | ✔ | `VALYU_API_KEY` |
51
51
 
52
+ Advanced option: `custom-cli` is a configurable adapter provider that can route
53
+ any managed tool through a local wrapper command using a JSON stdin/stdout
54
+ contract.
55
+
52
56
  See [`example-config.json`](example-config.json) for a full default
53
57
  configuration.
54
58
 
@@ -61,14 +65,17 @@ and that provider is currently available. Tool-specific settings live under
61
65
 
62
66
  #### `web_search`
63
67
 
64
- Find likely sources on the public web for up to 10 queries in a single call
65
- and return titles, URLs, and snippets grouped by query.
68
+ Search the public web for up to 10 queries in one call. It returns grouped
69
+ titles, URLs, and snippets for each query.
70
+
71
+ <details>
72
+ <summary><strong>Parameters and behavior</strong></summary>
66
73
 
67
- | Parameter | Type | Default | Description |
68
- | ------------ | -------- | -------- | -------------------------------------------------------------------- |
69
- | `queries` | string[] | required | One or more search queries to run (max 10) |
70
- | `maxResults` | integer | `5` | Result count per query, clamped to `1–20` |
71
- | `options` | object | — | Provider-specific search options plus local `prefetch` orchestration |
74
+ | Parameter | Type | Default | Description |
75
+ | ------------ | -------- | -------- | -------------------------------------------------------------- |
76
+ | `queries` | string[] | required | One or more search queries to run (max 10) |
77
+ | `maxResults` | integer | `5` | Result count per query, clamped to `1–20` |
78
+ | `options` | object | — | Provider-specific search options and local `prefetch` settings |
72
79
 
73
80
  `web_search.options.prefetch` is local-only and not forwarded into the provider
74
81
  SDK. It accepts `provider`, `maxUrls`, `ttlMs`, and `contentsOptions`, and
@@ -76,9 +83,15 @@ starts a background page-extraction workflow only when `prefetch.provider` is
76
83
  set. `/web-providers` can also persist default search prefetch settings under
77
84
  `toolSettings.search.prefetch`.
78
85
 
86
+ </details>
87
+
79
88
  #### `web_contents`
80
89
 
81
- Read and extract the main contents of one or more web pages.
90
+ Read the main text from one or more web pages. It reuses cached pages when they
91
+ match and fetches only missing or stale URLs.
92
+
93
+ <details>
94
+ <summary><strong>Parameters and behavior</strong></summary>
82
95
 
83
96
  | Parameter | Type | Default | Description |
84
97
  | --------- | -------- | -------- | ------------------------------------ |
@@ -89,20 +102,34 @@ Read and extract the main contents of one or more web pages.
89
102
  content store—whether they came from prefetch or an earlier read—and only
90
103
  fetches missing or stale URLs.
91
104
 
105
+ </details>
106
+
92
107
  #### `web_answer`
93
108
 
94
- Answer one or more questions using web-grounded evidence.
109
+ Answer one or more questions using web-grounded evidence. When you ask more
110
+ than one question, the response is grouped into per-question sections.
111
+
112
+ <details>
113
+ <summary><strong>Parameters and behavior</strong></summary>
95
114
 
96
115
  | Parameter | Type | Default | Description |
97
116
  | --------- | -------- | -------- | ---------------------------------------------------- |
98
117
  | `queries` | string[] | required | One or more questions to answer in one call (max 10) |
99
118
  | `options` | object | — | Provider-specific options |
100
119
 
101
- Responses are grouped into per-question sections when more than one question is provided.
120
+ Responses are grouped into per-question sections when more than one question is
121
+ provided.
122
+
123
+ </details>
102
124
 
103
125
  #### `web_research`
104
126
 
105
- Investigate a topic across web sources and produce a longer report.
127
+ Investigate a topic across web sources and produce a longer report. The
128
+ provider-specific `options` stay native to each SDK, and runtime options
129
+ override provider configuration when both are set.
130
+
131
+ <details>
132
+ <summary><strong>Parameters and behavior</strong></summary>
106
133
 
107
134
  | Parameter | Type | Default | Description |
108
135
  | --------- | ------ | -------- | -------------------------- |
@@ -114,6 +141,8 @@ different field names across SDKs—for example Perplexity uses `country`, Exa
114
141
  uses `userLocation`, and Valyu uses `countryCode`. Runtime `options` override
115
142
  provider-native config, but managed tool inputs and tool wiring stay fixed.
116
143
 
144
+ </details>
145
+
117
146
  <details>
118
147
  <summary><strong>Timeout, retry, and delivery modes</strong></summary>
119
148
 
@@ -140,13 +169,7 @@ Providers deliver results in one of three modes:
140
169
 
141
170
  ### Providers
142
171
 
143
- Every provider is a thin adapter around an official SDK. Each provider has an
144
- `enabled` toggle that controls whether it is eligible for tool mappings.
145
- Provider config is split into `native` settings (forwarded to the SDK) and
146
- `policy` settings (local overrides that take precedence over generic settings);
147
- legacy `defaults` blocks are still accepted when reading. Secret-like values
148
- can be literal strings, environment variable names (e.g., `EXA_API_KEY`), or
149
- shell commands prefixed with `!`.
172
+ The built-in providers below are thin adapters around official SDKs.
150
173
 
151
174
  <details>
152
175
  <summary><strong>Claude</strong></summary>
@@ -234,6 +257,87 @@ shell commands prefixed with `!`.
234
257
 
235
258
  </details>
236
259
 
260
+ ### Custom CLI provider
261
+
262
+ The `custom-cli` provider lets you bring your own wrapper command for any
263
+ managed tool. Each capability can point at a different local command under
264
+ `providers["custom-cli"].native`.
265
+
266
+ The repo includes actual wrapper examples under
267
+ [`examples/custom-cli/wrappers/`](examples/custom-cli/wrappers/). They are
268
+ small bash scripts that use `jq` for JSON handling. Each one uses a different
269
+ backend pattern:
270
+
271
+ - `codex --search exec` for `web_search`
272
+ - Gemini API via `curl` for `web_contents`
273
+ - `claude -p` for `web_answer`
274
+ - Perplexity API via `curl` for `web_research`
275
+
276
+ <details>
277
+ <summary><strong>Configuration example</strong></summary>
278
+
279
+ Copy the example wrappers into a local `./wrappers/` directory, then configure:
280
+
281
+ ```json
282
+ {
283
+ "tools": {
284
+ "search": "custom-cli",
285
+ "contents": "custom-cli",
286
+ "answer": "custom-cli",
287
+ "research": "custom-cli"
288
+ },
289
+ "providers": {
290
+ "custom-cli": {
291
+ "enabled": true,
292
+ "native": {
293
+ "search": {
294
+ "argv": ["bash", "./wrappers/codex-search.sh"]
295
+ },
296
+ "contents": {
297
+ "argv": ["bash", "./wrappers/gemini-contents.sh"]
298
+ },
299
+ "answer": {
300
+ "argv": ["bash", "./wrappers/claude-answer.sh"]
301
+ },
302
+ "research": {
303
+ "argv": ["bash", "./wrappers/perplexity-research.sh"]
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+ ```
310
+
311
+ Those example wrappers deliberately use different local CLIs and APIs so you
312
+ can see several wrapper styles in one setup without extra glue code.
313
+
314
+ Each capability can also set an optional `cwd` and `env` block. Use `cwd` when
315
+ one wrapper must run from a specific directory. Use `env` for per-command
316
+ variables; each value can be a literal string, an environment variable name, or
317
+ `!command`.
318
+
319
+ `web_research` runs as a foreground wrapper command, so local polling controls
320
+ (`pollIntervalMs`, `timeoutMs`, `maxConsecutivePollErrors`) and `resumeId` do
321
+ not apply to `custom-cli`.
322
+
323
+ Wrapper contract:
324
+
325
+ - `stdin`: one JSON request object with `capability` plus the per-call managed
326
+ inputs (`query`, `urls`, `input`, `maxResults`, `options`, `cwd`)
327
+ - `stdout`: one JSON response object
328
+ - `search`: `{ "results": [{ "title", "url", "snippet" }] }`
329
+ - `contents` / `answer` / `research`: `{ "text": "...", "summary"?: "...", "itemCount"?: 1, "metadata"?: {} }`
330
+ - `stderr`: optional progress lines
331
+ - exit code `0`: success
332
+ - non-zero exit code: failure
333
+
334
+ </details>
335
+
336
+ See [`examples/custom-cli/README.md`](examples/custom-cli/README.md) for a
337
+ copy-and-pasteable setup, and see
338
+ [`examples/custom-cli/wrappers/`](examples/custom-cli/wrappers/) for the actual
339
+ wrapper files.
340
+
237
341
  ### Generic settings
238
342
 
239
343
  The `genericSettings` block sets shared execution defaults that apply to all
@@ -248,13 +352,6 @@ providers unless overridden in a provider's `policy` block:
248
352
  | `researchTimeoutMs` | `21600000` | Overall deadline for research before returning |
249
353
  | `researchMaxConsecutivePollErrors` | `3` | Consecutive poll failures before stopping |
250
354
 
251
- ## 🛠️ Development
252
-
253
- ```bash
254
- npm run check
255
- npm test
256
- ```
257
-
258
355
  ## 📄 License
259
356
 
260
357
  [MIT](LICENSE)